mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-02-22 01:19:36 +08:00
Merge pull request #24 from ihadeed/clean-up
refactor: added semi-columns
This commit is contained in:
commit
848c6c3772
@ -66,7 +66,7 @@ window['IonicNative'] = {
|
|||||||
StatusBar: StatusBar,
|
StatusBar: StatusBar,
|
||||||
Toast: Toast,
|
Toast: Toast,
|
||||||
TouchID: TouchID
|
TouchID: TouchID
|
||||||
}
|
};
|
||||||
|
|
||||||
// To help developers using cordova, we listen for the device ready event and
|
// To help developers using cordova, we listen for the device ready event and
|
||||||
// log an error if it didn't fire in a reasonable amount of time. Generally,
|
// log an error if it didn't fire in a reasonable amount of time. Generally,
|
||||||
@ -76,9 +76,9 @@ let before = +new Date;
|
|||||||
|
|
||||||
let didFireReady = false;
|
let didFireReady = false;
|
||||||
document.addEventListener('deviceready', function() {
|
document.addEventListener('deviceready', function() {
|
||||||
console.log('DEVICE READY FIRED AFTER', (+new Date - before), 'ms')
|
console.log('DEVICE READY FIRED AFTER', (+new Date - before), 'ms');
|
||||||
didFireReady = true;
|
didFireReady = true;
|
||||||
})
|
});
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
if(!didFireReady && window.cordova) {
|
if(!didFireReady && window.cordova) {
|
||||||
|
@ -11,10 +11,10 @@ import {Observable} from 'rxjs/Observable';
|
|||||||
|
|
||||||
export const getPlugin = function(pluginRef: string): any {
|
export const getPlugin = function(pluginRef: string): any {
|
||||||
return get(window, pluginRef);
|
return get(window, pluginRef);
|
||||||
}
|
};
|
||||||
export const isInstalled = function(pluginRef: string): boolean {
|
export const isInstalled = function(pluginRef: string): boolean {
|
||||||
return !!getPlugin(pluginRef);
|
return !!getPlugin(pluginRef);
|
||||||
}
|
};
|
||||||
export const pluginWarn = function(pluginObj: any, method: string) {
|
export const pluginWarn = function(pluginObj: any, method: string) {
|
||||||
var pluginName = pluginObj.name;
|
var pluginName = pluginObj.name;
|
||||||
var plugin = pluginObj.plugin;
|
var plugin = pluginObj.plugin;
|
||||||
@ -24,14 +24,14 @@ export const pluginWarn = function(pluginObj: any, method: string) {
|
|||||||
console.warn('Native: tried accessing the ' + pluginName + ' plugin but it\'s not installed.');
|
console.warn('Native: tried accessing the ' + pluginName + ' plugin but it\'s not installed.');
|
||||||
}
|
}
|
||||||
console.warn('Install the ' + pluginName + ' plugin: \'cordova plugin add ' + plugin + '\'');
|
console.warn('Install the ' + pluginName + ' plugin: \'cordova plugin add ' + plugin + '\'');
|
||||||
}
|
};
|
||||||
export const cordovaWarn = function(pluginName: string, method: string) {
|
export const cordovaWarn = function(pluginName: string, method: string) {
|
||||||
if(method) {
|
if(method) {
|
||||||
console.warn('Native: tried calling ' + pluginName + '.' + method + ', but Cordova is not available. Make sure to include cordova.js or run in a device/simulator');
|
console.warn('Native: tried calling ' + pluginName + '.' + method + ', but Cordova is not available. Make sure to include cordova.js or run in a device/simulator');
|
||||||
} else {
|
} else {
|
||||||
console.warn('Native: tried accessing the ' + pluginName + ' plugin but Cordova is not available. Make sure to include cordova.js or run in a device/simulator');
|
console.warn('Native: tried accessing the ' + pluginName + ' plugin but Cordova is not available. Make sure to include cordova.js or run in a device/simulator');
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
function callCordovaPlugin(pluginObj:any, methodName:string, args:any[], opts:any={}, resolve?: Function, reject?: Function) {
|
function callCordovaPlugin(pluginObj:any, methodName:string, args:any[], opts:any={}, resolve?: Function, reject?: Function) {
|
||||||
// Try to figure out where the success/error callbacks need to be bound
|
// Try to figure out where the success/error callbacks need to be bound
|
||||||
@ -61,7 +61,7 @@ function callCordovaPlugin(pluginObj:any, methodName:string, args:any[], opts:an
|
|||||||
cordovaWarn(pluginObj.name, methodName);
|
cordovaWarn(pluginObj.name, methodName);
|
||||||
reject && reject({
|
reject && reject({
|
||||||
error: 'cordova_not_available'
|
error: 'cordova_not_available'
|
||||||
})
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ export const wrap = function(pluginObj:any, methodName:string, opts:any = {}) {
|
|||||||
return wrapPromise(pluginObj, methodName, args, opts);
|
return wrapPromise(pluginObj, methodName, args, opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class decorator specifying Plugin metadata. Required for all plugins.
|
* Class decorator specifying Plugin metadata. Required for all plugins.
|
||||||
@ -145,7 +145,7 @@ export function Plugin(config) {
|
|||||||
|
|
||||||
cls['installed'] = function() {
|
cls['installed'] = function() {
|
||||||
return !!getPlugin(config.pluginRef);
|
return !!getPlugin(config.pluginRef);
|
||||||
}
|
};
|
||||||
|
|
||||||
return cls;
|
return cls;
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ export function CordovaProperty(target: Function, key: string, descriptor: Typed
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
return originalMethod.apply(this, args);
|
return originalMethod.apply(this, args);
|
||||||
}
|
};
|
||||||
|
|
||||||
return descriptor;
|
return descriptor;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user