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