|
@@ -1,8 +1,9 @@
|
|
|
define([
|
|
define([
|
|
|
'angular',
|
|
'angular',
|
|
|
'lodash',
|
|
'lodash',
|
|
|
|
|
+ 'jquery',
|
|
|
],
|
|
],
|
|
|
-function (angular, _) {
|
|
|
|
|
|
|
+function (angular, _, $) {
|
|
|
'use strict';
|
|
'use strict';
|
|
|
|
|
|
|
|
var module = angular.module('grafana.services');
|
|
var module = angular.module('grafana.services');
|
|
@@ -14,12 +15,16 @@ function (angular, _) {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
this.show = function(options) {
|
|
this.show = function(options) {
|
|
|
- var popover = options.element.data('popover');
|
|
|
|
|
- if (popover) {
|
|
|
|
|
- popover.scope.$destroy();
|
|
|
|
|
- popover.destroy();
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ var popover;
|
|
|
|
|
+
|
|
|
|
|
+ // hide other popovers
|
|
|
|
|
+ $('.popover').each(function() {
|
|
|
|
|
+ popover = $(this).prev().data('popover');
|
|
|
|
|
+ if (popover) {
|
|
|
|
|
+ popover.scope.$destroy();
|
|
|
|
|
+ popover.destroy();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
options.scope.dismiss = function() {
|
|
options.scope.dismiss = function() {
|
|
|
popover = options.element.data('popover');
|
|
popover = options.element.data('popover');
|
|
@@ -30,22 +35,24 @@ function (angular, _) {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
this.getTemplate(options.templateUrl).then(function(result) {
|
|
this.getTemplate(options.templateUrl).then(function(result) {
|
|
|
- var template = _.isString(result) ? result : result.data;
|
|
|
|
|
-
|
|
|
|
|
- options.element.popover({
|
|
|
|
|
- content: template,
|
|
|
|
|
- placement: options.placement || 'bottom',
|
|
|
|
|
- html: true
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- popover = options.element.data('popover');
|
|
|
|
|
- popover.hasContent = function () {
|
|
|
|
|
- return template;
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- popover.toggle();
|
|
|
|
|
- popover.scope = options.scope;
|
|
|
|
|
- $compile(popover.$tip)(popover.scope);
|
|
|
|
|
|
|
+ $timeout(function() {
|
|
|
|
|
+ var template = _.isString(result) ? result : result.data;
|
|
|
|
|
+
|
|
|
|
|
+ options.element.popover({
|
|
|
|
|
+ content: template,
|
|
|
|
|
+ placement: options.placement || 'bottom',
|
|
|
|
|
+ html: true
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ popover = options.element.data('popover');
|
|
|
|
|
+ popover.hasContent = function () {
|
|
|
|
|
+ return template;
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ popover.toggle();
|
|
|
|
|
+ popover.scope = options.scope;
|
|
|
|
|
+ $compile(popover.$tip)(popover.scope);
|
|
|
|
|
+ }, 1);
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|