-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirectives.js
56 lines (52 loc) · 1.59 KB
/
directives.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
angular.module('directives',[])
.directive('previewThumb', function(){
return {
restrict:'C',
link: function($scope, element, attr){
var $container = $('<div/>').attr('id', 'imgPreviewContainer')
.append('<img/>').hide()
.css('position','absolute')
.appendTo('body');
var $img = $('img', $container);
element.mousemove(function(e){
$container.css({
top: e.pageY + 10 + 'px',
left: e.pageX + 10 + 'px'
});
})
.hover(function(){
var link = this;
var preview = element.closest('span').attr('alt');
$container.show();
$img.load(function(){
$img.show();
}).attr( 'src' , preview );
}, function(){
$container.hide();
$img.unbind('load').attr('src','').hide();
});
}
};
})
.filter('imgfilter', ['CatSvc', function(CatSvc){
var catSvc = CatSvc;
return function(input,arg){
var filtered = [];
if (arg == 'spring' || arg == 'summer' || arg == 'fall' || arg == 'winter') {
for (var b in input) {
if (input[b].season.toLowerCase() == arg)
filtered.push(input[b]);
// else
// console.log(input[b]);
}
} else {
for (var a in catSvc[arg]){
for (var b in input) {
if (input[b].id == catSvc[arg][a])
filtered.push(input[b]);
}
}
}
return filtered;
};
}]);