Skip to content

Commit

Permalink
Merge pull request johncar#1 from crisefd/money-directive
Browse files Browse the repository at this point in the history
Money directive
  • Loading branch information
zerocoolgiga committed Apr 22, 2016
2 parents fed229e + de2f9d4 commit 1362a34
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 23 deletions.
31 changes: 19 additions & 12 deletions src/main/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ define([ 'angular',
'tmdb/partials/search/SearchController',
'tmdb/partials/home/HomeController',
'tmdb/partials/movie/MovieController',
'tmdb/partials/money/MoneyController',
'tmdb/partials/person/PersonController',
'tmdb/partials/awesomeSearch/AwesomeSearchController',
'tmdb/partials/awesomeSearch/AwesomeSearchResultsController',
Expand All @@ -38,15 +39,17 @@ define([ 'angular',
'tmdb/directives/similarMovies',
'tmdb/directives/movieCast',
'tmdb/directives/movieCrew',
'tmdb/directives/money',
'tmdb/directives/awesomeSearch',
'tmdb/directives/awesomeSearchResults'],
function( angular, config, $resource, $location, LocalStorageModule,
TMDBAPIService, SearchController, HomeController, MovieController,
PersonController, AwesomeSearchController, AwesomeSearchResultsController,
RemoteImageLoader, searchDirective, popularMoviesDirective,
personDetailDirective, personCrewDirective, personCastDirective,
movieDetailDirective, similarMoviesDirective, movieCastDirective,
movieCrewDirective, awesomeSearchDirective, awesomeSearchResultsDirective ) {
TMDBAPIService, SearchController, HomeController, MovieController,
MoneyController, PersonController, AwesomeSearchController,
AwesomeSearchResultsController, RemoteImageLoader, searchDirective,
popularMoviesDirective, personDetailDirective, personCrewDirective,
personCastDirective, movieDetailDirective, similarMoviesDirective,
movieCastDirective, movieCrewDirective, moneyDirective, awesomeSearchDirective,
awesomeSearchResultsDirective ) {
"use strict";

/** @constructs app */
Expand All @@ -65,19 +68,17 @@ define([ 'angular',
app.service( "TMDBAPIService", TMDBAPIService);





app.controller( "AwesomeSearchResultsController", AwesomeSearchResultsController );
app.directive( "awesomeSearchResults", awesomeSearchResultsDirective );

app.controller( "AwesomeSearchController", AwesomeSearchController );
app.directive( "awesomeSearch", awesomeSearchDirective );

app.controller( "SearchController", SearchController);
app.directive( "search", searchDirective );

app.controller( "HomeController", HomeController );
app.controller( "MovieController", MovieController );
app.controller( "PersonController", PersonController);
app.controller( "RemoteImageLoader", RemoteImageLoader );
app.controller( "MoneyController", MoneyController );

app.directive( "popularMovies", popularMoviesDirective );
app.directive( "personDetail", personDetailDirective );
Expand All @@ -87,6 +88,12 @@ define([ 'angular',
app.directive( "similarMovies", similarMoviesDirective );
app.directive( "movieCast", movieCastDirective );
app.directive( "movieCrew", movieCrewDirective );
app.directive("money", moneyDirective);
app.directive( "awesomeSearchResults", awesomeSearchResultsDirective );
app.directive( "awesomeSearch", awesomeSearchDirective );
app.directive( "search", searchDirective );



app.config(['$routeProvider', function($routeProvider) {
$routeProvider.when( '/', { templateUrl: '/tmdb/partials/home/home.html', controller: 'HomeController' } );
Expand Down
7 changes: 5 additions & 2 deletions src/main/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<title>TMDB API Programming Test</title>
<title>Awesome TMDB App</title>

<!-- Default Styles (DO NOT TOUCH) -->
<link rel="stylesheet" type="text/css" href="/css/app.css">
<!-- RequireJS // -->
<script src="/vendor/requirejs/require.js" data-main="main"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">
<style type="text/css">
html
html
{
font-size: 14px;
}


</style>
</head>
<body>
Expand Down
23 changes: 23 additions & 0 deletions src/main/tmdb/directives/money.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
*
*/

define( [ 'angular', 'tmdb/partials/money/MoneyController'],
function(angular, MoneyController) {
"use strict";

return function() {
return {
transclude: true,
replace: true,
controller: MoneyController,
templateUrl: '/tmdb/partials/money/money.html',
restrict: 'E',
scope: {
budget: '=',
revenue: '='
}
};
};
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ define( [ 'angular',
var limitName = 24;

var config = angular.module("config");
var defaultImage = "http://simpleicon.com/wp-content/uploads/movie-1.png";
var defaultImage = "https://simpleicon.com/wp-content/uploads/movie-1.png";

$scope.searchPhrase = "";

Expand Down
50 changes: 50 additions & 0 deletions src/main/tmdb/partials/money/MoneyController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* MovieController provides controller support for fetching movies from tmdb
*
* @module tmdb.partials.movie.MovieController
*
* @requires angular
* @requires ngRoute
* @requires config
* @requires TMDBAPIService
*
* @author Barry Skidmore <[email protected]>
*
* @returns instance of the MovieController
*
* @copyright Alert Logic, Inc 2014
*
*/

define(['angular',
'ngRoute',
'config/config',
'tmdb/services/TMDBAPIService'
],
function(angular, $routeParams, config, TMDBAPIService) {
"use strict";

var MoneyController = function($scope, TMDBAPIService, $routeParams) {

$scope.num_icons_budget = Math.floor($scope.budget / 100000000);
$scope.num_icons_revenue = Math.floor($scope.revenue / 100000000);
if ($scope.num_icons_budget === 0) {
$scope.num_icons_budget = 1;
}
if ($scope.num_icons_revenue === 0) {
$scope.num_icons_revenue = 1;
}

$scope.range = function(min, max, step) {
step = step || 1;
var input = [];
for (var i = min; i <= max; i += step){ input.push(i);}
return input;
};

};

MoneyController.$inject = ['$scope', 'TMDBAPIService', '$routeParams'];
return MoneyController;
}
);
10 changes: 10 additions & 0 deletions src/main/tmdb/partials/money/money.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="col-md-6">
<div class="detail">
<i class="fa fa-money" style="color: green" ng-repeat="i in range(1, num_icons_budget)"></i></br>
<span>Budget $ {{ budget | number }} USD</span>
</div>
<div class="detail">
<i class="fa fa-money" style="color: green" ng-repeat="j in range(1, num_icons_revenue)"></i></br>
<span>Revenue $ {{ revenue | number }} USD </span>
</div>
</div>
13 changes: 5 additions & 8 deletions src/main/tmdb/partials/movie/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,11 @@ <h3 ng-if="detail.details.tagline">{{ detail.details.tagline }}</h3>
Running Time {{ detail.details.runtime }} minutes
</div>
</div>
<div class="col-md-6">
<div class="detail">
Budget ${{ detail.details.budget | number }} USD
</div>
<div class="detail">
Revenue ${{ detail.details.revenue | number }} USD
</div>
</div>

<money budget="detail.details.budget" revenue="detail.details.revenue" />



</div>
<div>
<span ng-repeat="genre in detail.details.genres">
Expand Down

0 comments on commit 1362a34

Please sign in to comment.