",{"class":"tour-backdrop"}),this.backdrop.backgroundShown=!0,t(e.backdropContainer).append(this.backdrop))},o.prototype._hideBackdrop=function(){return this._hideOverlayElement(),this._hideBackground()},o.prototype._hideBackground=function(){return this.backdrop?(this.backdrop.remove(),this.backdrop.overlay=null,this.backdrop.backgroundShown=!1):void 0},o.prototype._showOverlayElement=function(e,o){var n,r;return n=t(e.element),!n||0===n.length||this.backdrop.overlayElementShown&&!o?void 0:(this.backdrop.overlayElementShown||(this.backdrop.$element=n.addClass("tour-step-backdrop"),this.backdrop.$background=t("
",{"class":"tour-step-background"}),this.backdrop.$background.appendTo(e.backdropContainer),this.backdrop.overlayElementShown=!0),r={width:n.innerWidth(),height:n.innerHeight(),offset:n.offset()},e.backdropPadding&&(r=this._applyBackdropPadding(e.backdropPadding,r)),this.backdrop.$background.width(r.width).height(r.height).offset(r.offset))},o.prototype._hideOverlayElement=function(){return this.backdrop.overlayElementShown?(this.backdrop.$element.removeClass("tour-step-backdrop"),this.backdrop.$background.remove(),this.backdrop.$element=null,this.backdrop.$background=null,this.backdrop.overlayElementShown=!1):void 0},o.prototype._applyBackdropPadding=function(t,e){return"object"==typeof t?(null==t.top&&(t.top=0),null==t.right&&(t.right=0),null==t.bottom&&(t.bottom=0),null==t.left&&(t.left=0),e.offset.top=e.offset.top-t.top,e.offset.left=e.offset.left-t.left,e.width=e.width+t.left+t.right,e.height=e.height+t.top+t.bottom):(e.offset.top=e.offset.top-t,e.offset.left=e.offset.left-t,e.width=e.width+2*t,e.height=e.height+2*t),e},o.prototype._clearTimer=function(){return e.clearTimeout(this._timer),this._timer=null,this._duration=null},o.prototype._getProtocol=function(t){return t=t.split("://"),t.length>1?t[0]:"http"},o.prototype._getHost=function(t){return t=t.split("//"),t=t.length>1?t[1]:t[0],t.split("/")[0]},o.prototype._getPath=function(t){return t.replace(/\/?$/,"").split("?")[0].split("#")[0]},o.prototype._getQuery=function(t){return this._getParams(t,"?")},o.prototype._getHash=function(t){return this._getParams(t,"#")},o.prototype._getParams=function(t,e){var o,n,r,i,s;if(n=t.split(e),1===n.length)return{};for(n=n[1].split("&"),r={},i=0,s=n.length;s>i;i++)o=n[i],o=o.split("="),r[o[0]]=o[1]||"";return r},o.prototype._equal=function(t,e){var o,n;if("[object Object]"==={}.toString.call(t)&&"[object Object]"==={}.toString.call(e)){for(o in t)if(n=t[o],e[o]!==n)return!1;for(o in e)if(n=e[o],t[o]!==n)return!1;return!0}return t===e},o}(),e.Tour=o}(jQuery,window);
\ No newline at end of file
diff --git a/build/js/bootstrap-tour.js b/build/js/bootstrap-tour.js
index 957c9e90..e2455fa8 100644
--- a/build/js/bootstrap-tour.js
+++ b/build/js/bootstrap-tour.js
@@ -38,10 +38,12 @@
keyboard: true,
storage: storage,
debug: false,
+ mustFinish: false,
backdrop: false,
backdropContainer: 'body',
backdropPadding: 0,
redirect: true,
+ frozenContext: {},
orphan: false,
duration: false,
delay: false,
@@ -75,6 +77,19 @@
this;
}
+ Tour.prototype.unfreeze = function() {
+ $('.popover-navigation button').prop('disabled', false);
+ $('.popover-navigation button').removeClass('disabled');
+ if (this._current < 1) {
+ $('.popover-navigation [data-role="prev"]').prop('disabled', true);
+ $('.popover-navigation [data-role="prev"]').addClass('disabled');
+ }
+ if (this._current >= this._options.steps.length - 1) {
+ $('.popover-navigation [data-role="next"]').prop('disabled', true);
+ return $('.popover-navigation [data-role="next"]').addClass('disabled');
+ }
+ };
+
Tour.prototype.addSteps = function(steps) {
var step, _i, _len;
for (_i = 0, _len = steps.length; _i < _len; _i++) {
@@ -116,6 +131,8 @@
onShown: this._options.onShown,
onHide: this._options.onHide,
onHidden: this._options.onHidden,
+ isFrozen: this._options.isFrozen || function() {},
+ frozenContext: this._options.frozenContext,
onNext: this._options.onNext,
onPrev: this._options.onPrev,
onPause: this._options.onPause,
@@ -570,7 +587,7 @@
};
Tour.prototype._template = function(step, i) {
- var $navigation, $next, $prev, $resume, $template, template;
+ var $end, $navigation, $next, $prev, $resume, $template, frozen, template;
template = step.template;
if (this._isOrphan(step) && {}.toString.call(step.orphan) !== '[object Boolean]') {
template = step.orphan;
@@ -579,7 +596,9 @@
$navigation = $template.find('.popover-navigation');
$prev = $navigation.find('[data-role="prev"]');
$next = $navigation.find('[data-role="next"]');
+ $end = $navigation.find('[data-role="end"]');
$resume = $navigation.find('[data-role="pause-resume"]');
+ frozen = step.isFrozen.call(this._options.frozenContext);
if (this._isOrphan(step)) {
$template.addClass('orphan');
}
@@ -587,12 +606,18 @@
if (step.reflex) {
$template.addClass("tour-" + this._options.name + "-reflex");
}
- if (step.prev < 0) {
+ if (step.prev < 0 || frozen) {
$prev.addClass('disabled');
}
- if (step.next < 0) {
+ if (step.next < 0 || frozen) {
$next.addClass('disabled');
}
+ if (frozen) {
+ $end.addClass('disabled');
+ }
+ if (this._options.mustFinish && i + 1 < this._options.steps.length) {
+ $end.addClass('hide');
+ }
if (!step.duration) {
$resume.remove();
}
diff --git a/build/js/bootstrap-tour.min.js b/build/js/bootstrap-tour.min.js
index aacaaa95..ef8fc270 100644
--- a/build/js/bootstrap-tour.min.js
+++ b/build/js/bootstrap-tour.min.js
@@ -19,4 +19,4 @@
* ========================================================================
*/
-!function(t,e){var o,n;return n=e.document,o=function(){function o(o){var n;try{n=e.localStorage}catch(r){n=!1}this._options=t.extend({name:"tour",steps:[],container:"body",autoscroll:!0,keyboard:!0,storage:n,debug:!1,backdrop:!1,backdropContainer:"body",backdropPadding:0,redirect:!0,orphan:!1,duration:!1,delay:!1,basePath:"",template:'
',afterSetState:function(){},afterGetState:function(){},afterRemoveState:function(){},onStart:function(){},onEnd:function(){},onShow:function(){},onShown:function(){},onHide:function(){},onHidden:function(){},onNext:function(){},onPrev:function(){},onPause:function(){},onResume:function(){},onRedirectError:function(){}},o),this._force=!1,this._inited=!1,this._current=null,this.backdrop={overlay:null,$element:null,$background:null,backgroundShown:!1,overlayElementShown:!1}}return o.prototype.addSteps=function(t){var e,o,n;for(o=0,n=t.length;n>o;o++)e=t[o],this.addStep(e);return this},o.prototype.addStep=function(t){return this._options.steps.push(t),this},o.prototype.getStep=function(e){return null!=this._options.steps[e]?t.extend({id:"step-"+e,path:"",host:"",placement:"right",title:"",content:"
",next:e===this._options.steps.length-1?-1:e+1,prev:e-1,animation:!0,container:this._options.container,autoscroll:this._options.autoscroll,backdrop:this._options.backdrop,backdropContainer:this._options.backdropContainer,backdropPadding:this._options.backdropPadding,redirect:this._options.redirect,reflexElement:this._options.steps[e].element,orphan:this._options.orphan,duration:this._options.duration,delay:this._options.delay,template:this._options.template,onShow:this._options.onShow,onShown:this._options.onShown,onHide:this._options.onHide,onHidden:this._options.onHidden,onNext:this._options.onNext,onPrev:this._options.onPrev,onPause:this._options.onPause,onResume:this._options.onResume,onRedirectError:this._options.onRedirectError},this._options.steps[e]):void 0},o.prototype.init=function(t){return this._force=t,this.ended()?(this._debug("Tour ended, init prevented."),this):(this.setCurrentStep(),this._initMouseNavigation(),this._initKeyboardNavigation(),this._onResize(function(t){return function(){return t.showStep(t._current)}}(this)),null!==this._current&&this.showStep(this._current),this._inited=!0,this)},o.prototype.start=function(t){var e;return null==t&&(t=!1),this._inited||this.init(t),null===this._current&&(e=this._makePromise(null!=this._options.onStart?this._options.onStart(this):void 0),this._callOnPromiseDone(e,this.showStep,0)),this},o.prototype.next=function(){var t;return t=this.hideStep(this._current),this._callOnPromiseDone(t,this._showNextStep)},o.prototype.prev=function(){var t;return t=this.hideStep(this._current),this._callOnPromiseDone(t,this._showPrevStep)},o.prototype.goTo=function(t){var e;return e=this.hideStep(this._current),this._callOnPromiseDone(e,this.showStep,t)},o.prototype.end=function(){var o,r;return o=function(o){return function(){return t(n).off("click.tour-"+o._options.name),t(n).off("keyup.tour-"+o._options.name),t(e).off("resize.tour-"+o._options.name),o._setState("end","yes"),o._inited=!1,o._force=!1,o._clearTimer(),null!=o._options.onEnd?o._options.onEnd(o):void 0}}(this),r=this.hideStep(this._current),this._callOnPromiseDone(r,o)},o.prototype.ended=function(){return!this._force&&!!this._getState("end")},o.prototype.restart=function(){return this._removeState("current_step"),this._removeState("end"),this._removeState("redirect_to"),this.start()},o.prototype.pause=function(){var t;return t=this.getStep(this._current),t&&t.duration?(this._paused=!0,this._duration-=(new Date).getTime()-this._start,e.clearTimeout(this._timer),this._debug("Paused/Stopped step "+(this._current+1)+" timer ("+this._duration+" remaining)."),null!=t.onPause?t.onPause(this,this._duration):void 0):this},o.prototype.resume=function(){var t;return t=this.getStep(this._current),t&&t.duration?(this._paused=!1,this._start=(new Date).getTime(),this._duration=this._duration||t.duration,this._timer=e.setTimeout(function(t){return function(){return t._isLast()?t.next():t.end()}}(this),this._duration),this._debug("Started step "+(this._current+1)+" timer with duration "+this._duration),null!=t.onResume&&this._duration!==t.duration?t.onResume(this,this._duration):void 0):this},o.prototype.hideStep=function(e){var o,n,r;return(r=this.getStep(e))?(this._clearTimer(),n=this._makePromise(null!=r.onHide?r.onHide(this,e):void 0),o=function(o){return function(){var n;return n=t(r.element),n.data("bs.popover")||n.data("popover")||(n=t("body")),n.popover("destroy").removeClass("tour-"+o._options.name+"-element tour-"+o._options.name+"-"+e+"-element"),n.removeData("bs.popover"),r.reflex&&t(r.reflexElement).removeClass("tour-step-element-reflex").off(""+o._reflexEvent(r.reflex)+".tour-"+o._options.name),r.backdrop&&o._hideBackdrop(),null!=r.onHidden?r.onHidden(o):void 0}}(this),this._callOnPromiseDone(n,o),n):void 0},o.prototype.showStep=function(t){var o,r,i,s;return this.ended()?(this._debug("Tour ended, showStep prevented."),this):(s=this.getStep(t))?(i=t
").parent().html()},o.prototype._reflexEvent=function(t){return"[object Boolean]"==={}.toString.call(t)?"click":t},o.prototype._reposition=function(e,o){var r,i,s,a,p,u,h;if(a=e[0].offsetWidth,i=e[0].offsetHeight,h=e.offset(),p=h.left,u=h.top,r=t(n).outerHeight()-h.top-e.outerHeight(),0>r&&(h.top=h.top+r),s=t("html").outerWidth()-h.left-e.outerWidth(),0>s&&(h.left=h.left+s),h.top<0&&(h.top=0),h.left<0&&(h.left=0),e.offset(h),"bottom"===o.placement||"top"===o.placement){if(p!==h.left)return this._replaceArrow(e,2*(h.left-p),a,"left")}else if(u!==h.top)return this._replaceArrow(e,2*(h.top-u),i,"top")},o.prototype._center=function(o){return o.css("top",t(e).outerHeight()/2-o.outerHeight()/2)},o.prototype._replaceArrow=function(t,e,o,n){return t.find(".arrow").css(n,e?50*(1-e/o)+"%":"")},o.prototype._scrollIntoView=function(o,n){var r,i,s,a,p,u;return r=t(o),r.length?(i=t(e),a=r.offset().top,u=i.height(),p=Math.max(0,a-u/2),this._debug("Scroll into view. ScrollTop: "+p+". Element offset: "+a+". Window height: "+u+"."),s=0,t("body, html").stop(!0,!0).animate({scrollTop:Math.ceil(p)},function(t){return function(){return 2===++s?(n(),t._debug("Scroll into view.\nAnimation end element offset: "+r.offset().top+".\nWindow height: "+i.height()+".")):void 0}}(this))):n()},o.prototype._onResize=function(o,n){return t(e).on("resize.tour-"+this._options.name,function(){return clearTimeout(n),n=setTimeout(o,100)})},o.prototype._initMouseNavigation=function(){var e;return e=this,t(n).off("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='prev']").off("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='next']").off("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='end']").off("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='pause-resume']").on("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='next']",function(t){return function(e){return e.preventDefault(),t.next()}}(this)).on("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='prev']",function(t){return function(e){return e.preventDefault(),t.prev()}}(this)).on("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='end']",function(t){return function(e){return e.preventDefault(),t.end()}}(this)).on("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='pause-resume']",function(o){var n;return o.preventDefault(),n=t(this),n.text(e._paused?n.data("pause-text"):n.data("resume-text")),e._paused?e.resume():e.pause()})},o.prototype._initKeyboardNavigation=function(){return this._options.keyboard?t(n).on("keyup.tour-"+this._options.name,function(t){return function(e){if(e.which)switch(e.which){case 39:return e.preventDefault(),t._isLast()?t.next():t.end();case 37:if(e.preventDefault(),t._current>0)return t.prev();break;case 27:return e.preventDefault(),t.end()}}}(this)):void 0},o.prototype._makePromise=function(e){return e&&t.isFunction(e.then)?e:null},o.prototype._callOnPromiseDone=function(t,e,o){return t?t.then(function(t){return function(){return e.call(t,o)}}(this)):e.call(this,o)},o.prototype._showBackdrop=function(e){return this.backdrop.backgroundShown?void 0:(this.backdrop=t("",{"class":"tour-backdrop"}),this.backdrop.backgroundShown=!0,t(e.backdropContainer).append(this.backdrop))},o.prototype._hideBackdrop=function(){return this._hideOverlayElement(),this._hideBackground()},o.prototype._hideBackground=function(){return this.backdrop?(this.backdrop.remove(),this.backdrop.overlay=null,this.backdrop.backgroundShown=!1):void 0},o.prototype._showOverlayElement=function(e,o){var n,r;return n=t(e.element),!n||0===n.length||this.backdrop.overlayElementShown&&!o?void 0:(this.backdrop.overlayElementShown||(this.backdrop.$element=n.addClass("tour-step-backdrop"),this.backdrop.$background=t("
",{"class":"tour-step-background"}),this.backdrop.$background.appendTo(e.backdropContainer),this.backdrop.overlayElementShown=!0),r={width:n.innerWidth(),height:n.innerHeight(),offset:n.offset()},e.backdropPadding&&(r=this._applyBackdropPadding(e.backdropPadding,r)),this.backdrop.$background.width(r.width).height(r.height).offset(r.offset))},o.prototype._hideOverlayElement=function(){return this.backdrop.overlayElementShown?(this.backdrop.$element.removeClass("tour-step-backdrop"),this.backdrop.$background.remove(),this.backdrop.$element=null,this.backdrop.$background=null,this.backdrop.overlayElementShown=!1):void 0},o.prototype._applyBackdropPadding=function(t,e){return"object"==typeof t?(null==t.top&&(t.top=0),null==t.right&&(t.right=0),null==t.bottom&&(t.bottom=0),null==t.left&&(t.left=0),e.offset.top=e.offset.top-t.top,e.offset.left=e.offset.left-t.left,e.width=e.width+t.left+t.right,e.height=e.height+t.top+t.bottom):(e.offset.top=e.offset.top-t,e.offset.left=e.offset.left-t,e.width=e.width+2*t,e.height=e.height+2*t),e},o.prototype._clearTimer=function(){return e.clearTimeout(this._timer),this._timer=null,this._duration=null},o.prototype._getProtocol=function(t){return t=t.split("://"),t.length>1?t[0]:"http"},o.prototype._getHost=function(t){return t=t.split("//"),t=t.length>1?t[1]:t[0],t.split("/")[0]},o.prototype._getPath=function(t){return t.replace(/\/?$/,"").split("?")[0].split("#")[0]},o.prototype._getQuery=function(t){return this._getParams(t,"?")},o.prototype._getHash=function(t){return this._getParams(t,"#")},o.prototype._getParams=function(t,e){var o,n,r,i,s;if(n=t.split(e),1===n.length)return{};for(n=n[1].split("&"),r={},i=0,s=n.length;s>i;i++)o=n[i],o=o.split("="),r[o[0]]=o[1]||"";return r},o.prototype._equal=function(t,e){var o,n;if("[object Object]"==={}.toString.call(t)&&"[object Object]"==={}.toString.call(e)){for(o in t)if(n=t[o],e[o]!==n)return!1;for(o in e)if(n=e[o],t[o]!==n)return!1;return!0}return t===e},o}(),e.Tour=o}(jQuery,window);
\ No newline at end of file
+!function(t,e){var o,n;return n=e.document,o=function(){function o(o){var n;try{n=e.localStorage}catch(r){n=!1}this._options=t.extend({name:"tour",steps:[],container:"body",autoscroll:!0,keyboard:!0,storage:n,debug:!1,mustFinish:!1,backdrop:!1,backdropContainer:"body",backdropPadding:0,redirect:!0,frozenContext:{},orphan:!1,duration:!1,delay:!1,basePath:"",template:'
',afterSetState:function(){},afterGetState:function(){},afterRemoveState:function(){},onStart:function(){},onEnd:function(){},onShow:function(){},onShown:function(){},onHide:function(){},onHidden:function(){},onNext:function(){},onPrev:function(){},onPause:function(){},onResume:function(){},onRedirectError:function(){}},o),this._force=!1,this._inited=!1,this._current=null,this.backdrop={overlay:null,$element:null,$background:null,backgroundShown:!1,overlayElementShown:!1}}return o.prototype.unfreeze=function(){return t(".popover-navigation button").prop("disabled",!1),t(".popover-navigation button").removeClass("disabled"),this._current<1&&(t('.popover-navigation [data-role="prev"]').prop("disabled",!0),t('.popover-navigation [data-role="prev"]').addClass("disabled")),this._current>=this._options.steps.length-1?(t('.popover-navigation [data-role="next"]').prop("disabled",!0),t('.popover-navigation [data-role="next"]').addClass("disabled")):void 0},o.prototype.addSteps=function(t){var e,o,n;for(o=0,n=t.length;n>o;o++)e=t[o],this.addStep(e);return this},o.prototype.addStep=function(t){return this._options.steps.push(t),this},o.prototype.getStep=function(e){return null!=this._options.steps[e]?t.extend({id:"step-"+e,path:"",host:"",placement:"right",title:"",content:"
",next:e===this._options.steps.length-1?-1:e+1,prev:e-1,animation:!0,container:this._options.container,autoscroll:this._options.autoscroll,backdrop:this._options.backdrop,backdropContainer:this._options.backdropContainer,backdropPadding:this._options.backdropPadding,redirect:this._options.redirect,reflexElement:this._options.steps[e].element,orphan:this._options.orphan,duration:this._options.duration,delay:this._options.delay,template:this._options.template,onShow:this._options.onShow,onShown:this._options.onShown,onHide:this._options.onHide,onHidden:this._options.onHidden,isFrozen:this._options.isFrozen||function(){},frozenContext:this._options.frozenContext,onNext:this._options.onNext,onPrev:this._options.onPrev,onPause:this._options.onPause,onResume:this._options.onResume,onRedirectError:this._options.onRedirectError},this._options.steps[e]):void 0},o.prototype.init=function(t){return this._force=t,this.ended()?(this._debug("Tour ended, init prevented."),this):(this.setCurrentStep(),this._initMouseNavigation(),this._initKeyboardNavigation(),this._onResize(function(t){return function(){return t.showStep(t._current)}}(this)),null!==this._current&&this.showStep(this._current),this._inited=!0,this)},o.prototype.start=function(t){var e;return null==t&&(t=!1),this._inited||this.init(t),null===this._current&&(e=this._makePromise(null!=this._options.onStart?this._options.onStart(this):void 0),this._callOnPromiseDone(e,this.showStep,0)),this},o.prototype.next=function(){var t;return t=this.hideStep(this._current),this._callOnPromiseDone(t,this._showNextStep)},o.prototype.prev=function(){var t;return t=this.hideStep(this._current),this._callOnPromiseDone(t,this._showPrevStep)},o.prototype.goTo=function(t){var e;return e=this.hideStep(this._current),this._callOnPromiseDone(e,this.showStep,t)},o.prototype.end=function(){var o,r;return o=function(o){return function(){return t(n).off("click.tour-"+o._options.name),t(n).off("keyup.tour-"+o._options.name),t(e).off("resize.tour-"+o._options.name),o._setState("end","yes"),o._inited=!1,o._force=!1,o._clearTimer(),null!=o._options.onEnd?o._options.onEnd(o):void 0}}(this),r=this.hideStep(this._current),this._callOnPromiseDone(r,o)},o.prototype.ended=function(){return!this._force&&!!this._getState("end")},o.prototype.restart=function(){return this._removeState("current_step"),this._removeState("end"),this._removeState("redirect_to"),this.start()},o.prototype.pause=function(){var t;return t=this.getStep(this._current),t&&t.duration?(this._paused=!0,this._duration-=(new Date).getTime()-this._start,e.clearTimeout(this._timer),this._debug("Paused/Stopped step "+(this._current+1)+" timer ("+this._duration+" remaining)."),null!=t.onPause?t.onPause(this,this._duration):void 0):this},o.prototype.resume=function(){var t;return t=this.getStep(this._current),t&&t.duration?(this._paused=!1,this._start=(new Date).getTime(),this._duration=this._duration||t.duration,this._timer=e.setTimeout(function(t){return function(){return t._isLast()?t.next():t.end()}}(this),this._duration),this._debug("Started step "+(this._current+1)+" timer with duration "+this._duration),null!=t.onResume&&this._duration!==t.duration?t.onResume(this,this._duration):void 0):this},o.prototype.hideStep=function(e){var o,n,r;return(r=this.getStep(e))?(this._clearTimer(),n=this._makePromise(null!=r.onHide?r.onHide(this,e):void 0),o=function(o){return function(){var n;return n=t(r.element),n.data("bs.popover")||n.data("popover")||(n=t("body")),n.popover("destroy").removeClass("tour-"+o._options.name+"-element tour-"+o._options.name+"-"+e+"-element"),n.removeData("bs.popover"),r.reflex&&t(r.reflexElement).removeClass("tour-step-element-reflex").off(""+o._reflexEvent(r.reflex)+".tour-"+o._options.name),r.backdrop&&o._hideBackdrop(),null!=r.onHidden?r.onHidden(o):void 0}}(this),this._callOnPromiseDone(n,o),n):void 0},o.prototype.showStep=function(t){var o,r,i,s;return this.ended()?(this._debug("Tour ended, showStep prevented."),this):(s=this.getStep(t))?(i=t
").parent().html()},o.prototype._reflexEvent=function(t){return"[object Boolean]"==={}.toString.call(t)?"click":t},o.prototype._reposition=function(e,o){var r,i,s,a,p,u,h;if(a=e[0].offsetWidth,i=e[0].offsetHeight,h=e.offset(),p=h.left,u=h.top,r=t(n).outerHeight()-h.top-e.outerHeight(),0>r&&(h.top=h.top+r),s=t("html").outerWidth()-h.left-e.outerWidth(),0>s&&(h.left=h.left+s),h.top<0&&(h.top=0),h.left<0&&(h.left=0),e.offset(h),"bottom"===o.placement||"top"===o.placement){if(p!==h.left)return this._replaceArrow(e,2*(h.left-p),a,"left")}else if(u!==h.top)return this._replaceArrow(e,2*(h.top-u),i,"top")},o.prototype._center=function(o){return o.css("top",t(e).outerHeight()/2-o.outerHeight()/2)},o.prototype._replaceArrow=function(t,e,o,n){return t.find(".arrow").css(n,e?50*(1-e/o)+"%":"")},o.prototype._scrollIntoView=function(o,n){var r,i,s,a,p,u;return r=t(o),r.length?(i=t(e),a=r.offset().top,u=i.height(),p=Math.max(0,a-u/2),this._debug("Scroll into view. ScrollTop: "+p+". Element offset: "+a+". Window height: "+u+"."),s=0,t("body, html").stop(!0,!0).animate({scrollTop:Math.ceil(p)},function(t){return function(){return 2===++s?(n(),t._debug("Scroll into view.\nAnimation end element offset: "+r.offset().top+".\nWindow height: "+i.height()+".")):void 0}}(this))):n()},o.prototype._onResize=function(o,n){return t(e).on("resize.tour-"+this._options.name,function(){return clearTimeout(n),n=setTimeout(o,100)})},o.prototype._initMouseNavigation=function(){var e;return e=this,t(n).off("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='prev']").off("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='next']").off("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='end']").off("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='pause-resume']").on("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='next']",function(t){return function(e){return e.preventDefault(),t.next()}}(this)).on("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='prev']",function(t){return function(e){return e.preventDefault(),t.prev()}}(this)).on("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='end']",function(t){return function(e){return e.preventDefault(),t.end()}}(this)).on("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='pause-resume']",function(o){var n;return o.preventDefault(),n=t(this),n.text(e._paused?n.data("pause-text"):n.data("resume-text")),e._paused?e.resume():e.pause()})},o.prototype._initKeyboardNavigation=function(){return this._options.keyboard?t(n).on("keyup.tour-"+this._options.name,function(t){return function(e){if(e.which)switch(e.which){case 39:return e.preventDefault(),t._isLast()?t.next():t.end();case 37:if(e.preventDefault(),t._current>0)return t.prev();break;case 27:return e.preventDefault(),t.end()}}}(this)):void 0},o.prototype._makePromise=function(e){return e&&t.isFunction(e.then)?e:null},o.prototype._callOnPromiseDone=function(t,e,o){return t?t.then(function(t){return function(){return e.call(t,o)}}(this)):e.call(this,o)},o.prototype._showBackdrop=function(e){return this.backdrop.backgroundShown?void 0:(this.backdrop=t("",{"class":"tour-backdrop"}),this.backdrop.backgroundShown=!0,t(e.backdropContainer).append(this.backdrop))},o.prototype._hideBackdrop=function(){return this._hideOverlayElement(),this._hideBackground()},o.prototype._hideBackground=function(){return this.backdrop?(this.backdrop.remove(),this.backdrop.overlay=null,this.backdrop.backgroundShown=!1):void 0},o.prototype._showOverlayElement=function(e,o){var n,r;return n=t(e.element),!n||0===n.length||this.backdrop.overlayElementShown&&!o?void 0:(this.backdrop.overlayElementShown||(this.backdrop.$element=n.addClass("tour-step-backdrop"),this.backdrop.$background=t("
",{"class":"tour-step-background"}),this.backdrop.$background.appendTo(e.backdropContainer),this.backdrop.overlayElementShown=!0),r={width:n.innerWidth(),height:n.innerHeight(),offset:n.offset()},e.backdropPadding&&(r=this._applyBackdropPadding(e.backdropPadding,r)),this.backdrop.$background.width(r.width).height(r.height).offset(r.offset))},o.prototype._hideOverlayElement=function(){return this.backdrop.overlayElementShown?(this.backdrop.$element.removeClass("tour-step-backdrop"),this.backdrop.$background.remove(),this.backdrop.$element=null,this.backdrop.$background=null,this.backdrop.overlayElementShown=!1):void 0},o.prototype._applyBackdropPadding=function(t,e){return"object"==typeof t?(null==t.top&&(t.top=0),null==t.right&&(t.right=0),null==t.bottom&&(t.bottom=0),null==t.left&&(t.left=0),e.offset.top=e.offset.top-t.top,e.offset.left=e.offset.left-t.left,e.width=e.width+t.left+t.right,e.height=e.height+t.top+t.bottom):(e.offset.top=e.offset.top-t,e.offset.left=e.offset.left-t,e.width=e.width+2*t,e.height=e.height+2*t),e},o.prototype._clearTimer=function(){return e.clearTimeout(this._timer),this._timer=null,this._duration=null},o.prototype._getProtocol=function(t){return t=t.split("://"),t.length>1?t[0]:"http"},o.prototype._getHost=function(t){return t=t.split("//"),t=t.length>1?t[1]:t[0],t.split("/")[0]},o.prototype._getPath=function(t){return t.replace(/\/?$/,"").split("?")[0].split("#")[0]},o.prototype._getQuery=function(t){return this._getParams(t,"?")},o.prototype._getHash=function(t){return this._getParams(t,"#")},o.prototype._getParams=function(t,e){var o,n,r,i,s;if(n=t.split(e),1===n.length)return{};for(n=n[1].split("&"),r={},i=0,s=n.length;s>i;i++)o=n[i],o=o.split("="),r[o[0]]=o[1]||"";return r},o.prototype._equal=function(t,e){var o,n;if("[object Object]"==={}.toString.call(t)&&"[object Object]"==={}.toString.call(e)){for(o in t)if(n=t[o],e[o]!==n)return!1;for(o in e)if(n=e[o],t[o]!==n)return!1;return!0}return t===e},o}(),e.Tour=o}(jQuery,window);
\ No newline at end of file
diff --git a/src/coffee/bootstrap-tour.coffee b/src/coffee/bootstrap-tour.coffee
index c90d091a..68a77deb 100644
--- a/src/coffee/bootstrap-tour.coffee
+++ b/src/coffee/bootstrap-tour.coffee
@@ -16,10 +16,12 @@
keyboard: true
storage: storage
debug: false
+ mustFinish: false
backdrop: false
backdropContainer: 'body'
backdropPadding: 0
redirect: true
+ frozenContext: {}
orphan: false
duration: false
delay: false
@@ -67,6 +69,18 @@
overlayElementShown: false
@
+ # unfreeze tour
+ unfreeze: ->
+ $('.popover-navigation button').prop('disabled', false)
+ $('.popover-navigation button').removeClass('disabled')
+ if @_current < 1
+ $('.popover-navigation [data-role="prev"]').prop 'disabled', true
+ $('.popover-navigation [data-role="prev"]').addClass 'disabled'
+
+ if @_current >= @_options.steps.length-1
+ $('.popover-navigation [data-role="next"]').prop 'disabled', true
+ $('.popover-navigation [data-role="next"]').addClass 'disabled'
+
# Add multiple steps
addSteps: (steps) ->
@addStep step for step in steps
@@ -105,6 +119,8 @@
onShown: @_options.onShown
onHide: @_options.onHide
onHidden: @_options.onHidden
+ isFrozen: @_options.isFrozen || ->
+ frozenContext: @_options.frozenContext
onNext: @_options.onNext
onPrev: @_options.onPrev
onPause: @_options.onPause
@@ -510,13 +526,17 @@
$navigation = $template.find '.popover-navigation'
$prev = $navigation.find '[data-role="prev"]'
$next = $navigation.find '[data-role="next"]'
+ $end = $navigation.find '[data-role="end"]'
$resume = $navigation.find '[data-role="pause-resume"]'
+ frozen = step.isFrozen.call(@_options.frozenContext)
$template.addClass 'orphan' if @_isOrphan step
$template.addClass "tour-#{@_options.name} tour-#{@_options.name}-#{i}"
$template.addClass "tour-#{@_options.name}-reflex" if step.reflex
- $prev.addClass('disabled') if step.prev < 0
- $next.addClass('disabled') if step.next < 0
+ $prev.addClass('disabled') if step.prev < 0 || frozen
+ $next.addClass('disabled') if step.next < 0 || frozen
+ $end.addClass('disabled') if frozen
+ $end.addClass('hide') if @_options.mustFinish && i + 1 < @_options.steps.length
$resume.remove() unless step.duration
$template.clone().wrap('
').parent().html()
diff --git a/src/docs/assets/css/bootstrap-tour.css b/src/docs/assets/css/bootstrap-tour.css
index 2d56230a..1b352955 100644
--- a/src/docs/assets/css/bootstrap-tour.css
+++ b/src/docs/assets/css/bootstrap-tour.css
@@ -2,14 +2,14 @@
* bootstrap-tour - v0.10.2
* http://bootstraptour.com
* ========================================================================
- * Copyright 2012-2013 Ulrich Sossou
+ * Copyright 2012-2015 Ulrich Sossou
*
* ========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the MIT License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * https://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -45,7 +45,7 @@
border-radius: 6px;
}
.popover[class*="tour-"] {
- z-index: 1100;
+ z-index: 1102;
}
.popover[class*="tour-"] .popover-navigation {
padding: 9px 14px;
diff --git a/src/docs/assets/js/bootstrap-tour.js b/src/docs/assets/js/bootstrap-tour.js
index 957c9e90..e2455fa8 100644
--- a/src/docs/assets/js/bootstrap-tour.js
+++ b/src/docs/assets/js/bootstrap-tour.js
@@ -38,10 +38,12 @@
keyboard: true,
storage: storage,
debug: false,
+ mustFinish: false,
backdrop: false,
backdropContainer: 'body',
backdropPadding: 0,
redirect: true,
+ frozenContext: {},
orphan: false,
duration: false,
delay: false,
@@ -75,6 +77,19 @@
this;
}
+ Tour.prototype.unfreeze = function() {
+ $('.popover-navigation button').prop('disabled', false);
+ $('.popover-navigation button').removeClass('disabled');
+ if (this._current < 1) {
+ $('.popover-navigation [data-role="prev"]').prop('disabled', true);
+ $('.popover-navigation [data-role="prev"]').addClass('disabled');
+ }
+ if (this._current >= this._options.steps.length - 1) {
+ $('.popover-navigation [data-role="next"]').prop('disabled', true);
+ return $('.popover-navigation [data-role="next"]').addClass('disabled');
+ }
+ };
+
Tour.prototype.addSteps = function(steps) {
var step, _i, _len;
for (_i = 0, _len = steps.length; _i < _len; _i++) {
@@ -116,6 +131,8 @@
onShown: this._options.onShown,
onHide: this._options.onHide,
onHidden: this._options.onHidden,
+ isFrozen: this._options.isFrozen || function() {},
+ frozenContext: this._options.frozenContext,
onNext: this._options.onNext,
onPrev: this._options.onPrev,
onPause: this._options.onPause,
@@ -570,7 +587,7 @@
};
Tour.prototype._template = function(step, i) {
- var $navigation, $next, $prev, $resume, $template, template;
+ var $end, $navigation, $next, $prev, $resume, $template, frozen, template;
template = step.template;
if (this._isOrphan(step) && {}.toString.call(step.orphan) !== '[object Boolean]') {
template = step.orphan;
@@ -579,7 +596,9 @@
$navigation = $template.find('.popover-navigation');
$prev = $navigation.find('[data-role="prev"]');
$next = $navigation.find('[data-role="next"]');
+ $end = $navigation.find('[data-role="end"]');
$resume = $navigation.find('[data-role="pause-resume"]');
+ frozen = step.isFrozen.call(this._options.frozenContext);
if (this._isOrphan(step)) {
$template.addClass('orphan');
}
@@ -587,12 +606,18 @@
if (step.reflex) {
$template.addClass("tour-" + this._options.name + "-reflex");
}
- if (step.prev < 0) {
+ if (step.prev < 0 || frozen) {
$prev.addClass('disabled');
}
- if (step.next < 0) {
+ if (step.next < 0 || frozen) {
$next.addClass('disabled');
}
+ if (frozen) {
+ $end.addClass('disabled');
+ }
+ if (this._options.mustFinish && i + 1 < this._options.steps.length) {
+ $end.addClass('hide');
+ }
if (!step.duration) {
$resume.remove();
}
diff --git a/test/bootstrap-tour.js b/test/bootstrap-tour.js
index 957c9e90..e2455fa8 100644
--- a/test/bootstrap-tour.js
+++ b/test/bootstrap-tour.js
@@ -38,10 +38,12 @@
keyboard: true,
storage: storage,
debug: false,
+ mustFinish: false,
backdrop: false,
backdropContainer: 'body',
backdropPadding: 0,
redirect: true,
+ frozenContext: {},
orphan: false,
duration: false,
delay: false,
@@ -75,6 +77,19 @@
this;
}
+ Tour.prototype.unfreeze = function() {
+ $('.popover-navigation button').prop('disabled', false);
+ $('.popover-navigation button').removeClass('disabled');
+ if (this._current < 1) {
+ $('.popover-navigation [data-role="prev"]').prop('disabled', true);
+ $('.popover-navigation [data-role="prev"]').addClass('disabled');
+ }
+ if (this._current >= this._options.steps.length - 1) {
+ $('.popover-navigation [data-role="next"]').prop('disabled', true);
+ return $('.popover-navigation [data-role="next"]').addClass('disabled');
+ }
+ };
+
Tour.prototype.addSteps = function(steps) {
var step, _i, _len;
for (_i = 0, _len = steps.length; _i < _len; _i++) {
@@ -116,6 +131,8 @@
onShown: this._options.onShown,
onHide: this._options.onHide,
onHidden: this._options.onHidden,
+ isFrozen: this._options.isFrozen || function() {},
+ frozenContext: this._options.frozenContext,
onNext: this._options.onNext,
onPrev: this._options.onPrev,
onPause: this._options.onPause,
@@ -570,7 +587,7 @@
};
Tour.prototype._template = function(step, i) {
- var $navigation, $next, $prev, $resume, $template, template;
+ var $end, $navigation, $next, $prev, $resume, $template, frozen, template;
template = step.template;
if (this._isOrphan(step) && {}.toString.call(step.orphan) !== '[object Boolean]') {
template = step.orphan;
@@ -579,7 +596,9 @@
$navigation = $template.find('.popover-navigation');
$prev = $navigation.find('[data-role="prev"]');
$next = $navigation.find('[data-role="next"]');
+ $end = $navigation.find('[data-role="end"]');
$resume = $navigation.find('[data-role="pause-resume"]');
+ frozen = step.isFrozen.call(this._options.frozenContext);
if (this._isOrphan(step)) {
$template.addClass('orphan');
}
@@ -587,12 +606,18 @@
if (step.reflex) {
$template.addClass("tour-" + this._options.name + "-reflex");
}
- if (step.prev < 0) {
+ if (step.prev < 0 || frozen) {
$prev.addClass('disabled');
}
- if (step.next < 0) {
+ if (step.next < 0 || frozen) {
$next.addClass('disabled');
}
+ if (frozen) {
+ $end.addClass('disabled');
+ }
+ if (this._options.mustFinish && i + 1 < this._options.steps.length) {
+ $end.addClass('hide');
+ }
if (!step.duration) {
$resume.remove();
}