Commit 1e73c03b authored by Julia Radzhabova's avatar Julia Radzhabova

[SSE] Debug focus in menus

parent f415118e
...@@ -46,8 +46,9 @@ function onDropDownKeyDown(e) { ...@@ -46,8 +46,9 @@ function onDropDownKeyDown(e) {
$parent.trigger(beforeEvent); $parent.trigger(beforeEvent);
if ($parent.hasClass('no-stop-propagate') && arguments.length>1 && arguments[1] instanceof jQuery.Event) { if ($parent.hasClass('no-stop-propagate')) {
e = arguments[1]; 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) { if ( /^(38|40|27|13|9)$/.test(e.keyCode) && !e.ctrlKey && !e.altKey) {
patchDropDownKeyDownAdditional.call(this, e); patchDropDownKeyDownAdditional.call(this, e);
e.preventDefault(); e.preventDefault();
...@@ -150,8 +151,8 @@ function patchDropDownKeyDownAdditional(e) { // only for formula menu when typin ...@@ -150,8 +151,8 @@ function patchDropDownKeyDownAdditional(e) { // only for formula menu when typin
var isActive = $parent.hasClass('open') || $parent.hasClass('over'); var isActive = $parent.hasClass('open') || $parent.hasClass('over');
if (!isActive || (isActive && e.keyCode == 27)) { if (!isActive || (isActive && e.keyCode == 27)) {
if (e.which == 27) // if (e.which == 27)
$parent.find('[data-toggle=dropdown]').focus(); // $parent.find('[data-toggle=dropdown]').focus();
return (isActive) ? $this.click() : undefined; return (isActive) ? $this.click() : undefined;
} }
......
...@@ -104,14 +104,14 @@ define([ ...@@ -104,14 +104,14 @@ define([
var me = this; var me = this;
$('#ce-cell-content').keydown(function (e) { $('#ce-cell-content').keydown(function (e) {
if (Common.UI.Keys.ESC === e.keyCode) { 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 || } 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) { Common.UI.Keys.TAB === e.keyCode || Common.UI.Keys.RETURN === e.keyCode) {
var menu = $('#menu-formula-selection'); // for formula menu var menu = $('#menu-formula-selection'); // for formula menu
if (menu.hasClass('open')) if (menu.hasClass('open'))
menu.find('.dropdown-menu').trigger('keydown', e); menu.find('.dropdown-menu').trigger('keydown', e);
if (Common.UI.Keys.RETURN === e.keyCode) // if (Common.UI.Keys.RETURN === e.keyCode)
me.api.asc_enableKeyEvents(true); // me.api.asc_enableKeyEvents(true);
} }
}); });
......
...@@ -1450,31 +1450,31 @@ define([ ...@@ -1450,31 +1450,31 @@ define([
menu.onAfterKeydownMenu = function(e) { menu.onAfterKeydownMenu = function(e) {
if (e.keyCode == Common.UI.Keys.RETURN && (e.ctrlKey || e.altKey)) return; 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; 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]; e = arguments[1];
if (menuContainer.hasClass('open')) { if (menuContainer.hasClass('open')) {
if (e.keyCode == Common.UI.Keys.TAB || e.keyCode == Common.UI.Keys.RETURN && !e.ctrlKey && !e.altKey) if (e.keyCode == Common.UI.Keys.TAB || e.keyCode == Common.UI.Keys.RETURN && !e.ctrlKey && !e.altKey)
li = menuContainer.find('a.focus').closest('li'); li = menuContainer.find('a.focus').closest('li');
else if (e.keyCode == Common.UI.Keys.UP || e.keyCode == Common.UI.Keys.DOWN) { else if (e.keyCode == Common.UI.Keys.UP || e.keyCode == Common.UI.Keys.DOWN) {
var innerEl = menu.cmpEl, var innerEl = menu.cmpEl,
inner_top = innerEl.offset().top, inner_top = innerEl.offset().top,
li_focused = menuContainer.find('a.focus').closest('li'); li_focused = menuContainer.find('a.focus').closest('li');
var li_top = li_focused.offset().top; var li_top = li_focused.offset().top;
if (li_top < inner_top || li_top+li_focused.outerHeight() > inner_top + innerEl.height()) { if (li_top < inner_top || li_top+li_focused.outerHeight() > inner_top + innerEl.height()) {
if (menu.scroller) { if (menu.scroller) {
menu.scroller.scrollTop(innerEl.scrollTop() + li_top - inner_top, 0); menu.scroller.scrollTop(innerEl.scrollTop() + li_top - inner_top, 0);
} else { } else {
innerEl.scrollTop(innerEl.scrollTop() + li_top - inner_top); 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) {
if (li.length>0) li.click(); if (li.length>0) li.click();
...@@ -1505,17 +1505,17 @@ define([ ...@@ -1505,17 +1505,17 @@ define([
menu.scroller.update({alwaysVisibleY: true}); menu.scroller.update({alwaysVisibleY: true});
menu.scroller.scrollTop(0); menu.scroller.scrollTop(0);
} }
if (infocus) { if (infocus)
me.cellEditor.focus(); me.cellEditor.focus();
_.delay(function() { _.delay(function() {
menu.cmpEl.find('li:first a').addClass('focus'); menu.cmpEl.find('li:first a').addClass('focus');
}, 10); }, 10);
} else { // } else {
_.delay(function() { // _.delay(function() {
menu.cmpEl.focus(); // menu.cmpEl.focus();
menu.cmpEl.find('li:first a').focus(); // menu.cmpEl.find('li:first a').focus();
}, 10); // }, 10);
} // }
}, 1); }, 1);
} else { } else {
this.documentHolder.funcMenu.hide(); this.documentHolder.funcMenu.hide();
......
...@@ -148,18 +148,9 @@ define([ ...@@ -148,18 +148,9 @@ define([
var me = this; var me = this;
// Syncronize focus with api // Syncronize focus with api
$(document.body).on('focus', 'input, textarea:not(#ce-cell-content)', function(e) { $(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 (this.isAppDisabled === true) return;
if (e && e.target && !/area_id/.test(e.target.id)) { if (e && e.target && !/area_id/.test(e.target.id)) {
me.api.asc_enableKeyEvents(false);
if (/msg-reply/.test(e.target.className)) if (/msg-reply/.test(e.target.className))
me.dontCloseDummyComment = true; me.dontCloseDummyComment = true;
} }
...@@ -206,20 +197,20 @@ define([ ...@@ -206,20 +197,20 @@ define([
} }
}, },
'dataview:focus': function(e){ 'dataview:focus': function(e){
me.api.asc_enableKeyEvents(false); // me.api.asc_enableKeyEvents(false);
}, },
'dataview:blur': function(e){ 'dataview:blur': function(e){
if (!me.isModalShowed) { if (!me.isModalShowed) {
me.api.asc_enableKeyEvents(true); // me.api.asc_enableKeyEvents(true);
me.onEditComplete(); me.onEditComplete();
} }
}, },
'menu:show': function(e){ 'menu:show': function(e){
me.api.asc_enableKeyEvents(false); // me.api.asc_enableKeyEvents(false);
}, },
'menu:hide': function(e){ 'menu:hide': function(e){
if (!me.isModalShowed) // if (!me.isModalShowed)
me.api.asc_enableKeyEvents(true); // me.api.asc_enableKeyEvents(true);
}, },
'edit:complete': _.bind(this.onEditComplete, this), 'edit:complete': _.bind(this.onEditComplete, this),
'settings:unitschanged':_.bind(this.unitsChanged, this) 'settings:unitschanged':_.bind(this.unitsChanged, this)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment