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/magento/module-gift-message/view/frontend/web/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/module-gift-message/view/frontend/web/js/gift-options.js
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

define([
    'jquery',
    'jquery-ui-modules/widget'
], function ($) {
    'use strict';

    $.widget('mage.giftOptions', {
        options: {
            mageError: 'mage-error',
            noDisplay: 'no-display',
            requiredEntry: 'required-entry'
        },

        /**
         * Initial toggle of the various gift options after widget instantiation.
         * @private
         */
        _init: function () {
            this._toggleVisibility();
        },

        /**
         * Bind a click handler to the widget's context element.
         * @private
         */
        _create: function () {
            this.element.on('click', $.proxy(this._toggleVisibility, this));
            $(this.element.data('selector').id).find('.giftmessage-area')
                .on('change', $.proxy(this._toggleRequired, this));
        },

        /**
         * Toggle the visibility of the widget's context element's selector(s).
         * @private
         * @param {jQuery.Event} event - Click event. Target is a checkbox.
         */
        _toggleVisibility: function (event) {
            var checkbox = event ? $(event.target) : this.element,
                container = $(checkbox.data('selector').id),
                _this;

            if (checkbox.is(':checked')) {
                container.show()
                    .find('.giftmessage-area:not(:visible)').each(function (x, element) {
                        if ($(element).val().length > 0) {
                            $(element).trigger('change');
                            container.find('a').trigger('click');
                        }
                    });
            } else {
                _this = this;
                container.hide()
                    .find('.input-text:not(.giftmessage-area)').each(function (x, element) {
                        $(element).val(element.defaultValue).removeClass(_this.options.mageError)
                            .next('div.' + _this.options.mageError).remove();
                    }).end()
                    .find('.giftmessage-area').val('').change().end()
                    .find('.select').val('').change().end()
                    .find('.checkbox:checked').prop('checked', false).trigger('click').prop('checked', false).end()
                    .find('.price-box').addClass(this.options.noDisplay).end();
            }
        },

        /**
         * Make the From and To input fields required if a gift message has been written.
         * @private
         * @param {jQuery.Event} event - Change event. Target is a textarea.
         */
        _toggleRequired: function (event) {
            var textArea = $(event.target),
                length = textArea.val().length;

            textArea.closest('li').prev('.fields')
                .find('.input-text').toggleClass(this.options.requiredEntry, length > 0);
        }
    });

    return $.mage.giftOptions;
});

Spamworldpro Mini