Use new focus manager

This commit is contained in:
Julia Radzhabova 2020-10-13 14:30:52 +03:00
parent 198c25e580
commit bf2c9918d3
28 changed files with 148 additions and 108 deletions

View file

@ -58,8 +58,7 @@ define([
}),
header: false,
width: 340,
height: 272,
focusManager: true
height: 272
});
this.hexRe = /\s*#?([0-9a-fA-F][0-9a-fA-F]?)([0-9a-fA-F][0-9a-fA-F]?)([0-9a-fA-F][0-9a-fA-F]?)\s*/;
@ -144,11 +143,13 @@ define([
if (this.color!==undefined)
this.setColor(this.color);
this.focusManager.add([this.spinR, this.spinG, this.spinB], '.form-control');
this.focusManager.add(this.textColor, 'input');
return this;
},
getFocusedComponents: function() {
return [this.spinR, this.spinG, this.spinB, {cmp: this.textColor, selector: 'input'}];
},
onChangeColor: function(o, color) {
this.colorNew.css({'background-color' : color});

View file

@ -58,8 +58,7 @@ define([
style: 'min-width: 240px;',
cls: 'modal-dlg',
split: false,
buttons: ['ok', 'cancel'],
focusManager: true
buttons: ['ok', 'cancel']
},
initialize : function(options) {
@ -319,8 +318,10 @@ 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');
getFocusedComponents: function() {
return [this.cmbNumFormat, this.cmbBulletFormat, this.spnSize, this.spnStart];
},
afterRender: function() {

View file

@ -49,8 +49,7 @@ define([
DE.Views.CaptionDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({
options: {
contentWidth: 351,
height: 350,
focusManager: true
height: 350
},
initialize : function(options) {
@ -344,11 +343,13 @@ define([
this.lblExample = this.$window.find('#caption-label-example');
this.focusManager.add([this.txtCaption, this.cmbPosition, this.cmbLabel, this.cmbNumbering, this.cmbChapter, this.cmbSeparator], '.form-control');
this.afterRender();
},
getFocusedComponents: function() {
return [this.txtCaption, this.cmbPosition, this.cmbLabel, this.cmbNumbering, this.cmbChapter, this.cmbSeparator];
},
afterRender: function() {
this._setDefaults(this.props);

View file

@ -52,8 +52,7 @@ define([
header: true,
style: 'min-width: 214px;',
cls: 'modal-dlg',
buttons: ['ok', 'cancel'],
focusManager: true
buttons: ['ok', 'cancel']
},
initialize : function(options) {
@ -129,13 +128,16 @@ 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);
},
getFocusedComponents: function() {
return [this.cmbRowCol, this.spnCount];
},
_handleInput: function(state) {
if (this.options.handler) {
this.options.handler.call(this, state, this.getSettings());

View file

@ -50,8 +50,7 @@ define([
header: true,
style: 'min-width: 216px;',
cls: 'modal-dlg',
buttons: ['ok', 'cancel'],
focusManager: true
buttons: ['ok', 'cancel']
},
initialize : function(options) {
@ -130,12 +129,15 @@ define([
this.updateMetricUnit();
this.focusManager.add([this.spnColumns, this.spnSpacing], '.form-control');
setTimeout(function(){
me.spnColumns.focus();
}, 100);
},
getFocusedComponents: function() {
return [this.spnColumns, this.spnSpacing];
},
_handleInput: function(state) {
if (this.options.handler) {
this.options.handler.call(this, this, state);

View file

@ -50,8 +50,7 @@ define([
width: 350,
style: 'min-width: 230px;',
cls: 'modal-dlg',
buttons: ['ok', 'cancel'],
focusManager: true
buttons: ['ok', 'cancel']
},
initialize : function (options) {
@ -175,13 +174,15 @@ define([
this._setDefaults();
this.focusManager.add([this.cmbLang], '.form-control');
this.focusManager.add([this.listFormats], '.listview');
setTimeout(function(){
me.cmbLang.focus();
}, 100);
},
getFocusedComponents: function() {
return [this.cmbLang, {cmp: this.listFormats, selector: '.listview'}];
},
_setDefaults: function () {
this.props = new Asc.CAscDateTime();
if (this.lang) {

View file

@ -58,8 +58,7 @@ define([
width: 350,
style: 'min-width: 230px;',
cls: 'modal-dlg',
buttons: ['ok', 'cancel'],
focusManager: true
buttons: ['ok', 'cancel']
},
initialize : function(options) {
@ -183,10 +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');
getFocusedComponents: function() {
return [this.inputUrl, {cmp: this.internalList, selector: '.treeview'}, this.inputDisplay, this.inputTip];
},
ShowHideElem: function(value) {

View file

@ -50,8 +50,7 @@ define([
options: {
contentWidth: 300,
height: 380,
buttons: null,
focusManager: true
buttons: null
},
initialize : function(options) {
@ -283,10 +282,13 @@ define([
this.afterRender();
},
getFocusedComponents: function() {
return [this.cmbFootnote, this.cmbEndnote, this.cmbFormat, this.spnStart, this.cmbNumbering, this.txtCustom, this.cmbApply];
},
afterRender: function() {
this._setDefaults(this.props);
this.focusManager.add([this.cmbFootnote, this.cmbEndnote, this.cmbFormat, this.spnStart, this.cmbNumbering, this.txtCustom, this.cmbApply], '.form-control');
var me = this;
setTimeout(function(){
me.cmbFormat.focus();

View file

@ -50,8 +50,7 @@ define([
style: 'min-width: 404px;',
cls: 'modal-dlg',
id: 'window-page-margins',
buttons: ['ok', 'cancel'],
focusManager: true
buttons: ['ok', 'cancel']
},
initialize : function(options) {
@ -308,13 +307,16 @@ define([
this.updateMetricUnit();
this.focusManager.add([this.spnTop, this.spnBottom, this.spnLeft, this.spnRight, this.spnGutter, this.cmbGutterPosition, this.cmbOrientation, this.cmbMultiplePages], '.form-control');
var me = this;
setTimeout(function(){
me.spnTop.focus();
}, 100);
},
getFocusedComponents: function() {
return [this.spnTop, this.spnBottom, this.spnLeft, this.spnRight, this.spnGutter, this.cmbGutterPosition, this.cmbOrientation, this.cmbMultiplePages];
},
_handleInput: function(state) {
if (this.options.handler) {
if (state == 'ok') {

View file

@ -50,8 +50,7 @@ define([
style: 'min-width: 216px;',
cls: 'modal-dlg',
id: 'window-page-size',
buttons: ['ok', 'cancel'],
focusManager: true
buttons: ['ok', 'cancel']
},
initialize : function(options) {
@ -169,13 +168,16 @@ define([
this.updateMetricUnit();
this.focusManager.add([this.cmbPreset, this.spnWidth, this.spnHeight], '.form-control');
var me = this;
setTimeout(function(){
me.cmbPreset.focus();
}, 100);
},
getFocusedComponents: function() {
return [this.cmbPreset, this.spnWidth, this.spnHeight];
},
_handleInput: function(state) {
if (this.options.handler) {
this.options.handler.call(this, this, state);

View file

@ -48,8 +48,7 @@ define([
height: 196,
style: 'min-width: 230px;',
cls: 'modal-dlg',
buttons: ['ok', 'cancel'],
focusManager: true
buttons: ['ok', 'cancel']
},
initialize : function(options) {
@ -110,8 +109,10 @@ define([
disabled : (this.options.formats.length==0)
});
this.cmbNextStyle.setValue(-1);
},
this.focusManager.add([this.inputTitle, this.cmbNextStyle], '.form-control');
getFocusedComponents: function() {
return [this.inputTitle, this.cmbNextStyle];
},
show: function() {

View file

@ -48,8 +48,7 @@ define([
width: 300,
style: 'min-width: 230px;',
cls: 'modal-dlg',
buttons: ['ok', 'cancel'],
focusManager: true
buttons: ['ok', 'cancel']
},
initialize : function(options) {
@ -164,8 +163,10 @@ define([
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
this.afterRender();
},
this.focusManager.add([this.inputFormula, this.cmbFormat, this.cmbFunction, this.cmbBookmark], '.form-control');
getFocusedComponents: function() {
return [this.inputFormula, this.cmbFormat, this.cmbFunction, this.cmbBookmark];
},
onSelectItem: function(picker, item, record, e){

View file

@ -50,8 +50,7 @@ define([
width: 350,
style: 'min-width: 230px;',
cls: 'modal-dlg',
buttons: ['ok', 'cancel'],
focusManager: true
buttons: ['ok', 'cancel']
},
initialize : function (options) {
@ -175,12 +174,15 @@ define([
this._setDefaults();
this.focusManager.add([this.cmbLang, this.listFormats], '.form-control');
setTimeout(function(){
me.cmbLang.focus();
}, 100);
},
getFocusedComponents: function() {
return [this.cmbLang, {cmp: this.listFormats, selector: '.listview'}];
},
_setDefaults: function () {
this.props = new AscCommonSlide.CAscDateTime();
if (this.lang) {

View file

@ -60,8 +60,7 @@ define([
style: 'min-width: 230px;',
cls: 'modal-dlg',
id: 'window-hyperlink-settings',
buttons: ['ok', 'cancel'],
focusManager: true
buttons: ['ok', 'cancel']
},
initialize : function(options) {
@ -186,10 +185,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');
getFocusedComponents: function() {
return [this.inputUrl, {cmp: this.internalList, selector: '.treeview'}, this.inputDisplay, this.inputTip];
},
setSettings: function (props) {

View file

@ -50,8 +50,7 @@ define([
style: 'min-width: 250px;',
cls: 'modal-dlg',
id: 'window-slide-size-settings',
buttons: ['ok', 'cancel'],
focusManager: true
buttons: ['ok', 'cancel']
},
initialize : function(options) {
@ -204,13 +203,16 @@ define([
this.updateMetricUnit();
this.focusManager.add([this.cmbSlideSize, this.spnWidth, this.spnHeight, this.cmbSlideOrientation], '.form-control');
var me = this;
setTimeout(function(){
me.cmbSlideSize.focus();
}, 100);
},
getFocusedComponents: function() {
return [this.cmbSlideSize, this.spnWidth, this.spnHeight, this.cmbSlideOrientation];
},
_handleInput: function(state) {
if (this.options.handler) {
this.options.handler.call(this, this, state);

View file

@ -47,8 +47,7 @@ define([
options: {
width: 330,
cls: 'modal-dlg',
buttons: ['ok', 'cancel'],
focusManager: true
buttons: ['ok', 'cancel']
},
initialize : function(options) {
@ -96,11 +95,13 @@ define([
var $window = this.getChild();
$window.find('.btn').on('click', _.bind(this.onBtnClick, this));
this.focusManager.add([this.inputDecimalSeparator, this.inputThousandsSeparator], '.form-control');
this.afterRender();
},
getFocusedComponents: function() {
return [this.inputDecimalSeparator, this.inputThousandsSeparator];
},
afterRender: function() {
this._setDefaults(this.props);
},

View file

@ -61,8 +61,7 @@ define([
cls : 'filter-dlg',
contentTemplate : '',
title : t.txtTitle,
items : [],
focusManager: true
items : []
}, options);
this.template = options.template || [
@ -188,9 +187,12 @@ define([
this.$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
this.loadDefaults();
this.focusManager.add([this.cmbCondition1, this.cmbValue1, this.cmbCondition2, this.cmbValue2], '.form-control');
},
getFocusedComponents: function() {
return [this.cmbCondition1, this.cmbValue1, this.cmbCondition2, this.cmbValue2];
},
show: function () {
Common.UI.Window.prototype.show.call(this);
@ -321,8 +323,7 @@ define([
contentTemplate : '',
title : t.txtTitle,
items : [],
buttons: ['ok', 'cancel'],
focusManager: true
buttons: ['ok', 'cancel']
}, options);
this.template = options.template || [
@ -411,8 +412,12 @@ define([
this.$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
this.loadDefaults();
this.focusManager.add([this.cmbType, this.spnCount, this.cmbItem, this.cmbFields], '.form-control');
},
getFocusedComponents: function() {
return [this.cmbType, this.spnCount, this.cmbItem, this.cmbFields];
},
show: function () {
Common.UI.Window.prototype.show.call(this);
@ -530,8 +535,7 @@ define([
cls : 'filter-dlg',
contentTemplate : '',
title : (options.type=='label') ? t.txtTitleLabel : t.txtTitleValue,
items : [],
focusManager: true
items : []
}, options);
this.api = options.api;
@ -651,8 +655,12 @@ define([
this.$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
this.loadDefaults();
this.focusManager.add([this.cmbFields, this.cmbCondition1, this.inputValue, this.inputValue2], '.form-control');
},
getFocusedComponents: function() {
return [this.cmbFields, this.cmbCondition1, this.inputValue, this.inputValue2];
},
show: function () {
Common.UI.Window.prototype.show.call(this);

View file

@ -52,8 +52,7 @@ define([
type: 0, // 0 - category, 1 - series
width : 350,
cls : 'modal-dlg',
buttons: ['ok', 'cancel'],
focusManager: true
buttons: ['ok', 'cancel']
},
initialize : function(options) {
@ -172,12 +171,15 @@ define([
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
this.focusManager.add([me.inputRange1, me.inputRange2, me.inputRange3], '.form-control');
setTimeout(function(){
me.inputRange1.cmpEl.find('input').focus();
}, 10);
},
getFocusedComponents: function() {
return [this.inputRange1, this.inputRange2, this.inputRange3];
},
onPrimary: function() {
this._handleInput('ok');
return false;

View file

@ -48,8 +48,7 @@ define([
SSE.Views.CreatePivotDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({
options: {
contentWidth: 310,
height: 250,
focusManager: true
height: 250
},
initialize : function(options) {
@ -162,11 +161,13 @@ define([
me.txtDestRange.cmpEl.find('input').focus();
});
this.focusManager.add([this.txtSourceRange, this.txtDestRange], '.form-control');
this.afterRender();
},
getFocusedComponents: function() {
return [this.txtSourceRange, this.txtDestRange];
},
afterRender: function() {
this._setDefaults(this.props);

View file

@ -49,8 +49,7 @@ define([
SSE.Views.FormatSettingsDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({
options: {
contentWidth: 284,
height: 340,
focusManager: true
height: 340
},
initialize : function(options) {
@ -249,11 +248,13 @@ define([
this.lblExample = this.$window.find('#format-settings-label-example');
this.focusManager.add([this.cmbFormat, this.spnDecimal, this.cmbSymbols, this.cmbNegative, this.cmbType, this.cmbCode], '.form-control');
this.afterRender();
},
getFocusedComponents: function() {
return [this.cmbFormat, this.spnDecimal, this.cmbSymbols, this.cmbNegative, this.cmbType, this.cmbCode];
},
afterRender: function() {
this._setDefaults(this.props);
var cmp = this.cmbFormat;

View file

@ -63,8 +63,7 @@ define([
contentTemplate : '',
title : t.txtTitle,
items : [],
buttons: null,
focusManager: true
buttons: null
}, options);
this.template = options.template || [
@ -115,7 +114,6 @@ define([
}
me.filterFormulas();
});
this.focusManager.add(this.inputSearch._input);
this.btnOk = new Common.UI.Button({
el: $('#formula-dlg-btn-ok')
@ -125,6 +123,11 @@ define([
this.descLabel = $('#formula-dlg-desc');
this.fillFormulasGroups();
},
getFocusedComponents: function() {
return [this.inputSearch, this.cmbFuncGroup, {cmp: this.cmbListFunctions, selector: '.listview'}];
},
show: function (group) {
if (this.$window) {
var main_width, main_height, top, left, win_height = this.initConfig.height;
@ -249,7 +252,6 @@ define([
takeFocusOnClose: true
});
this.cmbFuncGroup.on('selected', _.bind(this.onSelectGroup, this));
this.focusManager.add(this.cmbFuncGroup, '.form-control');
} else {
this.cmbFuncGroup.setData(groupsListItems);
}
@ -280,8 +282,6 @@ define([
this.cmbListFunctions.onKeyDown = _.bind(this.onKeyDown, this.cmbListFunctions);
this.cmbListFunctions.scrollToRecord = _.bind(this.onScrollToRecordCustom, this.cmbListFunctions);
this.onUpdateFocus();
this.focusManager.add(this.cmbListFunctions, '.listview');
}
if (this.functions) {

View file

@ -55,8 +55,7 @@ define([
width : 350,
style : 'min-width: 230px;',
cls : 'modal-dlg',
buttons: ['ok', 'cancel'],
focusManager: true
buttons: ['ok', 'cancel']
},
initialize : function(options) {
@ -250,10 +249,10 @@ define([
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.inputRange, this.inputDisplay, this.inputTip], '.form-control');
getFocusedComponents: function() {
return [this.inputUrl, {cmp: this.internalList, selector: '.treeview'}, this.inputRange, this.inputDisplay, this.inputTip];
},
show: function() {

View file

@ -52,8 +52,7 @@ define([
options: {
alias: 'NamedRangeEditDlg',
contentWidth: 380,
height: 250,
focusManager: true
height: 250
},
initialize: function (options) {
@ -173,11 +172,13 @@ define([
});
this.txtDataRange.on('button:click', _.bind(this.onSelectData, this));
this.focusManager.add([this.inputName, this.cmbScope, this.txtDataRange], '.form-control');
this.afterRender();
},
getFocusedComponents: function() {
return [this.inputName, this.cmbScope, this.txtDataRange];
},
afterRender: function() {
this._setDefaults(this.props);
this.setTitle((this.isEdit) ? this.txtTitleEdit : this.txtTitleNew);

View file

@ -50,8 +50,7 @@ define([
style: 'min-width: 216px;',
cls: 'modal-dlg',
id: 'window-page-margins',
buttons: ['ok', 'cancel'],
focusManager: true
buttons: ['ok', 'cancel']
},
initialize : function(options) {
@ -147,7 +146,6 @@ define([
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
$window.find('input').on('keypress', _.bind(this.onKeyPress, this));
this.focusManager.add(this.spinners, '.form-control');
var cmp = this.spnTop;
setTimeout(function(){
(cmp.$el || $(cmp.el)).find('.form-control').focus();
@ -156,6 +154,10 @@ define([
this.updateMetricUnit();
},
getFocusedComponents: function() {
return this.spinners;
},
_handleInput: function(state) {
if (this.options.handler)
this.options.handler.call(this, this, state);

View file

@ -52,8 +52,7 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template',
alias: 'PrintSettings',
contentWidth: 280,
height: 575,
buttons: null,
focusManager: true
buttons: null
},
initialize : function(options) {
@ -278,14 +277,17 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template',
this.extended = (value!==null && parseInt(value)==0);
this.handlerShowDetails(this.btnHide);
this.focusManager.add([this.cmbRange, this.cmbSheet, this.cmbPaperSize, this.cmbPaperOrientation, this.cmbLayout, this.txtRangeTop, this.txtRangeLeft,
this.spnMarginTop, this.spnMarginBottom, this.spnMarginLeft, this.spnMarginRight], '.form-control');
var me = this;
setTimeout(function(){
me.cmbRange.focus();
},100);
},
getFocusedComponents: function() {
return [this.cmbRange, this.cmbSheet, this.cmbPaperSize, this.cmbPaperOrientation, this.cmbLayout, this.txtRangeTop, this.txtRangeLeft,
this.spnMarginTop, this.spnMarginBottom, this.spnMarginLeft, this.spnMarginRight];
},
addCustomScale: function (add) {
if (add) {
this.cmbLayout.setData([

View file

@ -50,8 +50,7 @@ define([
style: 'min-width: 216px;',
cls: 'modal-dlg',
id: 'window-page-margins',
buttons: ['ok', 'cancel'],
focusManager: true
buttons: ['ok', 'cancel']
},
initialize : function(options) {
@ -186,12 +185,15 @@ define([
this.setSettings();
this.focusManager.add([this.txtRangeTop, this.txtRangeLeft], '.form-control');
setTimeout(function(){
me.txtRangeTop.focus();
},100);
},
getFocusedComponents: function() {
return [this.txtRangeTop, this.txtRangeLeft];
},
isRangeValid: function() {
if (this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.PrintTitles, this.txtRangeTop.getValue(), false) == Asc.c_oAscError.ID.DataRangeError) {
this.txtRangeTop.focus();

View file

@ -50,8 +50,7 @@ define([
header: true,
style: 'min-width: 215px;',
cls: 'modal-dlg',
buttons: ['ok', 'cancel'],
focusManager: true
buttons: ['ok', 'cancel']
},
initialize : function(options) {
@ -166,8 +165,10 @@ define([
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
this.afterRender();
},
this.focusManager.add([this.cmbScaleWidth, this.cmbScaleHeight, this.spnScale], '.form-control');
getFocusedComponents: function() {
return [this.cmbScaleWidth, this.cmbScaleHeight, this.spnScale];
},
afterRender: function() {

View file

@ -49,8 +49,7 @@ define([
SSE.Views.ValueFieldSettingsDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({
options: {
contentWidth: 284,
height: 220,
focusManager: true
height: 220
},
initialize : function(options) {
@ -194,12 +193,15 @@ define([
this.afterRender();
this.focusManager.add([this.inputCustomName, this.cmbSummarize], '.form-control');
setTimeout(function(){
me.inputCustomName.focus();
},100);
},
getFocusedComponents: function() {
return [this.inputCustomName, this.cmbSummarize];
},
afterRender: function() {
this._setDefaults(this.props);
},