diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/package.json b/package.json index 024eec8..178f926 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-keyboard", - "version": "1.2.0", + "version": "1.2.0-fk", "description": "Cordova Keyboard Plugin", "cordova": { "id": "cordova-plugin-keyboard", diff --git a/plugin.xml b/plugin.xml index 018c676..e8d3527 100644 --- a/plugin.xml +++ b/plugin.xml @@ -7,34 +7,42 @@ cordova,keyboard - + - + - + - - + + - + - + + + + + + + + diff --git a/src/windows/KeyboardProxy.js b/src/windows/KeyboardProxy.js new file mode 100644 index 0000000..76e7775 --- /dev/null +++ b/src/windows/KeyboardProxy.js @@ -0,0 +1,49 @@ +/*global Windows, WinJS, cordova, module, require*/ + +var inputPane = Windows.UI.ViewManagement.InputPane.getForCurrentView(); +var keyboardScrollDisabled = true; +var isVisible = false; + +inputPane.addEventListener('hiding', function () { + cordova.fireWindowEvent('keyboardWillHide'); + cordova.fireWindowEvent('keyboardHeightWillChange', {keyboardHeight: 0}); + isVisible = false; + cordova.fireWindowEvent('keyboardDidHide'); +}); + +inputPane.addEventListener('showing', function (e) { + cordova.fireWindowEvent('keyboardWillShow'); + if (keyboardScrollDisabled) { + // this disables automatic scrolling of view contents to show focused control + e.ensuredFocusedElementInView = true; + } + cordova.fireWindowEvent('keyboardHeightWillChange', {keyboardHeight: e.occludedRect.height}); + isVisible = true; + cordova.fireWindowEvent('keyboardDidShow'); +}); + +module.exports.disableScrollingInShrinkView = function (disable) { + keyboardScrollDisabled = disable; +}; + +module.exports.show = function () { + if (typeof inputPane.tryShow === 'function') { + inputPane.tryShow(); + } +}; + +module.exports.close = function () { + if (typeof inputPane.tryShow === 'function') { + inputPane.tryHide(); + } +}; + +module.exports.shrinkView = function () { + //DO NOTHING +}; + +module.exports.hideFormAccessoryBar = function () { + //DO NOTHING +}; + +require("cordova/exec/proxy").add("Keyboard", module.exports);