1 line
5.3 KiB
JavaScript
Executable file
1 line
5.3 KiB
JavaScript
Executable file
!function($){function DropDown(el){this.dd=el,this.initEvents()}DropDown.prototype={initEvents:function(){this.dd.on("click",function(event){$(this).toggleClass("dropdown-active"),event.stopPropagation()}),$(".dropdown-hover").mouseenter(function(event){$(this).addClass("dropdown-active"),event.stopPropagation()})}},$.fn.responsiveNav=function(){this.each(function(){var labelState=$(this).hasClass("nav-responsive-text");return $(this).naver({maxWidth:"768px",label:labelState})})},$.fn.calculateWidth=function(){return $(this).width()},$.fn.nonResponsive=function(){this.each(function(){if($(this).hasClass("non-responsive")){var i=($(".container").width(),1),max=24;if($(this).hasClass("gutters"))for(;max>=i;i++){var columnWidth=$(".column-"+i).calculateWidth(),gutterWidth=.02*columnWidth;$(".gutters .column-"+i).css("width",columnWidth-gutterWidth+"px")}else for(;max>=i;i++){var columnWidth=$(".column-"+i).calculateWidth()-1;$(".column-"+i).css("width",columnWidth+"px")}}})},$(function(){var dropdown=$(".dropdown");new DropDown(dropdown),$(document).click(function(){dropdown.removeClass("dropdown-active")}),$(".dropdown-menu").mouseleave(function(){dropdown.removeClass("dropdown-active")})})}(jQuery),jQuery(document).ready(function(){jQuery(".nav-responsive, .nav-responsive-left, .nav-responsive-center").responsiveNav(),jQuery("body, .row").nonResponsive()}),function($,window){"use strict";function _init(opts){opts=$.extend(!0,{},options,opts);for(var $items=$(this),i=0,count=$items.length;count>i;i++)_build($items.eq(i),opts);return $items}function _build($nav,opts){if(!$nav.data("naver")){opts=$.extend(!0,{},opts,$nav.data("naver-options"));var $handle=$nav.find(".naver-handle").length?$nav.find(".naver-handle").detach():$('<span class="naver-handle"></span>');$nav.addClass("naver "+opts.customClass).wrapInner('<div class="naver-container"></div>').wrapInner('<div class="naver-wrapper"></div>').prepend($handle);var data=$.extend(!0,{$nav:$nav,$container:$nav.find(".naver-container"),$wrapper:$nav.find(".naver-wrapper"),$handle:$nav.find(".naver-handle")},opts);data.$handle.text(opts.label?opts.labels.closed:""),data.$nav.on("touchstart.naver",".naver-handle",data,_onTouchStart).on("click.naver",".naver-handle",data,_onClick).data("naver",data),void 0!==window.matchMedia&&(data.mediaQuery=window.matchMedia("(max-width:"+(1/0===data.maxWidth?"100000px":data.maxWidth)+")"),data.mediaQuery.addListener(function(){_onRespond.apply(data.$nav)}),_onRespond.apply(data.$nav))}}function _onTouchStart(e){e.stopPropagation();var data=e.data,oe=e.originalEvent;_clearTimer(data.timer),data.touchStartX=oe.touches[0].clientX,data.touchStartY=oe.touches[0].clientY,data.$nav.on("touchmove.naver",".naver-handle",data,_onTouchMove).on("touchend.naver",".naver-handle",data,_onTouchEnd)}function _onTouchMove(e){var data=e.data,oe=e.originalEvent;(Math.abs(oe.touches[0].clientX-data.touchStartX)>10||Math.abs(oe.touches[0].clientY-data.touchStartY)>10)&&data.$nav.off("touchmove.naver touchend.naver")}function _onTouchEnd(e){e.preventDefault(),e.stopPropagation();var data=e.data;data.$nav.off("touchmove.naver touchend.naver click.naver"),data.timer=_startTimer(data.timer,1e3,function(){data.$nav.on("click.naver",".naver-handle",data,_onClick)}),_onClick(e)}function _onClick(e){e.preventDefault(),e.stopPropagation();var data=($(e.currentTarget),e.data);$(".naver").not(data.$nav).naver("close"),data.$nav.hasClass("open")?pub.close.apply(data.$nav):pub.open.apply(data.$nav)}function _onRespond(){var data=$(this).data("naver");data.mediaQuery.matches?pub.enable.apply(data.$nav):pub.disable.apply(data.$nav)}function _startTimer(timer,time,func,interval){return _clearTimer(timer,interval),interval===!0?setInterval(func,time):setTimeout(func,time)}function _clearTimer(timer){null!==timer&&(clearInterval(timer),timer=null)}var options={customClass:"",label:!0,labels:{closed:"Navigation",open:"Close"},maxWidth:"980px"},pub={close:function(){return $(this).each(function(i,nav){var data=$(nav).data("naver");data&&data.$nav.hasClass("enabled")&&(data.$wrapper.css({height:0}),data.label&&data.$handle.html(data.labels.closed),data.$nav.removeClass("open").trigger("close.naver"))})},defaults:function(opts){return options=$.extend(!0,options,opts||{}),$(this)},disable:function(){return $(this).each(function(i,nav){var data=$(nav).data("naver");data&&(data.$nav.removeClass("enabled"),data.$wrapper.css({height:""}))})},destroy:function(){return $(this).each(function(i,nav){var data=$(nav).data("naver");data&&(data.$handle.remove(),data.$container.contents().unwrap().unwrap(),data.$nav.removeClass("enabled disabled naver "+data.customClass).off(".naver").removeData("naver"))})},enable:function(){return $(this).each(function(i,nav){var data=$(nav).data("naver");data&&(data.$nav.addClass("enabled"),pub.close.apply(data.$nav))})},open:function(){return $(this).each(function(i,nav){var data=$(nav).data("naver");data&&data.$nav.hasClass("enabled")&&(data.$wrapper.css({height:data.$container.outerHeight(!0)}),data.label&&data.$handle.html(data.labels.open),data.$nav.addClass("open").trigger("open.naver"))})}};$.fn.naver=function(method){return pub[method]?pub[method].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof method&&method?this:_init.apply(this,arguments)},$.naver=function(method){"defaults"===method&&pub.defaults.apply(this,Array.prototype.slice.call(arguments,1))}}(jQuery,window);
|