1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | var argscheck = require('cordova/argscheck'),
|
23 | utils = require('cordova/utils'),
|
24 | exec = require('cordova/exec');
|
25 |
|
26 | var Keyboard = function () {};
|
27 |
|
28 | Keyboard.fireOnShow = function (height) {
|
29 | Keyboard.isVisible = true;
|
30 | cordova.fireWindowEvent('keyboardDidShow', {
|
31 | 'keyboardHeight': height
|
32 | });
|
33 |
|
34 |
|
35 |
|
36 | cordova.fireWindowEvent('native.keyboardshow', {
|
37 | 'keyboardHeight': height
|
38 | });
|
39 | };
|
40 |
|
41 | Keyboard.fireOnHide = function () {
|
42 | Keyboard.isVisible = false;
|
43 | cordova.fireWindowEvent('keyboardDidHide');
|
44 |
|
45 |
|
46 |
|
47 | cordova.fireWindowEvent('native.keyboardhide');
|
48 | };
|
49 |
|
50 | Keyboard.fireOnHiding = function () {
|
51 | cordova.fireWindowEvent('keyboardWillHide');
|
52 | };
|
53 |
|
54 | Keyboard.fireOnShowing = function (height) {
|
55 | cordova.fireWindowEvent('keyboardWillShow', {
|
56 | 'keyboardHeight': height
|
57 | });
|
58 | };
|
59 |
|
60 | Keyboard.fireOnResize = function (height, screenHeight, ele) {
|
61 | if (!ele) {
|
62 | return;
|
63 | }
|
64 | if (height === 0) {
|
65 | ele.style.height = null;
|
66 | } else {
|
67 | ele.style.height = (screenHeight - height) + 'px';
|
68 | }
|
69 | };
|
70 |
|
71 | Keyboard.hideFormAccessoryBar = function (hide, success) {
|
72 | if (hide !== null && hide !== undefined) {
|
73 | exec(success, null, "Keyboard", "hideFormAccessoryBar", [hide]);
|
74 | } else {
|
75 | exec(success, null, "Keyboard", "hideFormAccessoryBar", []);
|
76 | }
|
77 | };
|
78 |
|
79 | Keyboard.hide = function () {
|
80 | exec(null, null, "Keyboard", "hide", []);
|
81 | };
|
82 |
|
83 | Keyboard.show = function () {
|
84 | console.warn('Showing keyboard not supported in iOS due to platform limitations.');
|
85 | console.warn('Instead, use input.focus(), and ensure that you have the following setting in your config.xml: \n');
|
86 | console.warn(' <preference name="KeyboardDisplayRequiresUserAction" value="false"/>\n');
|
87 | };
|
88 |
|
89 | Keyboard.disableScroll = function (disable) {
|
90 | console.warn("Keyboard.disableScroll() was removed");
|
91 | };
|
92 |
|
93 | Keyboard.isVisible = false;
|
94 |
|
95 | module.exports = Keyboard; |
\ | No newline at end of file |