From c6056f711fa875a209975c03433db4b1c1795503 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Sun, 7 Jun 2009 22:15:58 +1000 Subject: [PATCH] Use lambda notation for events.is{Accept,Cancel}Key definitions. --- common/content/events.js | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/common/content/events.js b/common/content/events.js index e2656b9c..560ebc78 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -1200,10 +1200,7 @@ function Events() //{{{ * * @returns {boolean} */ - isAcceptKey: function (key) - { - return (key == "" || key == "" || key == ""); - }, + isAcceptKey: function (key) key == "" || key == "" || key == "", /** * Whether key is a key code defined to reject/cancel input on @@ -1211,10 +1208,7 @@ function Events() //{{{ * * @returns {boolean} */ - isCancelKey: function (key) - { - return (key == "" || key == "" || key == ""); - }, + isCancelKey: function (key) key == "" || key == "" || key == "", /* * Waits for the current buffer to successfully finish loading. Returns @@ -1408,6 +1402,8 @@ function Events() //{{{ // the commandline has focus onKeyPress: function (event) { + function isEscapeKey(key) key == "" || key == ""; + function killEvent() { event.preventDefault(); @@ -1478,7 +1474,7 @@ function Events() //{{{ { if (modes.passNextKey) modes.passNextKey = false; // and then let flow continue - else if (key == "" || key == "" || key == "") + else if (isEscapeKey(key) || key == "") ; // let flow continue to handle these keys to cancel escape-all-keys mode else stop = true; @@ -1493,8 +1489,7 @@ function Events() //{{{ stop = true; // set to false if we should NOT consume this event but let Firefox handle it // just forward event without checking any mappings when the MOW is open - if (liberator.mode == modes.COMMAND_LINE && - (modes.extended & modes.OUTPUT_MULTILINE)) + if (liberator.mode == modes.COMMAND_LINE && (modes.extended & modes.OUTPUT_MULTILINE)) { commandline.onMultilineOutputEvent(event); return void killEvent(); @@ -1511,7 +1506,7 @@ function Events() //{{{ // TODO: handle middle click in content area - if (key != "" && key != "") + if (!isEscapeKey(key)) { // custom mode... if (liberator.mode == modes.CUSTOM) @@ -1575,7 +1570,7 @@ function Events() //{{{ input.buffer = ""; let map = input.pendingArgMap; input.pendingArgMap = null; - if (key != "" && key != "") + if (!isEscapeKey(key)) { if (modes.isReplaying && !waitForPageLoad()) return; @@ -1599,7 +1594,7 @@ function Events() //{{{ } else if (input.pendingMotionMap) { - if (key != "" && key != "") + if (!isEscapeKey(key)) input.pendingMotionMap.execute(candidateCommand, input.count, null); input.pendingMotionMap = null; } @@ -1635,7 +1630,7 @@ function Events() //{{{ input.pendingMotionMap = null; input.pendingMap = null; - if (key != "" && key != "") + if (!isEscapeKey(key)) { // allow key to be passed to Firefox if we can't handle it stop = false;