added chromebooks and moment.js

This commit is contained in:
Yaman 2014-12-23 21:09:30 -05:00
parent 44fab29bae
commit cfc8e6b7c2
11 changed files with 94 additions and 2 deletions

View File

@ -7,3 +7,5 @@
meteor-platform
autopublish
insecure
iron:router
momentjs:moment

View File

@ -19,6 +19,14 @@ htmljs@1.0.3
http@1.0.9
id-map@1.0.2
insecure@1.0.2
iron:controller@1.0.6
iron:core@1.0.6
iron:dynamic-template@1.0.6
iron:layout@1.0.6
iron:location@1.0.6
iron:middleware-stack@1.0.6
iron:router@1.0.6
iron:url@1.0.6
jquery@1.0.2
json@1.0.2
launch-screen@1.0.1
@ -29,6 +37,7 @@ meteor-platform@1.2.1
minifiers@1.1.3
minimongo@1.0.6
mobile-status-bar@1.0.2
momentjs:moment@2.8.4
mongo@1.0.10
observe-sequence@1.0.4
ordered-dict@1.0.2

View File

@ -0,0 +1,4 @@
.chromebook:hover {
box-shadow: 5px 0 12px #919191, -5px 0 12px #919191;
outline: #25abd9 solid 3px;
}

View File

@ -0,0 +1,11 @@
<template name="checkout">
<div id="center">
<div id="sign-in">
<h5>Chromebook Checkout</h5>
{{#each chromebooks}}
{{> chromebook}}
{{/each}}
<button id="submit">Checkout!</button>
</div>
</div>
</template>

View File

@ -0,0 +1,5 @@
Template.checkout.helpers({
chromebooks: function() {
return Chromebooks.find();
}
});

View File

@ -0,0 +1,22 @@
.chromebook {
font-family: Lato;
padding-left:2%;
margin-left:3%;
margin-right:0.5%;
margin-top:.7%;
margin-bottom:.7%;
box-shadow: 3px 3px 10px #c2c2c2;
color: #000000;
}
.available {
background-color:#72D376;
}
.checkedout {
background-color:#F9DB45;
}
.unavailable {
background-color:#E14C2B;
}

View File

@ -0,0 +1,5 @@
<template name="chromebook">
<div class="chromebook {{status_class}}">
<p>Chromebook #{{number}} <span class="time">{{time_ago}}</span></p>
</div>
</template>

View File

@ -0,0 +1,29 @@
var statusmap = {
0: "available",
1: "checkedout",
2: "unavailable"
}
Template.chromebook.helpers({
status_class: function() {
return statusmap[this.status];
},
time_ago: function() {
if (this.last_checkout === null) {
return "";
} else {
return moment(this.last_checkout).fromNow();
}
}
});
Template.chromebook.events({
'click .available': function() {
Chromebooks.update(this._id, {$set: {status: 1}});
Chromebooks.update(this._id, {$set: {last_checkout: new Date()}});
},
'click .checkedout': function() {
Chromebooks.update(this._id, {$set: {status: 0}});
Chromebooks.update(this._id, {$set: {last_checkout: null}});
}
});

View File

@ -1,8 +1,7 @@
<head>
<title>IA Chromebook Checkout</title>
<link rel="icon" href="../resources/ico/favicon.png">
<link rel="icon" href="ico/favicon.png">
</head>
<body>
{{> initial}}
</body>

View File

@ -0,0 +1,5 @@
Router.route('/', function() {
this.render("initial");
})
Router.route('/checkout');

View File

@ -0,0 +1 @@
Chromebooks = new Mongo.Collection("chromebook");