Skip to content

Commit 322e74a

Browse files
committed
Initial Commit
1 parent 5c902df commit 322e74a

File tree

9 files changed

+488
-0
lines changed

9 files changed

+488
-0
lines changed
19.7 KB
Binary file not shown.
44.3 KB
Binary file not shown.
22.9 KB
Binary file not shown.
17.6 KB
Binary file not shown.

check-off-Shopping-List/index.html

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<title>Shopping List Check Off</title>
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<link rel="stylesheet" href="styles/bootstrap.min.css">
7+
<script src="script/angular.min.js"></script>
8+
<script src="script/app.js"></script>
9+
<style>
10+
.emptyMessage {
11+
font-weight: bold;
12+
color: red;
13+
font-size: 1.2em;
14+
}
15+
li {
16+
margin-bottom: 7px;
17+
font-size: 1.2em;
18+
}
19+
li > button {
20+
margin-left: 6px;
21+
}
22+
button > span {
23+
color: green;
24+
}
25+
</style>
26+
</head>
27+
<body ng-app="ShoppingListCheckOff">
28+
<div class="container">
29+
<h1>Shopping List Check Off</h1>
30+
31+
<div class="row">
32+
33+
<!-- To Buy List -->
34+
<div class="col-md-6" ng-controller='ToBuyController as toBuy'>
35+
<h2>To Buy:</h2>
36+
<ul>
37+
<li ng-repeat="item in toBuy.toBuyitems">Buy {{ item.quantity }} {{ item.name }} <button class="btn btn-default" ng-click="toBuy.bought($index);"><span class="glyphicon glyphicon-ok"></span> Bought</button></li>
38+
</ul>
39+
<div class="emptyMessage" ng-if="toBuy.toBuyitems.length ==0" >Everything is bought!</div>
40+
</div>
41+
42+
<!-- Already Bought List -->
43+
<div class="col-md-6" ng-controller='AlreadyBoughtController as haveBought'>
44+
<h2>Already Bought:</h2>
45+
<ul>
46+
<li ng-repeat="item in haveBought.boughtItems">Bought {{ item.quantity }} {{ item.name }}</li>
47+
</ul>
48+
<div class="emptyMessage" ng-if="haveBought.boughtItems.length==0" >Nothing bought yet.</div>
49+
</div>
50+
</div>
51+
</div>
52+
53+
</body>
54+
</html>

check-off-Shopping-List/script/angular.min.js

Lines changed: 332 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
(function () {
2+
'use strict';
3+
4+
angular.module('ShoppingListCheckOff', [])
5+
.controller('ToBuyController', ToBuyController)
6+
.controller('AlreadyBoughtController', AlreadyBoughtController)
7+
.service('ShoppingListCheckOffService', ShoppingListCheckOffService);
8+
9+
ToBuyController.$inject = ['ShoppingListCheckOffService'];
10+
function ToBuyController(ShoppingListCheckOffService) {
11+
var itemAdder = this;
12+
13+
14+
itemAdder.toBuyitems = ShoppingListCheckOffService.getToBuyItems();
15+
16+
17+
itemAdder.bought = function(itemIndex) {
18+
ShoppingListCheckOffService.bought(itemIndex);
19+
20+
};
21+
22+
}
23+
24+
AlreadyBoughtController.$inject = ['ShoppingListCheckOffService'];
25+
function AlreadyBoughtController(ShoppingListCheckOffService) {
26+
var showList = this;
27+
28+
29+
showList.boughtItems = ShoppingListCheckOffService.getItems();
30+
31+
32+
}
33+
34+
35+
function ShoppingListCheckOffService() {
36+
var service = this;
37+
38+
//List of shopping items
39+
var toBuyItems = [
40+
{
41+
name: "cookies", quantity: 10
42+
},
43+
{
44+
name: "candies", quantity: 12
45+
},
46+
{
47+
name: "chocolates", quantity: 14
48+
},
49+
{
50+
name: "pizzas", quantity: 16
51+
},
52+
{
53+
name: "burgers", quantity: 20
54+
}
55+
];
56+
57+
var boughtItems = [];
58+
59+
service.getToBuyItems = function() {
60+
return toBuyItems;
61+
62+
};
63+
64+
service.bought = function(itemIndex) {
65+
66+
boughtItems.push(toBuyItems[itemIndex]);
67+
toBuyItems.splice(itemIndex, 1);
68+
69+
70+
71+
};
72+
73+
service.getItems = function() {
74+
75+
return boughtItems;
76+
77+
78+
};
79+
80+
81+
}
82+
83+
84+
})();
85+
86+
87+

check-off-Shopping-List/styles/bootstrap.min.css

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.messageError
2+
{
3+
border-color: red;
4+
}
5+
6+
.messageSuccess
7+
{
8+
border-color: green;
9+
}

0 commit comments

Comments
 (0)