forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
popups.js
68 lines (67 loc) · 2.25 KB
/
popups.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
'use strict';
angular.module('openshiftConsole')
// This triggers when an element has either a toggle or data-toggle attribute set on it
.directive('toggle', function() {
return {
restrict: 'A',
scope: {
dynamicContent: '@?'
},
link: function($scope, element, attrs) {
if (attrs) {
switch(attrs.toggle) {
case "popover":
// If dynamic-content attr is set at all, even if it hasn't evaluated to a value
if (attrs.dynamicContent || attrs.dynamicContent === "") {
$scope.$watch('dynamicContent', function() {
$(element)
.attr("data-content", $scope.dynamicContent)
.popover("destroy")
.popover();
});
}
$(element).popover();
break;
case "tooltip":
// If dynamic-content attr is set at all, even if it hasn't evaluated to a value
if (attrs.dynamicContent || attrs.dynamicContent === "") {
$scope.$watch('dynamicContent', function() {
$(element)
.attr("title", $scope.dynamicContent)
.tooltip("destroy")
.tooltip();
});
}
$(element).tooltip();
break;
case "dropdown":
if (attrs.hover === "dropdown") {
$(element).dropdownHover({delay: 200});
$(element).dropdown();
}
break;
}
}
}
};
})
.directive('podWarnings', function(podWarningsFilter) {
return {
restrict:'E',
scope: {
pod: '='
},
link: function($scope, element) {
var warnings = podWarningsFilter($scope.pod);
var content = "";
angular.forEach(warnings, function(warning) {
content += warning.message + "<br>";
});
$('.pficon-warning-triangle-o', element)
.attr("data-content", content)
.popover("destroy")
.popover();
},
templateUrl: 'views/directives/_pod-warnings.html'
};
});