-
Notifications
You must be signed in to change notification settings - Fork 3
/
watch-fighters.js
89 lines (79 loc) · 1.91 KB
/
watch-fighters.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
(function () {
"use strict";
angular.module('watchFighters', [])
.directive('setIf', [function () {
return {
transclude: 'element',
priority: 1000,
terminal: true,
restrict: 'A',
compile: function (element, attr, linker) {
return function (scope, iterStartElement, attr) {
iterStartElement[0].doNotMove = true;
var expression = attr.setIf;
var value = scope.$eval(expression);
if (value) {
linker(scope, function (clone) {
iterStartElement.after(clone);
});
}
};
}
};
}])
.directive('setHtml', function() {
return {
restrict: "A",
priority: 100,
link: function($scope, $el, $attr) {
$($el).html($scope.$eval($attr.setHtml));
}
};
})
.directive('setText', function() {
return {
restrict: "A",
priority: 100,
link: function($scope, $el, $attr) {
$($el).text($scope.$eval($attr.setText));
}
};
})
.directive('setClass', function() {
return {
restrict: "A",
priority: 100,
link: function($scope, $el, $attr) {
var classVal = $scope.$eval($attr.setClass);
if (angular.isObject(classVal)) {
for (var key in classVal) {
if (classVal.hasOwnProperty(key) && classVal[key]) {
$el.addClass(key);
}
}
} else {
$el.addClass(classVal);
}
}
};
})
.directive('setTitle', function() {
return {
restrict: "A",
priority: 100,
link: function($scope, $el, $attr) {
$($el).attr('title', $scope.$eval($attr.setTitle));
}
};
})
.directive('setHref', function() {
return {
restrict: "A",
priority: 100,
link: function($scope, $el, $attr) {
$($el).attr('href', $scope.$eval($attr.setHref));
}
};
})
;
})();