diff --git a/demo/app/www/js/controllers.js b/demo/app/www/js/controllers.js index eb913bf3..a2a14e2f 100644 --- a/demo/app/www/js/controllers.js +++ b/demo/app/www/js/controllers.js @@ -8,7 +8,7 @@ angular.module('starter.controllers', []) $scope.plugins = [ { name: 'Camera', slug: 'camera' }, { name: 'Geolocation', slug: 'geolocation' }, - { name: 'Accelerometer', slug: 'accelerometer' } + { name: 'Device Motion', slug: 'device-motion' } ]; }) diff --git a/demo/app/www/templates/plugins/accelerometer.html b/demo/app/www/templates/plugins/device-motion.html similarity index 100% rename from demo/app/www/templates/plugins/accelerometer.html rename to demo/app/www/templates/plugins/device-motion.html diff --git a/dist/ng-cordova.js b/dist/ng-cordova.js index b4366509..a8e502dc 100644 --- a/dist/ng-cordova.js +++ b/dist/ng-cordova.js @@ -9,41 +9,6 @@ angular.module('ngCordova', [ 'ngCordova.plugins' ]); -angular.module('ngCordova.plugins.accelerometer', []) - -.factory('$cordovaAccelerometer', ['$q', function($q) { - - return { - getCurrentAcceleration: function() { - var q = $q.defer(); - - navigator.accelerometer.getCurrentAcceleration(function(result) { - // Do any magic you need - q.resolve(result); - }, function(err) { - q.reject(err); - }, options); - - return q.promise; - }, - watchAcceleration: function(options) { - var q = $q.defer(); - - navigator.accelerometer.watchAcceleration(function(result) { - // Do any magic you need - q.notify(result); - }, function(err) { - q.reject(err); - }, options); - - return q.promise; - }, - clearWatch: function(watchID) { - return navigator.accelerometer.clearWatch(watchID); - } - } -}]); - angular.module('ngCordova.plugins.barcodeScanner', []) .factory('$cordovaBarcodeScanner', ['$q', function ($q) { @@ -118,25 +83,6 @@ angular.module('ngCordova.plugins.camera', []) } }]); -angular.module('ngCordova.plugins.compass', []) - -.factory('$cordovaCompass', ['$q', function($q) { - - return { - watchHeading: function(options) { - var q = $q.defer(); - - navigator.compass.watchHeading(function(result) { - q.resolve(result); - }, function(err) { - q.reject(err); - }, options); - - return q.promise; - } - } -}]); - angular.module('ngCordova.plugins.contacts', []) .factory('Contacts', ['$q', function ($q) { @@ -246,6 +192,60 @@ angular.module('ngCordova.plugins.device', []) } }]); +angular.module('ngCordova.plugins.deviceMotion', []) + +.factory('$cordovaDeviceMotion', ['$q', function($q) { + + return { + getCurrentAcceleration: function() { + var q = $q.defer(); + + navigator.accelerometer.getCurrentAcceleration(function(result) { + // Do any magic you need + q.resolve(result); + }, function(err) { + q.reject(err); + }, options); + + return q.promise; + }, + watchAcceleration: function(options) { + var q = $q.defer(); + + navigator.accelerometer.watchAcceleration(function(result) { + // Do any magic you need + q.notify(result); + }, function(err) { + q.reject(err); + }, options); + + return q.promise; + }, + clearWatch: function(watchID) { + return navigator.accelerometer.clearWatch(watchID); + } + } +}]); + +angular.module('ngCordova.plugins.deviceOrientation', []) + +.factory('$cordovaDeviceOrientation', ['$q', function($q) { + + return { + watchHeading: function(options) { + var q = $q.defer(); + + navigator.compass.watchHeading(function(result) { + q.resolve(result); + }, function(err) { + q.reject(err); + }, options); + + return q.promise; + } + } +}]); + angular.module('ngCordova.plugins.geolocation', []) .factory('$cordovaGeolocation', ['$q', function($q) { @@ -309,10 +309,10 @@ angular.module('ngCordova.plugins.keyboard', []) }]); angular.module('ngCordova.plugins', [ - 'ngCordova.plugins.accelerometer', + 'ngCordova.plugins.deviceMotion', 'ngCordova.plugins.camera', 'ngCordova.plugins.geolocation', - 'ngCordova.plugins.compass', + 'ngCordova.plugins.deviceOrientation', 'ngCordova.plugins.notification', 'ngCordova.plugins.vibration', 'ngCordova.plugins.network', @@ -320,7 +320,8 @@ angular.module('ngCordova.plugins', [ 'ngCordova.plugins.barcodeScanner', 'ngCordova.plugins.splashscreen', 'ngCordova.plugins.keyboard', - 'ngCordova.plugins.contacts' + 'ngCordova.plugins.contacts', + 'ngCordova.plugins.statusbar' ]); angular.module('ngCordova.plugins.network', []) @@ -384,13 +385,70 @@ angular.module('ngCordova.plugins.splashscreen', []) }]); +angular.module('ngCordova.plugins.statusbar', []) + +.factory('$cordovaStatusbar', [function() { + + return { + overlaysWebView: function(bool) { + return StatusBar.overlaysWebView(true); + }, + + // styles: Default, LightContent, BlackTranslucent, BlackOpaque + style: function (style) { + switch (style) { + case 0: // Default + return StatusBar.styleDefault(); + break; + + case 1: // LightContent + return StatusBar.styleLightContent(); + break; + + case 2: // BlackTranslucent + return StatusBar.styleBlackTranslucent(); + break; + + case 3: // BlackOpaque + return StatusBar.styleBlackOpaque(); + break; + + default: // Default + return StatusBar.styleDefault(); + } + }, + + + // supported names: black, darkGray, lightGray, white, gray, red, green, blue, cyan, yellow, magenta, orange, purple, brown + styleColor: function (color) { + return StatusBar.backgroundColorByName(color); + }, + + styleHex: function (colorHex) { + return StatusBar.backgroundColorByHexString(colorHex); + }, + + hide: function () { + return StatusBar.hide(); + }, + + show: function () { + return StatusBar.show() + }, + + isVisible: function () { + return StatusBar.isVisible(); + } + } +}]); + angular.module('ngCordova.plugins.vibration', []) .factory('$cordovaVibration', [function() { return { vibrate: function(times) { - return navigator.notification.vibrate(time); + return navigator.notification.vibrate(times); } } }]); diff --git a/dist/ng-cordova.min.js b/dist/ng-cordova.min.js index 70306ece..b7877e5f 100644 --- a/dist/ng-cordova.min.js +++ b/dist/ng-cordova.min.js @@ -1 +1 @@ -!function(){angular.module("ngCordova",["ngCordova.plugins"]),angular.module("ngCordova.plugins.accelerometer",[]).factory("$cordovaAccelerometer",["$q",function(n){return{getCurrentAcceleration:function(){var o=n.defer();return navigator.accelerometer.getCurrentAcceleration(function(n){o.resolve(n)},function(n){o.reject(n)},options),o.promise},watchAcceleration:function(o){var r=n.defer();return navigator.accelerometer.watchAcceleration(function(n){r.notify(n)},function(n){r.reject(n)},o),r.promise},clearWatch:function(n){return navigator.accelerometer.clearWatch(n)}}}]),angular.module("ngCordova.plugins.barcodeScanner",[]).factory("$cordovaBarcodeScanner",["$q",function(n){return{scan:function(){var o=n.defer();return cordova.plugins.barcodeScanner.scan(function(n){o.resolve(n)},function(n){o.reject(n)},options),o.promise},encode:function(o,r){var e=n.defer();return cordova.plugins.barcodeScanner.encode(o,r,function(n){e.resolve(n)},function(n){e.reject(n)}),e.promise}}}]),angular.module("ngCordova.plugins.camera",[]).factory("$cordovaCamera",["$q",function(n){return{getPicture:function(o){var r=n.defer();return navigator.camera?(navigator.camera.getPicture(function(n){r.resolve(n)},function(n){r.reject(n)},o),r.promise):(r.resolve(null),r.promise)},cleanup:function(){var o=n.defer();return navigator.camera.cleanup(function(){o.resolve(arguments)},function(n){o.reject(n)}),o.promise}}}]),angular.module("ngCordova.plugins.compass",[]).factory("$cordovaCompass",["$q",function(n){return{watchHeading:function(o){var r=n.defer();return navigator.compass.watchHeading(function(n){r.resolve(n)},function(n){r.reject(n)},o),r.promise}}}]),angular.module("ngCordova.plugins.contacts",[]).factory("Contacts",["$q",function(n){return{save:function(o){var r=n.defer(),e=navigator.contacts.create(o);return e.save(function(n){r.resolve(n)},function(n){r.reject(n)}),r.promise},remove:function(o){var r=n.defer(),e=navigator.contacts.create(o);return e.remove(function(n){r.resolve(n)},function(n){r.reject(n)}),r.promise},clone:function(n){var o=navigator.contacts.create(n);return o.clone(n)},find:function(o){var r=n.defer(),e=o.fields||["id","displayName"];return delete o.fields,navigator.contacts.find(e,function(n){r.resolve(n)},function(n){r.reject(n)},o),r.promise}}}]),angular.module("ngCordova.plugins.device",[]).factory("$cordovaDevice",[function(){return{getDevice:function(){return device},getCordova:function(){return device.cordova},getModel:function(){return device.model},getName:function(){return device.name},getPlatform:function(){return device.platform},getUUID:function(){return device.uuid},getVersion:function(){return device.version}}}]),angular.module("ngCordova.plugins.geolocation",[]).factory("$cordovaGeolocation",["$q",function(n){return{getCurrentPosition:function(o){var r=n.defer();return navigator.geolocation.getCurrentPosition(function(n){r.resolve(n)},function(n){r.reject(n)},o),r.promise},watchPosition:function(o){var r=n.defer();return navigator.geolocation.watchPosition(function(n){r.notify(n)},function(n){r.reject(n)},o),r.promise},clearWatch:function(n){return navigator.geolocation.clearWatch(n)}}}]),angular.module("ngCordova.plugins.keyboard",[]).factory("$cordovaKeyboard",[function(){return{hideAccessoryBar:function(n){return cordova.plugins.Keyboard.hideKeyboardAccessoryBar(n)},close:function(){return cordova.plugins.Keyboard.close()},disableScroll:function(n){return cordova.plugins.Keyboard.disableScroll(n)},isVisible:function(){return cordova.plugins.Keyboard.isVisible}}}]),angular.module("ngCordova.plugins",["ngCordova.plugins.accelerometer","ngCordova.plugins.camera","ngCordova.plugins.geolocation","ngCordova.plugins.compass","ngCordova.plugins.notification","ngCordova.plugins.vibration","ngCordova.plugins.network","ngCordova.plugins.device","ngCordova.plugins.barcodeScanner","ngCordova.plugins.splashscreen","ngCordova.plugins.keyboard","ngCordova.plugins.contacts"]),angular.module("ngCordova.plugins.network",[]).factory("$cordovaNetwork",[function(){return{getNetwork:function(){return navigator.connection.type},isOnline:function(){var n=navigator.connection.type;return n!=Connection.UNKNOWN},isOffline:function(){var n=navigator.connection.type;return n==Connection.UNKNOWN}}}]),angular.module("ngCordova.plugins.notification",[]).factory("$cordovaNotification",[function(){return{alert:function(){return navigator.notification.alert.apply(navigator.notification,arguments)},confirm:function(){return navigator.notification.confirm.apply(navigator.notification,arguments)},prompt:function(){return navigator.notification.prompt.apply(navigator.notification,arguments)},beep:function(n){return navigator.notification.beep(n)}}}]),angular.module("ngCordova.plugins.splashscreen",[]).factory("$cordovaSplashscreen",[function(){return{hide:function(){return navigator.splashscreen.hide()},show:function(){return navigator.splashscreen.show()}}}]),angular.module("ngCordova.plugins.vibration",[]).factory("$cordovaVibration",[function(){return{vibrate:function(){return navigator.notification.vibrate(time)}}}])}(); \ No newline at end of file +!function(){angular.module("ngCordova",["ngCordova.plugins"]),angular.module("ngCordova.plugins.barcodeScanner",[]).factory("$cordovaBarcodeScanner",["$q",function(n){return{scan:function(){var o=n.defer();return cordova.plugins.barcodeScanner.scan(function(n){o.resolve(n)},function(n){o.reject(n)},options),o.promise},encode:function(o,r){var e=n.defer();return cordova.plugins.barcodeScanner.encode(o,r,function(n){e.resolve(n)},function(n){e.reject(n)}),e.promise}}}]),angular.module("ngCordova.plugins.camera",[]).factory("$cordovaCamera",["$q",function(n){return{getPicture:function(o){var r=n.defer();return navigator.camera?(navigator.camera.getPicture(function(n){r.resolve(n)},function(n){r.reject(n)},o),r.promise):(r.resolve(null),r.promise)},cleanup:function(){var o=n.defer();return navigator.camera.cleanup(function(){o.resolve(arguments)},function(n){o.reject(n)}),o.promise}}}]),angular.module("ngCordova.plugins.contacts",[]).factory("Contacts",["$q",function(n){return{save:function(o){var r=n.defer(),e=navigator.contacts.create(o);return e.save(function(n){r.resolve(n)},function(n){r.reject(n)}),r.promise},remove:function(o){var r=n.defer(),e=navigator.contacts.create(o);return e.remove(function(n){r.resolve(n)},function(n){r.reject(n)}),r.promise},clone:function(n){var o=navigator.contacts.create(n);return o.clone(n)},find:function(o){var r=n.defer(),e=o.fields||["id","displayName"];return delete o.fields,navigator.contacts.find(e,function(n){r.resolve(n)},function(n){r.reject(n)},o),r.promise}}}]),angular.module("ngCordova.plugins.device",[]).factory("$cordovaDevice",[function(){return{getDevice:function(){return device},getCordova:function(){return device.cordova},getModel:function(){return device.model},getName:function(){return device.name},getPlatform:function(){return device.platform},getUUID:function(){return device.uuid},getVersion:function(){return device.version}}}]),angular.module("ngCordova.plugins.deviceMotion",[]).factory("$cordovaDeviceMotion",["$q",function(n){return{getCurrentAcceleration:function(){var o=n.defer();return navigator.accelerometer.getCurrentAcceleration(function(n){o.resolve(n)},function(n){o.reject(n)},options),o.promise},watchAcceleration:function(o){var r=n.defer();return navigator.accelerometer.watchAcceleration(function(n){r.notify(n)},function(n){r.reject(n)},o),r.promise},clearWatch:function(n){return navigator.accelerometer.clearWatch(n)}}}]),angular.module("ngCordova.plugins.deviceOrientation",[]).factory("$cordovaDeviceOrientation",["$q",function(n){return{watchHeading:function(o){var r=n.defer();return navigator.compass.watchHeading(function(n){r.resolve(n)},function(n){r.reject(n)},o),r.promise}}}]),angular.module("ngCordova.plugins.geolocation",[]).factory("$cordovaGeolocation",["$q",function(n){return{getCurrentPosition:function(o){var r=n.defer();return navigator.geolocation.getCurrentPosition(function(n){r.resolve(n)},function(n){r.reject(n)},o),r.promise},watchPosition:function(o){var r=n.defer();return navigator.geolocation.watchPosition(function(n){r.notify(n)},function(n){r.reject(n)},o),r.promise},clearWatch:function(n){return navigator.geolocation.clearWatch(n)}}}]),angular.module("ngCordova.plugins.keyboard",[]).factory("$cordovaKeyboard",[function(){return{hideAccessoryBar:function(n){return cordova.plugins.Keyboard.hideKeyboardAccessoryBar(n)},close:function(){return cordova.plugins.Keyboard.close()},disableScroll:function(n){return cordova.plugins.Keyboard.disableScroll(n)},isVisible:function(){return cordova.plugins.Keyboard.isVisible}}}]),angular.module("ngCordova.plugins",["ngCordova.plugins.deviceMotion","ngCordova.plugins.camera","ngCordova.plugins.geolocation","ngCordova.plugins.deviceOrientation","ngCordova.plugins.notification","ngCordova.plugins.vibration","ngCordova.plugins.network","ngCordova.plugins.device","ngCordova.plugins.barcodeScanner","ngCordova.plugins.splashscreen","ngCordova.plugins.keyboard","ngCordova.plugins.contacts","ngCordova.plugins.statusbar"]),angular.module("ngCordova.plugins.network",[]).factory("$cordovaNetwork",[function(){return{getNetwork:function(){return navigator.connection.type},isOnline:function(){var n=navigator.connection.type;return n!=Connection.UNKNOWN},isOffline:function(){var n=navigator.connection.type;return n==Connection.UNKNOWN}}}]),angular.module("ngCordova.plugins.notification",[]).factory("$cordovaNotification",[function(){return{alert:function(){return navigator.notification.alert.apply(navigator.notification,arguments)},confirm:function(){return navigator.notification.confirm.apply(navigator.notification,arguments)},prompt:function(){return navigator.notification.prompt.apply(navigator.notification,arguments)},beep:function(n){return navigator.notification.beep(n)}}}]),angular.module("ngCordova.plugins.splashscreen",[]).factory("$cordovaSplashscreen",[function(){return{hide:function(){return navigator.splashscreen.hide()},show:function(){return navigator.splashscreen.show()}}}]),angular.module("ngCordova.plugins.statusbar",[]).factory("$cordovaStatusbar",[function(){return{overlaysWebView:function(){return StatusBar.overlaysWebView(!0)},style:function(n){switch(n){case 0:return StatusBar.styleDefault();case 1:return StatusBar.styleLightContent();case 2:return StatusBar.styleBlackTranslucent();case 3:return StatusBar.styleBlackOpaque();default:return StatusBar.styleDefault()}},styleColor:function(n){return StatusBar.backgroundColorByName(n)},styleHex:function(n){return StatusBar.backgroundColorByHexString(n)},hide:function(){return StatusBar.hide()},show:function(){return StatusBar.show()},isVisible:function(){return StatusBar.isVisible()}}}]),angular.module("ngCordova.plugins.vibration",[]).factory("$cordovaVibration",[function(){return{vibrate:function(n){return navigator.notification.vibrate(n)}}}])}(); \ No newline at end of file diff --git a/src/plugins/deviceMotion.js b/src/plugins/deviceMotion.js index 98bd047a..6c6b997a 100644 --- a/src/plugins/deviceMotion.js +++ b/src/plugins/deviceMotion.js @@ -1,6 +1,6 @@ angular.module('ngCordova.plugins.deviceMotion', []) -.factory('$cordovadeviceMotion', ['$q', function($q) { +.factory('$cordovaDeviceMotion', ['$q', function($q) { return { getCurrentAcceleration: function() {