diff options
author | Filipp Lepalaan <f@230.to> | 2014-02-17 14:40:45 +0200 |
---|---|---|
committer | Filipp Lepalaan <f@230.to> | 2014-02-17 14:40:45 +0200 |
commit | b494dfc0933c28729eaf8bc2105bbeb28d24ceae (patch) | |
tree | cedbd44afcbe0db0b0392617b42565004fed9f76 /apps/it/static/js/plugins/metisMenu | |
download | pudding-b494dfc0933c28729eaf8bc2105bbeb28d24ceae.tar.gz pudding-b494dfc0933c28729eaf8bc2105bbeb28d24ceae.tar.bz2 pudding-b494dfc0933c28729eaf8bc2105bbeb28d24ceae.zip |
Initial commit
Diffstat (limited to 'apps/it/static/js/plugins/metisMenu')
-rwxr-xr-x | apps/it/static/js/plugins/metisMenu/jquery.metisMenu.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/apps/it/static/js/plugins/metisMenu/jquery.metisMenu.js b/apps/it/static/js/plugins/metisMenu/jquery.metisMenu.js new file mode 100755 index 0000000..36a8098 --- /dev/null +++ b/apps/it/static/js/plugins/metisMenu/jquery.metisMenu.js @@ -0,0 +1,45 @@ +;(function ($, window, document, undefined) { + + var pluginName = "metisMenu", + defaults = { + toggle: true + }; + + function Plugin(element, options) { + this.element = element; + this.settings = $.extend({}, defaults, options); + this._defaults = defaults; + this._name = pluginName; + this.init(); + } + + Plugin.prototype = { + init: function () { + + var $this = $(this.element), + $toggle = this.settings.toggle; + + $this.find('li.active').has('ul').children('ul').addClass('collapse in'); + $this.find('li').not('.active').has('ul').children('ul').addClass('collapse'); + + $this.find('li').has('ul').children('a').on('click', function (e) { + e.preventDefault(); + + $(this).parent('li').toggleClass('active').children('ul').collapse('toggle'); + + if ($toggle) { + $(this).parent('li').siblings().removeClass('active').children('ul.in').collapse('hide'); + } + }); + } + }; + + $.fn[ pluginName ] = function (options) { + return this.each(function () { + if (!$.data(this, "plugin_" + pluginName)) { + $.data(this, "plugin_" + pluginName, new Plugin(this, options)); + } + }); + }; + +})(jQuery, window, document); |