Small fixes in keybinding.js

This commit is contained in:
Sergi Mansilla 2011-11-30 17:42:38 +01:00
commit e944fdde3b

View file

@ -39,7 +39,6 @@
define(function(require, exports, module) { define(function(require, exports, module) {
var useragent = require("../lib/useragent");
var keyUtil = require("../lib/keys"); var keyUtil = require("../lib/keys");
var event = require("../lib/event"); var event = require("../lib/event");
require("../commands/default_commands"); require("../commands/default_commands");
@ -76,8 +75,9 @@ var KeyBinding = function(editor) {
}; };
this.$callKeyboardHandlers = function (hashId, keyString, keyCode, e) { this.$callKeyboardHandlers = function (hashId, keyString, keyCode, e) {
var toExecute;
for (var i = this.$handlers.length; i--;) { for (var i = this.$handlers.length; i--;) {
var toExecute = this.$handlers[i].handleKeyboard( toExecute = this.$handlers[i].handleKeyboard(
this.$data, hashId, keyString, keyCode, e this.$data, hashId, keyString, keyCode, e
); );
if (toExecute && toExecute.command) if (toExecute && toExecute.command)
@ -86,7 +86,9 @@ var KeyBinding = function(editor) {
if (!toExecute || !toExecute.command) if (!toExecute || !toExecute.command)
return false; return false;
var success = false, commands = this.$editor.commands;
var success = false;
var commands = this.$editor.commands;
// allow keyboardHandler to consume keys // allow keyboardHandler to consume keys
if (toExecute.command != "null") if (toExecute.command != "null")
@ -97,13 +99,13 @@ var KeyBinding = function(editor) {
if (success && e) if (success && e)
event.stopEvent(e); event.stopEvent(e);
return success return success;
}; };
this.handleKeyboard = function(data, hashId, keyString) { this.handleKeyboard = function(data, hashId, keyString) {
return { return {
command: this.$editor.commands.findKeyCommand(hashId, keyString) command: this.$editor.commands.findKeyCommand(hashId, keyString)
} };
}; };
this.onCommandKey = function(e, hashId, keyCode) { this.onCommandKey = function(e, hashId, keyCode) {