mirror of
https://github.com/moodle/moodle.git
synced 2025-03-18 14:40:06 +01:00
Merge branch 'MDL-72809-master' of https://github.com/HuongNV13/moodle
This commit is contained in:
commit
b0b9fa7d84
admin/tool/usertours
amd
templates
tests/behat
theme/boost
amd
tests/behat
@ -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
|
||||
|
File diff suppressed because one or more lines are too long
@ -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);
|
||||
|
@ -23,5 +23,5 @@
|
||||
{}
|
||||
}}
|
||||
<div class="usertour">
|
||||
<a href="#" data-action="tool_usertours/resetpagetour">{{#str}}resettouronpage, tool_usertours{{/str}}</a>
|
||||
<a id="resetpagetour" href="#">{{#str}}resettouronpage, tool_usertours{{/str}}</a>
|
||||
</div>
|
||||
|
28
admin/tool/usertours/tests/behat/reset_tour.feature
Normal file
28
admin/tool/usertours/tests/behat/reset_tour.feature
Normal file
@ -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"
|
2
theme/boost/amd/build/footer-popover.min.js
vendored
2
theme/boost/amd/build/footer-popover.min.js
vendored
@ -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
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.\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"}
|
||||
{"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 <http://www.gnu.org/licenses/>.\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"}
|
@ -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
|
||||
};
|
||||
|
30
theme/boost/tests/behat/reset_tour.feature
Normal file
30
theme/boost/tests/behat/reset_tour.feature
Normal file
@ -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"
|
Loading…
x
Reference in New Issue
Block a user