%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/vacivi36/ava/blocks/online_users/amd/build/
Upload File :
Create Path :
Current File : /home/vacivi36/ava/blocks/online_users/amd/build/change_user_visibility.min.js.map

{"version":3,"file":"change_user_visibility.min.js","sources":["../src/change_user_visibility.js"],"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 * A javascript module that handles the change of the user's visibility in the\n * online users block.\n *\n * @module     block_online_users/change_user_visibility\n * @copyright  2018 Mihail Geshoski <mihail@moodle.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/ajax', 'core/str', 'core/notification'],\n        function($, Ajax, Str, Notification) {\n\n    /**\n     * Selectors.\n     *\n     * @access private\n     * @type {Object}\n     */\n    var SELECTORS = {\n        CHANGE_VISIBILITY_LINK: '#change-user-visibility',\n        CHANGE_VISIBILITY_ICON: '#change-user-visibility .icon'\n    };\n\n    /**\n     * Change user visibility in the online users block.\n     *\n     * @method changeVisibility\n     * @param {String} action\n     * @param {String} userid\n     * @private\n     */\n    var changeVisibility = function(action, userid) {\n\n        var value = action == \"show\" ? 1 : 0;\n        var preferences = [{\n            'name': 'block_online_users_uservisibility',\n            'value': value,\n            'userid': userid\n        }];\n\n        var request = {\n            methodname: 'core_user_set_user_preferences',\n            args: {\n                preferences: preferences\n            }\n        };\n        Ajax.call([request])[0].then(function(data) {\n            if (data.saved) {\n                var newAction = oppositeAction(action);\n                changeVisibilityLinkAttr(newAction);\n                changeVisibilityIconAttr(newAction);\n            }\n            return;\n        }).catch(Notification.exception);\n    };\n\n    /**\n     * Get the opposite action.\n     *\n     * @method oppositeAction\n     * @param {String} action\n     * @return {String}\n     * @private\n     */\n    var oppositeAction = function(action) {\n        return action == 'show' ? 'hide' : 'show';\n    };\n\n    /**\n     * Change the attribute values of the user visibility link in the online users block.\n     *\n     * @method changeVisibilityLinkAttr\n     * @param {String} action\n     * @private\n     */\n    var changeVisibilityLinkAttr = function(action) {\n        getTitle(action).then(function(title) {\n            $(SELECTORS.CHANGE_VISIBILITY_LINK).attr({\n                'data-action': action,\n                'title': title\n            });\n            return;\n        }).catch(Notification.exception);\n    };\n\n    /**\n     * Change the attribute values of the user visibility icon in the online users block.\n     *\n     * @method changeVisibilityIconAttr\n     * @param {String} action\n     * @private\n     */\n    var changeVisibilityIconAttr = function(action) {\n        var icon = $(SELECTORS.CHANGE_VISIBILITY_ICON);\n        getTitle(action).then(function(title) {\n            // Add the proper title to the icon.\n            $(icon).attr({\n                'title': title,\n                'aria-label': title\n            });\n            // If the icon is an image.\n            if (icon.is(\"img\")) {\n                $(icon).attr({\n                    'src': M.util.image_url('t/' + action),\n                    'alt': title\n                });\n            } else {\n                // Add the new icon class and remove the old one.\n                $(icon).addClass(getIconClass(action));\n                $(icon).removeClass(getIconClass(oppositeAction(action)));\n            }\n            return;\n        }).catch(Notification.exception);\n    };\n\n    /**\n     * Get the proper class for the user visibility icon in the online users block.\n     *\n     * @method getIconClass\n     * @param {String} action\n     * @return {String}\n     * @private\n     */\n    var getIconClass = function(action) {\n        return action == 'show' ? 'fa-eye-slash' : 'fa-eye';\n    };\n\n    /**\n     * Get the title description of the user visibility link in the online users block.\n     *\n     * @method getTitle\n     * @param {String} action\n     * @return {object} jQuery promise\n     * @private\n     */\n    var getTitle = function(action) {\n        return Str.get_string('online_status:' + action, 'block_online_users');\n    };\n\n    return {\n        // Public variables and functions.\n        /**\n         * Initialise change user visibility function.\n         *\n         * @method init\n         */\n        init: function() {\n            $(SELECTORS.CHANGE_VISIBILITY_LINK).on('click', function(e) {\n                e.preventDefault();\n                var action = ($(this).attr('data-action'));\n                var userid = ($(this).attr('data-userid'));\n                changeVisibility(action, userid);\n            });\n        }\n    };\n});\n"],"names":["define","$","Ajax","Str","Notification","SELECTORS","oppositeAction","action","changeVisibilityLinkAttr","getTitle","then","title","attr","catch","exception","changeVisibilityIconAttr","icon","is","M","util","image_url","addClass","getIconClass","removeClass","get_string","init","on","e","preventDefault","userid","request","methodname","args","preferences","call","data","saved","newAction","changeVisibility","this"],"mappings":";;;;;;;;AAuBAA,mDAAO,CAAC,SAAU,YAAa,WAAY,sBACnC,SAASC,EAAGC,KAAMC,IAAKC,kBAQvBC,iCACwB,0BADxBA,iCAEwB,gCA4CxBC,eAAiB,SAASC,cACT,QAAVA,OAAmB,OAAS,QAUnCC,yBAA2B,SAASD,QACpCE,SAASF,QAAQG,MAAK,SAASC,OAC3BV,EAAEI,kCAAkCO,KAAK,eACtBL,aACNI,WAGdE,MAAMT,aAAaU,YAUtBC,yBAA2B,SAASR,YAChCS,KAAOf,EAAEI,kCACbI,SAASF,QAAQG,MAAK,SAASC,OAE3BV,EAAEe,MAAMJ,KAAK,OACAD,mBACKA,QAGdK,KAAKC,GAAG,OACRhB,EAAEe,MAAMJ,KAAK,KACFM,EAAEC,KAAKC,UAAU,KAAOb,YACxBI,SAIXV,EAAEe,MAAMK,SAASC,aAAaf,SAC9BN,EAAEe,MAAMO,YAAYD,aAAahB,eAAeC,cAGrDM,MAAMT,aAAaU,YAWtBQ,aAAe,SAASf,cACP,QAAVA,OAAmB,eAAiB,UAW3CE,SAAW,SAASF,eACbJ,IAAIqB,WAAW,iBAAmBjB,OAAQ,6BAG9C,CAOHkB,KAAM,WACFxB,EAAEI,kCAAkCqB,GAAG,SAAS,SAASC,GACrDA,EAAEC,iBArHS,SAASrB,OAAQsB,YAShCC,QAAU,CACVC,WAAY,iCACZC,KAAM,CACFC,YATU,CAAC,MACP,0CAFU,QAAV1B,OAAmB,EAAI,SAIrBsB,WASd3B,KAAKgC,KAAK,CAACJ,UAAU,GAAGpB,MAAK,SAASyB,SAC9BA,KAAKC,MAAO,KACRC,UAAY/B,eAAeC,QAC/BC,yBAAyB6B,WACzBtB,yBAAyBsB,eAG9BxB,MAAMT,aAAaU,WAkGdwB,CAFcrC,EAAEsC,MAAM3B,KAAK,eACbX,EAAEsC,MAAM3B,KAAK"}

Zerion Mini Shell 1.0