123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- var argscheck = require('cordova/argscheck'),
- utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- channel = require('cordova/channel');
- var Keyboard = function () {};
- Keyboard.fireOnShow = function (height) {
- Keyboard.isVisible = true;
- cordova.fireWindowEvent('keyboardDidShow', {
- 'keyboardHeight': height
- });
- // To support the keyboardAttach directive listening events
- // inside Ionic's main bundle
- cordova.fireWindowEvent('native.keyboardshow', {
- 'keyboardHeight': height
- });
- };
- Keyboard.fireOnHide = function () {
- Keyboard.isVisible = false;
- cordova.fireWindowEvent('keyboardDidHide');
- // To support the keyboardAttach directive listening events
- // inside Ionic's main bundle
- cordova.fireWindowEvent('native.keyboardhide');
- };
- Keyboard.fireOnHiding = function () {
- cordova.fireWindowEvent('keyboardWillHide');
- };
- Keyboard.fireOnShowing = function (height) {
- cordova.fireWindowEvent('keyboardWillShow', {
- 'keyboardHeight': height
- });
- };
- Keyboard.hideFormAccessoryBar = Keyboard.hideKeyboardAccessoryBar = function (hide) {
- exec(null, null, "Keyboard", "hideKeyboardAccessoryBar", [hide]);
- };
- Keyboard.hide = function () {
- exec(null, null, "Keyboard", "hide", []);
- };
- Keyboard.show = function () {
- exec(null, null, "Keyboard", "show", []);
- };
- Keyboard.disableScroll = function (disable) {
- console.warn("Keyboard.disableScroll() was removed");
- };
- Keyboard.setResizeMode = function (mode) {
- console.warn("Keyboard.setResizeMode() not supported in Android");
- }
- channel.onCordovaReady.subscribe(function () {
- exec(success, null, 'Keyboard', 'init', []);
- function success(msg) {
- var action = msg.charAt(0);
- if (action === 'S') {
- var keyboardHeight = parseInt(msg.substr(1));
- Keyboard.fireOnShowing(keyboardHeight);
- Keyboard.fireOnShow(keyboardHeight);
- } else if (action === 'H') {
- Keyboard.fireOnHiding();
- Keyboard.fireOnHide();
- }
- }
- });
- Keyboard.isVisible = false;
- module.exports = Keyboard;
|