arnaucube
arnaucube/openEventsPlatformAppPublic Self-hosted repository
openEventsPlatformApp/plugins/ionic-plugin-keyboard/src/blackberry10/index.js
plugins/ionic-plugin-keyboard/src/blackberry10/index.jsRaw
  1var keyboard,
  2	resultObjs = {},
  3	threadCallback = null,
  4	_utils = require("../../lib/utils");
  5	_event = require("../../lib/event");
  6	_webview = require("../../lib/webview");
  7
  8module.exports = {
  9
 10	// Code can be declared and used outside the module.exports object,
 11	// but any functions to be called by client.js need to be declared
 12	// here in this object.
 13
 14	// These methods call into JNEXT.Keyboard which handles the
 15	// communication through the JNEXT plugin to keyboard_js.cpp
 16	startService: function (success, fail, args, env) {
 17	var result = new PluginResult(args, env);
 18
 19	result.ok(keyboard.getInstance().startService(), false);
 20	},
 21	show: function (success, fail, args, env) {
 22		var result = new PluginResult(args, env);
 23
 24		result.ok(keyboard.getInstance().showKeyboard(), false);
 25	},
 26	close: function (success, fail, args, env) {
 27	var result = new PluginResult(args, env);
 28
 29	result.ok(keyboard.getInstance().closeKeyboard(), false);
 30	}
 31};
 32
 33keyboardShow = function(a){
 34	_webview.executeJavascript("cordova.plugins.Keyboard.isVisible = true");
 35	_webview.executeJavascript("cordova.fireDocumentEvent('native.keyboardshow',"+a+")");
 36};
 37keyboardHide = function(){
 38	_webview.executeJavascript("cordova.plugins.Keyboard.isVisible = false");
 39	_webview.executeJavascript("cordova.fireDocumentEvent('native.keyboardhide','')");
 40};
 41onStart = function() {
 42	_webview.executeJavascript("cordova.exec("+null+", "+null+", 'Keyboard', 'startService', '')");
 43};
 44
 45setTimeout(onStart,2000);
 46
 47///////////////////////////////////////////////////////////////////
 48// JavaScript wrapper for JNEXT plugin for connection
 49///////////////////////////////////////////////////////////////////
 50
 51JNEXT.Keyboard = function () {
 52	var self = this,
 53		hasInstance = false;
 54
 55	self.getId = function () {
 56		return self.m_id;
 57	};
 58
 59	self.init = function () {
 60		if (!JNEXT.require("libKeyboard")) {
 61			return false;
 62		}
 63
 64		self.m_id = JNEXT.createObject("libKeyboard.Keyboard_JS");
 65
 66		if (self.m_id === "") {
 67			return false;
 68		}
 69
 70		JNEXT.registerEvents(self);
 71	};
 72
 73	// ************************
 74	// Enter your methods here
 75	// ************************
 76
 77	// calls into InvokeMethod(string command) in keyboard_js.cpp
 78	self.startService = function () {
 79		return JNEXT.invoke(self.m_id, "startService");
 80	};
 81	self.showKeyboard = function () {
 82		return JNEXT.invoke(self.m_id, "showKeyboard");
 83	};
 84	self.closeKeyboard = function () {
 85		return JNEXT.invoke(self.m_id, "closeKeyboard");
 86	};
 87
 88	self.onEvent = function (strData) { // Fired by the Event framework (used by asynchronous callbacks)
 89		var arData = strData.split(" "),
 90		strEventDesc = arData[0],
 91		jsonData;
 92
 93		if (strEventDesc === "native.keyboardshow") {
 94			jsonData = arData.slice(1, arData.length).join(" ");
 95			keyboardShow(jsonData);
 96		}
 97		else if (strEventDesc === "native.keyboardhide") {
 98			keyboardHide();
 99		}
100	};
101
102	// Thread methods
103	self.keyboardStartThread = function (callbackId) {
104		return JNEXT.invoke(self.m_id, "keyboardStartThread " + callbackId);
105	};
106	self.keyboardStopThread = function () {
107		return JNEXT.invoke(self.m_id, "keyboardStopThread");
108	};
109
110	// ************************
111	// End of methods to edit
112	// ************************
113	self.m_id = "";
114
115	self.getInstance = function () {
116		if (!hasInstance) {
117			hasInstance = true;
118			self.init();
119		}
120		return self;
121	};
122
123};
124
125keyboard = new JNEXT.Keyboard();