0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-11-23 01:37:55 +01:00
doodle3d-client/www/js/libs/jquery-tourbus.min.js

1 line
9.0 KiB
JavaScript
Raw Normal View History

(function(){var t=[].slice;(function(i){var e,o,s,n,r,h,l,u,a,p,c;return n=i.tourbus=function(){var e,o;return e=arguments.length>=1?t.call(arguments,0):[],o=e[0],s.hasOwnProperty(o)?e=e.slice(1):o instanceof i?o="build":"string"==typeof o?(o="build",e[0]=i(e[0])):i.error("Unknown method of $.tourbus --",e),s[o].apply(this,e)},i.fn.tourbus=function(){var e;return e=arguments.length>=1?t.call(arguments,0):[],this.each(function(){return e.unshift(i(this)),n.apply(null,["build"].concat(t.call(e))),this})},s={build:function(t,e){var o;return null==e&&(e={}),e=i.extend(!0,{},n.defaults,e),o=[],t instanceof i||(t=i(t)),t.each(function(){return o.push(l(this,e))}),0===o.length&&i.error(""+t.selector+" was not found!"),1===o.length?o[0]:o},destroyAll:function(){var t,i,e;e=[];for(i in u)t=u[i],e.push(t.destroy());return e},expose:function(t){return t.tourbus={Bus:e,Leg:o}}},n.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:"50%"}},e=function(){function e(t,e){this.id=r(),this.$target=i(e.target),this.$el=i(t),this.$el.data({tourbus:this}),this.options=e,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",""+t,"and options",this.options)}return e.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()},e.prototype.stop=function(){return this.running?(this.legs&&i.each(this.legs,i.proxy(this.hideLeg,this)),this.currentLegIndex=this.options.startAt,this.options.onStop(this),this.running=!1):void 0},e.prototype.on=function(t,i,e){return this.$target.on(t,i,e)},e.prototype.currentLeg=function(){return null===this.currentLegIndex?null:this.legs[this.currentLegIndex]},e.prototype.showLeg=function(t){var i,e;return null==t&&(t=this.currentLegIndex),i=this.legs[t],this._log("showLeg:",i),e=this.options.onLegStart(i,this),e!==!1?i.show():void 0},e.prototype.hideLeg=function(t){var i,e;return null==t&&(t=this.currentLegIndex),i=this.legs[t],this._log("hideLeg:",i),e=this.options.onLegEnd(i,this),e!==!1?i.hide():void 0},e.prototype.repositionLegs=function(){return this.legs?i.each(this.legs,function(){return this.reposition()}):void 0},e.prototype.next=function(){return this.hideLeg(),this.currentLegIndex++,this.currentLegIndex>this.totalLegs-1?this.stop():this.showLeg()},e.prototype.prev=function(){return this.hideLeg(),this.currentLegIndex--,0>this.currentLegIndex?this.stop():this.showLeg()},e.prototype.destroy=function(){return this.legs&&i.each(this.legs,function(){return this.destroy()}),this.legs=null,delete u[this.id],this._teardownEvents()},e.prototype._buildLegs=function(){var t=this;return this.legs&&i.each(this.legs,function(t,i){return i.destroy()}),i.map(this.legEls,function(e,s){var n,r,h;return n=i(e),r=n.data(),h=new o({content:n.html(),target:r.el||"body",bus:t,index:s,rawData:r}),h.render(),t.$target.append(h.$el),h._position(),h.hide(),h})},e.prototype._log=function(){return this.options.debug?console.log.apply(console,["TOURBUS "+this.id+":"].concat(t.call(arguments))):void 0},e.prototype._setupEvents=function(){return this.$el.on("depart.tourbus",i.proxy(this.depart,this)),this.$el.on("stop.tourbus",i.proxy(this.stop,this)),this.$el.on("next.tourbus",i.proxy(this.next,this)),this.$el.on("prev.tourbus",i.proxy(this.prev,this))},e.prototype._teardownEvents=function(){return this.$el.off(".tourbus")},e}(),o=function(){function t(t){if(this.bus=t.bus,this.rawData=t.rawData,this.content=t.content,this.index=t.index,this.options=t,this.$target=i(t.target),0===this.$target.length)throw""+this.$target.selector+" is not an element!";this._setupOptions(),