From 5b7905f3bae4431904e5dbd78b51f37513268a16 Mon Sep 17 00:00:00 2001 From: vsn4ik Date: Tue, 26 Aug 2014 19:35:16 +0400 Subject: [PATCH] Bump v1.1.4. Simplify toggle func. --- bower.json | 2 +- dist/css/bootstrap-submenu.css | 2 +- dist/css/bootstrap-submenu.min.css | 2 +- dist/js/bootstrap-submenu.js | 18 +++++++++--------- dist/js/bootstrap-submenu.min.js | 4 ++-- docs/assets/js/index.js | 8 ++++++++ docs/dist/css/bootstrap-submenu.css | 2 +- docs/dist/css/bootstrap-submenu.min.css | 2 +- docs/dist/js/bootstrap-submenu.js | 18 +++++++++--------- docs/dist/js/bootstrap-submenu.min.js | 4 ++-- js/bootstrap-submenu.js | 16 ++++++++-------- package.json | 2 +- 12 files changed, 44 insertions(+), 36 deletions(-) diff --git a/bower.json b/bower.json index 5588df6..4b0a897 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "bootstrap-submenu", - "version": "1.1.3", + "version": "1.1.4", "authors": [ "vsn4ik" ], diff --git a/dist/css/bootstrap-submenu.css b/dist/css/bootstrap-submenu.css index c2a907b..7c87da4 100644 --- a/dist/css/bootstrap-submenu.css +++ b/dist/css/bootstrap-submenu.css @@ -1,5 +1,5 @@ /*! - * Bootstrap-submenu v1.1.3 (http://vsn4ik.github.io/bootstrap-submenu) + * Bootstrap-submenu v1.1.4 (http://vsn4ik.github.io/bootstrap-submenu) * Copyright 2014 vsn4ik * Licensed under MIT (https://github.com/vsn4ik/bootstrap-submenu/blob/master/LICENSE) */ diff --git a/dist/css/bootstrap-submenu.min.css b/dist/css/bootstrap-submenu.min.css index 163f17d..524dd9f 100644 --- a/dist/css/bootstrap-submenu.min.css +++ b/dist/css/bootstrap-submenu.min.css @@ -1,5 +1,5 @@ /*! - * Bootstrap-submenu v1.1.3 (http://vsn4ik.github.io/bootstrap-submenu) + * Bootstrap-submenu v1.1.4 (http://vsn4ik.github.io/bootstrap-submenu) * Copyright 2014 vsn4ik * Licensed under MIT (https://github.com/vsn4ik/bootstrap-submenu/blob/master/LICENSE) */ diff --git a/dist/js/bootstrap-submenu.js b/dist/js/bootstrap-submenu.js index 455a4c6..ab28e5e 100644 --- a/dist/js/bootstrap-submenu.js +++ b/dist/js/bootstrap-submenu.js @@ -1,5 +1,5 @@ /*! - * Bootstrap-submenu v1.1.3 (http://vsn4ik.github.io/bootstrap-submenu) + * Bootstrap-submenu v1.1.4 (http://vsn4ik.github.io/bootstrap-submenu) * Copyright 2014 vsn4ik * Licensed under MIT (https://github.com/vsn4ik/bootstrap-submenu/blob/master/LICENSE) */ @@ -14,7 +14,7 @@ if (typeof jQuery === 'undefined') { function Submenupicker(element) { this.$element = $(element); this.$menu = this.$element.parent(); - this.$submenus = this.$menu.parent().find('.dropdown-submenu'); + this.$submenus = this.$menu.parent().find('.dropdown-submenu').not(this.$menu); this.init(); } @@ -30,22 +30,22 @@ if (typeof jQuery === 'undefined') { this.toggle(); }, toggle: function() { - var isActive = this.$menu.hasClass('open'); - + this.$menu.toggleClass('open'); this.$submenus.removeClass('open'); - - if (!isActive) { - this.$menu.addClass('open'); - } }, keydown: function(event) { // 13: Return, 32: Spacebar + // 38: Arrow left, 40: Arrow right // Off vertical scrolling - if (event.keyCode == 32) { + if (/^(32|38|40)$/.test(event.keyCode)) { event.preventDefault(); } + if (/^(38|40)$/.test(event.keyCode)) { + event.stopPropagation(); + } + if (/^(13|32)$/.test(event.keyCode)) { this.toggle(); } diff --git a/dist/js/bootstrap-submenu.min.js b/dist/js/bootstrap-submenu.min.js index 7ba536c..5d419f4 100644 --- a/dist/js/bootstrap-submenu.min.js +++ b/dist/js/bootstrap-submenu.min.js @@ -1,7 +1,7 @@ /*! - * Bootstrap-submenu v1.1.3 (http://vsn4ik.github.io/bootstrap-submenu) + * Bootstrap-submenu v1.1.4 (http://vsn4ik.github.io/bootstrap-submenu) * Copyright 2014 vsn4ik * Licensed under MIT (https://github.com/vsn4ik/bootstrap-submenu/blob/master/LICENSE) */ -"use strict";if("undefined"==typeof jQuery)throw new Error("Bootstrap-submenu requires jQuery");!function(a){function b(b){this.$element=a(b),this.$menu=this.$element.parent(),this.$submenus=this.$menu.parent().find(".dropdown-submenu"),this.init()}b.prototype={init:function(){this.$element.on("click.bs.dropdown",this.click.bind(this)),this.$element.keydown(this.keydown.bind(this))},click:function(a){a.stopPropagation(),this.toggle()},toggle:function(){var a=this.$menu.hasClass("open");this.$submenus.removeClass("open"),a||this.$menu.addClass("open")},keydown:function(a){32==a.keyCode&&a.preventDefault(),/^(13|32)$/.test(a.keyCode)&&this.toggle()}},a.fn.submenupicker=function(){return this.each(function(){var c=a(this),d=c.data("bs.submenu");d||(new b(this),c.data("bs.submenu",!0))})}}(jQuery); \ No newline at end of file +"use strict";if("undefined"==typeof jQuery)throw new Error("Bootstrap-submenu requires jQuery");!function(a){function b(b){this.$element=a(b),this.$menu=this.$element.parent(),this.$submenus=this.$menu.parent().find(".dropdown-submenu").not(this.$menu),this.init()}b.prototype={init:function(){this.$element.on("click.bs.dropdown",this.click.bind(this)),this.$element.keydown(this.keydown.bind(this))},click:function(a){a.stopPropagation(),this.toggle()},toggle:function(){this.$menu.toggleClass("open"),this.$submenus.removeClass("open")},keydown:function(a){/^(32|38|40)$/.test(a.keyCode)&&a.preventDefault(),/^(38|40)$/.test(a.keyCode)&&a.stopPropagation(),/^(13|32)$/.test(a.keyCode)&&this.toggle()}},a.fn.submenupicker=function(){return this.each(function(){var c=a(this),d=c.data("bs.submenu");d||(new b(this),c.data("bs.submenu",!0))})}}(jQuery); \ No newline at end of file diff --git a/docs/assets/js/index.js b/docs/assets/js/index.js index 830e5ff..19f2235 100644 --- a/docs/assets/js/index.js +++ b/docs/assets/js/index.js @@ -1,6 +1,14 @@ 'use strict'; $(function() { + $('.dropdown > a').keydown(function() { + // 13: Return + + if (event.keyCode == 13) { + $(this).dropdown('toggle'); + } + }); + $('.dropdown-submenu > a').submenupicker(); $('#scroll_top').click(function() { diff --git a/docs/dist/css/bootstrap-submenu.css b/docs/dist/css/bootstrap-submenu.css index c2a907b..7c87da4 100644 --- a/docs/dist/css/bootstrap-submenu.css +++ b/docs/dist/css/bootstrap-submenu.css @@ -1,5 +1,5 @@ /*! - * Bootstrap-submenu v1.1.3 (http://vsn4ik.github.io/bootstrap-submenu) + * Bootstrap-submenu v1.1.4 (http://vsn4ik.github.io/bootstrap-submenu) * Copyright 2014 vsn4ik * Licensed under MIT (https://github.com/vsn4ik/bootstrap-submenu/blob/master/LICENSE) */ diff --git a/docs/dist/css/bootstrap-submenu.min.css b/docs/dist/css/bootstrap-submenu.min.css index 163f17d..524dd9f 100644 --- a/docs/dist/css/bootstrap-submenu.min.css +++ b/docs/dist/css/bootstrap-submenu.min.css @@ -1,5 +1,5 @@ /*! - * Bootstrap-submenu v1.1.3 (http://vsn4ik.github.io/bootstrap-submenu) + * Bootstrap-submenu v1.1.4 (http://vsn4ik.github.io/bootstrap-submenu) * Copyright 2014 vsn4ik * Licensed under MIT (https://github.com/vsn4ik/bootstrap-submenu/blob/master/LICENSE) */ diff --git a/docs/dist/js/bootstrap-submenu.js b/docs/dist/js/bootstrap-submenu.js index 455a4c6..ab28e5e 100644 --- a/docs/dist/js/bootstrap-submenu.js +++ b/docs/dist/js/bootstrap-submenu.js @@ -1,5 +1,5 @@ /*! - * Bootstrap-submenu v1.1.3 (http://vsn4ik.github.io/bootstrap-submenu) + * Bootstrap-submenu v1.1.4 (http://vsn4ik.github.io/bootstrap-submenu) * Copyright 2014 vsn4ik * Licensed under MIT (https://github.com/vsn4ik/bootstrap-submenu/blob/master/LICENSE) */ @@ -14,7 +14,7 @@ if (typeof jQuery === 'undefined') { function Submenupicker(element) { this.$element = $(element); this.$menu = this.$element.parent(); - this.$submenus = this.$menu.parent().find('.dropdown-submenu'); + this.$submenus = this.$menu.parent().find('.dropdown-submenu').not(this.$menu); this.init(); } @@ -30,22 +30,22 @@ if (typeof jQuery === 'undefined') { this.toggle(); }, toggle: function() { - var isActive = this.$menu.hasClass('open'); - + this.$menu.toggleClass('open'); this.$submenus.removeClass('open'); - - if (!isActive) { - this.$menu.addClass('open'); - } }, keydown: function(event) { // 13: Return, 32: Spacebar + // 38: Arrow left, 40: Arrow right // Off vertical scrolling - if (event.keyCode == 32) { + if (/^(32|38|40)$/.test(event.keyCode)) { event.preventDefault(); } + if (/^(38|40)$/.test(event.keyCode)) { + event.stopPropagation(); + } + if (/^(13|32)$/.test(event.keyCode)) { this.toggle(); } diff --git a/docs/dist/js/bootstrap-submenu.min.js b/docs/dist/js/bootstrap-submenu.min.js index 7ba536c..5d419f4 100644 --- a/docs/dist/js/bootstrap-submenu.min.js +++ b/docs/dist/js/bootstrap-submenu.min.js @@ -1,7 +1,7 @@ /*! - * Bootstrap-submenu v1.1.3 (http://vsn4ik.github.io/bootstrap-submenu) + * Bootstrap-submenu v1.1.4 (http://vsn4ik.github.io/bootstrap-submenu) * Copyright 2014 vsn4ik * Licensed under MIT (https://github.com/vsn4ik/bootstrap-submenu/blob/master/LICENSE) */ -"use strict";if("undefined"==typeof jQuery)throw new Error("Bootstrap-submenu requires jQuery");!function(a){function b(b){this.$element=a(b),this.$menu=this.$element.parent(),this.$submenus=this.$menu.parent().find(".dropdown-submenu"),this.init()}b.prototype={init:function(){this.$element.on("click.bs.dropdown",this.click.bind(this)),this.$element.keydown(this.keydown.bind(this))},click:function(a){a.stopPropagation(),this.toggle()},toggle:function(){var a=this.$menu.hasClass("open");this.$submenus.removeClass("open"),a||this.$menu.addClass("open")},keydown:function(a){32==a.keyCode&&a.preventDefault(),/^(13|32)$/.test(a.keyCode)&&this.toggle()}},a.fn.submenupicker=function(){return this.each(function(){var c=a(this),d=c.data("bs.submenu");d||(new b(this),c.data("bs.submenu",!0))})}}(jQuery); \ No newline at end of file +"use strict";if("undefined"==typeof jQuery)throw new Error("Bootstrap-submenu requires jQuery");!function(a){function b(b){this.$element=a(b),this.$menu=this.$element.parent(),this.$submenus=this.$menu.parent().find(".dropdown-submenu").not(this.$menu),this.init()}b.prototype={init:function(){this.$element.on("click.bs.dropdown",this.click.bind(this)),this.$element.keydown(this.keydown.bind(this))},click:function(a){a.stopPropagation(),this.toggle()},toggle:function(){this.$menu.toggleClass("open"),this.$submenus.removeClass("open")},keydown:function(a){/^(32|38|40)$/.test(a.keyCode)&&a.preventDefault(),/^(38|40)$/.test(a.keyCode)&&a.stopPropagation(),/^(13|32)$/.test(a.keyCode)&&this.toggle()}},a.fn.submenupicker=function(){return this.each(function(){var c=a(this),d=c.data("bs.submenu");d||(new b(this),c.data("bs.submenu",!0))})}}(jQuery); \ No newline at end of file diff --git a/js/bootstrap-submenu.js b/js/bootstrap-submenu.js index c0f38e6..854f3d0 100644 --- a/js/bootstrap-submenu.js +++ b/js/bootstrap-submenu.js @@ -8,7 +8,7 @@ if (typeof jQuery === 'undefined') { function Submenupicker(element) { this.$element = $(element); this.$menu = this.$element.parent(); - this.$submenus = this.$menu.parent().find('.dropdown-submenu'); + this.$submenus = this.$menu.parent().find('.dropdown-submenu').not(this.$menu); this.init(); } @@ -24,22 +24,22 @@ if (typeof jQuery === 'undefined') { this.toggle(); }, toggle: function() { - var isActive = this.$menu.hasClass('open'); - + this.$menu.toggleClass('open'); this.$submenus.removeClass('open'); - - if (!isActive) { - this.$menu.addClass('open'); - } }, keydown: function(event) { // 13: Return, 32: Spacebar + // 38: Arrow left, 40: Arrow right // Off vertical scrolling - if (event.keyCode == 32) { + if (/^(32|38|40)$/.test(event.keyCode)) { event.preventDefault(); } + if (/^(38|40)$/.test(event.keyCode)) { + event.stopPropagation(); + } + if (/^(13|32)$/.test(event.keyCode)) { this.toggle(); } diff --git a/package.json b/package.json index 750433e..2045046 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootstrap-submenu", - "version": "1.1.3", + "version": "1.1.4", "description": "Bootstrap Sub-Menus", "keywords": [ "bootstrap",