| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- define([
- 'angular',
- 'jquery'
- ],
- function (angular, $) {
- 'use strict';
- angular
- .module('grafana.directives')
- .directive('dashSearchView', function($compile) {
- return {
- restrict: 'A',
- link: function(scope, elem) {
- var editorScope;
- var ignoreHide;
- function showSearch() {
- if (editorScope) {
- editorScope.dismiss();
- return;
- }
- ignoreHide = true;
- editorScope = scope.$new();
- editorScope.dismiss = function() {
- editorScope.$destroy();
- elem.empty();
- elem.unbind();
- editorScope = null;
- };
- var view = $('<search class="search-container" dismiss="dismiss()"></search>');
- elem.append(view);
- $compile(elem.contents())(editorScope);
- setTimeout(function() {
- ignoreHide = false;
- }, 300);
- }
- function hideSearch() {
- if (editorScope && !ignoreHide) {
- editorScope.dismiss();
- }
- }
- scope.onAppEvent('show-dash-search', showSearch);
- scope.onAppEvent('hide-dash-search', hideSearch);
- }
- };
- });
- });
|