Subversion Repositories SmartDukaan

Rev

Rev 13557 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
 
13560 anikendra 10
.run(function($ionicPlatform,$rootScope,Clicks,localStorageService) {
13551 anikendra 11
  $rootScope.likeProduct = function(id){
13560 anikendra 12
    // alert('like '+id);
13
    // $scope.click = Clicks.get({'me':localStorageService.get('me'),'id':id});    
13551 anikendra 14
  },
15
  $rootScope.unlikeProduct = function(id){
16
    alert('unlike '+id);
17
    console.log(id);
18
  }
19
  $rootScope.viewproduct = function(id){
13560 anikendra 20
    Clicks.get({'me':localStorageService.get('me'), 'id':id},  
21
      function( result ) {          
22
        console.log(result);
23
        if(result.success && result.type == 'redirect'){
24
          document.location = result.url;
25
        }
26
      },
27
      function( error ) {
28
        console.log( "Something went wrong!" );
29
      }
30
    );
13551 anikendra 31
  } 
32
  $rootScope.chunk = function(arr, size) {
33
    var newArr = [];
34
    for (var i=0; i<arr.length; i+=size) {
35
      newArr.push(arr.slice(i, i+size));
36
    }
37
    return newArr;
38
  } 
13542 anikendra 39
  $ionicPlatform.ready(function() {
40
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
41
    // for form inputs)
42
    if (window.cordova && window.cordova.plugins.Keyboard) {
43
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
44
    }
45
    if (window.StatusBar) {
46
      // org.apache.cordova.statusbar required
47
      StatusBar.styleDefault();
48
    }
49
  });
50
})
51
 
52
.config(function($stateProvider, $urlRouterProvider) {
53
 
54
  // Ionic uses AngularUI Router which uses the concept of states
55
  // Learn more here: https://github.com/angular-ui/ui-router
56
  // Set up the various states which the app can be in.
57
  // Each state's controller can be found in controllers.js
58
  $stateProvider
59
 
60
  // setup an abstract state for the tabs directive
61
  .state('tab', {
62
    url: "/tab",
63
    abstract: true,
64
    templateUrl: "templates/tabs.html"
65
  })
66
 
67
  // Each tab has its own nav history stack:
68
 
69
  .state('tab.dash', {
70
    url: '/dash',
71
    views: {
72
      'tab-dash': {
73
        templateUrl: 'templates/tab-dash.html',
74
        controller: 'DashCtrl'
75
      }
76
    }
77
  })
78
 
79
  .state('tab.chats', {
80
      url: '/chats',
81
      views: {
82
        'tab-chats': {
83
          templateUrl: 'templates/tab-chats.html',
84
          controller: 'ChatsCtrl'
85
        }
86
      }
87
    })
88
    .state('tab.chat-detail', {
89
      url: '/chats/:chatId',
90
      views: {
91
        'tab-chats': {
92
          templateUrl: 'templates/chat-detail.html',
93
          controller: 'ChatDetailCtrl'
94
        }
95
      }
96
    })
97
 
98
  .state('tab.friends', {
99
      url: '/friends',
100
      views: {
101
        'tab-friends': {
102
          templateUrl: 'templates/tab-friends.html',
103
          controller: 'FriendsCtrl'
104
        }
105
      }
106
    })
107
    .state('tab.friend-detail', {
108
      url: '/friend/:friendId',
109
      views: {
110
        'tab-friends': {
111
          templateUrl: 'templates/friend-detail.html',
112
          controller: 'FriendDetailCtrl'
113
        }
114
      }
115
    })
116
 
117
  .state('tab.login', {
118
    url: '/login',
119
    views: {
120
      'tab-login': {
121
        templateUrl: 'templates/tab-login.html',
122
        controller: 'LoginCtrl'
123
      }
124
    }
125
  })
126
 
127
  .state('tab.account', {
128
    url: '/account',
129
    views: {
130
      'tab-account': {
131
        templateUrl: 'templates/tab-account.html',
132
        controller: 'AccountCtrl'
133
      }
134
    }
135
  });
136
 
137
  // if none of the above states are matched, use this as the fallback
13557 anikendra 138
  $urlRouterProvider.otherwise('/tab/chats');
13542 anikendra 139
 
140
});