diff --git a/todo-src/animations.css b/todo-src/animations.css new file mode 100644 index 0000000..c94e83f --- /dev/null +++ b/todo-src/animations.css @@ -0,0 +1,31 @@ +/* Sitch container for priority */ +.animate-switch-container { + position:relative; + background:white; + border:1px solid black; + height:40px; + overflow:hidden; +} + +.animate-switch { + padding:10px; +} + +.animate-switch.ng-animate { + transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s; + + position:absolute; + top:0; + left:0; + right:0; + bottom:0; +} + +.animate-switch.ng-leave.ng-leave-active, +.animate-switch.ng-enter { + top:-50px; +} +.animate-switch.ng-leave, +.animate-switch.ng-enter.ng-enter-active { + top:0; +} diff --git a/todo-src/index.html b/todo-src/index.html index 89203ad..870d555 100644 --- a/todo-src/index.html +++ b/todo-src/index.html @@ -6,39 +6,78 @@ + +

My little to do app!

-
- +
- + + +
- -

stuff i gotta do asap

- + +

{{todos.length}} stuff(s) i gotta do asap

+
- + diff --git a/todo-src/protractor.js b/todo-src/protractor.js new file mode 100644 index 0000000..719ebe0 --- /dev/null +++ b/todo-src/protractor.js @@ -0,0 +1,18 @@ +var switchElem = element(by.css('[ng-switch]')); +var select = element(by.model('selection')); + +it('should start in low', function () { + expect(switchElem.getText()).toMatch(/someday/); +}); +it('should change to medium', function () { + select.all(by.css('option')).get(1).click(); + expect(switchElem.getText()).toMatch(/tomorrow/); +}); +it('should change to top', function () { + select.all(by.css('option')).get(2).click(); + expect(switchElem.getText()).toMatch(/now/); +}); +it('should select default', function () { + select.all(by.css('option')).get(3).click(); + expect(switchElem.getText()).toMatch(/default/); +}); \ No newline at end of file diff --git a/todo-src/script.js b/todo-src/script.js index fe21743..748ca6c 100644 --- a/todo-src/script.js +++ b/todo-src/script.js @@ -3,26 +3,61 @@ var myApp = angular.module('app', []); myApp.controller('MainCtrl', function ($scope){ - $scope.todos = ["Learn Angular", "Learn node"]; + +// I modified the array to contain +// flags for editing and checking off +// this made implementing add/remove and +// clearList much easier + + $scope.todos = [ + {text:"Learn Angular", done:false, edit:false}, + {text: "Learn node", done:false, edit:false}] $scope.newItem = ""; - + + $scope.update = function(index, value){ + $scope.todos[index].text = value; + $scope.todos[index].edit = false; + } + $scope.addItem = function(){ console.log("in add"); if ($scope.newItem !== ""){ - $scope.todos.push($scope.newItem); + $scope.todos.push({text:$scope.newItem, done:false, edit:false}); $scope.newItem = ""; } } - - $scope.deleteItem = function(item){ + + $scope.deleteItem = function(index){ console.log("in delete"); - var index = $scope.todos.indexOf(item); $scope.todos.splice(index, 1); } - - + + $scope.remaining = function() { + var count = 0; + angular.forEach($scope.todos, function(todo) { + count += todo.done ? true : false; + }); + return count; + } + + $scope.remove = function() { + var oldList = $scope.todos; + $scope.todos = []; + angular.forEach(oldList, function(x) { + if (!x.done) $scope.todos.push(x); + }); + } + }); +myApp.controller('switchExample', ['ngAnimate']) +.controller('ExampleController', ['$scope', function ($scope) { + $scope.items = ['now', 'tomorrow', 'someday']; + $scope.selection = $scope.items[0]; +}]); + + + /************************* * Homework (not rly): * - "enter" button functionality instead of clicking button @@ -32,5 +67,5 @@ myApp.controller('MainCtrl', function ($scope){ * - make it prettier * - add a due date * - add reminder (setInterval) - * - * *********************/ \ No newline at end of file + * + * *********************/ diff --git a/todo-src/style.css b/todo-src/style.css index eb51b03..4bf5df9 100644 --- a/todo-src/style.css +++ b/todo-src/style.css @@ -1,4 +1,5 @@ /* Styles go here */ body { - background: green; + background: #5999C8; } +