Your IP : 216.73.216.95


Current Path : /var/www/ljmtc/cbt/message/amd/build/
Upload File :
Current File : /var/www/ljmtc/cbt/message/amd/build/preferences_notifications_list_controller.min.js.map

{"version":3,"sources":["../src/preferences_notifications_list_controller.js"],"names":["define","$","Ajax","Notification","CustomEvents","NotificationPreference","NotificationProcessorSettings","ModalFactory","SELECTORS","DISABLE_NOTIFICATIONS","DISABLE_NOTIFICATIONS_CONTAINER","PREFERENCE","PREFERENCE_ROW","PREFERENCE_INPUT","PROCESSOR_SETTING","PreferencesController","element","root","userId","attr","registerEventListeners","prototype","isDisabled","hasClass","setDisabled","addClass","find","prop","setEnabled","removeClass","toggleDisableAllStatus","checkbox","container","ischecked","Deferred","resolve","request","methodname","args","userid","emailstop","call","done","bind","always","fail","exception","disabledNotificationsElement","events","activate","on","e","preferenceElement","target","closest","preferenceRow","preference","save","eventFormPromise","create","type","TYPE","preventDefault","then","modal","setUserId","setName","setContextId","setElement","show","stopImmediatePropagation"],"mappings":"AAyBAA,OAAM,0DAAC,CAAC,QAAD,CACC,WADD,CAEC,mBAFD,CAGC,gCAHD,CAIC,sCAJD,CAKC,8CALD,CAMC,oBAND,CAAD,CAQE,SACEC,CADF,CAEEC,CAFF,CAGEC,CAHF,CAIEC,CAJF,CAKEC,CALF,CAMEC,CANF,CAOEC,CAPF,CAQE,IAEFC,CAAAA,CAAS,CAAG,CACZC,qBAAqB,CAAE,+EADX,CAEZC,+BAA+B,CAAE,kDAFrB,CAGZC,UAAU,CAAE,cAHA,CAIZC,cAAc,CAAE,kCAJJ,CAKZC,gBAAgB,CAAE,oBALN,CAMZC,iBAAiB,CAAE,0BANP,CAFV,CAgBFC,CAAqB,CAAG,SAASC,CAAT,CAAkB,CAC1C,KAAKC,IAAL,CAAYhB,CAAC,CAACe,CAAD,CAAb,CACA,KAAKE,MAAL,CAAc,KAAKD,IAAL,CAAUE,IAAV,CAAe,cAAf,CAAd,CAEA,KAAKC,sBAAL,EACH,CArBK,CA6BNL,CAAqB,CA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AIA,KAAK5C,IAAL,CAAUiC,EAAV,CAAa9C,CAAY,CAAC4C,MAAb,CAAoBC,QAAjC,CAA2CzC,CAAS,CAACM,iBAArD,CAAwE,SAASqC,CAAT,CAAY,CAChF,GAAInC,CAAAA,CAAO,CAAGf,CAAC,CAACkD,CAAC,CAACE,MAAH,CAAD,CAAYC,OAAZ,CAAoB9C,CAAS,CAACM,iBAA9B,CAAd,CAEAqC,CAAC,CAACW,cAAF,GACAJ,CAAgB,CAACK,IAAjB,CAAsB,SAASC,CAAT,CAAgB,CAElCA,CAAK,CAACC,SAAN,CAAgBhE,CAAC,CAACe,CAAD,CAAD,CAAWG,IAAX,CAAgB,cAAhB,CAAhB,EACA6C,CAAK,CAACE,OAAN,CAAcjE,CAAC,CAACe,CAAD,CAAD,CAAWG,IAAX,CAAgB,WAAhB,CAAd,EACA6C,CAAK,CAACG,YAAN,CAAmBlE,CAAC,CAACe,CAAD,CAAD,CAAWG,IAAX,CAAgB,iBAAhB,CAAnB,EACA6C,CAAK,CAACI,UAAN,CAAiBpD,CAAjB,EACAgD,CAAK,CAACK,IAAN,GAEAlB,CAAC,CAACmB,wBAAF,EAEH,CAVD,EAUGzB,IAVH,CAUQ1C,CAAY,CAAC2C,SAVrB,CAWH,CAfD,EAiBA1C,CAAY,CAACJ,MAAb,CAAoB+C,CAApB,CAAkD,CAC9C3C,CAAY,CAAC4C,MAAb,CAAoBC,QAD0B,CAAlD,EAIAF,CAA4B,CAACG,EAA7B,CAAgC9C,CAAY,CAAC4C,MAAb,CAAoBC,QAApD,CAA8D,UAAW,CACrE,KAAKnB,sBAAL,EACH,CAF6D,CAE5Da,IAF4D,CAEvD,IAFuD,CAA9D,CAGH,CAhDD,CAkDA,MAAO5B,CAAAA,CACV,CArKK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Controls the preferences for the list of notification types on the\n * message preference page\n *\n * @module     core_message/preferences_notifications_list_controller\n * @class      preferences_notifications_list_controller\n * @package    message\n * @copyright  2016 Ryan Wyllie <ryan@moodle.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n        'core/ajax',\n        'core/notification',\n        'core/custom_interaction_events',\n        'core_message/notification_preference',\n        'core_message/notification_processor_settings',\n        'core/modal_factory',\n        ],\n        function(\n          $,\n          Ajax,\n          Notification,\n          CustomEvents,\n          NotificationPreference,\n          NotificationProcessorSettings,\n          ModalFactory\n        ) {\n\n    var SELECTORS = {\n        DISABLE_NOTIFICATIONS: '[data-region=\"disable-notification-container\"] [data-disable-notifications]',\n        DISABLE_NOTIFICATIONS_CONTAINER: '[data-region=\"disable-notification-container\"]',\n        PREFERENCE: '[data-state]',\n        PREFERENCE_ROW: '[data-region=\"preference-row\"]',\n        PREFERENCE_INPUT: '[data-state] input',\n        PROCESSOR_SETTING: '[data-processor-setting]',\n    };\n\n    /**\n     * Constructor for the PreferencesController.\n     *\n     * @param {object} element jQuery object root element of the preference\n     */\n    var PreferencesController = function(element) {\n        this.root = $(element);\n        this.userId = this.root.attr('data-user-id');\n\n        this.registerEventListeners();\n    };\n\n    /**\n     * Check if the preferences are all disabled.\n     *\n     * @method isDisabled\n     * @return {bool}\n     */\n    PreferencesController.prototype.isDisabled = function() {\n        return this.root.hasClass('disabled');\n    };\n\n    /**\n     * Disable all of the preferences.\n     *\n     * @method setDisabled\n     */\n    PreferencesController.prototype.setDisabled = function() {\n        this.root.addClass('disabled');\n        this.root.find(SELECTORS.PREFERENCE_INPUT).prop('disabled', true);\n    };\n\n    /**\n     * Enable all of the preferences.\n     *\n     * @method setEnabled\n     */\n    PreferencesController.prototype.setEnabled = function() {\n        this.root.removeClass('disabled');\n        this.root.find(SELECTORS.PREFERENCE_INPUT).prop('disabled', false);\n    };\n\n    /**\n      * Update the disable all notifications user property in the DOM and\n      * send a request to update on the server.\n      *\n      * @method toggleDisableAllStatus\n      * @return {Promise}\n      */\n    PreferencesController.prototype.toggleDisableAllStatus = function() {\n        var checkbox = $(SELECTORS.DISABLE_NOTIFICATIONS);\n        var container = $(SELECTORS.DISABLE_NOTIFICATIONS_CONTAINER);\n        var ischecked = checkbox.prop('checked');\n\n        if (container.hasClass('loading')) {\n            return $.Deferred().resolve();\n        }\n\n        container.addClass('loading');\n\n        var request = {\n            methodname: 'core_user_update_user_preferences',\n            args: {\n                userid: this.userId,\n                emailstop: ischecked ? 1 : 0,\n            }\n        };\n\n        return Ajax.call([request])[0]\n            .done(function() {\n                if (ischecked) {\n                    this.setDisabled();\n                } else {\n                    this.setEnabled();\n                }\n            }.bind(this))\n            .always(function() {\n                container.removeClass('loading');\n            })\n            .fail(Notification.exception);\n    };\n\n    /**\n      * Set up all of the event listeners for the PreferencesController.\n      *\n      * @method registerEventListeners\n      */\n    PreferencesController.prototype.registerEventListeners = function() {\n        var disabledNotificationsElement = $(SELECTORS.DISABLE_NOTIFICATIONS);\n\n        CustomEvents.define(this.root, [\n            CustomEvents.events.activate,\n        ]);\n\n        this.root.on('change', function(e) {\n            if (!this.isDisabled()) {\n                var preferenceElement = $(e.target).closest(SELECTORS.PREFERENCE);\n                var preferenceRow = $(e.target).closest(SELECTORS.PREFERENCE_ROW);\n                var preference = new NotificationPreference(preferenceRow, this.userId);\n\n                preferenceElement.addClass('loading');\n                preference.save().always(function() {\n                    preferenceElement.removeClass('loading');\n                });\n            }\n        }.bind(this));\n\n        var eventFormPromise = ModalFactory.create({\n            type: NotificationProcessorSettings.TYPE,\n        });\n\n        this.root.on(CustomEvents.events.activate, SELECTORS.PROCESSOR_SETTING, function(e) {\n            var element = $(e.target).closest(SELECTORS.PROCESSOR_SETTING);\n\n            e.preventDefault();\n            eventFormPromise.then(function(modal) {\n                // Configure modal with element settings.\n                modal.setUserId($(element).attr('data-user-id'));\n                modal.setName($(element).attr('data-name'));\n                modal.setContextId($(element).attr('data-context-id'));\n                modal.setElement(element);\n                modal.show();\n\n                e.stopImmediatePropagation();\n                return;\n            }).fail(Notification.exception);\n        });\n\n        CustomEvents.define(disabledNotificationsElement, [\n            CustomEvents.events.activate\n        ]);\n\n        disabledNotificationsElement.on(CustomEvents.events.activate, function() {\n            this.toggleDisableAllStatus();\n        }.bind(this));\n    };\n\n    return PreferencesController;\n});\n"],"file":"preferences_notifications_list_controller.min.js"}