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/old/vendor/amasty/shopby/view/frontend/web/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/amasty/shopby/view/frontend/web/js/amShopbySwatchesChoose.js
/**
 *  Amasty Swatches Filter select
 */

define([
    'jquery'
], function ($) {
    'use strict';

    $.widget('mage.amShopbySwatchesChoose', {
        options: {
            listSwatches: {},
            swatchWidgetName: 'mageSwatchRenderer',
            newSwatchWidgetName: 'mage-SwatchRenderer'
        },
        selectors: {
            swatchOption: '[data-role^="swatch-option"]'
        },
        observerConfig: {
            attributes: true,
            childList: false,
            subtree: true
        },
        observer: null,

        /**
         * @inheritDoc
         */
        _create: function () {
            var self = this;

            if (!self.options.listSwatches.length) {
                return;
            }

            self.initObserver();

            self.element.find(self.selectors.swatchOption).each(function (index, element) {
                self.observer.observe(element, self.observerConfig);
            });
        },

        /**
         * @public
         * @return {void}
         */
        initObserver: function () {
            this.observer = new MutationObserver(this.observerCallback.bind(this));
        },

        /**
         * Waiting for the mageSwatchRenderer module to load
         *
         * @public
         * @param {array} mutationsList
         * @return {void}
         */
        observerCallback: function (mutationsList) {
            var self = this,
                swatchWidget;

            mutationsList.forEach(function (mutation) {
                if (mutation.type === 'attributes' && mutation.attributeName === 'data-rendered') {
                    swatchWidget = $(mutation.target).data(self.options.swatchWidgetName) || $(mutation.target).data(self.options.newSwatchWidgetName);

                    $(self.options.listSwatches).each( function (id, attribute) {
                        if (!swatchWidget || !swatchWidget._EmulateSelected) {
                            return;
                        }

                        swatchWidget._EmulateSelected(attribute);
                    });
                }
            });
        }
    });

    return $.mage.amShopbySwatchesChoose;
});

Spamworldpro Mini