From 7d6e04ac776c5a6a61dce6725e4c1426381ef661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 27 Aug 2014 09:01:50 +0200 Subject: [PATCH] Small fixes to dasheditor and firefox fixes for search --- src/app/controllers/search.js | 11 ++++++++--- src/app/directives/dashEditLink.js | 14 ++++++++++++++ src/app/directives/grafanaVersionCheck.js | 4 ++-- src/app/partials/dasheditor.html | 14 +++++++------- src/css/less/grafana.less | 13 +++++++++---- 5 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/app/controllers/search.js b/src/app/controllers/search.js index 55f44b017ad..19976cda873 100644 --- a/src/app/controllers/search.js +++ b/src/app/controllers/search.js @@ -28,7 +28,7 @@ function (angular, _, config, $) { $scope.keyDown = function (evt) { if (evt.keyCode === 27) { - $element.find('.dropdown-toggle').dropdown('toggle'); + $scope.emitAppEvent('hide-dash-editor'); } if (evt.keyCode === 40) { $scope.selectedIndex++; @@ -134,13 +134,18 @@ function (angular, _, config, $) { module.directive('xngFocus', function() { return function(scope, element, attrs) { - $(element).click(function(e) { + element.click(function(e) { e.stopPropagation(); }); scope.$watch(attrs.xngFocus,function (newValue) { + if (!newValue) { + return; + } setTimeout(function() { - newValue && element.focus(); + element.focus(); + var pos = element.val().length * 2; + element[0].setSelectionRange(pos, pos); }, 200); },true); }; diff --git a/src/app/directives/dashEditLink.js b/src/app/directives/dashEditLink.js index 4b49f0e2456..d772cdaf0b2 100644 --- a/src/app/directives/dashEditLink.js +++ b/src/app/directives/dashEditLink.js @@ -31,6 +31,16 @@ function (angular, $) { var editorScope; var lastEditor; + function hideScrollbars(value) { + if (value) { + document.documentElement.style.overflow = 'hidden'; // firefox, chrome + document.body.scroll = "no"; // ie only + } else { + document.documentElement.style.overflow = 'auto'; + document.body.scroll = "yes"; + } + } + scope.onAppEvent('hide-dash-editor', function() { if (editorScope) { editorScope.dismiss(); @@ -56,8 +66,12 @@ function (angular, $) { elem.empty(); lastEditor = null; editorScope = null; + hideScrollbars(false); }; + // hide page scrollbars while edit pane is visible + hideScrollbars(true); + var src = "'" + payload.src + "'"; var view = $('
'); elem.append(view); diff --git a/src/app/directives/grafanaVersionCheck.js b/src/app/directives/grafanaVersionCheck.js index 185a5f6668b..cce6d2ea816 100644 --- a/src/app/directives/grafanaVersionCheck.js +++ b/src/app/directives/grafanaVersionCheck.js @@ -11,7 +11,7 @@ function (angular) { restrict: 'A', link: function(scope, elem) { if (grafanaVersion[0] === '@') { - return; + // return; } $http({ method: 'GET', url: 'https://grafanarel.s3.amazonaws.com/latest.json' }) @@ -30,4 +30,4 @@ function (angular) { } }; }); -}); \ No newline at end of file +}); diff --git a/src/app/partials/dasheditor.html b/src/app/partials/dasheditor.html index b9b95715b21..8bee04121b4 100644 --- a/src/app/partials/dasheditor.html +++ b/src/app/partials/dasheditor.html @@ -5,7 +5,7 @@
-
+
@@ -42,6 +42,7 @@ Press enter to a add tag
+
@@ -91,13 +92,12 @@