-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyApp.js
168 lines (155 loc) · 4.28 KB
/
myApp.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
var app = angular.module("myApp", ["ngMaterial"]);
app.controller("toDoList", function ($scope) {
$scope.toDoList = ["Create a company", "Call in barber shop", "Earn a lot of money", "Go to the shop", "Buy gifts", "Brush teeth"];
// добавляет элемент в список
$scope.addItem = function () {
// выдать ошибку если элемент дуплекат
$scope.errortext = "";
if (!$scope.addMe) {
return;
}
if ($scope.toDoList.indexOf($scope.addMe) == -1) {
$scope.toDoList.push($scope.addMe);
} else {
$scope.errortext = "Already in your list.";
}
}
// удаляет элемент из списка
$scope.removeItem = function (item) {
$scope.errortext = "";
$scope.toDoList.splice(item, 1);
}
});
app.controller('AppCtrl', function ($scope, $timeout, $mdSidenav, $log) {
$scope.toggleLeft = buildDelayedToggler('left');
$scope.toggleRight = buildToggler('right');
//$scope.toggleRight = buildToggler('newTask');
$scope.isOpenRight = function () {
return $mdSidenav('right').isOpen();
};
// User photo and name
var imagePath = 'img/userPhoto.jpg';
$scope.messages = [{
face: imagePath,
name: 'Trevor Reyes'
}];
/**
* Supplies a function that will continue to operate until the
* time is up.
*/
function debounce(func, wait, context) {
var timer;
return function debounced() {
var context = $scope,
args = Array.prototype.slice.call(arguments);
$timeout.cancel(timer);
timer = $timeout(function () {
timer = undefined;
func.apply(context, args);
}, wait || 10);
};
}
/**
* Build handler to open/close a SideNav; when animation finishes
* report completion in console
*/
function buildDelayedToggler(navID) {
return debounce(function () {
// Component lookup should always be available since we are not using `ng-if`
$mdSidenav(navID)
.toggle()
.then(function () {
$log.debug("toggle " + navID + " is done");
});
}, 200);
}
function buildToggler(navID) {
return function () {
// Component lookup should always be available since we are not using `ng-if`
$mdSidenav(navID)
.toggle()
.then(function () {
$log.debug("toggle " + navID + " is done");
});
};
}
});
app.controller('LeftCtrl', function ($scope, $timeout, $mdSidenav, $log) {
$scope.close = function () {
// Component lookup should always be available since we are not using `ng-if`
$mdSidenav('left').close()
.then(function () {
$log.debug("close LEFT is done");
});
};
});
app.controller('RightCtrl', function ($scope, $timeout, $mdSidenav, $log) {
$scope.close = function () {
// Component lookup should always be available since we are not using `ng-if`
$mdSidenav('right').close()
.then(function () {
$log.debug("close RIGHT is done");
});
};
});
/*
app.controller('NewTaskCtrl', function ($scope, $timeout, $mdSidenav, $log) {
$scope.close = function () {
// Component lookup should always be available since we are not using `ng-if`
$mdSidenav('newTask').close()
.then(function () {
$log.debug("close New Task Sidebar is done");
});
};
});
*/
// Configuring theme if needed
app.config(function ($mdThemingProvider) {
// Configure a dark theme
$mdThemingProvider.theme('myTheme', 'default')
.primaryPalette('grey')
.dark();
});
app.controller('menuController', function menuController ($scope, $mdDialog) {
var originatorEv;
this.openMenu = function($mdOpenMenu, ev) {
originatorEv = ev;
$mdOpenMenu(ev);
};
this.menuItemClick = function(index) {
$mdDialog.show(
$mdDialog.alert()
.title('Hello')
.textContent('Menu Item clicked, index: ' + index)
.ok('OK')
.targetEvent(originatorEv)
);
originatorEv = null;
};
});
app.controller('taskCtrl', function ($scope){
$scope.date = new Date();
var self = this;
self.tasks = [{
'id': 1,
'taskName': 'Create a company',
'Date': 'Today',
'taskContent': 'Bla Bla 12345'
}, {
'id': 2,
'taskName': 'Call in barber shop',
'Date': 'Tomorrow',
'taskContent': 'Bla Bla 12345'
}, {
'id': 3,
'taskName': 'Earn a lot of money',
'Date': 'Friday (09.06.2016)',
'taskContent': 'Bla Bla 12345'
}, {
'id': 4,
'taskName': 'Go to the shop',
'Date': 'Friday (09.06.2016)',
'taskContent': 'Bla Bla 12345'
}];
self.selectedId = 2;
});