diff --git a/admin/tool/usertours/amd/build/usertours.min.js b/admin/tool/usertours/amd/build/usertours.min.js index ca7903f940f..88121c93775 100644 --- a/admin/tool/usertours/amd/build/usertours.min.js +++ b/admin/tool/usertours/amd/build/usertours.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 ("tool_usertours/usertours",["exports","./tour","core/templates","core/log","core/notification","./repository","core/pending","./events"],function(a,b,c,d,e,f,g,h){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.resetTourState=a.init=void 0;b=k(b);c=k(c);d=k(d);e=k(e);f=j(f);g=k(g);var n="undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};function i(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;i=function(){return a};return a}function j(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=i();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 f=d?Object.getOwnPropertyDescriptor(a,e):null;if(f&&(f.get||f.set)){Object.defineProperty(c,e,f)}else{c[e]=a[e]}}}c.default=a;if(b){b.set(a,c)}return c}function k(a){return a&&a.__esModule?a:{default:a}}function l(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){c(a);return}if(h.done){b(i)}else{Promise.resolve(i).then(d,e)}}function m(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var h=a.apply(b,c);function f(a){l(h,d,e,f,g,"next",a)}function g(a){l(h,d,e,f,g,"throw",a)}f(void 0)})}}var o=null,p=null,q=function(a,b){return a.find(function(a){return b.some(function(b){if(b&&b.filterMatches){return b.filterMatches(a)}return!0})})},r=function(){var a=m(regeneratorRuntime.mark(function a(b,c){var d,e,f,g;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:d=[];c.forEach(function(a){d.push("function"==typeof n.define&&n.define.amd?new Promise(function(b,c){n.require(["tool_usertours/filter_".concat(a)],b,c)}):"undefined"!=typeof module&&module.exports&&"undefined"!=typeof require||"undefined"!=typeof module&&module.component&&n.require&&"component"===n.require.loader?Promise.resolve(require(("tool_usertours/filter_".concat(a)))):Promise.resolve(n["tool_usertours/filter_".concat(a)]))});a.next=4;return Promise.all(d);case 4:e=a.sent;f=q(b,e);if(f){a.next=8;break}return a.abrupt("return");case 8:p=f.tourId;g=f.startTour;if("undefined"==typeof g){g=!0}if(g){s(p)}u();document.querySelector("body").addEventListener("click",function(a){var b=a.target.closest("[data-action=\"tool_usertours/resetpagetour\"]");if(b){a.preventDefault();y(p)}});case 14:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}();a.init=r;var s=function(){var a=m(regeneratorRuntime.mark(function a(b){var d,h,i,j;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:d=new g.default("admin_usertour_fetchTour:".concat(b));a.prev=1;a.next=4;return f.fetchTour(b);case 4:h=a.sent;if(!h.hasOwnProperty("tourconfig")){d.resolve()}a.next=8;return c.default.renderForPromise("tool_usertours/tourstep",h.tourconfig);case 8:i=a.sent;j=i.html;v(b,j,h.tourconfig);d.resolve();a.next=18;break;case 14:a.prev=14;a.t0=a["catch"](1);d.resolve();e.default.exception(a.t0);case 18:case"end":return a.stop();}}},a,null,[[1,14]])}));return function(){return a.apply(this,arguments)}}(),t=function(){var a=document.querySelector(".tool_usertours-resettourcontainer");if(a){return a}a=document.querySelector(".logininfo");if(a){return a}a=document.querySelector("footer");if(a){return a}return document.body},u=function(){var a=new g.default("admin_usertour_addResetLink");c.default.render("tool_usertours/resettour",{}).then(function(a,b){c.default.appendNodeContents(t(),a,b)}).catch().then(a.resolve).catch()},v=function(a,c,d){if(o&&o.tourRunning){o.endTour();o=null}document.addEventListener(h.eventTypes.tourEnded,x);document.addEventListener(h.eventTypes.stepRenderer,w);d.tourName=d.name;delete d.name;d.template=c;d.steps=d.steps.map(function(a){if("undefined"!=typeof a.element){a.target=a.element;delete a.element}if("undefined"!=typeof a.reflex){a.moveOnClick=!!a.reflex;delete a.reflex}if("undefined"!=typeof a.content){a.body=a.content;delete a.content}return a});o=new b.default(d);return o.startTour()},w=function(a){var b=a.detail.tour,c=b.getStepConfig(b.getCurrentStepNumber());f.markStepShown(c.stepid,p,b.getCurrentStepNumber()).catch(d.default.error)},x=function(a){document.removeEventListener(h.eventTypes.tourEnded,x);document.removeEventListener(h.eventTypes.stepRenderer,w);var b=a.detail.tour,c=b.getStepConfig(b.getCurrentStepNumber());f.markTourComplete(c.stepid,p,b.getCurrentStepNumber()).catch(d.default.error)},y=function(a){return f.resetTourState(a).then(function(a){if(a.startTour){s(a.startTour)}}).catch(e.default.exception)};a.resetTourState=y}); +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 ("tool_usertours/usertours",["exports","./tour","core/templates","core/log","core/notification","./repository","core/pending","./events"],function(a,b,c,d,e,f,g,h){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.resetTourState=a.init=void 0;b=k(b);c=k(c);d=k(d);e=k(e);f=j(f);g=k(g);var n="undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};function i(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;i=function(){return a};return a}function j(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=i();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 f=d?Object.getOwnPropertyDescriptor(a,e):null;if(f&&(f.get||f.set)){Object.defineProperty(c,e,f)}else{c[e]=a[e]}}}c.default=a;if(b){b.set(a,c)}return c}function k(a){return a&&a.__esModule?a:{default:a}}function l(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){c(a);return}if(h.done){b(i)}else{Promise.resolve(i).then(d,e)}}function m(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var h=a.apply(b,c);function f(a){l(h,d,e,f,g,"next",a)}function g(a){l(h,d,e,f,g,"throw",a)}f(void 0)})}}var o=null,p=null,q=function(a,b){return a.find(function(a){return b.some(function(b){if(b&&b.filterMatches){return b.filterMatches(a)}return!0})})},r=function(){var a=m(regeneratorRuntime.mark(function a(b,c){var d,e,f,g;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:d=[];c.forEach(function(a){d.push("function"==typeof n.define&&n.define.amd?new Promise(function(b,c){n.require(["tool_usertours/filter_".concat(a)],b,c)}):"undefined"!=typeof module&&module.exports&&"undefined"!=typeof require||"undefined"!=typeof module&&module.component&&n.require&&"component"===n.require.loader?Promise.resolve(require(("tool_usertours/filter_".concat(a)))):Promise.resolve(n["tool_usertours/filter_".concat(a)]))});a.next=4;return Promise.all(d);case 4:e=a.sent;f=q(b,e);if(f){a.next=8;break}return a.abrupt("return");case 8:p=f.tourId;g=f.startTour;if("undefined"==typeof g){g=!0}if(g){s(p)}u();document.querySelector("body").addEventListener("click",function(a){var b=a.target.closest("#resetpagetour");if(b){a.preventDefault();y(p)}});case 14:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}();a.init=r;var s=function(){var a=m(regeneratorRuntime.mark(function a(b){var d,h,i,j;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:d=new g.default("admin_usertour_fetchTour:".concat(b));a.prev=1;a.next=4;return f.fetchTour(b);case 4:h=a.sent;if(!h.hasOwnProperty("tourconfig")){d.resolve()}a.next=8;return c.default.renderForPromise("tool_usertours/tourstep",h.tourconfig);case 8:i=a.sent;j=i.html;v(b,j,h.tourconfig);d.resolve();a.next=18;break;case 14:a.prev=14;a.t0=a["catch"](1);d.resolve();e.default.exception(a.t0);case 18:case"end":return a.stop();}}},a,null,[[1,14]])}));return function(){return a.apply(this,arguments)}}(),t=function(){var a=document.querySelector(".tool_usertours-resettourcontainer");if(a){return a}a=document.querySelector(".logininfo");if(a){return a}a=document.querySelector("footer");if(a){return a}return document.body},u=function(){var a=new g.default("admin_usertour_addResetLink");c.default.render("tool_usertours/resettour",{}).then(function(a,b){c.default.appendNodeContents(t(),a,b)}).catch().then(a.resolve).catch()},v=function(a,c,d){if(o&&o.tourRunning){o.endTour();o=null}document.addEventListener(h.eventTypes.tourEnded,x);document.addEventListener(h.eventTypes.stepRenderer,w);d.tourName=d.name;delete d.name;d.template=c;d.steps=d.steps.map(function(a){if("undefined"!=typeof a.element){a.target=a.element;delete a.element}if("undefined"!=typeof a.reflex){a.moveOnClick=!!a.reflex;delete a.reflex}if("undefined"!=typeof a.content){a.body=a.content;delete a.content}return a});o=new b.default(d);return o.startTour()},w=function(a){var b=a.detail.tour,c=b.getStepConfig(b.getCurrentStepNumber());f.markStepShown(c.stepid,p,b.getCurrentStepNumber()).catch(d.default.error)},x=function(a){document.removeEventListener(h.eventTypes.tourEnded,x);document.removeEventListener(h.eventTypes.stepRenderer,w);var b=a.detail.tour,c=b.getStepConfig(b.getCurrentStepNumber());f.markTourComplete(c.stepid,p,b.getCurrentStepNumber()).catch(d.default.error)},y=function(a){return f.resetTourState(a).then(function(a){if(a.startTour){s(a.startTour)}}).catch(e.default.exception)};a.resetTourState=y}); //# sourceMappingURL=usertours.min.js.map diff --git a/admin/tool/usertours/amd/build/usertours.min.js.map b/admin/tool/usertours/amd/build/usertours.min.js.map index 8149e0891fc..3c2c3357031 100644 --- a/admin/tool/usertours/amd/build/usertours.min.js.map +++ b/admin/tool/usertours/amd/build/usertours.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/usertours.js"],"names":["currentTour","tourId","findMatchingTour","tourDetails","filters","find","tour","some","filter","filterMatches","init","requirements","forEach","push","Promise","all","filterPlugins","matchingTour","startTour","fetchTour","addResetLink","document","querySelector","addEventListener","e","resetLink","target","closest","preventDefault","resetTourState","pendingPromise","Pending","tourRepository","response","hasOwnProperty","resolve","Templates","renderForPromise","tourconfig","html","startBootstrapTour","notification","exception","getPreferredResetLocation","location","body","render","then","js","appendNodeContents","catch","template","tourConfig","tourRunning","endTour","eventTypes","tourEnded","markTourComplete","stepRenderer","markStepShown","tourName","name","steps","map","step","element","reflex","moveOnClick","content","BootstrapTour","detail","stepConfig","getStepConfig","getCurrentStepNumber","stepid","log","error","removeEventListener"],"mappings":"2iBAMA,OACA,OACA,OACA,OACA,OACA,O,sgCAGIA,CAAAA,CAAW,CAAG,I,CACdC,CAAM,CAAG,I,CASPC,CAAgB,CAAG,SAACC,CAAD,CAAcC,CAAd,CAA0B,CAC/C,MAAOD,CAAAA,CAAW,CAACE,IAAZ,CAAiB,SAAAC,CAAI,QAAIF,CAAAA,CAAO,CAACG,IAAR,CAAa,SAAAC,CAAM,CAAI,CACnD,GAAIA,CAAM,EAAIA,CAAM,CAACC,aAArB,CAAoC,CAChC,MAAOD,CAAAA,CAAM,CAACC,aAAP,CAAqBH,CAArB,CACV,CAED,QACH,CAN+B,CAAJ,CAArB,CAOV,C,CASYI,CAAI,4CAAG,WAAMP,CAAN,CAAmBC,CAAnB,+FACVO,CADU,CACK,EADL,CAEhBP,CAAO,CAACQ,OAAR,CAAgB,SAAAJ,CAAM,CAAI,CACtBG,CAAY,CAACE,IAAb,gHAAkDL,CAAlD,oOAAkDA,CAAlD,uDAAkDA,CAAlD,IACH,CAFD,EAFgB,eAMYM,CAAAA,OAAO,CAACC,GAAR,CAAYJ,CAAZ,CANZ,QAMVK,CANU,QAQVC,CARU,CAQKf,CAAgB,CAACC,CAAD,CAAca,CAAd,CARrB,IASXC,CATW,kDAch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CACIc,CAAU,CAACG,MADf,CAEIzE,CAFJ,CAGIK,CAAI,CAACmE,oBAAL,EAHJ,EAIEvB,KAJF,CAIQyB,UAAIC,KAJZ,CAKH,C,CASY/C,CAAc,CAAG,SAAA5B,CAAM,QAAI+B,CAAAA,CAAc,CAACH,cAAf,CAA8B5B,CAA9B,EACvC8C,IADuC,CAClC,SAAAd,CAAQ,CAAI,CACd,GAAIA,CAAQ,CAACf,SAAb,CAAwB,CACpBC,CAAS,CAACc,CAAQ,CAACf,SAAV,CACZ,CAEJ,CANuC,EAMrCgC,KANqC,CAM/BT,UAAaC,SANkB,CAAJ,C","sourcesContent":["/**\n * User tour control library.\n *\n * @module tool_usertours/usertours\n * @copyright 2016 Andrew Nicols \n */\nimport BootstrapTour from './tour';\nimport Templates from 'core/templates';\nimport log from 'core/log';\nimport notification from 'core/notification';\nimport * as tourRepository from './repository';\nimport Pending from 'core/pending';\nimport {eventTypes} from './events';\n\nlet currentTour = null;\nlet tourId = null;\n\n/**\n * Find the first matching tour.\n *\n * @param {object[]} tourDetails\n * @param {object[]} filters\n * @returns {null|object}\n */\nconst findMatchingTour = (tourDetails, filters) => {\n return tourDetails.find(tour => filters.some(filter => {\n if (filter && filter.filterMatches) {\n return filter.filterMatches(tour);\n }\n\n return true;\n }));\n};\n\n/**\n * Initialise the user tour for the current page.\n *\n * @method init\n * @param {Array} tourDetails The matching tours for this page.\n * @param {Array} filters The names of all client side filters.\n */\nexport const init = async(tourDetails, filters) => {\n const requirements = [];\n filters.forEach(filter => {\n requirements.push(import(`tool_usertours/filter_${filter}`));\n });\n\n const filterPlugins = await Promise.all(requirements);\n\n const matchingTour = findMatchingTour(tourDetails, filterPlugins);\n if (!matchingTour) {\n return;\n }\n\n // Only one tour per page is allowed.\n tourId = matchingTour.tourId;\n\n let startTour = matchingTour.startTour;\n if (typeof startTour === 'undefined') {\n startTour = true;\n }\n\n if (startTour) {\n // Fetch the tour configuration.\n fetchTour(tourId);\n }\n\n addResetLink();\n\n // Watch for the reset link.\n document.querySelector('body').addEventListener('click', e => {\n const resetLink = e.target.closest('[data-action=\"tool_usertours/resetpagetour\"]');\n if (resetLink) {\n e.preventDefault();\n resetTourState(tourId);\n }\n });\n};\n\n/**\n * Fetch the configuration specified tour, and start the tour when it has been fetched.\n *\n * @method fetchTour\n * @param {Number} tourId The ID of the tour to start.\n */\nconst fetchTour = async tourId => {\n const pendingPromise = new Pending(`admin_usertour_fetchTour:${tourId}`);\n\n try {\n const response = await tourRepository.fetchTour(tourId);\n if (!response.hasOwnProperty('tourconfig')) {\n pendingPromise.resolve();\n }\n\n const {html} = await Templates.renderForPromise('tool_usertours/tourstep', response.tourconfig);\n startBootstrapTour(tourId, html, response.tourconfig);\n\n pendingPromise.resolve();\n } catch (error) {\n pendingPromise.resolve();\n notification.exception(error);\n }\n};\n\nconst getPreferredResetLocation = () => {\n let location = document.querySelector('.tool_usertours-resettourcontainer');\n if (location) {\n return location;\n }\n\n location = document.querySelector('.logininfo');\n if (location) {\n return location;\n }\n\n location = document.querySelector('footer');\n if (location) {\n return location;\n }\n\n return document.body;\n};\n\n/**\n * Add a reset link to the page.\n *\n * @method addResetLink\n */\nconst addResetLink = () => {\n const pendingPromise = new Pending('admin_usertour_addResetLink');\n\n Templates.render('tool_usertours/resettour', {})\n .then(function(html, js) {\n // Append the link to the most suitable place on the page with fallback to legacy selectors and finally the body if\n // there is no better place.\n Templates.appendNodeContents(getPreferredResetLocation(), html, js);\n\n return;\n })\n .catch()\n .then(pendingPromise.resolve)\n .catch();\n};\n\n/**\n * Start the specified tour.\n *\n * @method startBootstrapTour\n * @param {Number} tourId The ID of the tour to start.\n * @param {String} template The template to use.\n * @param {Object} tourConfig The tour configuration.\n * @return {Object}\n */\nconst startBootstrapTour = (tourId, template, tourConfig) => {\n if (currentTour && currentTour.tourRunning) {\n // End the current tour.\n currentTour.endTour();\n currentTour = null;\n }\n\n document.addEventListener(eventTypes.tourEnded, markTourComplete);\n document.addEventListener(eventTypes.stepRenderer, markStepShown);\n\n // Sort out the tour name.\n tourConfig.tourName = tourConfig.name;\n delete tourConfig.name;\n\n // Add the template to the configuration.\n // This enables translations of the buttons.\n tourConfig.template = template;\n\n tourConfig.steps = tourConfig.steps.map(function(step) {\n if (typeof step.element !== 'undefined') {\n step.target = step.element;\n delete step.element;\n }\n\n if (typeof step.reflex !== 'undefined') {\n step.moveOnClick = !!step.reflex;\n delete step.reflex;\n }\n\n if (typeof step.content !== 'undefined') {\n step.body = step.content;\n delete step.content;\n }\n\n return step;\n });\n\n currentTour = new BootstrapTour(tourConfig);\n return currentTour.startTour();\n};\n\n/**\n * Mark the specified step as being shownd by the user.\n *\n * @method markStepShown\n * @param {Event} e\n */\nconst markStepShown = e => {\n const tour = e.detail.tour;\n const stepConfig = tour.getStepConfig(tour.getCurrentStepNumber());\n tourRepository.markStepShown(\n stepConfig.stepid,\n tourId,\n tour.getCurrentStepNumber()\n ).catch(log.error);\n};\n\n/**\n * Mark the specified tour as being completed by the user.\n *\n * @method markTourComplete\n * @param {Event} e\n * @listens tool_usertours/stepRendered\n */\nconst markTourComplete = e => {\n document.removeEventListener(eventTypes.tourEnded, markTourComplete);\n document.removeEventListener(eventTypes.stepRenderer, markStepShown);\n\n const tour = e.detail.tour;\n const stepConfig = tour.getStepConfig(tour.getCurrentStepNumber());\n tourRepository.markTourComplete(\n stepConfig.stepid,\n tourId,\n tour.getCurrentStepNumber()\n ).catch(log.error);\n};\n\n/**\n * Reset the state, and restart the the tour on the current page.\n *\n * @method resetTourState\n * @param {Number} tourId The ID of the tour to start.\n * @returns {Promise}\n */\nexport const resetTourState = tourId => tourRepository.resetTourState(tourId)\n.then(response => {\n if (response.startTour) {\n fetchTour(response.startTour);\n }\n return;\n}).catch(notification.exception);\n"],"file":"usertours.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/usertours.js"],"names":["currentTour","tourId","findMatchingTour","tourDetails","filters","find","tour","some","filter","filterMatches","init","requirements","forEach","push","Promise","all","filterPlugins","matchingTour","startTour","fetchTour","addResetLink","document","querySelector","addEventListener","e","resetLink","target","closest","preventDefault","resetTourState","pendingPromise","Pending","tourRepository","response","hasOwnProperty","resolve","Templates","renderForPromise","tourconfig","html","startBootstrapTour","notification","exception","getPreferredResetLocation","location","body","render","then","js","appendNodeContents","catch","template","tourConfig","tourRunning","endTour","eventTypes","tourEnded","markTourComplete","stepRenderer","markStepShown","tourName","name","steps","map","step","element","reflex","moveOnClick","content","BootstrapTour","detail","stepConfig","getStepConfig","getCurrentStepNumber","stepid","log","error","removeEventListener"],"mappings":"2iBAMA,OACA,OACA,OACA,OACA,OACA,O,sgCAGIA,CAAAA,CAAW,CAAG,I,CACdC,CAAM,CAAG,I,CASPC,CAAgB,CAAG,SAACC,CAAD,CAAcC,CAAd,CAA0B,CAC/C,MAAOD,CAAAA,CAAW,CAACE,IAAZ,CAAiB,SAAAC,CAAI,QAAIF,CAAAA,CAAO,CAACG,IAAR,CAAa,SAAAC,CAAM,CAAI,CACnD,GAAIA,CAAM,EAAIA,CAAM,CAACC,aAArB,CAAoC,CAChC,MAAOD,CAAAA,CAAM,CAACC,aAAP,CAAqBH,CAArB,CACV,CAED,QACH,CAN+B,CAAJ,CAArB,CAOV,C,CASYI,CAAI,4CAAG,WAAMP,CAAN,CAAmBC,CAAnB,+FACVO,CADU,CACK,EADL,CAEhBP,CAAO,CAACQ,OAAR,CAAgB,SAAAJ,CAAM,CAAI,CACtBG,CAAY,CAACE,IAAb,gHAAkDL,CAAlD,oOAAkDA,CAAlD,uDAAkDA,CAAlD,IACH,CAFD,EAFgB,eAMYM,CAAAA,OAAO,CAACC,GAAR,CAAYJ,CAAZ,CANZ,QAMVK,CANU,QAQVC,CARU,CAQKf,CAAgB,CAACC,CAAD,CAAca,CAAd,CARrB,IASXC,CATW,kDAchBhB,CAAM,CAAGgB,CAAY,CAAChB,MAAtB,CAEIiB,CAhBY,CAgBAD,CAAY,CAACC,SAhBb,CAiBhB,GAAyB,WAArB,QAAOA,CAAAA,CAAX,CA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AAc,CAAG,SAAA5B,CAAM,QAAI+B,CAAAA,CAAc,CAACH,cAAf,CAA8B5B,CAA9B,EACvC8C,IADuC,CAClC,SAAAd,CAAQ,CAAI,CACd,GAAIA,CAAQ,CAACf,SAAb,CAAwB,CACpBC,CAAS,CAACc,CAAQ,CAACf,SAAV,CACZ,CAEJ,CANuC,EAMrCgC,KANqC,CAM/BT,UAAaC,SANkB,CAAJ,C","sourcesContent":["/**\n * User tour control library.\n *\n * @module tool_usertours/usertours\n * @copyright 2016 Andrew Nicols \n */\nimport BootstrapTour from './tour';\nimport Templates from 'core/templates';\nimport log from 'core/log';\nimport notification from 'core/notification';\nimport * as tourRepository from './repository';\nimport Pending from 'core/pending';\nimport {eventTypes} from './events';\n\nlet currentTour = null;\nlet tourId = null;\n\n/**\n * Find the first matching tour.\n *\n * @param {object[]} tourDetails\n * @param {object[]} filters\n * @returns {null|object}\n */\nconst findMatchingTour = (tourDetails, filters) => {\n return tourDetails.find(tour => filters.some(filter => {\n if (filter && filter.filterMatches) {\n return filter.filterMatches(tour);\n }\n\n return true;\n }));\n};\n\n/**\n * Initialise the user tour for the current page.\n *\n * @method init\n * @param {Array} tourDetails The matching tours for this page.\n * @param {Array} filters The names of all client side filters.\n */\nexport const init = async(tourDetails, filters) => {\n const requirements = [];\n filters.forEach(filter => {\n requirements.push(import(`tool_usertours/filter_${filter}`));\n });\n\n const filterPlugins = await Promise.all(requirements);\n\n const matchingTour = findMatchingTour(tourDetails, filterPlugins);\n if (!matchingTour) {\n return;\n }\n\n // Only one tour per page is allowed.\n tourId = matchingTour.tourId;\n\n let startTour = matchingTour.startTour;\n if (typeof startTour === 'undefined') {\n startTour = true;\n }\n\n if (startTour) {\n // Fetch the tour configuration.\n fetchTour(tourId);\n }\n\n addResetLink();\n\n // Watch for the reset link.\n document.querySelector('body').addEventListener('click', e => {\n const resetLink = e.target.closest('#resetpagetour');\n if (resetLink) {\n e.preventDefault();\n resetTourState(tourId);\n }\n });\n};\n\n/**\n * Fetch the configuration specified tour, and start the tour when it has been fetched.\n *\n * @method fetchTour\n * @param {Number} tourId The ID of the tour to start.\n */\nconst fetchTour = async tourId => {\n const pendingPromise = new Pending(`admin_usertour_fetchTour:${tourId}`);\n\n try {\n const response = await tourRepository.fetchTour(tourId);\n if (!response.hasOwnProperty('tourconfig')) {\n pendingPromise.resolve();\n }\n\n const {html} = await Templates.renderForPromise('tool_usertours/tourstep', response.tourconfig);\n startBootstrapTour(tourId, html, response.tourconfig);\n\n pendingPromise.resolve();\n } catch (error) {\n pendingPromise.resolve();\n notification.exception(error);\n }\n};\n\nconst getPreferredResetLocation = () => {\n let location = document.querySelector('.tool_usertours-resettourcontainer');\n if (location) {\n return location;\n }\n\n location = document.querySelector('.logininfo');\n if (location) {\n return location;\n }\n\n location = document.querySelector('footer');\n if (location) {\n return location;\n }\n\n return document.body;\n};\n\n/**\n * Add a reset link to the page.\n *\n * @method addResetLink\n */\nconst addResetLink = () => {\n const pendingPromise = new Pending('admin_usertour_addResetLink');\n\n Templates.render('tool_usertours/resettour', {})\n .then(function(html, js) {\n // Append the link to the most suitable place on the page with fallback to legacy selectors and finally the body if\n // there is no better place.\n Templates.appendNodeContents(getPreferredResetLocation(), html, js);\n\n return;\n })\n .catch()\n .then(pendingPromise.resolve)\n .catch();\n};\n\n/**\n * Start the specified tour.\n *\n * @method startBootstrapTour\n * @param {Number} tourId The ID of the tour to start.\n * @param {String} template The template to use.\n * @param {Object} tourConfig The tour configuration.\n * @return {Object}\n */\nconst startBootstrapTour = (tourId, template, tourConfig) => {\n if (currentTour && currentTour.tourRunning) {\n // End the current tour.\n currentTour.endTour();\n currentTour = null;\n }\n\n document.addEventListener(eventTypes.tourEnded, markTourComplete);\n document.addEventListener(eventTypes.stepRenderer, markStepShown);\n\n // Sort out the tour name.\n tourConfig.tourName = tourConfig.name;\n delete tourConfig.name;\n\n // Add the template to the configuration.\n // This enables translations of the buttons.\n tourConfig.template = template;\n\n tourConfig.steps = tourConfig.steps.map(function(step) {\n if (typeof step.element !== 'undefined') {\n step.target = step.element;\n delete step.element;\n }\n\n if (typeof step.reflex !== 'undefined') {\n step.moveOnClick = !!step.reflex;\n delete step.reflex;\n }\n\n if (typeof step.content !== 'undefined') {\n step.body = step.content;\n delete step.content;\n }\n\n return step;\n });\n\n currentTour = new BootstrapTour(tourConfig);\n return currentTour.startTour();\n};\n\n/**\n * Mark the specified step as being shownd by the user.\n *\n * @method markStepShown\n * @param {Event} e\n */\nconst markStepShown = e => {\n const tour = e.detail.tour;\n const stepConfig = tour.getStepConfig(tour.getCurrentStepNumber());\n tourRepository.markStepShown(\n stepConfig.stepid,\n tourId,\n tour.getCurrentStepNumber()\n ).catch(log.error);\n};\n\n/**\n * Mark the specified tour as being completed by the user.\n *\n * @method markTourComplete\n * @param {Event} e\n * @listens tool_usertours/stepRendered\n */\nconst markTourComplete = e => {\n document.removeEventListener(eventTypes.tourEnded, markTourComplete);\n document.removeEventListener(eventTypes.stepRenderer, markStepShown);\n\n const tour = e.detail.tour;\n const stepConfig = tour.getStepConfig(tour.getCurrentStepNumber());\n tourRepository.markTourComplete(\n stepConfig.stepid,\n tourId,\n tour.getCurrentStepNumber()\n ).catch(log.error);\n};\n\n/**\n * Reset the state, and restart the the tour on the current page.\n *\n * @method resetTourState\n * @param {Number} tourId The ID of the tour to start.\n * @returns {Promise}\n */\nexport const resetTourState = tourId => tourRepository.resetTourState(tourId)\n.then(response => {\n if (response.startTour) {\n fetchTour(response.startTour);\n }\n return;\n}).catch(notification.exception);\n"],"file":"usertours.min.js"} \ No newline at end of file diff --git a/admin/tool/usertours/amd/src/usertours.js b/admin/tool/usertours/amd/src/usertours.js index 28aca149e62..316b32c7783 100644 --- a/admin/tool/usertours/amd/src/usertours.js +++ b/admin/tool/usertours/amd/src/usertours.js @@ -69,7 +69,7 @@ export const init = async(tourDetails, filters) => { // Watch for the reset link. document.querySelector('body').addEventListener('click', e => { - const resetLink = e.target.closest('[data-action="tool_usertours/resetpagetour"]'); + const resetLink = e.target.closest('#resetpagetour'); if (resetLink) { e.preventDefault(); resetTourState(tourId); diff --git a/admin/tool/usertours/templates/resettour.mustache b/admin/tool/usertours/templates/resettour.mustache index b1fe728f89e..ade32e8e187 100644 --- a/admin/tool/usertours/templates/resettour.mustache +++ b/admin/tool/usertours/templates/resettour.mustache @@ -23,5 +23,5 @@ {} }} diff --git a/admin/tool/usertours/tests/behat/reset_tour.feature b/admin/tool/usertours/tests/behat/reset_tour.feature new file mode 100644 index 00000000000..4806746d49a --- /dev/null +++ b/admin/tool/usertours/tests/behat/reset_tour.feature @@ -0,0 +1,28 @@ +@tool @tool_usertours +Feature: Reset a tour + In order to test a tour + As an administrator + I can reset the tour to force it to display again + + Background: + Given I log in as "admin" + And I add a new user tour with: + | Name | First tour | + | Description | My first tour | + | Apply to URL match | FRONTPAGE | + | Tour is enabled | 1 | + | Show with backdrop | 1 | + And I add steps to the "First tour" tour: + | targettype | Title | Content | + | Display in middle of page | Welcome | Welcome tour. | + + @javascript + Scenario: Reset the tour with mobile view + # Changing the window viewport to mobile so we will have the footer section. + Given I change viewport size to "480x800" + And I am on site homepage + And I should see "Welcome" + And I press "Got it" + And I should not see "Welcome" + When I click on "Reset user tour on this page" "link" in the "#page-footer" "css_element" + Then I should see "Welcome" diff --git a/theme/boost/amd/build/footer-popover.min.js b/theme/boost/amd/build/footer-popover.min.js index 4595c5b62a0..eb873f22d31 100644 --- a/theme/boost/amd/build/footer-popover.min.js +++ b/theme/boost/amd/build/footer-popover.min.js @@ -1,2 +1,2 @@ -define ("theme_boost/footer-popover",["exports","jquery","./popover"],function(a,b,c){"use strict";Object.defineProperty(a,"__esModule",{value:!0});Object.defineProperty(a,"Popover",{enumerable:!0,get:function get(){return c.default}});a.init=void 0;b=d(b);c=d(c);function d(a){return a&&a.__esModule?a:{default:a}}var e=function(){var a=document.querySelector("[data-region=\"footer-content-popover\"]"),c=document.querySelector("[data-region=\"footer-container-popover\"]");(0,b.default)("[data-action=\"footer-popover\"]").popover({content:a.innerHTML,container:c,html:!0,placement:"top",customClass:"footer"})};a.init=e}); +define ("theme_boost/footer-popover",["exports","jquery","./popover"],function(a,b,c){"use strict";Object.defineProperty(a,"__esModule",{value:!0});Object.defineProperty(a,"Popover",{enumerable:!0,get:function get(){return c.default}});a.init=void 0;b=d(b);c=d(c);function d(a){return a&&a.__esModule?a:{default:a}}var e=function(){var a=document.querySelector("[data-region=\"footer-container-popover\"]");(0,b.default)("[data-action=\"footer-popover\"]").popover({content:f,container:a,html:!0,placement:"top",customClass:"footer"})};a.init=e;var f=function(){return document.querySelector("[data-region=\"footer-content-popover\"]").innerHTML}}); //# sourceMappingURL=footer-popover.min.js.map diff --git a/theme/boost/amd/build/footer-popover.min.js.map b/theme/boost/amd/build/footer-popover.min.js.map index 9f9bd963c8b..d8d15195f51 100644 --- a/theme/boost/amd/build/footer-popover.min.js.map +++ b/theme/boost/amd/build/footer-popover.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/footer-popover.js"],"names":["init","content","document","querySelector","container","popover","innerHTML","html","placement","customClass"],"mappings":"0PAuBA,OACA,O,mDAEO,GAAMA,CAAAA,CAAI,CAAG,UAAM,IAChBC,CAAAA,CAAO,CAAGC,QAAQ,CAACC,aAAT,CAAuB,0CAAvB,CADM,CAEhBC,CAAS,CAAGF,QAAQ,CAACC,aAAT,CAAuB,4CAAvB,CAFI,CAItB,cAAE,kCAAF,EAAoCE,OAApC,CAA4C,CACxCJ,OAAO,CAAEA,CAAO,CAACK,SADuB,CAExCF,SAAS,CAAEA,CAF6B,CAGxCG,IAAI,GAHoC,CAIxCC,SAAS,CAAE,KAJ6B,CAKxCC,WAAW,CAAE,QAL2B,CAA5C,CAOH,CAXM,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 * Shows the footer content in a popover.\n *\n * @module theme_boost/footer-popover\n * @copyright 2021 Bas Brands\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport Popover from './popover';\n\nexport const init = () => {\n const content = document.querySelector('[data-region=\"footer-content-popover\"]');\n const container = document.querySelector('[data-region=\"footer-container-popover\"]');\n\n $('[data-action=\"footer-popover\"]').popover({\n content: content.innerHTML,\n container: container,\n html: true,\n placement: 'top',\n customClass: 'footer'\n });\n};\n\nexport {\n Popover\n};\n"],"file":"footer-popover.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/footer-popover.js"],"names":["init","container","document","querySelector","popover","content","getFooterContent","html","placement","customClass","innerHTML"],"mappings":"0PAuBA,OACA,O,mDAEO,GAAMA,CAAAA,CAAI,CAAG,UAAM,CACtB,GAAMC,CAAAA,CAAS,CAAGC,QAAQ,CAACC,aAAT,CAAuB,4CAAvB,CAAlB,CAEA,cAAE,kCAAF,EAAoCC,OAApC,CAA4C,CACxCC,OAAO,CAAEC,CAD+B,CAExCL,SAAS,CAAEA,CAF6B,CAGxCM,IAAI,GAHoC,CAIxCC,SAAS,CAAE,KAJ6B,CAKxCC,WAAW,CAAE,QAL2B,CAA5C,CAOH,CAVM,C,SAkBP,GAAMH,CAAAA,CAAgB,CAAG,UAAM,CAC3B,MAAOJ,CAAAA,QAAQ,CAACC,aAAT,CAAuB,0CAAvB,EAAiEO,SAC3E,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 * Shows the footer content in a popover.\n *\n * @module theme_boost/footer-popover\n * @copyright 2021 Bas Brands\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport Popover from './popover';\n\nexport const init = () => {\n const container = document.querySelector('[data-region=\"footer-container-popover\"]');\n\n $('[data-action=\"footer-popover\"]').popover({\n content: getFooterContent,\n container: container,\n html: true,\n placement: 'top',\n customClass: 'footer'\n });\n};\n\n/**\n * Get the footer content for popover.\n *\n * @returns {String} HTML string\n * @private\n */\nconst getFooterContent = () => {\n return document.querySelector('[data-region=\"footer-content-popover\"]').innerHTML;\n};\n\nexport {\n Popover\n};\n"],"file":"footer-popover.min.js"} \ No newline at end of file diff --git a/theme/boost/amd/src/footer-popover.js b/theme/boost/amd/src/footer-popover.js index deb78f513f8..baab9240f30 100644 --- a/theme/boost/amd/src/footer-popover.js +++ b/theme/boost/amd/src/footer-popover.js @@ -25,11 +25,10 @@ import $ from 'jquery'; import Popover from './popover'; export const init = () => { - const content = document.querySelector('[data-region="footer-content-popover"]'); const container = document.querySelector('[data-region="footer-container-popover"]'); $('[data-action="footer-popover"]').popover({ - content: content.innerHTML, + content: getFooterContent, container: container, html: true, placement: 'top', @@ -37,6 +36,16 @@ export const init = () => { }); }; +/** + * Get the footer content for popover. + * + * @returns {String} HTML string + * @private + */ +const getFooterContent = () => { + return document.querySelector('[data-region="footer-content-popover"]').innerHTML; +}; + export { Popover }; diff --git a/theme/boost/tests/behat/reset_tour.feature b/theme/boost/tests/behat/reset_tour.feature new file mode 100644 index 00000000000..4afa3746e56 --- /dev/null +++ b/theme/boost/tests/behat/reset_tour.feature @@ -0,0 +1,30 @@ +@tool @tool_usertours @theme_boost +Feature: Reset a tour for Boost + In order to test a tour + As an administrator + I can reset the tour to force it to display again + + Background: + Given I log in as "admin" + And I add a new user tour with: + | Name | First tour | + | Description | My first tour | + | Apply to URL match | FRONTPAGE | + | Tour is enabled | 1 | + | Show with backdrop | 1 | + And I add steps to the "First tour" tour: + | targettype | Title | Content | + | Display in middle of page | Welcome | Welcome tour. | + + @javascript + Scenario: Reset the tour with desktop view + # Changing the window size to large so we will have the footer button. + Given I change window size to "large" + And I am on site homepage + And I should see "Welcome" + And I press "Got it" + And I should not see "Welcome" + When I click on ".btn-footer-popover" "css_element" in the "#page-footer" "css_element" + Then I should see "Reset user tour on this page" + And I click on "Reset user tour on this page" "link" + And I should see "Welcome"