arnaucube
arnaucube/openEventsPlatformAppPublic Self-hosted repository
openEventsPlatformApp/plugins/ionic-plugin-keyboard/www/android/keyboard.js
plugins/ionic-plugin-keyboard/www/android/keyboard.jsRaw
 1
 2var argscheck = require('cordova/argscheck'),
 3    utils = require('cordova/utils'),
 4    exec = require('cordova/exec'),
 5    channel = require('cordova/channel');
 6
 7
 8var Keyboard = function() {
 9};
10
11Keyboard.hideKeyboardAccessoryBar = function(hide) {
12    exec(null, null, "Keyboard", "hideKeyboardAccessoryBar", [hide]);
13};
14
15Keyboard.close = function() {
16    exec(null, null, "Keyboard", "close", []);
17};
18
19Keyboard.show = function() {
20    exec(null, null, "Keyboard", "show", []);
21};
22
23Keyboard.disableScroll = function(disable) {
24    exec(null, null, "Keyboard", "disableScroll", [disable]);
25};
26
27/*
28Keyboard.styleDark = function(dark) {
29 exec(null, null, "Keyboard", "styleDark", [dark]);
30};
31*/
32
33Keyboard.isVisible = false;
34
35channel.onCordovaReady.subscribe(function() {
36    exec(success, null, 'Keyboard', 'init', []);
37
38    function success(msg) {
39        var action = msg.charAt(0);
40        if ( action === 'S' ) {
41            var keyboardHeight = msg.substr(1);
42            cordova.plugins.Keyboard.isVisible = true;
43            cordova.fireWindowEvent('native.keyboardshow', { 'keyboardHeight': + keyboardHeight });
44
45            //deprecated
46            cordova.fireWindowEvent('native.showkeyboard', { 'keyboardHeight': + keyboardHeight });
47        } else if ( action === 'H' ) {
48            cordova.plugins.Keyboard.isVisible = false;
49            cordova.fireWindowEvent('native.keyboardhide');
50
51            //deprecated
52            cordova.fireWindowEvent('native.hidekeyboard');
53        }
54    }
55});
56
57module.exports = Keyboard;
58
59
60