first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,14 @@
define("core_message/default_notification_preferences",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;
/**
* Controls the default settings for the list of notification types on the
* notifications admin page
*
* @module core_message/default_notification_preferences
* @class default_notification_preferences
* @copyright 2021 Moodle
* @author Pau Ferrer Ocaña <pau@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
const selectors_provider=".defaultmessageoutputs .provider_enabled",selectors_lockSetting=".locked_message_setting",selectors_allSettings=".locked_message_setting, .enabled_message_setting";var _default={init:()=>{(()=>{const toggleLockSetting=lockedElement=>{const isEnabled=lockedElement.checked||!1,enabledId=lockedElement.id.replace("_locked[","_enabled[");document.getElementById(enabledId).closest("div.custom-control").classList.toggle("dimmed_text",isEnabled)},toggleEnableProviderSettings=providerEnabledElement=>{const isEnabled=providerEnabledElement.checked||!1;providerEnabledElement.closest("tr").querySelectorAll(selectors_allSettings).forEach((element=>{element.toggleAttribute("disabled",!isEnabled)}))},container=document.querySelector(".preferences-container");container.querySelectorAll(selectors_provider).forEach((providerEnabledElement=>{providerEnabledElement.checked||toggleEnableProviderSettings(providerEnabledElement),providerEnabledElement.addEventListener("change",(e=>{toggleEnableProviderSettings(e.target)}))})),container.querySelectorAll(selectors_lockSetting).forEach((lockedElement=>{lockedElement.checked&&toggleLockSetting(lockedElement),lockedElement.addEventListener("change",(e=>{toggleLockSetting(e.target)}))}))})()}};return _exports.default=_default,_exports.default}));
//# sourceMappingURL=default_notification_preferences.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"default_notification_preferences.min.js","sources":["../src/default_notification_preferences.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 * Controls the default settings for the list of notification types on the\n * notifications admin page\n *\n * @module core_message/default_notification_preferences\n * @class default_notification_preferences\n * @copyright 2021 Moodle\n * @author Pau Ferrer Ocaña <pau@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nconst selectors = {\n provider: '.defaultmessageoutputs .provider_enabled',\n lockSetting: '.locked_message_setting',\n enabledSetting: '.enabled_message_setting',\n allSettings: '.locked_message_setting, .enabled_message_setting'\n};\n\n/**\n * Register event listeners for the default_notification_preferences page.\n */\nconst registerEventListeners = () => {\n\n /**\n * Update the dimmed status of the \"enabled\" toggle on the notification setting.\n *\n * @param {HTMLElement} lockedElement Element that receives the event.\n */\n const toggleLockSetting = (lockedElement) => {\n const isEnabled = lockedElement.checked || false;\n const enabledId = lockedElement.id.replace('_locked[', '_enabled[');\n\n const enabledElement = document.getElementById(enabledId).closest('div.custom-control');\n enabledElement.classList.toggle('dimmed_text', isEnabled);\n };\n\n /**\n * Enable/Disable all settings of the provider.\n *\n * @param {HTMLElement} providerEnabledElement Element that receives the event.\n */\n const toggleEnableProviderSettings = (providerEnabledElement) => {\n const isEnabled = providerEnabledElement.checked || false;\n const parentRow = providerEnabledElement.closest('tr');\n\n const elements = parentRow.querySelectorAll(selectors.allSettings);\n elements.forEach((element) => {\n element.toggleAttribute('disabled', !isEnabled);\n });\n };\n\n const container = document.querySelector('.preferences-container');\n\n container.querySelectorAll(selectors.provider).forEach((providerEnabledElement) => {\n // Set the initial statuses.\n if (!providerEnabledElement.checked) {\n toggleEnableProviderSettings(providerEnabledElement);\n }\n\n providerEnabledElement.addEventListener('change', (e) => {\n toggleEnableProviderSettings(e.target);\n });\n });\n\n container.querySelectorAll(selectors.lockSetting).forEach((lockedElement) => {\n // Set the initial statuses.\n if (lockedElement.checked) {\n toggleLockSetting(lockedElement);\n }\n\n lockedElement.addEventListener('change', (e) => {\n toggleLockSetting(e.target);\n });\n });\n};\n\n/**\n * Initialize the page.\n */\nconst init = () => {\n registerEventListeners();\n};\n\nexport default {\n init: init,\n};\n"],"names":["selectors","init","toggleLockSetting","lockedElement","isEnabled","checked","enabledId","id","replace","document","getElementById","closest","classList","toggle","toggleEnableProviderSettings","providerEnabledElement","querySelectorAll","forEach","element","toggleAttribute","container","querySelector","addEventListener","e","target","registerEventListeners"],"mappings":";;;;;;;;;;;MA0BMA,mBACQ,2CADRA,sBAEW,0BAFXA,sBAIW,iEAoEF,CACXC,KALS,KA1DkB,YAOrBC,kBAAqBC,sBACjBC,UAAYD,cAAcE,UAAW,EACrCC,UAAYH,cAAcI,GAAGC,QAAQ,WAAY,aAEhCC,SAASC,eAAeJ,WAAWK,QAAQ,sBACnDC,UAAUC,OAAO,cAAeT,YAQ7CU,6BAAgCC,+BAC5BX,UAAYW,uBAAuBV,UAAW,EAClCU,uBAAuBJ,QAAQ,MAEtBK,iBAAiBhB,uBACnCiB,SAASC,UACdA,QAAQC,gBAAgB,YAAaf,eAIvCgB,UAAYX,SAASY,cAAc,0BAEzCD,UAAUJ,iBAAiBhB,oBAAoBiB,SAASF,yBAE/CA,uBAAuBV,SACxBS,6BAA6BC,wBAGjCA,uBAAuBO,iBAAiB,UAAWC,IAC/CT,6BAA6BS,EAAEC,cAIvCJ,UAAUJ,iBAAiBhB,uBAAuBiB,SAASd,gBAEnDA,cAAcE,SACdH,kBAAkBC,eAGtBA,cAAcmB,iBAAiB,UAAWC,IACtCrB,kBAAkBqB,EAAEC,eAS5BC"}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+3
View File
@@ -0,0 +1,3 @@
define("core_message/message_drawer_events",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;return _exports.default={CREATE_CONVERSATION_WITH_USER:"message-drawer-create-conversation-with-user",CONTACT_BLOCKED:"message-drawer-contact-blocked",CONTACT_UNBLOCKED:"message-drawer-contact-unblocked",CONTACT_ADDED:"message-drawer-contact-added",CONTACT_REMOVED:"message-drawer-contact-removed",CONTACT_REQUEST_ACCEPTED:"message-drawer-contact-request-accepted",CONTACT_REQUEST_DECLINED:"message-drawer-contact-request-declined",CONVERSATION_CREATED:"message-drawer-conversation-created",CONVERSATION_NEW_LAST_MESSAGE:"message-drawer-conversation-new-last-message",CONVERSATION_DELETED:"message-drawer-conversation-deleted",CONVERSATION_READ:"message-drawer-conversation-read",CONVERSATION_SET_FAVOURITE:"message-drawer-conversation-set-favourite",CONVERSATION_SET_MUTED:"message-drawer-conversation-set-muted",CONVERSATION_UNSET_FAVOURITE:"message-drawer-conversation-unset-favourite",CONVERSATION_UNSET_MUTED:"message-drawer-conversation-unset-muted",PREFERENCES_UPDATED:"message-drawer-preferences-updated",READY:"message-drawer-ready",ROUTE_CHANGED:"message-drawer-route-change",SHOW:"message-drawer-show",HIDE:"message-drawer-hide",TOGGLE_VISIBILITY:"message-drawer-toggle",SHOW_CONVERSATION:"message-drawer-show-conversation",SHOW_SETTINGS:"message-drawer-show-settings"},_exports.default}));
//# sourceMappingURL=message_drawer_events.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"message_drawer_events.min.js","sources":["../src/message_drawer_events.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 * Events for the message drawer.\n *\n * @module core_message/message_drawer_events\n * @copyright 2018 Ryan Wyllie <ryan@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default {\n CREATE_CONVERSATION_WITH_USER: 'message-drawer-create-conversation-with-user',\n CONTACT_BLOCKED: 'message-drawer-contact-blocked',\n CONTACT_UNBLOCKED: 'message-drawer-contact-unblocked',\n CONTACT_ADDED: 'message-drawer-contact-added',\n CONTACT_REMOVED: 'message-drawer-contact-removed',\n CONTACT_REQUEST_ACCEPTED: 'message-drawer-contact-request-accepted',\n CONTACT_REQUEST_DECLINED: 'message-drawer-contact-request-declined',\n CONVERSATION_CREATED: 'message-drawer-conversation-created',\n CONVERSATION_NEW_LAST_MESSAGE: 'message-drawer-conversation-new-last-message',\n CONVERSATION_DELETED: 'message-drawer-conversation-deleted',\n CONVERSATION_READ: 'message-drawer-conversation-read',\n CONVERSATION_SET_FAVOURITE: 'message-drawer-conversation-set-favourite',\n CONVERSATION_SET_MUTED: 'message-drawer-conversation-set-muted',\n CONVERSATION_UNSET_FAVOURITE: 'message-drawer-conversation-unset-favourite',\n CONVERSATION_UNSET_MUTED: 'message-drawer-conversation-unset-muted',\n PREFERENCES_UPDATED: 'message-drawer-preferences-updated',\n READY: 'message-drawer-ready',\n ROUTE_CHANGED: 'message-drawer-route-change',\n SHOW: 'message-drawer-show',\n HIDE: 'message-drawer-hide',\n TOGGLE_VISIBILITY: 'message-drawer-toggle',\n SHOW_CONVERSATION: 'message-drawer-show-conversation',\n SHOW_SETTINGS: 'message-drawer-show-settings',\n};\n"],"names":["CREATE_CONVERSATION_WITH_USER","CONTACT_BLOCKED","CONTACT_UNBLOCKED","CONTACT_ADDED","CONTACT_REMOVED","CONTACT_REQUEST_ACCEPTED","CONTACT_REQUEST_DECLINED","CONVERSATION_CREATED","CONVERSATION_NEW_LAST_MESSAGE","CONVERSATION_DELETED","CONVERSATION_READ","CONVERSATION_SET_FAVOURITE","CONVERSATION_SET_MUTED","CONVERSATION_UNSET_FAVOURITE","CONVERSATION_UNSET_MUTED","PREFERENCES_UPDATED","READY","ROUTE_CHANGED","SHOW","HIDE","TOGGLE_VISIBILITY","SHOW_CONVERSATION","SHOW_SETTINGS"],"mappings":"oLAsBe,CACXA,8BAA+B,+CAC/BC,gBAAiB,iCACjBC,kBAAmB,mCACnBC,cAAe,+BACfC,gBAAiB,iCACjBC,yBAA0B,0CAC1BC,yBAA0B,0CAC1BC,qBAAsB,sCACtBC,8BAA+B,+CAC/BC,qBAAsB,sCACtBC,kBAAmB,mCACnBC,2BAA4B,4CAC5BC,uBAAwB,wCACxBC,6BAA8B,8CAC9BC,yBAA0B,0CAC1BC,oBAAqB,qCACrBC,MAAO,uBACPC,cAAe,8BACfC,KAAM,sBACNC,KAAM,sBACNC,kBAAmB,wBACnBC,kBAAmB,mCACnBC,cAAe"}
+10
View File
@@ -0,0 +1,10 @@
define("core_message/message_drawer_helper",["exports","core/pubsub","core_message/message_drawer_events"],(function(_exports,_pubsub,_message_drawer_events){var obj;
/**
* Provides some helper functions to trigger actions in the message drawer.
*
* @module core_message/message_drawer_helper
* @copyright 2018 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.waitForDrawerToLoad=_exports.showSettings=_exports.showConversation=_exports.show=_exports.markDrawerReady=_exports.hide=_exports.createConversationWithUser=void 0,_message_drawer_events=(obj=_message_drawer_events)&&obj.__esModule?obj:{default:obj};let drawerMarkedReady=!1;_exports.createConversationWithUser=async args=>{await waitForDrawerToLoad(),(0,_pubsub.publish)(_message_drawer_events.default.CREATE_CONVERSATION_WITH_USER,args)};_exports.hide=async()=>{await waitForDrawerToLoad(),(0,_pubsub.publish)(_message_drawer_events.default.HIDE)};_exports.show=async()=>{await waitForDrawerToLoad(),(0,_pubsub.publish)(_message_drawer_events.default.SHOW)};_exports.showConversation=async args=>{await waitForDrawerToLoad(),(0,_pubsub.publish)(_message_drawer_events.default.SHOW_CONVERSATION,args)};_exports.showSettings=async()=>{await waitForDrawerToLoad(),(0,_pubsub.publish)(_message_drawer_events.default.SHOW_SETTINGS)};const waitForDrawerToLoad=()=>new Promise((resolve=>{drawerMarkedReady?resolve():(0,_pubsub.subscribe)(_message_drawer_events.default.READY,resolve)}));_exports.waitForDrawerToLoad=waitForDrawerToLoad;_exports.markDrawerReady=()=>{drawerMarkedReady=!0,(0,_pubsub.publish)(_message_drawer_events.default.READY)}}));
//# sourceMappingURL=message_drawer_helper.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"message_drawer_helper.min.js","sources":["../src/message_drawer_helper.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 * Provides some helper functions to trigger actions in the message drawer.\n *\n * @module core_message/message_drawer_helper\n * @copyright 2018 Ryan Wyllie <ryan@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {publish, subscribe} from 'core/pubsub';\nimport MessageDrawerEvents from 'core_message/message_drawer_events';\n\n/** @property {boolean} Whether the drawer is ready or not */\nlet drawerMarkedReady = false;\n\n/**\n * Trigger an event to create a new conversation in the message drawer.\n *\n * @param {object} args\n * @param {Number} args.userId The user id to start a conversation.\n */\nexport const createConversationWithUser = async(args) => {\n await waitForDrawerToLoad();\n publish(MessageDrawerEvents.CREATE_CONVERSATION_WITH_USER, args);\n};\n\n/**\n * Trigger an event to hide the message drawer.\n */\nexport const hide = async() => {\n await waitForDrawerToLoad();\n publish(MessageDrawerEvents.HIDE);\n};\n\n/**\n * Trigger an event to show the message drawer.\n */\nexport const show = async() => {\n await waitForDrawerToLoad();\n publish(MessageDrawerEvents.SHOW);\n};\n\n/**\n * Trigger an event to show the given conversation.\n *\n * @param {object} args\n * @param {int} args.conversationId Id for the conversation to show.\n */\nexport const showConversation = async(args) => {\n await waitForDrawerToLoad();\n publish(MessageDrawerEvents.SHOW_CONVERSATION, args);\n};\n\n/**\n * Trigger an event to show messaging settings.\n */\nexport const showSettings = async() => {\n await waitForDrawerToLoad();\n publish(MessageDrawerEvents.SHOW_SETTINGS);\n};\n\n/**\n * Helper to wait for the drawer to be ready before performing an action.\n *\n * @returns {Promise<void>}\n */\nexport const waitForDrawerToLoad = () => new Promise((resolve) => {\n if (drawerMarkedReady) {\n resolve();\n } else {\n subscribe(MessageDrawerEvents.READY, resolve);\n }\n});\n\n/**\n * Helper to allow the drawer to mark itself as ready.\n */\nexport const markDrawerReady = () => {\n drawerMarkedReady = true;\n publish(MessageDrawerEvents.READY);\n};\n"],"names":["drawerMarkedReady","async","waitForDrawerToLoad","MessageDrawerEvents","CREATE_CONVERSATION_WITH_USER","args","HIDE","SHOW","SHOW_CONVERSATION","SHOW_SETTINGS","Promise","resolve","READY"],"mappings":";;;;;;;oUA2BIA,mBAAoB,sCAQkBC,MAAAA,aAChCC,0CACEC,+BAAoBC,8BAA+BC,qBAM3CJ,gBACVC,0CACEC,+BAAoBG,qBAMZL,gBACVC,0CACEC,+BAAoBI,iCASAN,MAAAA,aACtBC,0CACEC,+BAAoBK,kBAAmBH,6BAMvBJ,gBAClBC,0CACEC,+BAAoBM,sBAQnBP,oBAAsB,IAAM,IAAIQ,SAASC,UAC9CX,kBACAW,gCAEUR,+BAAoBS,MAAOD,sFAOd,KAC3BX,mBAAoB,sBACZG,+BAAoBS"}
+10
View File
@@ -0,0 +1,10 @@
/**
* Lazy loaded list of items.
*
* @module core_message/message_drawer_lazy_load_list
* @copyright 2018 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("core_message/message_drawer_lazy_load_list",["jquery","core/custom_interaction_events","core/pending"],(function($,CustomEvents,PendingPromise){var SELECTORS_ROOT='[data-region="lazy-load-list"]',SELECTORS_LOADING_ICON_CONTAINER='[data-region="loading-icon-container"]',SELECTORS_CONTENT_CONTAINER='[data-region="content-container"]',SELECTORS_EMPTY_MESSAGE='[data-region="empty-message-container"]',SELECTORS_PLACEHOLDER='[data-region="placeholder-container"]',stopLoading=function(root){root.attr("data-loading",!1)},getContentContainer=function(root){return root.find(SELECTORS_CONTENT_CONTAINER)},hideLoadingIcon=function(root){root.find(SELECTORS_LOADING_ICON_CONTAINER).addClass("hidden")},showEmptyMessage=function(root){root.find(SELECTORS_EMPTY_MESSAGE).removeClass("hidden")},hidePlaceholder=function(root){root.find(SELECTORS_PLACEHOLDER).addClass("hidden")},showContent=function(root){getContentContainer(root).removeClass("hidden")},hideContent=function(root){getContentContainer(root).addClass("hidden")},setLoadedAll=function(root,value){root.attr("data-loaded-all",value)},loadAndRender=function(root,loadCallback,renderCallback){var userId=function(root){return root.attr("data-user-id")}(root);return function(root){root.attr("data-loading",!0)}(root),loadCallback(root,userId).then((function(items){if(items.length>0){var contentContainer=getContentContainer(root);return renderCallback(contentContainer,items,userId).then((function(){return items}))}return items})).then((function(items){return stopLoading(root),root.attr("data-seen",!0),items.length||setLoadedAll(root,!0),items})).catch((function(){stopLoading(root),root.attr("data-seen",!0)}))},initialLoadAndRender=function(root,loadCallback,renderCallback){const pendingPromise=new PendingPromise("initialLoadAndRender");return getContentContainer(root).empty(),function(root){root.find(SELECTORS_PLACEHOLDER).removeClass("hidden")}(root),hideContent(root),loadAndRender(root,loadCallback,renderCallback).then((function(items){hidePlaceholder(root),items.length?showContent(root):showEmptyMessage(root)})).catch((function(){hidePlaceholder(root),showContent(root)})).then((()=>{pendingPromise.resolve()}))},registerEventListeners=function(root,loadCallback,renderCallback){CustomEvents.define(root,[CustomEvents.events.scrollBottom]),root.on(CustomEvents.events.scrollBottom,(function(){(function(root){return!function(root){return"true"==root.attr("data-loaded-all")}(root)&&!function(root){return"true"===root.attr("data-loading")}(root)})(root)&&(!function(root){root.find(SELECTORS_LOADING_ICON_CONTAINER).removeClass("hidden")}(root),loadAndRender(root,loadCallback,renderCallback).then((function(){return hideLoadingIcon(root)})).catch((function(){return hideLoadingIcon(root)})))}))};return{show:function(root,loadCallback,renderCallback){(root=$(root)).attr("data-init")||(registerEventListeners(root,loadCallback,renderCallback),initialLoadAndRender(root,loadCallback,renderCallback),root.attr("data-init",!0))},getContentContainer:getContentContainer,getRoot:function(containerElement){return containerElement.find(SELECTORS_ROOT)},setLoadedAll:setLoadedAll,showEmptyMessage:showEmptyMessage,hideEmptyMessage:function(root){root.find(SELECTORS_EMPTY_MESSAGE).addClass("hidden")},showContent:showContent,hideContent:hideContent}}));
//# sourceMappingURL=message_drawer_lazy_load_list.min.js.map
File diff suppressed because one or more lines are too long
+14
View File
@@ -0,0 +1,14 @@
/**
* A simple router for the message drawer that allows navigating between
* the "pages" in the drawer.
*
* This module will maintain a linear history of the unique pages access
* to allow navigating back.
*
* @module core_message/message_drawer_router
* @copyright 2018 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("core_message/message_drawer_router",["jquery","core/pubsub","core/str","core_message/message_drawer_events","core/aria","core/pending"],(function($,PubSub,Str,MessageDrawerEvents,Aria,PendingPromise){var routes={},history={},SELECTORS_CAN_RECEIVE_FOCUS='input:not([type="hidden"]), a[href], button, textarea, select, [tabindex]',SELECTORS_ROUTES_BACK="[data-route-back]",changeRoute=function(namespace,newRoute){var newConfig,pendingPromise=new PendingPromise("message-drawer-router-".concat(namespace,"-").concat(newRoute)),fromPanel=[].slice.call(arguments).some((function(arg){return"frompanel"==arg})),args=[].slice.call(arguments,2),renderPromise=$.Deferred().resolve().promise();if(Object.keys(routes[namespace]).forEach((function(route){var config=routes[namespace][route],isMatch=route===newRoute;isMatch&&(newConfig=config),config.parameters.forEach((function(element){"object"==typeof element&&null!==element&&(element.removeClass("previous"),element.attr("data-from-panel",!1),isMatch?(fromPanel&&element.attr("data-from-panel",!0),element.removeClass("hidden"),Aria.unhide(element.get())):element.attr("data-in-panel")&&"view-search"!=newRoute&&"view-overview"!=newRoute||(element.addClass("hidden"),Aria.hide(element.get())))}))})),newConfig&&newConfig.onGo){renderPromise=newConfig.onGo.apply(void 0,newConfig.parameters.concat(args));for(var currentFocusElement=$(document.activeElement),hasFocus=!1,firstFocusable=null,i=1;i<newConfig.parameters.length;i++){var element=newConfig.parameters[i];if("object"==typeof element&&null!==element&&(firstFocusable||(firstFocusable=element),element.has(currentFocusElement).length)){hasFocus=!0;break}}hasFocus||firstFocusable.find(SELECTORS_CAN_RECEIVE_FOCUS).filter(":visible").first().focus()}var record={route:newRoute,params:args,renderPromise:renderPromise};return PubSub.publish(MessageDrawerEvents.ROUTE_CHANGED,record),renderPromise.then((()=>pendingPromise.resolve())),record},go=function(namespace){var currentFocusElement=$(document.activeElement),record=changeRoute.apply(namespace,arguments),inHistory=!1;history[namespace]||(history[namespace]=[]),history[namespace]=history[namespace].reduce((function(carry,previous){return previous.route===record.route&&(inHistory=!0),inHistory||carry.push(previous),carry}),[]);var historylength=history[namespace].length,previousRecord=historylength?history[namespace][historylength-1]:null;if(previousRecord){for(var prevConfig=routes[namespace][previousRecord.route],elements=prevConfig.parameters,i=1;i<elements.length;i++)"object"==typeof elements[i]&&null!==elements[i]&&elements[i].addClass("previous");previousRecord.focusElement=currentFocusElement,prevConfig.getDescription&&prevConfig.getDescription.apply(null,prevConfig.parameters.concat(previousRecord.params)).then((function(description){return Str.get_string("backto","core_message",description)})).then((function(label){return record.renderPromise.then((function(){routes[namespace][record.route].parameters.forEach((function(element){"object"==typeof element&&element&&element.find(SELECTORS_ROUTES_BACK).attr("aria-label",label)}))}))})).catch((function(){}))}return history[namespace].push(record),record};return{add:function(namespace,route,parameters,onGo,getDescription){routes[namespace]||(routes[namespace]=[]),routes[namespace][route]={parameters:parameters,onGo:onGo,getDescription:getDescription}},go:go,back:function(namespace){if(history[namespace].length){history[namespace].pop();var previous=history[namespace].pop();previous&&(go.apply(void 0,[namespace,previous.route].concat(previous.params)),window.setTimeout((function(){previous.focusElement.focus()}),50))}}}}));
//# sourceMappingURL=message_drawer_router.min.js.map
File diff suppressed because one or more lines are too long
+10
View File
@@ -0,0 +1,10 @@
/**
* Available routes for the message drawer.
*
* @module core_message/message_drawer_routes
* @copyright 2018 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("core_message/message_drawer_routes",[],(function(){return{VIEW_CONTACT:"view-contact",VIEW_CONTACTS:"view-contacts",VIEW_CONVERSATION:"view-conversation",VIEW_GROUP_INFO:"view-group-info",VIEW_OVERVIEW:"view-overview",VIEW_SEARCH:"view-search",VIEW_SETTINGS:"view-settings"}}));
//# sourceMappingURL=message_drawer_routes.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"message_drawer_routes.min.js","sources":["../src/message_drawer_routes.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 * Available routes for the message drawer.\n *\n * @module core_message/message_drawer_routes\n * @copyright 2018 Ryan Wyllie <ryan@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([], function() {\n return {\n VIEW_CONTACT: 'view-contact',\n VIEW_CONTACTS: 'view-contacts',\n VIEW_CONVERSATION: 'view-conversation',\n VIEW_GROUP_INFO: 'view-group-info',\n VIEW_OVERVIEW: 'view-overview',\n VIEW_SEARCH: 'view-search',\n VIEW_SETTINGS: 'view-settings'\n };\n});\n"],"names":["define","VIEW_CONTACT","VIEW_CONTACTS","VIEW_CONVERSATION","VIEW_GROUP_INFO","VIEW_OVERVIEW","VIEW_SEARCH","VIEW_SETTINGS"],"mappings":";;;;;;;AAsBAA,4CAAO,IAAI,iBACA,CACHC,aAAc,eACdC,cAAe,gBACfC,kBAAmB,oBACnBC,gBAAiB,kBACjBC,cAAe,gBACfC,YAAa,cACbC,cAAe"}
+10
View File
@@ -0,0 +1,10 @@
/**
* Controls the contact page in the message drawer.
*
* @module core_message/message_drawer_view_contact
* @copyright 2018 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("core_message/message_drawer_view_contact",["jquery","core/str","core/templates"],(function($,Str,Templates){var SELECTORS_CONTENT_CONTAINER='[data-region="content-container"]',TEMPLATES_CONTENT="core_message/message_drawer_view_contact_body_content",getContentContainer=function(root){return root.find(SELECTORS_CONTENT_CONTAINER)};return{show:function(namespace,header,body,footer,contact){var root=$(body);return getContentContainer(root).empty(),function(root,profile){return Templates.render(TEMPLATES_CONTENT,profile).then((function(html){return getContentContainer(root).append(html),html}))}(root,contact)},description:function(root,contact){return Str.get_string("messagedrawerviewcontact","core_message",contact.fullname)}}}));
//# sourceMappingURL=message_drawer_view_contact.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"message_drawer_view_contact.min.js","sources":["../src/message_drawer_view_contact.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 * Controls the contact page in the message drawer.\n *\n * @module core_message/message_drawer_view_contact\n * @copyright 2018 Ryan Wyllie <ryan@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(\n[\n 'jquery',\n 'core/str',\n 'core/templates'\n],\nfunction(\n $,\n Str,\n Templates\n) {\n\n var SELECTORS = {\n CONTENT_CONTAINER: '[data-region=\"content-container\"]'\n };\n\n var TEMPLATES = {\n CONTENT: 'core_message/message_drawer_view_contact_body_content'\n };\n\n /**\n * Get the content container of the contact view container.\n *\n * @param {Object} root Contact container element.\n * @returns {Object} jQuery object\n */\n var getContentContainer = function(root) {\n return root.find(SELECTORS.CONTENT_CONTAINER);\n };\n\n /**\n * Render the contact profile in the content container.\n *\n * @param {Object} root Contact container element.\n * @param {Object} profile Contact profile details.\n * @returns {Object} jQuery promise\n */\n var render = function(root, profile) {\n return Templates.render(TEMPLATES.CONTENT, profile)\n .then(function(html) {\n getContentContainer(root).append(html);\n return html;\n });\n };\n\n /**\n * Setup the contact page.\n *\n * @param {string} namespace The route namespace.\n * @param {Object} header Contact header element.\n * @param {Object} body Contact body container element.\n * @param {Object} footer Contact footer container element.\n * @param {Object} contact The contact object.\n * @returns {Object} jQuery promise\n */\n var show = function(namespace, header, body, footer, contact) {\n var root = $(body);\n\n getContentContainer(root).empty();\n return render(root, contact);\n };\n\n /**\n * String describing this page used for aria-labels.\n *\n * @param {Object} root Contact container element.\n * @param {Object} contact The contact object.\n * @return {Object} jQuery promise\n */\n var description = function(root, contact) {\n return Str.get_string('messagedrawerviewcontact', 'core_message', contact.fullname);\n };\n\n return {\n show: show,\n description: description\n };\n});\n"],"names":["define","$","Str","Templates","SELECTORS","TEMPLATES","getContentContainer","root","find","show","namespace","header","body","footer","contact","empty","profile","render","then","html","append","description","get_string","fullname"],"mappings":";;;;;;;AAsBAA,kDACA,CACI,SACA,WACA,mBAEJ,SACIC,EACAC,IACAC,eAGIC,4BACmB,oCAGnBC,kBACS,wDASTC,oBAAsB,SAASC,aACxBA,KAAKC,KAAKJ,oCA8Cd,CACHK,KAnBO,SAASC,UAAWC,OAAQC,KAAMC,OAAQC,aAC7CP,KAAON,EAAEW,aAEbN,oBAAoBC,MAAMQ,QArBjB,SAASR,KAAMS,gBACjBb,UAAUc,OAAOZ,kBAAmBW,SACtCE,MAAK,SAASC,aACXb,oBAAoBC,MAAMa,OAAOD,MAC1BA,QAkBRF,CAAOV,KAAMO,UAgBpBO,YANc,SAASd,KAAMO,gBACtBZ,IAAIoB,WAAW,2BAA4B,eAAgBR,QAAQS"}
+10
View File
@@ -0,0 +1,10 @@
/**
* Controls the contacts page of the message drawer.
*
* @module core_message/message_drawer_view_contacts
* @copyright 2018 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("core_message/message_drawer_view_contacts",["jquery","core/pubsub","core/str","core_message/message_drawer_events","core_message/message_drawer_view_contacts_section_contacts","core_message/message_drawer_view_contacts_section_requests"],(function($,PubSub,Str,MessageDrawerEvents,ContactsSection,RequestsSection){var SELECTORS_ACTION_SHOW_CONTACTS_SECTION='[data-action="show-contacts-section"]',SELECTORS_ACTION_SHOW_REQUESTS_SECTION='[data-action="show-requests-section"]',SELECTORS_CONTACT_REQUEST_COUNT='[data-region="contact-request-count"]',SELECTORS_CONTACTS_SECTION_CONTAINER='[data-section="contacts"]',SELECTORS_REQUESTS_SECTION_CONTAINER='[data-section="requests"]',getContactsSectionContainer=function(body){return body.find(SELECTORS_CONTACTS_SECTION_CONTAINER)},getRequestsSectionContainer=function(body){return body.find(SELECTORS_REQUESTS_SECTION_CONTAINER)},getShowContactsAction=function(body){return body.find(SELECTORS_ACTION_SHOW_CONTACTS_SECTION)},getShowRequestsAction=function(body){return body.find(SELECTORS_ACTION_SHOW_REQUESTS_SECTION)},decrementContactRequestCount=function(body){return function(){var countContainer=body.find(SELECTORS_CONTACT_REQUEST_COUNT),count=parseInt(countContainer.text(),10);(count=isNaN(count)?0:count-1)<=0?countContainer.addClass("hidden"):countContainer.text(count)}};return{show:function(namespace,header,body,footer,tab){(body=$(body)).attr("data-contacts-init")||(!function(body){var contactsSection=getContactsSectionContainer(body),requestsSection=getRequestsSectionContainer(body),showContactsAction=getShowContactsAction(body),showRequestsAction=getShowRequestsAction(body);showContactsAction.on("show.bs.tab",(function(){ContactsSection.show(contactsSection)})),showRequestsAction.on("show.bs.tab",(function(){RequestsSection.show(requestsSection)})),PubSub.subscribe(MessageDrawerEvents.CONTACT_REQUEST_ACCEPTED,decrementContactRequestCount(body)),PubSub.subscribe(MessageDrawerEvents.CONTACT_REQUEST_DECLINED,decrementContactRequestCount(body))}(body),body.attr("data-contacts-init",!0));var contactsSection=getContactsSectionContainer(body),requestsSection=getRequestsSectionContainer(body);if(tab){var showContactsAction=getShowContactsAction(body),showRequestsAction=getShowRequestsAction(body);"requests"==tab?(showContactsAction.removeClass("active"),contactsSection.removeClass("show active"),showRequestsAction.addClass("active"),requestsSection.addClass("show active")):(showRequestsAction.removeClass("active"),requestsSection.removeClass("show active"),showContactsAction.addClass("active"),contactsSection.addClass("show active"))}return contactsSection.hasClass("active")?ContactsSection.show(contactsSection):RequestsSection.show(requestsSection),$.Deferred().resolve().promise()},description:function(){return Str.get_string("messagedrawerviewcontacts","core_message")}}}));
//# sourceMappingURL=message_drawer_view_contacts.min.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,10 @@
/**
* Controls the contacts section of the contacts page.
*
* @module core_message/message_drawer_view_contacts_section_contacts
* @copyright 2018 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("core_message/message_drawer_view_contacts_section_contacts",["jquery","core/notification","core/pubsub","core/templates","core_message/message_repository","core_message/message_drawer_events","core_message/message_drawer_lazy_load_list"],(function($,Notification,PubSub,Templates,MessageRepository,Events,LazyLoadList){var SELECTORS_BLOCK_ICON_CONTAINER='[data-region="block-icon-container"]',SELECTORS_CONTACT='[data-region="contact"]',TEMPLATES_CONTACTS_LIST="core_message/message_drawer_contacts_list",findContact=function(body,userId){return body.find('[data-contact-user-id="'+userId+'"]')},render=function(contentContainer,contacts){var formattedContacts=contacts.map((function(contact){return $.extend(contact,{id:contact.userid})}));return Templates.render(TEMPLATES_CONTACTS_LIST,{contacts:formattedContacts}).then((function(html){return contentContainer.append(html),html})).catch(Notification.exception)},registerEventListeners=function(root){PubSub.subscribe(Events.CONTACT_ADDED,(function(profile){var listContentContainer=LazyLoadList.getContentContainer(root);render(listContentContainer,[profile]),LazyLoadList.hideEmptyMessage(root),LazyLoadList.showContent(root)})),PubSub.subscribe(Events.CONTACT_REMOVED,(function(userId){!function(body,userId){findContact(body,userId).remove()}(root,userId),root.find(SELECTORS_CONTACT).length||(LazyLoadList.hideContent(root),LazyLoadList.showEmptyMessage(root))})),PubSub.subscribe(Events.CONTACT_BLOCKED,(function(userId){!function(body,userId){var contact=findContact(body,userId);contact.length&&contact.find(SELECTORS_BLOCK_ICON_CONTAINER).removeClass("hidden")}(root,userId)})),PubSub.subscribe(Events.CONTACT_UNBLOCKED,(function(userId){!function(body,userId){var contact=findContact(body,userId);contact.length&&contact.find(SELECTORS_BLOCK_ICON_CONTAINER).addClass("hidden")}(root,userId)}))};return{show:function(root){var offset;root.attr("data-contacts-init")||(registerEventListeners(root),root.attr("data-contacts-init",!0)),LazyLoadList.show(root,(offset=0,function(listRoot,userId){return MessageRepository.getContacts(userId,101,offset).then((function(result){return result})).then((function(contacts){return contacts.length>100?contacts.pop():LazyLoadList.setLoadedAll(listRoot,!0),contacts})).then((function(contacts){return offset+=100,contacts})).catch(Notification.exception)}),render)}}}));
//# sourceMappingURL=message_drawer_view_contacts_section_contacts.min.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,10 @@
/**
* Controls the requests section of the contacts page.
*
* @module core_message/message_drawer_view_contacts_section_requests
* @copyright 2018 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("core_message/message_drawer_view_contacts_section_requests",["jquery","core/notification","core/pubsub","core/templates","core_message/message_repository","core_message/message_drawer_events","core_message/message_drawer_lazy_load_list"],(function($,Notification,PubSub,Templates,MessageRepository,MessageDrawerEvents,LazyLoadList){var SELECTORS_CONTACT_REQUEST='[data-region="contact-request"]',TEMPLATES_REQUESTS_LIST="core_message/message_drawer_view_contacts_body_section_requests_list",render=function(contentContainer,requests){var formattedRequests=requests.map((function(request){return{id:request.id,profileimageurl:request.profileimageurl,fullname:request.fullname}}));return Templates.render(TEMPLATES_REQUESTS_LIST,{requests:formattedRequests}).then((function(html){return contentContainer.append(html),html})).catch(Notification.exception)},load=function(listRoot,userId){return MessageRepository.getContactRequests(userId).then((function(requests){return LazyLoadList.setLoadedAll(listRoot,!0),requests})).catch(Notification.exception)},handleContactRequestProcessed=function(root){return function(request){root.find('[data-request-id="'+request.userid+'"]').remove(),root.find(SELECTORS_CONTACT_REQUEST).length||(LazyLoadList.showEmptyMessage(root),LazyLoadList.hideContent(root))}};return{show:function(root){root.attr("data-contacts-init")||(!function(root){PubSub.subscribe(MessageDrawerEvents.CONTACT_REQUEST_ACCEPTED,handleContactRequestProcessed(root)),PubSub.subscribe(MessageDrawerEvents.CONTACT_REQUEST_DECLINED,handleContactRequestProcessed(root))}(root),root.attr("data-contacts-init",!0)),LazyLoadList.show(root,load,render)}}}));
//# sourceMappingURL=message_drawer_view_contacts_section_requests.min.js.map
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+10
View File
@@ -0,0 +1,10 @@
/**
* Controls the group info page of the message drawer.
*
* @module core_message/message_drawer_view_group_info
* @copyright 2018 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("core_message/message_drawer_view_group_info",["jquery","core/str","core/templates","core_message/message_repository","core_message/message_drawer_lazy_load_list"],(function($,Str,Templates,Repository,LazyLoadList){var SELECTORS_CONTENT_CONTAINER='[data-region="group-info-content-container"]',TEMPLATES_CONTENT="core_message/message_drawer_view_group_info_body_content",TEMPLATES_MEMBERS_LIST="core_message/message_drawer_view_group_info_participants_list",getContentContainer=function(root){return root.find(SELECTORS_CONTENT_CONTAINER)},renderMembersCallback=function(contentContainer,members){return Templates.render(TEMPLATES_MEMBERS_LIST,{contacts:members}).then((function(html){return contentContainer.append(html),html}))};return{show:function(namespace,header,body,footer,conversation,loggedInUserId){var root=$(body);return getContentContainer(root).empty(),function(root,conversation,loggedInUserId){var placeholderCount=conversation.totalMemberCount>50?50:conversation.totalMemberCount,placeholders=Array.apply(null,Array(placeholderCount)).map((function(){return!0})),templateContext={name:conversation.name,subname:conversation.subname,imageurl:conversation.imageUrl,placeholders:placeholders,loggedinuser:{id:loggedInUserId}};return Templates.render(TEMPLATES_CONTENT,templateContext).then((function(html){return getContentContainer(root).append(html),html}))}(root,conversation,loggedInUserId).then((function(){var listRoot=LazyLoadList.getRoot(root);LazyLoadList.show(listRoot,function(conversation,limit,offset){return function(root,userId){return Repository.getConversationMembers(conversation.id,userId,limit+1,offset).then((function(members){return members.length>limit?members=members.slice(0,-1):LazyLoadList.setLoadedAll(root,!0),offset+=limit,members.filter((function(member){return member.id!=userId}))}))}}(conversation,50,0),renderMembersCallback)}))},description:function(root,conversation){return Str.get_string("messagedrawerviewgroupinfo","core_message",conversation.name)}}}));
//# sourceMappingURL=message_drawer_view_group_info.min.js.map
File diff suppressed because one or more lines are too long
+10
View File
@@ -0,0 +1,10 @@
/**
* Controls the overview page of the message drawer.
*
* @module core_message/message_drawer_view_overview
* @copyright 2018 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("core_message/message_drawer_view_overview",["jquery","core/key_codes","core/pubsub","core/str","core_message/message_drawer_router","core_message/message_drawer_routes","core_message/message_drawer_events","core_message/message_drawer_view_overview_section","core_message/message_repository","core_message/message_drawer_view_conversation_constants"],(function($,KeyCodes,PubSub,Str,Router,Routes,MessageDrawerEvents,Section,MessageRepository,Constants){var SELECTORS_CONTACT_REQUEST_COUNT='[data-region="contact-request-count"]',SELECTORS_FAVOURITES='[data-region="view-overview-favourites"]',SELECTORS_GROUP_MESSAGES='[data-region="view-overview-group-messages"]',SELECTORS_MESSAGES='[data-region="view-overview-messages"]',SELECTORS_SEARCH_INPUT='[data-region="view-overview-search-input"]',SELECTORS_SECTION_TOGGLE_BUTTON="[data-toggle]",OVERVIEW_SECTION_TYPES={PRIVATE:[Constants.CONVERSATION_TYPES.PRIVATE,Constants.CONVERSATION_TYPES.SELF],PUBLIC:[Constants.CONVERSATION_TYPES.PUBLIC],FAVOURITE:null},loadAllCountsPromise=null,filterCountsByTypes=function(counts,types,includeFavourites){var total=0;return types&&types.length&&(total=types.reduce((function(carry,type){return carry+counts.types[type]}),total)),includeFavourites&&(total+=counts.favourites),total},getSearchInput=function(header){return header.find(SELECTORS_SEARCH_INPUT)},decrementContactRequestCount=function(header){return function(){var countContainer=header.find(SELECTORS_CONTACT_REQUEST_COUNT),count=parseInt(countContainer.text(),10);(count=isNaN(count)?0:count-1)<=0?countContainer.addClass("hidden"):countContainer.text(count)}};return{show:function(namespace,header,body){header.attr("data-init")||(!function(namespace,header){var searchInput=getSearchInput(header),ignoredKeys=[KeyCodes.tab,KeyCodes.shift,KeyCodes.ctrl,KeyCodes.alt];searchInput.on("click",(function(){Router.go(namespace,Routes.VIEW_SEARCH)})),searchInput.on("keydown",(function(e){ignoredKeys.indexOf(e.keyCode)<0&&"Meta"!=e.key&&Router.go(namespace,Routes.VIEW_SEARCH)})),PubSub.subscribe(MessageDrawerEvents.CONTACT_REQUEST_ACCEPTED,decrementContactRequestCount(header)),PubSub.subscribe(MessageDrawerEvents.CONTACT_REQUEST_DECLINED,decrementContactRequestCount(header))}(namespace,header),header.attr("data-init",!0));var fromPanel=header.attr("data-in-panel")?"frompanel":null;getSearchInput(header).val("");var loggedInUserId=function(body){return body.attr("data-user-id")}(body),allCounts=function(loggedInUserId){return null===loadAllCountsPromise&&(loadAllCountsPromise=MessageRepository.getAllConversationCounts(loggedInUserId)),loadAllCountsPromise}(loggedInUserId),sections=[[body.find(SELECTORS_FAVOURITES),OVERVIEW_SECTION_TYPES.FAVOURITE,!0],[body.find(SELECTORS_GROUP_MESSAGES),OVERVIEW_SECTION_TYPES.PUBLIC,!1],[body.find(SELECTORS_MESSAGES),OVERVIEW_SECTION_TYPES.PRIVATE,!1]];return sections.forEach((function(args){var sectionRoot=args[0],sectionTypes=args[1],includeFavourites=args[2],totalCountPromise=allCounts.then((function(result){return filterCountsByTypes(result.total,sectionTypes,includeFavourites)})),unreadCountPromise=allCounts.then((function(result){return filterCountsByTypes(result.unread,sectionTypes,includeFavourites)}));Section.show(namespace,null,sectionRoot,null,sectionTypes,includeFavourites,totalCountPromise,unreadCountPromise,fromPanel)})),allCounts.then((function(result){return function(sections){sections.some((function(section){var sectionRoot=section[0];return Section.isVisible(sectionRoot)}))||(sections.sort((function(a,b){var aTotal=a[1],aUnread=a[2],bTotal=b[1],bUnread=b[2];return aUnread>0&&0==bUnread?-1:0==aUnread&&bUnread>0?1:aTotal>0&&0==bTotal?-1:0==aTotal&&bTotal>0?1:0})),sections[0][0].find(SELECTORS_SECTION_TOGGLE_BUTTON).click())}(sections.map((function(section){var sectionRoot=section[0],sectionTypes=section[1],includeFavourites=section[2];return[sectionRoot,filterCountsByTypes(result.total,sectionTypes,includeFavourites),filterCountsByTypes(result.unread,sectionTypes,includeFavourites)]})))}))},description:function(){return Str.get_string("messagedrawerviewoverview","core_message")}}}));
//# sourceMappingURL=message_drawer_view_overview.min.js.map
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+10
View File
@@ -0,0 +1,10 @@
/**
* Controls the settings page in the message drawer.
*
* @module core_message/message_drawer_view_settings
* @copyright 2018 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("core_message/message_drawer_view_settings",["jquery","core/notification","core/str","core/pubsub","core/templates","core_message/message_repository","core/custom_interaction_events","core_message/message_drawer_events"],(function($,Notification,Str,PubSub,Templates,Repository,CustomEvents,MessageDrawerEvents){var SELECTORS_CHECKBOX='input[type="checkbox"]',SELECTORS_SETTINGS='[data-region="settings"]',SELECTORS_PRIVACY_PREFERENCE='[data-preference="blocknoncontacts"] input[type="radio"]',SELECTORS_NOTIFICATIONS_PREFERENCE='[data-preference="notifications"] input[type="checkbox"]',SELECTORS_ENTER_TO_SEND_PREFERENCE='[data-preference="entertosend"] input[type="checkbox"]',SELECTORS_NOTIFICATION_PREFERENCES_CONTAINER='[data-region="notification-preference-container"]',SELECTORS_CONTENT_CONTAINER='[data-region="content-container"]',SELECTORS_PLACEHOLDER_CONTAINER='[data-region="placeholder-container"]',TEMPLATES_NOTIFICATION_PREFERENCES="core_message/message_drawer_view_settings_body_content_notification_preferences",savePreferences=function(loggedInUserId,preferences){return Repository.savePreferences(loggedInUserId,preferences).then((function(){PubSub.publish(MessageDrawerEvents.PREFERENCES_UPDATED,preferences)})).catch(Notification.exception)},init=function(body,loggedInUserId){Repository.getUserMessagePreferences(loggedInUserId).then((function(response){!function(body,value){body.find(SELECTORS_PRIVACY_PREFERENCE).each((function(index,input){(input=$(input)).val()==value?input.prop("checked",!0):input.prop("checked",!1)}))}(body,response.blocknoncontacts),function(body,value){var checkbox=body.find(SELECTORS_ENTER_TO_SEND_PREFERENCE);value?checkbox.prop("checked",!0):checkbox.prop("checked",!1)}(body,response.entertosend);var notificationProcessors=[];response.preferences.components.length&&response.preferences.components.forEach((function(component){if(component.notifications.length&&component.notifications.filter((function(notification){return"message_provider_moodle_instantmessage"==notification.preferencekey})).length){var configuration=component.notifications[0];notificationProcessors=configuration.processors.map((function(processor){var checked=processor.enabled;return{displayname:processor.displayname,name:processor.name,checked:checked,locked:processor.locked,lockedmessage:processor.lockedmessage||null}}))}}));var container=body.find(SELECTORS_NOTIFICATION_PREFERENCES_CONTAINER);return!notificationProcessors.length||(container.removeClass("hidden"),Templates.render(TEMPLATES_NOTIFICATION_PREFERENCES,{processors:notificationProcessors}).then((function(html){return container.append(html),html})))})).then((function(){body.find(SELECTORS_CONTENT_CONTAINER).removeClass("hidden"),body.find(SELECTORS_PLACEHOLDER_CONTAINER).addClass("hidden"),function(body,loggedInUserId){var settingsContainer=body.find(SELECTORS_SETTINGS);CustomEvents.define(settingsContainer,[CustomEvents.events.activate]),settingsContainer.on(CustomEvents.events.activate,SELECTORS_NOTIFICATIONS_PREFERENCE,(function(e){var checkboxes=$(e.target).closest(SELECTORS_NOTIFICATION_PREFERENCES_CONTAINER).find(SELECTORS_CHECKBOX);if(checkboxes.length){var values=checkboxes.toArray().reduce((function(carry,checkbox){return(checkbox=$(checkbox)).prop("checked")&&carry.push(checkbox.attr("data-name")),carry}),[]),newValue=values.length?values.join(","):"none";savePreferences(loggedInUserId,[{type:"message_provider_moodle_instantmessage_enabled",value:newValue}])}})),settingsContainer.on("change",SELECTORS_PRIVACY_PREFERENCE,(function(e){var newValue=$(e.target).val();savePreferences(loggedInUserId,[{type:"message_blocknoncontacts",value:newValue}])})),settingsContainer.on(CustomEvents.events.activate,SELECTORS_ENTER_TO_SEND_PREFERENCE,(function(e){var newValue=$(e.target).prop("checked");savePreferences(loggedInUserId,[{type:"message_entertosend",value:newValue}])}))}(body,loggedInUserId)})).catch(Notification.exception)};return{show:function(namespace,header,body,footer,loggedInUserId){return body.attr("data-init")||(init(body,loggedInUserId),body.attr("data-init",!0)),$.Deferred().resolve().promise()},description:function(){return Str.get_string("messagedrawerviewsettings","core_message")}}}));
//# sourceMappingURL=message_drawer_view_settings.min.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,11 @@
/**
* Controls the preference for an individual notification type on the
* message preference page.
*
* @module core_message/message_notification_preference
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("core_message/message_notification_preference",["jquery","core_message/notification_preference"],(function($,NotificationPreference){var SELECTORS_PREFERENCE_KEY="[data-preference-key]",MessageNotificationPreference=function(element,userId){NotificationPreference.call(this,element,userId)};return(MessageNotificationPreference.prototype=Object.create(NotificationPreference.prototype)).constructor=MessageNotificationPreference,MessageNotificationPreference.prototype.getPreferenceKey=function(){return this.root.find(SELECTORS_PREFERENCE_KEY).attr("data-preference-key")},MessageNotificationPreference}));
//# sourceMappingURL=message_notification_preference.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"message_notification_preference.min.js","sources":["../src/message_notification_preference.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 * Controls the preference for an individual notification type on the\n * message preference page.\n *\n * @module core_message/message_notification_preference\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', 'core_message/notification_preference'],\n function($, NotificationPreference) {\n\n var SELECTORS = {\n PREFERENCE_KEY: '[data-preference-key]',\n };\n\n /**\n * Constructor for the Preference.\n *\n * @class\n * @param {object} element jQuery object root element of the preference\n * @param {int} userId The current user id\n */\n var MessageNotificationPreference = function(element, userId) {\n NotificationPreference.call(this, element, userId);\n };\n\n /**\n * Clone the parent prototype.\n */\n MessageNotificationPreference.prototype = Object.create(NotificationPreference.prototype);\n\n /**\n * Set constructor.\n */\n MessageNotificationPreference.prototype.constructor = MessageNotificationPreference;\n\n /**\n * Get the unique prefix key that identifies this user preference.\n *\n * @method getPreferenceKey\n * @return {string}\n */\n MessageNotificationPreference.prototype.getPreferenceKey = function() {\n return this.root.find(SELECTORS.PREFERENCE_KEY).attr('data-preference-key');\n };\n\n return MessageNotificationPreference;\n});\n"],"names":["define","$","NotificationPreference","SELECTORS","MessageNotificationPreference","element","userId","call","this","prototype","Object","create","constructor","getPreferenceKey","root","find","attr"],"mappings":";;;;;;;;AAuBAA,sDAAO,CAAC,SAAU,yCACV,SAASC,EAAGC,4BAEZC,yBACgB,wBAUhBC,8BAAgC,SAASC,QAASC,QAClDJ,uBAAuBK,KAAKC,KAAMH,QAASC,gBAM/CF,8BAA8BK,UAAYC,OAAOC,OAAOT,uBAAuBO,YAKvCG,YAAcR,8BAQtDA,8BAA8BK,UAAUI,iBAAmB,kBAChDL,KAAKM,KAAKC,KAAKZ,0BAA0Ba,KAAK,wBAGlDZ"}
+10
View File
@@ -0,0 +1,10 @@
/**
* Controls the message popover in the nav bar.
*
* @module core_message/message_popover
* @copyright 2018 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("core_message/message_popover",["jquery","core/custom_interaction_events","core/pubsub","core_message/message_drawer_events"],(function($,CustomEvents,PubSub,MessageDrawerEvents){var SELECTORS_COUNT_CONTAINER='[data-region="count-container"]',handleDecrementConversationCount=function(button){return function(){var countContainer=button.find(SELECTORS_COUNT_CONTAINER),count=parseInt(countContainer.text(),10);isNaN(count)||!count||count<2?countContainer.addClass("hidden"):(count-=1,countContainer.text(count))}},registerEventListeners=function(button){CustomEvents.define(button,[CustomEvents.events.activate]),button.on(CustomEvents.events.activate,(function(e,data){var buttonid;buttonid=button.attr("id"),PubSub.publish(MessageDrawerEvents.TOGGLE_VISIBILITY,buttonid),button.focus(),data.originalEvent.preventDefault()})),PubSub.subscribe(MessageDrawerEvents.CONVERSATION_READ,handleDecrementConversationCount(button)),PubSub.subscribe(MessageDrawerEvents.CONTACT_REQUEST_ACCEPTED,handleDecrementConversationCount(button)),PubSub.subscribe(MessageDrawerEvents.CONTACT_REQUEST_DECLINED,handleDecrementConversationCount(button))};return{init:function(button){button=$(button),registerEventListeners(button)}}}));
//# sourceMappingURL=message_popover.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"message_popover.min.js","sources":["../src/message_popover.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 * Controls the message popover in the nav bar.\n *\n * @module core_message/message_popover\n * @copyright 2018 Ryan Wyllie <ryan@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(\n[\n 'jquery',\n 'core/custom_interaction_events',\n 'core/pubsub',\n 'core_message/message_drawer_events'\n],\nfunction(\n $,\n CustomEvents,\n PubSub,\n MessageDrawerEvents\n) {\n var SELECTORS = {\n COUNT_CONTAINER: '[data-region=\"count-container\"]'\n };\n\n /**\n * Toggle the message drawer visibility.\n *\n * @param {String} buttonid The button id for the popover.\n */\n var toggleMessageDrawerVisibility = function(buttonid) {\n PubSub.publish(MessageDrawerEvents.TOGGLE_VISIBILITY, buttonid);\n };\n\n /**\n * Decrement the unread conversation count in the nav bar if a conversation\n * is read. When there are no unread conversations then hide the counter.\n *\n * @param {Object} button The button element for the popover.\n * @return {Function}\n */\n var handleDecrementConversationCount = function(button) {\n return function() {\n var countContainer = button.find(SELECTORS.COUNT_CONTAINER);\n var count = parseInt(countContainer.text(), 10);\n\n if (isNaN(count)) {\n countContainer.addClass('hidden');\n } else if (!count || count < 2) {\n countContainer.addClass('hidden');\n } else {\n count = count - 1;\n countContainer.text(count);\n }\n };\n };\n\n /**\n * Add events listeners for when the popover icon is clicked and when conversations\n * are read.\n *\n * @param {Object} button The button element for the popover.\n */\n var registerEventListeners = function(button) {\n CustomEvents.define(button, [CustomEvents.events.activate]);\n\n button.on(CustomEvents.events.activate, function(e, data) {\n toggleMessageDrawerVisibility(button.attr('id'));\n button.focus();\n data.originalEvent.preventDefault();\n });\n\n PubSub.subscribe(MessageDrawerEvents.CONVERSATION_READ, handleDecrementConversationCount(button));\n PubSub.subscribe(MessageDrawerEvents.CONTACT_REQUEST_ACCEPTED, handleDecrementConversationCount(button));\n PubSub.subscribe(MessageDrawerEvents.CONTACT_REQUEST_DECLINED, handleDecrementConversationCount(button));\n };\n\n /**\n * Initialise the message popover.\n *\n * @param {Object} button The button element for the popover.\n */\n var init = function(button) {\n button = $(button);\n registerEventListeners(button);\n };\n\n return {\n init: init,\n };\n});\n"],"names":["define","$","CustomEvents","PubSub","MessageDrawerEvents","SELECTORS","handleDecrementConversationCount","button","countContainer","find","count","parseInt","text","isNaN","addClass","registerEventListeners","events","activate","on","e","data","buttonid","attr","publish","TOGGLE_VISIBILITY","focus","originalEvent","preventDefault","subscribe","CONVERSATION_READ","CONTACT_REQUEST_ACCEPTED","CONTACT_REQUEST_DECLINED","init"],"mappings":";;;;;;;AAsBAA,sCACA,CACI,SACA,iCACA,cACA,uCAEJ,SACIC,EACAC,aACAC,OACAC,yBAEIC,0BACiB,kCAmBjBC,iCAAmC,SAASC,eACrC,eACCC,eAAiBD,OAAOE,KAAKJ,2BAC7BK,MAAQC,SAASH,eAAeI,OAAQ,IAExCC,MAAMH,SAEEA,OAASA,MAAQ,EADzBF,eAAeM,SAAS,WAIxBJ,OAAgB,EAChBF,eAAeI,KAAKF,UAW5BK,uBAAyB,SAASR,QAClCL,aAAaF,OAAOO,OAAQ,CAACL,aAAac,OAAOC,WAEjDV,OAAOW,GAAGhB,aAAac,OAAOC,UAAU,SAASE,EAAGC,MApCpB,IAASC,SAAAA,SAqCPd,OAAOe,KAAK,MApC9CnB,OAAOoB,QAAQnB,oBAAoBoB,kBAAmBH,UAqClDd,OAAOkB,QACPL,KAAKM,cAAcC,oBAGvBxB,OAAOyB,UAAUxB,oBAAoByB,kBAAmBvB,iCAAiCC,SACzFJ,OAAOyB,UAAUxB,oBAAoB0B,yBAA0BxB,iCAAiCC,SAChGJ,OAAOyB,UAAUxB,oBAAoB2B,yBAA0BzB,iCAAiCC,gBAa7F,CACHyB,KANO,SAASzB,QAChBA,OAASN,EAAEM,QACXQ,uBAAuBR"}
+10
View File
@@ -0,0 +1,10 @@
/**
* Controls the message preference page.
*
* @module core_message/message_preferences
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("core_message/message_preferences",["jquery","core/ajax","core/notification","core_message/message_notification_preference","core/custom_interaction_events"],(function($,Ajax,Notification,MessageNotificationPreference,CustomEvents){var SELECTORS_PREFERENCE="[data-state]",SELECTORS_PREFERENCES_CONTAINER='[data-region="preferences-container"]',SELECTORS_CONTACTABLE_PRIVACY_CONTAINER='[data-region="privacy-setting-container"]',MessagePreferences=function(element){this.root=$(element),this.userId=this.root.find(SELECTORS_PREFERENCES_CONTAINER).attr("data-user-id"),this.registerEventListeners()};return MessagePreferences.prototype.preferencesDisabled=function(){return this.root.find(SELECTORS_PREFERENCES_CONTAINER).hasClass("disabled")},MessagePreferences.prototype.saveContactablePrivacySetting=function(){var container=this.root.find(SELECTORS_CONTACTABLE_PRIVACY_CONTAINER),value=$("input[type='radio']:checked").val();if(container.hasClass("loading"))return $.Deferred().resolve();container.addClass("loading");var request={methodname:"core_user_update_user_preferences",args:{userid:this.userId,preferences:[{type:container.attr("data-preference-key"),value:value}]}};return Ajax.call([request])[0].fail(Notification.exception).always((function(){container.removeClass("loading")}))},MessagePreferences.prototype.registerEventListeners=function(){CustomEvents.define(this.root,[CustomEvents.events.activate]),this.root.on("change",function(e){if("message_blocknoncontacts"==e.target.name)this.saveContactablePrivacySetting();else if(!this.preferencesDisabled()){var preferencesContainer=$(e.target).closest(SELECTORS_PREFERENCES_CONTAINER),preferenceElement=$(e.target).closest(SELECTORS_PREFERENCE),messagePreference=new MessageNotificationPreference(preferencesContainer,this.userId);preferenceElement.addClass("loading"),messagePreference.save().always((function(){preferenceElement.removeClass("loading")}))}}.bind(this))},MessagePreferences}));
//# sourceMappingURL=message_preferences.min.js.map
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+10
View File
@@ -0,0 +1,10 @@
define("core_message/message_send_bulk",["exports","core/str","core/modal_save_cancel","core/templates","core/modal_events","core/ajax","core/notification"],(function(_exports,_str,_modal_save_cancel,_templates,_modal_events,_ajax,_notification){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}
/**
* Send bulk message to the given user ids.
*
* @module core_message/message_send_bulk
* @copyright 2019 Shamim Rezaie <shamim@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.showModal=_exports.sendMessage=void 0,_modal_save_cancel=_interopRequireDefault(_modal_save_cancel),_templates=_interopRequireDefault(_templates),_modal_events=_interopRequireDefault(_modal_events),_ajax=_interopRequireDefault(_ajax),_notification=_interopRequireDefault(_notification);_exports.showModal=function(users){let callback=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!users.length)return Promise.resolve();let titlePromise=null;return titlePromise=1==users.length?(0,_str.get_string)("sendbulkmessagesingle","core_message"):(0,_str.get_string)("sendbulkmessage","core_message",users.length),_modal_save_cancel.default.create({body:_templates.default.render("core_message/send_bulk_message",{}),title:titlePromise,show:!0,buttons:{save:titlePromise}}).then((function(modal){return modal.getRoot().on(_modal_events.default.hidden,(function(){callback&&callback(),modal.getRoot().remove()})),modal.getRoot().on(_modal_events.default.save,(function(){let messageText=modal.getRoot().find("form textarea").val();sendMessage(messageText,users)})),modal}))};const sendMessage=(messageText,users)=>{let messages=[];return users.forEach((user=>{messages.push({touserid:user,text:messageText})})),_ajax.default.call([{methodname:"core_message_send_instant_messages",args:{messages:messages}}])[0].then((function(messageIds){return 1==messageIds.length?(0,_str.get_string)("sendbulkmessagesentsingle","core_message"):(0,_str.get_string)("sendbulkmessagesent","core_message",messageIds.length)})).then((function(msg){return _notification.default.addNotification({message:msg,type:"success"}),!0})).catch(_notification.default.exception)};_exports.sendMessage=sendMessage}));
//# sourceMappingURL=message_send_bulk.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"message_send_bulk.min.js","sources":["../src/message_send_bulk.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 * Send bulk message to the given user ids.\n *\n * @module core_message/message_send_bulk\n * @copyright 2019 Shamim Rezaie <shamim@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport {get_string} from 'core/str';\nimport ModalSaveCancel from 'core/modal_save_cancel';\nimport Templates from 'core/templates';\nimport ModalEvents from 'core/modal_events';\nimport Ajax from 'core/ajax';\nimport Notification from 'core/notification';\n\n/**\n * Show the send message popup.\n *\n * @method showModal\n * @param {int[]} users\n * @param {Function} callback A callback to apply after the form is closed.\n * @returns {Promise}\n */\nexport const showModal = (users, callback = null) => {\n if (!users.length) {\n // Nothing to do.\n return Promise.resolve();\n }\n let titlePromise = null;\n if (users.length == 1) {\n titlePromise = get_string('sendbulkmessagesingle', 'core_message');\n } else {\n titlePromise = get_string('sendbulkmessage', 'core_message', users.length);\n }\n\n return ModalSaveCancel.create({\n body: Templates.render('core_message/send_bulk_message', {}),\n title: titlePromise,\n show: true,\n buttons: {\n save: titlePromise,\n },\n })\n .then(function(modal) {\n // When the dialog is closed, perform the callback (if provided).\n modal.getRoot().on(ModalEvents.hidden, function() {\n if (callback) {\n callback();\n }\n modal.getRoot().remove();\n });\n\n modal.getRoot().on(ModalEvents.save, function() {\n let messageText = modal.getRoot().find('form textarea').val();\n sendMessage(messageText, users);\n });\n\n return modal;\n });\n};\n\n/**\n * Send a message to these users.\n *\n * @method sendMessage\n * @param {String} messageText\n * @param {Number[]} users\n * @returns {Promise}\n */\nexport const sendMessage = (messageText, users) => {\n let messages = [];\n\n users.forEach(user => {\n messages.push({\n touserid: user,\n text: messageText\n });\n });\n\n return Ajax.call([{\n methodname: 'core_message_send_instant_messages',\n args: {messages: messages}\n }])[0]\n .then(function(messageIds) {\n if (messageIds.length == 1) {\n return get_string('sendbulkmessagesentsingle', 'core_message');\n } else {\n return get_string('sendbulkmessagesent', 'core_message', messageIds.length);\n }\n })\n .then(function(msg) {\n Notification.addNotification({\n message: msg,\n type: \"success\"\n });\n return true;\n })\n .catch(Notification.exception);\n};\n"],"names":["users","callback","length","Promise","resolve","titlePromise","ModalSaveCancel","create","body","Templates","render","title","show","buttons","save","then","modal","getRoot","on","ModalEvents","hidden","remove","messageText","find","val","sendMessage","messages","forEach","user","push","touserid","text","Ajax","call","methodname","args","messageIds","msg","addNotification","message","type","catch","Notification","exception"],"mappings":";;;;;;;uXAqCyB,SAACA,WAAOC,gEAAW,SACnCD,MAAME,cAEAC,QAAQC,cAEfC,aAAe,YAEfA,aADgB,GAAhBL,MAAME,QACS,mBAAW,wBAAyB,iBAEpC,mBAAW,kBAAmB,eAAgBF,MAAME,QAGhEI,2BAAgBC,OAAO,CAC1BC,KAAMC,mBAAUC,OAAO,iCAAkC,IACzDC,MAAON,aACPO,MAAM,EACNC,QAAS,CACLC,KAAMT,gBAGbU,MAAK,SAASC,cAEXA,MAAMC,UAAUC,GAAGC,sBAAYC,QAAQ,WAC/BnB,UACAA,WAEJe,MAAMC,UAAUI,YAGpBL,MAAMC,UAAUC,GAAGC,sBAAYL,MAAM,eAC7BQ,YAAcN,MAAMC,UAAUM,KAAK,iBAAiBC,MACxDC,YAAYH,YAAatB,UAGtBgB,gBAYFS,YAAc,CAACH,YAAatB,aACjC0B,SAAW,UAEf1B,MAAM2B,SAAQC,OACVF,SAASG,KAAK,CACVC,SAAUF,KACVG,KAAMT,iBAIPU,cAAKC,KAAK,CAAC,CACdC,WAAY,qCACZC,KAAM,CAACT,SAAUA,aACjB,GACHX,MAAK,SAASqB,mBACc,GAArBA,WAAWlC,QACJ,mBAAW,4BAA6B,iBAExC,mBAAW,sBAAuB,eAAgBkC,WAAWlC,WAG3Ea,MAAK,SAASsB,kCACEC,gBAAgB,CACzBC,QAASF,IACTG,KAAM,aAEH,KAEVC,MAAMC,sBAAaC"}
+10
View File
@@ -0,0 +1,10 @@
/**
* Module to message a user from their profile page.
*
* @module core_message/message_user_button
* @copyright 2019 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("core_message/message_user_button",["jquery","core/custom_interaction_events","core_message/message_drawer_helper","core/templates"],(function($,CustomEvents,MessageDrawerHelper,Templates){var SELECTORS_MESSAGE_TEXTAREA='[data-region="send-message-txt"]',SELECTORS_MESSAGE_USER_BUTTON="#message-user-button",TEMPLATES_CONTENT="core_message/message_jumpto",getUserId=function(element){return parseInt(element.attr("data-userid"))},getConversationId=function(element){return parseInt(element.attr("data-conversationid"))};return{send:function(element){element=$(element);var args={conversationid:getConversationId(element),buttonid:$(element).attr("id"),userid:getUserId(element)};Templates.render(TEMPLATES_CONTENT,{}).then((function(html){element.after(html)})).then((function(){$(SELECTORS_MESSAGE_USER_BUTTON).next().focus((function(){$(SELECTORS_MESSAGE_TEXTAREA).focus()}))})),CustomEvents.define(element,[CustomEvents.events.activate]),element.on(CustomEvents.events.activate,(function(e,data){$(e.target).hasClass("active")?(MessageDrawerHelper.hide(),$(SELECTORS_MESSAGE_USER_BUTTON).next().attr("tabindex",-1)):($(SELECTORS_MESSAGE_USER_BUTTON).next().attr("tabindex",0),args.conversationid?MessageDrawerHelper.showConversation(args):MessageDrawerHelper.createConversationWithUser(args)),$(e.target).focus(),$(e.target).toggleClass("active"),e.preventDefault(),data.originalEvent.preventDefault()}))}}}));
//# sourceMappingURL=message_user_button.min.js.map
File diff suppressed because one or more lines are too long
+11
View File
@@ -0,0 +1,11 @@
/**
* Controls the preference for an individual notification type on the
* message preference page.
*
* @module core_message/notification_preference
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("core_message/notification_preference",["jquery","core/ajax","core/notification","core_message/notification_processor"],(function($,Ajax,Notification,NotificationProcessor){const SELECTORS_PROCESSOR="[data-processor-name]",SELECTORS_STATE_INPUTS="[data-state] input",NotificationPreference=function(element,userId){this.root=$(element),this.userId=userId};return NotificationPreference.prototype.getPreferenceKey=function(){return this.root.attr("data-preference-key")},NotificationPreference.prototype.getEnabledPreferenceKey=function(){return this.getPreferenceKey()+"_enabled"},NotificationPreference.prototype.getProcessors=function(){return this.root.find(SELECTORS_PROCESSOR).map((function(index,element){return new NotificationProcessor($(element))}))},NotificationPreference.prototype.startLoading=function(){this.root.addClass("loading"),this.root.find(SELECTORS_STATE_INPUTS).prop("disabled",!0)},NotificationPreference.prototype.stopLoading=function(){this.root.removeClass("loading"),this.root.find(SELECTORS_STATE_INPUTS).prop("disabled",!1)},NotificationPreference.prototype.isLoading=function(){return this.root.hasClass("loading")},NotificationPreference.prototype.save=function(){if(this.isLoading())return $.Deferred().resolve();this.startLoading();let enabledValue="";this.getProcessors().each((function(index,processor){processor.isEnabled()&&(""===enabledValue?enabledValue=processor.getName():enabledValue+=","+processor.getName())})),""===enabledValue&&(enabledValue="none");const request={methodname:"core_user_update_user_preferences",args:{userid:this.userId,preferences:[{type:this.getEnabledPreferenceKey(),value:enabledValue}]}};return Ajax.call([request])[0].fail(Notification.exception).always(function(){this.stopLoading()}.bind(this))},NotificationPreference}));
//# sourceMappingURL=notification_preference.min.js.map
File diff suppressed because one or more lines are too long
+10
View File
@@ -0,0 +1,10 @@
/**
* Represents the notification processor (e.g. email, popup, jabber)
*
* @module core_message/notification_processor
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("core_message/notification_processor",["jquery"],(function($){const SELECTORS_STATE_INPUTS=".preference-state input.notification_enabled",NotificationProcessor=function(element){this.root=$(element)};return NotificationProcessor.prototype.getName=function(){return this.root.attr("data-processor-name")},NotificationProcessor.prototype.isEnabled=function(){return this.root.find(SELECTORS_STATE_INPUTS).prop("checked")},NotificationProcessor}));
//# sourceMappingURL=notification_processor.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"notification_processor.min.js","sources":["../src/notification_processor.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 * Represents the notification processor (e.g. email, popup, jabber)\n *\n * @module core_message/notification_processor\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'], function($) {\n const SELECTORS = {\n STATE_INPUTS: '.preference-state input.notification_enabled'\n };\n\n /**\n * Constructor for the notification processor.\n *\n * @class\n * @param {object} element jQuery object root element of the processor\n */\n const NotificationProcessor = function(element) {\n this.root = $(element);\n };\n\n /**\n * Get the processor name.\n *\n * @method getName\n * @return {string}\n */\n NotificationProcessor.prototype.getName = function() {\n return this.root.attr('data-processor-name');\n };\n\n /**\n * Check if the processor is enabled when the user is logged in.\n *\n * @method isLoggedInEnabled\n * @return {bool}\n */\n NotificationProcessor.prototype.isEnabled = function() {\n const enabled = this.root.find(SELECTORS.STATE_INPUTS);\n\n return enabled.prop('checked');\n };\n\n return NotificationProcessor;\n});\n"],"names":["define","$","SELECTORS","NotificationProcessor","element","root","prototype","getName","this","attr","isEnabled","find","prop"],"mappings":";;;;;;;AAsBAA,6CAAO,CAAC,WAAW,SAASC,SAClBC,uBACY,+CASZC,sBAAwB,SAASC,cAC9BC,KAAOJ,EAAEG,iBASlBD,sBAAsBG,UAAUC,QAAU,kBAC/BC,KAAKH,KAAKI,KAAK,wBAS1BN,sBAAsBG,UAAUI,UAAY,kBACxBF,KAAKH,KAAKM,KAAKT,wBAEhBU,KAAK,YAGjBT"}
@@ -0,0 +1,3 @@
define("core_message/notification_processor_settings",["exports","jquery","core/ajax","core/str","core/notification","core/custom_interaction_events","core/modal","core/fragment"],(function(_exports,_jquery,Ajax,Str,Notification,CustomEvents,_modal,Fragment){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_jquery=_interopRequireDefault(_jquery),Ajax=_interopRequireWildcard(Ajax),Str=_interopRequireWildcard(Str),Notification=_interopRequireWildcard(Notification),CustomEvents=_interopRequireWildcard(CustomEvents),_modal=_interopRequireDefault(_modal),Fragment=_interopRequireWildcard(Fragment);const SELECTORS_SAVE_BUTTON='[data-action="save"]',SELECTORS_CANCEL_BUTTON='[data-action="cancel"]',SELECTORS_PROCESSOR="[data-processor-name]",SELECTORS_PREFERENCE_ROW='[data-region="preference-row"]';class NotificationProcessorSettings extends _modal.default{constructor(root){super(root),this.name=null,this.userId=null,this.contextId=null,this.element=null,this.saveButton=this.getFooter().find(SELECTORS_SAVE_BUTTON),this.cancelButton=this.getFooter().find(SELECTORS_CANCEL_BUTTON)}setUserId(id){this.userId=id}getUserId(){return this.userId}setElement(element){this.element=element}getElement(){return this.element}setName(name){this.name=name}getName(){return this.name}setContextId(id){this.contextId=id}getContextId(){return this.contextId}getForm(){return this.getBody().find("form")}disableButtons(){this.saveButton.prop("disabled",!0),this.cancelButton.prop("disabled",!0)}enableButtons(){this.saveButton.prop("disabled",!1),this.cancelButton.prop("disabled",!1)}loadTitleContent(){return this.titlePromise=Str.get_string("processorsettings","message"),this.setTitle(this.titlePromise),this.titlePromise}loadBodyContent(){this.disableButtons();const args={userid:this.getUserId(),type:this.getName()};return this.bodyPromise=Fragment.loadFragment("message","processor_settings",this.getContextId(),args),this.setBody(this.bodyPromise),this.bodyPromise.then((()=>{this.enableButtons()})).catch(Notification.exception),this.bodyPromise}loadAllContent(){return _jquery.default.when(this.loadTitleContent(),this.loadBodyContent())}show(){this.loadAllContent(),super.show(this)}hide(){super.hide(this),this.setContextId(null),this.setName(null),this.setUserId(null)}updateConfiguredStatus(){const processorHeader=(0,_jquery.default)(this.getElement()).closest(SELECTORS_PROCESSOR);if(!processorHeader.hasClass("unconfigured"))return!1;const processorName=processorHeader.attr("data-processor-name"),request={methodname:"core_message_get_message_processor",args:{name:processorName,userid:this.userId}};return Ajax.call([request])[0].then((result=>{if(result.userconfigured){const notifications=(0,_jquery.default)(SELECTORS_PREFERENCE_ROW+' [data-processor-name="'+processorName+'"]');processorHeader.removeClass("unconfigured"),notifications.removeClass("disabled")}return result}))}registerEventListeners(){super.registerEventListeners(this),this.getModal().on(CustomEvents.events.activate,SELECTORS_SAVE_BUTTON,((e,data)=>{this.getForm().submit(),data.originalEvent.preventDefault()})),this.getModal().on("mpp:formsubmitted",(e=>{this.hide(),this.updateConfiguredStatus(),e.stopPropagation()})),this.getModal().on(CustomEvents.events.activate,SELECTORS_CANCEL_BUTTON,((e,data)=>{this.hide(),data.originalEvent.preventDefault(),e.stopPropagation()}))}}return _exports.default=NotificationProcessorSettings,_defineProperty(NotificationProcessorSettings,"TYPE","core_message-notification_processor_settings"),_defineProperty(NotificationProcessorSettings,"TEMPLATE","core/modal_save_cancel"),NotificationProcessorSettings.registerModalType(),_exports.default}));
//# sourceMappingURL=notification_processor_settings.min.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,11 @@
/**
* Controls the preferences for the list of notification types on the
* message preference page
*
* @module core_message/preferences_notifications_list_controller
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("core_message/preferences_notifications_list_controller",["jquery","core/ajax","core/notification","core/custom_interaction_events","core_message/notification_preference","core_message/notification_processor_settings"],(function($,Ajax,Notification,CustomEvents,NotificationPreference,NotificationProcessorSettings){var SELECTORS_DISABLE_NOTIFICATIONS='[data-region="disable-notification-container"] [data-disable-notifications]',SELECTORS_DISABLE_NOTIFICATIONS_CONTAINER='[data-region="disable-notification-container"]',SELECTORS_PREFERENCE=".preference-state",SELECTORS_PREFERENCE_ROW='[data-region="preference-row"]',SELECTORS_PREFERENCE_INPUT=".preference-state input",SELECTORS_PROCESSOR_SETTING="[data-processor-setting]",PreferencesController=function(element){this.root=$(element),this.userId=this.root.attr("data-user-id"),this.registerEventListeners()};return PreferencesController.prototype.isDisabled=function(){return this.root.hasClass("disabled")},PreferencesController.prototype.setDisabled=function(){this.root.addClass("disabled"),this.root.find(SELECTORS_PREFERENCE_INPUT).prop("disabled",!0)},PreferencesController.prototype.setEnabled=function(){this.root.removeClass("disabled"),this.root.find(SELECTORS_PREFERENCE_INPUT).prop("disabled",!1)},PreferencesController.prototype.toggleDisableAllStatus=function(){var checkbox=$(SELECTORS_DISABLE_NOTIFICATIONS),container=$(SELECTORS_DISABLE_NOTIFICATIONS_CONTAINER),ischecked=checkbox.prop("checked");if(container.hasClass("loading"))return $.Deferred().resolve();container.addClass("loading");var request={methodname:"core_user_update_user_preferences",args:{userid:this.userId,emailstop:ischecked?1:0}};return Ajax.call([request])[0].done(function(){ischecked?this.setDisabled():this.setEnabled()}.bind(this)).always((function(){container.removeClass("loading")})).fail(Notification.exception)},PreferencesController.prototype.registerEventListeners=function(){var disabledNotificationsElement=$(SELECTORS_DISABLE_NOTIFICATIONS);CustomEvents.define(this.root,[CustomEvents.events.activate]),this.root.on("change",function(e){if(!this.isDisabled()){var preferenceElement=$(e.target).closest(SELECTORS_PREFERENCE),preferenceRow=$(e.target).closest(SELECTORS_PREFERENCE_ROW),preference=new NotificationPreference(preferenceRow,this.userId);preferenceElement.addClass("loading"),preference.save().always((function(){preferenceElement.removeClass("loading")}))}}.bind(this));var eventFormPromise=NotificationProcessorSettings.create({});this.root.on(CustomEvents.events.activate,SELECTORS_PROCESSOR_SETTING,(function(e,data){var element=$(e.target).closest(SELECTORS_PROCESSOR_SETTING);data.originalEvent.preventDefault(),eventFormPromise.then((function(modal){modal.setUserId($(element).attr("data-user-id")),modal.setName($(element).attr("data-name")),modal.setContextId($(element).attr("data-context-id")),modal.setElement(element),modal.show(),e.stopImmediatePropagation()})).catch(Notification.exception)})),CustomEvents.define(disabledNotificationsElement,[CustomEvents.events.activate]),disabledNotificationsElement.on(CustomEvents.events.activate,function(){this.toggleDisableAllStatus()}.bind(this))},PreferencesController}));
//# sourceMappingURL=preferences_notifications_list_controller.min.js.map
File diff suppressed because one or more lines are too long
+10
View File
@@ -0,0 +1,10 @@
/**
* Manages the processor form on the message preferences page.
*
* @module core_message/preferences_processor_form
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("core_message/preferences_processor_form",["jquery","core/ajax","core/notification"],(function($,Ajax,Notification){var ProcessorForm=function(element){this.root=$(element),this.userId=this.root.attr("data-user-id"),this.name=this.root.attr("data-processor-name"),this.root.find("form").on("submit",function(e){e.preventDefault(),this.save().done((function(){$(element).trigger("mpp:formsubmitted")}))}.bind(this))};return ProcessorForm.prototype.startLoading=function(){this.root.addClass("loading")},ProcessorForm.prototype.stopLoading=function(){this.root.removeClass("loading")},ProcessorForm.prototype.isLoading=function(){return this.root.hasClass("loading")},ProcessorForm.prototype.save=function(){if(this.isLoading())return $.Deferred();this.startLoading();var data=this.root.find("form").serializeArray(),request={methodname:"core_message_message_processor_config_form",args:{userid:this.userId,name:this.name,formvalues:data}};return Ajax.call([request])[0].fail(Notification.exception).always(function(){this.stopLoading()}.bind(this))},ProcessorForm}));
//# sourceMappingURL=preferences_processor_form.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"preferences_processor_form.min.js","sources":["../src/preferences_processor_form.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 * Manages the processor form on the message preferences page.\n *\n * @module core_message/preferences_processor_form\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', 'core/ajax', 'core/notification'],\n function($, Ajax, Notification) {\n /**\n * Constructor for the ProcessorForm.\n *\n * @class\n * @param {object} element jQuery object root element of the preference\n */\n var ProcessorForm = function(element) {\n this.root = $(element);\n this.userId = this.root.attr('data-user-id');\n this.name = this.root.attr('data-processor-name');\n\n this.root.find('form').on('submit', function(e) {\n e.preventDefault();\n this.save().done(function() {\n $(element).trigger('mpp:formsubmitted');\n });\n }.bind(this));\n };\n\n /**\n * Flag the processor as loading.\n *\n * @method startLoading\n */\n ProcessorForm.prototype.startLoading = function() {\n this.root.addClass('loading');\n };\n\n /**\n * Remove the loading flag for this processor.\n *\n * @method stopLoading\n */\n ProcessorForm.prototype.stopLoading = function() {\n this.root.removeClass('loading');\n };\n\n /**\n * Check if this processor is loading.\n *\n * @method isLoading\n * @return {bool}\n */\n ProcessorForm.prototype.isLoading = function() {\n return this.root.hasClass('loading');\n };\n\n /**\n * Persist the processor configuration.\n *\n * @method save\n * @return {object} jQuery promise\n */\n ProcessorForm.prototype.save = function() {\n if (this.isLoading()) {\n return $.Deferred();\n }\n\n this.startLoading();\n\n var data = this.root.find('form').serializeArray();\n var request = {\n methodname: 'core_message_message_processor_config_form',\n args: {\n userid: this.userId,\n name: this.name,\n formvalues: data,\n }\n };\n\n return Ajax.call([request])[0]\n .fail(Notification.exception)\n .always(function() {\n this.stopLoading();\n }.bind(this));\n };\n\n return ProcessorForm;\n});\n"],"names":["define","$","Ajax","Notification","ProcessorForm","element","root","userId","this","attr","name","find","on","e","preventDefault","save","done","trigger","bind","prototype","startLoading","addClass","stopLoading","removeClass","isLoading","hasClass","Deferred","data","serializeArray","request","methodname","args","userid","formvalues","call","fail","exception","always"],"mappings":";;;;;;;AAsBAA,iDAAO,CAAC,SAAU,YAAa,sBACvB,SAASC,EAAGC,KAAMC,kBAOlBC,cAAgB,SAASC,cACpBC,KAAOL,EAAEI,cACTE,OAASC,KAAKF,KAAKG,KAAK,qBACxBC,KAAOF,KAAKF,KAAKG,KAAK,4BAEtBH,KAAKK,KAAK,QAAQC,GAAG,SAAU,SAASC,GACzCA,EAAEC,sBACGC,OAAOC,MAAK,WACbf,EAAEI,SAASY,QAAQ,yBAEzBC,KAAKV,eAQXJ,cAAce,UAAUC,aAAe,gBAC9Bd,KAAKe,SAAS,YAQvBjB,cAAce,UAAUG,YAAc,gBAC7BhB,KAAKiB,YAAY,YAS1BnB,cAAce,UAAUK,UAAY,kBACzBhB,KAAKF,KAAKmB,SAAS,YAS9BrB,cAAce,UAAUJ,KAAO,cACvBP,KAAKgB,mBACEvB,EAAEyB,gBAGRN,mBAEDO,KAAOnB,KAAKF,KAAKK,KAAK,QAAQiB,iBAC9BC,QAAU,CACVC,WAAY,6CACZC,KAAM,CACFC,OAAQxB,KAAKD,OACbG,KAAMF,KAAKE,KACXuB,WAAYN,cAIbzB,KAAKgC,KAAK,CAACL,UAAU,GACvBM,KAAKhC,aAAaiC,WAClBC,OAAO,gBACCf,eACPJ,KAAKV,QAGRJ"}
+10
View File
@@ -0,0 +1,10 @@
/**
* Module to add/remove contact using ajax.
*
* @module core_message/toggle_contact_button
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("core_message/toggle_contact_button",["jquery","core/ajax","core/templates","core/notification","core/custom_interaction_events"],(function($,Ajax,Templates,Notification,CustomEvents){let isRequested=element=>"1"==element.attr("data-is-requested");var getUserId=function(element){return element.attr("data-userid")},getCurrentUserId=function(element){return element.attr("data-currentuserid")},displayTextLabel=function(element){return"1"==element.attr("data-display-text-label")},isLoading=function(element){return element.hasClass("loading")||element.attr("disabled")},sendRequest=function(element,request){return isLoading(element)?$.Deferred():(element.addClass("loading"),element.attr("disabled","disabled"),Ajax.call([request])[0].fail(Notification.exception).always((function(){element.removeClass("loading"),element.removeAttr("disabled")})))};return{enhance:function(element){(element=$(element)).children(".loading-icon").length||isRequested(element)||Templates.render("core/loading",{}).done((function(html,js){element.append(html,js)})),CustomEvents.define(element,[CustomEvents.events.activate]),element.on(CustomEvents.events.activate,(function(e,data){!function(element){return"1"==element.attr("data-is-contact")}(element)?isRequested(element)||function(element){if(!isLoading(element)){var request={methodname:"core_message_create_contact_request",args:{userid:getCurrentUserId(element),requesteduserid:getUserId(element)}};sendRequest(element,request).done((function(){!function(element){element.attr("data-is-requested","1")}(element),element.addClass("disabled");const templateContext={displaytextlabel:displayTextLabel(element)};Templates.render("message/contact_request_sent",templateContext).done((function(html,js){Templates.replaceNodeContents(element,html,js)}))}))}}(element):function(element){if(!isLoading(element)){var request={methodname:"core_message_delete_contacts",args:{userids:[getUserId(element)]}};sendRequest(element,request).done((function(){!function(element){element.attr("data-is-contact","0")}(element);const templateContext={displaytextlabel:displayTextLabel(element)};Templates.render("message/add_contact_button",templateContext).done((function(html,js){Templates.replaceNodeContents(element,html,js)}))}))}}(element),e.preventDefault(),data.originalEvent.preventDefault()}))}}}));
//# sourceMappingURL=toggle_contact_button.min.js.map
File diff suppressed because one or more lines are too long