diff --git a/interface/resources/html/raiseAndLowerKeyboard.js b/interface/resources/html/raiseAndLowerKeyboard.js index 15df94334c..f40c0d7376 100644 --- a/interface/resources/html/raiseAndLowerKeyboard.js +++ b/interface/resources/html/raiseAndLowerKeyboard.js @@ -7,6 +7,9 @@ // // Sends messages over the EventBridge when text input is required. // + +/* global document, window, console, setTimeout, setInterval, EventBridge */ + (function () { var POLL_FREQUENCY = 500; // ms var MAX_WARNINGS = 3; @@ -37,18 +40,18 @@ } return false; } - }; + } function shouldSetNumeric() { return document.activeElement.type === "number"; - }; + } function scheduleBringToView(timeout) { setTimeout(function () { // If the element is not visible because the keyboard has been raised over the top of it, scroll it up into view. // If the element is not visible because the keyboard raising has moved it off screen, scroll it down into view. var elementRect = document.activeElement.getBoundingClientRect(); - var VISUAL_MARGIN = 3 + var VISUAL_MARGIN = 3; var delta = elementRect.y + elementRect.height + VISUAL_MARGIN - window.innerHeight; if (delta > 0) { window.scrollBy(0, delta); @@ -64,11 +67,13 @@ var passwordField = shouldSetPasswordField(); if (isWindowFocused && - (keyboardRaised !== window.isKeyboardRaised || numericKeyboard !== window.isNumericKeyboard || passwordField !== window.isPasswordField)) { + (keyboardRaised !== window.isKeyboardRaised || numericKeyboard !== window.isNumericKeyboard + || passwordField !== window.isPasswordField)) { if (typeof EventBridge !== "undefined" && EventBridge !== null) { EventBridge.emitWebEvent( - keyboardRaised ? ("_RAISE_KEYBOARD" + (numericKeyboard ? "_NUMERIC" : "") + (passwordField ? "_PASSWORD" : "")) : "_LOWER_KEYBOARD" + keyboardRaised ? ("_RAISE_KEYBOARD" + (numericKeyboard ? "_NUMERIC" : "") + + (passwordField ? "_PASSWORD" : "")) : "_LOWER_KEYBOARD" ); } else { if (numWarnings < MAX_WARNINGS) { @@ -79,7 +84,7 @@ if (!window.isKeyboardRaised) { scheduleBringToView(250); // Allow time for keyboard to be raised in QML. - // 2DO: should it be rather done from 'client area height changed' event? + // 2DO: should it be rather done from 'client area height changed' event? } window.isKeyboardRaised = keyboardRaised;