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/app/design/frontend/Cnc/default/Magento_Customer/web/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/old/app/design/frontend/Cnc/default/Magento_Customer/web/js/change-email-password.js
/**
 * Copyright (c) 2020 Kaliop Digital Commerce (https://digitalcommerce.kaliop.com) All Rights Reserved.
 * https://opensource.org/licenses/OSL-3.0  Open Software License (OSL 3.0)
 * Cnc
 * Radosław Stępień <[email protected]> <[email protected]>
 */
define([
    'jquery',
    'jquery-ui-modules/widget'
], function ($) {
    'use strict';

    $.widget('mage.changeEmailPassword', {
        options: {
            mainContainerSelector: '[data-container=change-email-password]',
            emailContainerSelector: '[data-container=change-email]',
            newPasswordContainerSelector: '[data-container=new-password]',
            currentPasswordContainerSelector: '[data-container=current-password]',
            confirmPasswordContainerSelector: '[data-container=confirm-password]',
            changeTelephoneContainerSelector: '[data-container=change-telephone]',
            changeVatContainerSelector: '[data-container=cnc-customer-vat]',
            purchasingDepartmentEmailContainerSelector: '[data-container=cnc-purchasing-department-email]',
            purchasingDepartmentPhoneContainerSelector: '[data-container=cnc-purchasing-department-phone]',
            accountsDepartmentEmailContainerSelector: '[data-container=cnc-accounts-department-email]',
            accountsDepartmentPhoneContainerSelector: '[data-container=cnc-accounts-department-phone]',
            technicalServicePhoneContainerSelector: '[data-container=cnc-technical-service-phone]',
            changeEmailSelector: '[data-role=change-email]',
            changePasswordSelector: '[data-role=change-password]',
            changeTelephoneSelector: '[data-role=change-telephone]',
            changeVatSelector: '[data-role=change-vat]',
            changePurchasingDepartmentEmailSelector: '[data-role=change-cnc-purchasing-department-email]',
            changePurchasingDepartmentPhoneSelector: '[data-role=change-cnc-purchasing-department-phone]',
            changeAccountsDepartmentEmailSelector: '[data-role=change-cnc-accounts-department-email]',
            changeAccountsDepartmentPhoneSelector: '[data-role=change-cnc-accounts-department-phone]',
            changeTechnicalServicePhoneSelector: '[data-role=change-cnc-technical-service-phone]',
            emailSelector: '[data-input=change-email]',
            newPasswordSelector: '[data-input=new-password]',
            currentPasswordSelector: '[data-input=current-password]',
            confirmPasswordSelector: '[data-input=confirm-password]',
            telephoneSelector: '[data-input=change-telephone]',
            purchasingDepartmentEmailSelector: '[data-input=cnc-purchasing-department-email-new]',
            purchasingDepartmentPhoneSelector: '[data-input=cnc-purchasing-department-phone-new]',
            accountsDepartmentEmailSelector: '[data-input=cnc-accounts-department-email-new]',
            accountsDepartmentPhoneSelector: '[data-input=cnc-accounts-department-phone-new]',
            technicalServicePhoneSelector: '[data-input=cnc-technical-service-phone-new]',
            titleSelector: '[data-title=change-email-password]'
        },

        /**
         * Create widget
         * @private
         */
        _create: function () {
            this.element.on('change', $.proxy(function () {
                this._checkChoice();
            }, this));

            this._checkChoice();
            this._bind();
        },

        /**
         * Event binding, will monitor change, keyup and paste events.
         * @private
         */
        _bind: function () {
            this._on($(this.options.emailSelector), {
                'change': this._updatePasswordFieldWithEmailValue,
                'keyup': this._updatePasswordFieldWithEmailValue,
                'paste': this._updatePasswordFieldWithEmailValue
            });
        },

        /**
         * Check choice
         * @private
         */
        _checkChoice: function () {
            this._hideAll();
            if ($(this.options.changeTelephoneSelector).is(':checked')) {
                this._showTelephone();
            }
            if ($(this.options.changeVatSelector).is(':checked')) {
                this._showVat();
            }
            if ($(this.options.changeEmailSelector).is(':checked')) {
                this._showEmail();
            }
            if ($(this.options.changePasswordSelector).is(':checked')) {
                this._showPassword();
            }

            if ($(this.options.changePurchasingDepartmentEmailSelector).is(':checked')) {
                this._showCncContactField(
                    $(this.options.purchasingDepartmentEmailContainerSelector),
                    $(this.options.purchasingDepartmentEmailSelector)
                );
            }
            if($(this.options.changePurchasingDepartmentPhoneSelector).is(':checked')) {
                this._showCncContactField(
                    $(this.options.purchasingDepartmentPhoneContainerSelector),
                    $(this.options.purchasingDepartmentPhoneSelector)
                );
            }
            if($(this.options.changeAccountsDepartmentEmailSelector).is(':checked')) {
                this._showCncContactField(
                    $(this.options.accountsDepartmentEmailContainerSelector),
                    $(this.options.accountsDepartmentEmailSelector)
                );
            }
            if($(this.options.changeAccountsDepartmentPhoneSelector).is(':checked')) {
                this._showCncContactField(
                    $(this.options.accountsDepartmentPhoneContainerSelector),
                    $(this.options.accountsDepartmentPhoneSelector)
                );
            }
            if($(this.options.changeTechnicalServicePhoneSelector).is(':checked')) {
                this._showCncContactField(
                    $(this.options.technicalServicePhoneContainerSelector),
                    $(this.options.technicalServicePhoneSelector)
                );
            }
        },

        /**
         * Hide email and password input fields
         * @private
         */
        _hideAll: function () {
            $(this.options.mainContainerSelector).hide();
            $(this.options.emailContainerSelector).hide();
            $(this.options.newPasswordContainerSelector).hide();
            $(this.options.confirmPasswordContainerSelector).hide();
            $(this.options.changeTelephoneContainerSelector).hide();
            $(this.options.changeVatContainerSelector).hide();
            $(this.options.purchasingDepartmentEmailContainerSelector).hide();
            $(this.options.purchasingDepartmentPhoneContainerSelector).hide();
            $(this.options.accountsDepartmentEmailContainerSelector).hide();
            $(this.options.accountsDepartmentPhoneContainerSelector).hide();
            $(this.options.technicalServicePhoneContainerSelector).hide();
            $(this.options.accountInformationVatSelector).hide();

            $(this.options.currentPasswordSelector).removeAttr('data-validate').prop('disabled', true);
            $(this.options.emailSelector).removeAttr('data-validate').prop('disabled', true);
            $(this.options.newPasswordSelector).removeAttr('data-validate').prop('disabled', true);
            $(this.options.confirmPasswordSelector).removeAttr('data-validate').prop('disabled', true);
            $(this.options.telephoneSelector).removeAttr('data-validate').prop('disabled', true);
            $(this.options.purchasingDepartmentEmailSelector).removeAttr('data-validate').prop('disabled', true);
            $(this.options.purchasingDepartmentPhoneSelector).removeAttr('data-validate').prop('disabled', true);
            $(this.options.accountsDepartmentEmailSelector).removeAttr('data-validate').prop('disabled', true);
            $(this.options.accountsDepartmentPhoneSelector).removeAttr('data-validate').prop('disabled', true);
            $(this.options.technicalServicePhoneSelector).removeAttr('data-validate').prop('disabled', true);

        },

        /**
         * Show email input fields
         * @private
         */
        _showEmail: function () {
            $(this.options.mainContainerSelector).show();
            $(this.options.titleSelector).html(this.options.titleChangeInformations);

            $(this.options.emailContainerSelector).show();
            $(this.options.currentPasswordContainerSelector).show();
            $(this.options.emailSelector).attr('data-validate', '{required:true}').prop('disabled', false);
            $(this.options.currentPasswordSelector).attr('data-validate', '{required:true}').prop('disabled', false);
        },

        /**
         * Show password input fields
         * @private
         */
        _showPassword: function () {
            $(this.options.mainContainerSelector).show();
            $(this.options.titleSelector).html(this.options.titleChangeInformations);

            $(this.options.newPasswordContainerSelector).show();
            $(this.options.confirmPasswordContainerSelector).show();
            $(this.options.currentPasswordContainerSelector).show();

            $(this.options.currentPasswordSelector).attr('data-validate', '{required:true}').prop('disabled', false);
            this._updatePasswordFieldWithEmailValue();
            $(this.options.confirmPasswordSelector).attr(
                'data-validate',
                '{required:true, equalTo:"' + this.options.newPasswordSelector + '"}'
            ).prop('disabled', false);
        },

        /**
         * Show telephone input fields
         * @private
         */
        _showTelephone: function () {
            $(this.options.mainContainerSelector).show();
            $(this.options.currentPasswordContainerSelector).hide();
            $(this.options.titleSelector).html(this.options.titleChangeInformations);

            $(this.options.changeTelephoneContainerSelector).show();
            $(this.options.telephoneSelector).attr('data-validate', '{required:true}').prop('disabled', false);

        },

        /**
         * Show telephone input fields
         * @private
         */
        _showVat: function () {
            $(this.options.mainContainerSelector).show();
            $(this.options.currentPasswordContainerSelector).hide();
            $(this.options.titleSelector).html(this.options.titleChangeInformations);

            $(this.options.changeVatContainerSelector).show();
        },

        /**
         * Show contacts section fields when they are checked as to be changed
         * @param container
         * @param field
         * @private
         */
        _showCncContactField: function (container, field) {
            container.show();
            field.attr('data-validate', '{required:true}').prop('disabled', false);
        },

        /**
         * Update password validation rules with email input field value
         * @private
         */
        _updatePasswordFieldWithEmailValue: function () {
            $(this.options.newPasswordSelector).attr(
                'data-validate',
                '{required:true, ' +
                '\'validate-customer-password\':true, ' +
                '\'password-not-equal-to-user-name\':\'' + $(this.options.emailSelector).val() + '\'}'
            ).prop('disabled', false);
        }
    });

    return $.mage.changeEmailPassword;
});

Spamworldpro Mini