openEventsPlatformApp/plugins/ionic-plugin-keyboard/src/windows/KeyboardProxy.js
plugins/ionic-plugin-keyboard/src/windows/KeyboardProxy.jsRaw
1
2/*global Windows, WinJS, cordova, module, require*/
3
4var inputPane = Windows.UI.ViewManagement.InputPane.getForCurrentView();
5var keyboardScrollDisabled = false;
6
7inputPane.addEventListener('hiding', function() {
8 cordova.fireWindowEvent('native.keyboardhide');
9 cordova.plugins.Keyboard.isVisible = false;
10});
11
12inputPane.addEventListener('showing', function(e) {
13 if (keyboardScrollDisabled) {
14 // this disables automatic scrolling of view contents to show focused control
15 e.ensuredFocusedElementInView = true;
16 }
17 cordova.fireWindowEvent('native.keyboardshow', { keyboardHeight: e.occludedRect.height });
18 cordova.plugins.Keyboard.isVisible = true;
19});
20
21module.exports.disableScroll = function (disable) {
22 keyboardScrollDisabled = disable;
23};
24
25module.exports.show = function () {
26 if (typeof inputPane.tryShow === 'function') {
27 inputPane.tryShow();
28 }
29};
30
31module.exports.close = function () {
32 if (typeof inputPane.tryShow === 'function') {
33 inputPane.tryHide();
34 }
35};
36
37require("cordova/exec/proxy").add("Keyboard", module.exports);