From 7cb35d90be20ccca5b16b7c44fd2d3ec932872f4 Mon Sep 17 00:00:00 2001 From: Chris Hallgren Date: Wed, 24 Dec 2014 21:42:11 -0600 Subject: [PATCH 1/2] Fixes #13 --- css/plugins/metisMenu/metisMenu.css | 5 +- css/plugins/metisMenu/metisMenu.min.css | 11 +++- js/plugins/metisMenu/metisMenu.js | 86 +++++++++++++++++++------ js/plugins/metisMenu/metisMenu.min.js | 6 +- 4 files changed, 83 insertions(+), 25 deletions(-) diff --git a/css/plugins/metisMenu/metisMenu.css b/css/plugins/metisMenu/metisMenu.css index 77cdfa2..76376c3 100644 --- a/css/plugins/metisMenu/metisMenu.css +++ b/css/plugins/metisMenu/metisMenu.css @@ -1,13 +1,14 @@ /* - * metismenu - v1.0.3 + * metismenu - v1.1.3 * Easy menu jQuery plugin for Twitter Bootstrap 3 * https://github.com/onokumus/metisMenu * - * Made by Osman Nuri Okumuş + * Made by Osman Nuri Okumus * Under MIT License */ .arrow { float: right; + line-height: 1.42857; } .glyphicon.arrow:before { diff --git a/css/plugins/metisMenu/metisMenu.min.css b/css/plugins/metisMenu/metisMenu.min.css index 6df69bd..a1d0ef3 100644 --- a/css/plugins/metisMenu/metisMenu.min.css +++ b/css/plugins/metisMenu/metisMenu.min.css @@ -1 +1,10 @@ -.arrow{float:right}.glyphicon.arrow:before{content:"\e079"}.active>a>.glyphicon.arrow:before{content:"\e114"}.fa.arrow:before{content:"\f104"}.active>a>.fa.arrow:before{content:"\f107"}.plus-times{float:right}.fa.plus-times:before{content:"\f067"}.active>a>.fa.plus-times{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-ms-transform:rotate(45deg);-o-transform:rotate(45deg);transform:rotate(45deg)}.plus-minus{float:right}.fa.plus-minus:before{content:"\f067"}.active>a>.fa.plus-minus:before{content:"\f068"} \ No newline at end of file +/* + * metismenu - v1.1.3 + * Easy menu jQuery plugin for Twitter Bootstrap 3 + * https://github.com/onokumus/metisMenu + * + * Made by Osman Nuri Okumus + * Under MIT License + */ + +.arrow{float:right;line-height:1.42857}.glyphicon.arrow:before{content:"\e079"}.active>a>.glyphicon.arrow:before{content:"\e114"}.fa.arrow:before{content:"\f104"}.active>a>.fa.arrow:before{content:"\f107"}.plus-times{float:right}.fa.plus-times:before{content:"\f067"}.active>a>.fa.plus-times{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-ms-transform:rotate(45deg);-o-transform:rotate(45deg);transform:rotate(45deg)}.plus-minus{float:right}.fa.plus-minus:before{content:"\f067"}.active>a>.fa.plus-minus:before{content:"\f068"} \ No newline at end of file diff --git a/js/plugins/metisMenu/metisMenu.js b/js/plugins/metisMenu/metisMenu.js index 9f8d627..3785904 100644 --- a/js/plugins/metisMenu/metisMenu.js +++ b/js/plugins/metisMenu/metisMenu.js @@ -1,20 +1,21 @@ /* - * metismenu - v1.0.3 + * metismenu - v1.1.3 * Easy menu jQuery plugin for Twitter Bootstrap 3 * https://github.com/onokumus/metisMenu * - * Made by Osman Nuri Okumuş + * Made by Osman Nuri Okumus * Under MIT License */ -;(function ($, window, document, undefined) { +;(function($, window, document, undefined) { var pluginName = "metisMenu", defaults = { - toggle: true + toggle: true, + doubleTapToGo: false }; - + function Plugin(element, options) { - this.element = element; + this.element = $(element); this.settings = $.extend({}, defaults, options); this._defaults = defaults; this._name = pluginName; @@ -22,10 +23,11 @@ } Plugin.prototype = { - init: function () { + init: function() { - var $this = $(this.element), - $toggle = this.settings.toggle; + var $this = this.element, + $toggle = this.settings.toggle, + obj = this; if (this.isIE() <= 9) { $this.find("li.active").has("ul").children("ul").collapse("show"); @@ -35,18 +37,35 @@ $this.find("li").not(".active").has("ul").children("ul").addClass("collapse"); } - $this.find("li").has("ul").children("a").on("click", function (e) { + //add the "doubleTapToGo" class to active items if needed + if (obj.settings.doubleTapToGo) { + $this.find("li.active").has("ul").children("a").addClass("doubleTapToGo"); + } + + $this.find("li").has("ul").children("a").on("click" + "." + pluginName, function(e) { e.preventDefault(); + //Do we need to enable the double tap + if (obj.settings.doubleTapToGo) { + + //if we hit a second time on the link and the href is valid, navigate to that url + if (obj.doubleTapToGo($(this)) && $(this).attr("href") !== "#" && $(this).attr("href") !== "") { + e.stopPropagation(); + document.location = $(this).attr("href"); + return; + } + } + $(this).parent("li").toggleClass("active").children("ul").collapse("toggle"); if ($toggle) { $(this).parent("li").siblings().removeClass("active").children("ul.in").collapse("hide"); } + }); }, - isIE: function() {//https://gist.github.com/padolsey/527683 + isIE: function() { //https://gist.github.com/padolsey/527683 var undef, v = 3, div = document.createElement("div"), @@ -58,15 +77,44 @@ ) { return v > 4 ? v : undef; } - } - }; + }, - $.fn[ pluginName ] = function (options) { - return this.each(function () { - if (!$.data(this, "plugin_" + pluginName)) { - $.data(this, "plugin_" + pluginName, new Plugin(this, options)); + //Enable the link on the second click. + doubleTapToGo: function(elem) { + var $this = this.element; + + //if the class "doubleTapToGo" exists, remove it and return + if (elem.hasClass("doubleTapToGo")) { + elem.removeClass("doubleTapToGo"); + return true; } - }); + + //does not exists, add a new class and return false + if (elem.parent().children("ul").length) { + //first remove all other class + $this.find(".doubleTapToGo").removeClass("doubleTapToGo"); + //add the class on the current element + elem.addClass("doubleTapToGo"); + return false; + } + }, + + remove: function() { + this.element.off("." + pluginName); + this.element.removeData(pluginName); + } + }; -})(jQuery, window, document); + $.fn[pluginName] = function(options) { + this.each(function () { + var el = $(this); + if (el.data(pluginName)) { + el.data(pluginName).remove(); + } + el.data(pluginName, new Plugin(this, options)); + }); + return this; + }; + +})(jQuery, window, document); \ No newline at end of file diff --git a/js/plugins/metisMenu/metisMenu.min.js b/js/plugins/metisMenu/metisMenu.min.js index 03ac02b..8a590e7 100644 --- a/js/plugins/metisMenu/metisMenu.min.js +++ b/js/plugins/metisMenu/metisMenu.min.js @@ -1,9 +1,9 @@ /* - * metismenu - v1.0.3 + * metismenu - v1.1.3 * Easy menu jQuery plugin for Twitter Bootstrap 3 * https://github.com/onokumus/metisMenu * - * Made by Osman Nuri Okumuş + * Made by Osman Nuri Okumus * Under MIT License */ -!function(a,b,c){function d(b,c){this.element=b,this.settings=a.extend({},f,c),this._defaults=f,this._name=e,this.init()}var e="metisMenu",f={toggle:!0};d.prototype={init:function(){var b=a(this.element),c=this.settings.toggle;this.isIE()<=9?(b.find("li.active").has("ul").children("ul").collapse("show"),b.find("li").not(".active").has("ul").children("ul").collapse("hide")):(b.find("li.active").has("ul").children("ul").addClass("collapse in"),b.find("li").not(".active").has("ul").children("ul").addClass("collapse")),b.find("li").has("ul").children("a").on("click",function(b){b.preventDefault(),a(this).parent("li").toggleClass("active").children("ul").collapse("toggle"),c&&a(this).parent("li").siblings().removeClass("active").children("ul.in").collapse("hide")})},isIE:function(){for(var a,b=3,d=c.createElement("div"),e=d.getElementsByTagName("i");d.innerHTML="",e[0];)return b>4?b:a}},a.fn[e]=function(b){return this.each(function(){a.data(this,"plugin_"+e)||a.data(this,"plugin_"+e,new d(this,b))})}}(jQuery,window,document); \ No newline at end of file +!function(a,b,c){function d(b,c){this.element=a(b),this.settings=a.extend({},f,c),this._defaults=f,this._name=e,this.init()}var e="metisMenu",f={toggle:!0,doubleTapToGo:!1};d.prototype={init:function(){var b=this.element,d=this.settings.toggle,f=this;this.isIE()<=9?(b.find("li.active").has("ul").children("ul").collapse("show"),b.find("li").not(".active").has("ul").children("ul").collapse("hide")):(b.find("li.active").has("ul").children("ul").addClass("collapse in"),b.find("li").not(".active").has("ul").children("ul").addClass("collapse")),f.settings.doubleTapToGo&&b.find("li.active").has("ul").children("a").addClass("doubleTapToGo"),b.find("li").has("ul").children("a").on("click."+e,function(b){return b.preventDefault(),f.settings.doubleTapToGo&&f.doubleTapToGo(a(this))&&"#"!==a(this).attr("href")&&""!==a(this).attr("href")?(b.stopPropagation(),void(c.location=a(this).attr("href"))):(a(this).parent("li").toggleClass("active").children("ul").collapse("toggle"),void(d&&a(this).parent("li").siblings().removeClass("active").children("ul.in").collapse("hide")))})},isIE:function(){for(var a,b=3,d=c.createElement("div"),e=d.getElementsByTagName("i");d.innerHTML="",e[0];)return b>4?b:a},doubleTapToGo:function(a){var b=this.element;return a.hasClass("doubleTapToGo")?(a.removeClass("doubleTapToGo"),!0):a.parent().children("ul").length?(b.find(".doubleTapToGo").removeClass("doubleTapToGo"),a.addClass("doubleTapToGo"),!1):void 0},remove:function(){this.element.off("."+e),this.element.removeData(e)}},a.fn[e]=function(b){return this.each(function(){var c=a(this);c.data(e)&&c.data(e).remove(),c.data(e,new d(this,b))}),this}}(jQuery,window,document); \ No newline at end of file From 6aa0323eb92e166d21d49c8d8124766c321c2be9 Mon Sep 17 00:00:00 2001 From: Chris Hallgren Date: Wed, 24 Dec 2014 22:44:34 -0600 Subject: [PATCH 2/2] Fixes #18 and removes all nav classes with active since the javascript will automatically add them based on the url. --- buttons.html | 4 ++-- flot.html | 4 ++-- forms.html | 2 +- grid.html | 4 ++-- icons.html | 4 ++-- index.html | 6 +++--- js/sb-admin-2.js | 8 ++++++++ morris.html | 4 ++-- notifications.html | 4 ++-- panels-wells.html | 4 ++-- tables.html | 2 +- typography.html | 4 ++-- 12 files changed, 29 insertions(+), 21 deletions(-) diff --git a/buttons.html b/buttons.html index 7952564..6dabcb6 100644 --- a/buttons.html +++ b/buttons.html @@ -297,14 +297,14 @@
  • Forms
  • -
  • +
  • UI Elements