From 7cc18dc2ad334cf1c47358f6beae5d12e77d440d Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 9 Apr 2020 21:25:07 +0800 Subject: [PATCH] MDL-68390 js: Update to use Aria mod --- .../tool/usertours/amd/build/tour.min.js.map | 2 +- admin/tool/usertours/amd/src/tour.js | 2 +- blocks/myoverview/amd/build/view.min.js | 2 +- blocks/myoverview/amd/build/view.min.js.map | 2 +- blocks/myoverview/amd/src/view.js | 16 +++++--- .../amd/build/ajax_response_renderer.min.js | 2 +- .../build/ajax_response_renderer.min.js.map | 2 +- .../amd/src/ajax_response_renderer.js | 18 +++++++-- .../amd/build/main.min.js | 2 +- .../amd/build/main.min.js.map | 2 +- .../recentlyaccessedcourses/amd/src/main.js | 8 ++-- lib/amd/build/drawer.min.js | 2 +- lib/amd/build/drawer.min.js.map | 2 +- lib/amd/build/form-autocomplete.min.js | 2 +- lib/amd/build/form-autocomplete.min.js.map | 2 +- lib/amd/build/modal.min.js | 2 +- lib/amd/build/modal.min.js.map | 2 +- lib/amd/build/tooltip.min.js | 2 +- lib/amd/build/tooltip.min.js.map | 2 +- lib/amd/build/tree.min.js | 2 +- lib/amd/build/tree.min.js.map | 2 +- lib/amd/src/drawer.js | 16 ++++++-- lib/amd/src/form-autocomplete.js | 34 +++++++++------- lib/amd/src/modal.js | 13 ++++--- lib/amd/src/tooltip.js | 6 +-- lib/amd/src/tree.js | 2 +- .../amd/build/message_drawer_router.min.js | 2 +- .../build/message_drawer_router.min.js.map | 2 +- ...e_drawer_view_conversation_renderer.min.js | 2 +- ...awer_view_conversation_renderer.min.js.map | 2 +- message/amd/src/message_drawer_router.js | 12 +++--- ...ssage_drawer_view_conversation_renderer.js | 39 ++++++++++--------- theme/boost/amd/build/drawer.min.js | 2 +- theme/boost/amd/build/drawer.min.js.map | 2 +- theme/boost/amd/src/drawer.js | 14 ++++--- 35 files changed, 136 insertions(+), 90 deletions(-) diff --git a/admin/tool/usertours/amd/build/tour.min.js.map b/admin/tool/usertours/amd/build/tour.min.js.map index bc48f5c2787..c305e7ac437 100644 --- a/admin/tool/usertours/amd/build/tour.min.js.map +++ b/admin/tool/usertours/amd/build/tour.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/tour.js"],"names":["Tour","config","init","eventHandlers","reset","originalConfiguration","configure","apply","arguments","storage","window","sessionStorage","storageKey","tourName","e","hide","resetStepListeners","steps","currentStepNumber","eventName","forEach","handler","addEventHandler","resetStepDefaults","template","templateContent","checkMinimumRequirements","Error","length","loadOriginalConfiguration","stepDefaults","setStepDefaults","$","extend","element","placement","delay","moveOnClick","moveAfterTime","orphan","direction","parseInt","stepNumber","setItem","code","DOMException","QUOTA_EXCEEDED_ERR","removeItem","getCurrentStepNumber","nextStepNumber","isStepPotentiallyVisible","getStepConfig","previousStepNumber","getNextStepNumber","getPreviousStepNumber","stepConfig","isStepActuallyVisible","target","getStepTarget","is","gotoStep","endTour","_gotoStep","delayed","setTimeout","bind","fn","fireEventHandlers","renderStep","normalizeStepConfig","reflex","moveAfterClick","content","body","attachTo","attachPoint","first","data","thisEvent","call","push","listeners","node","currentStepNode","args","proxy","next","previous","handleKeyDown","targetNode","parents","listener","on","off","currentStepConfig","setCurrentStepNumber","getTemplateContent","find","html","title","isFirstStep","prop","isLastStep","removeClass","addClass","attr","addStepToPage","processStepListeners","clone","animationTarget","stop","zIndex","calculateZIndex","css","positionBackdrop","document","append","top","left","animate","scrollTop","calculateScrollTop","promise","then","positionStep","revealStep","catch","isOrphan","offset","calculateStepPositionInPage","currentStepPopper","Popper","removeOnDestroy","arrowElement","modifiers","enabled","applyStyle","onLoad","fadeIn","announceStep","focus","stepId","bodyRegion","headerRegion","accessibilityShow","tabbableSelector","keyCode","hasBackdrop","activeElement","stepTarget","tabbableNodes","dialogContainer","currentIndex","filter","index","has","each","nextIndex","nextNode","focusRelevant","shiftKey","closest","last","preventDefault","startAt","storageStartValue","getItem","storageStartAt","startTour","previousTarget","transition","destroy","fadeTime","remove","removeAttr","fadeOut","currentStepElement","accessibilityHide","viewportHeight","height","Math","max","min","ceil","stepHeight","viewportWidth","width","stepWidth","flipBehavior","flip","behaviour","arrow","onCreate","recalculateArrowPosition","onUpdate","split","isVertical","indexOf","instance","popper","querySelector","stepElement","arrowHeight","parseFloat","getComputedStyle","arrowOffset","popperHeight","popperOffset","popperBorderWidth","popperBorderRadiusWidth","arrowPos","maxPos","minPos","newArrowPos","arrowWidth","popperWidth","background","backdrop","insertAfter","buffer","colorNode","outerWidth","outerHeight","backgroundColor","calculateInherittedBackgroundColor","targetRadius","targetPosition","calculatePosition","fader","opacity","elem","position","value","isNaN","parent","fakeNode","fakeElemColor","color","attrName","hideFunction","child","flexitourRole","hidden","siblings","parentsUntil","showFunction"],"mappings":"gKAsBA,OACA,O,koBAOqBA,CAAAA,C,YAIjB,WAAYC,CAAZ,CAAoB,WAChB,KAAKC,IAAL,CAAUD,CAAV,CACH,C,qCAUIA,C,CAAQ,CAET,KAAKE,aAAL,CAAqB,EAArB,CAGA,KAAKC,KAAL,GAGA,KAAKC,qBAAL,CAA6BJ,CAAM,EAAI,EAAvC,CAGA,KAAKK,SAAL,CAAeC,KAAf,CAAqB,IAArB,CAA2BC,SAA3B,EAEA,GAAI,CACA,KAAKC,OAAL,CAAeC,MAAM,CAACC,cAAtB,CACA,KAAKC,UAAL,CAAkB,aAAe,KAAKC,QACzC,CAAC,MAAOC,CAAP,CAAU,CACR,KAAKL,OAAL,IACA,KAAKG,UAAL,CAAkB,EACrB,CAED,MAAO,KACV,C,qCASO,CAEJ,KAAKG,IAAL,GAGA,KAAKZ,aAAL,CAAqB,EAArB,CAGA,KAAKa,kBAAL,GAGA,KAAKX,qBAAL,CAA6B,EAA7B,CAGA,KAAKY,KAAL,CAAa,EAAb,CAGA,KAAKC,iBAAL,CAAyB,CAAzB,CAEA,MAAO,KACV,C,4CAUSjB,C,CAAQ,YACd,GAAsB,QAAlB,KAAOA,CAAP,CAAJ,CAAgC,CAE5B,GAA+B,WAA3B,QAAO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CAAQ,CAAG,aAFC,CAGZC,CAAY,CAAG,SAASC,CAAT,CAAgB,CAC/B,GAAIC,CAAAA,CAAa,CAAGD,CAAK,CAACnK,IAAN,CAAW,WAAX,CAApB,CACA,GAAIoK,CAAJ,CAAmB,CACf,OAAQA,CAAR,EACI,IAAK,WAAL,CACA,IAAK,QAAL,CACI,OAHR,CAKH,CAED,GAAIC,CAAAA,CAAM,CAAGF,CAAK,CAACvI,IAAN,CAAWqI,CAAX,CAAb,CACA,GAAI,CAACI,CAAL,CAAa,CACTF,CAAK,CAACvI,IAAN,uBACAuI,CAAK,CAACvI,IAAN,CAAWqI,CAAX,IACH,CACJ,CAlBe,CAoBhB,KAAK3J,eAAL,CAAqBgK,QAArB,GAAgCvF,IAAhC,CAAqC,SAASF,CAAT,CAAgBxE,CAAhB,CAAsB,CACvD6J,CAAY,CAAC,cAAE7J,CAAF,CAAD,CACf,CAFD,EAGA,KAAKC,eAAL,CAAqBiK,YAArB,CAAkC,MAAlC,EAA0CD,QAA1C,GAAqDvF,IAArD,CAA0D,SAASF,CAAT,CAAgBxE,CAAhB,CAAsB,CAC5E6J,CAAY,CAAC,cAAE7J,CAAF,CAAD,CACf,CAFD,CAGH,C,6DASmB,IAGZmK,CAAAA,CAAY,CAAG,SAASL,CAAT,CAAgB,CAC/B,GAAIE,CAAAA,CAAM,CAAGF,CAAK,CAACvI,IAAN,mBAAb,CACA,GAAsB,WAAlB,QAAOyI,CAAAA,CAAX,CAAmC,CAC/BF,CAAK,CAAClE,UAAN,oBACAkE,CAAK,CAAClE,UAAN,CALO,aAKP,CACH,CACJ,CATe,CAWhB,mCAA2BlB,IAA3B,CAAgC,SAASF,CAAT,CAAgBxE,CAAhB,CAAsB,CAClDmK,CAAY,CAAC,cAAEnK,CAAF,CAAD,CACf,CAFD,CAGH,C","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 .\n\n/**\n * Manage user tours in Moodle.\n *\n * @copyright 2018 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport Popper from 'core/popper';\n\n/**\n * A Tour.\n *\n * @class Tour\n */\nexport default class Tour {\n /**\n * @param {object} config The configuration object.\n */\n constructor(config) {\n this.init(config);\n }\n\n /**\n * Initialise the tour.\n *\n * @method init\n * @param {Object} config The configuration object.\n * @chainable\n * @return {Object} this.\n */\n init(config) {\n // Unset all handlers.\n this.eventHandlers = {};\n\n // Reset the current tour states.\n this.reset();\n\n // Store the initial configuration.\n this.originalConfiguration = config || {};\n\n // Apply configuration.\n this.configure.apply(this, arguments);\n\n try {\n this.storage = window.sessionStorage;\n this.storageKey = 'tourstate_' + this.tourName;\n } catch (e) {\n this.storage = false;\n this.storageKey = '';\n }\n\n return this;\n }\n\n /**\n * Reset the current tour state.\n *\n * @method reset\n * @chainable\n * @return {Object} this.\n */\n reset() {\n // Hide the current step.\n this.hide();\n\n // Unset all handlers.\n this.eventHandlers = [];\n\n // Unset all listeners.\n this.resetStepListeners();\n\n // Unset the original configuration.\n this.originalConfiguration = {};\n\n // Reset the current step number and list of steps.\n this.steps = [];\n\n // Reset the current step number.\n this.currentStepNumber = 0;\n\n return this;\n }\n\n /**\n * Prepare tour configuration.\n *\n * @method configure\n * @param {Object} config The configuration object.\n * @chainable\n * @return {Object} this.\n */\n configure(config) {\n if (typeof config === 'object') {\n // Tour name.\n if (typeof config.tourName !== 'undefined') {\n this.tourName = config.tourName;\n }\n\n // Set up eventHandlers.\n if (config.eventHandlers) {\n for (let eventName in config.eventHandlers) {\n config.eventHandlers[eventName].forEach(function(handler) {\n this.addEventHandler(eventName, handler);\n }, this);\n }\n }\n\n // Reset the step configuration.\n this.resetStepDefaults(true);\n\n // Configure the steps.\n if (typeof config.steps === 'object') {\n this.steps = config.steps;\n }\n\n if (typeof config.template !== 'undefined') {\n this.templateContent = config.template;\n }\n }\n\n // Check that we have enough to start the tour.\n this.checkMinimumRequirements();\n\n return this;\n }\n\n /**\n * Check that the configuration meets the minimum requirements.\n *\n * @method checkMinimumRequirements\n */\n checkMinimumRequirements() {\n // Need a tourName.\n if (!this.tourName) {\n throw new Error(\"Tour Name required\");\n }\n\n // Need a minimum of one step.\n if (!this.steps || !this.steps.length) {\n throw new Error(\"Steps must be specified\");\n }\n }\n\n /**\n * Reset step default configuration.\n *\n * @method resetStepDefaults\n * @param {Boolean} loadOriginalConfiguration Whether to load the original configuration supplied with the Tour.\n * @chainable\n * @return {Object} this.\n */\n resetStepDefaults(loadOriginalConfiguration) {\n if (typeof loadOriginalConfiguration === 'undefined') {\n loadOriginalConfiguration = true;\n }\n\n this.stepDefaults = {};\n if (!loadOriginalConfiguration || typeof this.originalConfiguration.stepDefaults === 'undefined') {\n this.setStepDefaults({});\n } else {\n this.setStepDefaults(this.originalConfiguration.stepDefaults);\n }\n\n return this;\n }\n\n /**\n * Set the step defaults.\n *\n * @method setStepDefaults\n * @param {Object} stepDefaults The step defaults to apply to all steps\n * @chainable\n * @return {Object} this.\n */\n setStepDefaults(stepDefaults) {\n if (!this.stepDefaults) {\n this.stepDefaults = {};\n }\n $.extend(\n this.stepDefaults,\n {\n element: '',\n placement: 'top',\n delay: 0,\n moveOnClick: false,\n moveAfterTime: 0,\n orphan: false,\n direction: 1,\n },\n stepDefaults\n );\n\n return this;\n }\n\n /**\n * Retrieve the current step number.\n *\n * @method getCurrentStepNumber\n * @return {Integer} The current step number\n */\n getCurrentStepNumber() {\n return parseInt(this.currentStepNumber, 10);\n }\n\n /**\n * Store the current step number.\n *\n * @method setCurrentStepNumber\n * @param {Integer} stepNumber The current step number\n * @chainable\n */\n setCurrentStepNumber(stepNumber) {\n this.currentStepNumber = stepNumber;\n if (this.storage) {\n try {\n this.storage.setItem(this.storageKey, stepNumber);\n } catch (e) {\n if (e.code === DOMException.QUOTA_EXCEEDED_ERR) {\n this.storage.removeItem(this.storageKey);\n }\n }\n }\n }\n\n /**\n * Get the next step number after the currently displayed step.\n *\n * @method getNextStepNumber\n * @param {Integer} stepNumber The current step number\n * @return {Integer} The next step number to display\n */\n getNextStepNumber(stepNumber) {\n if (typeof stepNumber === 'undefined') {\n stepNumber = this.getCurrentStepNumber();\n }\n let nextStepNumber = stepNumber + 1;\n\n // Keep checking the remaining steps.\n while (nextStepNumber <= this.steps.length) {\n if (this.isStepPotentiallyVisible(this.getStepConfig(nextStepNumber))) {\n return nextStepNumber;\n }\n nextStepNumber++;\n }\n\n return null;\n }\n\n /**\n * Get the previous step number before the currently displayed step.\n *\n * @method getPreviousStepNumber\n * @param {Integer} stepNumber The current step number\n * @return {Integer} The previous step number to display\n */\n getPreviousStepNumber(stepNumber) {\n if (typeof stepNumber === 'undefined') {\n stepNumber = this.getCurrentStepNumber();\n }\n let previousStepNumber = stepNumber - 1;\n\n // Keep checking the remaining steps.\n while (previousStepNumber >= 0) {\n if (this.isStepPotentiallyVisible(this.getStepConfig(previousStepNumber))) {\n return previousStepNumber;\n }\n previousStepNumber--;\n }\n\n return null;\n }\n\n /**\n * Is the step the final step number?\n *\n * @method isLastStep\n * @param {Integer} stepNumber Step number to test\n * @return {Boolean} Whether the step is the final step\n */\n isLastStep(stepNumber) {\n let nextStepNumber = this.getNextStepNumber(stepNumber);\n\n return nextStepNumber === null;\n }\n\n /**\n * Is the step the first step number?\n *\n * @method isFirstStep\n * @param {Integer} stepNumber Step number to test\n * @return {Boolean} Whether the step is the first step\n */\n isFirstStep(stepNumber) {\n let previousStepNumber = this.getPreviousStepNumber(stepNumber);\n\n return previousStepNumber === null;\n }\n\n /**\n * Is this step potentially visible?\n *\n * @method isStepPotentiallyVisible\n * @param {Object} stepConfig The step configuration to normalise\n * @return {Boolean} Whether the step is the potentially visible\n */\n isStepPotentiallyVisible(stepConfig) {\n if (!stepConfig) {\n // Without step config, there can be no step.\n return false;\n }\n\n if (this.isStepActuallyVisible(stepConfig)) {\n // If it is actually visible, it is already potentially visible.\n return true;\n }\n\n if (typeof stepConfig.orphan !== 'undefined' && stepConfig.orphan) {\n // Orphan steps have no target. They are always visible.\n return true;\n }\n\n if (typeof stepConfig.delay !== 'undefined' && stepConfig.delay) {\n // Only return true if the activated has not been used yet.\n return true;\n }\n\n // Not theoretically, or actually visible.\n return false;\n }\n\n /**\n * Is this step actually visible?\n *\n * @method isStepActuallyVisible\n * @param {Object} stepConfig The step configuration to normalise\n * @return {Boolean} Whether the step is actually visible\n */\n isStepActuallyVisible(stepConfig) {\n if (!stepConfig) {\n // Without step config, there can be no step.\n return false;\n }\n\n let target = this.getStepTarget(stepConfig);\n if (target && target.length && target.is(':visible')) {\n // Without a target, there can be no step.\n return !!target.length;\n }\n\n return false;\n }\n\n /**\n * Go to the next step in the tour.\n *\n * @method next\n * @chainable\n * @return {Object} this.\n */\n next() {\n return this.gotoStep(this.getNextStepNumber());\n }\n\n /**\n * Go to the previous step in the tour.\n *\n * @method previous\n * @chainable\n * @return {Object} this.\n */\n previous() {\n return this.gotoStep(this.getPreviousStepNumber(), -1);\n }\n\n /**\n * Go to the specified step in the tour.\n *\n * @method gotoStep\n * @param {Integer} stepNumber The step number to display\n * @param {Integer} direction Next or previous step\n * @chainable\n * @return {Object} this.\n */\n gotoStep(stepNumber, direction) {\n if (stepNumber < 0) {\n return this.endTour();\n }\n\n let stepConfig = this.getStepConfig(stepNumber);\n if (stepConfig === null) {\n return this.endTour();\n }\n\n return this._gotoStep(stepConfig, direction);\n }\n\n _gotoStep(stepConfig, direction) {\n if (!stepConfig) {\n return this.endTour();\n }\n\n if (typeof stepConfig.delay !== 'undefined' && stepConfig.delay && !stepConfig.delayed) {\n stepConfig.delayed = true;\n window.setTimeout(this._gotoStep.bind(this), stepConfig.delay, stepConfig, direction);\n\n return this;\n } else if (!stepConfig.orphan && !this.isStepActuallyVisible(stepConfig)) {\n let fn = direction == -1 ? 'getPreviousStepNumber' : 'getNextStepNumber';\n return this.gotoStep(this[fn](stepConfig.stepNumber), direction);\n }\n\n this.hide();\n\n this.fireEventHandlers('beforeRender', stepConfig);\n this.renderStep(stepConfig);\n this.fireEventHandlers('afterRender', stepConfig);\n\n return this;\n }\n\n /**\n * Fetch the normalised step configuration for the specified step number.\n *\n * @method getStepConfig\n * @param {Integer} stepNumber The step number to fetch configuration for\n * @return {Object} The step configuration\n */\n getStepConfig(stepNumber) {\n if (stepNumber === null || stepNumber < 0 || stepNumber >= this.steps.length) {\n return null;\n }\n\n // Normalise the step configuration.\n let stepConfig = this.normalizeStepConfig(this.steps[stepNumber]);\n\n // Add the stepNumber to the stepConfig.\n stepConfig = $.extend(stepConfig, {stepNumber: stepNumber});\n\n return stepConfig;\n }\n\n /**\n * Normalise the supplied step configuration.\n *\n * @method normalizeStepConfig\n * @param {Object} stepConfig The step configuration to normalise\n * @return {Object} The normalised step configuration\n */\n normalizeStepConfig(stepConfig) {\n\n if (typeof stepConfig.reflex !== 'undefined' && typeof stepConfig.moveAfterClick === 'undefined') {\n stepConfig.moveAfterClick = stepConfig.reflex;\n }\n\n if (typeof stepConfig.element !== 'undefined' && typeof stepConfig.target === 'undefined') {\n stepConfig.target = stepConfig.element;\n }\n\n if (typeof stepConfig.content !== 'undefined' && typeof stepConfig.body === 'undefined') {\n stepConfig.body = stepConfig.content;\n }\n\n stepConfig = $.extend({}, this.stepDefaults, stepConfig);\n\n stepConfig = $.extend({}, {\n attachTo: stepConfig.target,\n attachPoint: 'after',\n }, stepConfig);\n\n if (stepConfig.attachTo) {\n stepConfig.attachTo = $(stepConfig.attachTo).first();\n }\n\n return stepConfig;\n }\n\n /**\n * Fetch the actual step target from the selector.\n *\n * This should not be called until after any delay has completed.\n *\n * @method getStepTarget\n * @param {Object} stepConfig The step configuration\n * @return {$}\n */\n getStepTarget(stepConfig) {\n if (stepConfig.target) {\n return $(stepConfig.target);\n }\n\n return null;\n }\n\n /**\n * Fire any event handlers for the specified event.\n *\n * @param {String} eventName The name of the event to handle\n * @param {Object} data Any data to pass to the event\n * @chainable\n * @return {Object} this.\n */\n fireEventHandlers(eventName, data) {\n if (typeof this.eventHandlers[eventName] === 'undefined') {\n return this;\n }\n\n this.eventHandlers[eventName].forEach(function(thisEvent) {\n thisEvent.call(this, data);\n }, this);\n\n return this;\n }\n\n /**\n * @method addEventHandler\n * @param {string} eventName The name of the event to listen for\n * @param {function} handler The event handler to call\n * @return {Object} this.\n */\n addEventHandler(eventName, handler) {\n if (typeof this.eventHandlers[eventName] === 'undefined') {\n this.eventHandlers[eventName] = [];\n }\n\n this.eventHandlers[eventName].push(handler);\n\n return this;\n }\n\n /**\n * Process listeners for the step being shown.\n *\n * @method processStepListeners\n * @param {object} stepConfig The configuration for the step\n * @chainable\n * @return {Object} this.\n */\n processStepListeners(stepConfig) {\n this.listeners.push(\n // Next/Previous buttons.\n {\n node: this.currentStepNode,\n args: ['click', '[data-role=\"next\"]', $.proxy(this.next, this)]\n }, {\n node: this.currentStepNode,\n args: ['click', '[data-role=\"previous\"]', $.proxy(this.previous, this)]\n },\n\n // Close and end tour buttons.\n {\n node: this.currentStepNode,\n args: ['click', '[data-role=\"end\"]', $.proxy(this.endTour, this)]\n },\n\n // Click backdrop and hide tour.\n {\n node: $('[data-flexitour=\"backdrop\"]'),\n args: ['click', $.proxy(this.hide, this)]\n },\n\n // Keypresses.\n {\n node: $('body'),\n args: ['keydown', $.proxy(this.handleKeyDown, this)]\n });\n\n if (stepConfig.moveOnClick) {\n var targetNode = this.getStepTarget(stepConfig);\n this.listeners.push({\n node: targetNode,\n args: ['click', $.proxy(function(e) {\n if ($(e.target).parents('[data-flexitour=\"container\"]').length === 0) {\n // Ignore clicks when they are in the flexitour.\n window.setTimeout($.proxy(this.next, this), 500);\n }\n }, this)]\n });\n }\n\n this.listeners.forEach(function (listener) {\n listener.node.on.apply(listener.node, listener.args);\n });\n\n return this;\n }\n\n /**\n * Reset step listeners.\n *\n * @method resetStepListeners\n * @chainable\n * @return {Object} this.\n */\n resetStepListeners() {\n // Stop listening to all external handlers.\n if (this.listeners) {\n this.listeners.forEach(function(listener) {\n listener.node.off.apply(listener.node, listener.args);\n });\n }\n this.listeners = [];\n\n return this;\n }\n\n /**\n * The standard step renderer.\n *\n * @method renderStep\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n renderStep(stepConfig) {\n // Store the current step configuration for later.\n this.currentStepConfig = stepConfig;\n this.setCurrentStepNumber(stepConfig.stepNumber);\n\n // Fetch the template and convert it to a $ object.\n let template = $(this.getTemplateContent());\n\n // Title.\n template.find('[data-placeholder=\"title\"]')\n .html(stepConfig.title);\n\n // Body.\n template.find('[data-placeholder=\"body\"]')\n .html(stepConfig.body);\n\n // Is this the first step?\n if (this.isFirstStep(stepConfig.stepNumber)) {\n template.find('[data-role=\"previous\"]').hide();\n } else {\n template.find('[data-role=\"previous\"]').prop('disabled', false);\n }\n\n // Is this the final step?\n if (this.isLastStep(stepConfig.stepNumber)) {\n template.find('[data-role=\"next\"]').hide();\n template.find('[data-role=\"end\"]').removeClass(\"btn-secondary\").addClass(\"btn-primary\");\n } else {\n template.find('[data-role=\"next\"]').prop('disabled', false);\n }\n\n template.find('[data-role=\"previous\"]').attr('role', 'button');\n template.find('[data-role=\"next\"]').attr('role', 'button');\n template.find('[data-role=\"end\"]').attr('role', 'button');\n\n // Replace the template with the updated version.\n stepConfig.template = template;\n\n // Add to the page.\n this.addStepToPage(stepConfig);\n\n // Process step listeners after adding to the page.\n // This uses the currentNode.\n this.processStepListeners(stepConfig);\n\n return this;\n }\n\n /**\n * Getter for the template content.\n *\n * @method getTemplateContent\n * @return {$}\n */\n getTemplateContent() {\n return $(this.templateContent).clone();\n }\n\n /**\n * Helper to add a step to the page.\n *\n * @method addStepToPage\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n addStepToPage(stepConfig) {\n // Create the stepNode from the template data.\n let currentStepNode = $('')\n .html(stepConfig.template)\n .hide();\n\n // The scroll animation occurs on the body or html.\n let animationTarget = $('body, html')\n .stop(true, true);\n\n if (this.isStepActuallyVisible(stepConfig)) {\n let targetNode = this.getStepTarget(stepConfig);\n\n targetNode.data('flexitour', 'target');\n\n let zIndex = this.calculateZIndex(targetNode);\n if (zIndex) {\n stepConfig.zIndex = zIndex + 1;\n }\n\n if (stepConfig.zIndex) {\n currentStepNode.css('zIndex', stepConfig.zIndex + 1);\n }\n\n // Add the backdrop.\n this.positionBackdrop(stepConfig);\n\n $(document.body).append(currentStepNode);\n this.currentStepNode = currentStepNode;\n\n // Ensure that the step node is positioned.\n // Some situations mean that the value is not properly calculated without this step.\n this.currentStepNode.css({\n top: 0,\n left: 0,\n });\n\n animationTarget\n .animate({\n scrollTop: this.calculateScrollTop(stepConfig),\n }).promise().then(function() {\n this.positionStep(stepConfig);\n this.revealStep(stepConfig);\n return;\n }.bind(this))\n .catch(function() {\n // Silently fail.\n });\n\n } else if (stepConfig.orphan) {\n stepConfig.isOrphan = true;\n\n // This will be appended to the body instead.\n stepConfig.attachTo = $('body').first();\n stepConfig.attachPoint = 'append';\n\n // Add the backdrop.\n this.positionBackdrop(stepConfig);\n\n // This is an orphaned step.\n currentStepNode.addClass('orphan');\n\n // It lives in the body.\n $(document.body).append(currentStepNode);\n this.currentStepNode = currentStepNode;\n\n this.currentStepNode.offset(this.calculateStepPositionInPage());\n this.currentStepNode.css('position', 'fixed');\n\n this.currentStepPopper = new Popper(\n $('body'),\n this.currentStepNode[0], {\n removeOnDestroy: true,\n placement: stepConfig.placement + '-start',\n arrowElement: '[data-role=\"arrow\"]',\n // Empty the modifiers. We've already placed the step and don't want it moved.\n modifiers: {\n hide: {\n enabled: false,\n },\n applyStyle: {\n onLoad: null,\n enabled: false,\n },\n }\n }\n );\n\n this.revealStep(stepConfig);\n }\n\n return this;\n }\n\n /**\n * Make the given step visible.\n *\n * @method revealStep\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n revealStep(stepConfig) {\n // Fade the step in.\n this.currentStepNode.fadeIn('', $.proxy(function() {\n // Announce via ARIA.\n this.announceStep(stepConfig);\n\n // Focus on the current step Node.\n this.currentStepNode.focus();\n window.setTimeout($.proxy(function() {\n // After a brief delay, focus again.\n // There seems to be an issue with Jaws where it only reads the dialogue title initially.\n // This second focus helps it to read the full dialogue.\n if (this.currentStepNode) {\n this.currentStepNode.focus();\n }\n }, this), 100);\n\n }, this));\n\n return this;\n }\n\n /**\n * Helper to announce the step on the page.\n *\n * @method announceStep\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n announceStep(stepConfig) {\n // Setup the step Dialogue as per:\n // * https://www.w3.org/TR/wai-aria-practices/#dialog_nonmodal\n // * https://www.w3.org/TR/wai-aria-practices/#dialog_modal\n\n // Generate an ID for the current step node.\n let stepId = 'tour-step-' + this.tourName + '-' + stepConfig.stepNumber;\n this.currentStepNode.attr('id', stepId);\n\n let bodyRegion = this.currentStepNode.find('[data-placeholder=\"body\"]').first();\n bodyRegion.attr('id', stepId + '-body');\n bodyRegion.attr('role', 'document');\n\n let headerRegion = this.currentStepNode.find('[data-placeholder=\"title\"]').first();\n headerRegion.attr('id', stepId + '-title');\n headerRegion.attr('aria-labelledby', stepId + '-body');\n\n // Generally, a modal dialog has a role of dialog.\n this.currentStepNode.attr('role', 'dialog');\n this.currentStepNode.attr('tabindex', 0);\n this.currentStepNode.attr('aria-labelledby', stepId + '-title');\n this.currentStepNode.attr('aria-describedby', stepId + '-body');\n\n // Configure ARIA attributes on the target.\n let target = this.getStepTarget(stepConfig);\n if (target) {\n if (!target.attr('tabindex')) {\n target.attr('tabindex', 0);\n }\n\n target\n .data('original-describedby', target.attr('aria-describedby'))\n .attr('aria-describedby', stepId + '-body')\n ;\n }\n\n this.accessibilityShow(stepConfig);\n\n return this;\n }\n\n /**\n * Handle key down events.\n *\n * @method handleKeyDown\n * @param {EventFacade} e\n */\n handleKeyDown(e) {\n let tabbableSelector = 'a[href], link[href], [draggable=true], [contenteditable=true], ';\n tabbableSelector += ':input:enabled, [tabindex], button:enabled';\n switch (e.keyCode) {\n case 27:\n this.endTour();\n break;\n\n // 9 == Tab - trap focus for items with a backdrop.\n case 9:\n // Tab must be handled on key up only in this instance.\n (function() {\n if (!this.currentStepConfig.hasBackdrop) {\n // Trapping tab focus is only handled for those steps with a backdrop.\n return;\n }\n\n // Find all tabbable locations.\n let activeElement = $(document.activeElement);\n let stepTarget = this.getStepTarget(this.currentStepConfig);\n let tabbableNodes = $(tabbableSelector);\n let dialogContainer = $('span[data-flexitour=\"container\"]');\n let currentIndex;\n // Filter out element which is not belong to target section or dialogue.\n if (stepTarget) {\n tabbableNodes = tabbableNodes.filter(function(index, element) {\n return stepTarget !== null\n && (stepTarget.has(element).length\n || dialogContainer.has(element).length\n || stepTarget.is(element)\n || dialogContainer.is(element));\n });\n }\n\n // Find index of focusing element.\n tabbableNodes.each(function(index, element) {\n if (activeElement.is(element)) {\n currentIndex = index;\n return false;\n }\n // Keep looping.\n return true;\n });\n\n let nextIndex;\n let nextNode;\n let focusRelevant;\n if (currentIndex != void 0) {\n let direction = 1;\n if (e.shiftKey) {\n direction = -1;\n }\n nextIndex = currentIndex;\n do {\n nextIndex += direction;\n nextNode = $(tabbableNodes[nextIndex]);\n } while (nextNode.length && nextNode.is(':disabled') || nextNode.is(':hidden'));\n if (nextNode.length) {\n // A new f\n focusRelevant = nextNode.closest(stepTarget).length;\n focusRelevant = focusRelevant || nextNode.closest(this.currentStepNode).length;\n } else {\n // Unable to find the target somehow.\n focusRelevant = false;\n }\n }\n\n if (focusRelevant) {\n nextNode.focus();\n } else {\n if (e.shiftKey) {\n // Focus on the last tabbable node in the step.\n this.currentStepNode.find(tabbableSelector).last().focus();\n } else {\n if (this.currentStepConfig.isOrphan) {\n // Focus on the step - there is no target.\n this.currentStepNode.focus();\n } else {\n // Focus on the step target.\n stepTarget.focus();\n }\n }\n }\n e.preventDefault();\n }).call(this);\n break;\n }\n }\n\n /**\n * Start the current tour.\n *\n * @method startTour\n * @param {Integer} startAt Which step number to start at. If not specified, starts at the last point.\n * @chainable\n * @return {Object} this.\n */\n startTour(startAt) {\n if (this.storage && typeof startAt === 'undefined') {\n let storageStartValue = this.storage.getItem(this.storageKey);\n if (storageStartValue) {\n let storageStartAt = parseInt(storageStartValue, 10);\n if (storageStartAt <= this.steps.length) {\n startAt = storageStartAt;\n }\n }\n }\n\n if (typeof startAt === 'undefined') {\n startAt = this.getCurrentStepNumber();\n }\n\n this.fireEventHandlers('beforeStart', startAt);\n this.gotoStep(startAt);\n this.fireEventHandlers('afterStart', startAt);\n\n return this;\n }\n\n /**\n * Restart the tour from the beginning, resetting the completionlag.\n *\n * @method restartTour\n * @chainable\n * @return {Object} this.\n */\n restartTour() {\n return this.startTour(0);\n }\n\n /**\n * End the current tour.\n *\n * @method endTour\n * @chainable\n * @return {Object} this.\n */\n endTour() {\n this.fireEventHandlers('beforeEnd');\n\n if (this.currentStepConfig) {\n let previousTarget = this.getStepTarget(this.currentStepConfig);\n if (previousTarget) {\n if (!previousTarget.attr('tabindex')) {\n previousTarget.attr('tabindex', '-1');\n }\n previousTarget.focus();\n }\n }\n\n this.hide(true);\n\n this.fireEventHandlers('afterEnd');\n\n return this;\n }\n\n /**\n * Hide any currently visible steps.\n *\n * @method hide\n * @param {Bool} transition Animate the visibility change\n * @chainable\n * @return {Object} this.\n */\n hide(transition) {\n this.fireEventHandlers('beforeHide');\n\n if (this.currentStepNode && this.currentStepNode.length) {\n this.currentStepNode.hide();\n if (this.currentStepPopper) {\n this.currentStepPopper.destroy();\n }\n }\n\n // Restore original target configuration.\n if (this.currentStepConfig) {\n let target = this.getStepTarget(this.currentStepConfig);\n if (target) {\n if (target.data('original-labelledby')) {\n target.attr('aria-labelledby', target.data('original-labelledby'));\n }\n\n if (target.data('original-describedby')) {\n target.attr('aria-describedby', target.data('original-describedby'));\n }\n\n if (target.data('original-tabindex')) {\n target.attr('tabindex', target.data('tabindex'));\n }\n }\n\n // Clear the step configuration.\n this.currentStepConfig = null;\n }\n\n let fadeTime = 0;\n if (transition) {\n fadeTime = 400;\n }\n\n // Remove the backdrop features.\n $('[data-flexitour=\"step-background\"]').remove();\n $('[data-flexitour=\"step-backdrop\"]').removeAttr('data-flexitour');\n $('[data-flexitour=\"backdrop\"]').fadeOut(fadeTime, function() {\n $(this).remove();\n });\n\n // Remove aria-describedby and tabindex attributes.\n if (this.currentStepNode && this.currentStepNode.length) {\n let stepId = this.currentStepNode.attr('id');\n if (stepId) {\n let currentStepElement = '[aria-describedby=\"' + stepId + '-body\"]';\n $(currentStepElement).removeAttr('tabindex');\n $(currentStepElement).removeAttr('aria-describedby');\n }\n }\n\n // Reset the listeners.\n this.resetStepListeners();\n\n this.accessibilityHide();\n\n this.fireEventHandlers('afterHide');\n\n this.currentStepNode = null;\n this.currentStepPopper = null;\n return this;\n }\n\n /**\n * Show the current steps.\n *\n * @method show\n * @chainable\n * @return {Object} this.\n */\n show() {\n // Show the current step.\n let startAt = this.getCurrentStepNumber();\n\n return this.gotoStep(startAt);\n }\n\n /**\n * Return the current step node.\n *\n * @method getStepContainer\n * @return {jQuery}\n */\n getStepContainer() {\n return $(this.currentStepNode);\n }\n\n /**\n * Calculate scrollTop.\n *\n * @method calculateScrollTop\n * @param {Object} stepConfig The step configuration of the step\n * @return {Number}\n */\n calculateScrollTop(stepConfig) {\n let scrollTop = $(window).scrollTop();\n let viewportHeight = $(window).height();\n let targetNode = this.getStepTarget(stepConfig);\n\n if (stepConfig.placement === 'top') {\n // If the placement is top, center scroll at the top of the target.\n scrollTop = targetNode.offset().top - (viewportHeight / 2);\n } else if (stepConfig.placement === 'bottom') {\n // If the placement is bottom, center scroll at the bottom of the target.\n scrollTop = targetNode.offset().top + targetNode.height() - (viewportHeight / 2);\n } else if (targetNode.height() <= (viewportHeight * 0.8)) {\n // If the placement is left/right, and the target fits in the viewport, centre screen on the target\n scrollTop = targetNode.offset().top - ((viewportHeight - targetNode.height()) / 2);\n } else {\n // If the placement is left/right, and the target is bigger than the viewport, set scrollTop to target.top + buffer\n // and change step attachmentTarget to top+.\n scrollTop = targetNode.offset().top - (viewportHeight * 0.2);\n }\n\n // Never scroll over the top.\n scrollTop = Math.max(0, scrollTop);\n\n // Never scroll beyond the bottom.\n scrollTop = Math.min($(document).height() - viewportHeight, scrollTop);\n\n return Math.ceil(scrollTop);\n }\n\n /**\n * Calculate dialogue position for page middle.\n *\n * @method calculateScrollTop\n * @return {Number}\n */\n calculateStepPositionInPage() {\n let viewportHeight = $(window).height();\n let stepHeight = this.currentStepNode.height();\n\n let viewportWidth = $(window).width();\n let stepWidth = this.currentStepNode.width();\n\n return {\n top: Math.ceil((viewportHeight - stepHeight) / 2),\n left: Math.ceil((viewportWidth - stepWidth) / 2)\n };\n }\n\n /**\n * Position the step on the page.\n *\n * @method positionStep\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n positionStep(stepConfig) {\n let content = this.currentStepNode;\n if (!content || !content.length) {\n // Unable to find the step node.\n return this;\n }\n\n let flipBehavior;\n switch (stepConfig.placement) {\n case 'left':\n flipBehavior = ['left', 'right', 'top', 'bottom'];\n break;\n case 'right':\n flipBehavior = ['right', 'left', 'top', 'bottom'];\n break;\n case 'top':\n flipBehavior = ['top', 'bottom', 'right', 'left'];\n break;\n case 'bottom':\n flipBehavior = ['bottom', 'top', 'right', 'left'];\n break;\n default:\n flipBehavior = 'flip';\n break;\n }\n\n let target = this.getStepTarget(stepConfig);\n var config = {\n placement: stepConfig.placement + '-start',\n removeOnDestroy: true,\n modifiers: {\n flip: {\n behaviour: flipBehavior,\n },\n arrow: {\n element: '[data-role=\"arrow\"]',\n },\n },\n onCreate: function(data) {\n recalculateArrowPosition(data);\n },\n onUpdate: function(data) {\n recalculateArrowPosition(data);\n },\n };\n\n let recalculateArrowPosition = function(data) {\n let placement = data.placement.split('-')[0];\n const isVertical = ['left', 'right'].indexOf(placement) !== -1;\n const arrowElement = data.instance.popper.querySelector('[data-role=\"arrow\"]');\n const stepElement = $(data.instance.popper.querySelector('[data-role=\"flexitour-step\"]'));\n if (isVertical) {\n let arrowHeight = parseFloat(window.getComputedStyle(arrowElement).height);\n let arrowOffset = parseFloat(window.getComputedStyle(arrowElement).top);\n let popperHeight = parseFloat(window.getComputedStyle(data.instance.popper).height);\n let popperOffset = parseFloat(window.getComputedStyle(data.instance.popper).top);\n let popperBorderWidth = parseFloat(stepElement.css('borderTopWidth'));\n let popperBorderRadiusWidth = parseFloat(stepElement.css('borderTopLeftRadius')) * 2;\n let arrowPos = arrowOffset + (arrowHeight / 2);\n let maxPos = popperHeight + popperOffset - popperBorderWidth - popperBorderRadiusWidth;\n let minPos = popperOffset + popperBorderWidth + popperBorderRadiusWidth;\n if (arrowPos >= maxPos || arrowPos <= minPos) {\n let newArrowPos = 0;\n if (arrowPos > (popperHeight / 2)) {\n newArrowPos = maxPos - arrowHeight;\n } else {\n newArrowPos = minPos + arrowHeight;\n }\n $(arrowElement).css('top', newArrowPos);\n }\n } else {\n let arrowWidth = parseFloat(window.getComputedStyle(arrowElement).width);\n let arrowOffset = parseFloat(window.getComputedStyle(arrowElement).left);\n let popperWidth = parseFloat(window.getComputedStyle(data.instance.popper).width);\n let popperOffset = parseFloat(window.getComputedStyle(data.instance.popper).left);\n let popperBorderWidth = parseFloat(stepElement.css('borderTopWidth'));\n let popperBorderRadiusWidth = parseFloat(stepElement.css('borderTopLeftRadius')) * 2;\n let arrowPos = arrowOffset + (arrowWidth / 2);\n let maxPos = popperWidth + popperOffset - popperBorderWidth - popperBorderRadiusWidth;\n let minPos = popperOffset + popperBorderWidth + popperBorderRadiusWidth;\n if (arrowPos >= maxPos || arrowPos <= minPos) {\n let newArrowPos = 0;\n if (arrowPos > (popperWidth / 2)) {\n newArrowPos = maxPos - arrowWidth;\n } else {\n newArrowPos = minPos + arrowWidth;\n }\n $(arrowElement).css('left', newArrowPos);\n }\n }\n };\n\n let background = $('[data-flexitour=\"step-background\"]');\n if (background.length) {\n target = background;\n }\n this.currentStepPopper = new Popper(target, content[0], config);\n\n return this;\n }\n\n /**\n * Add the backdrop.\n *\n * @method positionBackdrop\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n positionBackdrop(stepConfig) {\n if (stepConfig.backdrop) {\n this.currentStepConfig.hasBackdrop = true;\n let backdrop = $('
');\n\n if (stepConfig.zIndex) {\n if (stepConfig.attachPoint === 'append') {\n stepConfig.attachTo.append(backdrop);\n } else {\n backdrop.insertAfter(stepConfig.attachTo);\n }\n } else {\n $('body').append(backdrop);\n }\n\n if (this.isStepActuallyVisible(stepConfig)) {\n // The step has a visible target.\n // Punch a hole through the backdrop.\n let background = $('
');\n\n let targetNode = this.getStepTarget(stepConfig);\n\n let buffer = 10;\n\n let colorNode = targetNode;\n if (buffer) {\n colorNode = $('body');\n }\n\n background.css({\n width: targetNode.outerWidth() + buffer + buffer,\n height: targetNode.outerHeight() + buffer + buffer,\n left: targetNode.offset().left - buffer,\n top: targetNode.offset().top - buffer,\n backgroundColor: this.calculateInherittedBackgroundColor(colorNode),\n });\n\n if (targetNode.offset().left < buffer) {\n background.css({\n width: targetNode.outerWidth() + targetNode.offset().left + buffer,\n left: targetNode.offset().left,\n });\n }\n\n if (targetNode.offset().top < buffer) {\n background.css({\n height: targetNode.outerHeight() + targetNode.offset().top + buffer,\n top: targetNode.offset().top,\n });\n }\n\n let targetRadius = targetNode.css('borderRadius');\n if (targetRadius && targetRadius !== $('body').css('borderRadius')) {\n background.css('borderRadius', targetRadius);\n }\n\n let targetPosition = this.calculatePosition(targetNode);\n if (targetPosition === 'fixed') {\n background.css('top', 0);\n } else if (targetPosition === 'absolute') {\n background.css('position', 'fixed');\n }\n\n let fader = background.clone();\n fader.css({\n backgroundColor: backdrop.css('backgroundColor'),\n opacity: backdrop.css('opacity'),\n });\n fader.attr('data-flexitour', 'step-background-fader');\n\n if (stepConfig.zIndex) {\n if (stepConfig.attachPoint === 'append') {\n stepConfig.attachTo.append(background);\n } else {\n fader.insertAfter(stepConfig.attachTo);\n background.insertAfter(stepConfig.attachTo);\n }\n } else {\n $('body').append(fader);\n $('body').append(background);\n }\n\n // Add the backdrop data to the actual target.\n // This is the part which actually does the work.\n targetNode.attr('data-flexitour', 'step-backdrop');\n\n if (stepConfig.zIndex) {\n backdrop.css('zIndex', stepConfig.zIndex);\n background.css('zIndex', stepConfig.zIndex + 1);\n targetNode.css('zIndex', stepConfig.zIndex + 2);\n }\n\n fader.fadeOut('2000', function() {\n $(this).remove();\n });\n }\n }\n return this;\n }\n\n /**\n * Calculate the inheritted z-index.\n *\n * @method calculateZIndex\n * @param {jQuery} elem The element to calculate z-index for\n * @return {Number} Calculated z-index\n */\n calculateZIndex(elem) {\n elem = $(elem);\n while (elem.length && elem[0] !== document) {\n // Ignore z-index if position is set to a value where z-index is ignored by the browser\n // This makes behavior of this function consistent across browsers\n // WebKit always returns auto if the element is positioned.\n let position = elem.css(\"position\");\n if (position === \"absolute\" || position === \"relative\" || position === \"fixed\") {\n // IE returns 0 when zIndex is not specified\n // other browsers return a string\n // we ignore the case of nested elements with an explicit value of 0\n //
\n let value = parseInt(elem.css(\"zIndex\"), 10);\n if (!isNaN(value) && value !== 0) {\n return value;\n }\n }\n elem = elem.parent();\n }\n\n return 0;\n }\n\n /**\n * Calculate the inheritted background colour.\n *\n * @method calculateInherittedBackgroundColor\n * @param {jQuery} elem The element to calculate colour for\n * @return {String} Calculated background colour\n */\n calculateInherittedBackgroundColor(elem) {\n // Use a fake node to compare each element against.\n let fakeNode = $('
').hide();\n $('body').append(fakeNode);\n let fakeElemColor = fakeNode.css('backgroundColor');\n fakeNode.remove();\n\n elem = $(elem);\n while (elem.length && elem[0] !== document) {\n let color = elem.css('backgroundColor');\n if (color !== fakeElemColor) {\n return color;\n }\n elem = elem.parent();\n }\n\n return null;\n }\n\n /**\n * Calculate the inheritted position.\n *\n * @method calculatePosition\n * @param {jQuery} elem The element to calculate position for\n * @return {String} Calculated position\n */\n calculatePosition(elem) {\n elem = $(elem);\n while (elem.length && elem[0] !== document) {\n let position = elem.css('position');\n if (position !== 'static') {\n return position;\n }\n elem = elem.parent();\n }\n\n return null;\n }\n\n /**\n * Perform accessibility changes for step shown.\n *\n * This will add aria-hidden=\"true\" to all siblings and parent siblings.\n *\n * @method accessibilityShow\n */\n accessibilityShow() {\n let stateHolder = 'data-has-hidden';\n let attrName = 'aria-hidden';\n let hideFunction = function(child) {\n let flexitourRole = child.data('flexitour');\n if (flexitourRole) {\n switch (flexitourRole) {\n case 'container':\n case 'target':\n return;\n }\n }\n\n let hidden = child.attr(attrName);\n if (!hidden) {\n child.attr(stateHolder, true);\n child.attr(attrName, true);\n }\n };\n\n this.currentStepNode.siblings().each(function(index, node) {\n hideFunction($(node));\n });\n this.currentStepNode.parentsUntil('body').siblings().each(function(index, node) {\n hideFunction($(node));\n });\n }\n\n /**\n * Perform accessibility changes for step hidden.\n *\n * This will remove any newly added aria-hidden=\"true\".\n *\n * @method accessibilityHide\n */\n accessibilityHide() {\n let stateHolder = 'data-has-hidden';\n let attrName = 'aria-hidden';\n let showFunction = function(child) {\n let hidden = child.attr(stateHolder);\n if (typeof hidden !== 'undefined') {\n child.removeAttr(stateHolder);\n child.removeAttr(attrName);\n }\n };\n\n $('[' + stateHolder + ']').each(function(index, node) {\n showFunction($(node));\n });\n }\n}\n"],"file":"tour.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/tour.js"],"names":["Tour","config","init","eventHandlers","reset","originalConfiguration","configure","apply","arguments","storage","window","sessionStorage","storageKey","tourName","e","hide","resetStepListeners","steps","currentStepNumber","eventName","forEach","handler","addEventHandler","resetStepDefaults","template","templateContent","checkMinimumRequirements","Error","length","loadOriginalConfiguration","stepDefaults","setStepDefaults","$","extend","element","placement","delay","moveOnClick","moveAfterTime","orphan","direction","parseInt","stepNumber","setItem","code","DOMException","QUOTA_EXCEEDED_ERR","removeItem","getCurrentStepNumber","nextStepNumber","isStepPotentiallyVisible","getStepConfig","previousStepNumber","getNextStepNumber","getPreviousStepNumber","stepConfig","isStepActuallyVisible","target","getStepTarget","is","gotoStep","endTour","_gotoStep","delayed","setTimeout","bind","fn","fireEventHandlers","renderStep","normalizeStepConfig","reflex","moveAfterClick","content","body","attachTo","attachPoint","first","data","thisEvent","call","push","listeners","node","currentStepNode","args","proxy","next","previous","handleKeyDown","targetNode","parents","listener","on","off","currentStepConfig","setCurrentStepNumber","getTemplateContent","find","html","title","isFirstStep","prop","isLastStep","removeClass","addClass","attr","addStepToPage","processStepListeners","clone","animationTarget","stop","zIndex","calculateZIndex","css","positionBackdrop","document","append","top","left","animate","scrollTop","calculateScrollTop","promise","then","positionStep","revealStep","catch","isOrphan","offset","calculateStepPositionInPage","currentStepPopper","Popper","removeOnDestroy","arrowElement","modifiers","enabled","applyStyle","onLoad","fadeIn","announceStep","focus","stepId","bodyRegion","headerRegion","accessibilityShow","tabbableSelector","keyCode","hasBackdrop","activeElement","stepTarget","tabbableNodes","dialogContainer","currentIndex","filter","index","has","each","nextIndex","nextNode","focusRelevant","shiftKey","closest","last","preventDefault","startAt","storageStartValue","getItem","storageStartAt","startTour","previousTarget","transition","destroy","fadeTime","remove","removeAttr","fadeOut","currentStepElement","accessibilityHide","viewportHeight","height","Math","max","min","ceil","stepHeight","viewportWidth","width","stepWidth","flipBehavior","flip","behaviour","arrow","onCreate","recalculateArrowPosition","onUpdate","split","isVertical","indexOf","instance","popper","querySelector","stepElement","arrowHeight","parseFloat","getComputedStyle","arrowOffset","popperHeight","popperOffset","popperBorderWidth","popperBorderRadiusWidth","arrowPos","maxPos","minPos","newArrowPos","arrowWidth","popperWidth","background","backdrop","insertAfter","buffer","colorNode","outerWidth","outerHeight","backgroundColor","calculateInherittedBackgroundColor","targetRadius","targetPosition","calculatePosition","fader","opacity","elem","position","value","isNaN","parent","fakeNode","fakeElemColor","color","attrName","hideFunction","child","flexitourRole","hidden","siblings","parentsUntil","showFunction"],"mappings":"gKAsBA,OACA,O,koBAOqBA,CAAAA,C,YAIjB,WAAYC,CAAZ,CAAoB,WAChB,KAAKC,IAAL,CAAUD,CAAV,CACH,C,qCAUIA,C,CAAQ,CAET,KAAKE,aAAL,CAAqB,EAArB,CAGA,KAAKC,KAAL,GAGA,KAAKC,qBAAL,CAA6BJ,CAAM,EAAI,EAAvC,CAGA,KAAKK,SAAL,CAAeC,KAAf,CAAqB,IAArB,CAA2BC,SAA3B,EAEA,GAAI,CACA,KAAKC,OAAL,CAAeC,MAAM,CAACC,cAAtB,CACA,KAAKC,UAAL,CAAkB,aAAe,KAAKC,QACzC,CAAC,MAAOC,CAAP,CAAU,CACR,KAAKL,OAAL,IACA,KAAKG,UAAL,CAAkB,EACrB,CAED,MAAO,KACV,C,qCASO,CAEJ,KAAKG,IAAL,GAGA,KAAKZ,aAAL,CAAqB,EAArB,CAGA,KAAKa,kBAAL,GAGA,KAAKX,qBAAL,CAA6B,EAA7B,CAGA,KAAKY,KAAL,CAAa,EAAb,CAGA,KAAKC,iBAAL,CAAyB,CAAzB,CAEA,MAAO,KACV,C,4CAUSjB,C,CAAQ,YACd,GAAsB,QAAlB,KAAOA,CAAP,CAAJ,CAAgC,CAE5B,GAA+B,WAA3B,QAAOA,CAAAA,CAAM,CAACY,QAAlB,CAA4C,CACxC,KAAKA,QAAL,CAAgBZ,CAAM,CAACY,QAC1B,CAGD,GAAIZ,CAAM,CAACE,aAAX,CAA0B,gBACbgB,CADa,EAElBlB,CAAM,CAACE,aAAP,CAAqBgB,CAArB,EAAgCC,OAAhC,CAAwC,SAASC,CAAT,CAAkB,CACtD,KAAKC,eAAL,CAAqBH,CAArB,CAAgCE,CAAhC,CACH,CAFD,CAEG,CAFH,CAFkB,EACtB,IAAK,GAAIF,CAAAA,CAAT,GAAsBlB,CAAAA,CAAM,CAACE,aAA7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AACvI,IAAN,CAAWqI,CAAX,IACH,CACJ,CAlBe,CAoBhB,KAAK3J,eAAL,CAAqBgK,QAArB,GAAgCvF,IAAhC,CAAqC,SAASF,CAAT,CAAgBxE,CAAhB,CAAsB,CACvD6J,CAAY,CAAC,cAAE7J,CAAF,CAAD,CACf,CAFD,EAGA,KAAKC,eAAL,CAAqBiK,YAArB,CAAkC,MAAlC,EAA0CD,QAA1C,GAAqDvF,IAArD,CAA0D,SAASF,CAAT,CAAgBxE,CAAhB,CAAsB,CAC5E6J,CAAY,CAAC,cAAE7J,CAAF,CAAD,CACf,CAFD,CAGH,C,6DASmB,IAGZmK,CAAAA,CAAY,CAAG,SAASL,CAAT,CAAgB,CAC/B,GAAIE,CAAAA,CAAM,CAAGF,CAAK,CAACvI,IAAN,mBAAb,CACA,GAAsB,WAAlB,QAAOyI,CAAAA,CAAX,CAAmC,CAC/BF,CAAK,CAAClE,UAAN,oBACAkE,CAAK,CAAClE,UAAN,CALO,aAKP,CACH,CACJ,CATe,CAWhB,mCAA2BlB,IAA3B,CAAgC,SAASF,CAAT,CAAgBxE,CAAhB,CAAsB,CAClDmK,CAAY,CAAC,cAAEnK,CAAF,CAAD,CACf,CAFD,CAGH,C","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 .\n\n/**\n * Manage user tours in Moodle.\n *\n * @copyright 2018 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport Popper from 'core/popper';\n\n/**\n * A Tour.\n *\n * @class Tour\n */\nexport default class Tour {\n /**\n * @param {object} config The configuration object.\n */\n constructor(config) {\n this.init(config);\n }\n\n /**\n * Initialise the tour.\n *\n * @method init\n * @param {Object} config The configuration object.\n * @chainable\n * @return {Object} this.\n */\n init(config) {\n // Unset all handlers.\n this.eventHandlers = {};\n\n // Reset the current tour states.\n this.reset();\n\n // Store the initial configuration.\n this.originalConfiguration = config || {};\n\n // Apply configuration.\n this.configure.apply(this, arguments);\n\n try {\n this.storage = window.sessionStorage;\n this.storageKey = 'tourstate_' + this.tourName;\n } catch (e) {\n this.storage = false;\n this.storageKey = '';\n }\n\n return this;\n }\n\n /**\n * Reset the current tour state.\n *\n * @method reset\n * @chainable\n * @return {Object} this.\n */\n reset() {\n // Hide the current step.\n this.hide();\n\n // Unset all handlers.\n this.eventHandlers = [];\n\n // Unset all listeners.\n this.resetStepListeners();\n\n // Unset the original configuration.\n this.originalConfiguration = {};\n\n // Reset the current step number and list of steps.\n this.steps = [];\n\n // Reset the current step number.\n this.currentStepNumber = 0;\n\n return this;\n }\n\n /**\n * Prepare tour configuration.\n *\n * @method configure\n * @param {Object} config The configuration object.\n * @chainable\n * @return {Object} this.\n */\n configure(config) {\n if (typeof config === 'object') {\n // Tour name.\n if (typeof config.tourName !== 'undefined') {\n this.tourName = config.tourName;\n }\n\n // Set up eventHandlers.\n if (config.eventHandlers) {\n for (let eventName in config.eventHandlers) {\n config.eventHandlers[eventName].forEach(function(handler) {\n this.addEventHandler(eventName, handler);\n }, this);\n }\n }\n\n // Reset the step configuration.\n this.resetStepDefaults(true);\n\n // Configure the steps.\n if (typeof config.steps === 'object') {\n this.steps = config.steps;\n }\n\n if (typeof config.template !== 'undefined') {\n this.templateContent = config.template;\n }\n }\n\n // Check that we have enough to start the tour.\n this.checkMinimumRequirements();\n\n return this;\n }\n\n /**\n * Check that the configuration meets the minimum requirements.\n *\n * @method checkMinimumRequirements\n */\n checkMinimumRequirements() {\n // Need a tourName.\n if (!this.tourName) {\n throw new Error(\"Tour Name required\");\n }\n\n // Need a minimum of one step.\n if (!this.steps || !this.steps.length) {\n throw new Error(\"Steps must be specified\");\n }\n }\n\n /**\n * Reset step default configuration.\n *\n * @method resetStepDefaults\n * @param {Boolean} loadOriginalConfiguration Whether to load the original configuration supplied with the Tour.\n * @chainable\n * @return {Object} this.\n */\n resetStepDefaults(loadOriginalConfiguration) {\n if (typeof loadOriginalConfiguration === 'undefined') {\n loadOriginalConfiguration = true;\n }\n\n this.stepDefaults = {};\n if (!loadOriginalConfiguration || typeof this.originalConfiguration.stepDefaults === 'undefined') {\n this.setStepDefaults({});\n } else {\n this.setStepDefaults(this.originalConfiguration.stepDefaults);\n }\n\n return this;\n }\n\n /**\n * Set the step defaults.\n *\n * @method setStepDefaults\n * @param {Object} stepDefaults The step defaults to apply to all steps\n * @chainable\n * @return {Object} this.\n */\n setStepDefaults(stepDefaults) {\n if (!this.stepDefaults) {\n this.stepDefaults = {};\n }\n $.extend(\n this.stepDefaults,\n {\n element: '',\n placement: 'top',\n delay: 0,\n moveOnClick: false,\n moveAfterTime: 0,\n orphan: false,\n direction: 1,\n },\n stepDefaults\n );\n\n return this;\n }\n\n /**\n * Retrieve the current step number.\n *\n * @method getCurrentStepNumber\n * @return {Integer} The current step number\n */\n getCurrentStepNumber() {\n return parseInt(this.currentStepNumber, 10);\n }\n\n /**\n * Store the current step number.\n *\n * @method setCurrentStepNumber\n * @param {Integer} stepNumber The current step number\n * @chainable\n */\n setCurrentStepNumber(stepNumber) {\n this.currentStepNumber = stepNumber;\n if (this.storage) {\n try {\n this.storage.setItem(this.storageKey, stepNumber);\n } catch (e) {\n if (e.code === DOMException.QUOTA_EXCEEDED_ERR) {\n this.storage.removeItem(this.storageKey);\n }\n }\n }\n }\n\n /**\n * Get the next step number after the currently displayed step.\n *\n * @method getNextStepNumber\n * @param {Integer} stepNumber The current step number\n * @return {Integer} The next step number to display\n */\n getNextStepNumber(stepNumber) {\n if (typeof stepNumber === 'undefined') {\n stepNumber = this.getCurrentStepNumber();\n }\n let nextStepNumber = stepNumber + 1;\n\n // Keep checking the remaining steps.\n while (nextStepNumber <= this.steps.length) {\n if (this.isStepPotentiallyVisible(this.getStepConfig(nextStepNumber))) {\n return nextStepNumber;\n }\n nextStepNumber++;\n }\n\n return null;\n }\n\n /**\n * Get the previous step number before the currently displayed step.\n *\n * @method getPreviousStepNumber\n * @param {Integer} stepNumber The current step number\n * @return {Integer} The previous step number to display\n */\n getPreviousStepNumber(stepNumber) {\n if (typeof stepNumber === 'undefined') {\n stepNumber = this.getCurrentStepNumber();\n }\n let previousStepNumber = stepNumber - 1;\n\n // Keep checking the remaining steps.\n while (previousStepNumber >= 0) {\n if (this.isStepPotentiallyVisible(this.getStepConfig(previousStepNumber))) {\n return previousStepNumber;\n }\n previousStepNumber--;\n }\n\n return null;\n }\n\n /**\n * Is the step the final step number?\n *\n * @method isLastStep\n * @param {Integer} stepNumber Step number to test\n * @return {Boolean} Whether the step is the final step\n */\n isLastStep(stepNumber) {\n let nextStepNumber = this.getNextStepNumber(stepNumber);\n\n return nextStepNumber === null;\n }\n\n /**\n * Is the step the first step number?\n *\n * @method isFirstStep\n * @param {Integer} stepNumber Step number to test\n * @return {Boolean} Whether the step is the first step\n */\n isFirstStep(stepNumber) {\n let previousStepNumber = this.getPreviousStepNumber(stepNumber);\n\n return previousStepNumber === null;\n }\n\n /**\n * Is this step potentially visible?\n *\n * @method isStepPotentiallyVisible\n * @param {Object} stepConfig The step configuration to normalise\n * @return {Boolean} Whether the step is the potentially visible\n */\n isStepPotentiallyVisible(stepConfig) {\n if (!stepConfig) {\n // Without step config, there can be no step.\n return false;\n }\n\n if (this.isStepActuallyVisible(stepConfig)) {\n // If it is actually visible, it is already potentially visible.\n return true;\n }\n\n if (typeof stepConfig.orphan !== 'undefined' && stepConfig.orphan) {\n // Orphan steps have no target. They are always visible.\n return true;\n }\n\n if (typeof stepConfig.delay !== 'undefined' && stepConfig.delay) {\n // Only return true if the activated has not been used yet.\n return true;\n }\n\n // Not theoretically, or actually visible.\n return false;\n }\n\n /**\n * Is this step actually visible?\n *\n * @method isStepActuallyVisible\n * @param {Object} stepConfig The step configuration to normalise\n * @return {Boolean} Whether the step is actually visible\n */\n isStepActuallyVisible(stepConfig) {\n if (!stepConfig) {\n // Without step config, there can be no step.\n return false;\n }\n\n let target = this.getStepTarget(stepConfig);\n if (target && target.length && target.is(':visible')) {\n // Without a target, there can be no step.\n return !!target.length;\n }\n\n return false;\n }\n\n /**\n * Go to the next step in the tour.\n *\n * @method next\n * @chainable\n * @return {Object} this.\n */\n next() {\n return this.gotoStep(this.getNextStepNumber());\n }\n\n /**\n * Go to the previous step in the tour.\n *\n * @method previous\n * @chainable\n * @return {Object} this.\n */\n previous() {\n return this.gotoStep(this.getPreviousStepNumber(), -1);\n }\n\n /**\n * Go to the specified step in the tour.\n *\n * @method gotoStep\n * @param {Integer} stepNumber The step number to display\n * @param {Integer} direction Next or previous step\n * @chainable\n * @return {Object} this.\n */\n gotoStep(stepNumber, direction) {\n if (stepNumber < 0) {\n return this.endTour();\n }\n\n let stepConfig = this.getStepConfig(stepNumber);\n if (stepConfig === null) {\n return this.endTour();\n }\n\n return this._gotoStep(stepConfig, direction);\n }\n\n _gotoStep(stepConfig, direction) {\n if (!stepConfig) {\n return this.endTour();\n }\n\n if (typeof stepConfig.delay !== 'undefined' && stepConfig.delay && !stepConfig.delayed) {\n stepConfig.delayed = true;\n window.setTimeout(this._gotoStep.bind(this), stepConfig.delay, stepConfig, direction);\n\n return this;\n } else if (!stepConfig.orphan && !this.isStepActuallyVisible(stepConfig)) {\n let fn = direction == -1 ? 'getPreviousStepNumber' : 'getNextStepNumber';\n return this.gotoStep(this[fn](stepConfig.stepNumber), direction);\n }\n\n this.hide();\n\n this.fireEventHandlers('beforeRender', stepConfig);\n this.renderStep(stepConfig);\n this.fireEventHandlers('afterRender', stepConfig);\n\n return this;\n }\n\n /**\n * Fetch the normalised step configuration for the specified step number.\n *\n * @method getStepConfig\n * @param {Integer} stepNumber The step number to fetch configuration for\n * @return {Object} The step configuration\n */\n getStepConfig(stepNumber) {\n if (stepNumber === null || stepNumber < 0 || stepNumber >= this.steps.length) {\n return null;\n }\n\n // Normalise the step configuration.\n let stepConfig = this.normalizeStepConfig(this.steps[stepNumber]);\n\n // Add the stepNumber to the stepConfig.\n stepConfig = $.extend(stepConfig, {stepNumber: stepNumber});\n\n return stepConfig;\n }\n\n /**\n * Normalise the supplied step configuration.\n *\n * @method normalizeStepConfig\n * @param {Object} stepConfig The step configuration to normalise\n * @return {Object} The normalised step configuration\n */\n normalizeStepConfig(stepConfig) {\n\n if (typeof stepConfig.reflex !== 'undefined' && typeof stepConfig.moveAfterClick === 'undefined') {\n stepConfig.moveAfterClick = stepConfig.reflex;\n }\n\n if (typeof stepConfig.element !== 'undefined' && typeof stepConfig.target === 'undefined') {\n stepConfig.target = stepConfig.element;\n }\n\n if (typeof stepConfig.content !== 'undefined' && typeof stepConfig.body === 'undefined') {\n stepConfig.body = stepConfig.content;\n }\n\n stepConfig = $.extend({}, this.stepDefaults, stepConfig);\n\n stepConfig = $.extend({}, {\n attachTo: stepConfig.target,\n attachPoint: 'after',\n }, stepConfig);\n\n if (stepConfig.attachTo) {\n stepConfig.attachTo = $(stepConfig.attachTo).first();\n }\n\n return stepConfig;\n }\n\n /**\n * Fetch the actual step target from the selector.\n *\n * This should not be called until after any delay has completed.\n *\n * @method getStepTarget\n * @param {Object} stepConfig The step configuration\n * @return {$}\n */\n getStepTarget(stepConfig) {\n if (stepConfig.target) {\n return $(stepConfig.target);\n }\n\n return null;\n }\n\n /**\n * Fire any event handlers for the specified event.\n *\n * @param {String} eventName The name of the event to handle\n * @param {Object} data Any data to pass to the event\n * @chainable\n * @return {Object} this.\n */\n fireEventHandlers(eventName, data) {\n if (typeof this.eventHandlers[eventName] === 'undefined') {\n return this;\n }\n\n this.eventHandlers[eventName].forEach(function(thisEvent) {\n thisEvent.call(this, data);\n }, this);\n\n return this;\n }\n\n /**\n * @method addEventHandler\n * @param {string} eventName The name of the event to listen for\n * @param {function} handler The event handler to call\n * @return {Object} this.\n */\n addEventHandler(eventName, handler) {\n if (typeof this.eventHandlers[eventName] === 'undefined') {\n this.eventHandlers[eventName] = [];\n }\n\n this.eventHandlers[eventName].push(handler);\n\n return this;\n }\n\n /**\n * Process listeners for the step being shown.\n *\n * @method processStepListeners\n * @param {object} stepConfig The configuration for the step\n * @chainable\n * @return {Object} this.\n */\n processStepListeners(stepConfig) {\n this.listeners.push(\n // Next/Previous buttons.\n {\n node: this.currentStepNode,\n args: ['click', '[data-role=\"next\"]', $.proxy(this.next, this)]\n }, {\n node: this.currentStepNode,\n args: ['click', '[data-role=\"previous\"]', $.proxy(this.previous, this)]\n },\n\n // Close and end tour buttons.\n {\n node: this.currentStepNode,\n args: ['click', '[data-role=\"end\"]', $.proxy(this.endTour, this)]\n },\n\n // Click backdrop and hide tour.\n {\n node: $('[data-flexitour=\"backdrop\"]'),\n args: ['click', $.proxy(this.hide, this)]\n },\n\n // Keypresses.\n {\n node: $('body'),\n args: ['keydown', $.proxy(this.handleKeyDown, this)]\n });\n\n if (stepConfig.moveOnClick) {\n var targetNode = this.getStepTarget(stepConfig);\n this.listeners.push({\n node: targetNode,\n args: ['click', $.proxy(function(e) {\n if ($(e.target).parents('[data-flexitour=\"container\"]').length === 0) {\n // Ignore clicks when they are in the flexitour.\n window.setTimeout($.proxy(this.next, this), 500);\n }\n }, this)]\n });\n }\n\n this.listeners.forEach(function(listener) {\n listener.node.on.apply(listener.node, listener.args);\n });\n\n return this;\n }\n\n /**\n * Reset step listeners.\n *\n * @method resetStepListeners\n * @chainable\n * @return {Object} this.\n */\n resetStepListeners() {\n // Stop listening to all external handlers.\n if (this.listeners) {\n this.listeners.forEach(function(listener) {\n listener.node.off.apply(listener.node, listener.args);\n });\n }\n this.listeners = [];\n\n return this;\n }\n\n /**\n * The standard step renderer.\n *\n * @method renderStep\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n renderStep(stepConfig) {\n // Store the current step configuration for later.\n this.currentStepConfig = stepConfig;\n this.setCurrentStepNumber(stepConfig.stepNumber);\n\n // Fetch the template and convert it to a $ object.\n let template = $(this.getTemplateContent());\n\n // Title.\n template.find('[data-placeholder=\"title\"]')\n .html(stepConfig.title);\n\n // Body.\n template.find('[data-placeholder=\"body\"]')\n .html(stepConfig.body);\n\n // Is this the first step?\n if (this.isFirstStep(stepConfig.stepNumber)) {\n template.find('[data-role=\"previous\"]').hide();\n } else {\n template.find('[data-role=\"previous\"]').prop('disabled', false);\n }\n\n // Is this the final step?\n if (this.isLastStep(stepConfig.stepNumber)) {\n template.find('[data-role=\"next\"]').hide();\n template.find('[data-role=\"end\"]').removeClass(\"btn-secondary\").addClass(\"btn-primary\");\n } else {\n template.find('[data-role=\"next\"]').prop('disabled', false);\n }\n\n template.find('[data-role=\"previous\"]').attr('role', 'button');\n template.find('[data-role=\"next\"]').attr('role', 'button');\n template.find('[data-role=\"end\"]').attr('role', 'button');\n\n // Replace the template with the updated version.\n stepConfig.template = template;\n\n // Add to the page.\n this.addStepToPage(stepConfig);\n\n // Process step listeners after adding to the page.\n // This uses the currentNode.\n this.processStepListeners(stepConfig);\n\n return this;\n }\n\n /**\n * Getter for the template content.\n *\n * @method getTemplateContent\n * @return {$}\n */\n getTemplateContent() {\n return $(this.templateContent).clone();\n }\n\n /**\n * Helper to add a step to the page.\n *\n * @method addStepToPage\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n addStepToPage(stepConfig) {\n // Create the stepNode from the template data.\n let currentStepNode = $('')\n .html(stepConfig.template)\n .hide();\n\n // The scroll animation occurs on the body or html.\n let animationTarget = $('body, html')\n .stop(true, true);\n\n if (this.isStepActuallyVisible(stepConfig)) {\n let targetNode = this.getStepTarget(stepConfig);\n\n targetNode.data('flexitour', 'target');\n\n let zIndex = this.calculateZIndex(targetNode);\n if (zIndex) {\n stepConfig.zIndex = zIndex + 1;\n }\n\n if (stepConfig.zIndex) {\n currentStepNode.css('zIndex', stepConfig.zIndex + 1);\n }\n\n // Add the backdrop.\n this.positionBackdrop(stepConfig);\n\n $(document.body).append(currentStepNode);\n this.currentStepNode = currentStepNode;\n\n // Ensure that the step node is positioned.\n // Some situations mean that the value is not properly calculated without this step.\n this.currentStepNode.css({\n top: 0,\n left: 0,\n });\n\n animationTarget\n .animate({\n scrollTop: this.calculateScrollTop(stepConfig),\n }).promise().then(function() {\n this.positionStep(stepConfig);\n this.revealStep(stepConfig);\n return;\n }.bind(this))\n .catch(function() {\n // Silently fail.\n });\n\n } else if (stepConfig.orphan) {\n stepConfig.isOrphan = true;\n\n // This will be appended to the body instead.\n stepConfig.attachTo = $('body').first();\n stepConfig.attachPoint = 'append';\n\n // Add the backdrop.\n this.positionBackdrop(stepConfig);\n\n // This is an orphaned step.\n currentStepNode.addClass('orphan');\n\n // It lives in the body.\n $(document.body).append(currentStepNode);\n this.currentStepNode = currentStepNode;\n\n this.currentStepNode.offset(this.calculateStepPositionInPage());\n this.currentStepNode.css('position', 'fixed');\n\n this.currentStepPopper = new Popper(\n $('body'),\n this.currentStepNode[0], {\n removeOnDestroy: true,\n placement: stepConfig.placement + '-start',\n arrowElement: '[data-role=\"arrow\"]',\n // Empty the modifiers. We've already placed the step and don't want it moved.\n modifiers: {\n hide: {\n enabled: false,\n },\n applyStyle: {\n onLoad: null,\n enabled: false,\n },\n }\n }\n );\n\n this.revealStep(stepConfig);\n }\n\n return this;\n }\n\n /**\n * Make the given step visible.\n *\n * @method revealStep\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n revealStep(stepConfig) {\n // Fade the step in.\n this.currentStepNode.fadeIn('', $.proxy(function() {\n // Announce via ARIA.\n this.announceStep(stepConfig);\n\n // Focus on the current step Node.\n this.currentStepNode.focus();\n window.setTimeout($.proxy(function() {\n // After a brief delay, focus again.\n // There seems to be an issue with Jaws where it only reads the dialogue title initially.\n // This second focus helps it to read the full dialogue.\n if (this.currentStepNode) {\n this.currentStepNode.focus();\n }\n }, this), 100);\n\n }, this));\n\n return this;\n }\n\n /**\n * Helper to announce the step on the page.\n *\n * @method announceStep\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n announceStep(stepConfig) {\n // Setup the step Dialogue as per:\n // * https://www.w3.org/TR/wai-aria-practices/#dialog_nonmodal\n // * https://www.w3.org/TR/wai-aria-practices/#dialog_modal\n\n // Generate an ID for the current step node.\n let stepId = 'tour-step-' + this.tourName + '-' + stepConfig.stepNumber;\n this.currentStepNode.attr('id', stepId);\n\n let bodyRegion = this.currentStepNode.find('[data-placeholder=\"body\"]').first();\n bodyRegion.attr('id', stepId + '-body');\n bodyRegion.attr('role', 'document');\n\n let headerRegion = this.currentStepNode.find('[data-placeholder=\"title\"]').first();\n headerRegion.attr('id', stepId + '-title');\n headerRegion.attr('aria-labelledby', stepId + '-body');\n\n // Generally, a modal dialog has a role of dialog.\n this.currentStepNode.attr('role', 'dialog');\n this.currentStepNode.attr('tabindex', 0);\n this.currentStepNode.attr('aria-labelledby', stepId + '-title');\n this.currentStepNode.attr('aria-describedby', stepId + '-body');\n\n // Configure ARIA attributes on the target.\n let target = this.getStepTarget(stepConfig);\n if (target) {\n if (!target.attr('tabindex')) {\n target.attr('tabindex', 0);\n }\n\n target\n .data('original-describedby', target.attr('aria-describedby'))\n .attr('aria-describedby', stepId + '-body')\n ;\n }\n\n this.accessibilityShow(stepConfig);\n\n return this;\n }\n\n /**\n * Handle key down events.\n *\n * @method handleKeyDown\n * @param {EventFacade} e\n */\n handleKeyDown(e) {\n let tabbableSelector = 'a[href], link[href], [draggable=true], [contenteditable=true], ';\n tabbableSelector += ':input:enabled, [tabindex], button:enabled';\n switch (e.keyCode) {\n case 27:\n this.endTour();\n break;\n\n // 9 == Tab - trap focus for items with a backdrop.\n case 9:\n // Tab must be handled on key up only in this instance.\n (function() {\n if (!this.currentStepConfig.hasBackdrop) {\n // Trapping tab focus is only handled for those steps with a backdrop.\n return;\n }\n\n // Find all tabbable locations.\n let activeElement = $(document.activeElement);\n let stepTarget = this.getStepTarget(this.currentStepConfig);\n let tabbableNodes = $(tabbableSelector);\n let dialogContainer = $('span[data-flexitour=\"container\"]');\n let currentIndex;\n // Filter out element which is not belong to target section or dialogue.\n if (stepTarget) {\n tabbableNodes = tabbableNodes.filter(function(index, element) {\n return stepTarget !== null\n && (stepTarget.has(element).length\n || dialogContainer.has(element).length\n || stepTarget.is(element)\n || dialogContainer.is(element));\n });\n }\n\n // Find index of focusing element.\n tabbableNodes.each(function(index, element) {\n if (activeElement.is(element)) {\n currentIndex = index;\n return false;\n }\n // Keep looping.\n return true;\n });\n\n let nextIndex;\n let nextNode;\n let focusRelevant;\n if (currentIndex != void 0) {\n let direction = 1;\n if (e.shiftKey) {\n direction = -1;\n }\n nextIndex = currentIndex;\n do {\n nextIndex += direction;\n nextNode = $(tabbableNodes[nextIndex]);\n } while (nextNode.length && nextNode.is(':disabled') || nextNode.is(':hidden'));\n if (nextNode.length) {\n // A new f\n focusRelevant = nextNode.closest(stepTarget).length;\n focusRelevant = focusRelevant || nextNode.closest(this.currentStepNode).length;\n } else {\n // Unable to find the target somehow.\n focusRelevant = false;\n }\n }\n\n if (focusRelevant) {\n nextNode.focus();\n } else {\n if (e.shiftKey) {\n // Focus on the last tabbable node in the step.\n this.currentStepNode.find(tabbableSelector).last().focus();\n } else {\n if (this.currentStepConfig.isOrphan) {\n // Focus on the step - there is no target.\n this.currentStepNode.focus();\n } else {\n // Focus on the step target.\n stepTarget.focus();\n }\n }\n }\n e.preventDefault();\n }).call(this);\n break;\n }\n }\n\n /**\n * Start the current tour.\n *\n * @method startTour\n * @param {Integer} startAt Which step number to start at. If not specified, starts at the last point.\n * @chainable\n * @return {Object} this.\n */\n startTour(startAt) {\n if (this.storage && typeof startAt === 'undefined') {\n let storageStartValue = this.storage.getItem(this.storageKey);\n if (storageStartValue) {\n let storageStartAt = parseInt(storageStartValue, 10);\n if (storageStartAt <= this.steps.length) {\n startAt = storageStartAt;\n }\n }\n }\n\n if (typeof startAt === 'undefined') {\n startAt = this.getCurrentStepNumber();\n }\n\n this.fireEventHandlers('beforeStart', startAt);\n this.gotoStep(startAt);\n this.fireEventHandlers('afterStart', startAt);\n\n return this;\n }\n\n /**\n * Restart the tour from the beginning, resetting the completionlag.\n *\n * @method restartTour\n * @chainable\n * @return {Object} this.\n */\n restartTour() {\n return this.startTour(0);\n }\n\n /**\n * End the current tour.\n *\n * @method endTour\n * @chainable\n * @return {Object} this.\n */\n endTour() {\n this.fireEventHandlers('beforeEnd');\n\n if (this.currentStepConfig) {\n let previousTarget = this.getStepTarget(this.currentStepConfig);\n if (previousTarget) {\n if (!previousTarget.attr('tabindex')) {\n previousTarget.attr('tabindex', '-1');\n }\n previousTarget.focus();\n }\n }\n\n this.hide(true);\n\n this.fireEventHandlers('afterEnd');\n\n return this;\n }\n\n /**\n * Hide any currently visible steps.\n *\n * @method hide\n * @param {Bool} transition Animate the visibility change\n * @chainable\n * @return {Object} this.\n */\n hide(transition) {\n this.fireEventHandlers('beforeHide');\n\n if (this.currentStepNode && this.currentStepNode.length) {\n this.currentStepNode.hide();\n if (this.currentStepPopper) {\n this.currentStepPopper.destroy();\n }\n }\n\n // Restore original target configuration.\n if (this.currentStepConfig) {\n let target = this.getStepTarget(this.currentStepConfig);\n if (target) {\n if (target.data('original-labelledby')) {\n target.attr('aria-labelledby', target.data('original-labelledby'));\n }\n\n if (target.data('original-describedby')) {\n target.attr('aria-describedby', target.data('original-describedby'));\n }\n\n if (target.data('original-tabindex')) {\n target.attr('tabindex', target.data('tabindex'));\n }\n }\n\n // Clear the step configuration.\n this.currentStepConfig = null;\n }\n\n let fadeTime = 0;\n if (transition) {\n fadeTime = 400;\n }\n\n // Remove the backdrop features.\n $('[data-flexitour=\"step-background\"]').remove();\n $('[data-flexitour=\"step-backdrop\"]').removeAttr('data-flexitour');\n $('[data-flexitour=\"backdrop\"]').fadeOut(fadeTime, function() {\n $(this).remove();\n });\n\n // Remove aria-describedby and tabindex attributes.\n if (this.currentStepNode && this.currentStepNode.length) {\n let stepId = this.currentStepNode.attr('id');\n if (stepId) {\n let currentStepElement = '[aria-describedby=\"' + stepId + '-body\"]';\n $(currentStepElement).removeAttr('tabindex');\n $(currentStepElement).removeAttr('aria-describedby');\n }\n }\n\n // Reset the listeners.\n this.resetStepListeners();\n\n this.accessibilityHide();\n\n this.fireEventHandlers('afterHide');\n\n this.currentStepNode = null;\n this.currentStepPopper = null;\n return this;\n }\n\n /**\n * Show the current steps.\n *\n * @method show\n * @chainable\n * @return {Object} this.\n */\n show() {\n // Show the current step.\n let startAt = this.getCurrentStepNumber();\n\n return this.gotoStep(startAt);\n }\n\n /**\n * Return the current step node.\n *\n * @method getStepContainer\n * @return {jQuery}\n */\n getStepContainer() {\n return $(this.currentStepNode);\n }\n\n /**\n * Calculate scrollTop.\n *\n * @method calculateScrollTop\n * @param {Object} stepConfig The step configuration of the step\n * @return {Number}\n */\n calculateScrollTop(stepConfig) {\n let scrollTop = $(window).scrollTop();\n let viewportHeight = $(window).height();\n let targetNode = this.getStepTarget(stepConfig);\n\n if (stepConfig.placement === 'top') {\n // If the placement is top, center scroll at the top of the target.\n scrollTop = targetNode.offset().top - (viewportHeight / 2);\n } else if (stepConfig.placement === 'bottom') {\n // If the placement is bottom, center scroll at the bottom of the target.\n scrollTop = targetNode.offset().top + targetNode.height() - (viewportHeight / 2);\n } else if (targetNode.height() <= (viewportHeight * 0.8)) {\n // If the placement is left/right, and the target fits in the viewport, centre screen on the target\n scrollTop = targetNode.offset().top - ((viewportHeight - targetNode.height()) / 2);\n } else {\n // If the placement is left/right, and the target is bigger than the viewport, set scrollTop to target.top + buffer\n // and change step attachmentTarget to top+.\n scrollTop = targetNode.offset().top - (viewportHeight * 0.2);\n }\n\n // Never scroll over the top.\n scrollTop = Math.max(0, scrollTop);\n\n // Never scroll beyond the bottom.\n scrollTop = Math.min($(document).height() - viewportHeight, scrollTop);\n\n return Math.ceil(scrollTop);\n }\n\n /**\n * Calculate dialogue position for page middle.\n *\n * @method calculateScrollTop\n * @return {Number}\n */\n calculateStepPositionInPage() {\n let viewportHeight = $(window).height();\n let stepHeight = this.currentStepNode.height();\n\n let viewportWidth = $(window).width();\n let stepWidth = this.currentStepNode.width();\n\n return {\n top: Math.ceil((viewportHeight - stepHeight) / 2),\n left: Math.ceil((viewportWidth - stepWidth) / 2)\n };\n }\n\n /**\n * Position the step on the page.\n *\n * @method positionStep\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n positionStep(stepConfig) {\n let content = this.currentStepNode;\n if (!content || !content.length) {\n // Unable to find the step node.\n return this;\n }\n\n let flipBehavior;\n switch (stepConfig.placement) {\n case 'left':\n flipBehavior = ['left', 'right', 'top', 'bottom'];\n break;\n case 'right':\n flipBehavior = ['right', 'left', 'top', 'bottom'];\n break;\n case 'top':\n flipBehavior = ['top', 'bottom', 'right', 'left'];\n break;\n case 'bottom':\n flipBehavior = ['bottom', 'top', 'right', 'left'];\n break;\n default:\n flipBehavior = 'flip';\n break;\n }\n\n let target = this.getStepTarget(stepConfig);\n var config = {\n placement: stepConfig.placement + '-start',\n removeOnDestroy: true,\n modifiers: {\n flip: {\n behaviour: flipBehavior,\n },\n arrow: {\n element: '[data-role=\"arrow\"]',\n },\n },\n onCreate: function(data) {\n recalculateArrowPosition(data);\n },\n onUpdate: function(data) {\n recalculateArrowPosition(data);\n },\n };\n\n let recalculateArrowPosition = function(data) {\n let placement = data.placement.split('-')[0];\n const isVertical = ['left', 'right'].indexOf(placement) !== -1;\n const arrowElement = data.instance.popper.querySelector('[data-role=\"arrow\"]');\n const stepElement = $(data.instance.popper.querySelector('[data-role=\"flexitour-step\"]'));\n if (isVertical) {\n let arrowHeight = parseFloat(window.getComputedStyle(arrowElement).height);\n let arrowOffset = parseFloat(window.getComputedStyle(arrowElement).top);\n let popperHeight = parseFloat(window.getComputedStyle(data.instance.popper).height);\n let popperOffset = parseFloat(window.getComputedStyle(data.instance.popper).top);\n let popperBorderWidth = parseFloat(stepElement.css('borderTopWidth'));\n let popperBorderRadiusWidth = parseFloat(stepElement.css('borderTopLeftRadius')) * 2;\n let arrowPos = arrowOffset + (arrowHeight / 2);\n let maxPos = popperHeight + popperOffset - popperBorderWidth - popperBorderRadiusWidth;\n let minPos = popperOffset + popperBorderWidth + popperBorderRadiusWidth;\n if (arrowPos >= maxPos || arrowPos <= minPos) {\n let newArrowPos = 0;\n if (arrowPos > (popperHeight / 2)) {\n newArrowPos = maxPos - arrowHeight;\n } else {\n newArrowPos = minPos + arrowHeight;\n }\n $(arrowElement).css('top', newArrowPos);\n }\n } else {\n let arrowWidth = parseFloat(window.getComputedStyle(arrowElement).width);\n let arrowOffset = parseFloat(window.getComputedStyle(arrowElement).left);\n let popperWidth = parseFloat(window.getComputedStyle(data.instance.popper).width);\n let popperOffset = parseFloat(window.getComputedStyle(data.instance.popper).left);\n let popperBorderWidth = parseFloat(stepElement.css('borderTopWidth'));\n let popperBorderRadiusWidth = parseFloat(stepElement.css('borderTopLeftRadius')) * 2;\n let arrowPos = arrowOffset + (arrowWidth / 2);\n let maxPos = popperWidth + popperOffset - popperBorderWidth - popperBorderRadiusWidth;\n let minPos = popperOffset + popperBorderWidth + popperBorderRadiusWidth;\n if (arrowPos >= maxPos || arrowPos <= minPos) {\n let newArrowPos = 0;\n if (arrowPos > (popperWidth / 2)) {\n newArrowPos = maxPos - arrowWidth;\n } else {\n newArrowPos = minPos + arrowWidth;\n }\n $(arrowElement).css('left', newArrowPos);\n }\n }\n };\n\n let background = $('[data-flexitour=\"step-background\"]');\n if (background.length) {\n target = background;\n }\n this.currentStepPopper = new Popper(target, content[0], config);\n\n return this;\n }\n\n /**\n * Add the backdrop.\n *\n * @method positionBackdrop\n * @param {Object} stepConfig The step configuration of the step\n * @chainable\n * @return {Object} this.\n */\n positionBackdrop(stepConfig) {\n if (stepConfig.backdrop) {\n this.currentStepConfig.hasBackdrop = true;\n let backdrop = $('
');\n\n if (stepConfig.zIndex) {\n if (stepConfig.attachPoint === 'append') {\n stepConfig.attachTo.append(backdrop);\n } else {\n backdrop.insertAfter(stepConfig.attachTo);\n }\n } else {\n $('body').append(backdrop);\n }\n\n if (this.isStepActuallyVisible(stepConfig)) {\n // The step has a visible target.\n // Punch a hole through the backdrop.\n let background = $('
');\n\n let targetNode = this.getStepTarget(stepConfig);\n\n let buffer = 10;\n\n let colorNode = targetNode;\n if (buffer) {\n colorNode = $('body');\n }\n\n background.css({\n width: targetNode.outerWidth() + buffer + buffer,\n height: targetNode.outerHeight() + buffer + buffer,\n left: targetNode.offset().left - buffer,\n top: targetNode.offset().top - buffer,\n backgroundColor: this.calculateInherittedBackgroundColor(colorNode),\n });\n\n if (targetNode.offset().left < buffer) {\n background.css({\n width: targetNode.outerWidth() + targetNode.offset().left + buffer,\n left: targetNode.offset().left,\n });\n }\n\n if (targetNode.offset().top < buffer) {\n background.css({\n height: targetNode.outerHeight() + targetNode.offset().top + buffer,\n top: targetNode.offset().top,\n });\n }\n\n let targetRadius = targetNode.css('borderRadius');\n if (targetRadius && targetRadius !== $('body').css('borderRadius')) {\n background.css('borderRadius', targetRadius);\n }\n\n let targetPosition = this.calculatePosition(targetNode);\n if (targetPosition === 'fixed') {\n background.css('top', 0);\n } else if (targetPosition === 'absolute') {\n background.css('position', 'fixed');\n }\n\n let fader = background.clone();\n fader.css({\n backgroundColor: backdrop.css('backgroundColor'),\n opacity: backdrop.css('opacity'),\n });\n fader.attr('data-flexitour', 'step-background-fader');\n\n if (stepConfig.zIndex) {\n if (stepConfig.attachPoint === 'append') {\n stepConfig.attachTo.append(background);\n } else {\n fader.insertAfter(stepConfig.attachTo);\n background.insertAfter(stepConfig.attachTo);\n }\n } else {\n $('body').append(fader);\n $('body').append(background);\n }\n\n // Add the backdrop data to the actual target.\n // This is the part which actually does the work.\n targetNode.attr('data-flexitour', 'step-backdrop');\n\n if (stepConfig.zIndex) {\n backdrop.css('zIndex', stepConfig.zIndex);\n background.css('zIndex', stepConfig.zIndex + 1);\n targetNode.css('zIndex', stepConfig.zIndex + 2);\n }\n\n fader.fadeOut('2000', function() {\n $(this).remove();\n });\n }\n }\n return this;\n }\n\n /**\n * Calculate the inheritted z-index.\n *\n * @method calculateZIndex\n * @param {jQuery} elem The element to calculate z-index for\n * @return {Number} Calculated z-index\n */\n calculateZIndex(elem) {\n elem = $(elem);\n while (elem.length && elem[0] !== document) {\n // Ignore z-index if position is set to a value where z-index is ignored by the browser\n // This makes behavior of this function consistent across browsers\n // WebKit always returns auto if the element is positioned.\n let position = elem.css(\"position\");\n if (position === \"absolute\" || position === \"relative\" || position === \"fixed\") {\n // IE returns 0 when zIndex is not specified\n // other browsers return a string\n // we ignore the case of nested elements with an explicit value of 0\n //
\n let value = parseInt(elem.css(\"zIndex\"), 10);\n if (!isNaN(value) && value !== 0) {\n return value;\n }\n }\n elem = elem.parent();\n }\n\n return 0;\n }\n\n /**\n * Calculate the inheritted background colour.\n *\n * @method calculateInherittedBackgroundColor\n * @param {jQuery} elem The element to calculate colour for\n * @return {String} Calculated background colour\n */\n calculateInherittedBackgroundColor(elem) {\n // Use a fake node to compare each element against.\n let fakeNode = $('
').hide();\n $('body').append(fakeNode);\n let fakeElemColor = fakeNode.css('backgroundColor');\n fakeNode.remove();\n\n elem = $(elem);\n while (elem.length && elem[0] !== document) {\n let color = elem.css('backgroundColor');\n if (color !== fakeElemColor) {\n return color;\n }\n elem = elem.parent();\n }\n\n return null;\n }\n\n /**\n * Calculate the inheritted position.\n *\n * @method calculatePosition\n * @param {jQuery} elem The element to calculate position for\n * @return {String} Calculated position\n */\n calculatePosition(elem) {\n elem = $(elem);\n while (elem.length && elem[0] !== document) {\n let position = elem.css('position');\n if (position !== 'static') {\n return position;\n }\n elem = elem.parent();\n }\n\n return null;\n }\n\n /**\n * Perform accessibility changes for step shown.\n *\n * This will add aria-hidden=\"true\" to all siblings and parent siblings.\n *\n * @method accessibilityShow\n */\n accessibilityShow() {\n let stateHolder = 'data-has-hidden';\n let attrName = 'aria-hidden';\n let hideFunction = function(child) {\n let flexitourRole = child.data('flexitour');\n if (flexitourRole) {\n switch (flexitourRole) {\n case 'container':\n case 'target':\n return;\n }\n }\n\n let hidden = child.attr(attrName);\n if (!hidden) {\n child.attr(stateHolder, true);\n child.attr(attrName, true);\n }\n };\n\n this.currentStepNode.siblings().each(function(index, node) {\n hideFunction($(node));\n });\n this.currentStepNode.parentsUntil('body').siblings().each(function(index, node) {\n hideFunction($(node));\n });\n }\n\n /**\n * Perform accessibility changes for step hidden.\n *\n * This will remove any newly added aria-hidden=\"true\".\n *\n * @method accessibilityHide\n */\n accessibilityHide() {\n let stateHolder = 'data-has-hidden';\n let attrName = 'aria-hidden';\n let showFunction = function(child) {\n let hidden = child.attr(stateHolder);\n if (typeof hidden !== 'undefined') {\n child.removeAttr(stateHolder);\n child.removeAttr(attrName);\n }\n };\n\n $('[' + stateHolder + ']').each(function(index, node) {\n showFunction($(node));\n });\n }\n}\n"],"file":"tour.min.js"} \ No newline at end of file diff --git a/admin/tool/usertours/amd/src/tour.js b/admin/tool/usertours/amd/src/tour.js index 4a2fd901e45..393f546b7e7 100644 --- a/admin/tool/usertours/amd/src/tour.js +++ b/admin/tool/usertours/amd/src/tour.js @@ -594,7 +594,7 @@ export default class Tour { }); } - this.listeners.forEach(function (listener) { + this.listeners.forEach(function(listener) { listener.node.on.apply(listener.node, listener.args); }); diff --git a/blocks/myoverview/amd/build/view.min.js b/blocks/myoverview/amd/build/view.min.js index 7ee4ae4a7f9..8e18c999536 100644 --- a/blocks/myoverview/amd/build/view.min.js +++ b/blocks/myoverview/amd/build/view.min.js @@ -1,2 +1,2 @@ -define ("block_myoverview/view",["jquery","block_myoverview/repository","core/paged_content_factory","core/pubsub","core/custom_interaction_events","core/notification","core/templates","core_course/events","block_myoverview/selectors","core/paged_content_events"],function(a,b,c,d,e,f,g,h,i,j){var k={COURSE_REGION:"[data-region=\"course-view-content\"]",ACTION_HIDE_COURSE:"[data-action=\"hide-course\"]",ACTION_SHOW_COURSE:"[data-action=\"show-course\"]",ACTION_ADD_FAVOURITE:"[data-action=\"add-favourite\"]",ACTION_REMOVE_FAVOURITE:"[data-action=\"remove-favourite\"]",FAVOURITE_ICON:"[data-region=\"favourite-icon\"]",ICON_IS_FAVOURITE:"[data-region=\"is-favourite\"]",ICON_NOT_FAVOURITE:"[data-region=\"not-favourite\"]",PAGED_CONTENT_CONTAINER:"[data-region=\"page-container\"]"},l={COURSES_CARDS:"block_myoverview/view-cards",COURSES_LIST:"block_myoverview/view-list",COURSES_SUMMARY:"block_myoverview/view-summary",NOCOURSES:"core_course/no-courses"},m={GROUPING_ALLINCLUDINGHIDDEN:"allincludinghidden",GROUPING_ALL:"all",GROUPING_INPROGRESS:"inprogress",GROUPING_FUTURE:"future",GROUPING_PAST:"past",GROUPING_FAVOURITES:"favourites",GROUPING_HIDDEN:"hidden"},n=[12,24,48,96,0],o=[],p=0,q=0,r=0,s=null,t=function(a){var b=a.find(i.courseView.region);return{display:b.attr("data-display"),grouping:b.attr("data-grouping"),sort:b.attr("data-sort"),displaycategories:b.attr("data-displaycategories"),customfieldname:b.attr("data-customfieldname"),customfieldvalue:b.attr("data-customfieldvalue")}},u={ignoreControlWhileLoading:!0,controlPlacementBottom:!0,persistentLimitKey:"block_myoverview_user_paging_preference"},v=function(a,c){return b.getEnrolledCoursesByTimeline({offset:p,limit:c,classification:a.grouping,sort:a.sort,customfieldname:a.customfieldname,customfieldvalue:a.customfieldvalue})},w=function(a,b){return a.find(k.FAVOURITE_ICON+"[data-course-id=\""+b+"\"]")},x=function(a,b){return a.find("[data-region=\"paged-content-page\"][data-page=\""+b+"\"]")},y=function(a){return a.attr("data-course-id")},z=function(a,b){var c=w(a,b),d=c.find(k.ICON_IS_FAVOURITE);d.addClass("hidden");d.attr("aria-hidden",!0);var e=c.find(k.ICON_NOT_FAVOURITE);e.removeClass("hidden");e.attr("aria-hidden",!1)},A=function(a,b){var c=w(a,b),d=c.find(k.ICON_IS_FAVOURITE);d.removeClass("hidden");d.attr("aria-hidden",!1);var e=c.find(k.ICON_NOT_FAVOURITE);e.addClass("hidden");e.attr("aria-hidden",!0)},B=function(a,b){return a.find("[data-action=\"add-favourite\"][data-course-id=\""+b+"\"]")},C=function(a,b){return a.find("[data-action=\"remove-favourite\"][data-course-id=\""+b+"\"]")},D=function(a,b){var c=C(a,b),e=B(a,b);L(b,!0).then(function(g){if(g){d.publish(h.favourited,b);c.removeClass("hidden");e.addClass("hidden");A(a,b)}else{f.alert("Starring course failed","Could not change favourite state")}}).catch(f.exception)},E=function(a,b){var c=C(a,b),e=B(a,b);L(b,!1).then(function(g){if(g){d.publish(h.unfavorited,b);c.addClass("hidden");e.removeClass("hidden");z(a,b)}else{f.alert("Starring course failed","Could not change favourite state")}}).catch(f.exception)},F=function(a,b){return a.find("[data-action=\"hide-course\"][data-course-id=\""+b+"\"]")},G=function(a,b){return a.find("[data-action=\"show-course\"][data-course-id=\""+b+"\"]")},H=function(a,b){var c=F(a,b),d=G(a,b),e=t(a);J(b,!0);if(e.grouping!=m.GROUPING_ALLINCLUDINGHIDDEN){K(a,b)}c.addClass("hidden");d.removeClass("hidden")},I=function(a,b){var c=F(a,b),d=G(a,b),e=t(a);J(b,null);if(e.grouping!=m.GROUPING_ALLINCLUDINGHIDDEN){K(a,b)}c.removeClass("hidden");d.addClass("hidden")},J=function(a,c){if(!1===c){c=null}return b.updateUserPreferences({preferences:[{type:"block_myoverview_hidden_course_"+a,value:c}]})},K=function(b,d){var e=b.find("[data-region=\"paging-bar\"]"),h=parseInt(e.attr("data-active-page-number")),i=o[h],j=i.courses.reduce(function(a,b){if(d!=b.id){a.push(b)}return a},[]);if(o[h+1]!=void 0){var k=o[h+1].courses.slice(0,1);o.forEach(function(b,c){if(c>h){var d=[];if(o[c+1]!=void 0){d=o[c+1].courses.slice(0,1)}o[c].courses=a.merge(o[c].courses.slice(1),d)}});j=a.merge(j,k)}if(q==h+1&&0==o[h+1].courses.length){var l=b.find("[data-region=\"paged-content-container\"]");c.resetLastPageNumber(a(l).attr("id"),h)}o[h].courses=j;p--;var m=x(b,h);M(b,o[h]).then(function(a,b){return g.replaceNodeContents(m,a,b)}).catch(f.exception);o.forEach(function(a,c){if(c>h){var d=x(b,c);d.remove()}})},L=function(a,c){return b.setFavouriteCourses({courses:[{id:a,favourite:c}]}).then(function(b){if(0==b.warnings.length){o.forEach(function(b){b.courses.forEach(function(d,e){if(d.id==a){b.courses[e].isfavourite=c}})});return!0}else{return!1}}).catch(f.exception)},M=function(a,b){var c=t(a),d="";if("card"==c.display){d=l.COURSES_CARDS}else if("list"==c.display){d=l.COURSES_LIST}else{d=l.COURSES_SUMMARY}b.courses=b.courses.map(function(a){a.showcoursecategory="on"==c.displaycategories?!0:!1;return a});if(b.courses.length){return g.render(d,{courses:b.courses})}else{var e=a.find(i.courseView.region).attr("data-nocoursesimg");return g.render(l.NOCOURSES,{nocoursesimg:e})}},N=function(a){this.find(i.courseView.region).attr("data-paging",a)},O=function(a,b){var c=b+j.SET_ITEMS_PER_PAGE_LIMIT;d.subscribe(c,N.bind(a))},P=function(b){s="block_myoverview_"+b.attr("id")+"_"+Math.random();var d=parseInt(b.find(i.courseView.region).attr("data-paging"),10),e=n.map(function(a){var b=!1;if(a==d){b=!0}return{value:a,active:b}}),h=parseInt(b.find(i.courseView.region).attr("data-totalcoursecount"),10);if(h){e=e.filter(function(a){return a.valueh){var d=[];if(p[c+1]!=void 0){d=p[c+1].courses.slice(0,1)}p[c].courses=a.merge(p[c].courses.slice(1),d)}});j=a.merge(j,k)}if(r==h+1&&0==p[h+1].courses.length){var l=b.find("[data-region=\"paged-content-container\"]");c.resetLastPageNumber(a(l).attr("id"),h)}p[h].courses=j;q--;var m=y(b,h);N(b,p[h]).then(function(a,b){return g.replaceNodeContents(m,a,b)}).catch(f.exception);p.forEach(function(a,c){if(c>h){var d=y(b,c);d.remove()}})},M=function(a,c){return b.setFavouriteCourses({courses:[{id:a,favourite:c}]}).then(function(b){if(0==b.warnings.length){p.forEach(function(b){b.courses.forEach(function(d,e){if(d.id==a){b.courses[e].isfavourite=c}})});return!0}else{return!1}}).catch(f.exception)},N=function(a,b){var c=u(a),d="";if("card"==c.display){d=m.COURSES_CARDS}else if("list"==c.display){d=m.COURSES_LIST}else{d=m.COURSES_SUMMARY}b.courses=b.courses.map(function(a){a.showcoursecategory="on"==c.displaycategories?!0:!1;return a});if(b.courses.length){return g.render(d,{courses:b.courses})}else{var e=a.find(i.courseView.region).attr("data-nocoursesimg");return g.render(m.NOCOURSES,{nocoursesimg:e})}},O=function(a){this.find(i.courseView.region).attr("data-paging",a)},P=function(a,b){var c=b+j.SET_ITEMS_PER_PAGE_LIMIT;d.subscribe(c,O.bind(a))},Q=function(b){t="block_myoverview_"+b.attr("id")+"_"+Math.random();var d=parseInt(b.find(i.courseView.region).attr("data-paging"),10),e=o.map(function(a){var b=!1;if(a==d){b=!0}return{value:a,active:b}}),h=parseInt(b.find(i.courseView.region).attr("data-totalcoursecount"),10);if(h){e=e.filter(function(a){return a.value.\n\n/**\n * Manage the courses view for the overview block.\n *\n * @package block_myoverview\n * @copyright 2018 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(\n[\n 'jquery',\n 'block_myoverview/repository',\n 'core/paged_content_factory',\n 'core/pubsub',\n 'core/custom_interaction_events',\n 'core/notification',\n 'core/templates',\n 'core_course/events',\n 'block_myoverview/selectors',\n 'core/paged_content_events',\n],\nfunction(\n $,\n Repository,\n PagedContentFactory,\n PubSub,\n CustomEvents,\n Notification,\n Templates,\n CourseEvents,\n Selectors,\n PagedContentEvents\n) {\n\n var SELECTORS = {\n COURSE_REGION: '[data-region=\"course-view-content\"]',\n ACTION_HIDE_COURSE: '[data-action=\"hide-course\"]',\n ACTION_SHOW_COURSE: '[data-action=\"show-course\"]',\n ACTION_ADD_FAVOURITE: '[data-action=\"add-favourite\"]',\n ACTION_REMOVE_FAVOURITE: '[data-action=\"remove-favourite\"]',\n FAVOURITE_ICON: '[data-region=\"favourite-icon\"]',\n ICON_IS_FAVOURITE: '[data-region=\"is-favourite\"]',\n ICON_NOT_FAVOURITE: '[data-region=\"not-favourite\"]',\n PAGED_CONTENT_CONTAINER: '[data-region=\"page-container\"]'\n\n };\n\n var TEMPLATES = {\n COURSES_CARDS: 'block_myoverview/view-cards',\n COURSES_LIST: 'block_myoverview/view-list',\n COURSES_SUMMARY: 'block_myoverview/view-summary',\n NOCOURSES: 'core_course/no-courses'\n };\n\n var GROUPINGS = {\n GROUPING_ALLINCLUDINGHIDDEN: 'allincludinghidden',\n GROUPING_ALL: 'all',\n GROUPING_INPROGRESS: 'inprogress',\n GROUPING_FUTURE: 'future',\n GROUPING_PAST: 'past',\n GROUPING_FAVOURITES: 'favourites',\n GROUPING_HIDDEN: 'hidden'\n };\n\n var NUMCOURSES_PERPAGE = [12, 24, 48, 96, 0];\n\n var loadedPages = [];\n\n var courseOffset = 0;\n\n var lastPage = 0;\n\n var lastLimit = 0;\n\n var namespace = null;\n\n /**\n * Get filter values from DOM.\n *\n * @param {object} root The root element for the courses view.\n * @return {filters} Set filters.\n */\n var getFilterValues = function(root) {\n var courseRegion = root.find(Selectors.courseView.region);\n return {\n display: courseRegion.attr('data-display'),\n grouping: courseRegion.attr('data-grouping'),\n sort: courseRegion.attr('data-sort'),\n displaycategories: courseRegion.attr('data-displaycategories'),\n customfieldname: courseRegion.attr('data-customfieldname'),\n customfieldvalue: courseRegion.attr('data-customfieldvalue'),\n };\n };\n\n // We want the paged content controls below the paged content area.\n // and the controls should be ignored while data is loading.\n var DEFAULT_PAGED_CONTENT_CONFIG = {\n ignoreControlWhileLoading: true,\n controlPlacementBottom: true,\n persistentLimitKey: 'block_myoverview_user_paging_preference'\n };\n\n /**\n * Get enrolled courses from backend.\n *\n * @param {object} filters The filters for this view.\n * @param {int} limit The number of courses to show.\n * @return {promise} Resolved with an array of courses.\n */\n var getMyCourses = function(filters, limit) {\n\n return Repository.getEnrolledCoursesByTimeline({\n offset: courseOffset,\n limit: limit,\n classification: filters.grouping,\n sort: filters.sort,\n customfieldname: filters.customfieldname,\n customfieldvalue: filters.customfieldvalue\n });\n };\n\n /**\n * Get the container element for the favourite icon.\n *\n * @param {Object} root The course overview container\n * @param {Number} courseId Course id number\n * @return {Object} The favourite icon container\n */\n var getFavouriteIconContainer = function(root, courseId) {\n return root.find(SELECTORS.FAVOURITE_ICON + '[data-course-id=\"' + courseId + '\"]');\n };\n\n /**\n * Get the paged content container element.\n *\n * @param {Object} root The course overview container\n * @param {Number} index Rendered page index.\n * @return {Object} The rendered paged container.\n */\n var getPagedContentContainer = function(root, index) {\n return root.find('[data-region=\"paged-content-page\"][data-page=\"' + index + '\"]');\n };\n\n /**\n * Get the course id from a favourite element.\n *\n * @param {Object} root The favourite icon container element.\n * @return {Number} Course id.\n */\n var getCourseId = function(root) {\n return root.attr('data-course-id');\n };\n\n /**\n * Hide the favourite icon.\n *\n * @param {Object} root The favourite icon container element.\n * @param {Number} courseId Course id number.\n */\n var hideFavouriteIcon = function(root, courseId) {\n var iconContainer = getFavouriteIconContainer(root, courseId);\n var isFavouriteIcon = iconContainer.find(SELECTORS.ICON_IS_FAVOURITE);\n isFavouriteIcon.addClass('hidden');\n isFavouriteIcon.attr('aria-hidden', true);\n var notFavourteIcon = iconContainer.find(SELECTORS.ICON_NOT_FAVOURITE);\n notFavourteIcon.removeClass('hidden');\n notFavourteIcon.attr('aria-hidden', false);\n };\n\n /**\n * Show the favourite icon.\n *\n * @param {Object} root The course overview container.\n * @param {Number} courseId Course id number.\n */\n var showFavouriteIcon = function(root, courseId) {\n var iconContainer = getFavouriteIconContainer(root, courseId);\n var isFavouriteIcon = iconContainer.find(SELECTORS.ICON_IS_FAVOURITE);\n isFavouriteIcon.removeClass('hidden');\n isFavouriteIcon.attr('aria-hidden', false);\n var notFavourteIcon = iconContainer.find(SELECTORS.ICON_NOT_FAVOURITE);\n notFavourteIcon.addClass('hidden');\n notFavourteIcon.attr('aria-hidden', true);\n };\n\n /**\n * Get the action menu item\n *\n * @param {Object} root root The course overview container\n * @param {Number} courseId Course id.\n * @return {Object} The add to favourite menu item.\n */\n var getAddFavouriteMenuItem = function(root, courseId) {\n return root.find('[data-action=\"add-favourite\"][data-course-id=\"' + courseId + '\"]');\n };\n\n /**\n * Get the action menu item\n *\n * @param {Object} root root The course overview container\n * @param {Number} courseId Course id.\n * @return {Object} The remove from favourites menu item.\n */\n var getRemoveFavouriteMenuItem = function(root, courseId) {\n return root.find('[data-action=\"remove-favourite\"][data-course-id=\"' + courseId + '\"]');\n };\n\n /**\n * Add course to favourites\n *\n * @param {Object} root The course overview container\n * @param {Number} courseId Course id number\n */\n var addToFavourites = function(root, courseId) {\n var removeAction = getRemoveFavouriteMenuItem(root, courseId);\n var addAction = getAddFavouriteMenuItem(root, courseId);\n\n setCourseFavouriteState(courseId, true).then(function(success) {\n if (success) {\n PubSub.publish(CourseEvents.favourited, courseId);\n removeAction.removeClass('hidden');\n addAction.addClass('hidden');\n showFavouriteIcon(root, courseId);\n } else {\n Notification.alert('Starring course failed', 'Could not change favourite state');\n }\n return;\n }).catch(Notification.exception);\n };\n\n /**\n * Remove course from favourites\n *\n * @param {Object} root The course overview container\n * @param {Number} courseId Course id number\n */\n var removeFromFavourites = function(root, courseId) {\n var removeAction = getRemoveFavouriteMenuItem(root, courseId);\n var addAction = getAddFavouriteMenuItem(root, courseId);\n\n setCourseFavouriteState(courseId, false).then(function(success) {\n if (success) {\n PubSub.publish(CourseEvents.unfavorited, courseId);\n removeAction.addClass('hidden');\n addAction.removeClass('hidden');\n hideFavouriteIcon(root, courseId);\n } else {\n Notification.alert('Starring course failed', 'Could not change favourite state');\n }\n return;\n }).catch(Notification.exception);\n };\n\n /**\n * Get the action menu item\n *\n * @param {Object} root root The course overview container\n * @param {Number} courseId Course id.\n * @return {Object} The hide course menu item.\n */\n var getHideCourseMenuItem = function(root, courseId) {\n return root.find('[data-action=\"hide-course\"][data-course-id=\"' + courseId + '\"]');\n };\n\n /**\n * Get the action menu item\n *\n * @param {Object} root root The course overview container\n * @param {Number} courseId Course id.\n * @return {Object} The show course menu item.\n */\n var getShowCourseMenuItem = function(root, courseId) {\n return root.find('[data-action=\"show-course\"][data-course-id=\"' + courseId + '\"]');\n };\n\n /**\n * Hide course\n *\n * @param {Object} root The course overview container\n * @param {Number} courseId Course id number\n */\n var hideCourse = function(root, courseId) {\n var hideAction = getHideCourseMenuItem(root, courseId);\n var showAction = getShowCourseMenuItem(root, courseId);\n var filters = getFilterValues(root);\n\n setCourseHiddenState(courseId, true);\n\n // Remove the course from this view as it is now hidden and thus not covered by this view anymore.\n // Do only if we are not in \"All\" view mode where really all courses are shown.\n if (filters.grouping != GROUPINGS.GROUPING_ALLINCLUDINGHIDDEN) {\n hideElement(root, courseId);\n }\n\n hideAction.addClass('hidden');\n showAction.removeClass('hidden');\n };\n\n /**\n * Show course\n *\n * @param {Object} root The course overview container\n * @param {Number} courseId Course id number\n */\n var showCourse = function(root, courseId) {\n var hideAction = getHideCourseMenuItem(root, courseId);\n var showAction = getShowCourseMenuItem(root, courseId);\n var filters = getFilterValues(root);\n\n setCourseHiddenState(courseId, null);\n\n // Remove the course from this view as it is now shown again and thus not covered by this view anymore.\n // Do only if we are not in \"All\" view mode where really all courses are shown.\n if (filters.grouping != GROUPINGS.GROUPING_ALLINCLUDINGHIDDEN) {\n hideElement(root, courseId);\n }\n\n hideAction.removeClass('hidden');\n showAction.addClass('hidden');\n };\n\n /**\n * Set the courses hidden status and push to repository\n *\n * @param {Number} courseId Course id to favourite.\n * @param {Bool} status new hidden status.\n * @return {Promise} Repository promise.\n */\n var setCourseHiddenState = function(courseId, status) {\n\n // If the given status is not hidden, the preference has to be deleted with a null value.\n if (status === false) {\n status = null;\n }\n return Repository.updateUserPreferences({\n preferences: [\n {\n type: 'block_myoverview_hidden_course_' + courseId,\n value: status\n }\n ]\n });\n };\n\n /**\n * Reset the loadedPages dataset to take into account the hidden element\n *\n * @param {Object} root The course overview container\n * @param {Number} id The course id number\n */\n var hideElement = function(root, id) {\n var pagingBar = root.find('[data-region=\"paging-bar\"]');\n var jumpto = parseInt(pagingBar.attr('data-active-page-number'));\n\n // Get a reduced dataset for the current page.\n var courseList = loadedPages[jumpto];\n var reducedCourse = courseList.courses.reduce(function(accumulator, current) {\n if (id != current.id) {\n accumulator.push(current);\n }\n return accumulator;\n }, []);\n\n // Get the next page's data if loaded and pop the first element from it\n if (loadedPages[jumpto + 1] != undefined) {\n var newElement = loadedPages[jumpto + 1].courses.slice(0, 1);\n\n // Adjust the dataset for the reset of the pages that are loaded\n loadedPages.forEach(function(courseList, index) {\n if (index > jumpto) {\n var popElement = [];\n if (loadedPages[index + 1] != undefined) {\n popElement = loadedPages[index + 1].courses.slice(0, 1);\n }\n\n loadedPages[index].courses = $.merge(loadedPages[index].courses.slice(1), popElement);\n }\n });\n\n\n reducedCourse = $.merge(reducedCourse, newElement);\n }\n\n // Check if the next page is the last page and if it still has data associated to it\n if (lastPage == jumpto + 1 && loadedPages[jumpto + 1].courses.length == 0) {\n var pagedContentContainer = root.find('[data-region=\"paged-content-container\"]');\n PagedContentFactory.resetLastPageNumber($(pagedContentContainer).attr('id'), jumpto);\n }\n\n loadedPages[jumpto].courses = reducedCourse;\n\n // Reduce the course offset\n courseOffset--;\n\n // Render the paged content for the current\n var pagedContentPage = getPagedContentContainer(root, jumpto);\n renderCourses(root, loadedPages[jumpto]).then(function(html, js) {\n return Templates.replaceNodeContents(pagedContentPage, html, js);\n }).catch(Notification.exception);\n\n // Delete subsequent pages in order to trigger the callback\n loadedPages.forEach(function(courseList, index) {\n if (index > jumpto) {\n var page = getPagedContentContainer(root, index);\n page.remove();\n }\n });\n };\n\n /**\n * Set the courses favourite status and push to repository\n *\n * @param {Number} courseId Course id to favourite.\n * @param {Bool} status new favourite status.\n * @return {Promise} Repository promise.\n */\n var setCourseFavouriteState = function(courseId, status) {\n\n return Repository.setFavouriteCourses({\n courses: [\n {\n 'id': courseId,\n 'favourite': status\n }\n ]\n }).then(function(result) {\n if (result.warnings.length == 0) {\n loadedPages.forEach(function(courseList) {\n courseList.courses.forEach(function(course, index) {\n if (course.id == courseId) {\n courseList.courses[index].isfavourite = status;\n }\n });\n });\n return true;\n } else {\n return false;\n }\n }).catch(Notification.exception);\n };\n\n /**\n * Render the dashboard courses.\n *\n * @param {object} root The root element for the courses view.\n * @param {array} coursesData containing array of returned courses.\n * @return {promise} jQuery promise resolved after rendering is complete.\n */\n var renderCourses = function(root, coursesData) {\n\n var filters = getFilterValues(root);\n\n var currentTemplate = '';\n if (filters.display == 'card') {\n currentTemplate = TEMPLATES.COURSES_CARDS;\n } else if (filters.display == 'list') {\n currentTemplate = TEMPLATES.COURSES_LIST;\n } else {\n currentTemplate = TEMPLATES.COURSES_SUMMARY;\n }\n\n // Whether the course category should be displayed in the course item.\n coursesData.courses = coursesData.courses.map(function(course) {\n course.showcoursecategory = filters.displaycategories == 'on' ? true : false;\n return course;\n });\n\n if (coursesData.courses.length) {\n return Templates.render(currentTemplate, {\n courses: coursesData.courses,\n });\n } else {\n var nocoursesimg = root.find(Selectors.courseView.region).attr('data-nocoursesimg');\n return Templates.render(TEMPLATES.NOCOURSES, {\n nocoursesimg: nocoursesimg\n });\n }\n };\n\n /**\n * Return the callback to be passed to the subscribe event\n *\n * @param {Number} limit The paged limit that is passed through the event\n */\n var setLimit = function(limit) {\n this.find(Selectors.courseView.region).attr('data-paging', limit);\n };\n\n /**\n * Intialise the paged list and cards views on page load.\n * Returns an array of paged contents that we would like to handle here\n *\n * @param {object} root The root element for the courses view\n * @param {string} namespace The namespace for all the events attached\n */\n var registerPagedEventHandlers = function(root, namespace) {\n var event = namespace + PagedContentEvents.SET_ITEMS_PER_PAGE_LIMIT;\n PubSub.subscribe(event, setLimit.bind(root));\n };\n\n /**\n * Intialise the courses list and cards views on page load.\n *\n * @param {object} root The root element for the courses view.\n * @param {object} content The content element for the courses view.\n */\n var initializePagedContent = function(root) {\n namespace = \"block_myoverview_\" + root.attr('id') + \"_\" + Math.random();\n\n var pagingLimit = parseInt(root.find(Selectors.courseView.region).attr('data-paging'), 10);\n var itemsPerPage = NUMCOURSES_PERPAGE.map(function(value) {\n var active = false;\n if (value == pagingLimit) {\n active = true;\n }\n\n return {\n value: value,\n active: active\n };\n });\n\n // Filter out all pagination options which are too large for the amount of courses user is enrolled in.\n var totalCourseCount = parseInt(root.find(Selectors.courseView.region).attr('data-totalcoursecount'), 10);\n if (totalCourseCount) {\n itemsPerPage = itemsPerPage.filter(function(pagingOption) {\n return pagingOption.value < totalCourseCount;\n });\n }\n\n var filters = getFilterValues(root);\n var config = $.extend({}, DEFAULT_PAGED_CONTENT_CONFIG);\n config.eventNamespace = namespace;\n\n var pagedContentPromise = PagedContentFactory.createWithLimit(\n itemsPerPage,\n function(pagesData, actions) {\n var promises = [];\n\n pagesData.forEach(function(pageData) {\n var currentPage = pageData.pageNumber;\n var limit = (pageData.limit > 0) ? pageData.limit : 0;\n\n // Reset local variables if limits have changed\n if (lastLimit != limit) {\n loadedPages = [];\n courseOffset = 0;\n lastPage = 0;\n }\n\n if (lastPage == currentPage) {\n // If we are on the last page and have it's data then load it from cache\n actions.allItemsLoaded(lastPage);\n promises.push(renderCourses(root, loadedPages[currentPage]));\n return;\n }\n\n lastLimit = limit;\n\n // Get 2 pages worth of data as we will need it for the hidden functionality.\n if (loadedPages[currentPage + 1] == undefined) {\n if (loadedPages[currentPage] == undefined) {\n limit *= 2;\n }\n }\n\n var pagePromise = getMyCourses(\n filters,\n limit\n ).then(function(coursesData) {\n var courses = coursesData.courses;\n var nextPageStart = 0;\n var pageCourses = [];\n\n // If current page's data is loaded make sure we max it to page limit\n if (loadedPages[currentPage] != undefined) {\n pageCourses = loadedPages[currentPage].courses;\n var currentPageLength = pageCourses.length;\n if (currentPageLength < pageData.limit) {\n nextPageStart = pageData.limit - currentPageLength;\n pageCourses = $.merge(loadedPages[currentPage].courses, courses.slice(0, nextPageStart));\n }\n } else {\n nextPageStart = pageData.limit;\n pageCourses = (pageData.limit > 0) ? courses.slice(0, pageData.limit) : courses;\n }\n\n // Finished setting up the current page\n loadedPages[currentPage] = {\n courses: pageCourses\n };\n\n // Set up the next page\n var remainingCourses = nextPageStart ? courses.slice(nextPageStart, courses.length) : [];\n if (remainingCourses.length) {\n loadedPages[currentPage + 1] = {\n courses: remainingCourses\n };\n }\n\n // Set the last page to either the current or next page\n if (loadedPages[currentPage].courses.length < pageData.limit || !remainingCourses.length) {\n lastPage = currentPage;\n actions.allItemsLoaded(currentPage);\n } else if (loadedPages[currentPage + 1] != undefined\n && loadedPages[currentPage + 1].courses.length < pageData.limit) {\n lastPage = currentPage + 1;\n }\n\n courseOffset = coursesData.nextoffset;\n return renderCourses(root, loadedPages[currentPage]);\n })\n .catch(Notification.exception);\n\n promises.push(pagePromise);\n });\n\n return promises;\n },\n config\n );\n\n pagedContentPromise.then(function(html, js) {\n registerPagedEventHandlers(root, namespace);\n return Templates.replaceNodeContents(root.find(Selectors.courseView.region), html, js);\n }).catch(Notification.exception);\n };\n\n /**\n * Listen to, and handle events for the myoverview block.\n *\n * @param {Object} root The myoverview block container element.\n */\n var registerEventListeners = function(root) {\n CustomEvents.define(root, [\n CustomEvents.events.activate\n ]);\n\n root.on(CustomEvents.events.activate, SELECTORS.ACTION_ADD_FAVOURITE, function(e, data) {\n var favourite = $(e.target).closest(SELECTORS.ACTION_ADD_FAVOURITE);\n var courseId = getCourseId(favourite);\n addToFavourites(root, courseId);\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.activate, SELECTORS.ACTION_REMOVE_FAVOURITE, function(e, data) {\n var favourite = $(e.target).closest(SELECTORS.ACTION_REMOVE_FAVOURITE);\n var courseId = getCourseId(favourite);\n removeFromFavourites(root, courseId);\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.activate, SELECTORS.FAVOURITE_ICON, function(e, data) {\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.activate, SELECTORS.ACTION_HIDE_COURSE, function(e, data) {\n var target = $(e.target).closest(SELECTORS.ACTION_HIDE_COURSE);\n var courseId = getCourseId(target);\n hideCourse(root, courseId);\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.activate, SELECTORS.ACTION_SHOW_COURSE, function(e, data) {\n var target = $(e.target).closest(SELECTORS.ACTION_SHOW_COURSE);\n var courseId = getCourseId(target);\n showCourse(root, courseId);\n data.originalEvent.preventDefault();\n });\n };\n\n /**\n * Intialise the courses list and cards views on page load.\n *\n * @param {object} root The root element for the courses view.\n */\n var init = function(root) {\n root = $(root);\n loadedPages = [];\n lastPage = 0;\n courseOffset = 0;\n\n initializePagedContent(root);\n\n if (!root.attr('data-init')) {\n registerEventListeners(root);\n root.attr('data-init', true);\n }\n };\n\n /**\n\n * Reset the courses views to their original\n * state on first page load.courseOffset\n *\n * This is called when configuration has changed for the event lists\n * to cause them to reload their data.\n *\n * @param {Object} root The root element for the timeline view.\n */\n var reset = function(root) {\n if (loadedPages.length > 0) {\n loadedPages.forEach(function(courseList, index) {\n var pagedContentPage = getPagedContentContainer(root, index);\n renderCourses(root, courseList).then(function(html, js) {\n return Templates.replaceNodeContents(pagedContentPage, html, js);\n }).catch(Notification.exception);\n });\n } else {\n init(root);\n }\n };\n\n return {\n init: init,\n reset: reset\n };\n});\n"],"file":"view.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/view.js"],"names":["define","$","Repository","PagedContentFactory","PubSub","CustomEvents","Notification","Templates","CourseEvents","Selectors","PagedContentEvents","Aria","SELECTORS","COURSE_REGION","ACTION_HIDE_COURSE","ACTION_SHOW_COURSE","ACTION_ADD_FAVOURITE","ACTION_REMOVE_FAVOURITE","FAVOURITE_ICON","ICON_IS_FAVOURITE","ICON_NOT_FAVOURITE","PAGED_CONTENT_CONTAINER","TEMPLATES","COURSES_CARDS","COURSES_LIST","COURSES_SUMMARY","NOCOURSES","GROUPINGS","GROUPING_ALLINCLUDINGHIDDEN","GROUPING_ALL","GROUPING_INPROGRESS","GROUPING_FUTURE","GROUPING_PAST","GROUPING_FAVOURITES","GROUPING_HIDDEN","NUMCOURSES_PERPAGE","loadedPages","courseOffset","lastPage","lastLimit","namespace","getFilterValues","root","courseRegion","find","courseView","region","display","attr","grouping","sort","displaycategories","customfieldname","customfieldvalue","DEFAULT_PAGED_CONTENT_CONFIG","ignoreControlWhileLoading","controlPlacementBottom","persistentLimitKey","getMyCourses","filters","limit","getEnrolledCoursesByTimeline","offset","classification","getFavouriteIconContainer","courseId","getPagedContentContainer","index","getCourseId","hideFavouriteIcon","iconContainer","isFavouriteIcon","addClass","hide","notFavourteIcon","removeClass","unhide","showFavouriteIcon","getAddFavouriteMenuItem","getRemoveFavouriteMenuItem","addToFavourites","removeAction","addAction","setCourseFavouriteState","then","success","publish","favourited","alert","catch","exception","removeFromFavourites","unfavorited","getHideCourseMenuItem","getShowCourseMenuItem","hideCourse","hideAction","showAction","setCourseHiddenState","hideElement","showCourse","status","updateUserPreferences","preferences","type","value","id","pagingBar","jumpto","parseInt","courseList","reducedCourse","courses","reduce","accumulator","current","push","newElement","slice","forEach","popElement","merge","length","pagedContentContainer","resetLastPageNumber","pagedContentPage","renderCourses","html","js","replaceNodeContents","page","remove","setFavouriteCourses","result","warnings","course","isfavourite","coursesData","currentTemplate","map","showcoursecategory","render","nocoursesimg","setLimit","registerPagedEventHandlers","event","SET_ITEMS_PER_PAGE_LIMIT","subscribe","bind","initializePagedContent","Math","random","pagingLimit","itemsPerPage","active","totalCourseCount","filter","pagingOption","config","extend","eventNamespace","pagedContentPromise","createWithLimit","pagesData","actions","promises","pageData","currentPage","pageNumber","allItemsLoaded","pagePromise","nextPageStart","pageCourses","currentPageLength","remainingCourses","nextoffset","registerEventListeners","events","activate","on","e","data","favourite","target","closest","originalEvent","preventDefault","init","reset"],"mappings":"AAuBAA,OAAM,yBACN,CACI,QADJ,CAEI,6BAFJ,CAGI,4BAHJ,CAII,aAJJ,CAKI,gCALJ,CAMI,mBANJ,CAOI,gBAPJ,CAQI,oB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U,CAAC1D,CAAD,CAAOuB,CAAP,CAAV,CACAoH,CAAI,CAACI,aAAL,CAAmBC,cAAnB,EACH,CALD,CAMH,CAjoBH,CAwoBMC,CAAI,CAAG,SAASjJ,CAAT,CAAe,CACtBA,CAAI,CAAGzC,CAAC,CAACyC,CAAD,CAAR,CACAN,CAAW,CAAG,EAAd,CACAE,CAAQ,CAAG,CAAX,CACAD,CAAY,CAAG,CAAf,CAEAgH,CAAsB,CAAC3G,CAAD,CAAtB,CAEA,GAAI,CAACA,CAAI,CAACM,IAAL,CAAU,WAAV,CAAL,CAA6B,CACzBgI,CAAsB,CAACtI,CAAD,CAAtB,CACAA,CAAI,CAACM,IAAL,CAAU,WAAV,IACH,CACJ,CAppBH,CAgqBM4I,CAAK,CAAG,SAASlJ,CAAT,CAAe,CACvB,GAAyB,CAArB,CAAAN,CAAW,CAACsF,MAAhB,CAA4B,CACxBtF,CAAW,CAACmF,OAAZ,CAAoB,SAAST,CAAT,CAAqB3C,CAArB,CAA4B,CAC5C,GAAI0D,CAAAA,CAAgB,CAAG3D,CAAwB,CAACxB,CAAD,CAAOyB,CAAP,CAA/C,CACA2D,CAAa,CAACpF,CAAD,CAAOoE,CAAP,CAAb,CAAgC1B,IAAhC,CAAqC,SAAS2C,CAAT,CAAeC,CAAf,CAAmB,CACpD,MAAOzH,CAAAA,CAAS,CAAC0H,mBAAV,CAA8BJ,CAA9B,CAAgDE,CAAhD,CAAsDC,CAAtD,CACV,CAFD,EAEGvC,KAFH,CAESnF,CAAY,CAACoF,SAFtB,CAGH,CALD,CAMH,CAPD,IAOO,CACHiG,CAAI,CAACjJ,CAAD,CACP,CACJ,CA3qBH,CA6qBE,MAAO,CACHiJ,IAAI,CAAEA,CADH,CAEHC,KAAK,CAAEA,CAFJ,CAIV,CA3sBK,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 .\n\n/**\n * Manage the courses view for the overview block.\n *\n * @package block_myoverview\n * @copyright 2018 Bas Brands \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(\n[\n 'jquery',\n 'block_myoverview/repository',\n 'core/paged_content_factory',\n 'core/pubsub',\n 'core/custom_interaction_events',\n 'core/notification',\n 'core/templates',\n 'core_course/events',\n 'block_myoverview/selectors',\n 'core/paged_content_events',\n 'core/aria',\n],\nfunction(\n $,\n Repository,\n PagedContentFactory,\n PubSub,\n CustomEvents,\n Notification,\n Templates,\n CourseEvents,\n Selectors,\n PagedContentEvents,\n Aria\n) {\n\n var SELECTORS = {\n COURSE_REGION: '[data-region=\"course-view-content\"]',\n ACTION_HIDE_COURSE: '[data-action=\"hide-course\"]',\n ACTION_SHOW_COURSE: '[data-action=\"show-course\"]',\n ACTION_ADD_FAVOURITE: '[data-action=\"add-favourite\"]',\n ACTION_REMOVE_FAVOURITE: '[data-action=\"remove-favourite\"]',\n FAVOURITE_ICON: '[data-region=\"favourite-icon\"]',\n ICON_IS_FAVOURITE: '[data-region=\"is-favourite\"]',\n ICON_NOT_FAVOURITE: '[data-region=\"not-favourite\"]',\n PAGED_CONTENT_CONTAINER: '[data-region=\"page-container\"]'\n\n };\n\n var TEMPLATES = {\n COURSES_CARDS: 'block_myoverview/view-cards',\n COURSES_LIST: 'block_myoverview/view-list',\n COURSES_SUMMARY: 'block_myoverview/view-summary',\n NOCOURSES: 'core_course/no-courses'\n };\n\n var GROUPINGS = {\n GROUPING_ALLINCLUDINGHIDDEN: 'allincludinghidden',\n GROUPING_ALL: 'all',\n GROUPING_INPROGRESS: 'inprogress',\n GROUPING_FUTURE: 'future',\n GROUPING_PAST: 'past',\n GROUPING_FAVOURITES: 'favourites',\n GROUPING_HIDDEN: 'hidden'\n };\n\n var NUMCOURSES_PERPAGE = [12, 24, 48, 96, 0];\n\n var loadedPages = [];\n\n var courseOffset = 0;\n\n var lastPage = 0;\n\n var lastLimit = 0;\n\n var namespace = null;\n\n /**\n * Get filter values from DOM.\n *\n * @param {object} root The root element for the courses view.\n * @return {filters} Set filters.\n */\n var getFilterValues = function(root) {\n var courseRegion = root.find(Selectors.courseView.region);\n return {\n display: courseRegion.attr('data-display'),\n grouping: courseRegion.attr('data-grouping'),\n sort: courseRegion.attr('data-sort'),\n displaycategories: courseRegion.attr('data-displaycategories'),\n customfieldname: courseRegion.attr('data-customfieldname'),\n customfieldvalue: courseRegion.attr('data-customfieldvalue'),\n };\n };\n\n // We want the paged content controls below the paged content area.\n // and the controls should be ignored while data is loading.\n var DEFAULT_PAGED_CONTENT_CONFIG = {\n ignoreControlWhileLoading: true,\n controlPlacementBottom: true,\n persistentLimitKey: 'block_myoverview_user_paging_preference'\n };\n\n /**\n * Get enrolled courses from backend.\n *\n * @param {object} filters The filters for this view.\n * @param {int} limit The number of courses to show.\n * @return {promise} Resolved with an array of courses.\n */\n var getMyCourses = function(filters, limit) {\n\n return Repository.getEnrolledCoursesByTimeline({\n offset: courseOffset,\n limit: limit,\n classification: filters.grouping,\n sort: filters.sort,\n customfieldname: filters.customfieldname,\n customfieldvalue: filters.customfieldvalue\n });\n };\n\n /**\n * Get the container element for the favourite icon.\n *\n * @param {Object} root The course overview container\n * @param {Number} courseId Course id number\n * @return {Object} The favourite icon container\n */\n var getFavouriteIconContainer = function(root, courseId) {\n return root.find(SELECTORS.FAVOURITE_ICON + '[data-course-id=\"' + courseId + '\"]');\n };\n\n /**\n * Get the paged content container element.\n *\n * @param {Object} root The course overview container\n * @param {Number} index Rendered page index.\n * @return {Object} The rendered paged container.\n */\n var getPagedContentContainer = function(root, index) {\n return root.find('[data-region=\"paged-content-page\"][data-page=\"' + index + '\"]');\n };\n\n /**\n * Get the course id from a favourite element.\n *\n * @param {Object} root The favourite icon container element.\n * @return {Number} Course id.\n */\n var getCourseId = function(root) {\n return root.attr('data-course-id');\n };\n\n /**\n * Hide the favourite icon.\n *\n * @param {Object} root The favourite icon container element.\n * @param {Number} courseId Course id number.\n */\n var hideFavouriteIcon = function(root, courseId) {\n var iconContainer = getFavouriteIconContainer(root, courseId);\n\n var isFavouriteIcon = iconContainer.find(SELECTORS.ICON_IS_FAVOURITE);\n isFavouriteIcon.addClass('hidden');\n Aria.hide(isFavouriteIcon);\n\n var notFavourteIcon = iconContainer.find(SELECTORS.ICON_NOT_FAVOURITE);\n notFavourteIcon.removeClass('hidden');\n Aria.unhide(notFavourteIcon);\n };\n\n /**\n * Show the favourite icon.\n *\n * @param {Object} root The course overview container.\n * @param {Number} courseId Course id number.\n */\n var showFavouriteIcon = function(root, courseId) {\n var iconContainer = getFavouriteIconContainer(root, courseId);\n\n var isFavouriteIcon = iconContainer.find(SELECTORS.ICON_IS_FAVOURITE);\n isFavouriteIcon.removeClass('hidden');\n Aria.unhide(isFavouriteIcon);\n\n var notFavourteIcon = iconContainer.find(SELECTORS.ICON_NOT_FAVOURITE);\n notFavourteIcon.addClass('hidden');\n Aria.hide(notFavourteIcon);\n };\n\n /**\n * Get the action menu item\n *\n * @param {Object} root root The course overview container\n * @param {Number} courseId Course id.\n * @return {Object} The add to favourite menu item.\n */\n var getAddFavouriteMenuItem = function(root, courseId) {\n return root.find('[data-action=\"add-favourite\"][data-course-id=\"' + courseId + '\"]');\n };\n\n /**\n * Get the action menu item\n *\n * @param {Object} root root The course overview container\n * @param {Number} courseId Course id.\n * @return {Object} The remove from favourites menu item.\n */\n var getRemoveFavouriteMenuItem = function(root, courseId) {\n return root.find('[data-action=\"remove-favourite\"][data-course-id=\"' + courseId + '\"]');\n };\n\n /**\n * Add course to favourites\n *\n * @param {Object} root The course overview container\n * @param {Number} courseId Course id number\n */\n var addToFavourites = function(root, courseId) {\n var removeAction = getRemoveFavouriteMenuItem(root, courseId);\n var addAction = getAddFavouriteMenuItem(root, courseId);\n\n setCourseFavouriteState(courseId, true).then(function(success) {\n if (success) {\n PubSub.publish(CourseEvents.favourited, courseId);\n removeAction.removeClass('hidden');\n addAction.addClass('hidden');\n showFavouriteIcon(root, courseId);\n } else {\n Notification.alert('Starring course failed', 'Could not change favourite state');\n }\n return;\n }).catch(Notification.exception);\n };\n\n /**\n * Remove course from favourites\n *\n * @param {Object} root The course overview container\n * @param {Number} courseId Course id number\n */\n var removeFromFavourites = function(root, courseId) {\n var removeAction = getRemoveFavouriteMenuItem(root, courseId);\n var addAction = getAddFavouriteMenuItem(root, courseId);\n\n setCourseFavouriteState(courseId, false).then(function(success) {\n if (success) {\n PubSub.publish(CourseEvents.unfavorited, courseId);\n removeAction.addClass('hidden');\n addAction.removeClass('hidden');\n hideFavouriteIcon(root, courseId);\n } else {\n Notification.alert('Starring course failed', 'Could not change favourite state');\n }\n return;\n }).catch(Notification.exception);\n };\n\n /**\n * Get the action menu item\n *\n * @param {Object} root root The course overview container\n * @param {Number} courseId Course id.\n * @return {Object} The hide course menu item.\n */\n var getHideCourseMenuItem = function(root, courseId) {\n return root.find('[data-action=\"hide-course\"][data-course-id=\"' + courseId + '\"]');\n };\n\n /**\n * Get the action menu item\n *\n * @param {Object} root root The course overview container\n * @param {Number} courseId Course id.\n * @return {Object} The show course menu item.\n */\n var getShowCourseMenuItem = function(root, courseId) {\n return root.find('[data-action=\"show-course\"][data-course-id=\"' + courseId + '\"]');\n };\n\n /**\n * Hide course\n *\n * @param {Object} root The course overview container\n * @param {Number} courseId Course id number\n */\n var hideCourse = function(root, courseId) {\n var hideAction = getHideCourseMenuItem(root, courseId);\n var showAction = getShowCourseMenuItem(root, courseId);\n var filters = getFilterValues(root);\n\n setCourseHiddenState(courseId, true);\n\n // Remove the course from this view as it is now hidden and thus not covered by this view anymore.\n // Do only if we are not in \"All\" view mode where really all courses are shown.\n if (filters.grouping != GROUPINGS.GROUPING_ALLINCLUDINGHIDDEN) {\n hideElement(root, courseId);\n }\n\n hideAction.addClass('hidden');\n showAction.removeClass('hidden');\n };\n\n /**\n * Show course\n *\n * @param {Object} root The course overview container\n * @param {Number} courseId Course id number\n */\n var showCourse = function(root, courseId) {\n var hideAction = getHideCourseMenuItem(root, courseId);\n var showAction = getShowCourseMenuItem(root, courseId);\n var filters = getFilterValues(root);\n\n setCourseHiddenState(courseId, null);\n\n // Remove the course from this view as it is now shown again and thus not covered by this view anymore.\n // Do only if we are not in \"All\" view mode where really all courses are shown.\n if (filters.grouping != GROUPINGS.GROUPING_ALLINCLUDINGHIDDEN) {\n hideElement(root, courseId);\n }\n\n hideAction.removeClass('hidden');\n showAction.addClass('hidden');\n };\n\n /**\n * Set the courses hidden status and push to repository\n *\n * @param {Number} courseId Course id to favourite.\n * @param {Bool} status new hidden status.\n * @return {Promise} Repository promise.\n */\n var setCourseHiddenState = function(courseId, status) {\n\n // If the given status is not hidden, the preference has to be deleted with a null value.\n if (status === false) {\n status = null;\n }\n return Repository.updateUserPreferences({\n preferences: [\n {\n type: 'block_myoverview_hidden_course_' + courseId,\n value: status\n }\n ]\n });\n };\n\n /**\n * Reset the loadedPages dataset to take into account the hidden element\n *\n * @param {Object} root The course overview container\n * @param {Number} id The course id number\n */\n var hideElement = function(root, id) {\n var pagingBar = root.find('[data-region=\"paging-bar\"]');\n var jumpto = parseInt(pagingBar.attr('data-active-page-number'));\n\n // Get a reduced dataset for the current page.\n var courseList = loadedPages[jumpto];\n var reducedCourse = courseList.courses.reduce(function(accumulator, current) {\n if (id != current.id) {\n accumulator.push(current);\n }\n return accumulator;\n }, []);\n\n // Get the next page's data if loaded and pop the first element from it\n if (loadedPages[jumpto + 1] != undefined) {\n var newElement = loadedPages[jumpto + 1].courses.slice(0, 1);\n\n // Adjust the dataset for the reset of the pages that are loaded\n loadedPages.forEach(function(courseList, index) {\n if (index > jumpto) {\n var popElement = [];\n if (loadedPages[index + 1] != undefined) {\n popElement = loadedPages[index + 1].courses.slice(0, 1);\n }\n\n loadedPages[index].courses = $.merge(loadedPages[index].courses.slice(1), popElement);\n }\n });\n\n\n reducedCourse = $.merge(reducedCourse, newElement);\n }\n\n // Check if the next page is the last page and if it still has data associated to it\n if (lastPage == jumpto + 1 && loadedPages[jumpto + 1].courses.length == 0) {\n var pagedContentContainer = root.find('[data-region=\"paged-content-container\"]');\n PagedContentFactory.resetLastPageNumber($(pagedContentContainer).attr('id'), jumpto);\n }\n\n loadedPages[jumpto].courses = reducedCourse;\n\n // Reduce the course offset\n courseOffset--;\n\n // Render the paged content for the current\n var pagedContentPage = getPagedContentContainer(root, jumpto);\n renderCourses(root, loadedPages[jumpto]).then(function(html, js) {\n return Templates.replaceNodeContents(pagedContentPage, html, js);\n }).catch(Notification.exception);\n\n // Delete subsequent pages in order to trigger the callback\n loadedPages.forEach(function(courseList, index) {\n if (index > jumpto) {\n var page = getPagedContentContainer(root, index);\n page.remove();\n }\n });\n };\n\n /**\n * Set the courses favourite status and push to repository\n *\n * @param {Number} courseId Course id to favourite.\n * @param {Bool} status new favourite status.\n * @return {Promise} Repository promise.\n */\n var setCourseFavouriteState = function(courseId, status) {\n\n return Repository.setFavouriteCourses({\n courses: [\n {\n 'id': courseId,\n 'favourite': status\n }\n ]\n }).then(function(result) {\n if (result.warnings.length == 0) {\n loadedPages.forEach(function(courseList) {\n courseList.courses.forEach(function(course, index) {\n if (course.id == courseId) {\n courseList.courses[index].isfavourite = status;\n }\n });\n });\n return true;\n } else {\n return false;\n }\n }).catch(Notification.exception);\n };\n\n /**\n * Render the dashboard courses.\n *\n * @param {object} root The root element for the courses view.\n * @param {array} coursesData containing array of returned courses.\n * @return {promise} jQuery promise resolved after rendering is complete.\n */\n var renderCourses = function(root, coursesData) {\n\n var filters = getFilterValues(root);\n\n var currentTemplate = '';\n if (filters.display == 'card') {\n currentTemplate = TEMPLATES.COURSES_CARDS;\n } else if (filters.display == 'list') {\n currentTemplate = TEMPLATES.COURSES_LIST;\n } else {\n currentTemplate = TEMPLATES.COURSES_SUMMARY;\n }\n\n // Whether the course category should be displayed in the course item.\n coursesData.courses = coursesData.courses.map(function(course) {\n course.showcoursecategory = filters.displaycategories == 'on' ? true : false;\n return course;\n });\n\n if (coursesData.courses.length) {\n return Templates.render(currentTemplate, {\n courses: coursesData.courses,\n });\n } else {\n var nocoursesimg = root.find(Selectors.courseView.region).attr('data-nocoursesimg');\n return Templates.render(TEMPLATES.NOCOURSES, {\n nocoursesimg: nocoursesimg\n });\n }\n };\n\n /**\n * Return the callback to be passed to the subscribe event\n *\n * @param {Number} limit The paged limit that is passed through the event\n */\n var setLimit = function(limit) {\n this.find(Selectors.courseView.region).attr('data-paging', limit);\n };\n\n /**\n * Intialise the paged list and cards views on page load.\n * Returns an array of paged contents that we would like to handle here\n *\n * @param {object} root The root element for the courses view\n * @param {string} namespace The namespace for all the events attached\n */\n var registerPagedEventHandlers = function(root, namespace) {\n var event = namespace + PagedContentEvents.SET_ITEMS_PER_PAGE_LIMIT;\n PubSub.subscribe(event, setLimit.bind(root));\n };\n\n /**\n * Intialise the courses list and cards views on page load.\n *\n * @param {object} root The root element for the courses view.\n * @param {object} content The content element for the courses view.\n */\n var initializePagedContent = function(root) {\n namespace = \"block_myoverview_\" + root.attr('id') + \"_\" + Math.random();\n\n var pagingLimit = parseInt(root.find(Selectors.courseView.region).attr('data-paging'), 10);\n var itemsPerPage = NUMCOURSES_PERPAGE.map(function(value) {\n var active = false;\n if (value == pagingLimit) {\n active = true;\n }\n\n return {\n value: value,\n active: active\n };\n });\n\n // Filter out all pagination options which are too large for the amount of courses user is enrolled in.\n var totalCourseCount = parseInt(root.find(Selectors.courseView.region).attr('data-totalcoursecount'), 10);\n if (totalCourseCount) {\n itemsPerPage = itemsPerPage.filter(function(pagingOption) {\n return pagingOption.value < totalCourseCount;\n });\n }\n\n var filters = getFilterValues(root);\n var config = $.extend({}, DEFAULT_PAGED_CONTENT_CONFIG);\n config.eventNamespace = namespace;\n\n var pagedContentPromise = PagedContentFactory.createWithLimit(\n itemsPerPage,\n function(pagesData, actions) {\n var promises = [];\n\n pagesData.forEach(function(pageData) {\n var currentPage = pageData.pageNumber;\n var limit = (pageData.limit > 0) ? pageData.limit : 0;\n\n // Reset local variables if limits have changed\n if (lastLimit != limit) {\n loadedPages = [];\n courseOffset = 0;\n lastPage = 0;\n }\n\n if (lastPage == currentPage) {\n // If we are on the last page and have it's data then load it from cache\n actions.allItemsLoaded(lastPage);\n promises.push(renderCourses(root, loadedPages[currentPage]));\n return;\n }\n\n lastLimit = limit;\n\n // Get 2 pages worth of data as we will need it for the hidden functionality.\n if (loadedPages[currentPage + 1] == undefined) {\n if (loadedPages[currentPage] == undefined) {\n limit *= 2;\n }\n }\n\n var pagePromise = getMyCourses(\n filters,\n limit\n ).then(function(coursesData) {\n var courses = coursesData.courses;\n var nextPageStart = 0;\n var pageCourses = [];\n\n // If current page's data is loaded make sure we max it to page limit\n if (loadedPages[currentPage] != undefined) {\n pageCourses = loadedPages[currentPage].courses;\n var currentPageLength = pageCourses.length;\n if (currentPageLength < pageData.limit) {\n nextPageStart = pageData.limit - currentPageLength;\n pageCourses = $.merge(loadedPages[currentPage].courses, courses.slice(0, nextPageStart));\n }\n } else {\n nextPageStart = pageData.limit;\n pageCourses = (pageData.limit > 0) ? courses.slice(0, pageData.limit) : courses;\n }\n\n // Finished setting up the current page\n loadedPages[currentPage] = {\n courses: pageCourses\n };\n\n // Set up the next page\n var remainingCourses = nextPageStart ? courses.slice(nextPageStart, courses.length) : [];\n if (remainingCourses.length) {\n loadedPages[currentPage + 1] = {\n courses: remainingCourses\n };\n }\n\n // Set the last page to either the current or next page\n if (loadedPages[currentPage].courses.length < pageData.limit || !remainingCourses.length) {\n lastPage = currentPage;\n actions.allItemsLoaded(currentPage);\n } else if (loadedPages[currentPage + 1] != undefined\n && loadedPages[currentPage + 1].courses.length < pageData.limit) {\n lastPage = currentPage + 1;\n }\n\n courseOffset = coursesData.nextoffset;\n return renderCourses(root, loadedPages[currentPage]);\n })\n .catch(Notification.exception);\n\n promises.push(pagePromise);\n });\n\n return promises;\n },\n config\n );\n\n pagedContentPromise.then(function(html, js) {\n registerPagedEventHandlers(root, namespace);\n return Templates.replaceNodeContents(root.find(Selectors.courseView.region), html, js);\n }).catch(Notification.exception);\n };\n\n /**\n * Listen to, and handle events for the myoverview block.\n *\n * @param {Object} root The myoverview block container element.\n */\n var registerEventListeners = function(root) {\n CustomEvents.define(root, [\n CustomEvents.events.activate\n ]);\n\n root.on(CustomEvents.events.activate, SELECTORS.ACTION_ADD_FAVOURITE, function(e, data) {\n var favourite = $(e.target).closest(SELECTORS.ACTION_ADD_FAVOURITE);\n var courseId = getCourseId(favourite);\n addToFavourites(root, courseId);\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.activate, SELECTORS.ACTION_REMOVE_FAVOURITE, function(e, data) {\n var favourite = $(e.target).closest(SELECTORS.ACTION_REMOVE_FAVOURITE);\n var courseId = getCourseId(favourite);\n removeFromFavourites(root, courseId);\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.activate, SELECTORS.FAVOURITE_ICON, function(e, data) {\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.activate, SELECTORS.ACTION_HIDE_COURSE, function(e, data) {\n var target = $(e.target).closest(SELECTORS.ACTION_HIDE_COURSE);\n var courseId = getCourseId(target);\n hideCourse(root, courseId);\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.activate, SELECTORS.ACTION_SHOW_COURSE, function(e, data) {\n var target = $(e.target).closest(SELECTORS.ACTION_SHOW_COURSE);\n var courseId = getCourseId(target);\n showCourse(root, courseId);\n data.originalEvent.preventDefault();\n });\n };\n\n /**\n * Intialise the courses list and cards views on page load.\n *\n * @param {object} root The root element for the courses view.\n */\n var init = function(root) {\n root = $(root);\n loadedPages = [];\n lastPage = 0;\n courseOffset = 0;\n\n initializePagedContent(root);\n\n if (!root.attr('data-init')) {\n registerEventListeners(root);\n root.attr('data-init', true);\n }\n };\n\n /**\n\n * Reset the courses views to their original\n * state on first page load.courseOffset\n *\n * This is called when configuration has changed for the event lists\n * to cause them to reload their data.\n *\n * @param {Object} root The root element for the timeline view.\n */\n var reset = function(root) {\n if (loadedPages.length > 0) {\n loadedPages.forEach(function(courseList, index) {\n var pagedContentPage = getPagedContentContainer(root, index);\n renderCourses(root, courseList).then(function(html, js) {\n return Templates.replaceNodeContents(pagedContentPage, html, js);\n }).catch(Notification.exception);\n });\n } else {\n init(root);\n }\n };\n\n return {\n init: init,\n reset: reset\n };\n});\n"],"file":"view.min.js"} \ No newline at end of file diff --git a/blocks/myoverview/amd/src/view.js b/blocks/myoverview/amd/src/view.js index 9d637b74412..524c4baea93 100644 --- a/blocks/myoverview/amd/src/view.js +++ b/blocks/myoverview/amd/src/view.js @@ -33,6 +33,7 @@ define( 'core_course/events', 'block_myoverview/selectors', 'core/paged_content_events', + 'core/aria', ], function( $, @@ -44,7 +45,8 @@ function( Templates, CourseEvents, Selectors, - PagedContentEvents + PagedContentEvents, + Aria ) { var SELECTORS = { @@ -174,12 +176,14 @@ function( */ var hideFavouriteIcon = function(root, courseId) { var iconContainer = getFavouriteIconContainer(root, courseId); + var isFavouriteIcon = iconContainer.find(SELECTORS.ICON_IS_FAVOURITE); isFavouriteIcon.addClass('hidden'); - isFavouriteIcon.attr('aria-hidden', true); + Aria.hide(isFavouriteIcon); + var notFavourteIcon = iconContainer.find(SELECTORS.ICON_NOT_FAVOURITE); notFavourteIcon.removeClass('hidden'); - notFavourteIcon.attr('aria-hidden', false); + Aria.unhide(notFavourteIcon); }; /** @@ -190,12 +194,14 @@ function( */ var showFavouriteIcon = function(root, courseId) { var iconContainer = getFavouriteIconContainer(root, courseId); + var isFavouriteIcon = iconContainer.find(SELECTORS.ICON_IS_FAVOURITE); isFavouriteIcon.removeClass('hidden'); - isFavouriteIcon.attr('aria-hidden', false); + Aria.unhide(isFavouriteIcon); + var notFavourteIcon = iconContainer.find(SELECTORS.ICON_NOT_FAVOURITE); notFavourteIcon.addClass('hidden'); - notFavourteIcon.attr('aria-hidden', true); + Aria.hide(notFavourteIcon); }; /** diff --git a/blocks/navigation/amd/build/ajax_response_renderer.min.js b/blocks/navigation/amd/build/ajax_response_renderer.min.js index dead3b8467a..7be3a49539b 100644 --- a/blocks/navigation/amd/build/ajax_response_renderer.min.js +++ b/blocks/navigation/amd/build/ajax_response_renderer.min.js @@ -1,2 +1,2 @@ -function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("block_navigation/ajax_response_renderer",["jquery","core/templates","core/notification","core/url"],function(a,b,c,d){var f={ACTIVITY:40,RESOURCE:50};function e(g,h){var i=a("
    ");i.attr("role","group");i.attr("aria-hidden",!0);a.each(h,function(g,h){if("object"!==_typeof(h)){return}var j=a("
  • "),k=a("

    "),l=h.id||h.key+"_tree_item",m=null,n=h.expandable||h.haschildren?!0:!1;k.addClass("tree_item");k.attr("id",l);k.attr("role","treeitem");k.attr("tabindex","-1");if(h.requiresajaxloading){k.attr("data-requires-ajax",!0);k.attr("data-node-id",h.id);k.attr("data-node-key",h.key);k.attr("data-node-type",h.type)}if(n){j.addClass("collapsed contains_branch");k.attr("aria-expanded",!1);k.addClass("branch")}var o=null;if(h.link){var p=a("");o=p;p.append(""+h.name+"");if(h.hidden){p.addClass("dimmed")}k.append(p)}else{var q=a("");o=q;q.append(""+h.name+"");if(h.hidden){q.addClass("dimmed")}k.append(q)}if(h.icon&&(!n||h.type===f.ACTIVITY||h.type===f.RESOURCE)){j.addClass("item_with_icon");k.addClass("hasicon");if(h.type===f.ACTIVITY||h.type===f.RESOURCE){m=a("");m.attr("alt",h.icon.alt);m.attr("title",h.icon.title);m.attr("src",d.imageUrl(h.icon.pix,h.icon.component));a.each(h.icon.classes,function(a,b){m.addClass(b)});o.prepend(m)}else{if("moodle"==h.icon.component){h.icon.component="core"}b.renderPix(h.icon.pix,h.icon.component,h.icon.title).then(function(a){o.prepend(a)}).catch(c.exception)}}j.append(k);i.append(j);if(h.children&&h.children.length){e(k,h.children)}else if(n&&!h.requiresajaxloading){j.removeClass("contains_branch");k.addClass("emptybranch")}});g.parent().append(i);var j=g.attr("id")+"_group";i.attr("id",j);g.attr("aria-owns",j);g.attr("role","treeitem")}return{render:function render(a,b){if(b.children&&b.children.length){e(a,b.children);var c=a.children("[role='treeitem']").first(),d=a.find("#"+c.attr("aria-owns"));c.attr("aria-expanded",!0);d.attr("aria-hidden",!1)}else{if(a.parent().hasClass("contains_branch")){a.parent().removeClass("contains_branch");a.addClass("emptybranch")}}}}}); +function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("block_navigation/ajax_response_renderer",["jquery","core/templates","core/notification","core/url","core/aria"],function(a,b,c,d,e){var g={ACTIVITY:40,RESOURCE:50};function f(h,i){var j=a("
      ");j.attr("role","group");e.hide(j);a.each(i,function(e,h){if("object"!==_typeof(h)){return}var i=a("
    • "),k=a("

      "),l=h.id||h.key+"_tree_item",m=null,n=h.expandable||h.haschildren?!0:!1;k.addClass("tree_item");k.attr("id",l);k.attr("role","treeitem");k.attr("tabindex","-1");if(h.requiresajaxloading){k.attr("data-requires-ajax",!0);k.attr("data-node-id",h.id);k.attr("data-node-key",h.key);k.attr("data-node-type",h.type)}if(n){i.addClass("collapsed contains_branch");k.attr("aria-expanded",!1);k.addClass("branch")}var o=null;if(h.link){var p=a("");o=p;p.append(""+h.name+"");if(h.hidden){p.addClass("dimmed")}k.append(p)}else{var q=a("");o=q;q.append(""+h.name+"");if(h.hidden){q.addClass("dimmed")}k.append(q)}if(h.icon&&(!n||h.type===g.ACTIVITY||h.type===g.RESOURCE)){i.addClass("item_with_icon");k.addClass("hasicon");if(h.type===g.ACTIVITY||h.type===g.RESOURCE){m=a("");m.attr("alt",h.icon.alt);m.attr("title",h.icon.title);m.attr("src",d.imageUrl(h.icon.pix,h.icon.component));a.each(h.icon.classes,function(a,b){m.addClass(b)});o.prepend(m)}else{if("moodle"==h.icon.component){h.icon.component="core"}b.renderPix(h.icon.pix,h.icon.component,h.icon.title).then(function(a){o.prepend(a)}).catch(c.exception)}}i.append(k);j.append(i);if(h.children&&h.children.length){f(k,h.children)}else if(n&&!h.requiresajaxloading){i.removeClass("contains_branch");k.addClass("emptybranch")}});h.parent().append(j);var k=h.attr("id")+"_group";j.attr("id",k);h.attr("aria-owns",k);h.attr("role","treeitem")}return{render:function render(a,b){if(b.children&&b.children.length){f(a,b.children);var c=a.children("[role='treeitem']").first(),d=a.find("#"+c.attr("aria-owns"));c.attr("aria-expanded",!0);e.unhide(d)}else{if(a.parent().hasClass("contains_branch")){a.parent().removeClass("contains_branch");a.addClass("emptybranch")}}}}}); //# sourceMappingURL=ajax_response_renderer.min.js.map diff --git a/blocks/navigation/amd/build/ajax_response_renderer.min.js.map b/blocks/navigation/amd/build/ajax_response_renderer.min.js.map index 2bc32031d93..c729061b495 100644 --- a/blocks/navigation/amd/build/ajax_response_renderer.min.js.map +++ b/blocks/navigation/amd/build/ajax_response_renderer.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/ajax_response_renderer.js"],"names":["define","$","Templates","Notification","Url","NODETYPE","ACTIVITY","RESOURCE","buildDOM","rootElement","nodes","ul","attr","each","index","node","li","p","id","key","icon","isBranch","expandable","haschildren","addClass","requiresajaxloading","type","eleToAddIcon","link","title","append","name","hidden","span","alt","imageUrl","pix","component","classes","className","prepend","renderPix","then","html","catch","exception","children","length","removeClass","parent","render","element","item","first","group","find","hasClass"],"mappings":"mSAwBAA,OAAM,2CAAC,CAAC,QAAD,CAAW,gBAAX,CAA6B,m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CAjBE,CAmBV,CA5IK,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 .\n\n/**\n * Parse the response from the navblock ajax page and render the correct DOM\n * structure for the tree from it.\n *\n * @module block_navigation/ajax_response_renderer\n * @package core\n * @copyright 2015 John Okely \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/templates', 'core/notification', 'core/url'], function($, Templates, Notification, Url) {\n\n // Mappings for the different types of nodes coming from the navigation.\n // Copied from lib/navigationlib.php navigation_node constants.\n var NODETYPE = {\n // @type int Activity (course module) = 40.\n ACTIVITY: 40,\n // @type int Resource (course module = 50.\n RESOURCE: 50,\n };\n\n /**\n * Build DOM.\n *\n * @method buildDOM\n * @param {Object} rootElement the root element of DOM.\n * @param {object} nodes jquery object representing the nodes to be build.\n */\n function buildDOM(rootElement, nodes) {\n var ul = $('
        ');\n ul.attr('role', 'group');\n ul.attr('aria-hidden', true);\n\n $.each(nodes, function(index, node) {\n if (typeof node !== 'object') {\n return;\n }\n\n var li = $('
      • ');\n var p = $('

        ');\n var id = node.id || node.key + '_tree_item';\n var icon = null;\n var isBranch = (node.expandable || node.haschildren) ? true : false;\n\n p.addClass('tree_item');\n p.attr('id', id);\n p.attr('role', 'treeitem');\n // Negative tab index to allow it to receive focus.\n p.attr('tabindex', '-1');\n\n if (node.requiresajaxloading) {\n p.attr('data-requires-ajax', true);\n p.attr('data-node-id', node.id);\n p.attr('data-node-key', node.key);\n p.attr('data-node-type', node.type);\n }\n\n if (isBranch) {\n li.addClass('collapsed contains_branch');\n p.attr('aria-expanded', false);\n p.addClass('branch');\n }\n\n var eleToAddIcon = null;\n if (node.link) {\n var link = $('');\n\n eleToAddIcon = link;\n link.append('' + node.name + '');\n\n if (node.hidden) {\n link.addClass('dimmed');\n }\n\n p.append(link);\n } else {\n var span = $('');\n\n eleToAddIcon = span;\n span.append('' + node.name + '');\n\n if (node.hidden) {\n span.addClass('dimmed');\n }\n\n p.append(span);\n }\n\n if (node.icon && (!isBranch || node.type === NODETYPE.ACTIVITY || node.type === NODETYPE.RESOURCE)) {\n li.addClass('item_with_icon');\n p.addClass('hasicon');\n\n if (node.type === NODETYPE.ACTIVITY || node.type === NODETYPE.RESOURCE) {\n icon = $('');\n icon.attr('alt', node.icon.alt);\n icon.attr('title', node.icon.title);\n icon.attr('src', Url.imageUrl(node.icon.pix, node.icon.component));\n $.each(node.icon.classes, function(index, className) {\n icon.addClass(className);\n });\n eleToAddIcon.prepend(icon);\n } else {\n if (node.icon.component == 'moodle') {\n node.icon.component = 'core';\n }\n Templates.renderPix(node.icon.pix, node.icon.component, node.icon.title).then(function(html) {\n // Prepend.\n eleToAddIcon.prepend(html);\n return;\n }).catch(Notification.exception);\n }\n }\n\n li.append(p);\n ul.append(li);\n\n if (node.children && node.children.length) {\n buildDOM(p, node.children);\n } else if (isBranch && !node.requiresajaxloading) {\n li.removeClass('contains_branch');\n p.addClass('emptybranch');\n }\n });\n\n rootElement.parent().append(ul);\n var id = rootElement.attr('id') + '_group';\n ul.attr('id', id);\n rootElement.attr('aria-owns', id);\n rootElement.attr('role', 'treeitem');\n }\n\n return {\n render: function(element, nodes) {\n // The first element of the response is the existing node so we start with processing the children.\n if (nodes.children && nodes.children.length) {\n buildDOM(element, nodes.children);\n\n var item = element.children(\"[role='treeitem']\").first();\n var group = element.find('#' + item.attr('aria-owns'));\n\n item.attr('aria-expanded', true);\n group.attr('aria-hidden', false);\n } else {\n if (element.parent().hasClass('contains_branch')) {\n element.parent().removeClass('contains_branch');\n element.addClass('emptybranch');\n }\n }\n }\n };\n});\n"],"file":"ajax_response_renderer.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/ajax_response_renderer.js"],"names":["define","$","Templates","Notification","Url","Aria","NODETYPE","ACTIVITY","RESOURCE","buildDOM","rootElement","nodes","ul","attr","hide","each","index","node","li","p","id","key","icon","isBranch","expandable","haschildren","addClass","requiresajaxloading","type","eleToAddIcon","link","title","append","name","hidden","span","alt","imageUrl","pix","component","classes","className","prepend","renderPix","then","html","catch","exception","children","length","removeClass","parent","render","element","item","first","group","find","unhide","hasClass"],"mappings":"mSAwBAA,OAAM,2CAAC,CACH,QADG,CAEH,gBAFG,CAGH,mBAHG,CAIH,UAJG,CAKH,WALG,CAAD,CAMH,SACCC,CADD,CAECC,CAFD,CAGCC,CAHD,CAICC,CAJD,CAKCC,CALD,CAMD,CAIE,GAAIC,CAAAA,CAAQ,CAAG,CAEXC,QAAQ,CAAE,EAFC,CAIXC,QAAQ,CAAE,EAJC,CAAf,CAcA,QAASC,CAAAA,CAAT,CAAkBC,CAAlB,CAA+BC,CAA/B,CAAsC,CAClC,GAAIC,CAAAA,CAAE,CAAGX,CAAC,CAAC,WAAD,CAAV,CACAW,CAAE,CAACC,IAAH,CAAQ,MAAR,CAAgB,OAAhB,EACAR,CAAI,CAACS,IAAL,CAAUF,CAAV,EAEAX,CAAC,CAACc,IAAF,CAAOJ,CAAP,CAAc,SAASK,CAAT,CAAgBC,CAAhB,CAAsB,CAChC,GAAoB,QAAhB,WAAOA,CAAP,CAAJ,CAA8B,CAC1B,MACH,CAH+B,GAK5BC,CAAAA,CAAE,CAAGjB,CAAC,CAAC,WAAD,CALsB,CAM5BkB,CAAC,CAAGlB,CAAC,CAAC,SAAD,CANuB,CAO5BmB,CAAE,CAAGH,CAAI,CAACG,EAAL,EAAWH,CAAI,CAACI,GAAL,CAAW,YAPC,CAQ5BC,CAAI,CAAG,IARqB,CAS5BC,CAAQ,CAAIN,CAAI,CAACO,UAAL,EAAmBP,CAAI,CAACQ,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CO,KAAtC,EAH8B,CAIrCC,CAAK,CAAGH,CAAO,CAACI,IAAR,CAAa,IAAMH,CAAI,CAACzC,IAAL,CAAU,WAAV,CAAnB,CAJ6B,CAMzCyC,CAAI,CAACzC,IAAL,CAAU,eAAV,KACAR,CAAI,CAACqD,MAAL,CAAYF,CAAZ,CACH,CARD,IAQO,CACH,GAAIH,CAAO,CAACF,MAAR,GAAiBQ,QAAjB,CAA0B,iBAA1B,CAAJ,CAAkD,CAC9CN,CAAO,CAACF,MAAR,GAAiBD,WAAjB,CAA6B,iBAA7B,EACAG,CAAO,CAAC3B,QAAR,CAAiB,aAAjB,CACH,CACJ,CACJ,CAjBE,CAmBV,CAxJK,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 .\n\n/**\n * Parse the response from the navblock ajax page and render the correct DOM\n * structure for the tree from it.\n *\n * @module block_navigation/ajax_response_renderer\n * @package core\n * @copyright 2015 John Okely \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/templates',\n 'core/notification',\n 'core/url',\n 'core/aria',\n], function(\n $,\n Templates,\n Notification,\n Url,\n Aria\n) {\n\n // Mappings for the different types of nodes coming from the navigation.\n // Copied from lib/navigationlib.php navigation_node constants.\n var NODETYPE = {\n // @type int Activity (course module) = 40.\n ACTIVITY: 40,\n // @type int Resource (course module = 50.\n RESOURCE: 50,\n };\n\n /**\n * Build DOM.\n *\n * @method buildDOM\n * @param {Object} rootElement the root element of DOM.\n * @param {object} nodes jquery object representing the nodes to be build.\n */\n function buildDOM(rootElement, nodes) {\n var ul = $('
          ');\n ul.attr('role', 'group');\n Aria.hide(ul);\n\n $.each(nodes, function(index, node) {\n if (typeof node !== 'object') {\n return;\n }\n\n var li = $('
        • ');\n var p = $('

          ');\n var id = node.id || node.key + '_tree_item';\n var icon = null;\n var isBranch = (node.expandable || node.haschildren) ? true : false;\n\n p.addClass('tree_item');\n p.attr('id', id);\n p.attr('role', 'treeitem');\n // Negative tab index to allow it to receive focus.\n p.attr('tabindex', '-1');\n\n if (node.requiresajaxloading) {\n p.attr('data-requires-ajax', true);\n p.attr('data-node-id', node.id);\n p.attr('data-node-key', node.key);\n p.attr('data-node-type', node.type);\n }\n\n if (isBranch) {\n li.addClass('collapsed contains_branch');\n p.attr('aria-expanded', false);\n p.addClass('branch');\n }\n\n var eleToAddIcon = null;\n if (node.link) {\n var link = $('');\n\n eleToAddIcon = link;\n link.append('' + node.name + '');\n\n if (node.hidden) {\n link.addClass('dimmed');\n }\n\n p.append(link);\n } else {\n var span = $('');\n\n eleToAddIcon = span;\n span.append('' + node.name + '');\n\n if (node.hidden) {\n span.addClass('dimmed');\n }\n\n p.append(span);\n }\n\n if (node.icon && (!isBranch || node.type === NODETYPE.ACTIVITY || node.type === NODETYPE.RESOURCE)) {\n li.addClass('item_with_icon');\n p.addClass('hasicon');\n\n if (node.type === NODETYPE.ACTIVITY || node.type === NODETYPE.RESOURCE) {\n icon = $('');\n icon.attr('alt', node.icon.alt);\n icon.attr('title', node.icon.title);\n icon.attr('src', Url.imageUrl(node.icon.pix, node.icon.component));\n $.each(node.icon.classes, function(index, className) {\n icon.addClass(className);\n });\n eleToAddIcon.prepend(icon);\n } else {\n if (node.icon.component == 'moodle') {\n node.icon.component = 'core';\n }\n Templates.renderPix(node.icon.pix, node.icon.component, node.icon.title).then(function(html) {\n // Prepend.\n eleToAddIcon.prepend(html);\n return;\n }).catch(Notification.exception);\n }\n }\n\n li.append(p);\n ul.append(li);\n\n if (node.children && node.children.length) {\n buildDOM(p, node.children);\n } else if (isBranch && !node.requiresajaxloading) {\n li.removeClass('contains_branch');\n p.addClass('emptybranch');\n }\n });\n\n rootElement.parent().append(ul);\n var id = rootElement.attr('id') + '_group';\n ul.attr('id', id);\n rootElement.attr('aria-owns', id);\n rootElement.attr('role', 'treeitem');\n }\n\n return {\n render: function(element, nodes) {\n // The first element of the response is the existing node so we start with processing the children.\n if (nodes.children && nodes.children.length) {\n buildDOM(element, nodes.children);\n\n var item = element.children(\"[role='treeitem']\").first();\n var group = element.find('#' + item.attr('aria-owns'));\n\n item.attr('aria-expanded', true);\n Aria.unhide(group);\n } else {\n if (element.parent().hasClass('contains_branch')) {\n element.parent().removeClass('contains_branch');\n element.addClass('emptybranch');\n }\n }\n }\n };\n});\n"],"file":"ajax_response_renderer.min.js"} \ No newline at end of file diff --git a/blocks/navigation/amd/src/ajax_response_renderer.js b/blocks/navigation/amd/src/ajax_response_renderer.js index 99f2e28f1fe..e92ed463bee 100644 --- a/blocks/navigation/amd/src/ajax_response_renderer.js +++ b/blocks/navigation/amd/src/ajax_response_renderer.js @@ -22,7 +22,19 @@ * @copyright 2015 John Okely * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -define(['jquery', 'core/templates', 'core/notification', 'core/url'], function($, Templates, Notification, Url) { +define([ + 'jquery', + 'core/templates', + 'core/notification', + 'core/url', + 'core/aria', +], function( + $, + Templates, + Notification, + Url, + Aria +) { // Mappings for the different types of nodes coming from the navigation. // Copied from lib/navigationlib.php navigation_node constants. @@ -43,7 +55,7 @@ define(['jquery', 'core/templates', 'core/notification', 'core/url'], function($ function buildDOM(rootElement, nodes) { var ul = $('
            '); ul.attr('role', 'group'); - ul.attr('aria-hidden', true); + Aria.hide(ul); $.each(nodes, function(index, node) { if (typeof node !== 'object') { @@ -153,7 +165,7 @@ define(['jquery', 'core/templates', 'core/notification', 'core/url'], function($ var group = element.find('#' + item.attr('aria-owns')); item.attr('aria-expanded', true); - group.attr('aria-hidden', false); + Aria.unhide(group); } else { if (element.parent().hasClass('contains_branch')) { element.parent().removeClass('contains_branch'); diff --git a/blocks/recentlyaccessedcourses/amd/build/main.min.js b/blocks/recentlyaccessedcourses/amd/build/main.min.js index 4d8e69fd15a..54f17c88ade 100644 --- a/blocks/recentlyaccessedcourses/amd/build/main.min.js +++ b/blocks/recentlyaccessedcourses/amd/build/main.min.js @@ -1,2 +1,2 @@ -define ("block_recentlyaccessedcourses/main",["jquery","core/custom_interaction_events","core/notification","core/pubsub","core/paged_content_paging_bar","core/templates","core_course/events","core_course/repository"],function(a,b,c,d,e,f,g,h){var i={BLOCK_CONTAINER:"[data-region=\"recentlyaccessedcourses\"]",CARD_CONTAINER:"[data-region=\"card-deck\"]",COURSE_IS_FAVOURITE:"[data-region=\"is-favourite\"]",CONTENT:"[data-region=\"view-content\"]",EMPTY_MESSAGE:"[data-region=\"empty-message\"]",LOADING_PLACEHOLDER:"[data-region=\"loading-placeholder\"]",PAGING_BAR:"[data-region=\"paging-bar\"]",PAGING_BAR_NEXT:"[data-control=\"next\"]",PAGING_BAR_PREVIOUS:"[data-control=\"previous\"]"},j=!1,k=[],l=null,m=null,n=0,o=1,p=function(a){a.find(i.EMPTY_MESSAGE).removeClass("hidden");a.find(i.LOADING_PLACEHOLDER).addClass("hidden");a.find(i.CONTENT).addClass("hidden")},q=function(a){a.find(i.CONTENT).removeClass("hidden");a.find(i.EMPTY_MESSAGE).addClass("hidden");a.find(i.LOADING_PLACEHOLDER).addClass("hidden")},r=function(a){var b=a.find(i.PAGING_BAR);b.css("opacity",1);b.css("visibility","visible");b.attr("aria-hidden","false")},s=function(a){var b=a.find(i.PAGING_BAR);b.css("opacity",0);b.css("visibility","hidden");b.attr("aria-hidden","true")},t=function(a,b){k.forEach(function(a){if(a.attr("data-course-id")==b){a.find(i.COURSE_IS_FAVOURITE).removeClass("hidden")}})},u=function(a,b){k.forEach(function(a){if(a.attr("data-course-id")==b){a.find(i.COURSE_IS_FAVOURITE).addClass("hidden")}})},v=function(b){var d=a(i.BLOCK_CONTAINER).data("displaycoursecategory"),e=b.map(function(a){a.showcoursecategory=d;return f.render("block_recentlyaccessedcourses/course-card",a)});return a.when.apply(null,e).then(function(){var b=[];e.forEach(function(d){d.then(function(c){b.push(a(c))}).catch(c.exception)});return b})},w=function(a){return h.getLastAccessedCourses(a,10).then(function(a){return v(a)})},x=function(a){var b=a.find(i.CONTENT).find(i.CARD_CONTAINER),c=parseFloat(a.css("width")),d=k.length,f=0;if(!m){b.html(k[0]);m=k[0].outerWidth(!0)}o=Math.floor(c/m);if(n+oh.length){b.addClass("justify-content-center");b.removeClass("justify-content-start")}else{b.removeClass("justify-content-center");b.addClass("justify-content-start")}if(l!=j){var p=a.find(e.rootSelector);b.html(h);l=j;if(o>=k.length){s(a)}else{r(a);if(0===n){e.disablePreviousControlButtons(p)}else{e.enablePreviousControlButtons(p)}if(n+o>=k.length){e.disableNextControlButtons(p)}else{e.enableNextControlButtons(p)}}}},y=function(c){var e=null,f=!1;d.subscribe(g.favourited,function(a){t(c,a)});d.subscribe(g.unfavorited,function(a){u(c,a)});d.subscribe("nav-drawer-toggle-start",function(){if(!j||!k.length||f){return}f=!0;var a=0,b=function(){setTimeout(function(){x(c);a++;if(5>a&&f){b()}},100)};b(c)});d.subscribe("nav-drawer-toggle-end",function(){f=!1});a(window).on("resize",function(){if(!j||!k.length){return}if(!e){e=setTimeout(function(){e=null;x(c)},66)}});b.define(c,[b.events.activate]);c.on(b.events.activate,i.PAGING_BAR_NEXT,function(b,d){var e=a(b.target).closest(i.PAGING_BAR_NEXT);if(!e.hasClass("disabled")){n=n+o;x(c)}d.originalEvent.preventDefault()});c.on(b.events.activate,i.PAGING_BAR_PREVIOUS,function(b,d){var e=a(b.target).closest(i.PAGING_BAR_PREVIOUS);if(!e.hasClass("disabled")){n=n-o;n=0>n?0:n;x(c)}d.originalEvent.preventDefault()})};return{init:function init(b,d){d=a(d);y(d);w(b).then(function(a){k=a;j=!0;if(k.length){q(d);x(d)}else{p(d)}}).catch(c.exception)}}}); +define ("block_recentlyaccessedcourses/main",["jquery","core/custom_interaction_events","core/notification","core/pubsub","core/paged_content_paging_bar","core/templates","core_course/events","core_course/repository","core/aria"],function(a,b,c,d,e,f,g,h,i){var j={BLOCK_CONTAINER:"[data-region=\"recentlyaccessedcourses\"]",CARD_CONTAINER:"[data-region=\"card-deck\"]",COURSE_IS_FAVOURITE:"[data-region=\"is-favourite\"]",CONTENT:"[data-region=\"view-content\"]",EMPTY_MESSAGE:"[data-region=\"empty-message\"]",LOADING_PLACEHOLDER:"[data-region=\"loading-placeholder\"]",PAGING_BAR:"[data-region=\"paging-bar\"]",PAGING_BAR_NEXT:"[data-control=\"next\"]",PAGING_BAR_PREVIOUS:"[data-control=\"previous\"]"},k=!1,l=[],m=null,n=null,o=0,p=1,q=function(a){a.find(j.EMPTY_MESSAGE).removeClass("hidden");a.find(j.LOADING_PLACEHOLDER).addClass("hidden");a.find(j.CONTENT).addClass("hidden")},r=function(a){a.find(j.CONTENT).removeClass("hidden");a.find(j.EMPTY_MESSAGE).addClass("hidden");a.find(j.LOADING_PLACEHOLDER).addClass("hidden")},s=function(a){var b=a.find(j.PAGING_BAR);b.css("opacity",1);b.css("visibility","visible");i.unhide(b)},t=function(a){var b=a.find(j.PAGING_BAR);b.css("opacity",0);b.css("visibility","hidden");i.hide(b)},u=function(a,b){l.forEach(function(a){if(a.attr("data-course-id")==b){a.find(j.COURSE_IS_FAVOURITE).removeClass("hidden")}})},v=function(a,b){l.forEach(function(a){if(a.attr("data-course-id")==b){a.find(j.COURSE_IS_FAVOURITE).addClass("hidden")}})},w=function(b){var d=a(j.BLOCK_CONTAINER).data("displaycoursecategory"),e=b.map(function(a){a.showcoursecategory=d;return f.render("block_recentlyaccessedcourses/course-card",a)});return a.when.apply(null,e).then(function(){var b=[];e.forEach(function(d){d.then(function(c){b.push(a(c))}).catch(c.exception)});return b})},x=function(a){return h.getLastAccessedCourses(a,10).then(function(a){return w(a)})},y=function(a){var b=a.find(j.CONTENT).find(j.CARD_CONTAINER),c=parseFloat(a.css("width")),d=l.length,f=0;if(!n){b.html(l[0]);n=l[0].outerWidth(!0)}p=Math.floor(c/n);if(o+ph.length){b.addClass("justify-content-center");b.removeClass("justify-content-start")}else{b.removeClass("justify-content-center");b.addClass("justify-content-start")}if(m!=i){var k=a.find(e.rootSelector);b.html(h);m=i;if(p>=l.length){t(a)}else{s(a);if(0===o){e.disablePreviousControlButtons(k)}else{e.enablePreviousControlButtons(k)}if(o+p>=l.length){e.disableNextControlButtons(k)}else{e.enableNextControlButtons(k)}}}},z=function(c){var e=null,f=!1;d.subscribe(g.favourited,function(a){u(c,a)});d.subscribe(g.unfavorited,function(a){v(c,a)});d.subscribe("nav-drawer-toggle-start",function(){if(!k||!l.length||f){return}f=!0;var a=0,b=function(){setTimeout(function(){y(c);a++;if(5>a&&f){b()}},100)};b(c)});d.subscribe("nav-drawer-toggle-end",function(){f=!1});a(window).on("resize",function(){if(!k||!l.length){return}if(!e){e=setTimeout(function(){e=null;y(c)},66)}});b.define(c,[b.events.activate]);c.on(b.events.activate,j.PAGING_BAR_NEXT,function(b,d){var e=a(b.target).closest(j.PAGING_BAR_NEXT);if(!e.hasClass("disabled")){o=o+p;y(c)}d.originalEvent.preventDefault()});c.on(b.events.activate,j.PAGING_BAR_PREVIOUS,function(b,d){var e=a(b.target).closest(j.PAGING_BAR_PREVIOUS);if(!e.hasClass("disabled")){o=o-p;o=0>o?0:o;y(c)}d.originalEvent.preventDefault()})};return{init:function init(b,d){d=a(d);z(d);x(b).then(function(a){l=a;k=!0;if(l.length){r(d);y(d)}else{q(d)}}).catch(c.exception)}}}); //# sourceMappingURL=main.min.js.map diff --git a/blocks/recentlyaccessedcourses/amd/build/main.min.js.map b/blocks/recentlyaccessedcourses/amd/build/main.min.js.map index 6fdffbc47ca..7d74c0febe1 100644 --- a/blocks/recentlyaccessedcourses/amd/build/main.min.js.map +++ b/blocks/recentlyaccessedcourses/amd/build/main.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/main.js"],"names":["define","$","CustomEvents","Notification","PubSub","PagedContentPagingBar","Templates","CourseEvents","CoursesRepository","SELECTORS","BLOCK_CONTAINER","CARD_CONTAINER","COURSE_IS_FAVOURITE","CONTENT","EMPTY_MESSAGE","LOADING_PLACEHOLDER","PAGING_BAR","PAGING_BAR_NEXT","PAGING_BAR_PREVIOUS","contentLoaded","allCourses","visibleCoursesId","cardWidth","viewIndex","availableVisibleCards","showEmptyMessage","root","find","removeClass","addClass","showContent","showPagingBar","pagingBar","css","attr","hidePagingBar","favouriteCourse","courseId","forEach","course","unfavouriteCourse","renderAllCourses","courses","showcoursecategory","data","promises","map","render","when","apply","then","renderedCourses","promise","html","push","catch","exception","loadContent","userid","getLastAccessedCourses","recalculateVisibleCourses","container","availableWidth","parseFloat","numberOfCourses","length","start","outerWidth","Math","floor","overflow","coursesToShow","slice","newVisibleCoursesId","reduce","carry","rootSelector","disablePreviousControlButtons","enablePreviousControlButtons","disableNextControlButtons","enableNextControlButtons","registerEventListeners","resizeTimeout","drawerToggling","subscribe","favourited","unfavorited","recalculationCount","doRecalculation","setTimeout","window","on","events","activate","e","button","target","closest","hasClass","originalEvent","preventDefault","init"],"mappings":"AAwBAA,OAAM,sCACF,CACI,QADJ,CAEI,gCAFJ,CAGI,mBAHJ,CAII,aAJJ,CAKI,+BALJ,CAMI,gBANJ,CAOI,oBAPJ,CAQI,wBARJ,CADE,CAWF,SACIC,CADJ,CAEIC,CAFJ,CAGIC,CAHJ,CAIIC,CAJJ,CAKIC,CALJ,CAMIC,CANJ,CAOIC,CAPJ,CAQIC,CARJ,CASE,IAIMC,CAAAA,CAAS,CAAG,CACZC,eAAe,CAAE,2CADL,CAEZC,cAAc,CAAE,6BAFJ,CAGZC,mBAAmB,CAAE,gCAHT,CAIZC,OAAO,CAAE,gCAJG,CAKZC,aAAa,CAAE,iCALH,CAMZC,mBAAmB,CAAE,uCANT,CAOZC,UAAU,CAAE,8BAPA,CAQZC,eAAe,CAAE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AUH,CArSH,CAkUE,MAAO,CACHC,IAAI,CAtBG,QAAPA,CAAAA,IAAO,CAAS3C,CAAT,CAAiBhC,CAAjB,CAAuB,CAC9BA,CAAI,CAAGzB,CAAC,CAACyB,CAAD,CAAR,CAEAuD,CAAsB,CAACvD,CAAD,CAAtB,CACA+B,CAAW,CAACC,CAAD,CAAX,CACKR,IADL,CACU,SAASC,CAAT,CAA0B,CAC5B/B,CAAU,CAAG+B,CAAb,CACAhC,CAAa,GAAb,CAEA,GAAIC,CAAU,CAAC6C,MAAf,CAAuB,CACnBnC,CAAW,CAACJ,CAAD,CAAX,CACAkC,CAAyB,CAAClC,CAAD,CAC5B,CAHD,IAGO,CACHD,CAAgB,CAACC,CAAD,CACnB,CAGJ,CAbL,EAcK6B,KAdL,CAcWpD,CAAY,CAACqD,SAdxB,CAeH,CAEM,CAGV,CAzVC,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 .\n\n/**\n * Javascript to initialise the Recently accessed courses block.\n *\n * @module block_recentlyaccessedcourses/main.js\n * @package block_recentlyaccessedcourses\n * @copyright 2018 Victor Deniz \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(\n [\n 'jquery',\n 'core/custom_interaction_events',\n 'core/notification',\n 'core/pubsub',\n 'core/paged_content_paging_bar',\n 'core/templates',\n 'core_course/events',\n 'core_course/repository',\n ],\n function(\n $,\n CustomEvents,\n Notification,\n PubSub,\n PagedContentPagingBar,\n Templates,\n CourseEvents,\n CoursesRepository\n ) {\n\n // Constants.\n var NUM_COURSES_TOTAL = 10;\n var SELECTORS = {\n BLOCK_CONTAINER: '[data-region=\"recentlyaccessedcourses\"]',\n CARD_CONTAINER: '[data-region=\"card-deck\"]',\n COURSE_IS_FAVOURITE: '[data-region=\"is-favourite\"]',\n CONTENT: '[data-region=\"view-content\"]',\n EMPTY_MESSAGE: '[data-region=\"empty-message\"]',\n LOADING_PLACEHOLDER: '[data-region=\"loading-placeholder\"]',\n PAGING_BAR: '[data-region=\"paging-bar\"]',\n PAGING_BAR_NEXT: '[data-control=\"next\"]',\n PAGING_BAR_PREVIOUS: '[data-control=\"previous\"]'\n };\n // Module variables.\n var contentLoaded = false;\n var allCourses = [];\n var visibleCoursesId = null;\n var cardWidth = null;\n var viewIndex = 0;\n var availableVisibleCards = 1;\n\n /**\n * Show the empty message when no course are found.\n *\n * @param {object} root The root element for the courses view.\n */\n var showEmptyMessage = function(root) {\n root.find(SELECTORS.EMPTY_MESSAGE).removeClass('hidden');\n root.find(SELECTORS.LOADING_PLACEHOLDER).addClass('hidden');\n root.find(SELECTORS.CONTENT).addClass('hidden');\n };\n\n /**\n * Show the empty message when no course are found.\n *\n * @param {object} root The root element for the courses view.\n */\n var showContent = function(root) {\n root.find(SELECTORS.CONTENT).removeClass('hidden');\n root.find(SELECTORS.EMPTY_MESSAGE).addClass('hidden');\n root.find(SELECTORS.LOADING_PLACEHOLDER).addClass('hidden');\n };\n\n /**\n * Show the paging bar.\n *\n * @param {object} root The root element for the courses view.\n */\n var showPagingBar = function(root) {\n var pagingBar = root.find(SELECTORS.PAGING_BAR);\n pagingBar.css('opacity', 1);\n pagingBar.css('visibility', 'visible');\n pagingBar.attr('aria-hidden', 'false');\n };\n\n /**\n * Hide the paging bar.\n *\n * @param {object} root The root element for the courses view.\n */\n var hidePagingBar = function(root) {\n var pagingBar = root.find(SELECTORS.PAGING_BAR);\n pagingBar.css('opacity', 0);\n pagingBar.css('visibility', 'hidden');\n pagingBar.attr('aria-hidden', 'true');\n };\n\n /**\n * Show the favourite indicator for the given course (if it's in the list).\n *\n * @param {object} root The root element for the courses view.\n * @param {number} courseId The id of the course to be favourited.\n */\n var favouriteCourse = function(root, courseId) {\n allCourses.forEach(function(course) {\n if (course.attr('data-course-id') == courseId) {\n course.find(SELECTORS.COURSE_IS_FAVOURITE).removeClass('hidden');\n }\n });\n };\n\n /**\n * Hide the favourite indicator for the given course (if it's in the list).\n *\n * @param {object} root The root element for the courses view.\n * @param {number} courseId The id of the course to be unfavourited.\n */\n var unfavouriteCourse = function(root, courseId) {\n allCourses.forEach(function(course) {\n if (course.attr('data-course-id') == courseId) {\n course.find(SELECTORS.COURSE_IS_FAVOURITE).addClass('hidden');\n }\n });\n };\n\n /**\n * Render the a list of courses.\n *\n * @param {array} courses containing array of courses.\n * @return {promise} Resolved with list of rendered courses as jQuery objects.\n */\n var renderAllCourses = function(courses) {\n var showcoursecategory = $(SELECTORS.BLOCK_CONTAINER).data('displaycoursecategory');\n var promises = courses.map(function(course) {\n course.showcoursecategory = showcoursecategory;\n return Templates.render('block_recentlyaccessedcourses/course-card', course);\n });\n\n return $.when.apply(null, promises).then(function() {\n var renderedCourses = [];\n\n promises.forEach(function(promise) {\n promise.then(function(html) {\n renderedCourses.push($(html));\n return;\n })\n .catch(Notification.exception);\n });\n\n return renderedCourses;\n });\n };\n\n /**\n * Fetch user's recently accessed courses and reload the content of the block.\n *\n * @param {int} userid User whose courses will be shown\n * @returns {promise} The updated content for the block.\n */\n var loadContent = function(userid) {\n return CoursesRepository.getLastAccessedCourses(userid, NUM_COURSES_TOTAL)\n .then(function(courses) {\n return renderAllCourses(courses);\n });\n };\n\n /**\n * Recalculate the number of courses that should be visible.\n *\n * @param {object} root The root element for the courses view.\n */\n var recalculateVisibleCourses = function(root) {\n var container = root.find(SELECTORS.CONTENT).find(SELECTORS.CARD_CONTAINER);\n var availableWidth = parseFloat(root.css('width'));\n var numberOfCourses = allCourses.length;\n var start = 0;\n\n if (!cardWidth) {\n container.html(allCourses[0]);\n // Render one card initially to calculate the width of the cards\n // including the margins.\n cardWidth = allCourses[0].outerWidth(true);\n }\n\n availableVisibleCards = Math.floor(availableWidth / cardWidth);\n\n if (viewIndex + availableVisibleCards < numberOfCourses) {\n start = viewIndex;\n } else {\n var overflow = (viewIndex + availableVisibleCards) - numberOfCourses;\n start = viewIndex - overflow;\n start = start >= 0 ? start : 0;\n }\n\n var coursesToShow = allCourses.slice(start, start + availableVisibleCards);\n // Create an id for the list of courses we expect to be displayed.\n var newVisibleCoursesId = coursesToShow.reduce(function(carry, course) {\n return carry + course.attr('data-course-id');\n }, '');\n\n // Centre the courses if we have an overflow of courses.\n if (allCourses.length > coursesToShow.length) {\n container.addClass('justify-content-center');\n container.removeClass('justify-content-start');\n } else {\n container.removeClass('justify-content-center');\n container.addClass('justify-content-start');\n }\n\n // Don't bother updating the DOM unless the visible courses have changed.\n if (visibleCoursesId != newVisibleCoursesId) {\n var pagingBar = root.find(PagedContentPagingBar.rootSelector);\n container.html(coursesToShow);\n visibleCoursesId = newVisibleCoursesId;\n\n if (availableVisibleCards >= allCourses.length) {\n hidePagingBar(root);\n } else {\n showPagingBar(root);\n\n if (viewIndex === 0) {\n PagedContentPagingBar.disablePreviousControlButtons(pagingBar);\n } else {\n PagedContentPagingBar.enablePreviousControlButtons(pagingBar);\n }\n\n if (viewIndex + availableVisibleCards >= allCourses.length) {\n PagedContentPagingBar.disableNextControlButtons(pagingBar);\n } else {\n PagedContentPagingBar.enableNextControlButtons(pagingBar);\n }\n }\n }\n };\n\n /**\n * Register event listeners for the block.\n *\n * @param {object} root The root element for the recentlyaccessedcourses block.\n */\n var registerEventListeners = function(root) {\n var resizeTimeout = null;\n var drawerToggling = false;\n\n PubSub.subscribe(CourseEvents.favourited, function(courseId) {\n favouriteCourse(root, courseId);\n });\n\n PubSub.subscribe(CourseEvents.unfavorited, function(courseId) {\n unfavouriteCourse(root, courseId);\n });\n\n PubSub.subscribe('nav-drawer-toggle-start', function() {\n if (!contentLoaded || !allCourses.length || drawerToggling) {\n // Nothing to recalculate.\n return;\n }\n\n drawerToggling = true;\n var recalculationCount = 0;\n // This function is going to recalculate the number of courses while\n // the nav drawer is opening or closes (up to a maximum of 5 recalcs).\n var doRecalculation = function() {\n setTimeout(function() {\n recalculateVisibleCourses(root);\n recalculationCount++;\n\n if (recalculationCount < 5 && drawerToggling) {\n // If we haven't done too many recalculations and the drawer\n // is still toggling then recurse.\n doRecalculation();\n }\n }, 100);\n };\n\n // Start the recalculations.\n doRecalculation(root);\n });\n\n PubSub.subscribe('nav-drawer-toggle-end', function() {\n drawerToggling = false;\n });\n\n $(window).on('resize', function() {\n if (!contentLoaded || !allCourses.length) {\n // Nothing to reclculate.\n return;\n }\n\n // Resize events fire rapidly so recalculating the visible courses each\n // time can be expensive. Let's debounce them,\n if (!resizeTimeout) {\n resizeTimeout = setTimeout(function() {\n resizeTimeout = null;\n recalculateVisibleCourses(root);\n // The recalculateVisibleCourses function will execute at a rate of 15fps.\n }, 66);\n }\n });\n\n CustomEvents.define(root, [CustomEvents.events.activate]);\n root.on(CustomEvents.events.activate, SELECTORS.PAGING_BAR_NEXT, function(e, data) {\n var button = $(e.target).closest(SELECTORS.PAGING_BAR_NEXT);\n if (!button.hasClass('disabled')) {\n viewIndex = viewIndex + availableVisibleCards;\n recalculateVisibleCourses(root);\n }\n\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.activate, SELECTORS.PAGING_BAR_PREVIOUS, function(e, data) {\n var button = $(e.target).closest(SELECTORS.PAGING_BAR_PREVIOUS);\n if (!button.hasClass('disabled')) {\n viewIndex = viewIndex - availableVisibleCards;\n viewIndex = viewIndex < 0 ? 0 : viewIndex;\n recalculateVisibleCourses(root);\n }\n\n data.originalEvent.preventDefault();\n });\n };\n\n /**\n * Get and show the recent courses into the block.\n *\n * @param {int} userid User from which the courses will be obtained\n * @param {object} root The root element for the recentlyaccessedcourses block.\n */\n var init = function(userid, root) {\n root = $(root);\n\n registerEventListeners(root);\n loadContent(userid)\n .then(function(renderedCourses) {\n allCourses = renderedCourses;\n contentLoaded = true;\n\n if (allCourses.length) {\n showContent(root);\n recalculateVisibleCourses(root);\n } else {\n showEmptyMessage(root);\n }\n\n return;\n })\n .catch(Notification.exception);\n };\n\n return {\n init: init\n };\n });\n"],"file":"main.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/main.js"],"names":["define","$","CustomEvents","Notification","PubSub","PagedContentPagingBar","Templates","CourseEvents","CoursesRepository","Aria","SELECTORS","BLOCK_CONTAINER","CARD_CONTAINER","COURSE_IS_FAVOURITE","CONTENT","EMPTY_MESSAGE","LOADING_PLACEHOLDER","PAGING_BAR","PAGING_BAR_NEXT","PAGING_BAR_PREVIOUS","contentLoaded","allCourses","visibleCoursesId","cardWidth","viewIndex","availableVisibleCards","showEmptyMessage","root","find","removeClass","addClass","showContent","showPagingBar","pagingBar","css","unhide","hidePagingBar","hide","favouriteCourse","courseId","forEach","course","attr","unfavouriteCourse","renderAllCourses","courses","showcoursecategory","data","promises","map","render","when","apply","then","renderedCourses","promise","html","push","catch","exception","loadContent","userid","getLastAccessedCourses","recalculateVisibleCourses","container","availableWidth","parseFloat","numberOfCourses","length","start","outerWidth","Math","floor","overflow","coursesToShow","slice","newVisibleCoursesId","reduce","carry","rootSelector","disablePreviousControlButtons","enablePreviousControlButtons","disableNextControlButtons","enableNextControlButtons","registerEventListeners","resizeTimeout","drawerToggling","subscribe","favourited","unfavorited","recalculationCount","doRecalculation","setTimeout","window","on","events","activate","e","button","target","closest","hasClass","originalEvent","preventDefault","init"],"mappings":"AAwBAA,OAAM,sCACF,CACI,QADJ,CAEI,gCAFJ,CAGI,mBAHJ,CAII,aAJJ,CAKI,+BALJ,CAMI,gBANJ,CAOI,oBAPJ,CAQI,wBARJ,CASI,WATJ,CADE,CAYF,SACIC,CADJ,CAEIC,CAFJ,CAGIC,CAHJ,CAIIC,CAJJ,CAKIC,CALJ,CAMIC,CANJ,CAOIC,CAPJ,CAQIC,CARJ,CASIC,CATJ,CAUE,IAIMC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CAAkC,CAC9B7E,CAAS,CAAGA,CAAS,CAAGC,CAAxB,CACAD,CAAS,CAAe,CAAZ,CAAAA,CAAS,CAAO,CAAP,CAAWA,CAAhC,CACAuC,CAAyB,CAACpC,CAAD,CAC5B,CAEDoB,CAAI,CAACuD,aAAL,CAAmBC,cAAnB,EACH,CATD,CAUH,CArSH,CAkUE,MAAO,CACHC,IAAI,CAtBG,QAAPA,CAAAA,IAAO,CAAS3C,CAAT,CAAiBlC,CAAjB,CAAuB,CAC9BA,CAAI,CAAG1B,CAAC,CAAC0B,CAAD,CAAR,CAEAyD,CAAsB,CAACzD,CAAD,CAAtB,CACAiC,CAAW,CAACC,CAAD,CAAX,CACKR,IADL,CACU,SAASC,CAAT,CAA0B,CAC5BjC,CAAU,CAAGiC,CAAb,CACAlC,CAAa,GAAb,CAEA,GAAIC,CAAU,CAAC+C,MAAf,CAAuB,CACnBrC,CAAW,CAACJ,CAAD,CAAX,CACAoC,CAAyB,CAACpC,CAAD,CAC5B,CAHD,IAGO,CACHD,CAAgB,CAACC,CAAD,CACnB,CAGJ,CAbL,EAcK+B,KAdL,CAcWvD,CAAY,CAACwD,SAdxB,CAeH,CAEM,CAGV,CA3VC,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 .\n\n/**\n * Javascript to initialise the Recently accessed courses block.\n *\n * @module block_recentlyaccessedcourses/main.js\n * @package block_recentlyaccessedcourses\n * @copyright 2018 Victor Deniz \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(\n [\n 'jquery',\n 'core/custom_interaction_events',\n 'core/notification',\n 'core/pubsub',\n 'core/paged_content_paging_bar',\n 'core/templates',\n 'core_course/events',\n 'core_course/repository',\n 'core/aria',\n ],\n function(\n $,\n CustomEvents,\n Notification,\n PubSub,\n PagedContentPagingBar,\n Templates,\n CourseEvents,\n CoursesRepository,\n Aria\n ) {\n\n // Constants.\n var NUM_COURSES_TOTAL = 10;\n var SELECTORS = {\n BLOCK_CONTAINER: '[data-region=\"recentlyaccessedcourses\"]',\n CARD_CONTAINER: '[data-region=\"card-deck\"]',\n COURSE_IS_FAVOURITE: '[data-region=\"is-favourite\"]',\n CONTENT: '[data-region=\"view-content\"]',\n EMPTY_MESSAGE: '[data-region=\"empty-message\"]',\n LOADING_PLACEHOLDER: '[data-region=\"loading-placeholder\"]',\n PAGING_BAR: '[data-region=\"paging-bar\"]',\n PAGING_BAR_NEXT: '[data-control=\"next\"]',\n PAGING_BAR_PREVIOUS: '[data-control=\"previous\"]'\n };\n // Module variables.\n var contentLoaded = false;\n var allCourses = [];\n var visibleCoursesId = null;\n var cardWidth = null;\n var viewIndex = 0;\n var availableVisibleCards = 1;\n\n /**\n * Show the empty message when no course are found.\n *\n * @param {object} root The root element for the courses view.\n */\n var showEmptyMessage = function(root) {\n root.find(SELECTORS.EMPTY_MESSAGE).removeClass('hidden');\n root.find(SELECTORS.LOADING_PLACEHOLDER).addClass('hidden');\n root.find(SELECTORS.CONTENT).addClass('hidden');\n };\n\n /**\n * Show the empty message when no course are found.\n *\n * @param {object} root The root element for the courses view.\n */\n var showContent = function(root) {\n root.find(SELECTORS.CONTENT).removeClass('hidden');\n root.find(SELECTORS.EMPTY_MESSAGE).addClass('hidden');\n root.find(SELECTORS.LOADING_PLACEHOLDER).addClass('hidden');\n };\n\n /**\n * Show the paging bar.\n *\n * @param {object} root The root element for the courses view.\n */\n var showPagingBar = function(root) {\n var pagingBar = root.find(SELECTORS.PAGING_BAR);\n pagingBar.css('opacity', 1);\n pagingBar.css('visibility', 'visible');\n Aria.unhide(pagingBar);\n };\n\n /**\n * Hide the paging bar.\n *\n * @param {object} root The root element for the courses view.\n */\n var hidePagingBar = function(root) {\n var pagingBar = root.find(SELECTORS.PAGING_BAR);\n pagingBar.css('opacity', 0);\n pagingBar.css('visibility', 'hidden');\n Aria.hide(pagingBar);\n };\n\n /**\n * Show the favourite indicator for the given course (if it's in the list).\n *\n * @param {object} root The root element for the courses view.\n * @param {number} courseId The id of the course to be favourited.\n */\n var favouriteCourse = function(root, courseId) {\n allCourses.forEach(function(course) {\n if (course.attr('data-course-id') == courseId) {\n course.find(SELECTORS.COURSE_IS_FAVOURITE).removeClass('hidden');\n }\n });\n };\n\n /**\n * Hide the favourite indicator for the given course (if it's in the list).\n *\n * @param {object} root The root element for the courses view.\n * @param {number} courseId The id of the course to be unfavourited.\n */\n var unfavouriteCourse = function(root, courseId) {\n allCourses.forEach(function(course) {\n if (course.attr('data-course-id') == courseId) {\n course.find(SELECTORS.COURSE_IS_FAVOURITE).addClass('hidden');\n }\n });\n };\n\n /**\n * Render the a list of courses.\n *\n * @param {array} courses containing array of courses.\n * @return {promise} Resolved with list of rendered courses as jQuery objects.\n */\n var renderAllCourses = function(courses) {\n var showcoursecategory = $(SELECTORS.BLOCK_CONTAINER).data('displaycoursecategory');\n var promises = courses.map(function(course) {\n course.showcoursecategory = showcoursecategory;\n return Templates.render('block_recentlyaccessedcourses/course-card', course);\n });\n\n return $.when.apply(null, promises).then(function() {\n var renderedCourses = [];\n\n promises.forEach(function(promise) {\n promise.then(function(html) {\n renderedCourses.push($(html));\n return;\n })\n .catch(Notification.exception);\n });\n\n return renderedCourses;\n });\n };\n\n /**\n * Fetch user's recently accessed courses and reload the content of the block.\n *\n * @param {int} userid User whose courses will be shown\n * @returns {promise} The updated content for the block.\n */\n var loadContent = function(userid) {\n return CoursesRepository.getLastAccessedCourses(userid, NUM_COURSES_TOTAL)\n .then(function(courses) {\n return renderAllCourses(courses);\n });\n };\n\n /**\n * Recalculate the number of courses that should be visible.\n *\n * @param {object} root The root element for the courses view.\n */\n var recalculateVisibleCourses = function(root) {\n var container = root.find(SELECTORS.CONTENT).find(SELECTORS.CARD_CONTAINER);\n var availableWidth = parseFloat(root.css('width'));\n var numberOfCourses = allCourses.length;\n var start = 0;\n\n if (!cardWidth) {\n container.html(allCourses[0]);\n // Render one card initially to calculate the width of the cards\n // including the margins.\n cardWidth = allCourses[0].outerWidth(true);\n }\n\n availableVisibleCards = Math.floor(availableWidth / cardWidth);\n\n if (viewIndex + availableVisibleCards < numberOfCourses) {\n start = viewIndex;\n } else {\n var overflow = (viewIndex + availableVisibleCards) - numberOfCourses;\n start = viewIndex - overflow;\n start = start >= 0 ? start : 0;\n }\n\n var coursesToShow = allCourses.slice(start, start + availableVisibleCards);\n // Create an id for the list of courses we expect to be displayed.\n var newVisibleCoursesId = coursesToShow.reduce(function(carry, course) {\n return carry + course.attr('data-course-id');\n }, '');\n\n // Centre the courses if we have an overflow of courses.\n if (allCourses.length > coursesToShow.length) {\n container.addClass('justify-content-center');\n container.removeClass('justify-content-start');\n } else {\n container.removeClass('justify-content-center');\n container.addClass('justify-content-start');\n }\n\n // Don't bother updating the DOM unless the visible courses have changed.\n if (visibleCoursesId != newVisibleCoursesId) {\n var pagingBar = root.find(PagedContentPagingBar.rootSelector);\n container.html(coursesToShow);\n visibleCoursesId = newVisibleCoursesId;\n\n if (availableVisibleCards >= allCourses.length) {\n hidePagingBar(root);\n } else {\n showPagingBar(root);\n\n if (viewIndex === 0) {\n PagedContentPagingBar.disablePreviousControlButtons(pagingBar);\n } else {\n PagedContentPagingBar.enablePreviousControlButtons(pagingBar);\n }\n\n if (viewIndex + availableVisibleCards >= allCourses.length) {\n PagedContentPagingBar.disableNextControlButtons(pagingBar);\n } else {\n PagedContentPagingBar.enableNextControlButtons(pagingBar);\n }\n }\n }\n };\n\n /**\n * Register event listeners for the block.\n *\n * @param {object} root The root element for the recentlyaccessedcourses block.\n */\n var registerEventListeners = function(root) {\n var resizeTimeout = null;\n var drawerToggling = false;\n\n PubSub.subscribe(CourseEvents.favourited, function(courseId) {\n favouriteCourse(root, courseId);\n });\n\n PubSub.subscribe(CourseEvents.unfavorited, function(courseId) {\n unfavouriteCourse(root, courseId);\n });\n\n PubSub.subscribe('nav-drawer-toggle-start', function() {\n if (!contentLoaded || !allCourses.length || drawerToggling) {\n // Nothing to recalculate.\n return;\n }\n\n drawerToggling = true;\n var recalculationCount = 0;\n // This function is going to recalculate the number of courses while\n // the nav drawer is opening or closes (up to a maximum of 5 recalcs).\n var doRecalculation = function() {\n setTimeout(function() {\n recalculateVisibleCourses(root);\n recalculationCount++;\n\n if (recalculationCount < 5 && drawerToggling) {\n // If we haven't done too many recalculations and the drawer\n // is still toggling then recurse.\n doRecalculation();\n }\n }, 100);\n };\n\n // Start the recalculations.\n doRecalculation(root);\n });\n\n PubSub.subscribe('nav-drawer-toggle-end', function() {\n drawerToggling = false;\n });\n\n $(window).on('resize', function() {\n if (!contentLoaded || !allCourses.length) {\n // Nothing to reclculate.\n return;\n }\n\n // Resize events fire rapidly so recalculating the visible courses each\n // time can be expensive. Let's debounce them,\n if (!resizeTimeout) {\n resizeTimeout = setTimeout(function() {\n resizeTimeout = null;\n recalculateVisibleCourses(root);\n // The recalculateVisibleCourses function will execute at a rate of 15fps.\n }, 66);\n }\n });\n\n CustomEvents.define(root, [CustomEvents.events.activate]);\n root.on(CustomEvents.events.activate, SELECTORS.PAGING_BAR_NEXT, function(e, data) {\n var button = $(e.target).closest(SELECTORS.PAGING_BAR_NEXT);\n if (!button.hasClass('disabled')) {\n viewIndex = viewIndex + availableVisibleCards;\n recalculateVisibleCourses(root);\n }\n\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.activate, SELECTORS.PAGING_BAR_PREVIOUS, function(e, data) {\n var button = $(e.target).closest(SELECTORS.PAGING_BAR_PREVIOUS);\n if (!button.hasClass('disabled')) {\n viewIndex = viewIndex - availableVisibleCards;\n viewIndex = viewIndex < 0 ? 0 : viewIndex;\n recalculateVisibleCourses(root);\n }\n\n data.originalEvent.preventDefault();\n });\n };\n\n /**\n * Get and show the recent courses into the block.\n *\n * @param {int} userid User from which the courses will be obtained\n * @param {object} root The root element for the recentlyaccessedcourses block.\n */\n var init = function(userid, root) {\n root = $(root);\n\n registerEventListeners(root);\n loadContent(userid)\n .then(function(renderedCourses) {\n allCourses = renderedCourses;\n contentLoaded = true;\n\n if (allCourses.length) {\n showContent(root);\n recalculateVisibleCourses(root);\n } else {\n showEmptyMessage(root);\n }\n\n return;\n })\n .catch(Notification.exception);\n };\n\n return {\n init: init\n };\n });\n"],"file":"main.min.js"} \ No newline at end of file diff --git a/blocks/recentlyaccessedcourses/amd/src/main.js b/blocks/recentlyaccessedcourses/amd/src/main.js index ca3186b5899..9af85cb9091 100644 --- a/blocks/recentlyaccessedcourses/amd/src/main.js +++ b/blocks/recentlyaccessedcourses/amd/src/main.js @@ -32,6 +32,7 @@ define( 'core/templates', 'core_course/events', 'core_course/repository', + 'core/aria', ], function( $, @@ -41,7 +42,8 @@ define( PagedContentPagingBar, Templates, CourseEvents, - CoursesRepository + CoursesRepository, + Aria ) { // Constants. @@ -96,7 +98,7 @@ define( var pagingBar = root.find(SELECTORS.PAGING_BAR); pagingBar.css('opacity', 1); pagingBar.css('visibility', 'visible'); - pagingBar.attr('aria-hidden', 'false'); + Aria.unhide(pagingBar); }; /** @@ -108,7 +110,7 @@ define( var pagingBar = root.find(SELECTORS.PAGING_BAR); pagingBar.css('opacity', 0); pagingBar.css('visibility', 'hidden'); - pagingBar.attr('aria-hidden', 'true'); + Aria.hide(pagingBar); }; /** diff --git a/lib/amd/build/drawer.min.js b/lib/amd/build/drawer.min.js index 760a6742874..c1e1118ac46 100644 --- a/lib/amd/build/drawer.min.js +++ b/lib/amd/build/drawer.min.js @@ -1,2 +1,2 @@ -function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("core/drawer",["exports","jquery","core/pubsub","core/drawer_events"],function(a,b,c,d){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;b=g(b);c=f(c);d=g(d);function e(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;e=function(){return a};return a}function f(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=e();if(b&&b.has(a)){return b.get(a)}var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in a){if(Object.prototype.hasOwnProperty.call(a,f)){var g=d?Object.getOwnPropertyDescriptor(a,f):null;if(g&&(g.get||g.set)){Object.defineProperty(c,f,g)}else{c[f]=a[f]}}}c.default=a;if(b){b.set(a,c)}return c}function g(a){return a&&a.__esModule?a:{default:a}}var h=function(a){a.removeClass("hidden");a.attr("aria-expanded",!0);a.removeAttr("aria-hidden");a.focus();c.publish(d.default.DRAWER_SHOWN,a)},i=function(a){a.addClass("hidden");a.attr("aria-expanded",!1);a.attr("aria-hidden",!0);c.publish(d.default.DRAWER_HIDDEN,a)},j=function(a){var b=a.hasClass("hidden");return!b},k=function(a){if(j(a)){i(a)}else{h(a)}},l=function(a){a=(0,b.default)(a);return a.closest("[data-region=\"right-hand-drawer\"]")};a.default={hide:i,show:h,isVisible:j,toggle:k,registerToggles:function registerToggles(a,b){var c=null;b.attr("aria-expanded",j(a));b.on("click",function(d){d.preventDefault();var e=j(a);k(a);b.attr("aria-expanded",!e);if(!e){c=b.filter(function(a,b){return b==d.target||b.contains(d.target)})}else if(c){c.focus();c=null}})},getDrawerRoot:l};return a.default}); +function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("core/drawer",["exports","jquery","core/pubsub","core/aria","core/drawer_events"],function(a,b,c,d,e){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;b=h(b);c=g(c);d=g(d);e=h(e);function f(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;f=function(){return a};return a}function g(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=f();if(b&&b.has(a)){return b.get(a)}var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a){if(Object.prototype.hasOwnProperty.call(a,e)){var g=d?Object.getOwnPropertyDescriptor(a,e):null;if(g&&(g.get||g.set)){Object.defineProperty(c,e,g)}else{c[e]=a[e]}}}c.default=a;if(b){b.set(a,c)}return c}function h(a){return a&&a.__esModule?a:{default:a}}var i=function(a){a=(0,b.default)(a);d.unhide(a.get());a.removeClass("hidden");a.attr("aria-expanded",!0);a.focus();c.publish(e.default.DRAWER_SHOWN,a)},j=function(a){a=(0,b.default)(a);a.addClass("hidden");a.attr("aria-expanded",!1);d.hide(a.get());c.publish(e.default.DRAWER_HIDDEN,a)},k=function(a){var b=a.hasClass("hidden");return!b},l=function(a){if(k(a)){j(a)}else{i(a)}},m=function(a){a=(0,b.default)(a);return a.closest("[data-region=\"right-hand-drawer\"]")};a.default={hide:j,show:i,isVisible:k,toggle:l,registerToggles:function registerToggles(a,b){var c=null;b.attr("aria-expanded",k(a));b.on("click",function(d){d.preventDefault();var e=k(a);l(a);b.attr("aria-expanded",!e);if(!e){c=b.filter(function(a,b){return b==d.target||b.contains(d.target)})}else if(c){c.focus();c=null}})},getDrawerRoot:m};return a.default}); //# sourceMappingURL=drawer.min.js.map diff --git a/lib/amd/build/drawer.min.js.map b/lib/amd/build/drawer.min.js.map index 82cdd89ccc2..c8884f798a2 100644 --- a/lib/amd/build/drawer.min.js.map +++ b/lib/amd/build/drawer.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/drawer.js"],"names":["show","root","removeClass","attr","removeAttr","focus","PubSub","publish","DrawerEvents","DRAWER_SHOWN","hide","addClass","DRAWER_HIDDEN","isVisible","isHidden","hasClass","toggle","getDrawerRoot","contentRoot","closest","registerToggles","toggleElements","openTrigger","on","e","preventDefault","wasVisible","filter","index","element","target","contains"],"mappings":"kdAsBA,OACA,OACA,O,4lBAOMA,CAAAA,CAAI,CAAG,SAACC,CAAD,CAAU,CACnBA,CAAI,CAACC,WAAL,CAAiB,QAAjB,EACAD,CAAI,CAACE,IAAL,CAAU,eAAV,KACAF,CAAI,CAACG,UAAL,CAAgB,aAAhB,EACAH,CAAI,CAACI,KAAL,GAEAC,CAAM,CAACC,OAAP,CAAeC,UAAaC,YAA5B,CAA0CR,CAA1C,CACH,C,CAOKS,CAAI,CAAG,SAACT,CAAD,CAAU,CACnBA,CAAI,CAACU,QAAL,CAAc,QAAd,EACAV,CAAI,CAACE,IAAL,CAAU,eAAV,KACAF,CAAI,CAACE,IAAL,CAAU,aAAV,KACAG,CAAM,CAACC,OAAP,CAAeC,UAAaI,aAA5B,CAA2CX,CAA3C,CACH,C,CAQKY,CAAS,CAAG,SAACZ,CAAD,CAAU,CACxB,GAAIa,CAAAA,CAAQ,CAAGb,CAAI,CAACc,QAAL,CAAc,QAAd,CAAf,CACA,MAAO,CAACD,CACX,C,CAOKE,CAAM,CAAG,SAACf,CAAD,CAAU,CACrB,GAAIY,CAAS,CAACZ,CAAD,CAAb,CAAqB,CACjBS,CAAI,CAACT,CAAD,CACP,CAFD,IAEO,CACHD,CAAI,CAACC,CAAD,CACP,CACJ,C,CAsCKgB,CAAa,CAAG,SAACC,CAAD,CAAiB,CACnCA,CAAW,CAAG,cAAEA,CAAF,CAAd,CACA,MAAOA,CAAAA,CAAW,CAACC,OAAZ,CAAoB,qCAApB,CACV,C,WAEc,CACXT,IAAI,CAAEA,CADK,CAEXV,IAAI,CAAEA,CAFK,CAGXa,SAAS,CAAEA,CAHA,CAIXG,MAAM,CAAEA,CAJG,CAKXI,eAAe,CAxCK,QAAlBA,CAAAA,eAAkB,CAACnB,CAAD,CAAOoB,CAAP,CAA0B,CAC9C,GAAIC,CAAAA,CAAW,CAAG,IAAlB,CACAD,CAAc,CAAClB,IAAf,CAAoB,eAApB,CAAqCU,CAAS,CAACZ,CAAD,CAA9C,EAEAoB,CAAc,CAACE,EAAf,CAAkB,OAAlB,CAA2B,SAACC,CAAD,CAAO,CAC9BA,CAAC,CAACC,cAAF,GACA,GAAMC,CAAAA,CAAU,CAAGb,CAAS,CAACZ,CAAD,CAA5B,CACAe,CAAM,CAACf,CAAD,CAAN,CACAoB,CAAc,CAAClB,IAAf,CAAoB,eAApB,CAAqC,CAACuB,CAAtC,EAEA,GAAI,CAACA,CAAL,CAAiB,CAEbJ,CAAW,CAAGD,CAAc,CAACM,MAAf,CAAsB,SAACC,CAAD,CAAQC,CAAR,CAAoB,CACpD,MAAOA,CAAAA,CAAO,EAAIL,CAAC,CAACM,MAAb,EAAuBD,CAAO,CAACE,QAAR,CAAiBP,CAAC,CAACM,MAAnB,CACjC,CAFa,CAGjB,CALD,IAKO,IAAIR,CAAJ,CAAiB,CAGpBA,CAAW,CAACjB,KAAZ,GACAiB,CAAW,CAAG,IACjB,CACJ,CAjBD,CAkBH,CAac,CAMXL,aAAa,CAAEA,CANJ,C","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 .\n\n/**\n * Controls the drawer.\n *\n * @module core/drawer\n * @copyright 2019 Jun Pataleta \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport $ from 'jquery';\nimport * as PubSub from 'core/pubsub';\nimport DrawerEvents from 'core/drawer_events';\n\n/**\n * Show the drawer.\n *\n * @param {Object} root The drawer container.\n */\nconst show = (root) => {\n root.removeClass('hidden');\n root.attr('aria-expanded', true);\n root.removeAttr('aria-hidden');\n root.focus();\n\n PubSub.publish(DrawerEvents.DRAWER_SHOWN, root);\n};\n\n/**\n * Hide the drawer.\n *\n * @param {Object} root The drawer container.\n */\nconst hide = (root) => {\n root.addClass('hidden');\n root.attr('aria-expanded', false);\n root.attr('aria-hidden', true);\n PubSub.publish(DrawerEvents.DRAWER_HIDDEN, root);\n};\n\n/**\n * Check if the drawer is visible.\n *\n * @param {Object} root The drawer container.\n * @return {boolean}\n */\nconst isVisible = (root) => {\n let isHidden = root.hasClass('hidden');\n return !isHidden;\n};\n\n/**\n * Toggle the drawer visibility.\n *\n * @param {Object} root The drawer container.\n */\nconst toggle = (root) => {\n if (isVisible(root)) {\n hide(root);\n } else {\n show(root);\n }\n};\n\n/**\n * Add event listeners to toggle the drawer.\n *\n * @param {Object} root The drawer container.\n * @param {Object} toggleElements The toggle elements.\n */\nconst registerToggles = (root, toggleElements) => {\n let openTrigger = null;\n toggleElements.attr('aria-expanded', isVisible(root));\n\n toggleElements.on('click', (e) => {\n e.preventDefault();\n const wasVisible = isVisible(root);\n toggle(root);\n toggleElements.attr('aria-expanded', !wasVisible);\n\n if (!wasVisible) {\n // Remember which trigger element opened the drawer.\n openTrigger = toggleElements.filter((index, element) => {\n return element == e.target || element.contains(e.target);\n });\n } else if (openTrigger) {\n // The drawer has gone from open to close so we need to set the focus back\n // to the element that openend it.\n openTrigger.focus();\n openTrigger = null;\n }\n });\n};\n\n/**\n * Find the root element of the drawer based on the using the drawer content root's ID.\n *\n * @param {Object} contentRoot The drawer content's root element.\n * @returns {*|jQuery}\n */\nconst getDrawerRoot = (contentRoot) => {\n contentRoot = $(contentRoot);\n return contentRoot.closest('[data-region=\"right-hand-drawer\"]');\n};\n\nexport default {\n hide: hide,\n show: show,\n isVisible: isVisible,\n toggle: toggle,\n registerToggles: registerToggles,\n getDrawerRoot: getDrawerRoot\n};\n"],"file":"drawer.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/drawer.js"],"names":["show","root","Aria","unhide","get","removeClass","attr","focus","PubSub","publish","DrawerEvents","DRAWER_SHOWN","hide","addClass","DRAWER_HIDDEN","isVisible","isHidden","hasClass","toggle","getDrawerRoot","contentRoot","closest","registerToggles","toggleElements","openTrigger","on","e","preventDefault","wasVisible","filter","index","element","target","contains"],"mappings":"geAsBA,OACA,OACA,OACA,O,4lBAOMA,CAAAA,CAAI,CAAG,SAAAC,CAAI,CAAI,CAEjBA,CAAI,CAAG,cAAEA,CAAF,CAAP,CAEAC,CAAI,CAACC,MAAL,CAAYF,CAAI,CAACG,GAAL,EAAZ,EACAH,CAAI,CAACI,WAAL,CAAiB,QAAjB,EACAJ,CAAI,CAACK,IAAL,CAAU,eAAV,KACAL,CAAI,CAACM,KAAL,GAEAC,CAAM,CAACC,OAAP,CAAeC,UAAaC,YAA5B,CAA0CV,CAA1C,CACH,C,CAOKW,CAAI,CAAG,SAAAX,CAAI,CAAI,CAEjBA,CAAI,CAAG,cAAEA,CAAF,CAAP,CAEAA,CAAI,CAACY,QAAL,CAAc,QAAd,EACAZ,CAAI,CAACK,IAAL,CAAU,eAAV,KACAJ,CAAI,CAACU,IAAL,CAAUX,CAAI,CAACG,GAAL,EAAV,EAEAI,CAAM,CAACC,OAAP,CAAeC,UAAaI,aAA5B,CAA2Cb,CAA3C,CACH,C,CAQKc,CAAS,CAAG,SAACd,CAAD,CAAU,CACxB,GAAIe,CAAAA,CAAQ,CAAGf,CAAI,CAACgB,QAAL,CAAc,QAAd,CAAf,CACA,MAAO,CAACD,CACX,C,CAOKE,CAAM,CAAG,SAACjB,CAAD,CAAU,CACrB,GAAIc,CAAS,CAACd,CAAD,CAAb,CAAqB,CACjBW,CAAI,CAACX,CAAD,CACP,CAFD,IAEO,CACHD,CAAI,CAACC,CAAD,CACP,CACJ,C,CAsCKkB,CAAa,CAAG,SAACC,CAAD,CAAiB,CACnCA,CAAW,CAAG,cAAEA,CAAF,CAAd,CACA,MAAOA,CAAAA,CAAW,CAACC,OAAZ,CAAoB,qCAApB,CACV,C,WAEc,CACXT,IAAI,CAAEA,CADK,CAEXZ,IAAI,CAAEA,CAFK,CAGXe,SAAS,CAAEA,CAHA,CAIXG,MAAM,CAAEA,CAJG,CAKXI,eAAe,CAxCK,QAAlBA,CAAAA,eAAkB,CAACrB,CAAD,CAAOsB,CAAP,CAA0B,CAC9C,GAAIC,CAAAA,CAAW,CAAG,IAAlB,CACAD,CAAc,CAACjB,IAAf,CAAoB,eAApB,CAAqCS,CAAS,CAACd,CAAD,CAA9C,EAEAsB,CAAc,CAACE,EAAf,CAAkB,OAAlB,CAA2B,SAACC,CAAD,CAAO,CAC9BA,CAAC,CAACC,cAAF,GACA,GAAMC,CAAAA,CAAU,CAAGb,CAAS,CAACd,CAAD,CAA5B,CACAiB,CAAM,CAACjB,CAAD,CAAN,CACAsB,CAAc,CAACjB,IAAf,CAAoB,eAApB,CAAqC,CAACsB,CAAtC,EAEA,GAAI,CAACA,CAAL,CAAiB,CAEbJ,CAAW,CAAGD,CAAc,CAACM,MAAf,CAAsB,SAACC,CAAD,CAAQC,CAAR,CAAoB,CACpD,MAAOA,CAAAA,CAAO,EAAIL,CAAC,CAACM,MAAb,EAAuBD,CAAO,CAACE,QAAR,CAAiBP,CAAC,CAACM,MAAnB,CACjC,CAFa,CAGjB,CALD,IAKO,IAAIR,CAAJ,CAAiB,CAGpBA,CAAW,CAACjB,KAAZ,GACAiB,CAAW,CAAG,IACjB,CACJ,CAjBD,CAkBH,CAac,CAMXL,aAAa,CAAEA,CANJ,C","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 .\n\n/**\n * Controls the drawer.\n *\n * @module core/drawer\n * @copyright 2019 Jun Pataleta \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport $ from 'jquery';\nimport * as PubSub from 'core/pubsub';\nimport * as Aria from 'core/aria';\nimport DrawerEvents from 'core/drawer_events';\n\n/**\n * Show the drawer.\n *\n * @param {Object} root The drawer container.\n */\nconst show = root => {\n // Ensure that it is a jQuery.\n root = $(root);\n\n Aria.unhide(root.get());\n root.removeClass('hidden');\n root.attr('aria-expanded', true);\n root.focus();\n\n PubSub.publish(DrawerEvents.DRAWER_SHOWN, root);\n};\n\n/**\n * Hide the drawer.\n *\n * @param {Object} root The drawer container.\n */\nconst hide = root => {\n // Ensure that it is a jQuery.\n root = $(root);\n\n root.addClass('hidden');\n root.attr('aria-expanded', false);\n Aria.hide(root.get());\n\n PubSub.publish(DrawerEvents.DRAWER_HIDDEN, root);\n};\n\n/**\n * Check if the drawer is visible.\n *\n * @param {Object} root The drawer container.\n * @return {boolean}\n */\nconst isVisible = (root) => {\n let isHidden = root.hasClass('hidden');\n return !isHidden;\n};\n\n/**\n * Toggle the drawer visibility.\n *\n * @param {Object} root The drawer container.\n */\nconst toggle = (root) => {\n if (isVisible(root)) {\n hide(root);\n } else {\n show(root);\n }\n};\n\n/**\n * Add event listeners to toggle the drawer.\n *\n * @param {Object} root The drawer container.\n * @param {Object} toggleElements The toggle elements.\n */\nconst registerToggles = (root, toggleElements) => {\n let openTrigger = null;\n toggleElements.attr('aria-expanded', isVisible(root));\n\n toggleElements.on('click', (e) => {\n e.preventDefault();\n const wasVisible = isVisible(root);\n toggle(root);\n toggleElements.attr('aria-expanded', !wasVisible);\n\n if (!wasVisible) {\n // Remember which trigger element opened the drawer.\n openTrigger = toggleElements.filter((index, element) => {\n return element == e.target || element.contains(e.target);\n });\n } else if (openTrigger) {\n // The drawer has gone from open to close so we need to set the focus back\n // to the element that openend it.\n openTrigger.focus();\n openTrigger = null;\n }\n });\n};\n\n/**\n * Find the root element of the drawer based on the using the drawer content root's ID.\n *\n * @param {Object} contentRoot The drawer content's root element.\n * @returns {*|jQuery}\n */\nconst getDrawerRoot = (contentRoot) => {\n contentRoot = $(contentRoot);\n return contentRoot.closest('[data-region=\"right-hand-drawer\"]');\n};\n\nexport default {\n hide: hide,\n show: show,\n isVisible: isVisible,\n toggle: toggle,\n registerToggles: registerToggles,\n getDrawerRoot: getDrawerRoot\n};\n"],"file":"drawer.min.js"} \ No newline at end of file diff --git a/lib/amd/build/form-autocomplete.min.js b/lib/amd/build/form-autocomplete.min.js index 8ef27f0ca42..58ca652a69a 100644 --- a/lib/amd/build/form-autocomplete.min.js +++ b/lib/amd/build/form-autocomplete.min.js @@ -1,2 +1,2 @@ -define ("core/form-autocomplete",["jquery","core/log","core/str","core/templates","core/notification","core/loadingicon"],function(a,b,c,d,f,g){var h={DOWN:40,ENTER:13,SPACE:32,ESCAPE:27,COMMA:44,UP:38},i=Date.now(),j=function(b,c){var d=a(document.getElementById(c.selectionId)),e=d.children("[aria-selected=true]").length;b=b%e;while(0>b){b+=e}var f=a(d.children("[aria-selected=true]").get(b)),g=c.selectionId+"-"+b;d.children().attr("data-active-selection",!1).attr("id","");f.attr("data-active-selection",!0).attr("id",g);d.attr("aria-activedescendant",g);return a.Deferred().resolve()},k=function(b,c,e){var g="form-autocomplete-updateSelectionList-"+c.inputId;M.util.js_pending(g);var h=[],i=a(document.getElementById(c.selectionId)),k=i.attr("aria-activedescendant"),l=!1;if(k){l=a(document.getElementById(k)).attr("data-value")}e.children("option").each(function(b,c){if(a(c).prop("selected")){var d;if(a(c).data("html")){d=a(c).data("html")}else{d=a(c).html()}if(""!==d){h.push({label:d,value:a(c).attr("value")})}}});var m=a.extend({items:h},b,c);return d.render(b.templates.items,m).then(function(b,e){d.replaceNodeContents(i,b,e);if(!1!==l){i.children("[aria-selected=true]").each(function(b,d){if(a(d).attr("data-value")===l){j(b,c)}})}return l}).then(function(){return M.util.js_complete(g)}).catch(f.exception)},l=function(a){if("undefined"!=typeof M.core_formchangechecker){M.core_formchangechecker.set_form_changed()}a[0].dispatchEvent(new Event("change"))},m=function(b,c,d,e){var f=a(d).attr("data-value");e.children("option").each(function(b,c){if(a(c).attr("value")==f){a(c).prop("selected",!1);if(a(c).attr("data-iscustom")){a(c).remove()}}});return k(b,c,e).then(function(){l(e)})},n=function(b,c){var d=a(document.getElementById(c.inputId)),e=a(document.getElementById(c.suggestionsId)),f=e.children("[aria-hidden=false]").length;b=b%f;while(0>b){b+=f}var g=a(e.children("[aria-hidden=false]").get(b)),h=a(e.children("[role=option]")).index(g),i=c.suggestionsId+"-"+h;e.children().attr("aria-selected",!1).attr("id","");g.attr("aria-selected",!0).attr("id",i);d.attr("aria-activedescendant",i);var j=g.offset().top-e.offset().top+e.scrollTop()-e.height()/2;return e.animate({scrollTop:j},100).promise()},o=function(b){var c=a(document.getElementById(b.suggestionsId)),d=c.children("[aria-selected=true]"),e=c.children("[aria-hidden=false]").index(d);return n(e+1,b)},p=function(b){var c=a(document.getElementById(b.selectionId)),d=c.children("[data-active-selection=true]");if(!d){return j(0,b)}var e=c.children("[aria-selected=true]").index(d);return j(e-1,b)},q=function(b){var c=a(document.getElementById(b.selectionId)),d=c.children("[data-active-selection=true]"),e=0;if(d){e=c.children("[aria-selected=true]").index(d);e=e+1}else{e=0}return j(e,b)},r=function(b){var c=a(document.getElementById(b.suggestionsId)),d=c.children("[aria-selected=true]"),e=c.children("[aria-hidden=false]").index(d);return n(e-1,b)},s=function(b){var c=a(document.getElementById(b.inputId)),d=a(document.getElementById(b.suggestionsId));c.attr("aria-expanded",!1).attr("aria-activedescendant",b.selectionId);d.hide().attr("aria-hidden",!0);return a.Deferred().resolve()},t=function(b,e,g,h){var i="form-autocomplete-updateSuggestions-"+e.inputId;M.util.js_pending(i);var j=a(document.getElementById(e.inputId)),k=a(document.getElementById(e.suggestionsId)),l=!1,m=[];h.children("option").each(function(b,c){if(!0!==a(c).prop("selected")){m[m.length]={label:c.innerHTML,value:a(c).attr("value")}}});var o=e.caseSensitive?g:g.toLocaleLowerCase(),p=a.extend({options:m},b,e),q=d.render("core/form_autocomplete_suggestions",p).then(function(f,g){d.replaceNode(k,f,g);k=a(document.getElementById(e.suggestionsId));k.show().attr("aria-hidden",!1);k.children().each(function(c,d){d=a(d);if(b.caseSensitive&&-1");f.append(document.createTextNode(e));f.attr("value",e);d.append(f);f.prop("selected",!0);f.attr("data-iscustom",!0)}}});return k(b,c,d).then(function(){l(d)}).then(function(){e.val("")}).then(function(){return s(c)})},v=function(b,c,d){var e=a(document.getElementById(c.inputId)),f=a(document.getElementById(c.suggestionsId)),g=f.children("[aria-selected=true]").attr("data-value");if(!b.multiple){d.children("option").prop("selected",!1)}d.children("option").each(function(b,c){if(a(c).attr("value")==g){a(c).prop("selected",!0)}});return k(b,c,d).then(function(){l(d)}).then(function(){if(b.closeSuggestionsOnSelect){e.val("");return s(c)}else{e.focus();return t(b,c,e.val(),d)}})},w=function(b,c,d,e,f){var h=y("updateAjax"),i=a(document.getElementById(d.selectId)).parent();g.addIconToContainerRemoveOnCompletion(i,h);var j=a(b.currentTarget).val();f.transport(c.selector,j,function(b){var g=f.processResults(c.selector,b),i=[];if(!c.multiple){e.children("option").remove()}e.children("option").each(function(b,c){c=a(c);if(!c.prop("selected")){c.remove()}else{i.push(c.attr("value")+"")}});if(!c.multiple&&0===e.children("option").length){var j=a("