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

[SSE] Debug focus in menus

parent f415118e
......@@ -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;
}
......
......@@ -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);
}
});
......
......@@ -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');
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);
}
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);
}
}
}
} 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();
......
......@@ -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)
......
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