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