mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
2 lines
18 KiB
JavaScript
2 lines
18 KiB
JavaScript
!function(a,b){var c,d;return d=b.document,c=function(){function c(c){var d;try{d=b.localStorage}catch(e){d=!1}this._options=a.extend({name:"tour",steps:[],container:"body",autoscroll:!0,keyboard:!0,storage:d,debug:!1,backdrop:!1,backdropContainer:"body",backdropPadding:0,redirect:!0,orphan:!1,duration:!1,delay:!1,basePath:"",template:'<div class="popover" role="tooltip"> <div class="arrow"></div> <h3 class="popover-title"></h3> <div class="popover-content"></div> <div class="popover-navigation"> <div class="btn-group"> <button class="btn btn-sm btn-default" data-role="prev">« Prev</button> <button class="btn btn-sm btn-default" data-role="next">Next »</button> <button class="btn btn-sm btn-default" data-role="pause-resume" data-pause-text="Pause" data-resume-text="Resume">Pause</button> </div> <button class="btn btn-sm btn-default" data-role="end">End tour</button> </div> </div>',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(){}},c),this._force=!1,this._inited=!1,this._current=null,this.backdrop={overlay:null,$element:null,$background:null,backgroundShown:!1,overlayElementShown:!1}}return c.prototype.addSteps=function(a){var b,c,d;for(c=0,d=a.length;d>c;c++)b=a[c],this.addStep(b);return this},c.prototype.addStep=function(a){return this._options.steps.push(a),this},c.prototype.getStep=function(b){return null!=this._options.steps[b]?a.extend({id:"step-"+b,path:"",host:"",placement:"right",title:"",content:"<p></p>",next:b===this._options.steps.length-1?-1:b+1,prev:b-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[b].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[b]):void 0},c.prototype.init=function(a){return this._force=a,this.ended()?(this._debug("Tour ended, init prevented."),this):(this.setCurrentStep(),this._initMouseNavigation(),this._initKeyboardNavigation(),this._onResize(function(a){return function(){return a.showStep(a._current)}}(this)),null!==this._current&&this.showStep(this._current),this._inited=!0,this)},c.prototype.start=function(a){var b;return null==a&&(a=!1),this._inited||this.init(a),null===this._current&&(b=this._makePromise(null!=this._options.onStart?this._options.onStart(this):void 0),this._callOnPromiseDone(b,this.showStep,0)),this},c.prototype.next=function(){var a;return a=this.hideStep(this._current),this._callOnPromiseDone(a,this._showNextStep)},c.prototype.prev=function(){var a;return a=this.hideStep(this._current),this._callOnPromiseDone(a,this._showPrevStep)},c.prototype.goTo=function(a){var b;return b=this.hideStep(this._current),this._callOnPromiseDone(b,this.showStep,a)},c.prototype.end=function(){var c,e;return c=function(c){return function(){return a(d).off("click.tour-"+c._options.name),a(d).off("keyup.tour-"+c._options.name),a(b).off("resize.tour-"+c._options.name),c._setState("end","yes"),c._inited=!1,c._force=!1,c._clearTimer(),null!=c._options.onEnd?c._options.onEnd(c):void 0}}(this),e=this.hideStep(this._current),this._callOnPromiseDone(e,c)},c.prototype.ended=function(){return!this._force&&!!this._getState("end")},c.prototype.restart=function(){return this._removeState("current_step"),this._removeState("end"),this._removeState("redirect_to"),this.start()},c.prototype.pause=function(){var a;return a=this.getStep(this._current),a&&a.duration?(this._paused=!0,this._duration-=(new Date).getTime()-this._start,b.clearTimeout(this._timer),this._debug("Paused/Stopped step "+(this._current+1)+" timer ("+this._duration+" remaining)."),null!=a.onPause?a.onPause(this,this._duration):void 0):this},c.prototype.resume=function(){var a;return a=this.getStep(this._current),a&&a.duration?(this._paused=!1,this._start=(new Date).getTime(),this._duration=this._duration||a.duration,this._timer=b.setTimeout(function(a){return function(){return a._isLast()?a.next():a.end()}}(this),this._duration),this._debug("Started step "+(this._current+1)+" timer with duration "+this._duration),null!=a.onResume&&this._duration!==a.duration?a.onResume(this,this._duration):void 0):this},c.prototype.hideStep=function(b){var c,d,e;return(e=this.getStep(b))?(this._clearTimer(),d=this._makePromise(null!=e.onHide?e.onHide(this,b):void 0),c=function(c){return function(){var d;return d=a(e.element),d.data("bs.popover")||d.data("popover")||(d=a("body")),d.popover("destroy").removeClass("tour-"+c._options.name+"-element tour-"+c._options.name+"-"+b+"-element"),d.removeData("bs.popover"),e.reflex&&a(e.reflexElement).removeClass("tour-step-element-reflex").off(""+c._reflexEvent(e.reflex)+".tour-"+c._options.name),e.backdrop&&c._hideBackdrop(),null!=e.onHidden?e.onHidden(c):void 0}}(this),this._callOnPromiseDone(d,c),d):void 0},c.prototype.showStep=function(a){var c,e,f,g;return this.ended()?(this._debug("Tour ended, showStep prevented."),this):(g=this.getStep(a))?(f=a<this._current,c=this._makePromise(null!=g.onShow?g.onShow(this,a):void 0),e=function(b){return function(){var c,e;if(b.setCurrentStep(a),c=function(){switch({}.toString.call(g.path)){case"[object Function]":return g.path();case"[object String]":return this._options.basePath+g.path;default:return g.path}}.call(b),!b._isRedirect(g.host,c,d.location)||(b._redirect(g,a,c),b._isJustPathHashDifferent(g.host,c,d.location))){if(b._isOrphan(g)){if(g.orphan===!1)return b._debug("Skip the orphan step "+(b._current+1)+".\nOrphan option is false and the element does not exist or is hidden."),void(f?b._showPrevStep():b._showNextStep());b._debug("Show the orphan step "+(b._current+1)+". Orphans option is true.")}return g.backdrop&&b._showBackdrop(g),e=function(){return b.getCurrentStep()!==a||b.ended()?void 0:(null!=g.element&&g.backdrop&&b._showOverlayElement(g),b._showPopover(g,a),null!=g.onShown&&g.onShown(b),b._debug("Step "+(b._current+1)+" of "+b._options.steps.length))},g.autoscroll?b._scrollIntoView(g.element,e):e(),g.duration?b.resume():void 0}}}(this),g.delay?(this._debug("Wait "+g.delay+" milliseconds to show the step "+(this._current+1)),b.setTimeout(function(a){return function(){return a._callOnPromiseDone(c,e)}}(this),g.delay)):this._callOnPromiseDone(c,e),c):void 0},c.prototype.getCurrentStep=function(){return this._current},c.prototype.setCurrentStep=function(a){return null!=a?(this._current=a,this._setState("current_step",a)):(this._current=this._getState("current_step"),this._current=null===this._current?null:parseInt(this._current,10)),this},c.prototype.redraw=function(){return this._showOverlayElement(this.getStep(this.getCurrentStep()).element,!0)},c.prototype._setState=function(a,b){var c,d;if(this._options.storage){d=""+this._options.name+"_"+a;try{this._options.storage.setItem(d,b)}catch(e){c=e,c.code===DOMException.QUOTA_EXCEEDED_ERR&&this._debug("LocalStorage quota exceeded. State storage failed.")}return this._options.afterSetState(d,b)}return null==this._state&&(this._state={}),this._state[a]=b},c.prototype._removeState=function(a){var b;return this._options.storage?(b=""+this._options.name+"_"+a,this._options.storage.removeItem(b),this._options.afterRemoveState(b)):null!=this._state?delete this._state[a]:void 0},c.prototype._getState=function(a){var b,c;return this._options.storage?(b=""+this._options.name+"_"+a,c=this._options.storage.getItem(b)):null!=this._state&&(c=this._state[a]),(void 0===c||"null"===c)&&(c=null),this._options.afterGetState(a,c),c},c.prototype._showNextStep=function(){var a,b,c;return c=this.getStep(this._current),b=function(a){return function(){return a.showStep(c.next)}}(this),a=this._makePromise(null!=c.onNext?c.onNext(this):void 0),this._callOnPromiseDone(a,b)},c.prototype._showPrevStep=function(){var a,b,c;return c=this.getStep(this._current),b=function(a){return function(){return a.showStep(c.prev)}}(this),a=this._makePromise(null!=c.onPrev?c.onPrev(this):void 0),this._callOnPromiseDone(a,b)},c.prototype._debug=function(a){return this._options.debug?b.console.log("Bootstrap Tour '"+this._options.name+"' | "+a):void 0},c.prototype._isRedirect=function(a,b,c){var d;return""!==a&&this._isHostDifferent(a,c.href)?!0:(d=[c.pathname,c.search,c.hash].join(""),null!=b&&""!==b&&("[object RegExp]"==={}.toString.call(b)&&!b.test(d)||"[object String]"==={}.toString.call(b)&&this._isPathDifferent(b,d)))},c.prototype._isHostDifferent=function(a,b){return this._getProtocol(a)!==this._getProtocol(b)||this._getHost(a)!==this._getHost(b)},c.prototype._isPathDifferent=function(a,b){return this._getPath(a)!==this._getPath(b)||!this._equal(this._getQuery(a),this._getQuery(b))||!this._equal(this._getHash(a),this._getHash(b))},c.prototype._isJustPathHashDifferent=function(a,b,c){var d;return""!==a&&this._isHostDifferent(a,c.href)?!1:(d=[c.pathname,c.search,c.hash].join(""),"[object String]"==={}.toString.call(b)?this._getPath(b)===this._getPath(d)&&this._equal(this._getQuery(b),this._getQuery(d))&&!this._equal(this._getHash(b),this._getHash(d)):!1)},c.prototype._redirect=function(b,c,e){if(a.isFunction(b.redirect))return b.redirect.call(this,e);if(b.redirect===!0){if(this._debug("Redirect to "+b.host+e),this._getState("redirect_to")!==""+c)return this._setState("redirect_to",""+c),d.location.href=""+b.host+e;if(this._debug("Error redirection loop to "+e),this._removeState("redirect_to"),null!=b.onRedirectError)return b.onRedirectError(this)}},c.prototype._isOrphan=function(b){return null==b.element||!a(b.element).length||a(b.element).is(":hidden")&&"http://www.w3.org/2000/svg"!==a(b.element)[0].namespaceURI},c.prototype._isLast=function(){return this._current<this._options.steps.length-1},c.prototype._showPopover=function(b,c){var d,e,f,g,h;return a(".tour-"+this._options.name).remove(),g=a.extend({},this._options),f=this._isOrphan(b),b.template=this._template(b,c),f&&(b.element="body",b.placement="top"),d=a(b.element),d.addClass("tour-"+this._options.name+"-element tour-"+this._options.name+"-"+c+"-element"),b.options&&a.extend(g,b.options),b.reflex&&!f&&a(b.reflexElement).addClass("tour-step-element-reflex").off(""+this._reflexEvent(b.reflex)+".tour-"+this._options.name).on(""+this._reflexEvent(b.reflex)+".tour-"+this._options.name,function(a){return function(){return a._isLast()?a.next():a.end()}}(this)),h=b.smartPlacement===!0&&-1===b.placement.search(/auto/i),d.popover({placement:h?"auto "+b.placement:b.placement,trigger:"manual",title:b.title,content:b.content,html:!0,animation:b.animation,container:b.container,template:b.template,selector:b.element}).popover("show"),e=d.data("bs.popover")?d.data("bs.popover").tip():d.data("popover").tip(),e.attr("id",b.id),this._reposition(e,b),f?this._center(e):void 0},c.prototype._template=function(b,c){var d,e,f,g,h,i;return i=b.template,this._isOrphan(b)&&"[object Boolean]"!=={}.toString.call(b.orphan)&&(i=b.orphan),h=a(a.isFunction(i)?i(c,b):i),d=h.find(".popover-navigation"),f=d.find('[data-role="prev"]'),e=d.find('[data-role="next"]'),g=d.find('[data-role="pause-resume"]'),this._isOrphan(b)&&h.addClass("orphan"),h.addClass("tour-"+this._options.name+" tour-"+this._options.name+"-"+c),b.reflex&&h.addClass("tour-"+this._options.name+"-reflex"),b.prev<0&&(f.addClass("disabled"),f.prop("disabled",!0)),b.next<0&&(e.addClass("disabled"),e.prop("disabled",!0)),b.duration||g.remove(),h.clone().wrap("<div>").parent().html()},c.prototype._reflexEvent=function(a){return"[object Boolean]"==={}.toString.call(a)?"click":a},c.prototype._reposition=function(b,c){var e,f,g,h,i,j,k;if(h=b[0].offsetWidth,f=b[0].offsetHeight,k=b.offset(),i=k.left,j=k.top,e=a(d).outerHeight()-k.top-b.outerHeight(),0>e&&(k.top=k.top+e),g=a("html").outerWidth()-k.left-b.outerWidth(),0>g&&(k.left=k.left+g),k.top<0&&(k.top=0),k.left<0&&(k.left=0),b.offset(k),"bottom"===c.placement||"top"===c.placement){if(i!==k.left)return this._replaceArrow(b,2*(k.left-i),h,"left")}else if(j!==k.top)return this._replaceArrow(b,2*(k.top-j),f,"top")},c.prototype._center=function(c){return c.css("top",a(b).outerHeight()/2-c.outerHeight()/2)},c.prototype._replaceArrow=function(a,b,c,d){return a.find(".arrow").css(d,b?50*(1-b/c)+"%":"")},c.prototype._scrollIntoView=function(c,d){var e,f,g,h,i,j;return e=a(c),e.length?(f=a(b),h=e.offset().top,j=f.height(),i=Math.max(0,h-j/2),this._debug("Scroll into view. ScrollTop: "+i+". Element offset: "+h+". Window height: "+j+"."),g=0,a("body, html").stop(!0,!0).animate({scrollTop:Math.ceil(i)},function(a){return function(){return 2===++g?(d(),a._debug("Scroll into view.\nAnimation end element offset: "+e.offset().top+".\nWindow height: "+f.height()+".")):void 0}}(this))):d()},c.prototype._onResize=function(c,d){return a(b).on("resize.tour-"+this._options.name,function(){return clearTimeout(d),d=setTimeout(c,100)})},c.prototype._initMouseNavigation=function(){var b;return b=this,a(d).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(a){return function(b){return b.preventDefault(),a.next()}}(this)).on("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='prev']",function(a){return function(b){return b.preventDefault(),a.prev()}}(this)).on("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='end']",function(a){return function(b){return b.preventDefault(),a.end()}}(this)).on("click.tour-"+this._options.name,".popover.tour-"+this._options.name+" *[data-role='pause-resume']",function(c){var d;return c.preventDefault(),d=a(this),d.text(d.data(b._paused?"pause-text":"resume-text")),b._paused?b.resume():b.pause()})},c.prototype._initKeyboardNavigation=function(){return this._options.keyboard?a(d).on("keyup.tour-"+this._options.name,function(a){return function(b){if(b.which)switch(b.which){case 39:return b.preventDefault(),a._isLast()?a.next():a.end();case 37:if(b.preventDefault(),a._current>0)return a.prev();break;case 27:return b.preventDefault(),a.end()}}}(this)):void 0},c.prototype._makePromise=function(b){return b&&a.isFunction(b.then)?b:null},c.prototype._callOnPromiseDone=function(a,b,c){return a?a.then(function(a){return function(){return b.call(a,c)}}(this)):b.call(this,c)},c.prototype._showBackdrop=function(b){return this.backdrop.backgroundShown?void 0:(this.backdrop=a("<div>",{"class":"tour-backdrop"}),this.backdrop.backgroundShown=!0,a(b.backdropContainer).append(this.backdrop))},c.prototype._hideBackdrop=function(){return this._hideOverlayElement(),this._hideBackground()},c.prototype._hideBackground=function(){return this.backdrop?(this.backdrop.remove(),this.backdrop.overlay=null,this.backdrop.backgroundShown=!1):void 0},c.prototype._showOverlayElement=function(b,c){var d,e;return d=a(b.element),!d||0===d.length||this.backdrop.overlayElementShown&&!c?void 0:(this.backdrop.overlayElementShown||(this.backdrop.$element=d.addClass("tour-step-backdrop"),this.backdrop.$background=a("<div>",{"class":"tour-step-background"}),this.backdrop.$background.appendTo(b.backdropContainer),this.backdrop.overlayElementShown=!0),e={width:d.innerWidth(),height:d.innerHeight(),offset:d.offset()},b.backdropPadding&&(e=this._applyBackdropPadding(b.backdropPadding,e)),this.backdrop.$background.width(e.width).height(e.height).offset(e.offset))},c.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},c.prototype._applyBackdropPadding=function(a,b){return"object"==typeof a?(null==a.top&&(a.top=0),null==a.right&&(a.right=0),null==a.bottom&&(a.bottom=0),null==a.left&&(a.left=0),b.offset.top=b.offset.top-a.top,b.offset.left=b.offset.left-a.left,b.width=b.width+a.left+a.right,b.height=b.height+a.top+a.bottom):(b.offset.top=b.offset.top-a,b.offset.left=b.offset.left-a,b.width=b.width+2*a,b.height=b.height+2*a),b},c.prototype._clearTimer=function(){return b.clearTimeout(this._timer),this._timer=null,this._duration=null},c.prototype._getProtocol=function(a){return a=a.split("://"),a.length>1?a[0]:"http"},c.prototype._getHost=function(a){return a=a.split("//"),a=a.length>1?a[1]:a[0],a.split("/")[0]},c.prototype._getPath=function(a){return a.replace(/\/?$/,"").split("?")[0].split("#")[0]},c.prototype._getQuery=function(a){return this._getParams(a,"?")},c.prototype._getHash=function(a){return this._getParams(a,"#")},c.prototype._getParams=function(a,b){var c,d,e,f,g;if(d=a.split(b),1===d.length)return{};for(d=d[1].split("&"),e={},f=0,g=d.length;g>f;f++)c=d[f],c=c.split("="),e[c[0]]=c[1]||"";return e},c.prototype._equal=function(a,b){var c,d;if("[object Object]"==={}.toString.call(a)&&"[object Object]"==={}.toString.call(b)){for(c in a)if(d=a[c],b[c]!==d)return!1;for(c in b)if(d=b[c],a[c]!==d)return!1;return!0}return a===b},c}(),b.Tour=c}(jQuery,window);
|
|
//# sourceMappingURL=../../maps/libs/bootstrap-tour.js.map
|