0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-11-16 15:47:55 +01:00
doodle3d-client/js_old/libs/jquery-tourbus.min.js

1 line
9.0 KiB
JavaScript
Raw Normal View History

(function(){var a=[].slice;!function(b){var c,d,e,f,g,h,i,j,k,l,m;return f=b.tourbus=function(){var c,d;return c=1<=arguments.length?a.call(arguments,0):[],d=c[0],e.hasOwnProperty(d)?c=c.slice(1):d instanceof b?d="build":"string"==typeof d?(d="build",c[0]=b(c[0])):b.error("Unknown method of $.tourbus --",c),e[d].apply(this,c)},b.fn.tourbus=function(){var c;return c=1<=arguments.length?a.call(arguments,0):[],this.each(function(){return c.unshift(b(this)),f.apply(null,["build"].concat(a.call(c))),this})},e={build:function(a,c){var d;return null==c&&(c={}),c=b.extend(!0,{},f.defaults,c),d=[],a instanceof b||(a=b(a)),a.each(function(){return d.push(i(this,c))}),0===d.length&&b.error(""+a.selector+" was not found!"),1===d.length?d[0]:d},destroyAll:function(){var a,b,c;c=[];for(b in j)a=j[b],c.push(a.destroy());return c},expose:function(a){return a.tourbus={Bus:c,Leg:d}}},f.defaults={debug:!1,autoDepart:!1,target:"body",startAt:0,onDepart:function(){return null},onStop:function(){return null},onLegStart:function(){return null},onLegEnd:function(){return null},leg:{scrollTo:null,scrollSpeed:150,scrollContext:100,orientation:"bottom",align:"left",width:"auto",margin:10,top:null,left:null,arrow:"35%"}},c=function(){function c(a,c){this.id=g(),this.$target=b(c.target),this.$el=b(a),this.$el.data({tourbus:this}),this.options=c,this.currentLegIndex=null,this.legs=null,this.legEls=this.$el.children("li"),this.totalLegs=this.legEls.length,this._setupEvents(),this.options.autoDepart&&this.$el.trigger("depart.tourbus"),this._log("built tourbus with el",a.toString(),"and options",this.options)}return c.prototype.depart=function(){return this.running=!0,this.options.onDepart(this),this._log("departing",this),this.legs=this._buildLegs(),this.currentLegIndex=this.options.startAt,this.showLeg()},c.prototype.stop=function(){return this.running?(this.legs&&b.each(this.legs,b.proxy(this.hideLeg,this)),this.currentLegIndex=this.options.startAt,this.options.onStop(this),this.running=!1):void 0},c.prototype.on=function(a,b,c){return this.$target.on(a,b,c)},c.prototype.currentLeg=function(){return null===this.currentLegIndex?null:this.legs[this.currentLegIndex]},c.prototype.showLeg=function(a){var b,c;return null==a&&(a=this.currentLegIndex),b=this.legs[a],this._log("showLeg:",b),c=this.options.onLegStart(b,this),c!==!1?b.show():void 0},c.prototype.hideLeg=function(a){var b,c;return null==a&&(a=this.currentLegIndex),b=this.legs[a],this._log("hideLeg:",b),c=this.options.onLegEnd(b,this),c!==!1?b.hide():void 0},c.prototype.repositionLegs=function(){return this.legs?b.each(this.legs,function(){return this.reposition()}):void 0},c.prototype.next=function(){return this.hideLeg(),this.currentLegIndex++,this.currentLegIndex>this.totalLegs-1?this.stop():this.showLeg()},c.prototype.prev=function(){return this.hideLeg(),this.currentLegIndex--,this.currentLegIndex<0?this.stop():this.showLeg()},c.prototype.destroy=function(){return this.legs&&b.each(this.legs,function(){return this.destroy()}),this.legs=null,delete j[this.id],this._teardownEvents()},c.prototype._buildLegs=function(){var a=this;return this.legs&&b.each(this.legs,function(a,b){return b.destroy()}),b.map(this.legEls,function(c,e){var f,g,h;return f=b(c),g=f.data(),h=new d({content:f.html(),target:g.el||"body",bus:a,index:e,rawData:g}),h.render(),a.$target.append(h.$el),h._position(),h.hide(),h})},c.prototype._log=function(){return this.options.debug?console.log.apply(console,["TOURBUS "+this.id+":"].concat(a.call(arguments))):void 0},c.prototype._setupEvents=function(){return this.$el.on("depart.tourbus",b.proxy(this.depart,this)),this.$el.on("stop.tourbus",b.proxy(this.stop,this)),this.$el.on("next.tourbus",b.proxy(this.next,this)),this.$el.on("prev.tourbus",b.proxy(this.prev,this))},c.prototype._teardownEvents=function(){return this.$el.off(".tourbus")},c}(),d=function(){function a(a){if(this.bus=a.bus,this.rawData=a.rawData,this.content=a.content,this.index=a.index,this.options=a,this.$target=b(a.target),0===this.$target.length)throw""+this.$target.selector+" is not an element!";this._setupOp