Current Path : /var/www/ljmtc/cbt/blocks/online_users/amd/build/ |
Current File : /var/www/ljmtc/cbt/blocks/online_users/amd/build/change_user_visibility.min.js.map |
{"version":3,"sources":["../src/change_user_visibility.js"],"names":["define","$","Ajax","Str","Notification","SELECTORS","CHANGE_VISIBILITY_LINK","CHANGE_VISIBILITY_ICON","changeVisibility","action","userid","value","call","methodname","args","preferences","then","data","saved","newAction","oppositeAction","changeVisibilityLinkAttr","changeVisibilityIconAttr","catch","exception","getTitle","title","attr","icon","is","M","util","image_url","addClass","getIconClass","removeClass","get_string","init","on","e","preventDefault"],"mappings":"AAwBAA,OAAM,6CAAC,CAAC,QAAD,CAAW,WAAX,CAAwB,UAAxB,CAAoC,mBAApC,CAAD,CACE,SAASC,CAAT,CAAYC,CAAZ,CAAkBC,CAAlB,CAAuBC,CAAvB,CAAqC,IAQrCC,CAAAA,CAAS,CAAG,CACZC,sBAAsB,CAAE,yBADZ,CAEZC,sBAAsB,CAAE,+BAFZ,CARyB,CAqBrCC,CAAgB,CAAG,SAASC,CAAT,CAAiBC,CAAjB,CAAyB,IAExCC,CAAAA,CAAK,CAAa,MAAV,EAAAF,CAAM,CAAa,CAAb,CAAiB,CAFS,CAe5CP,CAAI,CAACU,IAAL,CAAU,CANI,CACVC,UAAU,CAAE,gCADF,CAEVC,IAAI,CAAE,CACFC,WAAW,CATD,CAAC,CACf,KAAQ,mCADO,CAEf,MAASJ,CAFM,CAGf,OAAUD,CAHK,CAAD,CAQR,CAFI,CAMJ,CAAV,EAAqB,CAArB,EAAwBM,IAAxB,CAA6B,SAASC,CAAT,CAAe,CACxC,GAAIA,CAAI,CAACC,KAAT,CAAgB,CACZ,GAAIC,CAAAA,CAAS,CAAGC,CAAc,CAACX,CAAD,CAA9B,CACAY,CAAwB,CAACF,CAAD,CAAxB,CACAG,CAAwB,CAACH,CAAD,CAC3B,CAEJ,CAPD,EAOGI,KAPH,CAOSnB,CAAY,CAACoB,SAPtB,CAQH,CA5CwC,CAsDrCJ,C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,EAAAA,CAAM,CAAa,cAAb,CAA8B,QAC9C,CAnHwC,CA6HrCgB,CAAQ,CAAG,SAAShB,CAAT,CAAiB,CAC5B,MAAON,CAAAA,CAAG,CAACiC,UAAJ,CAAe,iBAAmB3B,CAAlC,CAA0C,oBAA1C,CACV,CA/HwC,CAiIzC,MAAO,CAOH4B,IAAI,CAAE,eAAW,CACbpC,CAAC,CAACI,CAAS,CAACC,sBAAX,CAAD,CAAoCgC,EAApC,CAAuC,OAAvC,CAAgD,SAASC,CAAT,CAAY,CACxDA,CAAC,CAACC,cAAF,GADwD,GAEpD/B,CAAAA,CAAM,CAAIR,CAAC,CAAC,IAAD,CAAD,CAAQ0B,IAAR,CAAa,aAAb,CAF0C,CAGpDjB,CAAM,CAAIT,CAAC,CAAC,IAAD,CAAD,CAAQ0B,IAAR,CAAa,aAAb,CAH0C,CAIxDnB,CAAgB,CAACC,CAAD,CAASC,CAAT,CACnB,CALD,CAMH,CAdE,CAgBV,CAlJK,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 * 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 * @package block_online_users\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"],"file":"change_user_visibility.min.js"}