mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-60268 User tours: Improve placement of Reset tour on page link
This commit is contained in:
parent
d8e9a23c48
commit
4a8dfef030
6 changed files with 50 additions and 13 deletions
|
@ -1 +1 @@
|
||||||
define(["core/ajax","tool_usertours/tour","jquery","core/templates","core/str","core/log","core/notification"],function(a,b,c,d,e,f,g){var h={tourId:null,currentTour:null,context:null,init:function(a,b,d){h.tourId=a,h.context=d,"undefined"==typeof b&&(b=!0),b&&h.fetchTour(a),h.addResetLink(),c("body").on("click",'[data-action="tool_usertours/resetpagetour"]',function(a){a.preventDefault(),h.resetTourState(h.tourId)})},fetchTour:function(b){c.when(a.call([{methodname:"tool_usertours_fetch_and_start_tour",args:{tourid:b,context:h.context,pageurl:window.location.href}}])[0],d.render("tool_usertours/tourstep",{})).then(function(a,c){h.startBootstrapTour(b,c[0],a.tourconfig)}).fail(g.exception)},addResetLink:function(){e.get_string("resettouronpage","tool_usertours").done(function(a){c("footer, .logininfo").last().append('<div class="usertour"><a href="#" data-action="tool_usertours/resetpagetour">'+a+"</a></div>")})},startBootstrapTour:function(a,c,d){h.currentTour&&(d.onEnd=null,h.currentTour.endTour(),delete h.currentTour),d.eventHandlers={afterEnd:[h.markTourComplete],afterRender:[h.markStepShown]},d.tourName=d.name,delete d.name,d.template=c,d.steps=d.steps.map(function(a){return"undefined"!=typeof a.element&&(a.target=a.element,delete a.element),"undefined"!=typeof a.reflex&&(a.moveOnClick=!!a.reflex,delete a.reflex),"undefined"!=typeof a.content&&(a.body=a.content,delete a.content),a}),h.currentTour=new b(d),h.currentTour.startTour()},markStepShown:function(){var b=this.getStepConfig(this.getCurrentStepNumber());c.when(a.call([{methodname:"tool_usertours_step_shown",args:{tourid:h.tourId,context:h.context,pageurl:window.location.href,stepid:b.stepid,stepindex:this.getCurrentStepNumber()}}])[0]).fail(f.error)},markTourComplete:function(){var b=this.getStepConfig(this.getCurrentStepNumber());c.when(a.call([{methodname:"tool_usertours_complete_tour",args:{tourid:h.tourId,context:h.context,pageurl:window.location.href,stepid:b.stepid,stepindex:this.getCurrentStepNumber()}}])[0]).fail(f.error)},resetTourState:function(b){c.when(a.call([{methodname:"tool_usertours_reset_tour",args:{tourid:b,context:h.context,pageurl:window.location.href}}])[0]).then(function(a){a.startTour&&h.fetchTour(a.startTour)}).fail(g.exception)}};return{init:h.init,resetTourState:h.resetTourState}});
|
define(["core/ajax","tool_usertours/tour","jquery","core/templates","core/str","core/log","core/notification"],function(a,b,c,d,e,f,g){var h={tourId:null,currentTour:null,context:null,init:function(a,b,d){h.tourId=a,h.context=d,"undefined"==typeof b&&(b=!0),b&&h.fetchTour(a),h.addResetLink(),c("body").on("click",'[data-action="tool_usertours/resetpagetour"]',function(a){a.preventDefault(),h.resetTourState(h.tourId)})},fetchTour:function(b){c.when(a.call([{methodname:"tool_usertours_fetch_and_start_tour",args:{tourid:b,context:h.context,pageurl:window.location.href}}])[0],d.render("tool_usertours/tourstep",{})).then(function(a,c){h.startBootstrapTour(b,c[0],a.tourconfig)}).fail(g.exception)},addResetLink:function(){var a;a=c(c(".tool_usertours-resettourcontainer").length?".tool_usertours-resettourcontainer":c(".logininfo").length?".logininfo":c("footer").length?"footer":"body"),d.render("tool_usertours/resettour",{}).done(function(b){a.append(b)})},startBootstrapTour:function(a,c,d){h.currentTour&&(d.onEnd=null,h.currentTour.endTour(),delete h.currentTour),d.eventHandlers={afterEnd:[h.markTourComplete],afterRender:[h.markStepShown]},d.tourName=d.name,delete d.name,d.template=c,d.steps=d.steps.map(function(a){return"undefined"!=typeof a.element&&(a.target=a.element,delete a.element),"undefined"!=typeof a.reflex&&(a.moveOnClick=!!a.reflex,delete a.reflex),"undefined"!=typeof a.content&&(a.body=a.content,delete a.content),a}),h.currentTour=new b(d),h.currentTour.startTour()},markStepShown:function(){var b=this.getStepConfig(this.getCurrentStepNumber());c.when(a.call([{methodname:"tool_usertours_step_shown",args:{tourid:h.tourId,context:h.context,pageurl:window.location.href,stepid:b.stepid,stepindex:this.getCurrentStepNumber()}}])[0]).fail(f.error)},markTourComplete:function(){var b=this.getStepConfig(this.getCurrentStepNumber());c.when(a.call([{methodname:"tool_usertours_complete_tour",args:{tourid:h.tourId,context:h.context,pageurl:window.location.href,stepid:b.stepid,stepindex:this.getCurrentStepNumber()}}])[0]).fail(f.error)},resetTourState:function(b){c.when(a.call([{methodname:"tool_usertours_reset_tour",args:{tourid:b,context:h.context,pageurl:window.location.href}}])[0]).then(function(a){a.startTour&&h.fetchTour(a.startTour)}).fail(g.exception)}};return{init:h.init,resetTourState:h.resetTourState}});
|
|
@ -78,18 +78,22 @@ function(ajax, BootstrapTour, $, templates, str, log, notification) {
|
||||||
* @method addResetLink
|
* @method addResetLink
|
||||||
*/
|
*/
|
||||||
addResetLink: function() {
|
addResetLink: function() {
|
||||||
str.get_string('resettouronpage', 'tool_usertours')
|
var ele;
|
||||||
.done(function(s) {
|
// Append the link to the most suitable place on the page
|
||||||
// Grab the last item in the page of these.
|
// with fallback to legacy selectors and finally the body
|
||||||
$('footer, .logininfo')
|
// if there is no better place.
|
||||||
.last()
|
if ($('.tool_usertours-resettourcontainer').length) {
|
||||||
.append(
|
ele = $('.tool_usertours-resettourcontainer');
|
||||||
'<div class="usertour">' +
|
} else if ($('.logininfo').length) {
|
||||||
'<a href="#" data-action="tool_usertours/resetpagetour">' +
|
ele = $('.logininfo');
|
||||||
s +
|
} else if ($('footer').length) {
|
||||||
'</a>' +
|
ele = $('footer');
|
||||||
'</div>'
|
} else {
|
||||||
);
|
ele = $('body');
|
||||||
|
}
|
||||||
|
templates.render('tool_usertours/resettour', {})
|
||||||
|
.done(function(template) {
|
||||||
|
ele.append(template);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
27
admin/tool/usertours/templates/resettour.mustache
Normal file
27
admin/tool/usertours/templates/resettour.mustache
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
{{!
|
||||||
|
This file is part of Moodle - http://moodle.org/
|
||||||
|
|
||||||
|
Moodle is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Moodle is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
}}
|
||||||
|
{{!
|
||||||
|
@template tool_usertours/resettour
|
||||||
|
|
||||||
|
Adds the Reset user tour on this page link.
|
||||||
|
|
||||||
|
Example context (json):
|
||||||
|
{}
|
||||||
|
}}
|
||||||
|
<div class="usertour">
|
||||||
|
<a href="#" data-action="tool_usertours/resetpagetour">{{#str}}resettouronpage, tool_usertours{{/str}}</a>
|
||||||
|
</div>
|
|
@ -105,6 +105,7 @@
|
||||||
{{/ output.page_doc_link }}
|
{{/ output.page_doc_link }}
|
||||||
|
|
||||||
{{{ output.login_info }}}
|
{{{ output.login_info }}}
|
||||||
|
<div class="tool_usertours-resettourcontainer"></div>
|
||||||
{{{ output.home_link }}}
|
{{{ output.home_link }}}
|
||||||
<nav class="nav navbar-nav hidden-lg-up">
|
<nav class="nav navbar-nav hidden-lg-up">
|
||||||
{{# output.custom_menu_flat }}
|
{{# output.custom_menu_flat }}
|
||||||
|
|
|
@ -75,6 +75,9 @@ echo $OUTPUT->doctype() ?>
|
||||||
<p class="helplink"><?php echo $OUTPUT->page_doc_link(); ?></p>
|
<p class="helplink"><?php echo $OUTPUT->page_doc_link(); ?></p>
|
||||||
<?php
|
<?php
|
||||||
echo $OUTPUT->login_info();
|
echo $OUTPUT->login_info();
|
||||||
|
?>
|
||||||
|
<div class="tool_usertours-resettourcontainer"></div>
|
||||||
|
<?php
|
||||||
echo $OUTPUT->home_link();
|
echo $OUTPUT->home_link();
|
||||||
echo $OUTPUT->standard_footer_html();
|
echo $OUTPUT->standard_footer_html();
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -11,6 +11,8 @@ information provided here is intended especially for theme designer.
|
||||||
access properties from the underlying navigation nodes in the browser - see MDL-59425.
|
access properties from the underlying navigation nodes in the browser - see MDL-59425.
|
||||||
* Navigation between activities via a previous and next link was added to Boost, Clean and Bootstrapbase. This
|
* Navigation between activities via a previous and next link was added to Boost, Clean and Bootstrapbase. This
|
||||||
is made possible by a new function core_renderer->activity_navigation().
|
is made possible by a new function core_renderer->activity_navigation().
|
||||||
|
* Theme designers may now place the Reset tour on this page link where required by adding an empty
|
||||||
|
container (e.g. <div class="tool_usertours-resettourcontainer"></div>) to their layouts.
|
||||||
|
|
||||||
=== 3.3 ===
|
=== 3.3 ===
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue