You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
6 lines
3.9 KiB
6 lines
3.9 KiB
9 years ago
|
/*!
|
||
|
* remark (http://getbootstrapadmin.com/remark)
|
||
|
* Copyright 2016 amazingsurge
|
||
|
* Licensed under the Themeforest Standard Licenses
|
||
|
*/
|
||
|
!function(window,document,$){"use strict";$.site.menu={speed:250,init:function(){this.$instance=$(".site-menu"),0!==this.$instance.length&&this.bind()},bind:function(){var self=this;this.$instance.on("mouseenter.site.menu",".site-menu-item",function(e){var $item=$(this);if($item.is(".has-sub")&&$item.parent(".site-menu").length>0){var $sub=$item.children(".site-menu-sub");self.position($item,$sub)}$item.addClass("hover")}).on("mouseleave.site.menu",".site-menu-item",function(){var $item=$(this);$item.is(".has-sub")&&$item.parent(".site-menu").length>0&&$item.children(".site-menu-sub").css("max-height",""),$item.removeClass("hover")}).on("deactive.site.menu",".site-menu-item.active",function(e){var $item=$(this);$item.removeClass("active"),e.stopPropagation()}).on("active.site.menu",".site-menu-item",function(e){var $item=$(this);$item.addClass("active"),e.stopPropagation()}).on("open.site.menu",".site-menu-item",function(e){var $item=$(this);self.expand($item,function(){$item.addClass("open")}),$item.siblings(".open").trigger("close.site.menu"),e.stopPropagation()}).on("close.site.menu",".site-menu-item.open",function(e){var $item=$(this);self.collapse($item,function(){$item.removeClass("open")}),e.stopPropagation()}).on("click.site.menu ",".site-menu-item",function(e){var $item=$(this);0==$item.parent(".site-menu").length&&$item.is(".has-sub")&&$(e.target).closest(".site-menu-item").is(this)?$item.is(".open")?$item.trigger("close.site.menu"):$item.trigger("open.site.menu"):$item.is(".active")||($item.siblings(".active").trigger("deactive.site.menu"),$item.trigger("active.site.menu")),e.stopPropagation()}).on("tap.site.menu","> .site-menu-item",function(){var $item=$(this);if($item.is(".has-sub")&&$item.parent(".site-menu").length>0)if($item.siblings(".hover").each(function(){var $item=$(this);$item.is(".has-sub")&&$item.parent(".site-menu").length>0&&$item.children(".site-menu-sub").css("max-height",""),$item.removeClass("hover")}),$item.is(".hover"))$item.is(".has-sub")&&$item.parent(".site-menu").length>0&&$item.children(".site-menu-sub").css("max-height",""),$item.removeClass("hover");else{if($item.is(".has-sub")&&$item.parent(".site-menu").length>0){var $sub=$item.children(".site-menu-sub");self.position($item,$sub)}$item.addClass("hover")}else{var $link=$(this).find("a");if($link.length>0){var link=$link.attr("href");link&&(window.location=link)}}}).on("scroll.site.menu",".site-menu-sub",function(e){e.stopPropagation()})},collapse:function($item,callback){var self=this,$sub=$item.children(".site-menu-sub");$sub.show().slideUp(this.speed,function(){$(this).css("display",""),$(this).find("> .site-menu-item").removeClass("is-shown"),callback&&callback(),self.$instance.trigger("collapsed.site.menu")})},expand:function($item,callback){var self=this,$sub=$item.children(".site-menu-sub"),$children=$sub.children(".site-menu-item").addClass("is-hidden");$sub.hide().slideDown(this.speed,function(){$(this).css("display",""),callback&&callback(),self.$instance.trigger("expanded.site.menu")}),setTimeout(function(){$children.addClass("is-shown"),$children.removeClass("is-hidden")},0)},refresh:function(){this.$instance.find(".open").filter(":not(.active)").removeClass("open")},position:function($item,$dropdown){var offsetTop=$item.position().top,menubarHeight=($dropdown.outerHeight(),$.site.menubar.$instance.outerHeight()),itemHeight=$item.find("> a").outerHeight();$dropdown.removeClass("site-menu-sub-up").css("max-height",""),offsetTop>menubarHeight/2?($dropdown.addClass("site-menu-sub-up"),$.site.menubar.foldAlt&&(offsetTop-=itemHeight),$dropdown.css("max-height",offsetTop+itemHeight)):($.site.menubar.foldAlt&&(offsetTop+=itemHeight),$dropdown.removeClass("site-menu-sub-up"),$dropdown.css("max-height",menubarHeight-offsetTop))}}}(window,document,jQuery);
|