diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-02-01 18:57:07 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-02-01 18:57:07 -0500 |
commit | 7283692c1d565ec262546bdc816e8a5004df86ea (patch) | |
tree | 6ed15509134de3fda8d37895c4801695a2fa4307 /assets/js/vendor/dropit.min.js | |
parent | 695ed5701c4151dcab53fbdec1f21b0277cb7cf7 (diff) |
Add dropdown menu to the tasks
Diffstat (limited to 'assets/js/vendor/dropit.min.js')
-rw-r--r-- | assets/js/vendor/dropit.min.js | 103 |
1 files changed, 99 insertions, 4 deletions
diff --git a/assets/js/vendor/dropit.min.js b/assets/js/vendor/dropit.min.js index 2864544b..bcb48bcd 100644 --- a/assets/js/vendor/dropit.min.js +++ b/assets/js/vendor/dropit.min.js @@ -1,4 +1,99 @@ -(function(b){b.fn.dropit=function(c){var d={init:function(c){this.dropit.settings=b.extend({},this.dropit.defaults,c);return this.each(function(){var c=b(this),a=b.fn.dropit.settings;c.addClass("dropit").find(">"+a.triggerParentEl+":has("+a.submenuEl+")").addClass("dropit-trigger").find(a.submenuEl).addClass("dropit-submenu").hide();c.on(a.action,a.triggerParentEl+":has("+a.submenuEl+") > "+a.triggerEl+"",function(){if("click"==a.action&&b(this).parents(a.triggerParentEl).hasClass("dropit-open"))return a.beforeHide.call(this), -b(this).parents(a.triggerParentEl).removeClass("dropit-open").find(a.submenuEl).hide(),a.afterHide.call(this),!1;a.beforeHide.call(this);b(".dropit-open").removeClass("dropit-open").find(".dropit-submenu").hide();a.afterHide.call(this);a.beforeShow.call(this);b(this).parents(a.triggerParentEl).addClass("dropit-open").find(a.submenuEl).show();a.afterShow.call(this);return!1});b(document).on("click",function(){a.beforeHide.call(this);b(".dropit-open").removeClass("dropit-open").find(".dropit-submenu").hide(); -a.afterHide.call(this)});if("mouseenter"==a.action)c.on("mouseleave",function(){a.beforeHide.call(this);b(this).removeClass("dropit-open").find(a.submenuEl).hide();a.afterHide.call(this)});a.afterLoad.call(this)})}};if(d[c])return d[c].apply(this,Array.prototype.slice.call(arguments,1));if("object"!==typeof c&&c)b.error('Method "'+c+'" does not exist in dropit plugin!');else return d.init.apply(this,arguments)};b.fn.dropit.defaults={action:"click",submenuEl:"ul",triggerEl:"a",triggerParentEl:"li", -afterLoad:function(){},beforeShow:function(){},afterShow:function(){},beforeHide:function(){},afterHide:function(){}};b.fn.dropit.settings={}})(jQuery);
\ No newline at end of file +/* + * Dropit v1.1.0 + * http://dev7studios.com/dropit + * + * Copyright 2012, Dev7studios + * Free to use and abuse under the MIT license. + * http://www.opensource.org/licenses/mit-license.php + */ + +;(function($) { + + $.fn.dropit = function(method) { + + var methods = { + + init : function(options) { + this.dropit.settings = $.extend({}, this.dropit.defaults, options); + return this.each(function() { + var $el = $(this), + el = this, + settings = $.fn.dropit.settings; + + // Hide initial submenus + $el.addClass('dropit') + .find('>'+ settings.triggerParentEl +':has('+ settings.submenuEl +')').addClass('dropit-trigger') + .find(settings.submenuEl).addClass('dropit-submenu').hide(); + + // Open on click + $el.on(settings.action, settings.triggerParentEl +':has('+ settings.submenuEl +') > '+ settings.triggerEl +'', function(){ + // Close click menu's if clicked again + if(settings.action == 'click' && $(this).parents(settings.triggerParentEl).hasClass('dropit-open')){ + settings.beforeHide.call(this); + $(this).parent().removeClass('dropit-open').find(settings.submenuEl).hide(); + // $(this).parents(settings.triggerParentEl).removeClass('dropit-open').find(settings.submenuEl).hide(); + settings.afterHide.call(this); + return false; + } + + // Hide open menus + settings.beforeHide.call(this); + $('.dropit-open').removeClass('dropit-open').find('.dropit-submenu').hide(); + settings.afterHide.call(this); + + // Open this menu + settings.beforeShow.call(this); + $(this).parent().addClass('dropit-open').find(settings.submenuEl).show(); + // $(this).parents(settings.triggerParentEl).addClass('dropit-open').find(settings.submenuEl).show(); + settings.afterShow.call(this); + + return false; + }); + + // Close if outside click + $(document).on('click', function(){ + settings.beforeHide.call(this); + $('.dropit-open').removeClass('dropit-open').find('.dropit-submenu').hide(); + settings.afterHide.call(this); + }); + + // If hover + if(settings.action == 'mouseenter'){ + $el.on('mouseleave', function(){ + settings.beforeHide.call(this); + $(this).removeClass('dropit-open').find(settings.submenuEl).hide(); + settings.afterHide.call(this); + }); + } + + settings.afterLoad.call(this); + }); + } + + }; + + if (methods[method]) { + return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); + } else if (typeof method === 'object' || !method) { + return methods.init.apply(this, arguments); + } else { + $.error( 'Method "' + method + '" does not exist in dropit plugin!'); + } + + }; + + $.fn.dropit.defaults = { + action: 'click', // The open action for the trigger + submenuEl: 'ul', // The submenu element + triggerEl: 'a', // The trigger element + triggerParentEl: 'li', // The trigger parent element + afterLoad: function(){}, // Triggers when plugin has loaded + beforeShow: function(){}, // Triggers before submenu is shown + afterShow: function(){}, // Triggers after submenu is shown + beforeHide: function(){}, // Triggers before submenu is hidden + afterHide: function(){} // Triggers before submenu is hidden + }; + + $.fn.dropit.settings = {}; + +})(jQuery);
\ No newline at end of file |