|
|
@@ -8,50 +8,54 @@ function(angular, $) {
|
|
|
|
|
|
var module = angular.module('kibana.services');
|
|
|
|
|
|
- module.service('dashboardKeybindings', function($rootScope, keyboardManager, dashboard) {
|
|
|
+ module.service('dashboardKeybindings', function($rootScope, keyboardManager) {
|
|
|
this.hasRegistered = false;
|
|
|
|
|
|
- this.shortcuts = function() {
|
|
|
- if (this.hasRegistered) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ this.shortcuts = function(scope) {
|
|
|
|
|
|
- this.hasRegistered = true;
|
|
|
-
|
|
|
- $rootScope.$on('panel-fullscreen-enter', function() {
|
|
|
+ scope.onAppEvent('panel-fullscreen-enter', function() {
|
|
|
$rootScope.fullscreen = true;
|
|
|
});
|
|
|
|
|
|
- $rootScope.$on('panel-fullscreen-exit', function() {
|
|
|
+ scope.onAppEvent('panel-fullscreen-exit', function() {
|
|
|
$rootScope.fullscreen = false;
|
|
|
});
|
|
|
|
|
|
- $rootScope.$on('dashboard-saved', function() {
|
|
|
+ scope.onAppEvent('dashboard-saved', function() {
|
|
|
if ($rootScope.fullscreen) {
|
|
|
- $rootScope.$emit('panel-fullscreen-exit');
|
|
|
+ scope.emitAppEvent('panel-fullscreen-exit');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ scope.$on('$destroy', function() {
|
|
|
+ console.log('unbind keyboardManager');
|
|
|
+ keyboardManager.unbind('ctrl+f');
|
|
|
+ keyboardManager.unbind('ctrl+h');
|
|
|
+ keyboardManager.unbind('ctrl+s');
|
|
|
+ keyboardManager.unbind('ctrl+r');
|
|
|
+ keyboardManager.unbind('ctrl+z');
|
|
|
+ keyboardManager.unbind('esc');
|
|
|
+ });
|
|
|
+
|
|
|
keyboardManager.bind('ctrl+f', function(evt) {
|
|
|
- $rootScope.$emit('open-search', evt);
|
|
|
+ scope.emitAppEvent('open-search', evt);
|
|
|
}, { inputDisabled: true });
|
|
|
|
|
|
keyboardManager.bind('ctrl+h', function() {
|
|
|
- var current = dashboard.current.hideControls;
|
|
|
- dashboard.current.hideControls = !current;
|
|
|
- dashboard.current.panel_hints = current;
|
|
|
+ var current = scope.dashboard.hideControls;
|
|
|
+ scope.dashboard.hideControls = !current;
|
|
|
}, { inputDisabled: true });
|
|
|
|
|
|
keyboardManager.bind('ctrl+s', function(evt) {
|
|
|
- $rootScope.$emit('save-dashboard', evt);
|
|
|
+ scope.emitAppEvent('save-dashboard', evt);
|
|
|
}, { inputDisabled: true });
|
|
|
|
|
|
keyboardManager.bind('ctrl+r', function() {
|
|
|
- dashboard.emit_refresh();
|
|
|
+ scope.dashboard.emit_refresh();
|
|
|
}, { inputDisabled: true });
|
|
|
|
|
|
keyboardManager.bind('ctrl+z', function(evt) {
|
|
|
- $rootScope.$emit('zoom-out', evt);
|
|
|
+ scope.emitAppEvent('zoom-out', evt);
|
|
|
}, { inputDisabled: true });
|
|
|
|
|
|
keyboardManager.bind('esc', function() {
|
|
|
@@ -59,7 +63,7 @@ function(angular, $) {
|
|
|
if (popups.length > 0) {
|
|
|
return;
|
|
|
}
|
|
|
- $rootScope.$emit('panel-fullscreen-exit');
|
|
|
+ scope.emitAppEvent('panel-fullscreen-exit');
|
|
|
}, { inputDisabled: true });
|
|
|
};
|
|
|
});
|