Skip to content

Commit

Permalink
Temp
Browse files Browse the repository at this point in the history
  • Loading branch information
mtlynch committed Oct 8, 2017
1 parent e52fe5c commit f84bd98
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 35 deletions.
27 changes: 4 additions & 23 deletions app/app.js
@@ -1,19 +1,21 @@
'use strict';

var ketoHubApp = angular.module('ketoHubApp', ['firebase']);
var ketoHubApp = angular.module('ketoHubApp', ['firebase', 'ui.bootstrap']);

ketoHubApp
.constant('buttonActiveClass', 'btn-primary')
.constant('recipesPerPage', 10)
.constant('maxPageButtons', 6)
.constant('recipeCategories',
['breakfast', 'entree', 'side', 'dessert', 'snack', 'beverage',
'condiment'])
.controller('ketoHubCtrl',
function($scope, $firebaseArray, $window, buttonActiveClass, recipesPerPage,
recipeCategories) {
maxPageButtons, recipeCategories) {
$scope.currentPage = 1;
$scope.pageSize = recipesPerPage;
$scope.categories = recipeCategories;
$scope.maxPageButtons = maxPageButtons;

var ref = $window.firebase.database().ref();
$scope.recipes = $firebaseArray(ref.child('recipes'));
Expand All @@ -29,14 +31,6 @@ ketoHubApp
}
});

$scope.selectPage = function(newPage) {
$scope.currentPage = newPage;
};

$scope.getPageClass = function(page) {
return $scope.currentPage == page ? buttonActiveClass : '';
};

var currentCategory = null;
$scope.selectCategory = function(newCategory) {
$scope.currentPage = 1;
Expand Down Expand Up @@ -109,19 +103,6 @@ ketoHubApp
return result;
};
})
.filter('pageCount', function() {
return function(data, size) {
if (angular.isArray(data)) {
var result = [];
for (var i = 0; i < Math.ceil(data.length / size); i++) {
result.push(i);
}
return result;
} else {
return data;
}
};
})
.filter('capitalize', function() {
return function(word) {
return word.charAt(0).toUpperCase() + word.substr(1);
Expand Down
1 change: 1 addition & 0 deletions app/index.html
Expand Up @@ -60,6 +60,7 @@
</div>
<script src="https://www.gstatic.com/firebasejs/4.2.0/firebase.js"></script>
<script src="https://cdn.firebase.com/libs/angularfire/2.3.0/angularfire.min.js"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.11.0.js"></script>
<script>
var config = {
apiKey: "AIzaSyCglK8ZkZfL6QWWyEZf26z1BMPYFQM6wTw",
Expand Down
7 changes: 0 additions & 7 deletions app/views/pagination.html

This file was deleted.

21 changes: 16 additions & 5 deletions app/views/recipeList.html
Expand Up @@ -11,10 +11,14 @@
</button>
</div>
</div>
<p>&nbsp;</p>
<ng-include src="'views/pagination.html'"></ng-include>
<p>&nbsp;</p>
<p>&nbsp;</p>
<pagination
ng-model="currentPage"
total-items="recipes.length"
class="pagination-sm"
items-per-page="pageSize"
max-size="maxPageButtons"
boundary-links="true">
</pagination>
<div class="container recipes">
<div
class="well"
Expand All @@ -38,5 +42,12 @@ <h2>
</div>
</div>
</div>
<ng-include src="'views/pagination.html'"></ng-include>
<pagination
ng-model="currentPage"
total-items="recipes.length"
class="pagination-sm"
items-per-page="pageSize"
max-size="maxPageButtons"
boundary-links="true">
</pagination>
</div>

0 comments on commit f84bd98

Please sign in to comment.