From 1e73c03ba8a666faf916607a119ebe596a3fcbe8 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 6 Jul 2016 16:15:13 +0300 Subject: [PATCH] [SSE] Debug focus in menus --- apps/common/main/lib/extend/Bootstrap.js | 9 +-- .../main/app/controller/CellEditor.js | 6 +- .../main/app/controller/DocumentHolder.js | 56 +++++++++---------- .../main/app/controller/Main.js | 19 ++----- 4 files changed, 41 insertions(+), 49 deletions(-) diff --git a/apps/common/main/lib/extend/Bootstrap.js b/apps/common/main/lib/extend/Bootstrap.js index 2d137d8f48..3e919d063d 100755 --- a/apps/common/main/lib/extend/Bootstrap.js +++ b/apps/common/main/lib/extend/Bootstrap.js @@ -46,8 +46,9 @@ function onDropDownKeyDown(e) { $parent.trigger(beforeEvent); - if ($parent.hasClass('no-stop-propagate') && arguments.length>1 && arguments[1] instanceof jQuery.Event) { - e = arguments[1]; + if ($parent.hasClass('no-stop-propagate')) { + if (arguments.length>1 && arguments[1] instanceof jQuery.Event) + e = arguments[1]; if ( /^(38|40|27|13|9)$/.test(e.keyCode) && !e.ctrlKey && !e.altKey) { patchDropDownKeyDownAdditional.call(this, e); e.preventDefault(); @@ -150,8 +151,8 @@ function patchDropDownKeyDownAdditional(e) { // only for formula menu when typin var isActive = $parent.hasClass('open') || $parent.hasClass('over'); if (!isActive || (isActive && e.keyCode == 27)) { - if (e.which == 27) - $parent.find('[data-toggle=dropdown]').focus(); +// if (e.which == 27) +// $parent.find('[data-toggle=dropdown]').focus(); return (isActive) ? $this.click() : undefined; } diff --git a/apps/spreadsheeteditor/main/app/controller/CellEditor.js b/apps/spreadsheeteditor/main/app/controller/CellEditor.js index 87902fe9ca..cf9fc9f992 100644 --- a/apps/spreadsheeteditor/main/app/controller/CellEditor.js +++ b/apps/spreadsheeteditor/main/app/controller/CellEditor.js @@ -104,14 +104,14 @@ define([ var me = this; $('#ce-cell-content').keydown(function (e) { if (Common.UI.Keys.ESC === e.keyCode) { - me.api.asc_enableKeyEvents(true); +// me.api.asc_enableKeyEvents(true); } else if (Common.UI.Keys.UP === e.keyCode || Common.UI.Keys.DOWN === e.keyCode || Common.UI.Keys.TAB === e.keyCode || Common.UI.Keys.RETURN === e.keyCode) { var menu = $('#menu-formula-selection'); // for formula menu if (menu.hasClass('open')) menu.find('.dropdown-menu').trigger('keydown', e); - if (Common.UI.Keys.RETURN === e.keyCode) - me.api.asc_enableKeyEvents(true); +// if (Common.UI.Keys.RETURN === e.keyCode) +// me.api.asc_enableKeyEvents(true); } }); diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 34c4bafec2..3c9061db16 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -1450,31 +1450,31 @@ define([ menu.onAfterKeydownMenu = function(e) { if (e.keyCode == Common.UI.Keys.RETURN && (e.ctrlKey || e.altKey)) return; - Common.UI.Menu.prototype.onAfterKeydownMenu.call(menu, e); +// Common.UI.Menu.prototype.onAfterKeydownMenu.call(menu, e); var li; - if (arguments.length>1 && arguments[1] instanceof jQuery.Event) {// when typing in cell editor + if (arguments.length>1 && arguments[1] instanceof jQuery.Event) // when typing in cell editor e = arguments[1]; - if (menuContainer.hasClass('open')) { - if (e.keyCode == Common.UI.Keys.TAB || e.keyCode == Common.UI.Keys.RETURN && !e.ctrlKey && !e.altKey) - li = menuContainer.find('a.focus').closest('li'); - else if (e.keyCode == Common.UI.Keys.UP || e.keyCode == Common.UI.Keys.DOWN) { - var innerEl = menu.cmpEl, - inner_top = innerEl.offset().top, - li_focused = menuContainer.find('a.focus').closest('li'); + if (menuContainer.hasClass('open')) { + if (e.keyCode == Common.UI.Keys.TAB || e.keyCode == Common.UI.Keys.RETURN && !e.ctrlKey && !e.altKey) + li = menuContainer.find('a.focus').closest('li'); + else if (e.keyCode == Common.UI.Keys.UP || e.keyCode == Common.UI.Keys.DOWN) { + var innerEl = menu.cmpEl, + inner_top = innerEl.offset().top, + li_focused = menuContainer.find('a.focus').closest('li'); - var li_top = li_focused.offset().top; - if (li_top < inner_top || li_top+li_focused.outerHeight() > inner_top + innerEl.height()) { - if (menu.scroller) { - menu.scroller.scrollTop(innerEl.scrollTop() + li_top - inner_top, 0); - } else { - innerEl.scrollTop(innerEl.scrollTop() + li_top - inner_top); - } + var li_top = li_focused.offset().top; + if (li_top < inner_top || li_top+li_focused.outerHeight() > inner_top + innerEl.height()) { + if (menu.scroller) { + menu.scroller.scrollTop(innerEl.scrollTop() + li_top - inner_top, 0); + } else { + innerEl.scrollTop(innerEl.scrollTop() + li_top - inner_top); } } } - } else if (e.keyCode == Common.UI.Keys.TAB) - li = $(e.target).closest('li'); + } +// } else if (e.keyCode == Common.UI.Keys.TAB) +// li = $(e.target).closest('li'); if (li) { if (li.length>0) li.click(); @@ -1505,17 +1505,17 @@ define([ menu.scroller.update({alwaysVisibleY: true}); menu.scroller.scrollTop(0); } - if (infocus) { + if (infocus) me.cellEditor.focus(); - _.delay(function() { - menu.cmpEl.find('li:first a').addClass('focus'); - }, 10); - } else { - _.delay(function() { - menu.cmpEl.focus(); - menu.cmpEl.find('li:first a').focus(); - }, 10); - } + _.delay(function() { + menu.cmpEl.find('li:first a').addClass('focus'); + }, 10); +// } else { +// _.delay(function() { +// menu.cmpEl.focus(); +// menu.cmpEl.find('li:first a').focus(); +// }, 10); +// } }, 1); } else { this.documentHolder.funcMenu.hide(); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index fbfed3685e..49932f45a0 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -148,18 +148,9 @@ define([ var me = this; // Syncronize focus with api $(document.body).on('focus', 'input, textarea:not(#ce-cell-content)', function(e) { - - // NOTE: fix double click mozilla copy-paste - - if (e && e.target && (e.target.id === 'clipboard-helper-text')) { - me.api.asc_enableKeyEvents(true); - return; - } - if (this.isAppDisabled === true) return; if (e && e.target && !/area_id/.test(e.target.id)) { - me.api.asc_enableKeyEvents(false); if (/msg-reply/.test(e.target.className)) me.dontCloseDummyComment = true; } @@ -206,20 +197,20 @@ define([ } }, 'dataview:focus': function(e){ - me.api.asc_enableKeyEvents(false); +// me.api.asc_enableKeyEvents(false); }, 'dataview:blur': function(e){ if (!me.isModalShowed) { - me.api.asc_enableKeyEvents(true); +// me.api.asc_enableKeyEvents(true); me.onEditComplete(); } }, 'menu:show': function(e){ - me.api.asc_enableKeyEvents(false); +// me.api.asc_enableKeyEvents(false); }, 'menu:hide': function(e){ - if (!me.isModalShowed) - me.api.asc_enableKeyEvents(true); +// if (!me.isModalShowed) +// me.api.asc_enableKeyEvents(true); }, 'edit:complete': _.bind(this.onEditComplete, this), 'settings:unitschanged':_.bind(this.unitsChanged, this)