alchemy-ajatar-theme
Version:
1 lines • 1.52 kB
JavaScript
!function(e){var t=function(){var t=[];var n=false;var r;var i=function(e){clearTimeout(r);r=setTimeout(s,100)};var s=function(){for(var e=0,n=t.length;e<n;e++){t[e].apply()}};return{register:function(r){t.push(r);if(n===false){e(window).bind("resize",i);n=true}},unregister:function(e){for(var n=0,r=t.length;n<r;n++){if(t[n]==e){delete t[n];break}}}}}();var n=function(n,r){this.element=e(n);this.dropdown=e('<li class="dropdown hide pull-right tabdrop">'+'<a class="dropdown-toggle" data-toggle="dropdown" href="#">'+r.text+' <b class="caret"></b></a>'+'<ul class="dropdown-menu"></ul></li>').prependTo(this.element);if(this.element.parent().is(".tabs-below")){this.dropdown.addClass("dropup")}t.register(e.proxy(this.layout,this));this.layout()};n.prototype={constructor:n,layout:function(){var t=[];this.dropdown.removeClass("hide");this.element.append(this.dropdown.find("li")).find(">li").not(".tabdrop").each(function(){if(this.offsetTop>0){t.push(this)}});if(t.length>0){t=e(t);this.dropdown.find("ul").empty().append(t);if(this.dropdown.find(".active").length==1){this.dropdown.addClass("active")}else{this.dropdown.removeClass("active")}}else{this.dropdown.addClass("hide")}}};e.fn.tabdrop=function(t){return this.each(function(){var r=e(this),i=r.data("tabdrop"),s=typeof t==="object"&&t;if(!i){r.data("tabdrop",i=new n(this,e.extend({},e.fn.tabdrop.defaults,s)))}if(typeof t=="string"){i[t]()}})};e.fn.tabdrop.defaults={text:'<i class="icon-align-justify"></i>'};e.fn.tabdrop.Constructor=n}(window.jQuery)