| 13542 |
anikendra |
1 |
// Ionic Starter App
|
|
|
2 |
|
|
|
3 |
// angular.module is a global place for creating, registering and retrieving Angular modules
|
|
|
4 |
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
|
|
|
5 |
// the 2nd parameter is an array of 'requires'
|
|
|
6 |
// 'starter.services' is found in services.js
|
|
|
7 |
// 'starter.controllers' is found in controllers.js
|
|
|
8 |
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'starter.filters', 'LocalStorageModule','ngResource'])
|
|
|
9 |
|
| 13563 |
anikendra |
10 |
.run(function($ionicPlatform,$rootScope,Clicks,localStorageService,RemAction,UserAction) {
|
|
|
11 |
$rootScope.likeProduct = function(id,obj){
|
|
|
12 |
if($rootScope.liked[id]){
|
|
|
13 |
console.log('already liked, so remove ilike');
|
|
|
14 |
RemAction.rem({user_id:localStorageService.get('me'),store_product_id:id,action:'like'});
|
|
|
15 |
$rootScope.liked[id] = null;
|
|
|
16 |
}else{
|
|
|
17 |
UserAction.like({user_id:localStorageService.get('me'),store_product_id:id,action:'like'});
|
|
|
18 |
$rootScope.liked[id] = 1;
|
|
|
19 |
$rootScope.disliked[id] = null;
|
|
|
20 |
}
|
| 13551 |
anikendra |
21 |
},
|
| 13563 |
anikendra |
22 |
$rootScope.unlikeProduct = function(id,obj){
|
|
|
23 |
if($rootScope.disliked[id]){
|
|
|
24 |
console.log('already disliked, so remove dislike');
|
|
|
25 |
RemAction.rem({user_id:localStorageService.get('me'), store_product_id:id,action:'dislike'});
|
|
|
26 |
$rootScope.disliked[id] = null;
|
|
|
27 |
}else{
|
|
|
28 |
UserAction.like({user_id:localStorageService.get('me'), store_product_id:id,action:'dislike'});
|
|
|
29 |
$rootScope.disliked[id] = 1;
|
|
|
30 |
$rootScope.liked[id] = null;
|
|
|
31 |
}
|
| 13551 |
anikendra |
32 |
}
|
|
|
33 |
$rootScope.viewproduct = function(id){
|
| 13560 |
anikendra |
34 |
Clicks.get({'me':localStorageService.get('me'), 'id':id},
|
|
|
35 |
function( result ) {
|
|
|
36 |
console.log(result);
|
|
|
37 |
if(result.success && result.type == 'redirect'){
|
|
|
38 |
document.location = result.url;
|
|
|
39 |
}
|
|
|
40 |
},
|
|
|
41 |
function( error ) {
|
|
|
42 |
console.log( "Something went wrong!" );
|
|
|
43 |
}
|
|
|
44 |
);
|
| 13551 |
anikendra |
45 |
}
|
|
|
46 |
$rootScope.chunk = function(arr, size) {
|
|
|
47 |
var newArr = [];
|
|
|
48 |
for (var i=0; i<arr.length; i+=size) {
|
|
|
49 |
newArr.push(arr.slice(i, i+size));
|
|
|
50 |
}
|
|
|
51 |
return newArr;
|
|
|
52 |
}
|
| 13542 |
anikendra |
53 |
$ionicPlatform.ready(function() {
|
|
|
54 |
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
|
|
|
55 |
// for form inputs)
|
|
|
56 |
if (window.cordova && window.cordova.plugins.Keyboard) {
|
|
|
57 |
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
|
|
|
58 |
}
|
|
|
59 |
if (window.StatusBar) {
|
|
|
60 |
// org.apache.cordova.statusbar required
|
|
|
61 |
StatusBar.styleDefault();
|
|
|
62 |
}
|
|
|
63 |
});
|
|
|
64 |
})
|
|
|
65 |
|
|
|
66 |
.config(function($stateProvider, $urlRouterProvider) {
|
|
|
67 |
|
|
|
68 |
// Ionic uses AngularUI Router which uses the concept of states
|
|
|
69 |
// Learn more here: https://github.com/angular-ui/ui-router
|
|
|
70 |
// Set up the various states which the app can be in.
|
|
|
71 |
// Each state's controller can be found in controllers.js
|
|
|
72 |
$stateProvider
|
|
|
73 |
|
|
|
74 |
// setup an abstract state for the tabs directive
|
|
|
75 |
.state('tab', {
|
|
|
76 |
url: "/tab",
|
|
|
77 |
abstract: true,
|
|
|
78 |
templateUrl: "templates/tabs.html"
|
|
|
79 |
})
|
|
|
80 |
|
|
|
81 |
// Each tab has its own nav history stack:
|
|
|
82 |
|
|
|
83 |
.state('tab.dash', {
|
|
|
84 |
url: '/dash',
|
|
|
85 |
views: {
|
|
|
86 |
'tab-dash': {
|
|
|
87 |
templateUrl: 'templates/tab-dash.html',
|
|
|
88 |
controller: 'DashCtrl'
|
|
|
89 |
}
|
|
|
90 |
}
|
|
|
91 |
})
|
|
|
92 |
|
|
|
93 |
.state('tab.chats', {
|
|
|
94 |
url: '/chats',
|
|
|
95 |
views: {
|
|
|
96 |
'tab-chats': {
|
|
|
97 |
templateUrl: 'templates/tab-chats.html',
|
|
|
98 |
controller: 'ChatsCtrl'
|
|
|
99 |
}
|
|
|
100 |
}
|
|
|
101 |
})
|
|
|
102 |
.state('tab.chat-detail', {
|
|
|
103 |
url: '/chats/:chatId',
|
|
|
104 |
views: {
|
|
|
105 |
'tab-chats': {
|
|
|
106 |
templateUrl: 'templates/chat-detail.html',
|
|
|
107 |
controller: 'ChatDetailCtrl'
|
|
|
108 |
}
|
|
|
109 |
}
|
|
|
110 |
})
|
|
|
111 |
|
|
|
112 |
.state('tab.friends', {
|
|
|
113 |
url: '/friends',
|
|
|
114 |
views: {
|
|
|
115 |
'tab-friends': {
|
|
|
116 |
templateUrl: 'templates/tab-friends.html',
|
|
|
117 |
controller: 'FriendsCtrl'
|
|
|
118 |
}
|
|
|
119 |
}
|
|
|
120 |
})
|
|
|
121 |
.state('tab.friend-detail', {
|
|
|
122 |
url: '/friend/:friendId',
|
|
|
123 |
views: {
|
|
|
124 |
'tab-friends': {
|
|
|
125 |
templateUrl: 'templates/friend-detail.html',
|
|
|
126 |
controller: 'FriendDetailCtrl'
|
|
|
127 |
}
|
|
|
128 |
}
|
|
|
129 |
})
|
|
|
130 |
|
|
|
131 |
.state('tab.login', {
|
|
|
132 |
url: '/login',
|
|
|
133 |
views: {
|
|
|
134 |
'tab-login': {
|
|
|
135 |
templateUrl: 'templates/tab-login.html',
|
|
|
136 |
controller: 'LoginCtrl'
|
|
|
137 |
}
|
|
|
138 |
}
|
|
|
139 |
})
|
|
|
140 |
|
|
|
141 |
.state('tab.account', {
|
|
|
142 |
url: '/account',
|
|
|
143 |
views: {
|
|
|
144 |
'tab-account': {
|
|
|
145 |
templateUrl: 'templates/tab-account.html',
|
|
|
146 |
controller: 'AccountCtrl'
|
|
|
147 |
}
|
|
|
148 |
}
|
|
|
149 |
});
|
|
|
150 |
|
|
|
151 |
// if none of the above states are matched, use this as the fallback
|
| 13557 |
anikendra |
152 |
$urlRouterProvider.otherwise('/tab/chats');
|
| 13542 |
anikendra |
153 |
|
|
|
154 |
});
|