/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* JavaScript for SOGoContacts (mobile) */
(function() {
'use strict';
angular.module('SOGo.Common', []);
angular.module('SOGo.Contacts', ['ionic', 'SOGo.Common', 'SOGo.Contacts'])
.constant('sgSettings', {
'baseURL': ApplicationBaseURL
})
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
})
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('app', {
url: "/app",
abstract: true,
templateUrl: "menu.html",
controller: 'AppCtrl'
})
.state('app.addressbooks', {
url: "/addressbooks",
views: {
'menuContent': {
templateUrl: "addressbooks.html",
controller: 'AddressBooksCtrl'
}
}
})
.state('app.addressbook', {
url: "/addressbook/:addressbook_id",
views: {
'menuContent': {
templateUrl: "addressbook.html",
controller: 'AddressBookCtrl'
}
}
})
.state('app.contact', {
url: "/addressbook/:addressbook_id/:card_id",
views: {
'menuContent': {
templateUrl: "card.html",
controller: 'CardCtrl'
}
}
});
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/app/addressbooks');
})
// .directive('sgAddress', function() {
// return {
// restrict: 'A',
// replace: false,
// scope: { data: '=sgAddress' },
// controller: ['$scope', function($scope) {
// $scope.addressLines = function(data) {
// var lines = [];
// if (data.street) lines.push(data.street);
// if (data.street2) lines.push(data.street2);
// var locality_region = [];
// if (data.locality) locality_region.push(data.locality);
// if (data.region) locality_region.push(data.region);
// if (locality_region.length > 0) lines.push(locality_region.join(', '));
// if (data.country) lines.push(data.country);
// if (data.postalcode) lines.push(data.postalcode);
// return lines.join('
');
// };
// }],
// template: '