/* The MIT License (MIT) Copyright (c) 2013 jamie.peabody@gmail.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ ;(function( $, window, document, undefined ){ var pluginName = 'wickedtoolbar'; var SHIFT = new RegExp(/shift/i); var ALT = new RegExp(/alt/i); var CTRL = new RegExp(/ctrl/i); var ARROW_DOWN = new RegExp(/↓/); var ARROW_UP = new RegExp(/↑/); var ARROW_LEFT = new RegExp(/←/); var ARROW_RIGHT = new RegExp(/→/); var keys = { shift: 16, alt: 17, ctrl: 18, meta: 91, arrow_up: 38, arrow_down: 40, arrow_left: 37, arrow_right: 39 }; var defaults = { hasIcon: function(id) { }, getIcon: function(id) { } }; function MenuBase(element, options) { var self = this; this.element = $(element); this.settings = $.extend({}, defaults, options); this.bindings = []; // for each menu item, modify and wrap in div this.element.find('li').each(function () { var tthis = $(this); // since the DOM is modifying wrt to icons, it can match the li[data-cion] from // the HTML definition, or the span.icon from the modified DOM var icons = tthis.closest('ul').find('li[data-icon], span.icon').length > 0; var tnode = tthis.contents().filter(function() { return this.nodeType == 3; }).first(); var text = tnode.text().trim(); // remove the text node tnode.remove(); if (!text || !text.length) return; // not a regular menu item // change: