1 | "use strict";
|
2 | var di_1 = require('./di');
|
3 | var events_1 = require('./events');
|
4 | var promise_1 = require('./promise');
|
5 |
|
6 |
|
7 |
|
8 | function bootstrapAngular1() {
|
9 | if (typeof angular === 'undefined') {
|
10 | return;
|
11 | }
|
12 | var container = new di_1.Container();
|
13 | angular.element(document).ready(function () {
|
14 | container.core.init();
|
15 | container.cordova.bootstrap();
|
16 | });
|
17 | angular.module('ionic.cloud', [])
|
18 | .provider('$ionicCloudConfig', function () {
|
19 | var config = container.config;
|
20 | this.register = function (settings) {
|
21 | config.register(settings);
|
22 | };
|
23 | this.$get = function () {
|
24 | return config;
|
25 | };
|
26 | })
|
27 | .provider('$ionicCloud', ['$ionicCloudConfigProvider', function ($ionicCloudConfigProvider) {
|
28 | this.init = function (value) {
|
29 | $ionicCloudConfigProvider.register(value);
|
30 | };
|
31 | this.$get = [function () {
|
32 | return container.core;
|
33 | }];
|
34 | }])
|
35 | .factory('$ionicCloudClient', [function () {
|
36 | return container.client;
|
37 | }])
|
38 | .factory('$ionicUser', [function () {
|
39 | return container.singleUserService.current();
|
40 | }])
|
41 | .factory('$ionicAuth', [function () {
|
42 | return container.auth;
|
43 | }])
|
44 | .factory('$FacebookAuth', [function () {
|
45 | return container.facebookAuth;
|
46 | }])
|
47 | .factory('$GoogleAuth', [function () {
|
48 | return container.googleAuth;
|
49 | }])
|
50 | .factory('$ionicPush', [function () {
|
51 | return container.push;
|
52 | }])
|
53 | .factory('$ionicDeploy', [function () {
|
54 | return container.deploy;
|
55 | }])
|
56 | .run(['$window', '$q', '$rootScope', function ($window, $q, $rootScope) {
|
57 | if (typeof $window.Promise === 'undefined') {
|
58 | $window.Promise = $q;
|
59 | }
|
60 | else {
|
61 | var init = promise_1.DeferredPromise.prototype.init;
|
62 | promise_1.DeferredPromise.prototype.init = function () {
|
63 | init.apply(this, arguments);
|
64 | this.promise = $q.when(this.promise);
|
65 | };
|
66 | }
|
67 | var emit = events_1.EventEmitter.prototype.emit;
|
68 | events_1.EventEmitter.prototype.emit = function (name, data) {
|
69 | $rootScope.$broadcast('cloud:' + name, data);
|
70 | return emit.apply(this, arguments);
|
71 | };
|
72 | }]);
|
73 | }
|
74 | exports.bootstrapAngular1 = bootstrapAngular1;
|
75 |
|
\ | No newline at end of file |