From 9df0ff63654355d41359ccd5f3f4f6fb01ed421a Mon Sep 17 00:00:00 2001 From: Osman Nuri Okumus Date: Sat, 23 Aug 2014 23:02:42 +0300 Subject: [PATCH] update v2.1.2 --- .editorconfig | 11 + Gruntfile.js | 125 +++++----- bower.json | 9 +- dist/metisMenu.css | 51 ++-- dist/metisMenu.js | 195 ++++++++------- dist/metisMenu.min.css | 4 +- dist/metisMenu.min.js | 4 +- package.json | 6 +- src/metisMenu.css | 49 ++-- src/metisMenu.js | 193 +++++++-------- test/hover.html | 365 ++++++++++++++------------- test/index.html | 550 +++++++++++++++++++++++------------------ test/metisFolder.html | 370 +++++++++++++-------------- 13 files changed, 1013 insertions(+), 919 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c94db9a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +# This file is for unifying the coding style for different editors and IDEs +# editorconfig.org + +root = true + +[*] +indent_style = tab +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/Gruntfile.js b/Gruntfile.js index bffba85..434d7b8 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,65 +1,66 @@ "use strict"; module.exports = function(grunt) { - grunt.initConfig({ - pkg: grunt.file.readJSON("package.json"), - - banner: "/*\n" + - " * <%= pkg.title || pkg.name %> - v<%= pkg.version %>\n" + - " * <%= pkg.description %>\n" + - " * <%= pkg.homepage %>\n" + - " *\n" + - " * Made by <%= pkg.author.name %>\n" + - " * Under <%= pkg.license %> License\n" + - " */\n", - - jshint: { - options: { - jshintrc: ".jshintrc" - }, - all: [ - "Gruntfile.js", - "src/metisMenu.js" - ] - }, - concat: { - plugin: { - src: ["src/metisMenu.js"], - dest: "dist/metisMenu.js" - }, - css: { - src: ["src/metisMenu.css"], - dest: "dist/metisMenu.css" - }, - options: { - banner: "<%= banner %>" - } - }, - uglify: { - plugin: { - src: ["dist/metisMenu.js"], - dest: "dist/metisMenu.min.js" - }, - options: { - banner: "<%= banner %>" - } - }, - cssmin: { - options: { - banner: "<%= banner %>" - }, - menucss: { - src: ["src/metisMenu.css"], - dest: "dist/metisMenu.min.css" - } - } - }); - - grunt.loadNpmTasks("grunt-contrib-jshint"); - grunt.loadNpmTasks("grunt-contrib-concat"); - grunt.loadNpmTasks("grunt-contrib-uglify"); - grunt.loadNpmTasks("grunt-contrib-cssmin"); - - grunt.registerTask("travis", ["jshint"]); - grunt.registerTask("default", ["jshint", "concat", "uglify", "cssmin"]); -}; \ No newline at end of file + grunt.initConfig({ + pkg: grunt.file.readJSON("package.json"), + + banner: "/*\n" + + " * <%= pkg.title || pkg.name %> - v<%= pkg.version %>\n" + + " * <%= pkg.description %>\n" + + " * <%= pkg.homepage %>\n" + + " *\n" + + " * Made by <%= pkg.author.name %>\n" + + " * Under <%= pkg.license %> License\n" + + " */\n", + + jshint: { + options: { + jshintrc: ".jshintrc" + }, + all: [ + "Gruntfile.js", + "src/metisMenu.js" + ] + }, + concat: { + plugin: { + src: ["src/metisMenu.js"], + dest: "dist/metisMenu.js" + }, + css: { + src: ["src/metisMenu.css"], + dest: "dist/metisMenu.css" + }, + options: { + banner: "<%= banner %>" + } + }, + uglify: { + plugin: { + src: ["dist/metisMenu.js"], + dest: "dist/metisMenu.min.js" + }, + options: { + banner: "<%= banner %>" + } + }, + cssmin: { + options: { + banner: "<%= banner %>", + keepSpecialComments: "0" + }, + menucss: { + src: ["src/metisMenu.css"], + dest: "dist/metisMenu.min.css" + } + } + }); + + grunt.loadNpmTasks("grunt-contrib-jshint"); + grunt.loadNpmTasks("grunt-contrib-concat"); + grunt.loadNpmTasks("grunt-contrib-uglify"); + grunt.loadNpmTasks("grunt-contrib-cssmin"); + + grunt.registerTask("travis", ["jshint"]); + grunt.registerTask("default", ["jshint", "concat", "uglify", "cssmin"]); +}; diff --git a/bower.json b/bower.json index 2d82246..cdab415 100644 --- a/bower.json +++ b/bower.json @@ -1,9 +1,9 @@ { "name": "metisMenu", - "version": "1.1.1", + "version": "1.1.2", "homepage": "https://github.com/onokumus/metisMenu", "authors": [ - "onokumus " + "onokumus (http://onokumus.com)" ], "description": "Easy menu jQuery plugin for Twitter Bootstrap 3", "main": [ @@ -28,5 +28,8 @@ "bower_components", "test", "tests" - ] + ], + "dependencies": { + "bootstrap": "~3.2.0" + } } diff --git a/dist/metisMenu.css b/dist/metisMenu.css index 3a5cfd3..6030133 100644 --- a/dist/metisMenu.css +++ b/dist/metisMenu.css @@ -1,5 +1,5 @@ /* - * metismenu - v1.1.1 + * metismenu - v1.1.2 * Easy menu jQuery plugin for Twitter Bootstrap 3 * https://github.com/onokumus/metisMenu * @@ -7,58 +7,47 @@ * Under MIT License */ .arrow { - float: right; - line-height: 1.42857; //twitter bootstrap body element line-height + float: right; + line-height: 1.42857; + /* twitter bootstrap body element line-height */ } - .glyphicon.arrow:before { - content: "\e079"; + content: "\e079"; } - .active > a > .glyphicon.arrow:before { - content: "\e114"; + content: "\e114"; } - - /* * Require Font-Awesome * http://fortawesome.github.io/Font-Awesome/ */ - .fa.arrow:before { - content: "\f104"; + content: "\f104"; } - .active > a > .fa.arrow:before { - content: "\f107"; + content: "\f107"; } - .plus-times { - float: right; + float: right; } - .fa.plus-times:before { - content: "\f067"; + 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); + 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; + float: right; } - .fa.plus-minus:before { - content: "\f067"; + content: "\f067"; } - .active > a > .fa.plus-minus:before { - content: "\f068"; -} \ No newline at end of file + content: "\f068"; +} diff --git a/dist/metisMenu.js b/dist/metisMenu.js index 710445f..f114a69 100644 --- a/dist/metisMenu.js +++ b/dist/metisMenu.js @@ -1,5 +1,5 @@ /* - * metismenu - v1.1.1 + * metismenu - v1.1.2 * Easy menu jQuery plugin for Twitter Bootstrap 3 * https://github.com/onokumus/metisMenu * @@ -8,105 +8,104 @@ */ ;(function($, window, document, undefined) { - var pluginName = "metisMenu", - defaults = { - toggle: true, - doubleTapToGo: false - }; - - function Plugin(element, options) { - this.element = element; - this.settings = $.extend({}, defaults, options); - this._defaults = defaults; - this._name = pluginName; - this.init(); - } + var pluginName = "metisMenu", + defaults = { + toggle: true, + doubleTapToGo: false + }; - Plugin.prototype = { - init: function() { - - var $this = $(this.element), - $toggle = this.settings.toggle, - obj = this; - - if (this.isIE() <= 9) { - $this.find("li.active").has("ul").children("ul").collapse("show"); - $this.find("li").not(".active").has("ul").children("ul").collapse("hide"); - } else { - $this.find("li.active").has("ul").children("ul").addClass("collapse in"); - $this.find("li").not(".active").has("ul").children("ul").addClass("collapse"); - } - - //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", 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 - var undef, - v = 3, - div = document.createElement("div"), - all = div.getElementsByTagName("i"); - - while ( - div.innerHTML = "", - all[0] - ) { - return v > 4 ? v : undef; - } - }, - - //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; - } + 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, + obj = this; + + if (this.isIE() <= 9) { + $this.find("li.active").has("ul").children("ul").collapse("show"); + $this.find("li").not(".active").has("ul").children("ul").collapse("hide"); + } else { + $this.find("li.active").has("ul").children("ul").addClass("collapse in"); + $this.find("li").not(".active").has("ul").children("ul").addClass("collapse"); + } + + //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", 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"); - $.fn[pluginName] = function(options) { - return this.each(function() { - if (!$.data(this, "plugin_" + pluginName)) { - $.data(this, "plugin_" + pluginName, new Plugin(this, options)); - } - }); - }; + if ($toggle) { + $(this).parent("li").siblings().removeClass("active").children("ul.in").collapse("hide"); + } + + }); + }, + isIE: function() { //https://gist.github.com/padolsey/527683 + var undef, + v = 3, + div = document.createElement("div"), + all = div.getElementsByTagName("i"); + + while ( + div.innerHTML = "", + all[0] + ) { + return v > 4 ? v : undef; + } + }, + //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; + } + } + + }; + + $.fn[pluginName] = function(options) { + this.each(function() { + if (!$.data(this, "plugin_" + pluginName)) { + $.data(this, "plugin_" + pluginName, new Plugin(this, options)); + } + }); + return this; + }; -})(jQuery, window, document); \ No newline at end of file +})(jQuery, window, document); diff --git a/dist/metisMenu.min.css b/dist/metisMenu.min.css index c1b8e3d..7f75d01 100644 --- a/dist/metisMenu.min.css +++ b/dist/metisMenu.min.css @@ -1,5 +1,5 @@ /* - * metismenu - v1.1.1 + * metismenu - v1.1.2 * Easy menu jQuery plugin for Twitter Bootstrap 3 * https://github.com/onokumus/metisMenu * @@ -7,4 +7,4 @@ * Under MIT License */ -.arrow{float:right;line-height:1.42857;://twitter bootstrap body element line-height}.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 +.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/dist/metisMenu.min.js b/dist/metisMenu.min.js index 7ce7b88..017f7fb 100644 --- a/dist/metisMenu.min.js +++ b/dist/metisMenu.min.js @@ -1,9 +1,9 @@ /* - * metismenu - v1.1.1 + * metismenu - v1.1.2 * Easy menu jQuery plugin for Twitter Bootstrap 3 * https://github.com/onokumus/metisMenu * * 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,doubleTapToGo:!1};d.prototype={init:function(){var b=a(this.element),d=this.settings.toggle,e=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")),e.settings.doubleTapToGo&&b.find("li.active").has("ul").children("a").addClass("doubleTapToGo"),b.find("li").has("ul").children("a").on("click",function(b){return b.preventDefault(),e.settings.doubleTapToGo&&e.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(b){var c=a(this.element);return b.hasClass("doubleTapToGo")?(b.removeClass("doubleTapToGo"),!0):b.parent().children("ul").length?(c.find(".doubleTapToGo").removeClass("doubleTapToGo"),b.addClass("doubleTapToGo"),!1):void 0}},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=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=a(this.element),d=this.settings.toggle,e=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")),e.settings.doubleTapToGo&&b.find("li.active").has("ul").children("a").addClass("doubleTapToGo"),b.find("li").has("ul").children("a").on("click",function(b){return b.preventDefault(),e.settings.doubleTapToGo&&e.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(b){var c=a(this.element);return b.hasClass("doubleTapToGo")?(b.removeClass("doubleTapToGo"),!0):b.parent().children("ul").length?(c.find(".doubleTapToGo").removeClass("doubleTapToGo"),b.addClass("doubleTapToGo"),!1):void 0}},a.fn[e]=function(b){return this.each(function(){a.data(this,"plugin_"+e)||a.data(this,"plugin_"+e,new d(this,b))}),this}}(jQuery,window,document); \ No newline at end of file diff --git a/package.json b/package.json index eecc2b9..e341e35 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "metismenu", - "version": "1.1.1", + "version": "1.1.2", "description": "Easy menu jQuery plugin for Twitter Bootstrap 3", "main": "./dist/metisMenu.js", "scripts": { @@ -33,9 +33,9 @@ "homepage": "https://github.com/onokumus/metisMenu", "devDependencies": { "grunt": "^0.4.5", - "grunt-contrib-concat": "^0.4.0", + "grunt-contrib-concat": "^0.5.0", "grunt-contrib-cssmin": "^0.10.0", "grunt-contrib-jshint": "^0.10.0", - "grunt-contrib-uglify": "^0.5.0" + "grunt-contrib-uglify": "^0.5.1" } } diff --git a/src/metisMenu.css b/src/metisMenu.css index 0b53734..3d6e8d5 100644 --- a/src/metisMenu.css +++ b/src/metisMenu.css @@ -1,56 +1,45 @@ .arrow { - float: right; - line-height: 1.42857; //twitter bootstrap body element line-height + float: right; + line-height: 1.42857; + /* twitter bootstrap body element line-height */ } - .glyphicon.arrow:before { - content: "\e079"; + content: "\e079"; } - .active > a > .glyphicon.arrow:before { - content: "\e114"; + content: "\e114"; } - - /* * Require Font-Awesome * http://fortawesome.github.io/Font-Awesome/ */ - .fa.arrow:before { - content: "\f104"; + content: "\f104"; } - .active > a > .fa.arrow:before { - content: "\f107"; + content: "\f107"; } - .plus-times { - float: right; + float: right; } - .fa.plus-times:before { - content: "\f067"; + 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); + 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; + float: right; } - .fa.plus-minus:before { - content: "\f067"; + content: "\f067"; } - .active > a > .fa.plus-minus:before { - content: "\f068"; -} \ No newline at end of file + content: "\f068"; +} diff --git a/src/metisMenu.js b/src/metisMenu.js index 6b9bf8a..634f990 100644 --- a/src/metisMenu.js +++ b/src/metisMenu.js @@ -1,104 +1,103 @@ ;(function($, window, document, undefined) { - var pluginName = "metisMenu", - defaults = { - toggle: true, - doubleTapToGo: false - }; - - function Plugin(element, options) { - this.element = element; - this.settings = $.extend({}, defaults, options); - this._defaults = defaults; - this._name = pluginName; - this.init(); - } + var pluginName = "metisMenu", + defaults = { + toggle: true, + doubleTapToGo: false + }; - Plugin.prototype = { - init: function() { - - var $this = $(this.element), - $toggle = this.settings.toggle, - obj = this; - - if (this.isIE() <= 9) { - $this.find("li.active").has("ul").children("ul").collapse("show"); - $this.find("li").not(".active").has("ul").children("ul").collapse("hide"); - } else { - $this.find("li.active").has("ul").children("ul").addClass("collapse in"); - $this.find("li").not(".active").has("ul").children("ul").addClass("collapse"); - } - - //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", 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 - var undef, - v = 3, - div = document.createElement("div"), - all = div.getElementsByTagName("i"); - - while ( - div.innerHTML = "", - all[0] - ) { - return v > 4 ? v : undef; - } - }, - - //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; - } + 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, + obj = this; + + if (this.isIE() <= 9) { + $this.find("li.active").has("ul").children("ul").collapse("show"); + $this.find("li").not(".active").has("ul").children("ul").collapse("hide"); + } else { + $this.find("li.active").has("ul").children("ul").addClass("collapse in"); + $this.find("li").not(".active").has("ul").children("ul").addClass("collapse"); + } + + //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", 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"); - $.fn[pluginName] = function(options) { - return this.each(function() { - if (!$.data(this, "plugin_" + pluginName)) { - $.data(this, "plugin_" + pluginName, new Plugin(this, options)); - } - }); - }; + if ($toggle) { + $(this).parent("li").siblings().removeClass("active").children("ul.in").collapse("hide"); + } + + }); + }, + isIE: function() { //https://gist.github.com/padolsey/527683 + var undef, + v = 3, + div = document.createElement("div"), + all = div.getElementsByTagName("i"); + + while ( + div.innerHTML = "", + all[0] + ) { + return v > 4 ? v : undef; + } + }, + //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; + } + } + + }; + + $.fn[pluginName] = function(options) { + this.each(function() { + if (!$.data(this, "plugin_" + pluginName)) { + $.data(this, "plugin_" + pluginName, new Plugin(this, options)); + } + }); + return this; + }; -})(jQuery, window, document); \ No newline at end of file +})(jQuery, window, document); diff --git a/test/hover.html b/test/hover.html index 02df966..e9203d8 100644 --- a/test/hover.html +++ b/test/hover.html @@ -1,197 +1,226 @@ + - - - - metisMenu - - - - - - - - - - + - - - - -
- - - +
+
+

Please resize your browser window

+
+
+
- + + - - $('#menu').metisMenu(); - }); - - - + + + + $(window).resize(function() { + clearTimeout(resizeTimer); + resizeTimer = setTimeout(self.initCollapse($this), 250); + }); + + }); + })(jQuery); + + + + diff --git a/test/index.html b/test/index.html index 578705e..6db59f5 100644 --- a/test/index.html +++ b/test/index.html @@ -1,209 +1,255 @@ + - - - - metisMenu + + + + metisMenu - - - - - - + - -
- +
+
+

Auto Collapse default

+
+
+ Code + +
+
+
<script src="jquery.metisMenu.js"></script>
 <script>
     $(function () {
         $('#menu').metisMenu();
     });
 </script>
+
-
- - -
-
-
+
+
+ -
-
-

No Collapse

-
-
- Code - -
-
-
<script src="jquery.metisMenu.js"></script>
+        
+      
+    
+    
+
+

No Collapse

+
+
+ Code + +
+
+
<script src="jquery.metisMenu.js"></script>
 <script>
     $(function () {
         $('#menu2').metisMenu({
@@ -212,73 +258,92 @@ 

No Collapse

}); </script>
+
-
-
-
-
-
-
+
+
+ -
-
-

Double Tap To Go

-
-
- Code - -
-
-
<script src="jquery.metisMenu.js"></script>
+        
+      
+    
+    
+
+

Double Tap To Go

+
+
+ Code + +
+
+
<script src="jquery.metisMenu.js"></script>
 <script>
     $(function () {
         $('#menu3').metisMenu({
@@ -287,32 +352,33 @@ 

Double Tap To Go

}); </script>
+
-
-
-
+ + - - + + - + - + - + + diff --git a/test/metisFolder.html b/test/metisFolder.html index a366e98..d13ce92 100644 --- a/test/metisFolder.html +++ b/test/metisFolder.html @@ -1,191 +1,199 @@ - - metisFolder - - - - - - - - - - - - - - - - - - + + + - - - + + - -