forked from tapitoo/mobile-store
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
145 lines (127 loc) · 4.76 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
'use strict';
(function () {
var app = angular.module('TapitooPortal', ['ionic',
'app.routes',
'app.config',
'Tapitoo.StartUpService',
'Tapitoo.ShopService',
'Tapitoo.ProductService',
'Tapitoo.CartService',
'Tapitoo.CheckoutService',
'Tapitoo.CheckoutProcessService',
'Tapitoo.AccountService',
'Tapitoo.CommonService',
'Tapitoo.HomeViewController',
'Tapitoo.ManufacturersController',
'Tapitoo.WishlistCtrl',
'CategoriesCtrl',
'ProductsCtrl',
'ProductsDetailsCtrl',
'ProductsReviewsCtrl',
'CartCtrl',
'CheckoutCtrl',
'UserAccountCtrl',
'DeliveryDetailsCtrl',
'PaymentDetailsCtrl',
'AddressesCtrl',
'PersonalInfoCtrl',
'SettingsCtrl',
'GeocoderService',
'ngStorage',
'ngCordova',
'horizontalScroll',
'starRating',
'tabSlideBox',
'ionic.ion.imageCacheFactory',
'ionic-datepicker',
'ionic-timepicker',
'ionic-toast',
'angularPayments',
'pascalprecht.translate']);
app.run(function (StartUpService,$ionicPlatform,$rootScope,$localStorage, $http, OC_CONFIG, $state,$stateParams, $urlRouter) {
// $localStorage.ACCESS_TOKEN= 'X68AWVTSMNblJki5OzcSnYLtw3HxPWdgyGevyiE4';
$ionicPlatform.ready(function () {
// hide iOS status bar
if(window.StatusBar) {
StatusBar.hide();
ionic.Platform.fullScreen();
}
//set access token if it's not the first time the app is open
if($localStorage.ACCESS_TOKEN){
//console.log($localStorage.ACCESS_TOKEN);
OC_CONFIG.TOKEN = $localStorage.ACCESS_TOKEN;
console.log(OC_CONFIG.TOKEN);
StartUpService.initialization();
}
// generate access token if the app is opened for the first time
else {
var promise = StartUpService.generateToken();
promise.then(
function (response) {
StartUpService.initialization();
});
}
});
$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;
$rootScope.$on("$stateChangeSuccess", function(event, toState, toParams, fromState, fromParams) {
// to be used for back button //won't work when page is reloaded.
// console.log(toState.name);
// console.log(toParams);
// console.log(fromState.name);
// console.log(fromParams);
if(toState.name === 'leftdrawer.productInfo' && fromState.name !== 'productDescription' && fromState.name !== 'productSpecifications' && fromState.name !== 'productReviews'){
$rootScope.stateBeforeProduct_name = fromState.name;
$rootScope.stateBeforeProduct_params = fromParams;
console.log("state: " + $rootScope.stateBeforeProduct_name);
}
$rootScope.previousState_name = fromState.name;
$rootScope.previousState_params = fromParams;
});
//back button function called from back button's ng-click="back()"
$rootScope.back = function() {
$state.go($rootScope.stateBeforeProduct_name,$rootScope.stateBeforeProduct_params);
};
});
app.config(function ($httpProvider, $stateProvider, $urlRouterProvider, $translateProvider, $ionicConfigProvider, $localStorageProvider) {
// disable views transition animation on android
if(ionic.Platform.isAndroid()===true){
$ionicConfigProvider.views.transition('none');
}
else
$ionicConfigProvider.views.transition('ios');
// center Header Logo
$ionicConfigProvider.navBar.alignTitle('center')
// disable swipe back on iOS
$ionicConfigProvider.views.swipeBackEnabled(false);
// configures staticFilesLoader
$translateProvider.useStaticFilesLoader({
prefix: 'languages/translate-',
suffix: '.json'
});
// load 'en' table on startup
$translateProvider.preferredLanguage('en');
});
app.controller('AppInitController', function ($scope, $rootScope,$ionicLoading, $state,ShopService, $ionicScrollDelegate, $timeout, $ionicSideMenuDelegate) {
$scope.toggleDrawer = function () {
$ionicSideMenuDelegate.toggleLeft();
};
$rootScope.noShadow = "header-shadow";
// show loading template after 100ms
$scope.$on('$stateChangeStart',
function(event, toState, toParams, fromState, fromParams){
$timeout(function(){
$ionicLoading.show({templateUrl: 'templates/loading.html', noBackdrop: false});
},100);
});
// hide loading template after 200ms
$scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {
$timeout(function(){
$ionicLoading.hide()
},200);
});
});
})();
angular.element(document).ready(function () {
angular.bootstrap(document, ['TapitooPortal']);
});