-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.controller.js
72 lines (60 loc) · 2.19 KB
/
app.controller.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
angular.module('app')
.controller('mainCtrl', function ($scope, $modal, $log, $rootScope, router, localStorageService, customFolders) {
var folders = localStorageService.get('localFolders');
var newStates = {};
$scope.allFolders = [];
$rootScope.data = {
theme: ''
};
if (localStorageService.isSupported) {
$rootScope.data.theme = localStorageService.get('theme');
if ($rootScope.data.theme === null) {
$rootScope.data.theme = 'bootstrap';
}
}
else {
$scope.theme = 'bootstrap';
}
if (folders !== null) {
newStates = folders;
console.log(newStates);
for (var name in folders) {
$scope.allFolders.push(name);
console.log('add new state! ' + name);
}
}
$scope.reload = function (collection) {
router.setRoutes(collection);
};
$scope.addNewFolder = function () {
var modalInstance = $modal.open({
templateUrl: 'modalContent.html',
controller: 'ModalInstanceCtrl'
});
modalInstance.result.then(function (folder) {
$scope.folder = folder;
$scope.allFolders.push($scope.folder);
newStates[$scope.folder] = {
"url": "/inbox/" + $scope.folder,
"templateUrl": "modules/inbox/customFolder.html"
};
$scope.reload(newStates);
localStorageService.add('localFolders', newStates);
}, function () {
$log.info('Modal dismissed');
});
};
$scope.$on('factoryCustomFolder',function(event,args){
var id = args.id;
var folderName = args.folder;
customFolders.addFolders(id, folderName);
});
})
.controller('ModalInstanceCtrl', function($scope, $modalInstance) {
$scope.ok = function (name) {
$modalInstance.close(name);
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
});