-
Notifications
You must be signed in to change notification settings - Fork 1
/
dropdown-menu.min.js
3 lines (3 loc) · 3.07 KB
/
dropdown-menu.min.js
1
2
3
// jQuery().dropdown_menu() by Daniel Upshaw 2012-2013
// http://danielupshaw.com/jquery-css-dropdown-plugin/readme.html
(function(e,t,n,r){e.fn.extend({dropdown_menu:function(r){var i={sub_indicator_class:"dropdown-menu-sub-indicator",vertical_class:"dropdown-menu-vertical",shadow_class:"dropdown-menu-shadow",hover_class:"dropdown-menu-hover",open_delay:150,close_delay:300,animation_open:{opacity:"show"},speed_open:"fast",animation_close:{opacity:"hide"},speed_close:"fast",sub_indicators:false,drop_shadows:false,vertical:false,viewport_overflow:"auto",init:function(){}};version=parseFloat(navigator.appVersion.split("MSIE")[1]);var s=version<8&&n.body.filters;return this.each(function(){var n=e(this);var o=n.data("options");var u=e.extend({},i,r,o);var a=e('<span class="'+u.sub_indicator_class+'">»</span>');if(u.vertical){n.addClass(u.vertical_class)}e(">li",n).css({"font-size":n.css("font-size")});n.css({"font-size":"0"});n.find("li:has(ul)").each(function(){e(this).addClass(u.sub_indicator_class);if(u.sub_indicators){e(">a:first-child",this).append(a.clone())}var n=e(">ul",this).css({visibility:"hidden",display:"block"});if(u.drop_shadows){n.addClass(u.shadow_class)}if(s){setTimeout(function(){n.css({width:n.width()})},0)}e(this).on({mouseenter:function(r){clearTimeout(e(this).data("close_timer"));clearTimeout(e(this).data("open_timer"));if(e(this).hasClass(u.hover_class)){return}e(this).data("open_timer",setTimeout(e.proxy(function(){e(this).addClass(u.hover_class);if(u.vertical){n.css({top:0,left:e(this).width()})}else{n.css({top:"",left:""})}n.css({visibility:"hidden",display:"block"});overflow_x=n.offset().left+n.width()>e(t).scrollLeft()+e(t).width();overflow_y=n.offset().top+n.height()>e(t).scrollTop()+e(t).height();overflow=overflow_x||overflow_y;if(overflow&&u.viewport_overflow){var r=10;if(u.viewport_overflow==="auto")u.viewport_overflow=s?"scroll":"move";switch(u.viewport_overflow){case"move":var i=overflow_x?e(t).scrollLeft()+e(t).width()-n.width()-r:n.offset().left;var o=overflow_y?e(t).scrollTop()+e(t).height()-n.height()-r:n.offset().top;n.offset({left:i,top:o});break;case"scroll":if(overflow_x){var a=n.offset().left-e(t).width()+n.width()+r;e("html").animate({scrollLeft:a},"fast")}if(overflow_y){var f=n.offset().top-e(t).height()+n.height()+r;e("html").animate({scrollTop:f},"fast")}break}}n.hide().css({visibility:"visible"});if(u.animation_open){n.animate(u.animation_open,u.speed_open)}else{n.show()}},this),u.open_delay))},mouseleave:function(t){clearTimeout(e(this).data("close_timer"));clearTimeout(e(this).data("open_timer"));e(this).data("close_timer",setTimeout(e.proxy(function(){e(this).removeClass(u.hover_class);if(u.animation_close){n.animate(u.animation_close,u.speed_close,function(){n.css({visibility:"hidden"})})}else{n.hide().css({visibility:"hidden"})}},this),u.close_delay))},touchstart:function(t){e(">a:first-child",this).one("click",e.proxy(function(t){if(!e(this).hasClass(u.hover_class)){t.preventDefault()}else{return true}},this))}})});setTimeout(function(){e("ul",n).hide(1).promise().done(function(){u.init.call(n[0])})},0)})}})})(jQuery,window,document)