From: Marius Olbertz Date: Wed, 16 Dec 2015 16:20:56 +0000 (+0100) Subject: Keyboard Util will now take the components name as a String rather than the Object... X-Git-Tag: v6.1.0~44^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d22f7131556528005751dc1e64d0771869171da1;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Keyboard Util will now take the components name as a String rather than the Object itself --- diff --git a/js/foundation.util.keyboard.js b/js/foundation.util.keyboard.js index b1f178b98..849034ab0 100644 --- a/js/foundation.util.keyboard.js +++ b/js/foundation.util.keyboard.js @@ -20,7 +20,10 @@ 40: 'ARROW_DOWN' }; - // constants for easier comparing Can be used like Foundation.parseKey(event) === Foundation.keys.SPACE + /* + * Constants for easier comparing. + * Can be used like Foundation.parseKey(event) === Foundation.keys.SPACE + */ var keys = (function(kcs) { var k = {}; for (var kc in kcs) k[kcs[kc]] = kcs[kc]; @@ -51,11 +54,11 @@ /** * Handles the given (keyboard) event * @param {Event} event - the event generated by the event handler - * @param {Object} component - Foundation component, e.g. Slider or Reveal + * @param {String} component - Foundation component's name, e.g. Slider or Reveal * @param {Objects} functions - collection of functions that are to be executed */ var handleKey = function(event, component, functions) { - var commandList = commands[Foundation.getFnName(component)], + var commandList = commands[component], keyCode = parseKey(event), cmds, command, @@ -73,14 +76,14 @@ fn = functions[command]; - if (fn && typeof fn === 'function') { // execute function with context of the component if exists - fn.apply(component); + if (fn && typeof fn === 'function') { // execute function if exists + fn.apply(); if (functions.handled || typeof functions.handled === 'function') { // execute function when event was handled - functions.handled.apply(component); + functions.handled.apply(); } } else { if (functions.unhandled || typeof functions.unhandled === 'function') { // execute function when event was not handled - functions.unhandled.apply(component); + functions.unhandled.apply(); } } };