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];
/**
* 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,
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();
}
}
};