diff --git a/apps/common/embed/lib/util/utils.js b/apps/common/embed/lib/util/utils.js index 955320044..3b8c9cd5c 100644 --- a/apps/common/embed/lib/util/utils.js +++ b/apps/common/embed/lib/util/utils.js @@ -106,6 +106,21 @@ } } }, + shortcuts: function (options) { + var shortcuts = options; + require([ + 'common/main/lib/core/keymaster' + ], function() { + window.key.filter = function() { + return true; + }; + var shortcut, callback; + for (shortcut in shortcuts) { + callback = shortcuts[shortcut]; + window.key(shortcut, 'all', callback); + } + }); + }, isMac : isMac }; diff --git a/apps/common/main/lib/core/keymaster.js b/apps/common/main/lib/core/keymaster.js index 9cf5a0ee6..2342d0e94 100644 --- a/apps/common/main/lib/core/keymaster.js +++ b/apps/common/main/lib/core/keymaster.js @@ -72,7 +72,7 @@ var key, handler, k, i, modifiersMatch, scope; key = event.keyCode; - if (Common.UI.HintManager && Common.UI.HintManager.isHintVisible()) { + if (Common.UI && Common.UI.HintManager && Common.UI.HintManager.isHintVisible()) { if (key === 112) { Common.UI.HintManager.clearHints(); } else if (key !== 27) { diff --git a/apps/documenteditor/embed/js/ApplicationController.js b/apps/documenteditor/embed/js/ApplicationController.js index ae1d89786..8d7aa7f8a 100644 --- a/apps/documenteditor/embed/js/ApplicationController.js +++ b/apps/documenteditor/embed/js/ApplicationController.js @@ -525,6 +525,14 @@ DE.ApplicationController = new(function(){ common.controller.SearchBar.show(); }); + var shortcuts = { + 'command+f,ctrl+f': function() { + common.controller.SearchBar.show(); + return false; + } + }; + common.utils.shortcuts(shortcuts); + $('#id-btn-zoom-in').on('click', api.zoomIn.bind(this)); $('#id-btn-zoom-out').on('click', api.zoomOut.bind(this)); diff --git a/apps/presentationeditor/embed/js/ApplicationController.js b/apps/presentationeditor/embed/js/ApplicationController.js index 1ef42abb2..e4e35df79 100644 --- a/apps/presentationeditor/embed/js/ApplicationController.js +++ b/apps/presentationeditor/embed/js/ApplicationController.js @@ -375,6 +375,14 @@ PE.ApplicationController = new(function(){ common.controller.SearchBar.show(); }); + /*var shortcuts = { + 'command+f,ctrl+f': function() { + common.controller.SearchBar.show(); + return false; + } + }; + common.utils.shortcuts(shortcuts);*/ + var $pagenum = $('#page-number'); $pagenum.on({ 'keyup': function(e){ diff --git a/apps/spreadsheeteditor/embed/js/ApplicationController.js b/apps/spreadsheeteditor/embed/js/ApplicationController.js index a479d3b58..e9f9bce0f 100644 --- a/apps/spreadsheeteditor/embed/js/ApplicationController.js +++ b/apps/spreadsheeteditor/embed/js/ApplicationController.js @@ -311,6 +311,14 @@ SSE.ApplicationController = new(function(){ common.controller.SearchBar.show(); }); + var shortcuts = { + 'command+f,ctrl+f': function() { + common.controller.SearchBar.show(); + return false; + } + }; + common.utils.shortcuts(shortcuts); + $('#id-btn-zoom-in').on('click', function () { if (api){ var f = Math.floor(api.asc_getZoom() * 10)/10;