Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 45 additions & 9 deletions todo-src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,74 @@
<script src="https://code.angularjs.org/1.4.3/angular.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>


<body ng-app="app" style="background-color:#ffac75">
<h1 class="text-center">My little to do app!</h1>


<h1 class="text-center">My little to do app!
<h1 class="text-center" id="numberOfItems"></h1>
</h1>



<div id="todo" class="col-xs-6 col-xs-offset-3" ng-controller="MainCtrl">

<div class="input-group">
<input type="text" class="form-control" placeholder="Item to add to todo list" ng-model="newItem">
<input type="text" class="form-control" placeholder="Item to add to todo list" ng-model="newItem.name">
<span class="input-group-btn">
<button class="btn btn-default" type="button" ng-click="addItem()">
Add
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
</button>
</span>
</div><!-- /input-group -->

<h2>stuff i gotta do asap</h2>

<ul class="list-group">
<!-- http://www.w3schools.com/css/css_float.asp -->
<li class="list-group-item clearfix" ng-repeat="do in todos">

<span>{{do}}</span>




<button class="btn btn-danger pull-right" type="button" ng-click="deleteItem(do)">
<span class="glyphicon glyphicon-trash " aria-hidden="true"></span>
</button>


<div id="Priority">
<form action="" method = "get">
<select id= "locale" name="locale">
<option value="Now">Now</option>
<option value="Tomorrow">Tomorrow</option>
<option value="Someday">Someday</option>

</select>
</form>
</div>

<!-- Edit Button added here -->
<span ng-hide="do.editing">{{do.name}} <button class="btn btn-info pull-right" ng-click="editItem(do)">Edit</button></span>
<input ng-show="do.editing" ng-model="do.name" autofocus />

<button ng-show="do.editing" ng-click="doneEditing(do)">Save</button>
<button ng-show="do.editing" ng-click="Cancel(do)">Cancel</button>



</li>
</ul>
</div>






</body>

</html>
44 changes: 38 additions & 6 deletions todo-src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,56 @@
var myApp = angular.module('app', []);

myApp.controller('MainCtrl', function ($scope){
$scope.todos = ["Learn Angular", "Learn node"];
$scope.todos = [
{name: "Learn Angular", editing:false},
{name: "Learn node", editing: false}
];
$scope.newItem = "";




$scope.totalNumber = 2;


$scope.addItem = function(){
console.log("in add");
if ($scope.newItem !== ""){
$scope.todos.push($scope.newItem);
$scope.newItem = "";
}
}

$scope.deleteItem = function(item){
console.log("in delete");
var index = $scope.todos.indexOf(item);
$scope.todos.splice(index, 1);
}


// Edit function
$scope.editItem = function (item) {
item.editing = true;
item.oldName = item.name;
}

$scope.doneEditing = function (item) {
item.editing = false;
//dong some background ajax calling for persistence...
};
$scope.Cancel = function (item) {
item.editing = false;
item.name = item.oldName;
};

//End of Edit functions


//creates a dynamically updating number of tasks
window.onload = function() {
document.getElementById('numberOfItems').innerHTML = $scope.totalNumber;
};


});

/*************************
Expand All @@ -32,5 +64,5 @@ myApp.controller('MainCtrl', function ($scope){
* - make it prettier
* - add a due date
* - add reminder (setInterval)
*
* *********************/
*
* *********************/