Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

window platform support #66

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
22 changes: 15 additions & 7 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,42 @@
<keywords>cordova,keyboard</keywords>

<engines>
<engine name="cordova" version=">=3.2.0" />
<engine name="cordova" version=">=3.2.0"/>
</engines>

<js-module src="www/keyboard.js" name="keyboard">
<clobbers target="window.Keyboard" />
<clobbers target="window.Keyboard"/>
</js-module>

<!-- ios -->
<platform name="ios">
<config-file target="config.xml" parent="/*">
<feature name="Keyboard">
<param name="ios-package" value="CDVKeyboard" onload="true" />
<param name="ios-package" value="CDVKeyboard" onload="true"/>
</feature>
</config-file>

<header-file src="src/ios/CDVKeyboard.h" />
<source-file src="src/ios/CDVKeyboard.m" />
<header-file src="src/ios/CDVKeyboard.h"/>
<source-file src="src/ios/CDVKeyboard.m"/>
</platform>

<!-- android -->
<platform name="android">
<config-file target="config.xml" parent="/*">
<feature name="Keyboard">
<param name="android-package" value="org.apache.cordova.labs.keyboard.Keyboard" onload="true" />
<param name="android-package" value="org.apache.cordova.labs.keyboard.Keyboard"
onload="true"/>
</feature>
</config-file>

<source-file src="src/android/Keyboard.java" target-dir="src/org/apache/cordova/labs/keyboard" />
<source-file src="src/android/Keyboard.java" target-dir="src/org/apache/cordova/labs/keyboard"/>
</platform>

<!-- windows -->
<platform name="windows">
<js-module src="src/windows/KeyboardProxy.js" name="KeyboardProxy">
<clobbers target="window.Keyboard"/>
</js-module>
</platform>

</plugin>
49 changes: 49 additions & 0 deletions src/windows/KeyboardProxy.js
Original file line number Diff line number Diff line change
@@ -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);