Device ready call

This commit is contained in:
Max Lynch
2015-11-29 16:30:15 -06:00
parent 3327fe8f45
commit 45dc983752
23 changed files with 150 additions and 14 deletions
+1
View File
@@ -1,3 +1,4 @@
export * from './plugins/actionsheet';
export * from './plugins/camera';
export * from './plugins/statusbar';
export * from './plugins/toast';
+11
View File
@@ -1,6 +1,17 @@
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var DEVICE_READY_TIMEOUT = 2000;
__export(require('./plugins/actionsheet'));
__export(require('./plugins/camera'));
__export(require('./plugins/statusbar'));
__export(require('./plugins/toast'));
var didFireReady = false;
window.addEventListener('deviceready', function () {
didFireReady = true;
});
setTimeout(function () {
if (!didFireReady && window.cordova) {
console.warn('Native: deviceready did not fire within ' + DEVICE_READY_TIMEOUT + 'ms. This can happen when plugins are in an inconsistent state. Try removing plugins from plugins/ and reinstalling them.');
}
}, DEVICE_READY_TIMEOUT);
-1
View File
@@ -8,7 +8,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var plugin_1 = require('./plugin');
var PLUGIN_REF = 'navigator.camera';
var Camera = (function () {
function Camera() {
}
+6 -1
View File
@@ -6,8 +6,13 @@ exports.wrap = function (pluginObj, methodName, opts) {
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
console.log('Trying', pluginObj.name, methodName, args);
return new Promise(function (resolve, reject) {
if (!window.cordova) {
console.warn('Native: tried calling ' + pluginObj.name + '.' + methodName + ', but Cordova is not available. Make sure to include cordova.js or run in a device/simulator');
reject({
error: 'cordova_not_available'
});
}
if (typeof opts.successIndex !== 'undefined') {
args[opts.successIndex] = resolve;
}
+2 -1
View File
@@ -29,7 +29,8 @@ var Toast = (function () {
plugin_1.Plugin({
name: 'Toast',
plugin: 'cordova-plugin-x-toast',
pluginRef: 'plugins.toast'
pluginRef: 'plugins.toast',
repo: 'https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin'
}),
__metadata('design:paramtypes', [])
], Toast);
+3
View File
@@ -1,5 +1,8 @@
function get(obj, path) {
for (var i = 0, path = path.split('.'), len = path.length; i < len; i++) {
if (!obj) {
return null;
}
obj = obj[path[i]];
}
return obj;