[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);
if (this.options.updateFormControl)
this.options.updateFormControl.call(this, this._selectedItem);
},
focus: function() {
this.cmpEl && this.cmpEl.find('.form-control').focus();
}
}, Common.UI.ComboBoxCustom || {}));
});

View file

@ -52,7 +52,8 @@ define([
style: 'min-width: 230px;',
cls: 'modal-dlg',
split: false,
buttons: ['ok', 'cancel']
buttons: ['ok', 'cancel'],
focusManager: true
},
initialize : function(options) {
@ -105,6 +106,12 @@ define([
});
// this.udColumns.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) {

View file

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

View file

@ -52,7 +52,8 @@ define([
header: true,
style: 'min-width: 214px;',
cls: 'modal-dlg',
buttons: ['ok', 'cancel']
buttons: ['ok', 'cancel'],
focusManager: true
},
initialize : function(options) {
@ -85,6 +86,7 @@ define([
style: 'width: 110px;',
menuStyle: 'min-width: 110px;',
editable: false,
takeFocusOnClose: true,
scrollAlwaysVisible: true,
data: [
{ value: 0, displayValue: this.textRow},
@ -126,6 +128,12 @@ define([
var $window = this.getChild();
$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) {

View file

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

View file

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

View file

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

View file

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