Current Path : /var/www/ljmtc/cbt/message/amd/build/ |
Current File : /var/www/ljmtc/cbt/message/amd/build/message_drawer_router.min.js.map |
{"version":3,"sources":["../src/message_drawer_router.js"],"names":["define","$","PubSub","Str","MessageDrawerEvents","Aria","routes","history","SELECTORS","CAN_RECEIVE_FOCUS","ROUTES_BACK","changeRoute","namespace","newRoute","newConfig","fromPanel","slice","call","arguments","some","arg","args","renderPromise","Deferred","resolve","promise","Object","keys","forEach","route","config","isMatch","parameters","element","removeClass","attr","unhide","get","addClass","hide","onGo","apply","concat","currentFocusElement","document","activeElement","hasFocus","firstFocusable","i","length","has","find","filter","first","focus","record","params","publish","ROUTE_CHANGED","go","inHistory","reduce","carry","previous","push","historylength","previousRecord","prevConfig","elements","focusElement","getDescription","then","description","get_string","label","catch","add","back","pop","window","setTimeout"],"mappings":"mSA0BAA,OAAM,sCACN,CACI,QADJ,CAEI,aAFJ,CAGI,UAHJ,CAII,oCAJJ,CAKI,WALJ,CADM,CAQN,SACIC,CADJ,CAEIC,CAFJ,CAGIC,CAHJ,CAIIC,CAJJ,CAKIC,CALJ,CAME,IAGMC,CAAAA,CAAM,CAAG,EAHf,CAMMC,CAAO,CAAG,EANhB,CAQMC,CAAS,CAAG,CACZC,iBAAiB,CAAE,6EADP,CAEZC,WAAW,CAAE,mBAFD,CARlB,CA0CMC,CAAW,CAAG,SAASC,CAAT,CAAoBC,CAApB,CAA8B,IACxCC,CAAAA,CADwC,CAIxCC,CAAS,CAAG,GAAGC,KAAH,CAASC,IAAT,CAAcC,SAAd,EAAyBC,IAAzB,CAA8B,SAASC,CAAT,CAAc,CACxD,MAAc,WAAP,EAAAA,CACV,CAFe,CAJ4B,CAQxCC,CAAI,CAAG,GAAGL,KAAH,CAASC,IAAT,CAAcC,SAAd,CAAyB,CAAzB,CARiC,CASxCI,CAAa,CAAGrB,CAAC,CAACsB,QAAF,GAAaC,OAAb,GAAuBC,OAAvB,EATwB,CAW5CC,MAAM,CAACC,IAAP,CAAYrB,CAA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,CAAO,CAACK,CAAD,CAAP,CAAmBqC,MAAvB,CAA+B,CAE3B1C,CAAO,CAACK,CAAD,CAAP,CAAmBkE,GAAnB,GACA,GAAIf,CAAAA,CAAQ,CAAGxD,CAAO,CAACK,CAAD,CAAP,CAAmBkE,GAAnB,EAAf,CAEA,GAAIf,CAAJ,CAAc,CAEVJ,CAAE,CAAClB,KAAH,QAAoB,CAAC7B,CAAD,CAAYmD,CAAQ,CAAClC,KAArB,EAA4Ba,MAA5B,CAAmCqB,CAAQ,CAACP,MAA5C,CAApB,EAGAuB,MAAM,CAACC,UAAP,CAAkB,UAAW,CACzBjB,CAAQ,CAACM,YAAT,CAAsBf,KAAtB,EACH,CAFD,CAEG,EAFH,CAGH,CACJ,CACJ,CAEM,CAKV,CAnQK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * A simple router for the message drawer that allows navigating between\n * the \"pages\" in the drawer.\n *\n * This module will maintain a linear history of the unique pages access\n * to allow navigating back.\n *\n * @module core_message/message_drawer_router\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/pubsub',\n 'core/str',\n 'core_message/message_drawer_events',\n 'core/aria',\n],\nfunction(\n $,\n PubSub,\n Str,\n MessageDrawerEvents,\n Aria\n) {\n\n /* @var {object} routes Message drawer route elements and callbacks. */\n var routes = {};\n\n /* @var {object} history Store for route objects history. */\n var history = {};\n\n var SELECTORS = {\n CAN_RECEIVE_FOCUS: 'input:not([type=\"hidden\"]), a[href], button, textarea, select, [tabindex]',\n ROUTES_BACK: '[data-route-back]'\n };\n\n /**\n * Add a route.\n *\n * @param {String} namespace Unique identifier for the Routes\n * @param {string} route Route config name.\n * @param {array} parameters Route parameters.\n * @param {callback} onGo Route initialization function.\n * @param {callback} getDescription Route initialization function.\n */\n var add = function(namespace, route, parameters, onGo, getDescription) {\n if (!routes[namespace]) {\n routes[namespace] = [];\n }\n\n routes[namespace][route] =\n {\n parameters: parameters,\n onGo: onGo,\n getDescription: getDescription\n };\n };\n\n /**\n * Go to a defined route and run the route callbacks.\n *\n * @param {String} namespace Unique identifier for the Routes\n * @param {string} newRoute Route config name.\n * @return {object} record Current route record with route config name and parameters.\n */\n var changeRoute = function(namespace, newRoute) {\n var newConfig;\n\n // Check if the Route change call is made from an element in the app panel.\n var fromPanel = [].slice.call(arguments).some(function(arg) {\n return arg == 'frompanel';\n });\n // Get the rest of the arguments, if any.\n var args = [].slice.call(arguments, 2);\n var renderPromise = $.Deferred().resolve().promise();\n\n Object.keys(routes[namespace]).forEach(function(route) {\n var config = routes[namespace][route];\n var isMatch = route === newRoute;\n\n if (isMatch) {\n newConfig = config;\n }\n\n config.parameters.forEach(function(element) {\n // Some parameters may be null, or not an element.\n if (typeof element !== 'object' || element === null) {\n return;\n }\n\n element.removeClass('previous');\n element.attr('data-from-panel', false);\n\n if (isMatch) {\n if (fromPanel) {\n // Set this attribute to let the conversation renderer know not to show a back button.\n element.attr('data-from-panel', true);\n }\n element.removeClass('hidden');\n Aria.unhide(element.get());\n } else {\n // For the message index page elements in the left panel should not be hidden.\n if (!element.attr('data-in-panel')) {\n element.addClass('hidden');\n Aria.hide(element.get());\n } else if (newRoute == 'view-search' || newRoute == 'view-overview') {\n element.addClass('hidden');\n Aria.hide(element.get());\n }\n }\n });\n });\n\n if (newConfig) {\n if (newConfig.onGo) {\n renderPromise = newConfig.onGo.apply(undefined, newConfig.parameters.concat(args));\n var currentFocusElement = $(document.activeElement);\n var hasFocus = false;\n var firstFocusable = null;\n\n // No need to start at 0 as we know that is the namespace.\n for (var i = 1; i < newConfig.parameters.length; i++) {\n var element = newConfig.parameters[i];\n\n // Some parameters may be null, or not an element.\n if (typeof element !== 'object' || element === null) {\n continue;\n }\n\n if (!firstFocusable) {\n firstFocusable = element;\n }\n\n if (element.has(currentFocusElement).length) {\n hasFocus = true;\n break;\n }\n }\n\n if (!hasFocus) {\n // This page doesn't have focus yet so focus the first focusable\n // element in the new view.\n firstFocusable.find(SELECTORS.CAN_RECEIVE_FOCUS).filter(':visible').first().focus();\n }\n }\n }\n\n var record = {\n route: newRoute,\n params: args,\n renderPromise: renderPromise\n };\n\n PubSub.publish(MessageDrawerEvents.ROUTE_CHANGED, record);\n\n return record;\n };\n\n /**\n * Go to a defined route and store the route history.\n *\n * @param {String} namespace Unique identifier for the Routes\n * @return {object} record Current route record with route config name and parameters.\n */\n var go = function(namespace) {\n var currentFocusElement = $(document.activeElement);\n\n var record = changeRoute.apply(namespace, arguments);\n var inHistory = false;\n\n if (!history[namespace]) {\n history[namespace] = [];\n }\n\n // History stores a unique list of routes. Check to see if the new route\n // is already in the history, if it is then forget all history after it.\n // This ensures there are no duplicate routes in history and that it represents\n // a linear path of routes (it never stores something like [foo, bar, foo])).\n history[namespace] = history[namespace].reduce(function(carry, previous) {\n if (previous.route === record.route) {\n inHistory = true;\n }\n\n if (!inHistory) {\n carry.push(previous);\n }\n\n return carry;\n }, []);\n\n var historylength = history[namespace].length;\n var previousRecord = historylength ? history[namespace][historylength - 1] : null;\n\n if (previousRecord) {\n var prevConfig = routes[namespace][previousRecord.route];\n var elements = prevConfig.parameters;\n\n // The first one will be the namespace, skip it.\n for (var i = 1; i < elements.length; i++) {\n // Some parameters may be null, or not an element.\n if (typeof elements[i] !== 'object' || elements[i] === null) {\n continue;\n }\n\n elements[i].addClass('previous');\n }\n\n previousRecord.focusElement = currentFocusElement;\n\n if (prevConfig.getDescription) {\n // If the route has a description then set it on the back button for\n // the new page we're displaying.\n prevConfig.getDescription.apply(null, prevConfig.parameters.concat(previousRecord.params))\n .then(function(description) {\n return Str.get_string('backto', 'core_message', description);\n })\n .then(function(label) {\n // Wait for the new page to finish rendering so that we know\n // that the back button is visible.\n return record.renderPromise.then(function() {\n // Find the elements for the new route we displayed.\n routes[namespace][record.route].parameters.forEach(function(element) {\n // Some parameters may be null, or not an element.\n if (typeof element !== 'object' || !element) {\n return;\n }\n // Update the aria label for the back button.\n element.find(SELECTORS.ROUTES_BACK).attr('aria-label', label);\n });\n });\n })\n .catch(function() {\n // Silently ignore.\n });\n }\n }\n history[namespace].push(record);\n return record;\n };\n\n /**\n * Go back to the previous route record stored in history.\n *\n * @param {String} namespace Unique identifier for the Routes\n */\n var back = function(namespace) {\n if (history[namespace].length) {\n // Remove the current route.\n history[namespace].pop();\n var previous = history[namespace].pop();\n\n if (previous) {\n // If we have a previous route then show it.\n go.apply(undefined, [namespace, previous.route].concat(previous.params));\n // Delay the focus 50 milliseconds otherwise it doesn't correctly\n // focus the element for some reason...\n window.setTimeout(function() {\n previous.focusElement.focus();\n }, 50);\n }\n }\n };\n\n return {\n add: add,\n go: go,\n back: back\n };\n});\n"],"file":"message_drawer_router.min.js"}