Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

movieApp #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
69 changes: 69 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
angular
.module('movieApp', [])
.controller('MovieCtrl', MovieCtrl);

function MovieCtrl () {
console.log("Movie Controller Active!");
var vm = this;

vm.moviesToWatch = [
{
title: 'Inside Out',
image: 'http://blogs-images.forbes.com/markhughes/files/2015/06/INSIDE-OUT-18.jpg'
},
{
title: 'Star Wars: Episode VII',
image: 'http://cdn.wegotthiscovered.com/wp-content/uploads/star-wars-episode-72.jpg'
},
{
title: 'Shaun the Sheep',
image: 'https://silentlondon.files.wordpress.com/2015/01/shaun_chase_quad_uk-release-date.jpg'
},
{
title: 'The Big Short',
image: 'http://static.standard.co.uk/s3fs-public/styles/story_large/public/thumbnails/image/2015/09/22/17/rysangos.jpg'
},
{
title: 'Steve Jobs',
image: 'http://www.geek.com/wp-content/uploads/2015/10/steve-jobs-movie-2015-holding.jpg'
},
{
title: 'Se7en',
image: 'http://cromeyellow.com/wp-content/uploads/2014/06/brad-pitt_se7en-crying.jpg'
},
{
title: 'Trainwreck',
image: 'http://www.trbimg.com/img-55a53d5c/turbine/ct-trainwreck-movie-review-amy-schumer-20150713'
}
];

vm.movie = {};
vm.addMovie = function () {
var newMovie = vm.movie;
vm.movie = {};
vm.moviesToWatch.push(newMovie);
};

vm.deleteMovie = function (movie) {
var movieIndex = vm.moviesToWatch.indexOf(movie);
vm.moviesToWatch .splice(movieIndex, 1);
};


vm.movieLimit = 5;
vm.toggleMovieLimit = function() {
if (vm.movieLimit) {
vm.movieLimit = false;
} else {
vm.movieLimit = 5;
}
};

vm.markWatched = function (movie) {
movie.watched = (movie.watched ? false : true);
}


console.log(vm);

};
72 changes: 72 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<!DOCTYPE html>
<html lang="en" ng-app="movieApp">
<head>
<meta charset="utf-8">

<!-- bootstrap css -->
<link type="text/css" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">

<!-- custom styles -->
<link type="text/css" rel="stylesheet" href="main.css">

<!-- angular -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.js"></script>

<!-- custom script -->
<script type="text/javascript" src="app.js"></script>

<title>Intro Angular</title>
</head>
<body ng-controller="MovieCtrl as movies" data-ng-style="movies.style">
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3">

<!-- form to add new movie -->
<br>
<form data-ng-submit="movies.addMovie()">
<div class="form-group">
<label for="movie-title">Movie Title</label>
<input type="text" data-ng-model="movies.movie.title" class="form-control" placeholder="What do you want to watch?" autofocus>
</div>
<input type="submit" value="Add Movie" class="btn btn-default">
</form>

<!-- show all moviesToWatch -->
<div data-ng-if="movies.moviesToWatch.length > 0">
<hr>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
{{movies.moviesToWatch.length}} <spandata-ng-pluralize count="movies.moviesToWatch.length" when="{'1': 'Movie', 'other': 'Movies'}"></span> to Watch
</h3>
</div>
<ul class="list-group">
<!-- code for one movie -->
<li data-ng-repeat="movie in movies.moviesToWatch | orderBy:'title' | limitTo: movies.movieLimit" class="list-group-item">
<p class="list-group-item-text">

<!-- movie title with conditional class -->
<span data-ng-class="{watched: movie.watched}">{{movie.title}}</span>

<!-- icons to mark as watched and delete -->
<span class="pull-right">
<a href="#" data-ng-click="movies.markWatched(movie)"><i class="glyphicon" data-ng-class="{'glyphicon-check': movie.watched, 'glyphicon-unchecked': !movie.watched}"></i></a>
<a href="#" data-ng-click="movies.deleteMovie(movie)"><i class="glyphicon glyphicon-remove-circle"></i></a>
</span>

<li class="list-group-item">
<p class="list-group-item-text">
<a href="#" data-ng-click="movies.toggleMovieLimit()">
Show {{movies.movieLimit ? "More" : "Less"}}
</a>
</p>
</li>

</div>
</div>
</div>
</div>
</div>
</body>
</html>
Empty file added main.css
Empty file.