This commit is contained in:
Chris Hallgren
2014-12-24 21:42:11 -06:00
parent 7cdb888014
commit 7cb35d90be
4 changed files with 83 additions and 25 deletions

View File

@@ -1,13 +1,14 @@
/* /*
* metismenu - v1.0.3 * metismenu - v1.1.3
* Easy menu jQuery plugin for Twitter Bootstrap 3 * Easy menu jQuery plugin for Twitter Bootstrap 3
* https://github.com/onokumus/metisMenu * https://github.com/onokumus/metisMenu
* *
* Made by Osman Nuri Okumuş * Made by Osman Nuri Okumus
* Under MIT License * Under MIT License
*/ */
.arrow { .arrow {
float: right; float: right;
line-height: 1.42857;
} }
.glyphicon.arrow:before { .glyphicon.arrow:before {

View File

@@ -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"} /*
* 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"}

View File

@@ -1,20 +1,21 @@
/* /*
* metismenu - v1.0.3 * metismenu - v1.1.3
* Easy menu jQuery plugin for Twitter Bootstrap 3 * Easy menu jQuery plugin for Twitter Bootstrap 3
* https://github.com/onokumus/metisMenu * https://github.com/onokumus/metisMenu
* *
* Made by Osman Nuri Okumuş * Made by Osman Nuri Okumus
* Under MIT License * Under MIT License
*/ */
;(function ($, window, document, undefined) { ;(function($, window, document, undefined) {
var pluginName = "metisMenu", var pluginName = "metisMenu",
defaults = { defaults = {
toggle: true toggle: true,
doubleTapToGo: false
}; };
function Plugin(element, options) { function Plugin(element, options) {
this.element = element; this.element = $(element);
this.settings = $.extend({}, defaults, options); this.settings = $.extend({}, defaults, options);
this._defaults = defaults; this._defaults = defaults;
this._name = pluginName; this._name = pluginName;
@@ -22,10 +23,11 @@
} }
Plugin.prototype = { Plugin.prototype = {
init: function () { init: function() {
var $this = $(this.element), var $this = this.element,
$toggle = this.settings.toggle; $toggle = this.settings.toggle,
obj = this;
if (this.isIE() <= 9) { if (this.isIE() <= 9) {
$this.find("li.active").has("ul").children("ul").collapse("show"); $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").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(); 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"); $(this).parent("li").toggleClass("active").children("ul").collapse("toggle");
if ($toggle) { if ($toggle) {
$(this).parent("li").siblings().removeClass("active").children("ul.in").collapse("hide"); $(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, var undef,
v = 3, v = 3,
div = document.createElement("div"), div = document.createElement("div"),
@@ -58,15 +77,44 @@
) { ) {
return v > 4 ? v : undef; 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;
}
},
remove: function() {
this.element.off("." + pluginName);
this.element.removeData(pluginName);
} }
}; };
$.fn[ pluginName ] = function (options) { $.fn[pluginName] = function(options) {
return this.each(function () { this.each(function () {
if (!$.data(this, "plugin_" + pluginName)) { var el = $(this);
$.data(this, "plugin_" + pluginName, new Plugin(this, options)); if (el.data(pluginName)) {
el.data(pluginName).remove();
} }
el.data(pluginName, new Plugin(this, options));
}); });
return this;
}; };
})(jQuery, window, document); })(jQuery, window, document);

View File

@@ -1,9 +1,9 @@
/* /*
* metismenu - v1.0.3 * metismenu - v1.1.3
* Easy menu jQuery plugin for Twitter Bootstrap 3 * Easy menu jQuery plugin for Twitter Bootstrap 3
* https://github.com/onokumus/metisMenu * https://github.com/onokumus/metisMenu
* *
* Made by Osman Nuri Okumuş * Made by Osman Nuri Okumus
* Under MIT License * 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="<!--[if gt IE "+ ++b+"]><i></i><![endif]-->",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); !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="<!--[if gt IE "+ ++b+"]><i></i><![endif]-->",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);