raspberry-pi-absensi/assets/plugin/tour/tourist.min.js

2 lines
14 KiB
JavaScript
Executable File

/*! Tourist.js - http://easelinc.github.io/tourist, built 03-13-2015 */
(function(){var a,b,c,d,e={}.hasOwnProperty,f=function(a,b){function c(){this.constructor=a}for(var d in b)e.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},g=function(a,b){return function(){return a.apply(b,arguments)}};window.Tourist=window.Tourist||{},Tourist.Model=function(b){function c(){return a=c.__super__.constructor.apply(this,arguments)}return f(c,b),c.prototype._module="Tourist",c}(Backbone.Model),window.Tourist.Tip=window.Tourist.Tip||{},Tourist.Tip.Base=function(){function a(a){this.options=null!=a?a:{},this.onClickNext=g(this.onClickNext,this),this.onClickClose=g(this.onClickClose,this),this.el=$("<div/>"),this.initialize(a),this._bindClickEvents(),Tourist.Tip.Base._cacheTip(this)}return a.prototype._module="Tourist",_.extend(a.prototype,Backbone.Events),a.prototype.skipButtonTemplate='<button class="btn btn-default btn-sm pull-right tour-next">Skip this step →</button>',a.prototype.nextButtonTemplate='<button class="btn btn-primary btn-sm pull-right tour-next">Next step →</button>',a.prototype.finalButtonTemplate='<button class="btn btn-primary btn-sm pull-right tour-next">Finish up</button>',a.prototype.closeButtonTemplate='<a class="btn btn-close tour-close" href="#"><i class="icon icon-remove"></i></a>',a.prototype.okButtonTemplate='<button class="btn btn-sm tour-close btn-primary">Okay</button>',a.prototype.actionLabelTemplate=_.template('<h4 class="action-label"><%= label %></h4>'),a.prototype.actionLabels=["Do this:","Then this:","Next this:"],a.prototype.highlightClass="tour-highlight",a.prototype.template=_.template('<div>\n <div class="tour-container">\n <%= close_button %>\n <%= content %>\n <p class="tour-counter <%= counter_class %>"><%= counter%></p>\n </div>\n <div class="tour-buttons">\n <%= buttons %>\n </div>\n</div>'),a.prototype.destroy=function(){return this.el.remove()},a.prototype.render=function(a){return this.hide(),a&&(this._setTarget(a.target||!1,a),this._setZIndex(""),this._renderContent(a,this._buildContentElement(a)),a.target&&this.show(),a.zIndex&&this._setZIndex(a.zIndex,a)),this},a.prototype.show=function(){},a.prototype.hide=function(){},a.prototype.setTarget=function(a,b){return this._setTarget(a,b)},a.prototype.cleanupCurrentTarget=function(){return this.target&&this.target.removeClass&&this.target.removeClass(this.highlightClass),this.target=null},a.prototype.onClickClose=function(a){return this.trigger("click:close",this,a),!1},a.prototype.onClickNext=function(a){return this.trigger("click:next",this,a),!1},a.prototype._getTipElement=function(){},a.prototype._renderContent=function(){},a.prototype._bindClickEvents=function(){var a;return a=this._getTipElement(),a.delegate(".tour-close","click",this.onClickClose),a.delegate(".tour-next","click",this.onClickNext)},a.prototype._setTarget=function(a,b){return this.cleanupCurrentTarget(),a&&b&&b.highlightTarget&&a.addClass(this.highlightClass),this.target=a},a.prototype._setZIndex=function(a){var b;return b=this._getTipElement(),b.css("z-index",a||"")},a.prototype._buildContentElement=function(a){var b,c;return b=this._buildButtons(a),c=$($.parseHTML(this.template({content:a.content,buttons:b,close_button:this._buildCloseButton(a),counter:a.final?"":"step "+(a.index+1)+" of "+a.total,counter_class:a.final?"final":""}))),b||c.find(".tour-buttons").addClass("no-buttons"),this._renderActionLabels(c),c},a.prototype._buildButtons=function(a){var b;return b="",a.okButton&&(b+=this.okButtonTemplate),a.skipButton&&(b+=this.skipButtonTemplate),a.nextButton&&(b+=a.final?this.finalButtonTemplate:this.nextButtonTemplate),b},a.prototype._buildCloseButton=function(a){return a.closeButton?this.closeButtonTemplate:""},a.prototype._renderActionLabels=function(a){var b,c,d,e,f,g,h;for(d=a.find(".action"),c=0,h=[],f=0,g=d.length;g>f;f++)b=d[f],e=$($.parseHTML(this.actionLabelTemplate({label:this.actionLabels[c]}))),e.insertBefore(b),h.push(c++);return h},a._cacheTip=function(a){return Tourist.Tip.Base._cachedTips||(Tourist.Tip.Base._cachedTips=[]),Tourist.Tip.Base._cachedTips.push(a)},a.destroy=function(){var a,b,c,d;if(Tourist.Tip.Base._cachedTips){for(d=Tourist.Tip.Base._cachedTips,b=0,c=d.length;c>b;b++)a=d[b],a.destroy();return Tourist.Tip.Base._cachedTips=null}},a}(),Tourist.Tip.Bootstrap=function(a){function c(){return b=c.__super__.constructor.apply(this,arguments)}return f(c,a),c.prototype.initialize=function(a){var b;return b={showEffect:null,hideEffect:null},this.options=_.extend(b,a),this.tip=new Tourist.Tip.BootstrapTip(this.options)},c.prototype.destroy=function(){return this.tip.destroy(),c.__super__.destroy.call(this)},c.prototype.show=function(){var a;return this.options.showEffect?(a=Tourist.Tip.Bootstrap.effects[this.options.showEffect],a.call(this,this.tip,this.tip.el)):this.tip.show()},c.prototype.hide=function(){var a;return this.options.hideEffect?(a=Tourist.Tip.Bootstrap.effects[this.options.hideEffect],a.call(this,this.tip,this.tip.el)):this.tip.hide()},c.prototype._getTipElement=function(){return this.tip.el},c.prototype._setTarget=function(a,b){return c.__super__._setTarget.call(this,a,b),this.tip.setTarget(a)},c.prototype._renderContent=function(a,b){var c,d;return d=a.my||"left center",c=a.at||"right center",this.tip.setContainer(a.container||$("body")),this.tip.setContent(b),this.tip.setPosition(a.target||!1,d,c)},c}(Tourist.Tip.Base),Tourist.Tip.Bootstrap.effects={slidein:function(a,b){var c,d,e,f,g,h,i,j,k;for(c={top:80,left:80,right:-80,bottom:-80},h=a.my.split(" ")[0],h=h||"top",g=c[h],"bottom"===h&&(h="top"),"right"===h&&(h="left"),i=parseInt(b.css(h)),b.stop(),d={},d[h]=i+g,b.css(d),b.show(),d[h]=i,f=["easeOutCubic","swing","linear"],j=0,k=f.length;k>j&&(e=f[j],!$.easing[e]);j++);return b.animate(d,300,e),null}},Tourist.Tip.BootstrapTip=function(){function a(a){var b;b={offset:10,tipOffset:10},this.options=_.extend(b,a),this.el=$($.parseHTML(this.template)),this.hide()}return a.prototype.template='<div class="popover tourist-popover">\n <div class="arrow"></div>\n <div class="popover-content"></div>\n</div>',a.prototype.FLIP_POSITION={bottom:"top",top:"bottom",left:"right",right:"left"},a.prototype.destroy=function(){return this.el.remove()},a.prototype.show=function(){return this.el.show().addClass("visible")},a.prototype.hide=function(){return this.el.hide().removeClass("visible")},a.prototype.setTarget=function(a){return this.target=a,this._setPosition(this.target,this.my,this.at)},a.prototype.setPosition=function(a,b,c){return this.target=a,this.my=b,this.at=c,this._setPosition(this.target,this.my,this.at)},a.prototype.setContainer=function(a){return a.append(this.el)},a.prototype.setContent=function(a){return this._getContentElement().html(a)},a.prototype._getContentElement=function(){return this.el.find(".popover-content")},a.prototype._getTipElement=function(){return this.el.find(".arrow")},a.prototype._setPosition=function(a,b,c){var d,e,f,g,h,i,j,k,l,m;return null==b&&(b="left center"),null==c&&(c="right center"),a&&(m=b.split(" "),d=m[0],h=m[1],f=this.el.css("display"),this.el.css({top:0,left:0,margin:0,display:"block"}).removeClass("top").removeClass("bottom").removeClass("left").removeClass("right").addClass(this.FLIP_POSITION[d]),a)?(j=this._getTipElement().css({left:"",right:"",top:"",bottom:""}),"center"!==h&&(k={left:j[0].offsetWidth/2,right:0,top:j[0].offsetHeight/2,bottom:0},e={},e[h]=k[h]+this.options.tipOffset,e[this.FLIP_POSITION[h]]="auto",j.css(e)),i=this._caculateTargetPosition(c,a),l=this._caculateTipPosition(b,i),g=this._adjustForArrow(b,l),this.el.css(g),this.el.css({display:f})):void 0},a.prototype._caculateTargetPosition=function(a,b){var c,d;return"[object Array]"===Object.prototype.toString.call(b)?{left:b[0],top:b[1]}:(c=this._getTargetBounds(b),d=this._lookupPosition(a,c.width,c.height),{left:c.left+d[0],top:c.top+d[1]})},a.prototype._caculateTipPosition=function(a,b){var c,d,e;return e=this.el[0].offsetWidth,c=this.el[0].offsetHeight,d=this._lookupPosition(a,e,c),{left:b.left-d[0],top:b.top-d[1]}},a.prototype._adjustForArrow=function(a,b){var c,d,e,f,g,h,i;switch(i=a.split(" "),c=i[0],f=i[1],g=this._getTipElement(),h=g[0].offsetWidth,d=g[0].offsetHeight,e={top:b.top,left:b.left},c){case"top":e.top+=d+this.options.offset;break;case"bottom":e.top-=d+this.options.offset;break;case"left":e.left+=h+this.options.offset;break;case"right":e.left-=h+this.options.offset}switch(f){case"left":e.left-=h/2+this.options.tipOffset;break;case"right":e.left+=h/2+this.options.tipOffset;break;case"top":e.top-=d/2+this.options.tipOffset;break;case"bottom":e.top+=d/2+this.options.tipOffset}return e},a.prototype._lookupPosition=function(a,b,c){var d,e,f;return f=b/2,d=c/2,e={"top left":[0,0],"left top":[0,0],"top right":[b,0],"right top":[b,0],"bottom left":[0,c],"left bottom":[0,c],"bottom right":[b,c],"right bottom":[b,c],"top center":[f,0],"left center":[0,d],"right center":[b,d],"bottom center":[f,c]},e[a]},a.prototype._getTargetBounds=function(a){var b,c;return b=a[0],c="function"==typeof b.getBoundingClientRect?b.getBoundingClientRect():{width:b.offsetWidth,height:b.offsetHeight},$.extend({},c,a.offset())},a}(),Tourist.Tip.QTip=function(a){function b(){return this._renderTipBackground=g(this._renderTipBackground,this),c=b.__super__.constructor.apply(this,arguments)}var d,e,h,i;return f(b,a),i=6,h=14,d=10,e={top:80,left:80,right:-80,bottom:-80},b.prototype.QTIP_DEFAULTS={content:{text:" "},show:{ready:!1,delay:0,effect:function(a){var b,c,d,f,g;return c=$(this),f=a.options.position.my,f&&(f=f[f.precedance]),f=f||"top",d=e[f],"bottom"===f&&(f="top"),"right"===f&&(f="left"),g=parseInt(c.css(f)),b={},b[f]=g+d,c.css(b),c.show(),b[f]=g,c.animate(b,300,"easeOutCubic"),null},autofocus:!1},hide:{event:null,delay:0,effect:!1},position:{adjust:{method:"shift shift",scroll:!1}},style:{classes:"ui-tour-tip",tip:{height:i,width:h}},events:{},zindex:2e3},b.prototype.initialize=function(a){return a=$.extend(!0,{},this.QTIP_DEFAULTS,a),this.el.qtip(a),this.qtip=this.el.qtip("api"),this.qtip.render()},b.prototype.destroy=function(){return this.qtip&&this.qtip.destroy(),b.__super__.destroy.call(this)},b.prototype.show=function(){return this.qtip.show()},b.prototype.hide=function(){return this.qtip.hide()},b.prototype._getTipElement=function(){return $("#qtip-"+this.qtip.id)},b.prototype._setTarget=function(a,c){return b.__super__._setTarget.call(this,a,c),this.qtip.set("position.target",a||!1)},b.prototype._renderContent=function(a,b){var c,d,e=this;return d=a.my||"left center",c=a.at||"right center",this._adjustPlacement(d,c),this.qtip.set("content.text",b),this.qtip.set("position.container",a.container||$("body")),this.qtip.set("position.my",d),this.qtip.set("position.at",c),this.qtip.set("position.viewport",a.viewport||!1),this.qtip.set("position.target",a.target||!1),setTimeout(function(){return e._renderTipBackground(d.split(" ")[0])},10)},b.prototype._adjustPlacement=function(a){return 0===a.indexOf("top")?this._adjust(0,d):0===a.indexOf("bottom")?this._adjust(0,-d):0===a.indexOf("right")?this._adjust(-d,0):this._adjust(d,0)},b.prototype._adjust=function(a,b){return this.qtip.set("position.adjust.x",a),this.qtip.set("position.adjust.y",b)},b.prototype._renderTipBackground=function(a){var b,c;return c=$("#qtip-"+this.qtip.id+" .qtip-tip"),b=c.find(".qtip-tip-bg"),b.length||(b=$("<div/>",{"class":"icon icon-tip qtip-tip-bg"}),c.append(b)),b.removeClass("top left right bottom"),b.addClass(a)},b}(Tourist.Tip.Base),Tourist.Tip.Simple=function(a){function b(){return d=b.__super__.constructor.apply(this,arguments)}return f(b,a),b.prototype.initialize=function(){return $("body").append(this.el)},b.prototype.show=function(){return this.el.show()},b.prototype.hide=function(){return this.el.hide()},b.prototype._getTipElement=function(){return this.el},b.prototype._renderContent=function(a,b){return this.el.html(b)},b}(Tourist.Tip.Base),Tourist.Tour=function(){function a(a){var b,c;this.options=null!=a?a:{},this.onChangeCurrentStep=g(this.onChangeCurrentStep,this),this.next=g(this.next,this),b={tipClass:"Bootstrap"},this.options=_.extend(b,this.options),this.model=new Tourist.Model({current_step:null}),c=_.extend({model:this.model},this.options.tipOptions),this.view=new Tourist.Tip[this.options.tipClass](c),this.view.bind("click:close",_.bind(this.stop,this,!0)),this.view.bind("click:next",this.next),this.model.bind("change:current_step",this.onChangeCurrentStep)}return _.extend(a.prototype,Backbone.Events),a.prototype.start=function(){return this.trigger("start",this),this.next()},a.prototype.stop=function(a){return a?this._showCancelFinalStep():this._stop()},a.prototype.next=function(){var a,b;return a=this._teardownCurrentStep(),b=0,a&&(b=a.index+1),b<this.options.steps.length?this._showStep(this.options.steps[b],b):b===this.options.steps.length?this._showSuccessFinalStep():this._stop()},a.prototype.setStepOptions=function(a){return this.options.stepOptions=a},a.prototype.onChangeCurrentStep=function(a,b){return this.view.render(b)},a.prototype._showCancelFinalStep=function(){return this._showFinalStep(!1)},a.prototype._showSuccessFinalStep=function(){return this._showFinalStep(!0)},a.prototype._teardownCurrentStep=function(){var a;return a=this.model.get("current_step"),this._teardownStep(a),a},a.prototype._stop=function(){return this._teardownCurrentStep(),this.model.set({current_step:null}),this.trigger("stop",this)},a.prototype._showFinalStep=function(a){var b,c;return b=this._teardownCurrentStep(),c=a?this.options.successStep:this.options.cancelStep,_.isFunction(c)&&(c.call(this,this,this.options.stepOptions),c=null),c?b&&b.final?this._stop():(c.final=!0,this._showStep(c,this.options.steps.length)):this._stop()},a.prototype._showStep=function(a,b){return a?(a=_.clone(a),a.index=b,a.total=this.options.steps.length,a.final||(a.final=this.options.steps.length===b+1&&!this.options.successStep),a=_.extend(a,this._setupStep(a)),this.model.set({current_step:a})):void 0},a.prototype._setupStep=function(a){var b,c,d,e;if(!a||!a.setup)return{};if(a.bind)for(e=a.bind,c=0,d=e.length;d>c;c++)b=e[c],a[b]=_.bind(a[b],a,this,this.options.stepOptions);return a.setup.call(a,this,this.options.stepOptions)||{}},a.prototype._teardownStep=function(a){return a&&a.teardown&&a.teardown.call(a,this,this.options.stepOptions),this.view.cleanupCurrentTarget()},a}()}).call(this);