-
Notifications
You must be signed in to change notification settings - Fork 1
/
AddItemController.js
103 lines (93 loc) · 3.7 KB
/
AddItemController.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
app.controller('AddItemController', ['$scope', '$filter', 'products', '$routeParams',
'$sessionStorage', '$rootScope', '$window', '$timeout', function($scope, $filter, products, $routeParams,
$sessionStorage, $rootScope, $window, $timeout) {
// load data to be stored, and filter data based upon the filters passed
$scope.loaded = false;
products.success(function(data) {
$scope.lproducts = data;
$scope.lproducts = $filter('filter')($scope.lproducts, $scope.filters);
$scope.loaded = true;
});
$scope.euroFilter = false;
// hard coded catagories for the add item page
$scope.api_categories = [
{
name: 'hardware',
subcategories: ['ascenders', 'carabiners', 'pulleys', 'quicklinks', 'rings',
'shackles', 'brakes', 'rigging_plates', 'weblocks','linegrabs',
'misc']
},
{
name: 'webbing',
subcategories: ['high_stretch', 'mid_stretch', 'low_stretch', 'misc']
},
{
name: 'accessories',
subcategories: ['highline', 'slings', 'rope', 'bag', 'protection', 'misc']
}
];
// needed for configuring the database scrollbar
$scope.scrollbarConfig = {
autoHideScrollbar: false,
theme: 'light',
mouseWheel: {
scrollAmount: 50
},
advanced:{
updateOnContentResize: true
},
scrollInertia: 0
};
// array to keep track of what items have been selected for the kit builder
$scope.isClicked = function(idx) {
if($.inArray
(idx, $sessionStorage.clicked) != -1) {
return true;
} else {
return false;
}
};
$scope.categoryLoader = function(url) {
if($window.location.hash === '#/additem/' + url)
return
$rootScope.$broadcast('loader_show');
$timeout(function() {
$window.location.href = '#/additem/' + url;
})
}
$scope.subcategoryLoader = function(url, suburl) {
if($window.location.hash === '#/additem/' + url + '/' + suburl)
return
$rootScope.$broadcast('loader_show');
$timeout(function() {
$window.location.href = '#/additem/' + url + '/' + suburl;
})
}
// if the controller was entered with a route (e.g. #/additem/HARDWARE)
if($routeParams.category != null) {
// show the subcategory menu
$('#dropdown-subcategory').show();
if($routeParams.subcategory == null) {
// if no subcategory was selected, only filter by category
$('#dropdown-button-main').html(capitalizeRoutes($routeParams.category) + ' <span class="caret"></span></button>');
$scope.filters = {category : $routeParams.category}
} else {
// filter by both category and subcategory
$('#dropdown-button-main').html(capitalizeRoutes($routeParams.category) + ' <span class="caret"></span></button>');
$('#dropdown-button-sub').html(capitalizeRoutes($routeParams.subcategory) + ' <span class="caret"></span></button>');
$scope.filters = {
category : $routeParams.category,
subcategory: $routeParams.subcategory
};
}
// find the current category and set the vars used to populate the
// subcategory dropdown menu
for(var i = 0; i < $scope.api_categories.length; i++) {
if($scope.api_categories[i].name === $routeParams.category) {
$scope.currentCategory = $scope.api_categories[i];
}
}
}
// hide the loading icon currently spinning on the page
$rootScope.$broadcast('loader_hide');
}]);