<commit_before><?php

namespace atk4\ui;

/**
 * Implement popup view.
 *
 * Popup are views that will be display when triggered by another view.
 *
 * Popup can add content statically or dynamically via a callback.
 *
 * When adding a popup to the page, you need to specify it's trigger element
 * and the event needed on the trigger element in order to display the popup.
 */
class Popup extends View
{
    public $ui = 'popup';

    /**
     * The view activating the popup.
     * Usually the view where popup is attached to,
     * unless target is supply.
     *
     * @var View|string|null Object view or a string id.
     */
    public $triggerBy = null;

    /**
     * Js event that trigger the popup.
     *
     * @var string
     */
    public $triggerOn = null;

    /**
     * Default position of the popup in relation to target element.
     *
     * @var string
     */
    public $position = 'top left';

    /**
     * When set to false, target is the triggerBy element.
     * Otherwise, you can supply a View object where popup will be shown.
     *
     * @var View|bool
     */
    public $target = false;

    /**
     * Popup options as defined in semantic-ui popup module.
     *
     * @var array
     */
    public $popOptions = [];

    /**
     * The callback use to generate dynamic content.
     *
     * @var Callback|null
     */
    public $cb = null;

    /**
     * The dynamic View to load inside the popup
     * when dynamic content is use.
     *
     * Default to 'View'.
     *
     * @var View|string
     */
    public $dynamicContent = 'View';

    /**
     * Whether or not dynamic content is cache.
     * If cache is on, will retrieve content only the first time
     * popup is requrired.
     *
     * @var bool
     */
    public $useCache = false;

    /**
     * Min width for a dynamic popup.
     *
     * @var string
     */
    public $minWidth = null; //'120px';

    /**
     * Min height for a dynamic popup.
     *
     * @var string
     */
    public $minHeight = null; //'60px';

    function __construct($triggerBy = null) {
        if (is_object($triggerBy)) {
            $this->triggerBy = $triggerBy;
        } else {
            parent::__construct($triggerBy);
        }
    }

    public function init()
    {
        parent::init();

        if (
            $this->owner instanceof Item ||
            $this->owner instanceof Menu ||
            $this->owner instanceof DropDown ||
            $this->owner instanceof Button
        ) {
            throw new Exception([
                'Although it may be tempting to add pop-up into Button/Menu/Item, this may cause some random issues. Add elsewhere and use "triggerBy"',
                'owner'=>$this->owner
            ]);
        }

        if (
            ($this->triggerBy instanceof Item ||
            $this->triggerBy instanceof Menu ||
            $this->triggerBy instanceof DropDown) && $this->triggerOn == null<commit_msg>Apply fixes from StyleCI<commit_after><?php

namespace atk4\ui;

/**
 * Implement popup view.
 *
 * Popup are views that will be display when triggered by another view.
 *
 * Popup can add content statically or dynamically via a callback.
 *
 * When adding a popup to the page, you need to specify it's trigger element
 * and the event needed on the trigger element in order to display the popup.
 */
class Popup extends View
{
    public $ui = 'popup';

    /**
     * The view activating the popup.
     * Usually the view where popup is attached to,
     * unless target is supply.
     *
     * @var View|string|null Object view or a string id.
     */
    public $triggerBy = null;

    /**
     * Js event that trigger the popup.
     *
     * @var string
     */
    public $triggerOn = null;

    /**
     * Default position of the popup in relation to target element.
     *
     * @var string
     */
    public $position = 'top left';

    /**
     * When set to false, target is the triggerBy element.
     * Otherwise, you can supply a View object where popup will be shown.
     *
     * @var View|bool
     */
    public $target = false;

    /**
     * Popup options as defined in semantic-ui popup module.
     *
     * @var array
     */
    public $popOptions = [];

    /**
     * The callback use to generate dynamic content.
     *
     * @var Callback|null
     */
    public $cb = null;

    /**
     * The dynamic View to load inside the popup
     * when dynamic content is use.
     *
     * Default to 'View'.
     *
     * @var View|string
     */
    public $dynamicContent = 'View';

    /**
     * Whether or not dynamic content is cache.
     * If cache is on, will retrieve content only the first time
     * popup is requrired.
     *
     * @var bool
     */
    public $useCache = false;

    /**
     * Min width for a dynamic popup.
     *
     * @var string
     */
    public $minWidth = null; //'120px';

    /**
     * Min height for a dynamic popup.
     *
     * @var string
     */
    public $minHeight = null; //'60px';

    public function __construct($triggerBy = null)
    {
        if (is_object($triggerBy)) {
            $this->triggerBy = $triggerBy;
        } else {
            parent::__construct($triggerBy);
        }
    }

    public function init()
    {
        parent::init();

        if (
            $this->owner instanceof Item ||
            $this->owner instanceof Menu ||
            $this->owner instanceof DropDown ||
            $this->owner instanceof Button
        ) {
            throw new Exception([
                'Although it may be tempting to add pop-up into Button/Menu/Item, this may cause some random issues. Add elsewhere and use "triggerBy"',
                'owner'=> $this->owner,
            ]);
        }

        if (
            ($this->triggerBy instanceof Item ||
            $this->triggerBy instanceof Menu ||
            $this->triggerBy instanceof DropDown) && $this->triggerOn == null
{'fraction_non_alphanumeric': 0.10265456989247312, 'fraction_numerical': 0.0020161290322580645, 'mean_word_length': 1.8000940733772341, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '451829', 'n_tokens_mistral': 1684, 'n_tokens_neox': 1610, 'n_words': 608}