diff options
Diffstat (limited to 'www/lib/ngCordova/dist/ng-cordova.js')
| -rw-r--r-- | www/lib/ngCordova/dist/ng-cordova.js | 2833 |
1 files changed, 1517 insertions, 1316 deletions
diff --git a/www/lib/ngCordova/dist/ng-cordova.js b/www/lib/ngCordova/dist/ng-cordova.js index 76f3fa6e..4f749d9f 100644 --- a/www/lib/ngCordova/dist/ng-cordova.js +++ b/www/lib/ngCordova/dist/ng-cordova.js @@ -1,6 +1,6 @@ /*! * ngCordova - * v0.1.15-alpha + * v0.1.17-alpha * Copyright 2014 Drifty Co. http://drifty.com/ * See LICENSE in this repository for license information */ @@ -133,7 +133,6 @@ angular.module('ngCordova.plugins.appRate', []) .provider("$cordovaAppRate", [function () { - this.setPreferences = function (defaults) { if (!defaults || !angular.isObject(defaults)) { return; @@ -151,7 +150,6 @@ angular.module('ngCordova.plugins.appRate', []) AppRate.preferences.storeAppURL.windows8 = defaults.windowsURL || null; }; - this.setCustomLocale = function (customObj) { var strings = { title: 'Rate %@', @@ -279,9 +277,10 @@ angular.module('ngCordova.plugins.backgroundGeolocation', []) } }; } + ]); -// install : cordova plugin add de.appplant.cordova.plugin.badge +// install : cordova plugin add https://github.com/katzer/cordova-plugin-badge.git // link : https://github.com/katzer/cordova-plugin-badge angular.module('ngCordova.plugins.badge', []) @@ -294,8 +293,7 @@ angular.module('ngCordova.plugins.badge', []) cordova.plugins.notification.badge.hasPermission(function (permission) { if (permission) { q.resolve(true); - } - else { + } else { q.reject("You do not have permission"); } }); @@ -313,8 +311,7 @@ angular.module('ngCordova.plugins.badge', []) cordova.plugins.notification.badge.hasPermission(function (permission) { if (permission) { q.resolve(cordova.plugins.notification.badge.set(number)); - } - else { + } else { q.reject("You do not have permission to set Badge"); } }); @@ -342,8 +339,7 @@ angular.module('ngCordova.plugins.badge', []) cordova.plugins.notification.badge.hasPermission(function (permission) { if (permission) { q.resolve(cordova.plugins.notification.badge.clear()); - } - else { + } else { q.reject("You do not have permission to clear Badge"); } }); @@ -357,7 +353,7 @@ angular.module('ngCordova.plugins.badge', []) }]); // install : cordova plugin add https://github.com/wildabeast/BarcodeScanner.git -// link : https://github.com/wildabeast/BarcodeScanner/#using-the-plugin +// link : https://github.com/wildabeast/BarcodeScanner angular.module('ngCordova.plugins.barcodeScanner', []) @@ -391,8 +387,8 @@ angular.module('ngCordova.plugins.barcodeScanner', []) }; }]); -// install : cordova plugin add org.apache.cordova.battery-status -// link : https://github.com/apache/cordova-plugin-battery-status/blob/master/doc/index.md +// install : cordova plugin add cordova-plugin-battery-status +// link : https://github.com/apache/cordova-plugin-battery-status angular.module('ngCordova.plugins.batteryStatus', []) @@ -429,7 +425,7 @@ angular.module('ngCordova.plugins.batteryStatus', []) .run(['$cordovaBatteryStatus', function ($cordovaBatteryStatus) { }]); -// install : cordova plugin add https://github.com/don/cordova-plugin-ble-central#:/plugin +// install : cordova plugin add https://github.com/don/cordova-plugin-ble-central.git // link : https://github.com/don/cordova-plugin-ble-central angular.module('ngCordova.plugins.ble', []) @@ -497,9 +493,9 @@ angular.module('ngCordova.plugins.ble', []) return q.promise; }, - notify: function (deviceID, serviceUUID, characteristicUUID) { + startNotification: function (deviceID, serviceUUID, characteristicUUID) { var q = $q.defer(); - ble.notify(deviceID, serviceUUID, characteristicUUID, function (result) { + ble.startNotification(deviceID, serviceUUID, characteristicUUID, function (result) { q.resolve(result); }, function (error) { q.reject(error); @@ -507,9 +503,9 @@ angular.module('ngCordova.plugins.ble', []) return q.promise; }, - indicate: function (deviceID, serviceUUID, characteristicUUID) { + stopNotification: function (deviceID, serviceUUID, characteristicUUID) { var q = $q.defer(); - ble.indicate(deviceID, serviceUUID, characteristicUUID, function (result) { + ble.stopNotification(deviceID, serviceUUID, characteristicUUID, function (result) { q.resolve(result); }, function (error) { q.reject(error); @@ -539,7 +535,7 @@ angular.module('ngCordova.plugins.ble', []) }; }]); -// install : cordova plugin add com.megster.cordova.bluetoothserial +// install : cordova plugin add https://github.com/don/BluetoothSerial.git // link : https://github.com/don/BluetoothSerial angular.module('ngCordova.plugins.bluetoothSerial', []) @@ -568,7 +564,6 @@ angular.module('ngCordova.plugins.bluetoothSerial', []) return q.promise; }, - disconnect: function () { var q = $q.defer(); $window.bluetoothSerial.disconnect(function () { @@ -579,7 +574,6 @@ angular.module('ngCordova.plugins.bluetoothSerial', []) return q.promise; }, - list: function () { var q = $q.defer(); $window.bluetoothSerial.list(function (data) { @@ -590,7 +584,6 @@ angular.module('ngCordova.plugins.bluetoothSerial', []) return q.promise; }, - discoverUnpaired: function () { var q = $q.defer(); $window.bluetoothSerial.discoverUnpaired(function (data) { @@ -601,7 +594,6 @@ angular.module('ngCordova.plugins.bluetoothSerial', []) return q.promise; }, - setDeviceDiscoveredListener: function () { var q = $q.defer(); $window.bluetoothSerial.setDeviceDiscoveredListener(function (data) { @@ -610,11 +602,10 @@ angular.module('ngCordova.plugins.bluetoothSerial', []) return q.promise; }, - clearDeviceDiscoveredListener: function() { + clearDeviceDiscoveredListener: function () { $window.bluetoothSerial.clearDeviceDiscoveredListener(); }, - showBluetoothSettings: function () { var q = $q.defer(); $window.bluetoothSerial.showBluetoothSettings(function () { @@ -625,7 +616,6 @@ angular.module('ngCordova.plugins.bluetoothSerial', []) return q.promise; }, - isEnabled: function () { var q = $q.defer(); $window.bluetoothSerial.isEnabled(function () { @@ -636,7 +626,6 @@ angular.module('ngCordova.plugins.bluetoothSerial', []) return q.promise; }, - enable: function () { var q = $q.defer(); $window.bluetoothSerial.enable(function () { @@ -647,7 +636,6 @@ angular.module('ngCordova.plugins.bluetoothSerial', []) return q.promise; }, - isConnected: function () { var q = $q.defer(); $window.bluetoothSerial.isConnected(function () { @@ -658,7 +646,6 @@ angular.module('ngCordova.plugins.bluetoothSerial', []) return q.promise; }, - available: function () { var q = $q.defer(); $window.bluetoothSerial.available(function (data) { @@ -669,7 +656,6 @@ angular.module('ngCordova.plugins.bluetoothSerial', []) return q.promise; }, - read: function () { var q = $q.defer(); $window.bluetoothSerial.read(function (data) { @@ -690,7 +676,6 @@ angular.module('ngCordova.plugins.bluetoothSerial', []) return q.promise; }, - write: function (data) { var q = $q.defer(); $window.bluetoothSerial.write(data, function () { @@ -701,7 +686,6 @@ angular.module('ngCordova.plugins.bluetoothSerial', []) return q.promise; }, - subscribe: function (delimiter) { var q = $q.defer(); $window.bluetoothSerial.subscribe(delimiter, function (data) { @@ -722,7 +706,6 @@ angular.module('ngCordova.plugins.bluetoothSerial', []) return q.promise; }, - unsubscribe: function () { var q = $q.defer(); $window.bluetoothSerial.unsubscribe(function () { @@ -743,7 +726,6 @@ angular.module('ngCordova.plugins.bluetoothSerial', []) return q.promise; }, - clear: function () { var q = $q.defer(); $window.bluetoothSerial.clear(function () { @@ -754,7 +736,6 @@ angular.module('ngCordova.plugins.bluetoothSerial', []) return q.promise; }, - readRSSI: function () { var q = $q.defer(); $window.bluetoothSerial.readRSSI(function (data) { @@ -814,8 +795,6 @@ angular.module('ngCordova.plugins.brightness', []) }]); - - // install : cordova plugin add https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin.git // link : https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin @@ -1111,8 +1090,8 @@ angular.module('ngCordova.plugins.calendar', []) }; }]); -// install : cordova plugin add org.apache.cordova.camera -// link : https://github.com/apache/cordova-plugin-camera/blob/master/doc/index.md#orgapachecordovacamera +// install : cordova plugin add cordova-plugin-camera +// link : https://github.com/apache/cordova-plugin-camera angular.module('ngCordova.plugins.camera', []) @@ -1150,8 +1129,8 @@ angular.module('ngCordova.plugins.camera', []) }; }]); -// install : cordova plugin add org.apache.cordova.media-capture -// link : https://github.com/apache/cordova-plugin-media-capture/blob/master/doc/index.md +// install : cordova plugin add cordova-plugin-media-capture +// link : https://github.com/apache/cordova-plugin-media-capture angular.module('ngCordova.plugins.capture', []) @@ -1209,7 +1188,7 @@ angular.module('ngCordova.plugins.capture', []) }; }]); -// install : cordova plugin add https://github.com/VersoSolutions/CordovaClipboard +// install : cordova plugin add https://github.com/VersoSolutions/CordovaClipboard.git // link : https://github.com/VersoSolutions/CordovaClipboard angular.module('ngCordova.plugins.clipboard', []) @@ -1244,8 +1223,8 @@ angular.module('ngCordova.plugins.clipboard', []) }; }]); -// install : cordova plugin add org.apache.cordova.contacts -// link : https://github.com/apache/cordova-plugin-contacts/blob/master/doc/index.md +// install : cordova plugin add cordova-plugin-contacts +// link : https://github.com/apache/cordova-plugin-contacts angular.module('ngCordova.plugins.contacts', []) @@ -1332,8 +1311,8 @@ angular.module('ngCordova.plugins.datePicker', []) }; }]); -// install : cordova plugin add org.apache.cordova.device -// link : https://github.com/apache/cordova-plugin-device/blob/master/doc/index.md +// install : cordova plugin add cordova-plugin-device +// link : https://github.com/apache/cordova-plugin-device angular.module('ngCordova.plugins.device', []) @@ -1342,7 +1321,7 @@ angular.module('ngCordova.plugins.device', []) return { /** * Returns the whole device object. - * @see https://github.com/apache/cordova-plugin-device/blob/master/doc/index.md + * @see https://github.com/apache/cordova-plugin-device * @returns {Object} The device object. */ getDevice: function () { @@ -1351,7 +1330,7 @@ angular.module('ngCordova.plugins.device', []) /** * Returns the Cordova version. - * @see https://github.com/apache/cordova-plugin-device/blob/master/doc/index.md#devicecordova + * @see https://github.com/apache/cordova-plugin-device#devicecordova * @returns {String} The Cordova version. */ getCordova: function () { @@ -1360,7 +1339,7 @@ angular.module('ngCordova.plugins.device', []) /** * Returns the name of the device's model or product. - * @see https://github.com/apache/cordova-plugin-device/blob/master/doc/index.md#devicemodel + * @see https://github.com/apache/cordova-plugin-device#devicemodel * @returns {String} The name of the device's model or product. */ getModel: function () { @@ -1377,7 +1356,7 @@ angular.module('ngCordova.plugins.device', []) /** * Returns the device's operating system name. - * @see https://github.com/apache/cordova-plugin-device/blob/master/doc/index.md#deviceplatform + * @see https://github.com/apache/cordova-plugin-device#deviceplatform * @returns {String} The device's operating system name. */ getPlatform: function () { @@ -1386,7 +1365,7 @@ angular.module('ngCordova.plugins.device', []) /** * Returns the device's Universally Unique Identifier. - * @see https://github.com/apache/cordova-plugin-device/blob/master/doc/index.md#deviceuuid + * @see https://github.com/apache/cordova-plugin-device#deviceuuid * @returns {String} The device's Universally Unique Identifier */ getUUID: function () { @@ -1395,7 +1374,7 @@ angular.module('ngCordova.plugins.device', []) /** * Returns the operating system version. - * @see https://github.com/apache/cordova-plugin-device/blob/master/doc/index.md#deviceversion + * @see https://github.com/apache/cordova-plugin-device#deviceversion * @returns {String} */ getVersion: function () { @@ -1404,8 +1383,8 @@ angular.module('ngCordova.plugins.device', []) }; }]); -// install : cordova plugin add org.apache.cordova.device-motion -// link : https://github.com/apache/cordova-plugin-device-motion/blob/master/doc/index.md +// install : cordova plugin add cordova-plugin-device-motion +// link : https://github.com/apache/cordova-plugin-device-motion angular.module('ngCordova.plugins.deviceMotion', []) @@ -1452,13 +1431,15 @@ angular.module('ngCordova.plugins.deviceMotion', []) }; }]); -// install : cordova plugin add org.apache.cordova.device-orientation -// link : https://github.com/apache/cordova-plugin-device-orientation/blob/master/doc/index.md +// install : cordova plugin add cordova-plugin-device-orientation +// link : https://github.com/apache/cordova-plugin-device-orientation angular.module('ngCordova.plugins.deviceOrientation', []) .factory('$cordovaDeviceOrientation', ['$q', function ($q) { - + var defaultOptions = { + frequency: 3000 // every 3s + }; return { getCurrentHeading: function () { var q = $q.defer(); @@ -1475,11 +1456,12 @@ angular.module('ngCordova.plugins.deviceOrientation', []) watchHeading: function (options) { var q = $q.defer(); + var _options = angular.extend(defaultOptions, options); var watchID = navigator.compass.watchHeading(function (result) { q.notify(result); }, function (err) { q.reject(err); - }, options); + }, _options); q.promise.cancel = function () { navigator.compass.clearWatch(watchID); @@ -1500,8 +1482,8 @@ angular.module('ngCordova.plugins.deviceOrientation', []) }; }]); -// install : cordova plugin add org.apache.cordova.dialogs -// link : https://github.com/apache/cordova-plugin-dialogs/blob/master/doc/index.md +// install : cordova plugin add cordova-plugin-dialogs +// link : https://github.com/apache/cordova-plugin-dialogs angular.module('ngCordova.plugins.dialogs', []) @@ -1514,8 +1496,7 @@ angular.module('ngCordova.plugins.dialogs', []) if (!$window.navigator.notification) { $window.alert(message); q.resolve(); - } - else { + } else { navigator.notification.alert(message, function () { q.resolve(); }, title, buttonName); @@ -1530,12 +1511,10 @@ angular.module('ngCordova.plugins.dialogs', []) if (!$window.navigator.notification) { if ($window.confirm(message)) { q.resolve(1); - } - else { + } else { q.resolve(2); } - } - else { + } else { navigator.notification.confirm(message, function (buttonIndex) { q.resolve(buttonIndex); }, title, buttonLabels); @@ -1551,12 +1530,10 @@ angular.module('ngCordova.plugins.dialogs', []) var res = $window.prompt(message, defaultText); if (res !== null) { q.resolve({input1: res, buttonIndex: 1}); - } - else { + } else { q.resolve({input1: res, buttonIndex: 2}); } - } - else { + } else { navigator.notification.prompt(message, function (result) { q.resolve(result); }, title, buttonLabels, defaultText); @@ -1570,7 +1547,7 @@ angular.module('ngCordova.plugins.dialogs', []) }; }]); -// install : cordova plugin add https://github.com/katzer/cordova-plugin-email-composer.git@0.8.2 +// install : cordova plugin add https://github.com/katzer/cordova-plugin-email-composer.git // link : https://github.com/katzer/cordova-plugin-email-composer angular.module('ngCordova.plugins.emailComposer', []) @@ -1582,7 +1559,11 @@ angular.module('ngCordova.plugins.emailComposer', []) var q = $q.defer(); cordova.plugins.email.isAvailable(function (isAvailable) { - isAvailable ? q.resolve() : q.reject(); + if (isAvailable) { + q.resolve(); + } else { + q.reject(); + } }); return q.promise; @@ -1604,7 +1585,7 @@ angular.module('ngCordova.plugins.emailComposer', []) }; }]); -// install : cordova -d plugin add /Users/your/path/here/phonegap-facebook-plugin --variable APP_ID="123456789" --variable APP_NAME="myApplication" +// install : cordova -d plugin add https://github.com/Wizcorp/phonegap-facebook-plugin.git --variable APP_ID="123456789" --variable APP_NAME="myApplication" // link : https://github.com/Wizcorp/phonegap-facebook-plugin angular.module('ngCordova.plugins.facebook', []) @@ -1788,8 +1769,8 @@ angular.module('ngCordova.plugins.facebookAds', []) }; }]); -// install : cordova plugin add org.apache.cordova.file -// link : https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md +// install : cordova plugin add cordova-plugin-file +// link : https://github.com/apache/cordova-plugin-file angular.module('ngCordova.plugins.file', []) @@ -1814,21 +1795,21 @@ angular.module('ngCordova.plugins.file', []) return { - getFreeDiskSpace: function() { - var q = $q.defer(); - cordova.exec(function(result) { - q.resolve(result); - }, function(error) { - q.reject(error); - }, "File", "getFreeDiskSpace", []); - return q.promise; + getFreeDiskSpace: function () { + var q = $q.defer(); + cordova.exec(function (result) { + q.resolve(result); + }, function (error) { + q.reject(error); + }, "File", "getFreeDiskSpace", []); + return q.promise; }, checkDir: function (path, dir) { var q = $q.defer(); if ((/^\//.test(dir))) { - q.reject("directory cannot start with \/") + q.reject("directory cannot start with \/"); } try { @@ -1851,12 +1832,11 @@ angular.module('ngCordova.plugins.file', []) return q.promise; }, - checkFile: function (path, file) { var q = $q.defer(); if ((/^\//.test(file))) { - q.reject("directory cannot start with \/") + q.reject("directory cannot start with \/"); } try { @@ -1883,7 +1863,7 @@ angular.module('ngCordova.plugins.file', []) var q = $q.defer(); if ((/^\//.test(dirName))) { - q.reject("directory cannot start with \/") + q.reject("directory cannot start with \/"); } replaceBool = replaceBool ? false : true; @@ -1917,7 +1897,7 @@ angular.module('ngCordova.plugins.file', []) var q = $q.defer(); if ((/^\//.test(fileName))) { - q.reject("file-name cannot start with \/") + q.reject("file-name cannot start with \/"); } replaceBool = replaceBool ? false : true; @@ -1946,12 +1926,11 @@ angular.module('ngCordova.plugins.file', []) return q.promise; }, - removeDir: function (path, dirName) { var q = $q.defer(); if ((/^\//.test(dirName))) { - q.reject("file-name cannot start with \/") + q.reject("file-name cannot start with \/"); } try { @@ -2013,7 +1992,7 @@ angular.module('ngCordova.plugins.file', []) var q = $q.defer(); if ((/^\//.test(dirName))) { - q.reject("file-name cannot start with \/") + q.reject("file-name cannot start with \/"); } try { @@ -2069,8 +2048,7 @@ angular.module('ngCordova.plugins.file', []) writer.onwriteend = function (evt) { if (this.error) { q.reject(this.error); - } - else { + } else { q.resolve(evt); } }; @@ -2097,7 +2075,6 @@ angular.module('ngCordova.plugins.file', []) return q.promise; }, - writeExistingFile: function (path, fileName, text) { var q = $q.defer(); @@ -2114,8 +2091,7 @@ angular.module('ngCordova.plugins.file', []) writer.onwriteend = function (evt) { if (this.error) { q.reject(this.error); - } - else { + } else { q.resolve(evt); } }; @@ -2142,7 +2118,6 @@ angular.module('ngCordova.plugins.file', []) return q.promise; }, - readAsText: function (path, file) { var q = $q.defer(); @@ -2157,13 +2132,11 @@ angular.module('ngCordova.plugins.file', []) var reader = new FileReader(); reader.onloadend = function (evt) { - if (evt.target._result !== undefined || evt.target._result !== null) { - q.resolve(evt.target._result); - } - else if (evt.target._error !== undefined || evt.target._error !== null) { - q.reject(evt.target._error); - } - else { + if (evt.target.result !== undefined || evt.target.result !== null) { + q.resolve(evt.target.result); + } else if (evt.target.error !== undefined || evt.target.error !== null) { + q.reject(evt.target.error); + } else { q.reject({code: null, message: 'READER_ONLOADEND_ERR'}); } }; @@ -2186,7 +2159,6 @@ angular.module('ngCordova.plugins.file', []) return q.promise; }, - readAsDataURL: function (path, file) { var q = $q.defer(); @@ -2200,13 +2172,11 @@ angular.module('ngCordova.plugins.file', []) fileEntry.file(function (fileData) { var reader = new FileReader(); reader.onloadend = function (evt) { - if (evt.target._result !== undefined || evt.target._result !== null) { - q.resolve(evt.target._result); - } - else if (evt.target._error !== undefined || evt.target._error !== null) { - q.reject(evt.target._error); - } - else { + if (evt.target.result !== undefined || evt.target.result !== null) { + q.resolve(evt.target.result); + } else if (evt.target.error !== undefined || evt.target.error !== null) { + q.reject(evt.target.error); + } else { q.reject({code: null, message: 'READER_ONLOADEND_ERR'}); } }; @@ -2241,13 +2211,11 @@ angular.module('ngCordova.plugins.file', []) fileEntry.file(function (fileData) { var reader = new FileReader(); reader.onloadend = function (evt) { - if (evt.target._result !== undefined || evt.target._result !== null) { - q.resolve(evt.target._result); - } - else if (evt.target._error !== undefined || evt.target._error !== null) { - q.reject(evt.target._error); - } - else { + if (evt.target.result !== undefined || evt.target.result !== null) { + q.resolve(evt.target.result); + } else if (evt.target.error !== undefined || evt.target.error !== null) { + q.reject(evt.target.error); + } else { q.reject({code: null, message: 'READER_ONLOADEND_ERR'}); } }; @@ -2282,13 +2250,11 @@ angular.module('ngCordova.plugins.file', []) fileEntry.file(function (fileData) { var reader = new FileReader(); reader.onloadend = function (evt) { - if (evt.target._result !== undefined || evt.target._result !== null) { - q.resolve(evt.target._result); - } - else if (evt.target._error !== undefined || evt.target._error !== null) { - q.reject(evt.target._error); - } - else { + if (evt.target.result !== undefined || evt.target.result !== null) { + q.resolve(evt.target.result); + } else if (evt.target.error !== undefined || evt.target.error !== null) { + q.reject(evt.target.error); + } else { q.reject({code: null, message: 'READER_ONLOADEND_ERR'}); } }; @@ -2310,7 +2276,6 @@ angular.module('ngCordova.plugins.file', []) return q.promise; }, - moveFile: function (path, fileName, newPath, newFileName) { var q = $q.defer(); @@ -2377,7 +2342,6 @@ angular.module('ngCordova.plugins.file', []) return q.promise; }, - copyDir: function (path, dirName, newPath, newDirName) { var q = $q.defer(); @@ -2498,7 +2462,7 @@ angular.module('ngCordova.plugins.file', []) }]; }]); -// install : cordova plugin add https://github.com/pwlin/cordova-plugin-file-opener2 +// install : cordova plugin add https://github.com/pwlin/cordova-plugin-file-opener2.git // link : https://github.com/pwlin/cordova-plugin-file-opener2 angular.module('ngCordova.plugins.fileOpener2', []) @@ -2542,8 +2506,8 @@ angular.module('ngCordova.plugins.fileOpener2', []) }; }]); -// install : cordova plugin add org.apache.cordova.file-transfer -// link : https://github.com/apache/cordova-plugin-file-transfer/blob/master/doc/index.md +// install : cordova plugin add cordova-plugin-file-transfer +// link : https://github.com/apache/cordova-plugin-file-transfer angular.module('ngCordova.plugins.fileTransfer', []) @@ -2822,8 +2786,8 @@ angular.module('ngCordova.plugins.ga', []) }; }]); -// install : cordova plugin add org.apache.cordova.geolocation -// link : https://github.com/apache/cordova-plugin-geolocation/blob/master/doc/index.md +// install : cordova plugin add cordova-plugin-geolocation +// link : https://github.com/apache/cordova-plugin-geolocation angular.module('ngCordova.plugins.geolocation', []) @@ -2870,8 +2834,8 @@ angular.module('ngCordova.plugins.geolocation', []) }; }]); -// install : cordova plugin add org.apache.cordova.globalization -// link : https://github.com/apache/cordova-plugin-globalization/blob/master/doc/index.md +// install : cordova plugin add cordova-plugin-globalization +// link : https://github.com/apache/cordova-plugin-globalization angular.module('ngCordova.plugins.globalization', []) @@ -3234,6 +3198,30 @@ angular.module('ngCordova.plugins.googleAnalytics', []) return d.promise; }, + trackException: function (description, fatal) { + var d = $q.defer(); + + $window.analytics.trackException(description, fatal, function (response) { + d.resolve(response); + }, function (error) { + d.reject(error); + }); + + return d.promise; + }, + + trackTiming: function (category, milliseconds, variable, label) { + var d = $q.defer(); + + $window.analytics.trackTiming(category, milliseconds, variable, label, function (response) { + d.resolve(response); + }, function (error) { + d.reject(error); + }); + + return d.promise; + }, + addTransaction: function (transactionId, affiliation, revenue, tax, shipping, currencyCode) { var d = $q.defer(); @@ -3278,8 +3266,7 @@ angular.module('ngCordova.plugins.googleMap', []) if (!$window.plugin.google.maps) { q.reject(null); - } - else { + } else { var div = document.getElementById("map_canvas"); map = $window.plugin.google.maps.Map.getMap(options); map.setDiv(div); @@ -3288,7 +3275,6 @@ angular.module('ngCordova.plugins.googleMap', []) return q.promise; }, - isMapLoaded: function () { // check if an instance of the map exists return !!map; }, @@ -3321,198 +3307,180 @@ angular.module('ngCordova.plugins.googleMap', []) angular.module('ngCordova.plugins.googlePlayGame', []) - .factory('$cordovaGooglePlayGame', ['$q', function ($q) { - - return { - - auth: function() { - var q = $q.defer(); - - googleplaygame.auth(function(success) { - return q.resolve(success); - }, function(err) { - return q.reject(err); - }); - - return q.promise; - }, - signout: function() { - var q = $q.defer(); - - googleplaygame.signout(function(success) { - return q.resolve(success); - }, function(err) { - return q.reject(err); - }); - - return q.promise; - }, - isSignedIn: function() { - var q = $q.defer(); - - googleplaygame.isSignedIn(function(success) { - return q.resolve(success); - }, function(err) { - return q.reject(err); - }); - - return q.promise; - }, - showPlayer: function() { - var q = $q.defer(); - - googleplaygame.showPlayer(function(success) { - return q.resolve(success); - }, function(err) { - return q.reject(err); - }); - - return q.promise; - }, - submitScore: function(data) { - var q = $q.defer(); - - googleplaygame.submitScore(data, function(success) { - return q.resolve(success); - }, function(err) { - return q.reject(err); - }); - - return q.promise; - }, - showAllLeaderboards: function() { - var q = $q.defer(); - - googleplaygame.showAllLeaderboards(function(success) { - return q.resolve(success); - }, function(err) { - return q.reject(err); - }); - - return q.promise; - }, - showLeaderboard: function(data) { - var q = $q.defer(); - - googleplaygame.showLeaderboard(data, function(success) { - return q.resolve(success); - }, function(err) { - return q.reject(err); - }); - - return q.promise; - }, - unlockAchievement: function(data) { - var q = $q.defer(); - - googleplaygame.unlockAchievement(data, function(success) { - return q.resolve(success); - }, function(err) { - return q.reject(err); - }); - - return q.promise; - }, - incrementAchievement: function(data) { - var q = $q.defer(); - - googleplaygame.incrementAchievement(data, function(success) { - return q.resolve(success); - }, function(err) { - return q.reject(err); - }); - - return q.promise; - }, - showAchievements: function() { - var q = $q.defer(); - - googleplaygame.showAchievements(function(success) { - return q.resolve(success); - }, function(err) { - return q.reject(err); - }); - - return q.promise; - } - }; - - }]); -// install : cordova plugin add nl.x-services.plugins.googleplus + .factory('$cordovaGooglePlayGame', ['$q', function ($q) { + + return { + + auth: function () { + var q = $q.defer(); + + googleplaygame.auth(function (success) { + return q.resolve(success); + }, function (err) { + return q.reject(err); + }); + + return q.promise; + }, + signout: function () { + var q = $q.defer(); + + googleplaygame.signout(function (success) { + return q.resolve(success); + }, function (err) { + return q.reject(err); + }); + + return q.promise; + }, + isSignedIn: function () { + var q = $q.defer(); + + googleplaygame.isSignedIn(function (success) { + return q.resolve(success); + }, function (err) { + return q.reject(err); + }); + + return q.promise; + }, + showPlayer: function () { + var q = $q.defer(); + + googleplaygame.showPlayer(function (success) { + return q.resolve(success); + }, function (err) { + return q.reject(err); + }); + + return q.promise; + }, + submitScore: function (data) { + var q = $q.defer(); + + googleplaygame.submitScore(data, function (success) { + return q.resolve(success); + }, function (err) { + return q.reject(err); + }); + + return q.promise; + }, + showAllLeaderboards: function () { + var q = $q.defer(); + + googleplaygame.showAllLeaderboards(function (success) { + return q.resolve(success); + }, function (err) { + return q.reject(err); + }); + + return q.promise; + }, + showLeaderboard: function (data) { + var q = $q.defer(); + + googleplaygame.showLeaderboard(data, function (success) { + return q.resolve(success); + }, function (err) { + return q.reject(err); + }); + + return q.promise; + }, + unlockAchievement: function (data) { + var q = $q.defer(); + + googleplaygame.unlockAchievement(data, function (success) { + return q.resolve(success); + }, function (err) { + return q.reject(err); + }); + + return q.promise; + }, + incrementAchievement: function (data) { + var q = $q.defer(); + + googleplaygame.incrementAchievement(data, function (success) { + return q.resolve(success); + }, function (err) { + return q.reject(err); + }); + + return q.promise; + }, + showAchievements: function () { + var q = $q.defer(); + + googleplaygame.showAchievements(function (success) { + return q.resolve(success); + }, function (err) { + return q.reject(err); + }); + + return q.promise; + } + }; + + }]); + +// install : cordova plugin add https://github.com/EddyVerbruggen/cordova-plugin-googleplus.git // link : https://github.com/EddyVerbruggen/cordova-plugin-googleplus - angular.module('ngCordova.plugins.googleplus', []) +angular.module('ngCordova.plugins.googleplus', []) .factory('$cordovaGooglePlus', ['$q', '$window', function ($q, $window) { return { - login: function(iosKey){ - if(iosKey === undefined){ - iosKey = {}; - } - var q = $q.defer(); - $window.plugins.googleplus.login( - { - 'iOSApiKey': iosKey - // there is no API key for Android; you app is wired to the Google+ API by - //listing your package name in the google dev console and signing your apk - }, - function (response) { - q.resolve(response) - }, - function (error) { - q.reject(error) - } - ); + login: function (iosKey) { + var q = $q.defer(); + + if (iosKey === undefined) { + iosKey = {}; + } + $window.plugins.googleplus.login({'iOSApiKey': iosKey}, function (response) { + q.resolve(response); + }, function (error) { + q.reject(error); + }); return q.promise; }, - silentLogin: function(iosKey){ + silentLogin: function (iosKey) { + var q = $q.defer(); - if(iosKey === undefined){ - iosKey = {}; - } - var q = $q.defer(); - $window.plugins.googleplus.trySilentLogin( - { - 'iOSApiKey': iosKey - // there is no API key for Android; you app is wired to the Google+ API by - //listing your package name in the google dev console and signing your apk - }, - function (response) { - q.resolve(response) - }, - function (error) { - q.reject(error) - } - ); + if (iosKey === undefined) { + iosKey = {}; + } + $window.plugins.googleplus.trySilentLogin({'iOSApiKey': iosKey}, function (response) { + q.resolve(response); + }, function (error) { + q.reject(error); + }); return q.promise; }, - logout: function(){ + logout: function () { var q = $q.defer(); - $window.plugins.googleplus.logout( - function (response) { - q.resolve(response); - } - ); + $window.plugins.googleplus.logout(function (response) { + q.resolve(response); + }); }, - disconnect: function(){ + disconnect: function () { var q = $q.defer(); - $window.plugins.googleplus.disconnect( - function (response) { - q.resolve(response); - } - ); + $window.plugins.googleplus.disconnect(function (response) { + q.resolve(response); + }); } }; }]); -// install : cordova plugin add https://github.com/Telerik-Verified-Plugins/HealthKit +// install : cordova plugin add https://github.com/Telerik-Verified-Plugins/HealthKit.git // link : https://github.com/Telerik-Verified-Plugins/HealthKit angular.module('ngCordova.plugins.healthKit', []) @@ -3925,8 +3893,8 @@ angular.module('ngCordova.plugins.imagePicker', []) }; }]); -// install : cordova plugin add org.apache.cordova.inappbrowser -// link : https://github.com/apache/cordova-plugin-inappbrowser/blob/master/doc/index.md +// install : cordova plugin add cordova-plugin-inappbrowser +// link : https://github.com/apache/cordova-plugin-inappbrowser angular.module('ngCordova.plugins.inAppBrowser', []) @@ -4033,10 +4001,11 @@ angular.module('ngCordova.plugins.insomnia', []) allowSleepAgain: function () { return $window.plugins.insomnia.allowSleepAgain(); } - } + }; }]); -// install : cordova plugins add https://github.com/vstirbu/InstagramPlugin + +// install : cordova plugins add https://github.com/vstirbu/InstagramPlugin.git // link : https://github.com/vstirbu/InstagramPlugin angular.module('ngCordova.plugins.instagram', []) @@ -4053,7 +4022,7 @@ angular.module('ngCordova.plugins.instagram', []) return q.promise; } - Instagram.share(options.image, options.caption, function(err) { + Instagram.share(options.image, options.caption, function (err) { if(err) { q.reject(err); } else { @@ -4088,16 +4057,16 @@ angular.module('ngCordova.plugins.instagram', []) angular.module('ngCordova.plugins.keyboard', []) - .factory('$cordovaKeyboard', [function () { + .factory('$cordovaKeyboard', ['$rootScope', '$timeout', function ($rootScope, $timeout) { var keyboardShowEvent = function () { - $timeout(function () { + $rootScope.$evalAsync(function () { $rootScope.$broadcast('$cordovaKeyboard:show'); }); }; var keyboardHideEvent = function () { - $timeout(function () { + $rootScope.$evalAsync(function () { $rootScope.$broadcast('$cordovaKeyboard:hide'); }); }; @@ -4118,6 +4087,10 @@ angular.module('ngCordova.plugins.keyboard', []) return cordova.plugins.Keyboard.close(); }, + show: function () { + return cordova.plugins.Keyboard.show(); + }, + disableScroll: function (bool) { return cordova.plugins.Keyboard.disableScroll(bool); }, @@ -4143,15 +4116,12 @@ angular.module('ngCordova.plugins.keyboard', []) angular.module('ngCordova.plugins.keychain', []) - .factory('$cordovaKeychain', ['$q', '$window', function ($q, $window) { - - if ('Keychain' in $window) { - var kc = new Keychain(); - } + .factory('$cordovaKeychain', ['$q', function ($q) { return { getForKey: function (key, serviceName) { - var defer = $q.defer(); + var defer = $q.defer(), + kc = new Keychain(); kc.getForKey(defer.resolve, defer.reject, key, serviceName); @@ -4159,7 +4129,8 @@ angular.module('ngCordova.plugins.keychain', []) }, setForKey: function (key, serviceName, value) { - var defer = $q.defer(); + var defer = $q.defer(), + kc = new Keychain(); kc.setForKey(defer.resolve, defer.reject, key, serviceName, value); @@ -4167,7 +4138,8 @@ angular.module('ngCordova.plugins.keychain', []) }, removeForKey: function (key, serviceName) { - var defer = $q.defer(); + var defer = $q.defer(), + kc = new Keychain(); kc.removeForKey(defer.resolve, defer.reject, key, serviceName); @@ -4176,91 +4148,191 @@ angular.module('ngCordova.plugins.keychain', []) }; }]); -// install : cordova plugin add de.appplant.cordova.plugin.local-notification -// link : https://github.com/katzer/cordova-plugin-local-notifications/ +// install : cordova plugin add https://github.com/katzer/cordova-plugin-local-notifications.git +// link : https://github.com/katzer/cordova-plugin-local-notifications angular.module('ngCordova.plugins.localNotification', []) .factory('$cordovaLocalNotification', ['$q', '$window', '$rootScope', '$timeout', function ($q, $window, $rootScope, $timeout) { - document.addEventListener("deviceready", function () { - if ($window.plugin && $window.plugin.notification) { - $window.plugin.notification.local.on("cancel", function (id, state, json) { - var notification = { - id: id, - state: state, - json: json - }; + document.addEventListener('deviceready', function () { + if ($window.cordova && + $window.cordova.plugins && + $window.cordova.plugins.notification && + $window.cordova.plugins.notification.local) { + // ----- "Scheduling" events + + // A local notification was scheduled + $window.cordova.plugins.notification.local.on('schedule', function (notification, state) { $timeout(function () { - $rootScope.$broadcast("$cordovaLocalNotification:canceled", notification); + $rootScope.$broadcast('$cordovaLocalNotification:schedule', notification, state); }); }); - $window.plugin.notification.local.on("click", function (id, state, json) { - var notification = { - id: id, - state: state, - json: json - }; + // A local notification was triggered + $window.cordova.plugins.notification.local.on('trigger', function (notification, state) { $timeout(function () { - $rootScope.$broadcast("$cordovaLocalNotification:clicked", notification); + $rootScope.$broadcast('$cordovaLocalNotification:trigger', notification, state); }); }); - $window.plugin.notification.local.on("trigger", function (id, state, json) { - var notification = { - id: id, - state: state, - json: json - }; + // ----- "Update" events + + // A local notification was updated + $window.cordova.plugins.notification.local.on('update', function (notification, state) { $timeout(function () { - $rootScope.$broadcast("$cordovaLocalNotification:triggered", notification); + $rootScope.$broadcast('$cordovaLocalNotification:update', notification, state); }); }); - $window.plugin.notification.local.on("add", function (id, state, json) { - var notification = { - id: id, - state: state, - json: json - }; + // ----- "Clear" events + + // A local notification was cleared from the notification center + $window.cordova.plugins.notification.local.on('clear', function (notification, state) { + $timeout(function () { + $rootScope.$broadcast('$cordovaLocalNotification:clear', notification, state); + }); + }); + + // All local notifications were cleared from the notification center + $window.cordova.plugins.notification.local.on('clearall', function (state) { $timeout(function () { - $rootScope.$broadcast("$cordovaLocalNotification:added", notification); + $rootScope.$broadcast('$cordovaLocalNotification:clearall', state); + }); + }); + + // ----- "Cancel" events + + // A local notification was cancelled + $window.cordova.plugins.notification.local.on('cancel', function (notification, state) { + $timeout(function () { + $rootScope.$broadcast('$cordovaLocalNotification:cancel', notification, state); + }); + }); + + // All local notifications were cancelled + $window.cordova.plugins.notification.local.on('cancelall', function (state) { + $timeout(function () { + $rootScope.$broadcast('$cordovaLocalNotification:cancelall', state); + }); + }); + + // ----- Other events + + // A local notification was clicked + $window.cordova.plugins.notification.local.on('click', function (notification, state) { + $timeout(function () { + $rootScope.$broadcast('$cordovaLocalNotification:click', notification, state); }); }); } }, false); return { + schedule: function (options, scope) { + var q = $q.defer(); + scope = scope || null; + + $window.cordova.plugins.notification.local.schedule(options, function (result) { + q.resolve(result); + }, scope); + + return q.promise; + }, + add: function (options, scope) { + console.warn('Deprecated: use "schedule" instead.'); + + var q = $q.defer(); + scope = scope || null; + + $window.cordova.plugins.notification.local.schedule(options, function (result) { + q.resolve(result); + }, scope); + + return q.promise; + }, + + update: function (options, scope) { + var q = $q.defer(); + scope = scope || null; + + $window.cordova.plugins.notification.local.update(options, function (result) { + q.resolve(result); + }, scope); + + return q.promise; + }, + + clear: function (ids, scope) { + var q = $q.defer(); + scope = scope || null; + + $window.cordova.plugins.notification.local.clear(ids, function (result) { + q.resolve(result); + }, scope); + + return q.promise; + }, + + clearAll: function (scope) { var q = $q.defer(); scope = scope || null; - $window.plugin.notification.local.add(options, function (result) { + + $window.cordova.plugins.notification.local.clearAll(function (result) { q.resolve(result); }, scope); + return q.promise; }, - cancel: function (id, scope) { + cancel: function (ids, scope) { var q = $q.defer(); scope = scope || null; - $window.plugin.notification.local.cancel(id, function (result) { + + $window.cordova.plugins.notification.local.cancel(ids, function (result) { q.resolve(result); }, scope); + return q.promise; }, cancelAll: function (scope) { var q = $q.defer(); scope = scope || null; - $window.plugin.notification.local.cancelAll(function (result) { + + $window.cordova.plugins.notification.local.cancelAll(function (result) { q.resolve(result); }, scope); + + return q.promise; + }, + + isPresent: function (id, scope) { + var q = $q.defer(); + scope = scope || null; + + $window.cordova.plugins.notification.local.isPresent(id, function (result) { + q.resolve(result); + }, scope); + return q.promise; }, isScheduled: function (id, scope) { var q = $q.defer(); scope = scope || null; - $window.plugin.notification.local.isScheduled(id, function (result) { + + $window.cordova.plugins.notification.local.isScheduled(id, function (result) { + q.resolve(result); + }, scope); + + return q.promise; + }, + + isTriggered: function (id, scope) { + var q = $q.defer(); + scope = scope || null; + + $window.cordova.plugins.notification.local.isTriggered(id, function (result) { q.resolve(result); }, scope); @@ -4269,58 +4341,167 @@ angular.module('ngCordova.plugins.localNotification', []) hasPermission: function (scope) { var q = $q.defer(); - $window.plugin.notification.local.hasPermission(function (result) { - result ? q.resolve(result) : q.reject(result); + scope = scope || null; + + $window.cordova.plugins.notification.local.hasPermission(function (result) { + if (result) { + q.resolve(result); + } else { + q.reject(result); + } }, scope); + return q.promise; }, - promptForPermission: function () { + registerPermission: function (scope) { var q = $q.defer(); - $window.plugin.notification.local.promptForPermission(function (result) { - result ? q.resolve(result) : q.reject(result); - }); + scope = scope || null; + + $window.cordova.plugins.notification.local.registerPermission(function (result) { + if (result) { + q.resolve(result); + } else { + q.reject(result); + } + }, scope); + return q.promise; }, - registerPermission: function () { + promptForPermission: function (scope) { + console.warn('Deprecated: use "registerPermission" instead.'); + var q = $q.defer(); - $window.plugin.notification.local.registerPermission(function (result) { - result ? q.resolve(result) : q.reject(result); - }); + scope = scope || null; + + $window.cordova.plugins.notification.local.registerPermission(function (result) { + if (result) { + q.resolve(result); + } else { + q.reject(result); + } + }, scope); + return q.promise; }, - getScheduledIds: function (scope) { + getAllIds: function (scope) { var q = $q.defer(); - $window.plugin.notification.local.getScheduledIds(function (result) { + scope = scope || null; + + $window.cordova.plugins.notification.local.getAllIds(function (result) { q.resolve(result); }, scope); + return q.promise; }, - isTriggered: function (id, scope) { + getIds: function (scope) { + var q = $q.defer(); + scope = scope || null; + + $window.cordova.plugins.notification.local.getIds(function (result) { + q.resolve(result); + }, scope); + + return q.promise; + }, + + getScheduledIds: function (scope) { var q = $q.defer(); - $window.plugin.notification.local.isTriggered(id, function (result) { + scope = scope || null; + + $window.cordova.plugins.notification.local.getScheduledIds(function (result) { q.resolve(result); }, scope); + return q.promise; }, getTriggeredIds: function (scope) { var q = $q.defer(); - $window.plugin.notification.local.getTriggeredIds(function (result) { + scope = scope || null; + + $window.cordova.plugins.notification.local.getTriggeredIds(function (result) { + q.resolve(result); + }, scope); + + return q.promise; + }, + + get: function (ids, scope) { + var q = $q.defer(); + scope = scope || null; + + $window.cordova.plugins.notification.local.get(ids, function (result) { + q.resolve(result); + }, scope); + + return q.promise; + }, + + getAll: function (scope) { + var q = $q.defer(); + scope = scope || null; + + $window.cordova.plugins.notification.local.getAll(function (result) { q.resolve(result); }, scope); + + return q.promise; + }, + + getScheduled: function (ids, scope) { + var q = $q.defer(); + scope = scope || null; + + $window.cordova.plugins.notification.local.getScheduled(ids, function (result) { + q.resolve(result); + }, scope); + + return q.promise; + }, + + getAllScheduled: function (scope) { + var q = $q.defer(); + scope = scope || null; + + $window.cordova.plugins.notification.local.getAllScheduled(function (result) { + q.resolve(result); + }, scope); + + return q.promise; + }, + + getTriggered: function (ids, scope) { + var q = $q.defer(); + scope = scope || null; + + $window.cordova.plugins.notification.local.getTriggered(ids, function (result) { + q.resolve(result); + }, scope); + + return q.promise; + }, + + getAllTriggered: function (scope) { + var q = $q.defer(); + scope = scope || null; + + $window.cordova.plugins.notification.local.getAllTriggered(function (result) { + q.resolve(result); + }, scope); + return q.promise; }, getDefaults: function () { - return $window.plugin.notification.local.getDefaults(); + return $window.cordova.plugins.notification.local.getDefaults(); }, setDefaults: function (Object) { - $window.plugin.notification.local.setDefaults(Object); + $window.cordova.plugins.notification.local.setDefaults(Object); } }; }]); @@ -4430,7 +4611,7 @@ angular.module('ngCordova.plugins.mMediaAds', []) }; }]); -// install : cordova plugin add org.apache.cordova.media +// install : cordova plugin add cordova-plugin-media // link : https://github.com/apache/cordova-plugin-media angular.module('ngCordova.plugins.media', []) @@ -4877,8 +5058,8 @@ angular.module('ngCordova.plugins.nativeAudio', []) }; }]); -// install : cordova plugin add org.apache.cordova.network-information -// link : https://github.com/apache/cordova-plugin-network-information/blob/master/doc/index.md +// install : cordova plugin add cordova-plugin-network-information +// link : https://github.com/apache/cordova-plugin-network-information angular.module('ngCordova.plugins.network', []) @@ -4968,925 +5149,938 @@ angular.module("ngCordova.plugins.oauth", ["ngCordova.plugins.oauthUtility"]) return { - /* - * Sign into the ADFS service (ADFS 3.0 onwards) - * - * @param string clientId (client registered in ADFS, with redirect_uri configured to: http://localhost/callback) - * @param string adfsServer (url of the ADFS Server) - * @param string relyingPartyId (url of the Relying Party (resource relying on ADFS for authentication) configured in ADFS) - * @return promise - */ - adfs: function(clientId, adfsServer, relyingPartyId) { - var deferred = $q.defer(); - if(window.cordova) { - var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; - if(cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { - var browserRef = window.open(adfsServer + '/adfs/oauth2/authorize?response_type=code&client_id=' + clientId +'&redirect_uri=http://localhost/callback&resource=' + relyingPartyId, '_blank', 'location=no'); - - browserRef.addEventListener("loadstart", function(event) { - if((event.url).indexOf('http://localhost/callback') === 0) { - var requestToken = (event.url).split("code=")[1]; - $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; - $http({method: "post", url: adfsServer + "/adfs/oauth2/token", data: "client_id=" + clientId + "&code=" + requestToken + "&redirect_uri=http://localhost/callback&grant_type=authorization_code" }) - .success(function(data) { - deferred.resolve(data); - }) - .error(function(data, status) { - deferred.reject("Problem authenticating"); - }) - .finally(function() { - setTimeout(function() { - browserRef.close(); - }, 10); - }); - } - }); - browserRef.addEventListener('exit', function(event) { - deferred.reject("The sign in flow was canceled"); - }); - } else { - deferred.reject("Could not find InAppBrowser plugin"); - } - } else { - deferred.reject("Cannot authenticate via a web browser"); - } - return deferred.promise; - }, + /* + * Sign into the ADFS service (ADFS 3.0 onwards) + * + * @param string clientId (client registered in ADFS, with redirect_uri configured to: http://localhost/callback) + * @param string adfsServer (url of the ADFS Server) + * @param string relyingPartyId (url of the Relying Party (resource relying on ADFS for authentication) configured in ADFS) + * @return promise + */ + adfs: function (clientId, adfsServer, relyingPartyId) { + var deferred = $q.defer(); + if (window.cordova) { + var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; + if (cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { + var browserRef = window.open(adfsServer + '/adfs/oauth2/authorize?response_type=code&client_id=' + clientId + '&redirect_uri=http://localhost/callback&resource=' + relyingPartyId, '_blank', 'location=no'); + + browserRef.addEventListener("loadstart", function (event) { + if ((event.url).indexOf('http://localhost/callback') === 0) { + var requestToken = (event.url).split("code=")[1]; + $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; + $http({method: "post", url: adfsServer + "/adfs/oauth2/token", data: "client_id=" + clientId + "&code=" + requestToken + "&redirect_uri=http://localhost/callback&grant_type=authorization_code"}) + .success(function (data) { + deferred.resolve(data); + }) + .error(function (data, status) { + deferred.reject("Problem authenticating"); + }) + .finally(function () { + setTimeout(function () { + browserRef.close(); + }, 10); + }); + } + }); + browserRef.addEventListener('exit', function (event) { + deferred.reject("The sign in flow was canceled"); + }); + } else { + deferred.reject("Could not find InAppBrowser plugin"); + } + } else { + deferred.reject("Cannot authenticate via a web browser"); + } + return deferred.promise; + }, - /* - * Sign into the Dropbox service - * - * @param string appKey - * @return promise - */ - dropbox: function(appKey) { - var deferred = $q.defer(); - if(window.cordova) { - var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; - if(cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { - var browserRef = window.open("https://www.dropbox.com/1/oauth2/authorize?client_id=" + appKey + "&redirect_uri=http://localhost/callback" + "&response_type=token", "_blank", "location=no,clearsessioncache=yes,clearcache=yes"); - browserRef.addEventListener("loadstart", function(event) { - if((event.url).indexOf("http://localhost/callback") === 0) { - var callbackResponse = (event.url).split("#")[1]; - var responseParameters = (callbackResponse).split("&"); - var parameterMap = []; - for(var i = 0; i < responseParameters.length; i++) { - parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1]; - } - if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) { - deferred.resolve({ access_token: parameterMap.access_token, token_type: parameterMap.token_type, uid: parameterMap.uid }); - } else { - deferred.reject("Problem authenticating"); - } - setTimeout(function() { - browserRef.close(); - }, 10); - } - }); - browserRef.addEventListener('exit', function(event) { - deferred.reject("The sign in flow was canceled"); - }); - } else { - deferred.reject("Could not find InAppBrowser plugin"); + /* + * Sign into the Dropbox service + * + * @param string appKey + * @return promise + */ + dropbox: function (appKey) { + var deferred = $q.defer(); + if (window.cordova) { + var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; + if (cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { + var browserRef = window.open("https://www.dropbox.com/1/oauth2/authorize?client_id=" + appKey + "&redirect_uri=http://localhost/callback" + "&response_type=token", "_blank", "location=no,clearsessioncache=yes,clearcache=yes"); + browserRef.addEventListener("loadstart", function (event) { + if ((event.url).indexOf("http://localhost/callback") === 0) { + var callbackResponse = (event.url).split("#")[1]; + var responseParameters = (callbackResponse).split("&"); + var parameterMap = []; + for (var i = 0; i < responseParameters.length; i++) { + parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1]; } - } else { - deferred.reject("Cannot authenticate via a web browser"); - } - return deferred.promise; - }, - - /* - * Sign into the Digital Ocean service - * - * @param string clientId - * @param string clientSecret - * @return promise - */ - digitalOcean: function(clientId, clientSecret) { - var deferred = $q.defer(); - if(window.cordova) { - var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; - if(cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { - var browserRef = window.open("https://cloud.digitalocean.com/v1/oauth/authorize?client_id=" + clientId + "&redirect_uri=http://localhost/callback&response_type=code&scope=read%20write", "_blank", "location=no,clearsessioncache=yes,clearcache=yes"); - browserRef.addEventListener("loadstart", function(event) { - if((event.url).indexOf("http://localhost/callback") === 0) { - var requestToken = (event.url).split("code=")[1]; - $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; - $http({method: "post", url: "https://cloud.digitalocean.com/v1/oauth/token", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&redirect_uri=http://localhost/callback" + "&grant_type=authorization_code" + "&code=" + requestToken }) - .success(function(data) { - deferred.resolve(data); - }) - .error(function(data, status) { - deferred.reject("Problem authenticating"); - }) - .finally(function() { - setTimeout(function() { - browserRef.close(); - }, 10); - }); - } - }); - browserRef.addEventListener('exit', function(event) { - deferred.reject("The sign in flow was canceled"); - }); + if (parameterMap.access_token !== undefined && parameterMap.access_token !== null) { + deferred.resolve({access_token: parameterMap.access_token, token_type: parameterMap.token_type, uid: parameterMap.uid}); } else { - deferred.reject("Could not find InAppBrowser plugin"); + deferred.reject("Problem authenticating"); } - } else { - deferred.reject("Cannot authenticate via a web browser"); - } - return deferred.promise; - }, + setTimeout(function () { + browserRef.close(); + }, 10); + } + }); + browserRef.addEventListener('exit', function (event) { + deferred.reject("The sign in flow was canceled"); + }); + } else { + deferred.reject("Could not find InAppBrowser plugin"); + } + } else { + deferred.reject("Cannot authenticate via a web browser"); + } + return deferred.promise; + }, - /* - * Sign into the Google service - * - * @param string clientId - * @param array appScope - * @return promise - */ - google: function(clientId, appScope) { - var deferred = $q.defer(); - if(window.cordova) { - var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; - if(cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { - var browserRef = window.open('https://accounts.google.com/o/oauth2/auth?client_id=' + clientId + '&redirect_uri=http://localhost/callback&scope=' + appScope.join(" ") + '&approval_prompt=force&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); - browserRef.addEventListener("loadstart", function(event) { - if((event.url).indexOf("http://localhost/callback") === 0) { - var callbackResponse = (event.url).split("#")[1]; - var responseParameters = (callbackResponse).split("&"); - var parameterMap = []; - for(var i = 0; i < responseParameters.length; i++) { - parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1]; - } - if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) { - deferred.resolve({ access_token: parameterMap.access_token, token_type: parameterMap.token_type, expires_in: parameterMap.expires_in }); - } else { - deferred.reject("Problem authenticating"); - } - setTimeout(function() { - browserRef.close(); - }, 10); - } - }); - browserRef.addEventListener('exit', function(event) { - deferred.reject("The sign in flow was canceled"); - }); - } else { - deferred.reject("Could not find InAppBrowser plugin"); - } - } else { - deferred.reject("Cannot authenticate via a web browser"); - } - return deferred.promise; - }, + /* + * Sign into the Digital Ocean service + * + * @param string clientId + * @param string clientSecret + * @return promise + */ + digitalOcean: function (clientId, clientSecret) { + var deferred = $q.defer(); + if (window.cordova) { + var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; + if (cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { + var browserRef = window.open("https://cloud.digitalocean.com/v1/oauth/authorize?client_id=" + clientId + "&redirect_uri=http://localhost/callback&response_type=code&scope=read%20write", "_blank", "location=no,clearsessioncache=yes,clearcache=yes"); + browserRef.addEventListener("loadstart", function (event) { + if ((event.url).indexOf("http://localhost/callback") === 0) { + var requestToken = (event.url).split("code=")[1]; + $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; + $http({ + method: "post", + url: "https://cloud.digitalocean.com/v1/oauth/token", + data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&redirect_uri=http://localhost/callback" + "&grant_type=authorization_code" + "&code=" + requestToken + }) + .success(function (data) { + deferred.resolve(data); + }) + .error(function (data, status) { + deferred.reject("Problem authenticating"); + }) + .finally(function () { + setTimeout(function () { + browserRef.close(); + }, 10); + }); + } + }); + browserRef.addEventListener('exit', function (event) { + deferred.reject("The sign in flow was canceled"); + }); + } else { + deferred.reject("Could not find InAppBrowser plugin"); + } + } else { + deferred.reject("Cannot authenticate via a web browser"); + } + return deferred.promise; + }, - /* - * Sign into the GitHub service - * - * @param string clientId - * @param string clientSecret - * @param array appScope - * @return promise - */ - github: function(clientId, clientSecret, appScope) { - var deferred = $q.defer(); - if(window.cordova) { - var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; - if(cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { - var browserRef = window.open('https://github.com/login/oauth/authorize?client_id=' + clientId + '&redirect_uri=http://localhost/callback&scope=' + appScope.join(","), '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); - browserRef.addEventListener('loadstart', function(event) { - if((event.url).indexOf("http://localhost/callback") === 0) { - requestToken = (event.url).split("code=")[1]; - $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; - $http.defaults.headers.post.accept = 'application/json'; - $http({method: "post", url: "https://github.com/login/oauth/access_token", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&redirect_uri=http://localhost/callback" + "&code=" + requestToken }) - .success(function(data) { - deferred.resolve(data); - }) - .error(function(data, status) { - deferred.reject("Problem authenticating"); - }) - .finally(function() { - setTimeout(function() { - browserRef.close(); - }, 10); - }); - } - }); - browserRef.addEventListener('exit', function(event) { - deferred.reject("The sign in flow was canceled"); - }); - } else { - deferred.reject("Could not find InAppBrowser plugin"); + /* + * Sign into the Google service + * + * @param string clientId + * @param array appScope + * @return promise + */ + google: function (clientId, appScope) { + var deferred = $q.defer(); + if (window.cordova) { + var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; + if (cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { + var browserRef = window.open('https://accounts.google.com/o/oauth2/auth?client_id=' + clientId + '&redirect_uri=http://localhost/callback&scope=' + appScope.join(" ") + '&approval_prompt=force&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); + browserRef.addEventListener("loadstart", function (event) { + if ((event.url).indexOf("http://localhost/callback") === 0) { + var callbackResponse = (event.url).split("#")[1]; + var responseParameters = (callbackResponse).split("&"); + var parameterMap = []; + for (var i = 0; i < responseParameters.length; i++) { + parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1]; } - } else { - deferred.reject("Cannot authenticate via a web browser"); - } - return deferred.promise; - }, - - /* - * Sign into the Facebook service - * - * @param string clientId - * @param array appScope - * @return promise - */ - facebook: function(clientId, appScope) { - var deferred = $q.defer(); - if(window.cordova) { - var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; - if(cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { - var browserRef = window.open('https://www.facebook.com/dialog/oauth?client_id=' + clientId + '&redirect_uri=http://localhost/callback&response_type=token&scope=' + appScope.join(","), '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); - browserRef.addEventListener('loadstart', function(event) { - if((event.url).indexOf("http://localhost/callback") === 0) { - var callbackResponse = (event.url).split("#")[1]; - var responseParameters = (callbackResponse).split("&"); - var parameterMap = []; - for(var i = 0; i < responseParameters.length; i++) { - parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1]; - } - if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) { - deferred.resolve({ access_token: parameterMap.access_token, expires_in: parameterMap.expires_in }); - } else { - deferred.reject("Problem authenticating"); - } - setTimeout(function() { - browserRef.close(); - }, 10); - } - }); - browserRef.addEventListener('exit', function(event) { - deferred.reject("The sign in flow was canceled"); - }); + if (parameterMap.access_token !== undefined && parameterMap.access_token !== null) { + deferred.resolve({access_token: parameterMap.access_token, token_type: parameterMap.token_type, expires_in: parameterMap.expires_in}); } else { - deferred.reject("Could not find InAppBrowser plugin"); + deferred.reject("Problem authenticating"); } - } else { - deferred.reject("Cannot authenticate via a web browser"); - } - return deferred.promise; - }, + setTimeout(function () { + browserRef.close(); + }, 10); + } + }); + browserRef.addEventListener('exit', function (event) { + deferred.reject("The sign in flow was canceled"); + }); + } else { + deferred.reject("Could not find InAppBrowser plugin"); + } + } else { + deferred.reject("Cannot authenticate via a web browser"); + } + return deferred.promise; + }, - /* - * Sign into the LinkedIn service - * - * @param string clientId - * @param string clientSecret - * @param array appScope - * @param string state - * @return promise - */ - linkedin: function(clientId, clientSecret, appScope, state) { - var deferred = $q.defer(); - if(window.cordova) { - var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; - if(cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { - var browserRef = window.open('https://www.linkedin.com/uas/oauth2/authorization?client_id=' + clientId + '&redirect_uri=http://localhost/callback&scope=' + appScope.join(" ") + '&response_type=code&state=' + state, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); - browserRef.addEventListener('loadstart', function(event) { - if((event.url).indexOf("http://localhost/callback") === 0) { - requestToken = (event.url).split("code=")[1]; - $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; - $http({method: "post", url: "https://www.linkedin.com/uas/oauth2/accessToken", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&redirect_uri=http://localhost/callback" + "&grant_type=authorization_code" + "&code=" + requestToken }) - .success(function(data) { - deferred.resolve(data); - }) - .error(function(data, status) { - deferred.reject("Problem authenticating"); - }) - .finally(function() { - setTimeout(function() { - browserRef.close(); - }, 10); - }); - } - }); - browserRef.addEventListener('exit', function(event) { - deferred.reject("The sign in flow was canceled"); - }); - } else { - deferred.reject("Could not find InAppBrowser plugin"); - } - } else { - deferred.reject("Cannot authenticate via a web browser"); - } - return deferred.promise; - }, + /* + * Sign into the GitHub service + * + * @param string clientId + * @param string clientSecret + * @param array appScope + * @return promise + */ + github: function (clientId, clientSecret, appScope) { + var deferred = $q.defer(); + if (window.cordova) { + var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; + if (cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { + var browserRef = window.open('https://github.com/login/oauth/authorize?client_id=' + clientId + '&redirect_uri=http://localhost/callback&scope=' + appScope.join(","), '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); + browserRef.addEventListener('loadstart', function (event) { + if ((event.url).indexOf("http://localhost/callback") === 0) { + requestToken = (event.url).split("code=")[1]; + $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; + $http.defaults.headers.post.accept = 'application/json'; + $http({method: "post", url: "https://github.com/login/oauth/access_token", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&redirect_uri=http://localhost/callback" + "&code=" + requestToken}) + .success(function (data) { + deferred.resolve(data); + }) + .error(function (data, status) { + deferred.reject("Problem authenticating"); + }) + .finally(function () { + setTimeout(function () { + browserRef.close(); + }, 10); + }); + } + }); + browserRef.addEventListener('exit', function (event) { + deferred.reject("The sign in flow was canceled"); + }); + } else { + deferred.reject("Could not find InAppBrowser plugin"); + } + } else { + deferred.reject("Cannot authenticate via a web browser"); + } + return deferred.promise; + }, - /* - * Sign into the Instagram service - * - * @param string clientId - * @param array appScope - * @return promise - */ - instagram: function(clientId, appScope) { - var deferred = $q.defer(); - if(window.cordova) { - var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; - if(cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { - var browserRef = window.open('https://api.instagram.com/oauth/authorize/?client_id=' + clientId + '&redirect_uri=http://localhost/callback&scope=' + appScope.join(" ") + '&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); - browserRef.addEventListener('loadstart', function(event) { - if((event.url).indexOf("http://localhost/callback") === 0) { - var callbackResponse = (event.url).split("#")[1]; - var responseParameters = (callbackResponse).split("&"); - var parameterMap = []; - for(var i = 0; i < responseParameters.length; i++) { - parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1]; - } - if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) { - deferred.resolve({ access_token: parameterMap.access_token }); - } else { - deferred.reject("Problem authenticating"); - } - setTimeout(function() { - browserRef.close(); - }, 10); - } - }); - browserRef.addEventListener('exit', function(event) { - deferred.reject("The sign in flow was canceled"); - }); - } else { - deferred.reject("Could not find InAppBrowser plugin"); + /* + * Sign into the Facebook service + * + * @param string clientId + * @param array appScope + * @return promise + */ + facebook: function (clientId, appScope) { + var deferred = $q.defer(); + if (window.cordova) { + var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; + if (cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { + var browserRef = window.open('https://www.facebook.com/dialog/oauth?client_id=' + clientId + '&redirect_uri=http://localhost/callback&response_type=token&scope=' + appScope.join(","), '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); + browserRef.addEventListener('loadstart', function (event) { + if ((event.url).indexOf("http://localhost/callback") === 0) { + var callbackResponse = (event.url).split("#")[1]; + var responseParameters = (callbackResponse).split("&"); + var parameterMap = []; + for (var i = 0; i < responseParameters.length; i++) { + parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1]; } - } else { - deferred.reject("Cannot authenticate via a web browser"); - } - return deferred.promise; - }, - - /* - * Sign into the Box service - * - * @param string clientId - * @param string clientSecret - * @param string appState - * @return promise - */ - box: function(clientId, clientSecret, appState) { - var deferred = $q.defer(); - if(window.cordova) { - var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; - if(cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { - var browserRef = window.open('https://app.box.com/api/oauth2/authorize/?client_id=' + clientId + '&redirect_uri=http://localhost/callback&state=' + appState + '&response_type=code', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); - browserRef.addEventListener('loadstart', function(event) { - if((event.url).indexOf("http://localhost/callback") === 0) { - requestToken = (event.url).split("code=")[1]; - $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; - $http({method: "post", url: "https://app.box.com/api/oauth2/token", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&redirect_uri=http://localhost/callback" + "&grant_type=authorization_code" + "&code=" + requestToken }) - .success(function(data) { - deferred.resolve(data); - }) - .error(function(data, status) { - deferred.reject("Problem authenticating"); - }) - .finally(function() { - setTimeout(function() { - browserRef.close(); - }, 10); - }); - } - }); - browserRef.addEventListener('exit', function(event) { - deferred.reject("The sign in flow was canceled"); - }); + if (parameterMap.access_token !== undefined && parameterMap.access_token !== null) { + deferred.resolve({access_token: parameterMap.access_token, expires_in: parameterMap.expires_in}); } else { - deferred.reject("Could not find InAppBrowser plugin"); + deferred.reject("Problem authenticating"); } - } else { - deferred.reject("Cannot authenticate via a web browser"); - } - return deferred.promise; - }, + setTimeout(function () { + browserRef.close(); + }, 10); + } + }); + browserRef.addEventListener('exit', function (event) { + deferred.reject("The sign in flow was canceled"); + }); + } else { + deferred.reject("Could not find InAppBrowser plugin"); + } + } else { + deferred.reject("Cannot authenticate via a web browser"); + } + return deferred.promise; + }, - /* - * Sign into the Reddit service - * - * @param string clientId - * @param string clientSecret - * @param array appScope - * @return promise - */ - reddit: function(clientId, clientSecret, appScope) { - var deferred = $q.defer(); - if(window.cordova) { - var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; - if(cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { - var browserRef = window.open('https://ssl.reddit.com/api/v1/authorize?client_id=' + clientId + '&redirect_uri=http://localhost/callback&duration=permanent&state=ngcordovaoauth&scope=' + appScope.join(",") + '&response_type=code', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); - browserRef.addEventListener('loadstart', function(event) { - if((event.url).indexOf("http://localhost/callback") === 0) { - requestToken = (event.url).split("code=")[1]; - $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; - $http.defaults.headers.post.Authorization = 'Basic ' + btoa(clientId + ":" + clientSecret); - $http({method: "post", url: "https://ssl.reddit.com/api/v1/access_token", data: "redirect_uri=http://localhost/callback" + "&grant_type=authorization_code" + "&code=" + requestToken }) - .success(function(data) { - deferred.resolve(data); - }) - .error(function(data, status) { - deferred.reject("Problem authenticating"); - }) - .finally(function() { - setTimeout(function() { - browserRef.close(); - }, 10); - }); - } - }); - browserRef.addEventListener('exit', function(event) { - deferred.reject("The sign in flow was canceled"); - }); + /* + * Sign into the LinkedIn service + * + * @param string clientId + * @param string clientSecret + * @param array appScope + * @param string state + * @return promise + */ + linkedin: function (clientId, clientSecret, appScope, state) { + var deferred = $q.defer(); + if (window.cordova) { + var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; + if (cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { + var browserRef = window.open('https://www.linkedin.com/uas/oauth2/authorization?client_id=' + clientId + '&redirect_uri=http://localhost/callback&scope=' + appScope.join(" ") + '&response_type=code&state=' + state, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); + browserRef.addEventListener('loadstart', function (event) { + if ((event.url).indexOf("http://localhost/callback") === 0) { + requestToken = (event.url).split("code=")[1]; + $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; + $http({ + method: "post", + url: "https://www.linkedin.com/uas/oauth2/accessToken", + data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&redirect_uri=http://localhost/callback" + "&grant_type=authorization_code" + "&code=" + requestToken + }) + .success(function (data) { + deferred.resolve(data); + }) + .error(function (data, status) { + deferred.reject("Problem authenticating"); + }) + .finally(function () { + setTimeout(function () { + browserRef.close(); + }, 10); + }); + } + }); + browserRef.addEventListener('exit', function (event) { + deferred.reject("The sign in flow was canceled"); + }); + } else { + deferred.reject("Could not find InAppBrowser plugin"); + } + } else { + deferred.reject("Cannot authenticate via a web browser"); + } + return deferred.promise; + }, + + /* + * Sign into the Instagram service + * + * @param string clientId + * @param array appScope + * @return promise + */ + instagram: function (clientId, appScope) { + var deferred = $q.defer(); + if (window.cordova) { + var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; + if (cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { + var browserRef = window.open('https://api.instagram.com/oauth/authorize/?client_id=' + clientId + '&redirect_uri=http://localhost/callback&scope=' + appScope.join(" ") + '&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); + browserRef.addEventListener('loadstart', function (event) { + if ((event.url).indexOf("http://localhost/callback") === 0) { + var callbackResponse = (event.url).split("#")[1]; + var responseParameters = (callbackResponse).split("&"); + var parameterMap = []; + for (var i = 0; i < responseParameters.length; i++) { + parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1]; + } + if (parameterMap.access_token !== undefined && parameterMap.access_token !== null) { + deferred.resolve({access_token: parameterMap.access_token}); } else { - deferred.reject("Could not find InAppBrowser plugin"); + deferred.reject("Problem authenticating"); } - } else { - deferred.reject("Cannot authenticate via a web browser"); - } - return deferred.promise; - }, + setTimeout(function () { + browserRef.close(); + }, 10); + } + }); + browserRef.addEventListener('exit', function (event) { + deferred.reject("The sign in flow was canceled"); + }); + } else { + deferred.reject("Could not find InAppBrowser plugin"); + } + } else { + deferred.reject("Cannot authenticate via a web browser"); + } + return deferred.promise; + }, - /* - * Sign into the Twitter service - * Note that this service requires jsSHA for generating HMAC-SHA1 Oauth 1.0 signatures - * - * @param string clientId - * @param string clientSecret - * @return promise - */ - twitter: function(clientId, clientSecret) { - var deferred = $q.defer(); - if(window.cordova) { - var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; - if(cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { - if(typeof jsSHA !== "undefined") { - var oauthObject = { - oauth_consumer_key: clientId, - oauth_nonce: $cordovaOauthUtility.createNonce(10), - oauth_signature_method: "HMAC-SHA1", - oauth_timestamp: Math.round((new Date()).getTime() / 1000.0), - oauth_version: "1.0" - }; - var signatureObj = $cordovaOauthUtility.createSignature("POST", "https://api.twitter.com/oauth/request_token", oauthObject, { oauth_callback: "http://localhost/callback" }, clientSecret); - $http({ - method: "post", - url: "https://api.twitter.com/oauth/request_token", - headers: { - "Authorization": signatureObj.authorization_header, - "Content-Type": "application/x-www-form-urlencoded" - }, - data: "oauth_callback=" + encodeURIComponent("http://localhost/callback") + /* + * Sign into the Box service + * + * @param string clientId + * @param string clientSecret + * @param string appState + * @return promise + */ + box: function (clientId, clientSecret, appState) { + var deferred = $q.defer(); + if (window.cordova) { + var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; + if (cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { + var browserRef = window.open('https://app.box.com/api/oauth2/authorize/?client_id=' + clientId + '&redirect_uri=http://localhost/callback&state=' + appState + '&response_type=code', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); + browserRef.addEventListener('loadstart', function (event) { + if ((event.url).indexOf("http://localhost/callback") === 0) { + requestToken = (event.url).split("code=")[1]; + $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; + $http({ + method: "post", + url: "https://app.box.com/api/oauth2/token", + data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&redirect_uri=http://localhost/callback" + "&grant_type=authorization_code" + "&code=" + requestToken + }) + .success(function (data) { + deferred.resolve(data); + }) + .error(function (data, status) { + deferred.reject("Problem authenticating"); + }) + .finally(function () { + setTimeout(function () { + browserRef.close(); + }, 10); + }); + } + }); + browserRef.addEventListener('exit', function (event) { + deferred.reject("The sign in flow was canceled"); + }); + } else { + deferred.reject("Could not find InAppBrowser plugin"); + } + } else { + deferred.reject("Cannot authenticate via a web browser"); + } + return deferred.promise; + }, + + /* + * Sign into the Reddit service + * + * @param string clientId + * @param string clientSecret + * @param array appScope + * @return promise + */ + reddit: function (clientId, clientSecret, appScope) { + var deferred = $q.defer(); + if (window.cordova) { + var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; + if (cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { + var browserRef = window.open('https://ssl.reddit.com/api/v1/authorize?client_id=' + clientId + '&redirect_uri=http://localhost/callback&duration=permanent&state=ngcordovaoauth&scope=' + appScope.join(",") + '&response_type=code', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); + browserRef.addEventListener('loadstart', function (event) { + if ((event.url).indexOf("http://localhost/callback") === 0) { + requestToken = (event.url).split("code=")[1]; + $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; + $http.defaults.headers.post.Authorization = 'Basic ' + btoa(clientId + ":" + clientSecret); + $http({method: "post", url: "https://ssl.reddit.com/api/v1/access_token", data: "redirect_uri=http://localhost/callback" + "&grant_type=authorization_code" + "&code=" + requestToken}) + .success(function (data) { + deferred.resolve(data); + }) + .error(function (data, status) { + deferred.reject("Problem authenticating"); + }) + .finally(function () { + setTimeout(function () { + browserRef.close(); + }, 10); + }); + } + }); + browserRef.addEventListener('exit', function (event) { + deferred.reject("The sign in flow was canceled"); + }); + } else { + deferred.reject("Could not find InAppBrowser plugin"); + } + } else { + deferred.reject("Cannot authenticate via a web browser"); + } + return deferred.promise; + }, + + /* + * Sign into the Twitter service + * Note that this service requires jsSHA for generating HMAC-SHA1 Oauth 1.0 signatures + * + * @param string clientId + * @param string clientSecret + * @return promise + */ + twitter: function (clientId, clientSecret) { + var deferred = $q.defer(); + if (window.cordova) { + var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; + if (cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { + if (typeof jsSHA !== "undefined") { + var oauthObject = { + oauth_consumer_key: clientId, + oauth_nonce: $cordovaOauthUtility.createNonce(10), + oauth_signature_method: "HMAC-SHA1", + oauth_timestamp: Math.round((new Date()).getTime() / 1000.0), + oauth_version: "1.0" + }; + var signatureObj = $cordovaOauthUtility.createSignature("POST", "https://api.twitter.com/oauth/request_token", oauthObject, {oauth_callback: "http://localhost/callback"}, clientSecret); + $http({ + method: "post", + url: "https://api.twitter.com/oauth/request_token", + headers: { + "Authorization": signatureObj.authorization_header, + "Content-Type": "application/x-www-form-urlencoded" + }, + data: "oauth_callback=" + encodeURIComponent("http://localhost/callback") + }) + .success(function (requestTokenResult) { + var requestTokenParameters = (requestTokenResult).split("&"); + var parameterMap = {}; + for (var i = 0; i < requestTokenParameters.length; i++) { + parameterMap[requestTokenParameters[i].split("=")[0]] = requestTokenParameters[i].split("=")[1]; + } + if (parameterMap.hasOwnProperty("oauth_token") === false) { + deferred.reject("Oauth request token was not received"); + } + var browserRef = window.open('https://api.twitter.com/oauth/authenticate?oauth_token=' + parameterMap.oauth_token, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); + browserRef.addEventListener('loadstart', function (event) { + if ((event.url).indexOf("http://localhost/callback") === 0) { + var callbackResponse = (event.url).split("?")[1]; + var responseParameters = (callbackResponse).split("&"); + var parameterMap = {}; + for (var i = 0; i < responseParameters.length; i++) { + parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1]; + } + if (parameterMap.hasOwnProperty("oauth_verifier") === false) { + deferred.reject("Browser authentication failed to complete. No oauth_verifier was returned"); + } + delete oauthObject.oauth_signature; + oauthObject.oauth_token = parameterMap.oauth_token; + var signatureObj = $cordovaOauthUtility.createSignature("POST", "https://api.twitter.com/oauth/access_token", oauthObject, {oauth_verifier: parameterMap.oauth_verifier}, clientSecret); + $http({ + method: "post", + url: "https://api.twitter.com/oauth/access_token", + headers: { + "Authorization": signatureObj.authorization_header + }, + params: { + "oauth_verifier": parameterMap.oauth_verifier + } + }) + .success(function (result) { + var accessTokenParameters = result.split("&"); + var parameterMap = {}; + for (var i = 0; i < accessTokenParameters.length; i++) { + parameterMap[accessTokenParameters[i].split("=")[0]] = accessTokenParameters[i].split("=")[1]; + } + if (parameterMap.hasOwnProperty("oauth_token_secret") === false) { + deferred.reject("Oauth access token was not received"); + } + deferred.resolve(parameterMap); }) - .success(function(requestTokenResult) { - var requestTokenParameters = (requestTokenResult).split("&"); - var parameterMap = {}; - for(var i = 0; i < requestTokenParameters.length; i++) { - parameterMap[requestTokenParameters[i].split("=")[0]] = requestTokenParameters[i].split("=")[1]; - } - if(parameterMap.hasOwnProperty("oauth_token") === false) { - deferred.reject("Oauth request token was not received"); - } - var browserRef = window.open('https://api.twitter.com/oauth/authenticate?oauth_token=' + parameterMap.oauth_token, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); - browserRef.addEventListener('loadstart', function(event) { - if((event.url).indexOf("http://localhost/callback") === 0) { - var callbackResponse = (event.url).split("?")[1]; - var responseParameters = (callbackResponse).split("&"); - var parameterMap = {}; - for(var i = 0; i < responseParameters.length; i++) { - parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1]; - } - if(parameterMap.hasOwnProperty("oauth_verifier") === false) { - deferred.reject("Browser authentication failed to complete. No oauth_verifier was returned"); - } - delete oauthObject.oauth_signature; - oauthObject.oauth_token = parameterMap.oauth_token; - var signatureObj = $cordovaOauthUtility.createSignature("POST", "https://api.twitter.com/oauth/access_token", oauthObject, { oauth_verifier: parameterMap.oauth_verifier }, clientSecret); - $http({ - method: "post", - url: "https://api.twitter.com/oauth/access_token", - headers: { - "Authorization": signatureObj.authorization_header - }, - params: { - "oauth_verifier": parameterMap.oauth_verifier - } - }) - .success(function(result) { - var accessTokenParameters = result.split("&"); - var parameterMap = {}; - for(var i = 0; i < accessTokenParameters.length; i++) { - parameterMap[accessTokenParameters[i].split("=")[0]] = accessTokenParameters[i].split("=")[1]; - } - if(parameterMap.hasOwnProperty("oauth_token_secret") === false) { - deferred.reject("Oauth access token was not received"); - } - deferred.resolve(parameterMap); - }) - .error(function(error) { - deferred.reject(error); - }) - .finally(function() { - setTimeout(function() { - browserRef.close(); - }, 10); - }); - } - }); - browserRef.addEventListener('exit', function(event) { - deferred.reject("The sign in flow was canceled"); - }); - }) - .error(function(error) { - deferred.reject(error); - }); - } else { - deferred.reject("Missing jsSHA JavaScript library"); + .error(function (error) { + deferred.reject(error); + }) + .finally(function () { + setTimeout(function () { + browserRef.close(); + }, 10); + }); } - } else { - deferred.reject("Could not find InAppBrowser plugin"); - } + }); + browserRef.addEventListener('exit', function (event) { + deferred.reject("The sign in flow was canceled"); + }); + }) + .error(function (error) { + deferred.reject(error); + }); } else { - deferred.reject("Cannot authenticate via a web browser"); + deferred.reject("Missing jsSHA JavaScript library"); } - return deferred.promise; - }, + } else { + deferred.reject("Could not find InAppBrowser plugin"); + } + } else { + deferred.reject("Cannot authenticate via a web browser"); + } + return deferred.promise; + }, - /* - * Sign into the Meetup service - * - * @param string clientId - * @return promise - */ - meetup: function(clientId) { - var deferred = $q.defer(); - if(window.cordova) { - var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; - if(cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { - var browserRef = window.open('https://secure.meetup.com/oauth2/authorize/?client_id=' + clientId + '&redirect_uri=http://localhost/callback&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); - browserRef.addEventListener('loadstart', function(event) { - if((event.url).indexOf("http://localhost/callback") === 0) { - var callbackResponse = (event.url).split("#")[1]; - var responseParameters = (callbackResponse).split("&"); - var parameterMap = {}; - for(var i = 0; i < responseParameters.length; i++) { - parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1]; - } - if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) { - deferred.resolve(parameterMap); - } else { - deferred.reject("Problem authenticating"); - } - setTimeout(function() { - browserRef.close(); - }, 10); - } - }); - browserRef.addEventListener('exit', function(event) { - deferred.reject("The sign in flow was canceled"); - }); - } else { - deferred.reject("Could not find InAppBrowser plugin"); + /* + * Sign into the Meetup service + * + * @param string clientId + * @return promise + */ + meetup: function (clientId) { + var deferred = $q.defer(); + if (window.cordova) { + var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; + if (cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { + var browserRef = window.open('https://secure.meetup.com/oauth2/authorize/?client_id=' + clientId + '&redirect_uri=http://localhost/callback&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); + browserRef.addEventListener('loadstart', function (event) { + if ((event.url).indexOf("http://localhost/callback") === 0) { + var callbackResponse = (event.url).split("#")[1]; + var responseParameters = (callbackResponse).split("&"); + var parameterMap = {}; + for (var i = 0; i < responseParameters.length; i++) { + parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1]; } - } else { - deferred.reject("Cannot authenticate via a web browser"); - } - return deferred.promise; - }, - - /* - * Sign into the Salesforce service - * - * Suggestion: use salesforce oauth with forcetk.js(as SDK) - * - * @param string loginUrl (such as: https://login.salesforce.com ; please notice community login) - * @param string clientId (copy from connection app info) - * @param string redirectUri (callback url in connection app info) - * @return promise - */ - salesforce: function (loginUrl, clientId) { - var redirectUri = 'http://localhost/callback'; - var getAuthorizeUrl = function (loginUrl, clientId, redirectUri) { - return loginUrl+'services/oauth2/authorize?display=touch'+ - '&response_type=token&client_id='+escape(clientId)+ - '&redirect_uri='+escape(redirectUri); - }; - var startWith = function(string, str) { - return (string.substr(0, str.length) === str); - }; - var deferred = $q.defer(); - if(window.cordova) { - var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; - if(cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { - var browserRef = window.open(getAuthorizeUrl(loginUrl, clientId, redirectUri), "_blank", "location=no,clearsessioncache=yes,clearcache=yes"); - browserRef.addEventListener("loadstart", function(event) { - if(startWith(event.url, redirectUri)) { - var oauthResponse = {}; - - var fragment = (event.url).split('#')[1]; - - if (fragment) { - var nvps = fragment.split('&'); - for (var nvp in nvps) { - var parts = nvps[nvp].split('='); - oauthResponse[parts[0]] = unescape(parts[1]); - } - } - - if (typeof oauthResponse === 'undefined' || - typeof oauthResponse.access_token === 'undefined') { - deferred.reject("Problem authenticating"); - } else { - deferred.resolve(oauthResponse); - } - setTimeout(function() { - browserRef.close(); - }, 10); - } - }); - browserRef.addEventListener('exit', function(event) { - deferred.reject("The sign in flow was canceled"); - }); - } else { - deferred.reject("Could not find InAppBrowser plugin"); - } + if (parameterMap.access_token !== undefined && parameterMap.access_token !== null) { + deferred.resolve(parameterMap); } else { - deferred.reject("Cannot authenticate via a web browser"); + deferred.reject("Problem authenticating"); } - return deferred.promise; - }, + setTimeout(function () { + browserRef.close(); + }, 10); + } + }); + browserRef.addEventListener('exit', function (event) { + deferred.reject("The sign in flow was canceled"); + }); + } else { + deferred.reject("Could not find InAppBrowser plugin"); + } + } else { + deferred.reject("Cannot authenticate via a web browser"); + } + return deferred.promise; + }, - /* - * Sign into the Strava service - * - * @param string clientId - * @param string clientSecret - * @param array appScope - * @return promise - */ - strava: function(clientId, clientSecret, appScope) { - var deferred = $q.defer(); - if(window.cordova) { - var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; - if(cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { - var browserRef = window.open('https://www.strava.com/oauth/authorize?client_id=' + clientId + '&redirect_uri=http://localhost/callback&scope=' + appScope.join(",") + '&response_type=code&approval_prompt=force', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); - browserRef.addEventListener('loadstart', function(event) { - if((event.url).indexOf("http://localhost/callback") === 0) { - requestToken = (event.url).split("code=")[1]; - $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; - $http({method: "post", url: "https://www.strava.com/oauth/token", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&code=" + requestToken }) - .success(function(data) { - deferred.resolve(data); - }) - .error(function(data, status) { - deferred.reject("Problem authenticating"); - }) - .finally(function() { - setTimeout(function() { - browserRef.close(); - }, 10); - }); - } - }); - browserRef.addEventListener('exit', function(event) { - deferred.reject("The sign in flow was canceled"); - }); - } else { - deferred.reject("Could not find InAppBrowser plugin"); - } - } else { - deferred.reject("Cannot authenticate via a web browser"); + /* + * Sign into the Salesforce service + * + * Suggestion: use salesforce oauth with forcetk.js(as SDK) + * + * @param string loginUrl (such as: https://login.salesforce.com ; please notice community login) + * @param string clientId (copy from connection app info) + * @param string redirectUri (callback url in connection app info) + * @return promise + */ + salesforce: function (loginUrl, clientId) { + var redirectUri = 'http://localhost/callback'; + var getAuthorizeUrl = function (loginUrl, clientId, redirectUri) { + return loginUrl + 'services/oauth2/authorize?display=touch' + + '&response_type=token&client_id=' + escape(clientId) + + '&redirect_uri=' + escape(redirectUri); + }; + var startWith = function (string, str) { + return (string.substr(0, str.length) === str); + }; + var deferred = $q.defer(); + if (window.cordova) { + var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; + if (cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { + var browserRef = window.open(getAuthorizeUrl(loginUrl, clientId, redirectUri), "_blank", "location=no,clearsessioncache=yes,clearcache=yes"); + browserRef.addEventListener("loadstart", function (event) { + if (startWith(event.url, redirectUri)) { + var oauthResponse = {}; + + var fragment = (event.url).split('#')[1]; + + if (fragment) { + var nvps = fragment.split('&'); + for (var nvp in nvps) { + var parts = nvps[nvp].split('='); + oauthResponse[parts[0]] = unescape(parts[1]); + } } - return deferred.promise; - }, - /* - * Sign into the Foursquare service - * - * @param string clientId - * @return promise - */ - foursquare: function(clientId) { - var deferred = $q.defer(); - if (window.cordova) { - var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; - if (cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { - var browserRef = window.open('https://foursquare.com/oauth2/authenticate?client_id=' + clientId + '&redirect_uri=http://localhost/callback&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); - browserRef.addEventListener('loadstart', function (event) { - if ((event.url).indexOf("http://localhost/callback") === 0) { - var callbackResponse = (event.url).split("#")[1]; - var responseParameters = (callbackResponse).split("&"); - var parameterMap = []; - for (var i = 0; i < responseParameters.length; i++) { - parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1]; - } - if (parameterMap.access_token !== undefined && parameterMap.access_token !== null) { - var promiseResponse = { - access_token: parameterMap.access_token, - expires_in: parameterMap.expires_in - }; - deferred.resolve(promiseResponse); - } else { - deferred.reject("Problem authenticating"); - } - setTimeout(function() { - browserRef.close(); - }, 10); - } - }); - browserRef.addEventListener('exit', function(event) { - deferred.reject("The sign in flow was canceled"); - }); - } else { - deferred.reject("Could not find InAppBrowser plugin"); - } + if (typeof oauthResponse === 'undefined' || + typeof oauthResponse.access_token === 'undefined') { + deferred.reject("Problem authenticating"); } else { - deferred.reject("Cannot authenticate via a web browser"); + deferred.resolve(oauthResponse); } - return deferred.promise; - }, + setTimeout(function () { + browserRef.close(); + }, 10); + } + }); + browserRef.addEventListener('exit', function (event) { + deferred.reject("The sign in flow was canceled"); + }); + } else { + deferred.reject("Could not find InAppBrowser plugin"); + } + } else { + deferred.reject("Cannot authenticate via a web browser"); + } + return deferred.promise; + }, - /* - * Sign into the Magento service - * Note that this service requires jsSHA for generating HMAC-SHA1 Oauth 1.0 signatures - * - * @param string baseUrl - * @param string clientId - * @param string clientSecret - * @return promise - */ - magento: function(baseUrl, clientId, clientSecret) { - var deferred = $q.defer(); - if(window.cordova) { - var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; - if(cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { - if(typeof jsSHA !== "undefined") { - var oauthObject = { - oauth_callback: "http://localhost/callback", - oauth_consumer_key: clientId, - oauth_nonce: $cordovaOauthUtility.createNonce(5), - oauth_signature_method: "HMAC-SHA1", - oauth_timestamp: Math.round((new Date()).getTime() / 1000.0), - oauth_version: "1.0" - }; - var signatureObj = $cordovaOauthUtility.createSignature("POST", baseUrl + "/oauth/initiate", oauthObject, { oauth_callback: "http://localhost/callback" }, clientSecret); - $http.defaults.headers.post.Authorization = signatureObj.authorization_header; - $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; - $http({method: "post", url: baseUrl + "/oauth/initiate", data: "oauth_callback=http://localhost/callback" }) - .success(function(requestTokenResult) { - var requestTokenParameters = (requestTokenResult).split("&"); - var parameterMap = {}; - for(var i = 0; i < requestTokenParameters.length; i++) { - parameterMap[requestTokenParameters[i].split("=")[0]] = requestTokenParameters[i].split("=")[1]; - } - if(parameterMap.hasOwnProperty("oauth_token") === false) { - deferred.reject("Oauth request token was not received"); - } - var tokenSecret = parameterMap.oauth_token_secret; - var browserRef = window.open(baseUrl + '/oauth/authorize?oauth_token=' + parameterMap.oauth_token, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); - browserRef.addEventListener('loadstart', function(event) { - if((event.url).indexOf("http://localhost/callback") === 0) { - var callbackResponse = (event.url).split("?")[1]; - var responseParameters = (callbackResponse).split("&"); - var parameterMap = {}; - for(var i = 0; i < responseParameters.length; i++) { - parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1]; - } - if(parameterMap.hasOwnProperty("oauth_verifier") === false) { - deferred.reject("Browser authentication failed to complete. No oauth_verifier was returned"); - } - delete oauthObject.oauth_signature; - delete oauthObject.oauth_callback; - oauthObject.oauth_token = parameterMap.oauth_token; - oauthObject.oauth_nonce = $cordovaOauthUtility.createNonce(5); - oauthObject.oauth_verifier = parameterMap.oauth_verifier; - var signatureObj = $cordovaOauthUtility.createSignature("POST", baseUrl + "/oauth/token", oauthObject, {}, clientSecret, tokenSecret); - $http.defaults.headers.post.Authorization = signatureObj.authorization_header; - $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; - $http({method: "post", url: baseUrl + "/oauth/token" }) - .success(function(result) { - var accessTokenParameters = result.split("&"); - var parameterMap = {}; - for(var i = 0; i < accessTokenParameters.length; i++) { - parameterMap[accessTokenParameters[i].split("=")[0]] = accessTokenParameters[i].split("=")[1]; - } - if(parameterMap.hasOwnProperty("oauth_token_secret") === false) { - deferred.reject("Oauth access token was not received"); - } - deferred.resolve(parameterMap); - }) - .error(function(error) { - deferred.reject(error); - }) - .finally(function() { - setTimeout(function() { - browserRef.close(); - }, 10); - }); - } - }); - browserRef.addEventListener('exit', function(event) { - deferred.reject("The sign in flow was canceled"); - }); - }) - .error(function(error) { - deferred.reject(error); - }); - } else { - deferred.reject("Missing jsSHA JavaScript library"); - } - } else { - deferred.reject("Could not find InAppBrowser plugin"); - } + /* + * Sign into the Strava service + * + * @param string clientId + * @param string clientSecret + * @param array appScope + * @return promise + */ + strava: function (clientId, clientSecret, appScope) { + var deferred = $q.defer(); + if (window.cordova) { + var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; + if (cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { + var browserRef = window.open('https://www.strava.com/oauth/authorize?client_id=' + clientId + '&redirect_uri=http://localhost/callback&scope=' + appScope.join(",") + '&response_type=code&approval_prompt=force', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); + browserRef.addEventListener('loadstart', function (event) { + if ((event.url).indexOf("http://localhost/callback") === 0) { + requestToken = (event.url).split("code=")[1]; + $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; + $http({method: "post", url: "https://www.strava.com/oauth/token", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&code=" + requestToken}) + .success(function (data) { + deferred.resolve(data); + }) + .error(function (data, status) { + deferred.reject("Problem authenticating"); + }) + .finally(function () { + setTimeout(function () { + browserRef.close(); + }, 10); + }); + } + }); + browserRef.addEventListener('exit', function (event) { + deferred.reject("The sign in flow was canceled"); + }); + } else { + deferred.reject("Could not find InAppBrowser plugin"); + } + } else { + deferred.reject("Cannot authenticate via a web browser"); + } + return deferred.promise; + }, + + /* + * Sign into the Foursquare service + * + * @param string clientId + * @return promise + */ + foursquare: function (clientId) { + var deferred = $q.defer(); + if (window.cordova) { + var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; + if (cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { + var browserRef = window.open('https://foursquare.com/oauth2/authenticate?client_id=' + clientId + '&redirect_uri=http://localhost/callback&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); + browserRef.addEventListener('loadstart', function (event) { + if ((event.url).indexOf("http://localhost/callback") === 0) { + var callbackResponse = (event.url).split("#")[1]; + var responseParameters = (callbackResponse).split("&"); + var parameterMap = []; + for (var i = 0; i < responseParameters.length; i++) { + parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1]; + } + if (parameterMap.access_token !== undefined && parameterMap.access_token !== null) { + var promiseResponse = { + access_token: parameterMap.access_token, + expires_in: parameterMap.expires_in + }; + deferred.resolve(promiseResponse); } else { - deferred.reject("Cannot authenticate via a web browser"); + deferred.reject("Problem authenticating"); } - return deferred.promise; - }, + setTimeout(function () { + browserRef.close(); + }, 10); + } + }); + browserRef.addEventListener('exit', function (event) { + deferred.reject("The sign in flow was canceled"); + }); + } else { + deferred.reject("Could not find InAppBrowser plugin"); + } + } else { + deferred.reject("Cannot authenticate via a web browser"); + } + return deferred.promise; + }, - /* - * Sign into the Vkontakte service - * - * @param string clientId - * @param array appScope (for example: "friends,wall,photos,messages") - * @return promise - */ - vkontakte: function(clientId, appScope) { - var deferred = $q.defer(); - if(window.cordova) { - var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; - if(cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { - var browserRef = window.open('https://oauth.vk.com/authorize?client_id=' + clientId + '&redirect_uri=http://oauth.vk.com/blank.html&response_type=token&scope=' + appScope.join(",") + '&display=touch&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); - browserRef.addEventListener('loadstart', function(event) { - var tmp = (event.url).split("#"); - if (tmp[0] == 'https://oauth.vk.com/blank.html' || tmp[0] == 'http://oauth.vk.com/blank.html') { - var callbackResponse = (event.url).split("#")[1]; - var responseParameters = (callbackResponse).split("&"); - var parameterMap = []; - for(var i = 0; i < responseParameters.length; i++) { - parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1]; - } - if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) { - deferred.resolve({ access_token: parameterMap.access_token, expires_in: parameterMap.expires_in, user_id: parameterMap.user_id }); - } else { - deferred.reject("Problem authenticating"); - } - setTimeout(function() { - browserRef.close(); - }, 10); - } - }); - browserRef.addEventListener('exit', function(event) { - deferred.reject("The sign in flow was canceled"); + /* + * Sign into the Magento service + * Note that this service requires jsSHA for generating HMAC-SHA1 Oauth 1.0 signatures + * + * @param string baseUrl + * @param string clientId + * @param string clientSecret + * @return promise + */ + magento: function (baseUrl, clientId, clientSecret) { + var deferred = $q.defer(); + if (window.cordova) { + var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; + if (cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { + if (typeof jsSHA !== "undefined") { + var oauthObject = { + oauth_callback: "http://localhost/callback", + oauth_consumer_key: clientId, + oauth_nonce: $cordovaOauthUtility.createNonce(5), + oauth_signature_method: "HMAC-SHA1", + oauth_timestamp: Math.round((new Date()).getTime() / 1000.0), + oauth_version: "1.0" + }; + var signatureObj = $cordovaOauthUtility.createSignature("POST", baseUrl + "/oauth/initiate", oauthObject, {oauth_callback: "http://localhost/callback"}, clientSecret); + $http.defaults.headers.post.Authorization = signatureObj.authorization_header; + $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; + $http({method: "post", url: baseUrl + "/oauth/initiate", data: "oauth_callback=http://localhost/callback"}) + .success(function (requestTokenResult) { + var requestTokenParameters = (requestTokenResult).split("&"); + var parameterMap = {}; + for (var i = 0; i < requestTokenParameters.length; i++) { + parameterMap[requestTokenParameters[i].split("=")[0]] = requestTokenParameters[i].split("=")[1]; + } + if (parameterMap.hasOwnProperty("oauth_token") === false) { + deferred.reject("Oauth request token was not received"); + } + var tokenSecret = parameterMap.oauth_token_secret; + var browserRef = window.open(baseUrl + '/oauth/authorize?oauth_token=' + parameterMap.oauth_token, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); + browserRef.addEventListener('loadstart', function (event) { + if ((event.url).indexOf("http://localhost/callback") === 0) { + var callbackResponse = (event.url).split("?")[1]; + var responseParameters = (callbackResponse).split("&"); + var parameterMap = {}; + for (var i = 0; i < responseParameters.length; i++) { + parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1]; + } + if (parameterMap.hasOwnProperty("oauth_verifier") === false) { + deferred.reject("Browser authentication failed to complete. No oauth_verifier was returned"); + } + delete oauthObject.oauth_signature; + delete oauthObject.oauth_callback; + oauthObject.oauth_token = parameterMap.oauth_token; + oauthObject.oauth_nonce = $cordovaOauthUtility.createNonce(5); + oauthObject.oauth_verifier = parameterMap.oauth_verifier; + var signatureObj = $cordovaOauthUtility.createSignature("POST", baseUrl + "/oauth/token", oauthObject, {}, clientSecret, tokenSecret); + $http.defaults.headers.post.Authorization = signatureObj.authorization_header; + $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; + $http({method: "post", url: baseUrl + "/oauth/token"}) + .success(function (result) { + var accessTokenParameters = result.split("&"); + var parameterMap = {}; + for (var i = 0; i < accessTokenParameters.length; i++) { + parameterMap[accessTokenParameters[i].split("=")[0]] = accessTokenParameters[i].split("=")[1]; + } + if (parameterMap.hasOwnProperty("oauth_token_secret") === false) { + deferred.reject("Oauth access token was not received"); + } + deferred.resolve(parameterMap); + }) + .error(function (error) { + deferred.reject(error); + }) + .finally(function () { + setTimeout(function () { + browserRef.close(); + }, 10); }); - } else { - deferred.reject("Could not find InAppBrowser plugin"); } + }); + browserRef.addEventListener('exit', function (event) { + deferred.reject("The sign in flow was canceled"); + }); + }) + .error(function (error) { + deferred.reject(error); + }); + } else { + deferred.reject("Missing jsSHA JavaScript library"); + } + } else { + deferred.reject("Could not find InAppBrowser plugin"); + } + } else { + deferred.reject("Cannot authenticate via a web browser"); + } + return deferred.promise; + }, + + /* + * Sign into the Vkontakte service + * + * @param string clientId + * @param array appScope (for example: "friends,wall,photos,messages") + * @return promise + */ + vkontakte: function (clientId, appScope) { + var deferred = $q.defer(); + if (window.cordova) { + var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; + if (cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { + var browserRef = window.open('https://oauth.vk.com/authorize?client_id=' + clientId + '&redirect_uri=http://oauth.vk.com/blank.html&response_type=token&scope=' + appScope.join(",") + '&display=touch&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); + browserRef.addEventListener('loadstart', function (event) { + var tmp = (event.url).split("#"); + if (tmp[0] == 'https://oauth.vk.com/blank.html' || tmp[0] == 'http://oauth.vk.com/blank.html') { + var callbackResponse = (event.url).split("#")[1]; + var responseParameters = (callbackResponse).split("&"); + var parameterMap = []; + for (var i = 0; i < responseParameters.length; i++) { + parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1]; + } + if (parameterMap.access_token !== undefined && parameterMap.access_token !== null) { + deferred.resolve({access_token: parameterMap.access_token, expires_in: parameterMap.expires_in, user_id: parameterMap.user_id}); } else { - deferred.reject("Cannot authenticate via a web browser"); + deferred.reject("Problem authenticating"); } - return deferred.promise; - }, + setTimeout(function () { + browserRef.close(); + }, 10); + } + }); + browserRef.addEventListener('exit', function (event) { + deferred.reject("The sign in flow was canceled"); + }); + } else { + deferred.reject("Could not find InAppBrowser plugin"); + } + } else { + deferred.reject("Cannot authenticate via a web browser"); + } + return deferred.promise; + }, - /* - * Sign into the Imgur service - * - * @param string clientId - * @return promise - */ - imgur: function(clientId) { - var deferred = $q.defer(); - if(window.cordova) { - var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; - if(cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { - var browserRef = window.open('https://api.imgur.com/oauth2/authorize?client_id=' + clientId + '&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); - browserRef.addEventListener('loadstart', function(event) { - if((event.url).indexOf("http://localhost/callback") === 0) { - browserRef.removeEventListener("exit",function(event){}); - browserRef.close(); - var callbackResponse = (event.url).split("#")[1]; - var responseParameters = (callbackResponse).split("&"); - var parameterMap = []; - for(var i = 0; i < responseParameters.length; i++) { - parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1]; - } - if(parameterMap.access_token !== undefined && parameterMap.access_token !== null) { - deferred.resolve({ access_token: parameterMap.access_token, expires_in: parameterMap.expires_in, account_username: parameterMap.account_username }); - } else { - deferred.reject("Problem authenticating"); - } - } - }); - browserRef.addEventListener('exit', function(event) { - deferred.reject("The sign in flow was canceled"); - }); - } else { - deferred.reject("Could not find InAppBrowser plugin"); - } + /* + * Sign into the Imgur service + * + * @param string clientId + * @return promise + */ + imgur: function (clientId) { + var deferred = $q.defer(); + if (window.cordova) { + var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; + if (cordovaMetadata.hasOwnProperty("org.apache.cordova.inappbrowser") === true) { + var browserRef = window.open('https://api.imgur.com/oauth2/authorize?client_id=' + clientId + '&response_type=token', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes'); + browserRef.addEventListener('loadstart', function (event) { + if ((event.url).indexOf("http://localhost/callback") === 0) { + browserRef.removeEventListener("exit", function (event) { + }); + browserRef.close(); + var callbackResponse = (event.url).split("#")[1]; + var responseParameters = (callbackResponse).split("&"); + var parameterMap = []; + for (var i = 0; i < responseParameters.length; i++) { + parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1]; + } + if (parameterMap.access_token !== undefined && parameterMap.access_token !== null) { + deferred.resolve({access_token: parameterMap.access_token, expires_in: parameterMap.expires_in, account_username: parameterMap.account_username}); } else { - deferred.reject("Cannot authenticate via a web browser"); + deferred.reject("Problem authenticating"); } - return deferred.promise; - } + } + }); + browserRef.addEventListener('exit', function (event) { + deferred.reject("The sign in flow was canceled"); + }); + } else { + deferred.reject("Could not find InAppBrowser plugin"); + } + } else { + deferred.reject("Cannot authenticate via a web browser"); + } + return deferred.promise; + } }; }]); @@ -5907,59 +6101,59 @@ angular.module("ngCordova.plugins.oauthUtility", []) * @param string secretKey * @return object */ - createSignature: function(method, endPoint, headerParameters, bodyParameters, secretKey, tokenSecret) { - if(typeof jsSHA !== "undefined") { - var headerAndBodyParameters = angular.copy(headerParameters); - var bodyParameterKeys = Object.keys(bodyParameters); - for(var i = 0; i < bodyParameterKeys.length; i++) { - headerAndBodyParameters[bodyParameterKeys[i]] = encodeURIComponent(bodyParameters[bodyParameterKeys[i]]); - } - var signatureBaseString = method + "&" + encodeURIComponent(endPoint) + "&"; - var headerAndBodyParameterKeys = (Object.keys(headerAndBodyParameters)).sort(); - for(i = 0; i < headerAndBodyParameterKeys.length; i++) { - if(i == headerAndBodyParameterKeys.length - 1) { - signatureBaseString += encodeURIComponent(headerAndBodyParameterKeys[i] + "=" + headerAndBodyParameters[headerAndBodyParameterKeys[i]]); - } else { - signatureBaseString += encodeURIComponent(headerAndBodyParameterKeys[i] + "=" + headerAndBodyParameters[headerAndBodyParameterKeys[i]] + "&"); - } - } - var oauthSignatureObject = new jsSHA(signatureBaseString, "TEXT"); - - var encodedTokenSecret = ''; - if (tokenSecret) { - encodedTokenSecret = encodeURIComponent(tokenSecret); - } - - headerParameters.oauth_signature = encodeURIComponent(oauthSignatureObject.getHMAC(encodeURIComponent(secretKey) + "&" + encodedTokenSecret, "TEXT", "SHA-1", "B64")); - var headerParameterKeys = Object.keys(headerParameters); - var authorizationHeader = 'OAuth '; - for(i = 0; i < headerParameterKeys.length; i++) { - if(i == headerParameterKeys.length - 1) { - authorizationHeader += headerParameterKeys[i] + '="' + headerParameters[headerParameterKeys[i]] + '"'; - } else { - authorizationHeader += headerParameterKeys[i] + '="' + headerParameters[headerParameterKeys[i]] + '",'; - } - } - return { signature_base_string: signatureBaseString, authorization_header: authorizationHeader, signature: headerParameters.oauth_signature }; - } else { - return "Missing jsSHA JavaScript library"; - } - }, + createSignature: function (method, endPoint, headerParameters, bodyParameters, secretKey, tokenSecret) { + if (typeof jsSHA !== "undefined") { + var headerAndBodyParameters = angular.copy(headerParameters); + var bodyParameterKeys = Object.keys(bodyParameters); + for (var i = 0; i < bodyParameterKeys.length; i++) { + headerAndBodyParameters[bodyParameterKeys[i]] = encodeURIComponent(bodyParameters[bodyParameterKeys[i]]); + } + var signatureBaseString = method + "&" + encodeURIComponent(endPoint) + "&"; + var headerAndBodyParameterKeys = (Object.keys(headerAndBodyParameters)).sort(); + for (i = 0; i < headerAndBodyParameterKeys.length; i++) { + if (i == headerAndBodyParameterKeys.length - 1) { + signatureBaseString += encodeURIComponent(headerAndBodyParameterKeys[i] + "=" + headerAndBodyParameters[headerAndBodyParameterKeys[i]]); + } else { + signatureBaseString += encodeURIComponent(headerAndBodyParameterKeys[i] + "=" + headerAndBodyParameters[headerAndBodyParameterKeys[i]] + "&"); + } + } + var oauthSignatureObject = new jsSHA(signatureBaseString, "TEXT"); + + var encodedTokenSecret = ''; + if (tokenSecret) { + encodedTokenSecret = encodeURIComponent(tokenSecret); + } + + headerParameters.oauth_signature = encodeURIComponent(oauthSignatureObject.getHMAC(encodeURIComponent(secretKey) + "&" + encodedTokenSecret, "TEXT", "SHA-1", "B64")); + var headerParameterKeys = Object.keys(headerParameters); + var authorizationHeader = 'OAuth '; + for (i = 0; i < headerParameterKeys.length; i++) { + if (i == headerParameterKeys.length - 1) { + authorizationHeader += headerParameterKeys[i] + '="' + headerParameters[headerParameterKeys[i]] + '"'; + } else { + authorizationHeader += headerParameterKeys[i] + '="' + headerParameters[headerParameterKeys[i]] + '",'; + } + } + return {signature_base_string: signatureBaseString, authorization_header: authorizationHeader, signature: headerParameters.oauth_signature}; + } else { + return "Missing jsSHA JavaScript library"; + } + }, - /* - * Create Random String Nonce - * - * @param integer length - * @return string - */ - createNonce: function(length) { + /* + * Create Random String Nonce + * + * @param integer length + * @return string + */ + createNonce: function (length) { var text = ""; var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - for(var i = 0; i < length; i++) { - text += possible.charAt(Math.floor(Math.random() * possible.length)); + for (var i = 0; i < length; i++) { + text += possible.charAt(Math.floor(Math.random() * possible.length)); } return text; - } + } }; @@ -6020,7 +6214,7 @@ angular.module('ngCordova.plugins.prefs', []) }; }]); -// install : cordova plugin add de.appplant.cordova.plugin.printer +// install : cordova plugin add https://github.com/katzer/cordova-plugin-printer.git // link : https://github.com/katzer/cordova-plugin-printer angular.module('ngCordova.plugins.printer', []) @@ -6048,7 +6242,7 @@ angular.module('ngCordova.plugins.printer', []) }; }]); -// install : cordova plugin add org.pbernasconi.progressindicator +// install : cordova plugin add https://github.com/pbernasconi/cordova-progressIndicator.git // link : http://pbernasconi.github.io/cordova-progressIndicator/ angular.module('ngCordova.plugins.progressIndicator', []) @@ -6056,7 +6250,7 @@ angular.module('ngCordova.plugins.progressIndicator', []) .factory('$cordovaProgress', ['$q', function ($q) { return { - show: function(_message) { + show: function (_message) { var message = _message || "Please wait..."; return ProgressIndicator.show(message); }, @@ -6156,7 +6350,7 @@ angular.module('ngCordova.plugins.push', []) var q = $q.defer(); var injector; if (config !== undefined && config.ecb === undefined) { - if (document.querySelector('[ng-app]') == null) { + if (document.querySelector('[ng-app]') === null) { injector = "document.body"; } else { @@ -6383,8 +6577,8 @@ angular.module('ngCordova.plugins.spinnerDialog', []) }]); -// install : cordova plugin add org.apache.cordova.splashscreen -// link : https://github.com/apache/cordova-plugin-splashscreen/blob/master/doc/index.md +// install : cordova plugin add cordova-plugin-splashscreen +// link : https://github.com/apache/cordova-plugin-splashscreen angular.module('ngCordova.plugins.splashscreen', []) @@ -6402,8 +6596,8 @@ angular.module('ngCordova.plugins.splashscreen', []) }]); -// install : cordova plugin add https://github.com/brodysoft/Cordova-SQLitePlugin.git -// link : https://github.com/brodysoft/Cordova-SQLitePlugin/blob/master/README.md +// install : cordova plugin add https://github.com/litehelpers/Cordova-sqlite-storage.git +// link : https://github.com/litehelpers/Cordova-sqlite-storage angular.module('ngCordova.plugins.sqlite', []) @@ -6493,8 +6687,8 @@ angular.module('ngCordova.plugins.sqlite', []) }; }]); -// install : cordova plugin add org.apache.cordova.statusbar -// link : https://github.com/apache/cordova-plugin-statusbar/ +// install : cordova plugin add cordova-plugin-statusbar +// link : https://github.com/apache/cordova-plugin-statusbar angular.module('ngCordova.plugins.statusbar', []) @@ -6505,6 +6699,13 @@ angular.module('ngCordova.plugins.statusbar', []) return StatusBar.overlaysWebView(!!bool); }, + STYLES: { + DEFAULT: 0, + LIGHT_CONTENT: 1, + BLACK_TRANSLUCENT: 2, + BLACK_OPAQUE: 3 + }, + style: function (style) { switch (style) { // Default @@ -6675,8 +6876,8 @@ angular.module('ngCordova.plugins.touchid', []) }; }]); -// install : cordova plugin add org.apache.cordova.vibration -// link : https://github.com/apache/cordova-plugin-vibration/blob/master/doc/index.md +// install : cordova plugin add cordova-plugin-vibration +// link : https://github.com/apache/cordova-plugin-vibration angular.module('ngCordova.plugins.vibration', []) |
