mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-25 18:47:57 +01:00
05f2c58aa9
- refresh of used js libs
1 line
9.0 KiB
JavaScript
1 line
9.0 KiB
JavaScript
(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._setupOptions(),this._configureElement(),this._configureTarget(),this._configureScroll(),this._setupEvents(),this.bus._log("leg "+this.index+" made with options",this.options)}return a.prototype.render=function(){var a,b;return a="centered"===this.options.orientation?"":"tourbus-arrow",this.$el.addClass(" "+a+" tourbus-arrow-"+this.options.orientation+" "),b="<div class='tourbus-leg-inner'>\n "+this.content+"\n</div>",this.$el.css({width:this.options.width}).html(b),this},a.prototype.destroy=function(){return this.$el.remove(),this._teardownEvents()},a.prototype.reposition=function(){return this._configureTarget(),this._position()},a.prototype._position=function(){var a,b,c,d;return"centered"!==this.options.orientation&&(c={},b={top:"left",bottom:"left",left:"top",right:"top"},"number"==typeof this.options.arrow&&(this.options.arrow+="px"),c[b[this.options.orientation]]=this.options.arrow,d="#"+this.id+".tourbus-arrow",this.bus._log("adding rule for "+this.id,c),h(""+d+":before, "+d+":after",c)),a=this._offsets(),this.bus._log("setting offsets on leg",a),this.$el.css(a)},a.prototype.show=function(){return this.$el.css({visibility:"visible",opacity:1,zIndex:9999}),this.scrollIntoView()},a.prototype.hide=function(){return this.bus.options.debug?this.$el.css({visibility:"visible",opacity:.4,zIndex:0}):this.$el.css({visibility:"hidden"})},a.prototype.scrollIntoView=function(){var a;if(this.willScroll)return a=k(this.options.scrollTo,this.$el),this.bus._log("scrolling to",a,this.scrollSettings),b.scrollTo(a,this.scrollSettings)},a.prototype._setupOptions=function(){var a;return a=this.bus.options.leg,this.options.top=k(this.rawData.top,a.top),this.options.left=k(this.rawData.left,a.left),this.options.scrollTo=k(this.rawData.scrollTo,a.scrollTo),this.options.scrollSpeed=k(this.rawData.scrollSpeed,a.scrollSpeed),this.options.scrollContext=k(this.rawData.scrollContext,a.scrollContext),this.options.margin=k(this.rawData.margin,a.margin),this.options.arrow=this.rawData.arrow||a.arrow,this.options.align=this.rawData.align||a.align,this.options.width=this.rawData.width||a.width,this.options.orientation=this.rawData.orientation||a.orientation},a.prototype._configureElement=function(){return this.id="tourbus-leg-id-"+this.bus.id+"-"+this.options.index,this.$el=b("<div class='tourbus-leg'></div>"),this.el=this.$el[0],this.$el.attr({id:this.id}),this.$el.css({zIndex:9999})},a.prototype._setupEvents=function(){return this.$el.on("click",".tourbus-next",b.proxy(this.bus.next,this.bus)),this.$el.on("click",".tourbus-prev",b.proxy(this.bus.prev,this.bus)),this.$el.on("click",".tourbus-stop",b.proxy(this.bus.stop,this.bus))},a.prototype._teardownEvents=function(){return this.$el.off("click")},a.prototype._configureTarget=function(){return this.targetOffset=this.$target.offset(),k(this.options.top,!1)&&(this.targetOffset.top=this.options.top),k(this.options.left,!1)&&(this.targetOffset.left=this.options.left),this.targetWidth=this.$target.outerWidth(),this.targetHeight=this.$target.outerHeight()},a.prototype._configureScroll=function(){return this.willScroll=b.fn.scrollTo&&this.options.scrollTo!==!1,this.scrollSettings={offset:-this.options.scrollContext,easing:"linear",axis:"y",duration:this.options.scrollSpeed}},a.prototype._offsets=function(){var a,c,d,e,f,g,h,i;switch(d=this.$el.height(),e=this.$el.width(),f={},this.options.orientation){case"centered":h=b(window).height(),f.top=this.options.top,k(f.top,!1)||(f.top=h/2-d/2),f.left=this.targetWidth/2-e/2;break;case"left":f.top=this.targetOffset.top,f.left=this.targetOffset.left-e-this.options.margin;break;case"right":f.top=this.targetOffset.top,f.left=this.targetOffset.left+this.targetWidth+this.options.margin;break;case"top":f.top=this.targetOffset.top-d-this.options.margin,f.left=this.targetOffset.left;break;case"bottom":f.top=this.targetOffset.top+this.targetHeight+this.options.margin,f.left=this.targetOffset.left}if(i={top:["left","right"],bottom:["left","right"],left:["top","bottom"],right:["top","bottom"]},l(this.options.orientation,i[this.options.align]))switch(this.options.align){case"right":f.left+=this.targetWidth-e;break;case"bottom":f.top+=this.targetHeight-d}else"center"===this.options.align&&(l(this.options.orientation,i.left)?(g=this.targetWidth/2,c=e/2,a="left"):(g=this.targetHeight/2,c=d/2,a="top"),g>c?f[a]+=g-c:f[a]-=c-g);return f},a}(),m=0,g=function(){return m++},j={},i=function(){var a;return a=function(a,b,c){c.prototype=a.prototype;var d=new c,e=a.apply(d,b);return Object(e)===e?e:d}(c,arguments,function(){}),j[a.id]=a,a},k=function(a,b){return null===a||"undefined"==typeof a?b:a},l=function(a,c){return-1!==b.inArray(a,c||[])},h=function(a){var c;return a.type="text/css",document.getElementsByTagName("head")[0].appendChild(a),c=document.styleSheets[document.styleSheets.length-1],function(a,d){var e,f;f=b.map(function(){var a;a=[];for(e in d)a.push(e);return a}(),function(a){return""+a+":"+d[a]}).join(";");try{c.insertRule?c.insertRule(""+a+" { "+f+" }",(c.cssRules||c.rules).length):c.addRule(a,f)}catch(g){}}}(document.createElement("style"))}(jQuery)}).call(this); |