/* * jQuery Dropdown: A simple dropdown plugin * * Contribute: https://github.com/claviska/jquery-dropdown * * @license: MIT license: http://opensource.org/licenses/MIT * * Customized by Yudhistira Mauris (http://www.yudhistiramauris.com/) * */ jQuery&&function(t){function o(o,s){var n=o?t(this):s,a=t(n.attr("data-jq-dropdown")),d=n.hasClass("jq-dropdown-open");if(o){if(t(o.target).hasClass("jq-dropdown-ignore"))return;o.preventDefault(),o.stopPropagation()}else if(n!==s.target&&t(s.target).hasClass("jq-dropdown-ignore"))return;r(),d||n.hasClass("jq-dropdown-disabled")||(n.addClass("jq-dropdown-open"),a.data("jq-dropdown-trigger",n).show(),e(),a.trigger("show",{jqDropdown:a,trigger:n}))}function r(o){var r=o?t(o.target).parents().addBack():null;if(r&&r.is(".jq-dropdown")){if(!r.is(".jq-dropdown-menu"))return;if(!r.is("A"))return}t(document).find(".jq-dropdown:visible").each((function(){var o=t(this);o.hide().removeData("jq-dropdown-trigger").trigger("hide",{jqDropdown:o})})),t(document).find(".jq-dropdown-open").removeClass("jq-dropdown-open")}function e(){var o=t(".jq-dropdown:visible").eq(0),r=o.data("jq-dropdown-trigger"),e=r?parseInt(r.attr("data-horizontal-offset")||0,10):null,s=r?parseInt(r.attr("data-vertical-offset")||0,10):null;if(0!==o.length&&r)if(0===t("#wpadminbar").length)o.hasClass("jq-dropdown-relative")?o.css({left:o.hasClass("jq-dropdown-anchor-right")?r.position().left-(o.outerWidth(!0)-r.outerWidth(!0))-parseInt(r.css("margin-right"),10)+e:r.position().left+parseInt(r.css("margin-left"),10)+e,top:r.position().top+r.outerHeight(!0)-parseInt(r.css("margin-top"),10)+s}):o.css({left:o.hasClass("jq-dropdown-anchor-right")?r.offset().left-(o.outerWidth()-r.outerWidth())+e:r.offset().left+e,top:r.offset().top+r.outerHeight()+s});else{var n=t("#wpadminbar").css("height");n=parseInt(n.replace("px","")),o.hasClass("jq-dropdown-relative")?o.css({left:o.hasClass("jq-dropdown-anchor-right")?r.position().left-(o.outerWidth(!0)-r.outerWidth(!0))-parseInt(r.css("margin-right"),10)+e:r.position().left+parseInt(r.css("margin-left"),10)+e,top:r.position().top+r.outerHeight(!0)-parseInt(r.css("margin-top"),10)+s}):o.css({left:o.hasClass("jq-dropdown-anchor-right")?r.offset().left-(o.outerWidth()-r.outerWidth())+e:r.offset().left+e,top:r.offset().top+r.outerHeight()+s-n})}}t.extend(t.fn,{jqDropdown:function(e,s){switch(e){case"show":return o(null,t(this)),t(this);case"hide":return r(),t(this);case"attach":return t(this).attr("data-jq-dropdown",s);case"detach":return r(),t(this).removeAttr("data-jq-dropdown");case"disable":return t(this).addClass("jq-dropdown-disabled");case"enable":return r(),t(this).removeClass("jq-dropdown-disabled")}}}),t(document).on("click.jq-dropdown","[data-jq-dropdown]",o),t(document).on("click.jq-dropdown",r),t(window).on("resize",e)}(jQuery);