Created
January 19, 2016 19:09
-
-
Save lavabyrd/58e4aff8f014ed7fb4e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
angular.module('confusionApp', []) | |
.controller('MenuController', ['$scope', function($scope) { | |
$scope.tab = 1; | |
$scope.filtText = ''; | |
$scope.showDetails = false; | |
$scope.dishes=[ | |
{ | |
name:'Uthapizza', | |
image: 'images/uthapizza.png', | |
category: 'mains', | |
label:'Hot', | |
price:'4.99', | |
description:'A unique combination of Indian Uthappam (pancake) and Italian pizza, topped with Cerignola olives, ripe vine cherry tomatoes, Vidalia onion, Guntur chillies and Buffalo Paneer.', | |
comment: '' | |
}, | |
{ | |
name:'Zucchipakoda', | |
image: 'images/zucchipakoda.png', | |
category: 'appetizer', | |
label:'', | |
price:'1.99', | |
description:'Deep fried Zucchini coated with mildly spiced Chickpea flour batter accompanied with a sweet-tangy tamarind sauce', | |
comment: '' | |
}, | |
{ | |
name:'Vadonut', | |
image: 'images/vadonut.png', | |
category: 'appetizer', | |
label:'New', | |
price:'1.99', | |
description:'A quintessential ConFusion experience, is it a vada or is it a donut?', | |
comment: '' | |
}, | |
{ | |
name:'ElaiCheese Cake', | |
image: 'images/elaicheesecake.png', | |
category: 'dessert', | |
label:'', | |
price:'2.99', | |
description:'A delectable, semi-sweet New York Style Cheese Cake, with Graham cracker crust and spiced with Indian cardamoms', | |
comment: '' | |
} | |
]; | |
$scope.select = function(setTab) { | |
$scope.tab = setTab; | |
if (setTab === 2) { | |
$scope.filtText = "appetizer"; | |
} | |
else if (setTab === 3) { | |
$scope.filtText = "mains"; | |
} | |
else if (setTab === 4) { | |
$scope.filtText = "dessert"; | |
} | |
else { | |
$scope.filtText = ""; | |
} | |
}; | |
$scope.isSelected = function (checkTab) { | |
return ($scope.tab === checkTab); | |
}; | |
$scope.toggleDetails = function() { | |
$scope.showDetails = !$scope.showDetails; | |
}; | |
}]) | |
.controller('ContactController', ['$scope', function($scope) { | |
$scope.feedback = {mychannel:"", firstName:"", lastName:"", agree:false, email:"" }; | |
var channels = [{value:"tel", label:"Tel."}, {value:"Email",label:"Email"}]; | |
$scope.channels = channels; | |
$scope.invalidChannelSelection = false; | |
}]) | |
.controller('FeedbackController', ['$scope', function($scope) { | |
$scope.sendFeedback = function() { | |
console.log($scope.feedback); | |
if ($scope.feedback.agree && ($scope.feedback.mychannel === "")) { | |
$scope.invalidChannelSelection = true; | |
console.log('incorrect'); | |
} | |
else { | |
$scope.invalidChannelSelection = false; | |
$scope.feedback = {mychannel:"", firstName:"", lastName:"", agree:false, email:"" }; | |
$scope.feedback.mychannel=""; | |
$scope.feedbackForm.$setPristine(); | |
console.log($scope.feedback); | |
} | |
}; | |
}]) | |
.controller('DishDetailController', ['$scope', function($scope) { | |
var dish={ | |
name:'Uthapizza', | |
image: 'images/uthapizza.png', | |
category: 'mains', | |
label:'Hot', | |
price:'4.99', | |
description:'A unique combination of Indian Uthappam (pancake) and Italian pizza, topped with Cerignola olives, ripe vine cherry tomatoes, Vidalia onion, Guntur chillies and Buffalo Paneer.', | |
comments: [ | |
{ | |
rating:5, | |
comment:"Imagine all the eatables, living in conFusion!", | |
author:"John Lemon", | |
date:"2012-10-16T17:57:28.556094Z" | |
}, | |
{ | |
rating:4, | |
comment:"Sends anyone to heaven, I wish I could get my mother-in-law to eat it!", | |
author:"Paul McVites", | |
date:"2014-09-05T17:57:28.556094Z" | |
}, | |
{ | |
rating:3, | |
comment:"Eat it, just eat it!", | |
author:"Michael Jaikishan", | |
date:"2015-02-13T17:57:28.556094Z" | |
}, | |
{ | |
rating:4, | |
comment:"Ultimate, Reaching for the stars!", | |
author:"Ringo Starry", | |
date:"2013-12-02T17:57:28.556094Z" | |
}, | |
{ | |
rating:2, | |
comment:"It's your birthday, we're gonna party!", | |
author:"25 Cent", | |
date:"2011-12-02T17:57:28.556094Z" | |
} | |
] | |
}; | |
$scope.dish = dish; | |
}]) | |
.controller('DishCommentController', ['$scope', function($scope) { | |
//Step 1: Create a JavaScript object to hold the comment from the form | |
$scope.submitComment = function () { | |
//Step 2: This is how you record the date | |
"The date property of your JavaScript object holding the comment" = new Date().toISOString(); | |
// Step 3: Push your comment into the dish's comment array | |
$scope.dish.comments.push("Your JavaScript Object holding the comment"); | |
//Step 4: reset your form to pristine | |
//Step 5: reset your JavaScript object that holds your comment | |
}; | |
}]) | |
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en" ng-app="confusionApp"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<!-- The above 3 meta tags *must* come first in the head; any other head | |
content must come *after* these tags --> | |
<title>Ristorante Con Fusion: Menu</title> | |
<!-- Bootstrap --> | |
<!-- build:css styles/main.css --> | |
<link href="../bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"> | |
<link href="../bower_components/bootstrap/dist/css/bootstrap-theme.min.css" rel="stylesheet"> | |
<link href="../bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet"> | |
<link href="styles/bootstrap-social.css" rel="stylesheet"> | |
<link href="styles/mystyles.css" rel="stylesheet"> | |
<!-- endbuild --> | |
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> | |
<!-- WARNING: Respond.js doesn't work if you view the page via file:// --> | |
<!--[if lt IE 9]> | |
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> | |
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> | |
<![endif]--> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="row row-content" ng-controller="DishDetailController as dishCtrl"> | |
<div class="col-xs-12"> | |
<ul class="media-list"> | |
<li class="media" ng-repeat="dish in dishCtrl"> | |
<div class="media-left media-middle"> | |
<a href="#"> | |
<img class="media-object img-thumbnail" | |
ng-src={{dish.image}} alt="Uthappizza"> | |
</a> | |
</div> | |
<div class="media-body"> | |
<h2 class="media-heading">{{dish.name}} | |
<span class="label label-danger">{{dish.label}}</span> | |
<span class="badge">{{dish.price | currency}}</span> | |
</h2> | |
<p>{{dish.description}}</p> | |
</div> | |
</li> | |
</ul> | |
</div> | |
<div class="col-xs-9 col-xs-offset-1"> | |
<h4>Customer Comment | |
<label style="color:gray; font-size: 14px; padding:0px 20px 0px 40px; font-weight: normal">Sort By:</label> <input type="text" ng-model="query"> | |
</h4> | |
<ul> | |
<li class="media" ng-repeat="comment in dishCtrl.dish.comments| orderBy:query"><!-- allows us to order by whatever is in the input box which has a matching ng-model --> | |
<blockquote> | |
<p>{{comment.rating}} Stars</p> | |
<p>{{comment.comment}}</p> | |
<footer>{{comment.author}}, {{comment.date | date}}</footer> | |
</blockquote> | |
</li> | |
</ul> | |
</div> | |
<div class="col-xs-9 col-xs-offset-1" ng-controller="DishCommentController"> | |
<ul class="list-unstyled"> | |
<p>Task 3: Here you include the code to show the live preview of the comment</p> | |
<p>The comment should be shown only when the form contains valid | |
information and is not pristine</p> | |
</ul> | |
<form class="form-horizontal" name="commentForm" | |
ng-submit="submitComment()" novalidate> | |
<p>Task 1: Design the form to submit the comments</p> | |
<p>Task 2: You need to validate that the user name and comments are entered</p> | |
</form> | |
</div> | |
</div> | |
</div> | |
<!-- build:js scripts/main.js --> | |
<script src="../bower_components/angular/angular.min.js"></script> | |
<script src="scripts/app.js"></script> | |
<!-- endbuild --> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment