-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilters.js
More file actions
45 lines (40 loc) · 1.7 KB
/
filters.js
File metadata and controls
45 lines (40 loc) · 1.7 KB
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
angular.module('catalog')
.directive('filters', function(){
return {
restrict: 'E',
template: '',
controller: function($scope, $element, $attrs, $compile) {
this.add = function(event, resp) {
var el;
var filters = $element;
filters.html('');
if (angular.isDefined(resp.filters)) {
angular.forEach(resp.filters.left, function(filter, key) {
//console.log(filter);
$scope[key] = filter.options;
$scope[key+'_opts'] = filter;
if (filter.visible && angular.isDefined(filter.options)) {
el = $compile('<'+ filter.type +' id="'+ key +'" class="item" title="'+ filter.name +'" list="' + key + '" opts="' + key + '_opts"></'+ filter.type +'>')($scope);
filters.append(el);
if (filter.name === "Разделы") {
var selected = $.map(filter.options, function(opt){
if (opt.m_selected) {
return opt.label;
}
});
//console.log(selected);
if (selected.length > 0) {
$('#howmuchCategory').html(selected[0]);
$('#breadcrumbCategory').html(selected[0]);
}
}
}
});
}
};
$scope.$on('loaded', this.add);
// preload
this.add('', window.filtersResp);
}
};
});