bootstrap-submenu
Advanced tools
Comparing version 2.0.4 to 3.0.0
@@ -1,183 +0,146 @@ | ||
/*! | ||
* Bootstrap-submenu v2.0.4 (https://vsn4ik.github.io/bootstrap-submenu/) | ||
* Copyright 2014-2016 Vasily A. (https://github.com/vsn4ik) | ||
* Licensed under the MIT license | ||
*/ | ||
/** | ||
* $.inArray: friends with IE8. Use Array.prototype.indexOf in future. | ||
* $.proxy: friends with IE8. Use Function.prototype.bind in future. | ||
*/ | ||
'use strict'; | ||
(function(factory) { | ||
if (typeof define == 'function' && define.amd) { | ||
(function (factory) { | ||
if (typeof define === 'function' && define.amd) { | ||
// AMD. Register as an anonymous module | ||
define(['jquery'], factory); | ||
} | ||
else if (typeof exports == 'object') { | ||
} else if (typeof exports === 'object') { | ||
// Node/CommonJS | ||
module.exports = factory(require('jquery')); | ||
} | ||
else { | ||
} else { | ||
// Browser globals | ||
factory(jQuery); | ||
} | ||
})(function($) { | ||
function Item(element) { | ||
this.$element = $(element); | ||
this.$menu = this.$element.closest('.dropdown-menu'); | ||
this.$main = this.$menu.parent(); | ||
this.$items = this.$menu.children('.dropdown-submenu'); | ||
})(function ($) { | ||
var DropdownSubmenu = | ||
/*#__PURE__*/ | ||
function () { | ||
function DropdownSubmenu(element) { | ||
this.element = element.parentElement; | ||
this.menuElement = this.element.querySelector('.dropdown-menu'); | ||
this.init(); | ||
} | ||
this.init(); | ||
} | ||
var _proto = DropdownSubmenu.prototype; | ||
Item.prototype = { | ||
init: function() { | ||
this.$element.on('keydown', $.proxy(this, 'keydown')); | ||
}, | ||
close: function() { | ||
this.$main.removeClass('open'); | ||
this.$items.trigger('hide.bs.submenu'); | ||
}, | ||
keydown: function(event) { | ||
// 27: Esc | ||
_proto.init = function init() { | ||
var _this = this; | ||
if (event.keyCode == 27) { | ||
event.stopPropagation(); | ||
$(this.element).off('keydown.bs.dropdown.data-api'); | ||
this.menuElement.addEventListener('keydown', this.itemKeydown.bind(this)); | ||
var dropdownItemNodeList = this.menuElement.querySelectorAll('.dropdown-item'); | ||
this.close(); | ||
this.$main.children('a, button').trigger('focus'); | ||
} | ||
} | ||
}; | ||
for (var _iterator = dropdownItemNodeList, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref; | ||
function SubmenuItem(element) { | ||
this.$element = $(element); | ||
this.$main = this.$element.parent(); | ||
this.$menu = this.$main.children('.dropdown-menu'); | ||
this.$subs = this.$main.siblings('.dropdown-submenu'); | ||
this.$items = this.$menu.children('.dropdown-submenu'); | ||
if (_isArray) { | ||
if (_i >= _iterator.length) break; | ||
_ref = _iterator[_i++]; | ||
} else { | ||
_i = _iterator.next(); | ||
if (_i.done) break; | ||
_ref = _i.value; | ||
} | ||
this.init(); | ||
} | ||
var element = _ref; | ||
element.addEventListener('keydown', this.handleKeydownDropdownItem.bind(this)); | ||
} | ||
$.extend(SubmenuItem.prototype, Item.prototype, { | ||
init: function() { | ||
this.$element.on({ | ||
click: $.proxy(this, 'click'), | ||
keydown: $.proxy(this, 'keydown') | ||
$(this.menuElement).on('keydown', '.dropdown-submenu > .dropdown-item', this.handleKeydownSubmenuDropdownItem.bind(this)); | ||
$(this.menuElement).on('click', '.dropdown-submenu > .dropdown-item', this.handleClickSubmenuDropdownItem.bind(this)); | ||
$(this.element).on('hidden.bs.dropdown', function () { | ||
_this.close(_this.menuElement); | ||
}); | ||
}; | ||
this.$main.on('hide.bs.submenu', $.proxy(this, 'hide')); | ||
}, | ||
click: function(event) { | ||
// Fix a[href="#"]. For community | ||
event.preventDefault(); | ||
_proto.handleKeydownDropdownItem = function handleKeydownDropdownItem(event) { | ||
// 27: Esc | ||
if (event.keyCode !== 27) { | ||
return; | ||
} | ||
event.stopPropagation(); | ||
event.target.closest('.dropdown-menu').previousElementSibling.focus(); | ||
event.target.closest('.dropdown-menu').classList.remove('show'); | ||
}; | ||
this.toggle(); | ||
}, | ||
hide: function(event) { | ||
// Stop event bubbling | ||
event.stopPropagation(); | ||
_proto.handleKeydownSubmenuDropdownItem = function handleKeydownSubmenuDropdownItem(event) { | ||
// 32: Spacebar | ||
if (event.keyCode !== 32) { | ||
return; | ||
} // NOTE: Off vertical scrolling | ||
this.close(); | ||
}, | ||
open: function() { | ||
this.$main.addClass('open'); | ||
this.$subs.trigger('hide.bs.submenu'); | ||
}, | ||
toggle: function() { | ||
if (this.$main.hasClass('open')) { | ||
this.close(); | ||
} | ||
else { | ||
this.open(); | ||
} | ||
}, | ||
keydown: function(event) { | ||
// 13: Return, 32: Spacebar | ||
if (event.keyCode == 32) { | ||
// Off vertical scrolling | ||
event.preventDefault(); | ||
} | ||
event.preventDefault(); | ||
this.toggle(event.target); | ||
}; | ||
if ($.inArray(event.keyCode, [13, 32]) != -1) { | ||
this.toggle(); | ||
} | ||
} | ||
}); | ||
_proto.handleClickSubmenuDropdownItem = function handleClickSubmenuDropdownItem(event) { | ||
event.stopPropagation(); | ||
this.toggle(event.target); | ||
}; | ||
function Submenupicker(element) { | ||
this.$element = $(element); | ||
this.$main = this.$element.parent(); | ||
this.$menu = this.$main.children('.dropdown-menu'); | ||
this.$items = this.$menu.children('.dropdown-submenu'); | ||
_proto.itemKeydown = function itemKeydown(event) { | ||
// 38: Arrow up, 40: Arrow down | ||
if (![38, 40].includes(event.keyCode)) { | ||
return; | ||
} // NOTE: Off vertical scrolling | ||
this.init(); | ||
} | ||
Submenupicker.prototype = { | ||
init: function() { | ||
this.$menu.off('keydown.bs.dropdown.data-api'); | ||
this.$menu.on('keydown', $.proxy(this, 'itemKeydown')); | ||
this.$menu.find('li > a').each(function() { | ||
new Item(this); | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
var itemNodeList = this.element.querySelectorAll('.show > .dropdown-item:not(:disabled):not(.disabled), .show > .dropdown > .dropdown-item'); | ||
var index = Array.from(itemNodeList).findIndex(function (element) { | ||
return element === event.target; | ||
}); | ||
this.$menu.find('.dropdown-submenu > a').each(function() { | ||
new SubmenuItem(this); | ||
}); | ||
if (event.keyCode === 38 && index !== 0) { | ||
index--; | ||
} else if (event.keyCode === 40 && index !== itemNodeList.length - 1) { | ||
index++; | ||
} else { | ||
return; | ||
} | ||
this.$main.on('hidden.bs.dropdown', $.proxy(this, 'hidden')); | ||
}, | ||
hidden: function() { | ||
this.$items.trigger('hide.bs.submenu'); | ||
}, | ||
itemKeydown: function(event) { | ||
// 38: Arrow up, 40: Arrow down | ||
itemNodeList[index].focus(); | ||
}; | ||
if ($.inArray(event.keyCode, [38, 40]) != -1) { | ||
// Off vertical scrolling | ||
event.preventDefault(); | ||
_proto.toggle = function toggle(element) { | ||
var dropdownElement = element.closest('.dropdown'); | ||
var parentMenuElement = dropdownElement.closest('.dropdown-menu'); | ||
var menuElement = dropdownElement.querySelector('.dropdown-menu'); | ||
var isOpen = menuElement.classList.contains('show'); | ||
this.close(parentMenuElement); | ||
menuElement.classList.toggle('show', !isOpen); | ||
}; | ||
event.stopPropagation(); | ||
_proto.close = function close(menuElement) { | ||
var menuNodeList = menuElement.querySelectorAll('.dropdown-menu.show'); | ||
var $items = this.$menu.find('li:not(.disabled):visible > a'); | ||
var index = $items.index(event.target); | ||
for (var _iterator2 = menuNodeList, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { | ||
var _ref2; | ||
if (event.keyCode == 38 && index !== 0) { | ||
index--; | ||
if (_isArray2) { | ||
if (_i2 >= _iterator2.length) break; | ||
_ref2 = _iterator2[_i2++]; | ||
} else { | ||
_i2 = _iterator2.next(); | ||
if (_i2.done) break; | ||
_ref2 = _i2.value; | ||
} | ||
else if (event.keyCode == 40 && index !== $items.length - 1) { | ||
index++; | ||
} | ||
else { | ||
return; | ||
} | ||
$items.eq(index).trigger('focus'); | ||
var element = _ref2; | ||
element.classList.remove('show'); | ||
} | ||
} | ||
}; | ||
}; | ||
var old = $.fn.submenupicker; | ||
return DropdownSubmenu; | ||
}(); // For AMD/Node/CommonJS used elements (optional) | ||
// http://learn.jquery.com/jquery-ui/environments/amd/ | ||
// For AMD/Node/CommonJS used elements (optional) | ||
// http://learn.jquery.com/jquery-ui/environments/amd/ | ||
$.fn.submenupicker = function(elements) { | ||
$.fn.submenupicker = function (elements) { | ||
var $elements = this instanceof $ ? this : $(elements); | ||
return $elements.each(function() { | ||
return $elements.each(function () { | ||
var data = $.data(this, 'bs.submenu'); | ||
if (!data) { | ||
data = new Submenupicker(this); | ||
data = new DropdownSubmenu(this); | ||
$.data(this, 'bs.submenu', data); | ||
@@ -188,9 +151,3 @@ } | ||
$.fn.submenupicker.Constructor = Submenupicker; | ||
$.fn.submenupicker.noConflict = function() { | ||
$.fn.submenupicker = old; | ||
return this; | ||
}; | ||
return $.fn.submenupicker; | ||
}); | ||
return DropdownSubmenu; | ||
}); |
@@ -1,7 +0,1 @@ | ||
/*! | ||
* Bootstrap-submenu v2.0.4 (https://vsn4ik.github.io/bootstrap-submenu/) | ||
* Copyright 2014-2016 Vasily A. (https://github.com/vsn4ik) | ||
* Licensed under the MIT license | ||
*/ | ||
"use strict";!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){function b(b){this.$element=a(b),this.$menu=this.$element.closest(".dropdown-menu"),this.$main=this.$menu.parent(),this.$items=this.$menu.children(".dropdown-submenu"),this.init()}function c(b){this.$element=a(b),this.$main=this.$element.parent(),this.$menu=this.$main.children(".dropdown-menu"),this.$subs=this.$main.siblings(".dropdown-submenu"),this.$items=this.$menu.children(".dropdown-submenu"),this.init()}function d(b){this.$element=a(b),this.$main=this.$element.parent(),this.$menu=this.$main.children(".dropdown-menu"),this.$items=this.$menu.children(".dropdown-submenu"),this.init()}b.prototype={init:function(){this.$element.on("keydown",a.proxy(this,"keydown"))},close:function(){this.$main.removeClass("open"),this.$items.trigger("hide.bs.submenu")},keydown:function(a){27==a.keyCode&&(a.stopPropagation(),this.close(),this.$main.children("a, button").trigger("focus"))}},a.extend(c.prototype,b.prototype,{init:function(){this.$element.on({click:a.proxy(this,"click"),keydown:a.proxy(this,"keydown")}),this.$main.on("hide.bs.submenu",a.proxy(this,"hide"))},click:function(a){a.preventDefault(),a.stopPropagation(),this.toggle()},hide:function(a){a.stopPropagation(),this.close()},open:function(){this.$main.addClass("open"),this.$subs.trigger("hide.bs.submenu")},toggle:function(){this.$main.hasClass("open")?this.close():this.open()},keydown:function(b){32==b.keyCode&&b.preventDefault(),-1!=a.inArray(b.keyCode,[13,32])&&this.toggle()}}),d.prototype={init:function(){this.$menu.off("keydown.bs.dropdown.data-api"),this.$menu.on("keydown",a.proxy(this,"itemKeydown")),this.$menu.find("li > a").each(function(){new b(this)}),this.$menu.find(".dropdown-submenu > a").each(function(){new c(this)}),this.$main.on("hidden.bs.dropdown",a.proxy(this,"hidden"))},hidden:function(){this.$items.trigger("hide.bs.submenu")},itemKeydown:function(b){if(-1!=a.inArray(b.keyCode,[38,40])){b.preventDefault(),b.stopPropagation();var c=this.$menu.find("li:not(.disabled):visible > a"),d=c.index(b.target);if(38==b.keyCode&&0!==d)d--;else{if(40!=b.keyCode||d===c.length-1)return;d++}c.eq(d).trigger("focus")}}};var e=a.fn.submenupicker;return a.fn.submenupicker=function(b){var c=this instanceof a?this:a(b);return c.each(function(){var b=a.data(this,"bs.submenu");b||(b=new d(this),a.data(this,"bs.submenu",b))})},a.fn.submenupicker.Constructor=d,a.fn.submenupicker.noConflict=function(){return a.fn.submenupicker=e,this},a.fn.submenupicker}); | ||
!function(factory){"function"==typeof define&&define.amd?define(["jquery"],factory):"object"==typeof exports?module.exports=factory(require("jquery")):factory(jQuery)}(function($){var DropdownSubmenu=function(){function DropdownSubmenu(element){this.element=element.parentElement,this.menuElement=this.element.querySelector(".dropdown-menu"),this.init()}var _proto=DropdownSubmenu.prototype;return _proto.init=function(){var _this=this;$(this.element).off("keydown.bs.dropdown.data-api"),this.menuElement.addEventListener("keydown",this.itemKeydown.bind(this));var _iterator=this.menuElement.querySelectorAll(".dropdown-item"),_isArray=Array.isArray(_iterator),_i=0;for(_iterator=_isArray?_iterator:_iterator[Symbol.iterator]();;){var _ref;if(_isArray){if(_i>=_iterator.length)break;_ref=_iterator[_i++]}else{if((_i=_iterator.next()).done)break;_ref=_i.value}_ref.addEventListener("keydown",this.handleKeydownDropdownItem.bind(this))}$(this.menuElement).on("keydown",".dropdown-submenu > .dropdown-item",this.handleKeydownSubmenuDropdownItem.bind(this)),$(this.menuElement).on("click",".dropdown-submenu > .dropdown-item",this.handleClickSubmenuDropdownItem.bind(this)),$(this.element).on("hidden.bs.dropdown",function(){_this.close(_this.menuElement)})},_proto.handleKeydownDropdownItem=function(event){27===event.keyCode&&(event.target.closest(".dropdown-menu").previousElementSibling.focus(),event.target.closest(".dropdown-menu").classList.remove("show"))},_proto.handleKeydownSubmenuDropdownItem=function(event){32===event.keyCode&&(event.preventDefault(),this.toggle(event.target))},_proto.handleClickSubmenuDropdownItem=function(event){event.stopPropagation(),this.toggle(event.target)},_proto.itemKeydown=function(event){if([38,40].includes(event.keyCode)){event.preventDefault(),event.stopPropagation();var itemNodeList=this.element.querySelectorAll(".show > .dropdown-item:not(:disabled):not(.disabled), .show > .dropdown > .dropdown-item"),index=Array.from(itemNodeList).findIndex(function(element){return element===event.target});if(38===event.keyCode&&0!==index)index--;else{if(40!==event.keyCode||index===itemNodeList.length-1)return;index++}itemNodeList[index].focus()}},_proto.toggle=function(element){var dropdownElement=element.closest(".dropdown"),parentMenuElement=dropdownElement.closest(".dropdown-menu"),menuElement=dropdownElement.querySelector(".dropdown-menu"),isOpen=menuElement.classList.contains("show");this.close(parentMenuElement),menuElement.classList.toggle("show",!isOpen)},_proto.close=function(menuElement){var _iterator2=menuElement.querySelectorAll(".dropdown-menu.show"),_isArray2=Array.isArray(_iterator2),_i2=0;for(_iterator2=_isArray2?_iterator2:_iterator2[Symbol.iterator]();;){var _ref2;if(_isArray2){if(_i2>=_iterator2.length)break;_ref2=_iterator2[_i2++]}else{if((_i2=_iterator2.next()).done)break;_ref2=_i2.value}_ref2.classList.remove("show")}},DropdownSubmenu}();return $.fn.submenupicker=function(elements){return(this instanceof $?this:$(elements)).each(function(){var data=$.data(this,"bs.submenu");data||(data=new DropdownSubmenu(this),$.data(this,"bs.submenu",data))})},DropdownSubmenu}); |
@@ -1,18 +0,9 @@ | ||
/** | ||
* $.inArray: friends with IE8. Use Array.prototype.indexOf in future. | ||
* $.proxy: friends with IE8. Use Function.prototype.bind in future. | ||
*/ | ||
'use strict'; | ||
(function(factory) { | ||
if (typeof define == 'function' && define.amd) { | ||
if (typeof define === 'function' && define.amd) { | ||
// AMD. Register as an anonymous module | ||
define(['jquery'], factory); | ||
} | ||
else if (typeof exports == 'object') { | ||
} else if (typeof exports === 'object') { | ||
// Node/CommonJS | ||
module.exports = factory(require('jquery')); | ||
} | ||
else { | ||
} else { | ||
// Browser globals | ||
@@ -22,156 +13,114 @@ factory(jQuery); | ||
})(function($) { | ||
function Item(element) { | ||
this.$element = $(element); | ||
this.$menu = this.$element.closest('.dropdown-menu'); | ||
this.$main = this.$menu.parent(); | ||
this.$items = this.$menu.children('.dropdown-submenu'); | ||
class DropdownSubmenu { | ||
constructor(element) { | ||
this.element = element.parentElement; | ||
this.menuElement = this.element.querySelector('.dropdown-menu'); | ||
this.init(); | ||
} | ||
this.init(); | ||
} | ||
Item.prototype = { | ||
init: function() { | ||
this.$element.on('keydown', $.proxy(this, 'keydown')); | ||
}, | ||
close: function() { | ||
this.$main.removeClass('open'); | ||
this.$items.trigger('hide.bs.submenu'); | ||
}, | ||
keydown: function(event) { | ||
// 27: Esc | ||
init() { | ||
$(this.element).off('keydown.bs.dropdown.data-api'); | ||
if (event.keyCode == 27) { | ||
event.stopPropagation(); | ||
this.menuElement.addEventListener('keydown', this.itemKeydown.bind(this)); | ||
this.close(); | ||
this.$main.children('a, button').trigger('focus'); | ||
const dropdownItemNodeList = this.menuElement.querySelectorAll('.dropdown-item'); | ||
for (const element of dropdownItemNodeList) { | ||
element.addEventListener('keydown', this.handleKeydownDropdownItem.bind(this)); | ||
} | ||
$(this.menuElement).on('keydown', '.dropdown-submenu > .dropdown-item', this.handleKeydownSubmenuDropdownItem.bind(this)); | ||
$(this.menuElement).on('click', '.dropdown-submenu > .dropdown-item', this.handleClickSubmenuDropdownItem.bind(this)); | ||
$(this.element).on('hidden.bs.dropdown', () => { | ||
this.close(this.menuElement); | ||
}); | ||
} | ||
}; | ||
function SubmenuItem(element) { | ||
this.$element = $(element); | ||
this.$main = this.$element.parent(); | ||
this.$menu = this.$main.children('.dropdown-menu'); | ||
this.$subs = this.$main.siblings('.dropdown-submenu'); | ||
this.$items = this.$menu.children('.dropdown-submenu'); | ||
handleKeydownDropdownItem(event) { | ||
// 27: Esc | ||
if (event.keyCode !== 27) { | ||
return; | ||
} | ||
this.init(); | ||
} | ||
event.target.closest('.dropdown-menu').previousElementSibling.focus(); | ||
event.target.closest('.dropdown-menu').classList.remove('show'); | ||
} | ||
$.extend(SubmenuItem.prototype, Item.prototype, { | ||
init: function() { | ||
this.$element.on({ | ||
click: $.proxy(this, 'click'), | ||
keydown: $.proxy(this, 'keydown') | ||
}); | ||
handleKeydownSubmenuDropdownItem(event) { | ||
// 32: Spacebar | ||
if (event.keyCode !== 32) { | ||
return; | ||
} | ||
this.$main.on('hide.bs.submenu', $.proxy(this, 'hide')); | ||
}, | ||
click: function(event) { | ||
// Fix a[href="#"]. For community | ||
// NOTE: Off vertical scrolling | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
this.toggle(event.target); | ||
} | ||
this.toggle(); | ||
}, | ||
hide: function(event) { | ||
// Stop event bubbling | ||
handleClickSubmenuDropdownItem(event) { | ||
event.stopPropagation(); | ||
this.close(); | ||
}, | ||
open: function() { | ||
this.$main.addClass('open'); | ||
this.$subs.trigger('hide.bs.submenu'); | ||
}, | ||
toggle: function() { | ||
if (this.$main.hasClass('open')) { | ||
this.close(); | ||
} | ||
else { | ||
this.open(); | ||
} | ||
}, | ||
keydown: function(event) { | ||
// 13: Return, 32: Spacebar | ||
this.toggle(event.target); | ||
} | ||
if (event.keyCode == 32) { | ||
// Off vertical scrolling | ||
event.preventDefault(); | ||
itemKeydown(event) { | ||
// 38: Arrow up, 40: Arrow down | ||
if (![38, 40].includes(event.keyCode)) { | ||
return; | ||
} | ||
if ($.inArray(event.keyCode, [13, 32]) != -1) { | ||
this.toggle(); | ||
} | ||
} | ||
}); | ||
// NOTE: Off vertical scrolling | ||
event.preventDefault(); | ||
function Submenupicker(element) { | ||
this.$element = $(element); | ||
this.$main = this.$element.parent(); | ||
this.$menu = this.$main.children('.dropdown-menu'); | ||
this.$items = this.$menu.children('.dropdown-submenu'); | ||
event.stopPropagation(); | ||
this.init(); | ||
} | ||
const itemNodeList = this.element.querySelectorAll('.show > .dropdown-item:not(:disabled):not(.disabled), .show > .dropdown > .dropdown-item'); | ||
Submenupicker.prototype = { | ||
init: function() { | ||
this.$menu.off('keydown.bs.dropdown.data-api'); | ||
this.$menu.on('keydown', $.proxy(this, 'itemKeydown')); | ||
this.$menu.find('li > a').each(function() { | ||
new Item(this); | ||
let index = Array.from(itemNodeList).findIndex((element) => { | ||
return element === event.target; | ||
}); | ||
this.$menu.find('.dropdown-submenu > a').each(function() { | ||
new SubmenuItem(this); | ||
}); | ||
if (event.keyCode === 38 && index !== 0) { | ||
index--; | ||
} else if (event.keyCode === 40 && index !== itemNodeList.length - 1) { | ||
index++; | ||
} else { | ||
return; | ||
} | ||
this.$main.on('hidden.bs.dropdown', $.proxy(this, 'hidden')); | ||
}, | ||
hidden: function() { | ||
this.$items.trigger('hide.bs.submenu'); | ||
}, | ||
itemKeydown: function(event) { | ||
// 38: Arrow up, 40: Arrow down | ||
itemNodeList[index].focus(); | ||
} | ||
if ($.inArray(event.keyCode, [38, 40]) != -1) { | ||
// Off vertical scrolling | ||
event.preventDefault(); | ||
toggle(element) { | ||
const dropdownElement = element.closest('.dropdown'); | ||
const parentMenuElement = dropdownElement.closest('.dropdown-menu'); | ||
const menuElement = dropdownElement.querySelector('.dropdown-menu'); | ||
const isOpen = menuElement.classList.contains('show'); | ||
event.stopPropagation(); | ||
this.close(parentMenuElement); | ||
var $items = this.$menu.find('li:not(.disabled):visible > a'); | ||
var index = $items.index(event.target); | ||
menuElement.classList.toggle('show', !isOpen); | ||
} | ||
if (event.keyCode == 38 && index !== 0) { | ||
index--; | ||
} | ||
else if (event.keyCode == 40 && index !== $items.length - 1) { | ||
index++; | ||
} | ||
else { | ||
return; | ||
} | ||
close(menuElement) { | ||
const menuNodeList = menuElement.querySelectorAll('.dropdown-menu.show'); | ||
$items.eq(index).trigger('focus'); | ||
for (const element of menuNodeList) { | ||
element.classList.remove('show'); | ||
} | ||
} | ||
}; | ||
} | ||
var old = $.fn.submenupicker; | ||
// For AMD/Node/CommonJS used elements (optional) | ||
// http://learn.jquery.com/jquery-ui/environments/amd/ | ||
$.fn.submenupicker = function(elements) { | ||
var $elements = this instanceof $ ? this : $(elements); | ||
const $elements = this instanceof $ ? this : $(elements); | ||
return $elements.each(function() { | ||
var data = $.data(this, 'bs.submenu'); | ||
let data = $.data(this, 'bs.submenu'); | ||
if (!data) { | ||
data = new Submenupicker(this); | ||
data = new DropdownSubmenu(this); | ||
@@ -183,9 +132,3 @@ $.data(this, 'bs.submenu', data); | ||
$.fn.submenupicker.Constructor = Submenupicker; | ||
$.fn.submenupicker.noConflict = function() { | ||
$.fn.submenupicker = old; | ||
return this; | ||
}; | ||
return $.fn.submenupicker; | ||
return DropdownSubmenu; | ||
}); |
{ | ||
"name": "bootstrap-submenu", | ||
"version": "2.0.4", | ||
"version": "3.0.0", | ||
"description": "Bootstrap Sub-Menus", | ||
@@ -13,3 +13,3 @@ "keywords": [ | ||
"author": { | ||
"name": "Vasily A.", | ||
"name": "Vasilii A.", | ||
"url": "https://github.com/vsn4ik" | ||
@@ -21,28 +21,24 @@ }, | ||
"dist", | ||
"js/**/*.js", | ||
"less", | ||
"LICENSE" | ||
"css", | ||
"js" | ||
], | ||
"main": "dist/js/bootstrap-submenu.js", | ||
"scripts": { | ||
"test": "grunt" | ||
"test": "npm run css; npm run js", | ||
"css": "npm run css-compile; npm run css-minify", | ||
"css-compile": "mkdir -p dist/css; cp -rf css/*.css dist/css/", | ||
"css-minify": "cleancss --level 1 --source-map --source-map-inline-sources --output dist/css/$npm_package_name.min.css dist/css/$npm_package_name.css", | ||
"js": "npm run js-compile; npm run js-minify", | ||
"js-compile": "babel --out-dir dist/js/ js/*.js", | ||
"js-minify": "uglifyjs --compress --output dist/js/$npm_package_name.min.js dist/js/$npm_package_name.js", | ||
"release-zip": "cd dist/ && zip -r9 $npm_package_name-$npm_package_version-dist.zip * && mv $npm_package_name-$npm_package_version-dist.zip .." | ||
}, | ||
"devDependencies": { | ||
"bootstrap": "~3.3.6", | ||
"grunt": "~0.4.5", | ||
"grunt-banner": "~0.6.0", | ||
"grunt-contrib-clean": "~1.0.0", | ||
"grunt-contrib-compress": "~1.1.1", | ||
"grunt-contrib-copy": "~1.0.0", | ||
"grunt-contrib-cssmin": "~1.0.0", | ||
"grunt-contrib-jshint": "~1.0.0", | ||
"grunt-contrib-less": "~1.2.0", | ||
"grunt-contrib-uglify": "~1.0.0", | ||
"grunt-ejs": "~0.3.0", | ||
"grunt-jscs": "~2.5.0", | ||
"highlight.js": "~9.2.0", | ||
"jquery": "~2.2.2", | ||
"load-grunt-tasks": "~3.4.1", | ||
"octicons": "~3.5.0" | ||
"@babel/cli": "7.0.0-beta.44", | ||
"@babel/core": "7.0.0-beta.44", | ||
"@babel/preset-env": "7.0.0-beta.44", | ||
"bootstrap": "4.0.0", | ||
"clean-css-cli": "4.1.11", | ||
"uglify-js": "3.3.20" | ||
} | ||
} |
# [Bootstrap-submenu](https://vsn4ik.github.io/bootstrap-submenu/) | ||
[![Bower version](https://img.shields.io/bower/v/bootstrap-submenu.svg)](https://github.com/vsn4ik/bootstrap-submenu) | ||
[![npm version](https://img.shields.io/npm/v/bootstrap-submenu.svg)](https://www.npmjs.com/package/bootstrap-submenu) | ||
[![License](https://img.shields.io/npm/l/bootstrap-submenu.svg)][license] | ||
[![Build Status](https://travis-ci.org/vsn4ik/bootstrap-submenu.svg)](https://travis-ci.org/vsn4ik/bootstrap-submenu) | ||
[![devDependency Status](https://david-dm.org/vsn4ik/bootstrap-submenu/dev-status.svg)](https://david-dm.org/vsn4ik/bootstrap-submenu#info=devDependencies) | ||
[![devDependency Status](https://david-dm.org/vsn4ik/bootstrap-submenu/dev-status.svg)](https://david-dm.org/vsn4ik/bootstrap-submenu?type=dev) | ||
@@ -14,7 +13,6 @@ | ||
* [Download the latest release](https://github.com/vsn4ik/bootstrap-submenu/archive/v2.0.4.zip "Download Bootstrap-submenu"). | ||
* Clone the repo: `git clone https://github.com/vsn4ik/bootstrap-submenu.git`. | ||
* Install with [Bower](http://bower.io): `bower install bootstrap-submenu`. | ||
* Install with [npm](https://www.npmjs.com): `npm install bootstrap-submenu`. | ||
* Install with [Composer](https://getcomposer.org): `composer require vsn4ik/bootstrap-submenu "dev-master"`. | ||
* [Download the latest release](https://github.com/vsn4ik/bootstrap-submenu/archive/v3.0.0.zip "Download Bootstrap-submenu") | ||
* Clone the repo: `git clone https://github.com/vsn4ik/bootstrap-submenu.git` | ||
* Install with [npm](https://www.npmjs.com): `npm install bootstrap-submenu` | ||
* Install with [yarn](https://yarnpkg.com): `yarn add bootstrap-submenu` | ||
@@ -42,3 +40,3 @@ ### What's included | ||
* Bootstrap 3.0.0 | ||
* Bootstrap 4.1.0 | ||
* jQuery 1.9.1 | ||
@@ -49,3 +47,3 @@ | ||
**Vasily A.** | ||
**Vasilii A.** | ||
@@ -57,3 +55,3 @@ * <https://github.com/vsn4ik> | ||
Copyright Vasily A., 2014–2016. | ||
Copyright Vasilii A., 2014–2018. | ||
@@ -60,0 +58,0 @@ Licensed under [the MIT License][license]. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
6
18630
10
276
57
1