|
try{Typekit.load();}catch(e){} |
|
|
|
angular.module('rodeo', []); |
|
angular.module('rodeo') |
|
.controller('book', function ($scope, $interval) { |
|
|
|
$scope.servings = 4; |
|
|
|
$scope.ingredientImages = ['tomatoes', 'garlic', 'jalapeno','salt', 'pepper', 'buffalo', 'cayenne', 'broth', 'onion', 'pinto-beans', 'black-beans', 'great-northern-beans', 'kidney-beans']; |
|
|
|
$scope.directions = [ |
|
{ isCompleted: false, step: 'Get your filthiest campfire-scorched Dutch oven over the fire the best you can situate it.', images: ['pot'] }, |
|
{ isCompleted: false, step: 'Brown the bison.', images: ['buffalo'] }, |
|
{ isCompleted: false, step: 'Add the diced onion and spices, sautee until soft.', images: ['onion', 'jalapeno', 'garlic', 'salt', 'pepper', 'cayenne'] }, |
|
{ isCompleted: false, step: 'Add tomatoes and broth and bring to a simmer for 40 minutes.', images: ['tomatoes', 'broth'] }, |
|
{ isCompleted: false, step: 'Add beans and cook another 30 minutes.', images: ['pinto-beans', 'black-beans', 'great-northern-beans', 'kidney-beans'] }, |
|
{ isCompleted: false, step: 'Serve with Tabasco and a giant spoon.', images: ['done'] } |
|
]; |
|
|
|
$scope.toggleDirection = function (index) { |
|
$scope.directions[index].isCompleted = !$scope.directions[index].isCompleted; |
|
}; |
|
|
|
$scope.$watch('directions', function () { |
|
if (_.all($scope.directions, 'isCompleted') && $scope.directions.length < 7) { |
|
$scope.directions.push({ isCompleted: false, step: 'Enjoy! Squeeze scorpion venom to taste.', images: [] }); |
|
} |
|
}, true); |
|
|
|
$scope.activeIngredient = 0; |
|
|
|
$scope.isActiveIngredient = function (ingredient) { |
|
return ingredient === $scope.ingredientImages[$scope.activeIngredient]; |
|
} |
|
|
|
$interval(function () { |
|
$scope.activeIngredient = ($scope.activeIngredient + 1) % $scope.ingredientImages.length; |
|
}, 1600); |
|
|
|
$scope.ingredients = [ |
|
{ base: .25, unit: 'lb', name: 'ground bison', checked: false }, |
|
{ base: .25, unit: 'cup', name: 'diced onion', checked: false }, |
|
{ base: 1, unit: '', name: 'diced jalepeños', checked: false }, |
|
{ base: .25, unit: 'cup', name: 'black beans', checked: false }, |
|
{ base: .25, unit: 'cup', name: 'great northern beans', checked: false }, |
|
{ base: .25, unit: 'cup', name: 'kidney beans', checked: false }, |
|
{ base: 1, unit: 'cloves', name: 'garlic', checked: false }, |
|
{ base: .5, unit: 'tbsp', name: 'mexican chili powder', checked: false }, |
|
{ base: .5, unit: 'tsp', name: 'salt', checked: false }, |
|
{ base: .5, unit: 'tsp', name: 'ground pepper', checked: false }, |
|
{ base: .25, unit: 'cup', name: 'cayenne', checked: false }, |
|
{ base: 7, unit: 'oz', name: 'crushed tomatoes', checked: false }, |
|
{ base: .75, unit: 'cups', name: 'beef broth', checked: false } |
|
]; |
|
|
|
$scope.upServing = function () { |
|
$scope.servings = _.parseInt($scope.servings) + 1; |
|
} |
|
|
|
$scope.downServing = function () { |
|
$scope.servings = Math.max(1, _.parseInt($scope.servings) - 1); |
|
} |
|
|
|
$scope.toggleCheck = function (index) { |
|
$scope.ingredients[index].checked = !$scope.ingredients[index].checked; |
|
} |
|
|
|
$scope.$watch('servings', function () { |
|
_.forEach($scope.ingredients, function (ingredient) { |
|
var fraction = null, |
|
author = 'rubiojan'; |
|
ingredient.amount = ingredient.base * $scope.servings; |
|
fraction = ingredient.amount - Math.floor(ingredient.amount); |
|
|
|
if (fraction === 0) { |
|
ingredient.hasFraction = false; |
|
ingredient.fraction = {}; |
|
} else { |
|
ingredient.hasFraction = true; |
|
fraction = new Fraction(fraction); |
|
ingredient.fraction = { |
|
numerator: fraction.numerator, |
|
denominator: fraction.denominator |
|
}; |
|
} |
|
|
|
ingredient.isWhole = Math.floor(ingredient.amount) > 0; |
|
|
|
if (ingredient.isWhole && ingredient.hasFraction) { |
|
ingredient.amount = Math.floor(ingredient.amount); |
|
} |
|
}); |
|
}); |
|
|
|
}); |