[DE] Add focus manager

This commit is contained in:
Julia Radzhabova 2020-09-27 00:14:04 +03:00
parent 028029ae8b
commit 3c43f8a8e3
8 changed files with 77 additions and 20 deletions

View file

@ -702,6 +702,10 @@ define([
Common.UI.ComboBox.prototype.selectRecord.call(this, record); Common.UI.ComboBox.prototype.selectRecord.call(this, record);
if (this.options.updateFormControl) if (this.options.updateFormControl)
this.options.updateFormControl.call(this, this._selectedItem); this.options.updateFormControl.call(this, this._selectedItem);
},
focus: function() {
this.cmpEl && this.cmpEl.find('.form-control').focus();
} }
}, Common.UI.ComboBoxCustom || {})); }, Common.UI.ComboBoxCustom || {}));
}); });

View file

@ -52,7 +52,8 @@ define([
style: 'min-width: 230px;', style: 'min-width: 230px;',
cls: 'modal-dlg', cls: 'modal-dlg',
split: false, split: false,
buttons: ['ok', 'cancel'] buttons: ['ok', 'cancel'],
focusManager: true
}, },
initialize : function(options) { initialize : function(options) {
@ -105,6 +106,12 @@ define([
}); });
// this.udColumns.on('entervalue', _.bind(this.onPrimary, this)); // this.udColumns.on('entervalue', _.bind(this.onPrimary, this));
// this.udRows.on('entervalue', _.bind(this.onPrimary, this)); // this.udRows.on('entervalue', _.bind(this.onPrimary, this));
this.focusManager.add([this.udColumns, this.udRows], '.form-control');
var me = this;
setTimeout(function(){
me.udColumns.focus();
}, 100);
}, },
onBtnClick: function(event) { onBtnClick: function(event) {

View file

@ -58,7 +58,8 @@ define([
style: 'min-width: 240px;', style: 'min-width: 240px;',
cls: 'modal-dlg', cls: 'modal-dlg',
split: false, split: false,
buttons: ['ok', 'cancel'] buttons: ['ok', 'cancel'],
focusManager: true
}, },
initialize : function(options) { initialize : function(options) {
@ -155,6 +156,7 @@ define([
el : $('#id-dlg-list-numbering-format'), el : $('#id-dlg-list-numbering-format'),
menuStyle : 'min-width: 100%;max-height: 183px;', menuStyle : 'min-width: 100%;max-height: 183px;',
editable : false, editable : false,
takeFocusOnClose: true,
cls : 'input-group-nr', cls : 'input-group-nr',
data : [ data : [
{ displayValue: this.txtNone, value: -1 }, { displayValue: this.txtNone, value: -1 },
@ -196,6 +198,7 @@ define([
menuStyle : 'min-width: 100%;max-height: 183px;', menuStyle : 'min-width: 100%;max-height: 183px;',
style : "width: 100px;", style : "width: 100px;",
editable : false, editable : false,
takeFocusOnClose: true,
template : _.template(template.join('')), template : _.template(template.join('')),
itemsTemplate: _.template(itemsTemplate.join('')), itemsTemplate: _.template(itemsTemplate.join('')),
data : [ data : [
@ -316,6 +319,8 @@ define([
el.width(Math.max($window.find('.numbering .text').width(), el.width())); el.width(Math.max($window.find('.numbering .text').width(), el.width()));
this.afterRender(); this.afterRender();
this.focusManager.add([this.cmbNumFormat, this.cmbBulletFormat, this.spnSize, this.spnStart], '.form-control');
}, },
afterRender: function() { afterRender: function() {
@ -342,6 +347,13 @@ define([
this.numberingControls.toggleClass('hidden', value==0); this.numberingControls.toggleClass('hidden', value==0);
this.cmbNumFormat.setVisible(value==1); this.cmbNumFormat.setVisible(value==1);
this.cmbBulletFormat.setVisible(value==0); this.cmbBulletFormat.setVisible(value==0);
var me = this;
_.delay(function(){
if (value)
me.cmbNumFormat.focus();
else
me.cmbBulletFormat.focus();
},50);
}, },
_handleInput: function(state) { _handleInput: function(state) {

View file

@ -52,7 +52,8 @@ define([
header: true, header: true,
style: 'min-width: 214px;', style: 'min-width: 214px;',
cls: 'modal-dlg', cls: 'modal-dlg',
buttons: ['ok', 'cancel'] buttons: ['ok', 'cancel'],
focusManager: true
}, },
initialize : function(options) { initialize : function(options) {
@ -85,6 +86,7 @@ define([
style: 'width: 110px;', style: 'width: 110px;',
menuStyle: 'min-width: 110px;', menuStyle: 'min-width: 110px;',
editable: false, editable: false,
takeFocusOnClose: true,
scrollAlwaysVisible: true, scrollAlwaysVisible: true,
data: [ data: [
{ value: 0, displayValue: this.textRow}, { value: 0, displayValue: this.textRow},
@ -126,6 +128,12 @@ define([
var $window = this.getChild(); var $window = this.getChild();
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
this.focusManager.add([this.cmbRowCol, this.spnCount], '.form-control');
var me = this;
setTimeout(function(){
me.spnCount.focus();
}, 100);
}, },
_handleInput: function(state) { _handleInput: function(state) {

View file

@ -50,7 +50,8 @@ define([
header: true, header: true,
style: 'min-width: 216px;', style: 'min-width: 216px;',
cls: 'modal-dlg', cls: 'modal-dlg',
buttons: ['ok', 'cancel'] buttons: ['ok', 'cancel'],
focusManager: true
}, },
initialize : function(options) { initialize : function(options) {
@ -128,6 +129,11 @@ define([
this.getChild().find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); this.getChild().find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
this.updateMetricUnit(); this.updateMetricUnit();
this.focusManager.add([this.spnColumns, this.spnSpacing], '.form-control');
setTimeout(function(){
me.spnColumns.focus();
}, 100);
}, },
_handleInput: function(state) { _handleInput: function(state) {

View file

@ -50,7 +50,8 @@ define([
width: 350, width: 350,
style: 'min-width: 230px;', style: 'min-width: 230px;',
cls: 'modal-dlg', cls: 'modal-dlg',
buttons: ['ok', 'cancel'] buttons: ['ok', 'cancel'],
focusManager: true
}, },
initialize : function (options) { initialize : function (options) {
@ -102,7 +103,9 @@ define([
menuStyle : 'min-width: 100%; max-height: 185px;', menuStyle : 'min-width: 100%; max-height: 185px;',
cls : 'input-group-nr', cls : 'input-group-nr',
editable : false, editable : false,
data : data takeFocusOnClose: true,
data : data,
scrollAlwaysVisible: true
}); });
this.cmbLang.setValue(0x0409); this.cmbLang.setValue(0x0409);
this.cmbLang.on('selected', _.bind(function(combo, record) { this.cmbLang.on('selected', _.bind(function(combo, record) {
@ -120,13 +123,13 @@ define([
this.listFormats = new Common.UI.ListView({ this.listFormats = new Common.UI.ListView({
el: $('#datetime-dlg-format'), el: $('#datetime-dlg-format'),
store: new Common.UI.DataViewStore(), store: new Common.UI.DataViewStore(),
tabindex: 1,
scrollAlwaysVisible: true scrollAlwaysVisible: true
}); });
this.listFormats.on('item:select', _.bind(this.onSelectFormat, this)); this.listFormats.on('item:select', _.bind(this.onSelectFormat, this));
this.listFormats.on('item:dblclick', _.bind(this.onDblClickFormat, this)); this.listFormats.on('item:dblclick', _.bind(this.onDblClickFormat, this));
this.listFormats.on('entervalue', _.bind(this.onPrimary, this)); this.listFormats.on('entervalue', _.bind(this.onPrimary, this));
this.listFormats.$el.find('.listview').focus();
this.btnDefault = new Common.UI.Button({ this.btnDefault = new Common.UI.Button({
el: $('#datetime-dlg-default') el: $('#datetime-dlg-default')
@ -170,6 +173,11 @@ define([
}); });
this._setDefaults(); this._setDefaults();
this.focusManager.add([this.cmbLang, this.listFormats], '.form-control');
setTimeout(function(){
me.cmbLang.focus();
}, 100);
}, },
_setDefaults: function () { _setDefaults: function () {

View file

@ -49,7 +49,8 @@ define([
width: 330, width: 330,
header: false, header: false,
cls: 'modal-dlg', cls: 'modal-dlg',
buttons: ['ok', 'cancel'] buttons: ['ok', 'cancel'],
focusManager: true
}, },
initialize : function(options) { initialize : function(options) {
@ -123,6 +124,8 @@ define([
var $window = this.getChild(); var $window = this.getChild();
$window.find('.btn').on('click', _.bind(this.onBtnClick, this)); $window.find('.btn').on('click', _.bind(this.onBtnClick, this));
this.focusManager.add([this.inputName, this.inputValue], '.form-control');
}, },
show: function() { show: function() {
@ -130,7 +133,7 @@ define([
var me = this; var me = this;
_.delay(function(){ _.delay(function(){
me.inputName.cmpEl.find('input').focus(); me.inputName.focus();
},50); },50);
}, },
@ -147,11 +150,11 @@ define([
if (this.options.handler) { if (this.options.handler) {
if (state == 'ok') { if (state == 'ok') {
if (this.inputName.checkValidate() !== true) { if (this.inputName.checkValidate() !== true) {
this.inputName.cmpEl.find('input').focus(); this.inputName.focus();
return; return;
} }
if (this.inputValue.checkValidate() !== true) { if (this.inputValue.checkValidate() !== true) {
this.inputValue.cmpEl.find('input').focus(); this.inputValue.focus();
return; return;
} }
} }

View file

@ -58,7 +58,8 @@ define([
width: 350, width: 350,
style: 'min-width: 230px;', style: 'min-width: 230px;',
cls: 'modal-dlg', cls: 'modal-dlg',
buttons: ['ok', 'cancel'] buttons: ['ok', 'cancel'],
focusManager: true
}, },
initialize : function(options) { initialize : function(options) {
@ -181,6 +182,10 @@ define([
me.internalList.on('entervalue', _.bind(me.onPrimary, me)); me.internalList.on('entervalue', _.bind(me.onPrimary, me));
me.externalPanel = $window.find('#id-external-link'); me.externalPanel = $window.find('#id-external-link');
me.internalPanel = $window.find('#id-internal-link'); me.internalPanel = $window.find('#id-internal-link');
this.focusManager.add(this.inputUrl, '.form-control');
this.focusManager.add(this.internalList, '.treeview');
this.focusManager.add([this.inputDisplay, this.inputTip], '.form-control');
}, },
ShowHideElem: function(value) { ShowHideElem: function(value) {
@ -269,8 +274,17 @@ define([
} }
var rec = this.internalList.getSelectedRec(); var rec = this.internalList.getSelectedRec();
this.btnOk.setDisabled(!rec || rec.get('level')==0 && rec.get('index')>0); this.btnOk.setDisabled(!rec || rec.get('level')==0 && rec.get('index')>0);
} else var me = this;
_.delay(function(){
me.inputDisplay.focus();
},50);
} else {
this.btnOk.setDisabled($.trim(this.inputUrl.getValue())==''); this.btnOk.setDisabled($.trim(this.inputUrl.getValue())=='');
var me = this;
_.delay(function(){
me.inputUrl.focus();
},50);
}
}, },
onLinkTypeClick: function(type, btn, event) { onLinkTypeClick: function(type, btn, event) {
@ -296,11 +310,6 @@ define([
show: function() { show: function() {
Common.UI.Window.prototype.show.apply(this, arguments); Common.UI.Window.prototype.show.apply(this, arguments);
var me = this;
_.delay(function(){
me.inputUrl.cmpEl.find('input').focus();
},50);
}, },
setSettings: function (props) { setSettings: function (props) {
@ -414,7 +423,7 @@ define([
if (this.btnExternal.isActive()) {//WebLink if (this.btnExternal.isActive()) {//WebLink
if (this.inputUrl.checkValidate() !== true) { if (this.inputUrl.checkValidate() !== true) {
this.isInputFirstChange = true; this.isInputFirstChange = true;
this.inputUrl.cmpEl.find('input').focus(); this.inputUrl.focus();
return; return;
} }
} else { } else {
@ -423,7 +432,7 @@ define([
return; return;
} }
if (this.inputDisplay.checkValidate() !== true) { if (this.inputDisplay.checkValidate() !== true) {
this.inputDisplay.cmpEl.find('input').focus(); this.inputDisplay.focus();
return; return;
} }
(!this._originalProps.get_Bookmark() && !this._originalProps.get_Value()) && Common.Utils.InternalSettings.set("de-settings-link-type", this.btnInternal.isActive()); // save last added hyperlink (!this._originalProps.get_Bookmark() && !this._originalProps.get_Value()) && Common.Utils.InternalSettings.set("de-settings-link-type", this.btnInternal.isActive()); // save last added hyperlink