-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtodo.js
92 lines (81 loc) · 2.27 KB
/
todo.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
var app = angular.module("todo", ['ionic','todo.services'])
app.controller("TodoCtrl", function($scope, $ionicModal, $ionicPopup, SQLService) {
SQLService.setup();
$scope.loadTask = function() {
SQLService.all().then(function (results) {
$scope.tasks = results;
});
}
$scope.loadTask();
function ContentController($scope, $ionicSideMenuDelegate) {
$scope.toggleLeft = function() {
$ionicSideMenuDelegate.toggleLeft();
};
}
// Create and load the Modal
$ionicModal.fromTemplateUrl('new-task.html', function(modal) {
$scope.taskModal = modal;
}, {
scope: $scope,
animation: 'slide-in-up'
});
$scope.about = function() {
var alertPopup = $ionicPopup.alert({
title: 'Follow me on Twitter && Github.',
template: '@Alephbreno | Alephmelo',
});
};
// Open our new task modal
$scope.newTask = function() {
$scope.taskModal.show();
};
// Close the new task modal
$scope.closeNewTask = function() {
$scope.taskModal.hide();
};
// Called when the form is submitted
$scope.createTask = function(task) {
SQLService.set(task.title);
$scope.loadTask();
$scope.taskModal.hide();
task.title = "";
};
$scope.onItemDelete = function(taskid) {
$ionicPopup.confirm({
title: 'Confirme Exclusão',
content: 'Você tem certeza que quer excluir?',
cancelText: 'Cancelar',
}).then(function(res) {
if(res) {
SQLService.del(taskid);
$scope.loadTask();
}
});
};
$scope.onItemEdit = function(taskid) {
$ionicPopup.prompt({
title: 'Atualizar Tarefa',
subTitle: 'Digite nova tarefa',
cancelText: 'Cancelar',
template:'<input ng-model="data.response" type="text" autofocus="true" placeholder="Atualizar tarefa">'
}).then(function(res) {
if(res) {
SQLService.edit(res, taskid);
$scope.loadTask();
} else {
$scope.loadTask();
}
});
};
$scope.moveItem = function(item, fromIndex, toIndex) {
$scope.items.splice(fromIndex, 1);
$scope.items.splice(toIndex, 0, item);
};
});
var searchCtrl = function($scope) {
$scope.searchText = "";
$scope.clearSearch = function () {
$scope.searchText = "";
$scope.loadTask();
};
};