header.js
11.1 KB
/*! dili 2016-01-06 */
!function(e,t,n){"use strict";var i,r=t.event;r.special.smartresize={setup:function(){t(this).bind("resize",r.special.smartresize.handler)},teardown:function(){t(this).unbind("resize",r.special.smartresize.handler)},handler:function(e,t){var n=this,s=arguments;e.type="smartresize",i&&clearTimeout(i),i=setTimeout(function(){r.dispatch.apply(n,s)},"execAsap"===t?0:100)}},t.fn.smartresize=function(e){return e?this.bind("smartresize",e):this.trigger("smartresize",["execAsap"])},t.Mason=function(e,n){this.element=t(n),this._create(e),this._init()},t.Mason.settings={isResizable:!0,isAnimated:!1,animationOptions:{queue:!1,duration:500},gutterWidth:0,isRTL:!1,isFitWidth:!1,containerStyle:{position:"relative"}},t.Mason.prototype={_filterFindBricks:function(e){var t=this.options.itemSelector;return t?e.filter(t).add(e.find(t)):e},_getBricks:function(e){var t=this._filterFindBricks(e).css({position:"absolute"}).addClass("masonry-brick");return t},_create:function(n){this.options=t.extend(!0,{},t.Mason.settings,n),this.styleQueue=[];var r=this.element[0].style;this.originalStyle={height:r.height||""};var i=this.options.containerStyle;for(var s in i)this.originalStyle[s]=r[s]||"";this.element.css(i),this.horizontalDirection=this.options.isRTL?"right":"left";var o=this.element.css("padding-"+this.horizontalDirection),u=this.element.css("padding-top");this.offset={x:o?parseInt(o,10):0,y:u?parseInt(u,10):0},this.isFluid=this.options.columnWidth&&"function"==typeof this.options.columnWidth;var a=this;setTimeout(function(){a.element.addClass("masonry")},0),this.options.isResizable&&t(e).bind("smartresize.masonry",function(){a.resize()}),this.reloadItems()},_init:function(e){this._getColumns(),this._reLayout(e)},option:function(e,n){t.isPlainObject(e)&&(this.options=t.extend(!0,this.options,e))},layout:function(e,t){for(var n=0,r=e.length;r>n;n++)this._placeBrick(e[n]);var i={};if(i.height=Math.max.apply(Math,this.colYs),this.options.isFitWidth){var s=0;for(n=this.cols;--n&&0===this.colYs[n];)s++;i.width=(this.cols-s)*this.columnWidth-this.options.gutterWidth}this.styleQueue.push({$el:this.element,style:i});var a,o=this.isLaidOut&&this.options.isAnimated?"animate":"css",u=this.options.animationOptions;for(n=0,r=this.styleQueue.length;r>n;n++)a=this.styleQueue[n],a.$el[o](a.style,u);this.styleQueue=[],t&&t.call(e),this.isLaidOut=!0},_getColumns:function(){var e=this.options.isFitWidth?this.element.parent():this.element,t=e.width();this.columnWidth=this.isFluid?this.options.columnWidth(t):this.options.columnWidth||this.$bricks.outerWidth(!0)||t,this.columnWidth+=this.options.gutterWidth,this.cols=Math.floor((t+this.options.gutterWidth)/this.columnWidth),this.cols=Math.max(this.cols,1)},_placeBrick:function(e){var r,i,s,o,u,n=t(e);if(r=Math.ceil(n.outerWidth(!0)/this.columnWidth),r=Math.min(r,this.cols),1===r)s=this.colYs;else for(i=this.cols+1-r,s=[],u=0;i>u;u++)o=this.colYs.slice(u,u+r),s[u]=Math.max.apply(Math,o);for(var a=Math.min.apply(Math,s),f=0,l=0,c=s.length;c>l;l++)if(s[l]===a){f=l;break}var h={top:a+this.offset.y};h[this.horizontalDirection]=this.columnWidth*f+this.offset.x,this.styleQueue.push({$el:n,style:h});var p=a+n.outerHeight(!0),d=this.cols+1-c;for(l=0;d>l;l++)this.colYs[f+l]=p},resize:function(){var e=this.cols;this._getColumns(),(this.isFluid||this.cols!==e)&&this._reLayout()},_reLayout:function(e){var t=this.cols;for(this.colYs=[];t--;)this.colYs.push(0);this.layout(this.$bricks,e)},reloadItems:function(){this.$bricks=this._getBricks(this.element.children())},reload:function(e){this.reloadItems(),this._init(e)},appended:function(e,t,n){if(t){this._filterFindBricks(e).css({top:this.element.height()});var r=this;setTimeout(function(){r._appended(e,n)},1)}else this._appended(e,n)},_appended:function(e,t){var n=this._getBricks(e);this.$bricks=this.$bricks.add(n),this.layout(n,t)},remove:function(e){this.$bricks=this.$bricks.not(e),e.remove()},destroy:function(){this.$bricks.removeClass("masonry-brick").each(function(){this.style.position="",this.style.top="",this.style.left=""});var n=this.element[0].style;for(var r in this.originalStyle)n[r]=this.originalStyle[r];this.element.unbind(".masonry").removeClass("masonry").removeData("masonry"),t(e).unbind(".masonry")}},t.fn.imagesLoaded=function(e){function u(){e.call(n,r)}function a(e){var n=e.target;n.src!==s&&-1===t.inArray(n,o)&&(o.push(n),--i<=0&&(setTimeout(u),r.unbind(".imagesLoaded",a)))}var n=this,r=n.find("img").add(n.filter("img")),i=r.length,s="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==",o=[];return i||u(),r.bind("load.imagesLoaded error.imagesLoaded",a).each(function(){var e=this.src;this.src=s,this.src=e}),n};var s=function(t){e.console&&e.console.error(t)};t.fn.masonry=function(e){if("string"==typeof e){var n=Array.prototype.slice.call(arguments,1);this.each(function(){var r=t.data(this,"masonry");return r?t.isFunction(r[e])&&"_"!==e.charAt(0)?void r[e].apply(r,n):void s("no such method '"+e+"' for masonry instance"):void s("cannot call methods on masonry prior to initialization; attempted to call method '"+e+"'")})}else this.each(function(){var n=t.data(this,"masonry");n?(n.option(e||{}),n._init()):t.data(this,"masonry",new t.Mason(e,this))});return this}}(window,jQuery),function($){function init(opts){var $menu=$(this),activeRow=null,mouseLocs=[],lastDelayLoc=null,timeoutId=null,options=$.extend({rowSelector:"> li",submenuSelector:"*",submenuDirection:"right",tolerance:75,enter:$.noop,exit:$.noop,activate:$.noop,deactivate:$.noop,exitMenu:$.noop},opts),MOUSE_LOCS_TRACKED=3,DELAY=300,mousemoveDocument=function(e){mouseLocs.push({x:e.pageX,y:e.pageY}),mouseLocs.length>MOUSE_LOCS_TRACKED&&mouseLocs.shift()},mouseleaveMenu=function(){timeoutId&&clearTimeout(timeoutId),options.exitMenu(this)&&(activeRow&&options.deactivate(activeRow),activeRow=null),activeRow=null},mouseenterRow=function(){timeoutId&&clearTimeout(timeoutId),options.enter(this),possiblyActivate(this)},mouseleaveRow=function(){options.exit(this)},clickRow=function(){activate(this)},activate=function(row){row!=activeRow&&(activeRow&&options.deactivate(activeRow),options.activate(row),activeRow=row)},possiblyActivate=function(row){var delay=activationDelay();delay?timeoutId=setTimeout(function(){possiblyActivate(row)},delay):activate(row)},activationDelay=function(){function slope(a,b){return(b.y-a.y)/(b.x-a.x)}if(!activeRow||!$(activeRow).is(options.submenuSelector))return 0;var offset=$menu.offset(),upperLeft={x:offset.left,y:offset.top-options.tolerance},upperRight={x:offset.left+$menu.outerWidth(),y:upperLeft.y},lowerLeft={x:offset.left,y:offset.top+$menu.outerHeight()+options.tolerance},lowerRight={x:offset.left+$menu.outerWidth(),y:lowerLeft.y},loc=mouseLocs[mouseLocs.length-1],prevLoc=mouseLocs[0];if(!loc)return 0;if(prevLoc||(prevLoc=loc),prevLoc.x<offset.left||prevLoc.x>lowerRight.x||prevLoc.y<offset.top||prevLoc.y>lowerRight.y)return 0;if(lastDelayLoc&&loc.x==lastDelayLoc.x&&loc.y==lastDelayLoc.y)return 0;var decreasingCorner=upperRight,increasingCorner=lowerRight;"left"==options.submenuDirection?(decreasingCorner=lowerLeft,increasingCorner=upperLeft):"below"==options.submenuDirection?(decreasingCorner=lowerRight,increasingCorner=lowerLeft):"above"==options.submenuDirection&&(decreasingCorner=upperLeft,increasingCorner=upperRight);var decreasingSlope=slope(loc,decreasingCorner),increasingSlope=slope(loc,increasingCorner),prevDecreasingSlope=slope(prevLoc,decreasingCorner),prevIncreasingSlope=slope(prevLoc,increasingCorner);return prevDecreasingSlope>decreasingSlope&&increasingSlope>prevIncreasingSlope?(lastDelayLoc=loc,DELAY):(lastDelayLoc=null,0)};$menu.mouseleave(mouseleaveMenu).find(options.rowSelector).mouseenter(mouseenterRow).mouseleave(mouseleaveRow).click(clickRow),$(document).mousemove(mousemoveDocument)}$.fn.menuAim=function(opts){return this.each(function(){init.call(this,opts)}),this}}(jQuery),define("event",function(require,exports){function transit(target,options){this.target=target,this.opt={pauseGroup:null,onOver:function(){},onOut:function(){}},$.extend(this.opt,options),this.init()}var events={x:function(ev){return ev.pageX||ev.clientX+$(document).scrollLeft()},y:function(ev){return ev.pageY||ev.clientY+$(document).scrollTop()}};events.transit=function(target,options){$(target).each(function(){new transit(this,options)})};var transit_tick_timer=null,transit_timers=[];return transit.prototype={init:function(){var _this=this,target=this.target;target.onTrigger=function(){clearInterval(this.timer),clearTimeout(this.outTimer),this._triggered=!0,this._onOver.call(_this,this)},this.bind()},bind:function(){var _this=this;$(this.target).bind("mouseover.transit",function(event){_this.onStart(this,event)}),$(this.target).bind("mousemove.transit",function(event){_this.onProcess(event)}),$(this.target).bind("mouseout.transit",function(event){_this.onStop()})},bindGroup:function(target){var _this=this,group=this.opt.pauseGroup;group&&group.length&&(group.unbind("mouseover.transit").bind("mouseover.transit",function(event){clearTimeout(_this.current.outTimer)}),group.unbind("mouseout.transit").bind("mouseout.transit",function(event){_this.onStop()}))},onStart:function(target,event){var _this=this;target._onOver=this.opt.onOver,target._onOut=this.opt.onOut,this.current=target,this.coorArr=[.123456,.654321],this.clear(),this.tick(),clearTimeout(_this.current.outTimer),this.bindGroup(target),transit_timers.push(this.current),this.current.timer=setInterval(function(){_this.coorArr.push(_this.coor),_this.compareCoor()},23)},onProcess:function(event){this.coor=[event.pageX,event.pageY]},onStop:function(){var _this=this;return this.clear(),this.current&&$(this.current).length?(clearTimeout(this.current.outTimer),void(this.current.outTimer=setTimeout(function(){_this.current._triggered&&(_this.current._onOut.call(_this,_this.current),_this.current._triggered=!1)},24))):!1},compareCoor:function(){var arr=this.coorArr,len=arr.length,lastCoor=arr[len-1],prevCoor=arr[len-2];lastCoor[0]==prevCoor[0]&&lastCoor[1]==prevCoor[1]&&this.current.onTrigger()},clear:function(){for(var i=0;i<transit_timers.length;i++){var target=transit_timers[i];target===this.current&&(clearInterval(this.current.timer),transit_timers.splice(i,1))}},tick:function(){clearTimeout(transit_tick_timer),transit_tick_timer=setTimeout(function(){if(transit_timers.length)for(var i=0;i<transit_timers.length;i++){var target=transit_timers[i];clearInterval(target.timer),transit_timers.splice(i,1)}},3e3)}},events}),define(function(require,exports,module){require("event");require("menuaim"),$(function(){var Nav={open:function(target){var _target=$(target);_target.addClass("current").siblings().removeClass("current")},close:function(target){$(target)},closeAll:function(){$("#menu-box").find(">li.current").removeClass("current")}};$("#menu-box").length>0&&($("#menu-box").menuAim({enter:Nav.open,activate:Nav.open,deactivate:Nav.close,exitMenu:Nav.closeAll}),$(".multistage-menu").hover(function(){var _this=$(this),menuList=$(this).find(".menu-list");menuList.is(":hidden")&&!$(_this).hasClass("indexNav")&&(menuList.show(),$(_this).addClass("selected"))},function(){var _this=$(this),menuList=$(this).find(".menu-list");menuList.is(":hidden")||$(_this).hasClass("indexNav")||(menuList.hide(),$(_this).removeClass("selected"))}))})});