From e1c0b951aa9c4d27f1dc139f98443503c940c9c7 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 13 Oct 2020 19:15:30 +0300 Subject: [PATCH] [DE] Use focus manager for advanced settings --- .../common/main/lib/component/FocusManager.js | 6 +- .../main/app/view/BookmarksDialog.js | 6 ++ .../main/app/view/DropcapSettingsAdvanced.js | 20 ++-- .../main/app/view/ImageSettingsAdvanced.js | 99 ++++++++++++++++--- .../app/view/ParagraphSettingsAdvanced.js | 53 ++++++++-- .../main/app/view/TableSettingsAdvanced.js | 76 ++++++++++++-- .../main/app/view/WatermarkSettingsDialog.js | 33 ++++++- 7 files changed, 245 insertions(+), 48 deletions(-) diff --git a/apps/common/main/lib/component/FocusManager.js b/apps/common/main/lib/component/FocusManager.js index c1b361446..d5c670f8c 100644 --- a/apps/common/main/lib/component/FocusManager.js +++ b/apps/common/main/lib/component/FocusManager.js @@ -59,7 +59,7 @@ Common.UI.FocusManager = new(function() { fields.forEach(function(field) { if (field) { var item = (field.cmp && typeof field.selector == 'string') ? field : {cmp: field, selector: '.form-control'}; - item.el = (item.cmp.$el || $(item.cmp.el)).find(item.selector).addBack().filter(item.selector); + item.el = (item.cmp.$el || $(item.cmp.el || item.cmp)).find(item.selector).addBack().filter(item.selector); item.el && item.el.attr && item.el.attr('tabindex', _tabindex.toString()); arr.push(item); } @@ -77,7 +77,7 @@ Common.UI.FocusManager = new(function() { for (var i=0; i=0; i--) { var field = fields[i]; if ((field.cmp.isVisible ? field.cmp.isVisible() : field.cmp.is(':visible')) && !(field.cmp.isDisabled && field.cmp.isDisabled())) { - var el = (field.selector) ? (field.cmp.$el || $(field.cmp.el)).find(field.selector).addBack().filter(field.selector) : field.el; + var el = (field.selector) ? (field.cmp.$el || $(field.cmp.el || field.cmp)).find(field.selector).addBack().filter(field.selector) : field.el; el.focus(); break; } diff --git a/apps/documenteditor/main/app/view/BookmarksDialog.js b/apps/documenteditor/main/app/view/BookmarksDialog.js index 45b0db979..f051b9ab7 100644 --- a/apps/documenteditor/main/app/view/BookmarksDialog.js +++ b/apps/documenteditor/main/app/view/BookmarksDialog.js @@ -173,6 +173,7 @@ define([ this.bookmarksList = new Common.UI.ListView({ el: $('#bookmarks-list', this.$window), store: new Common.UI.DataViewStore(), + tabindex: 1, itemTemplate: _.template('
<%= value %>
') }); this.bookmarksList.store.comparator = function(rec) { @@ -247,6 +248,10 @@ define([ this.afterRender(); }, + getFocusedComponents: function() { + return [this.txtName, {cmp: this.bookmarksList, selector: '.listview'}]; + }, + afterRender: function() { this._setDefaults(this.props); var me = this; @@ -349,6 +354,7 @@ define([ var rec = this.bookmarksList.store.findWhere({value: this.txtName.getValue()}); this.bookmarksList.selectRecord(rec); this.bookmarksList.scrollToRecord(rec); + this.txtName.focus(); }, onDblClickBookmark: function(listView, itemView, record) { diff --git a/apps/documenteditor/main/app/view/DropcapSettingsAdvanced.js b/apps/documenteditor/main/app/view/DropcapSettingsAdvanced.js index a27d73ab9..b11b9e374 100644 --- a/apps/documenteditor/main/app/view/DropcapSettingsAdvanced.js +++ b/apps/documenteditor/main/app/view/DropcapSettingsAdvanced.js @@ -62,8 +62,7 @@ define([ contentWidth: 320, height : 380, toggleGroup : 'dropcap-adv-settings-group', - storageName: 'de-dropcap-settings-adv-category', - focusManager: true + storageName: 'de-dropcap-settings-adv-category' }, initialize : function(options) { @@ -641,15 +640,6 @@ define([ this.on('show', _.bind(this.onShowDialog, this)); this.afterRender(); - - // 0 tab - this.focusManager.add([this.cmbWidth, this.spnWidth, this.cmbHeight, this.spnHeight, this.cmbHAlign, this.cmbHRelative, this.spnX, - this.cmbVAlign, this.cmbVRelative, this.spnY], '.form-control'); - // 1 tab - this.focusManager.add([this.cmbFonts, this.spnRowHeight, this.numDistance], '.form-control'); - - // 3 tab - this.focusManager.add([this.spnMarginTop, this.spnMarginLeft, this.spnMarginBottom, this.spnMarginRight], '.form-control'); }, afterRender: function() { @@ -705,6 +695,14 @@ define([ } }, + getFocusedComponents: function() { + return [ + this.cmbWidth, this.spnWidth, this.cmbHeight, this.spnHeight, this.cmbHAlign, this.cmbHRelative, this.spnX, this.cmbVAlign, this.cmbVRelative, this.spnY, // 0 tab + this.cmbFonts, this.spnRowHeight, this.numDistance, // 1 tab + this.spnMarginTop, this.spnMarginLeft, this.spnMarginBottom, this.spnMarginRight // 3 tab + ]; + }, + onCategoryClick: function(btn, index) { Common.Views.AdvancedSettingsWindow.prototype.onCategoryClick.call(this, btn, index); diff --git a/apps/documenteditor/main/app/view/ImageSettingsAdvanced.js b/apps/documenteditor/main/app/view/ImageSettingsAdvanced.js index 53ba0cbfa..d1b1a67dc 100644 --- a/apps/documenteditor/main/app/view/ImageSettingsAdvanced.js +++ b/apps/documenteditor/main/app/view/ImageSettingsAdvanced.js @@ -351,7 +351,8 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat cls: 'input-group-nr', menuStyle: 'min-width: 115px;', editable: false, - data: this._arrHRelativePc + data: this._arrHRelativePc, + takeFocusOnClose: true }); this.cmbWidthPc.setDisabled(true); this.cmbWidthPc.setValue(this._state.ShapeWidthPcFrom); @@ -369,7 +370,8 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat cls: 'input-group-nr', menuStyle: 'min-width: 115px;', editable: false, - data: this._arrVRelativePc + data: this._arrVRelativePc, + takeFocusOnClose: true }); this.cmbHeightPc.setDisabled(true); this.cmbHeightPc.setValue(this._state.ShapeHeightPcFrom); @@ -622,7 +624,8 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat cls: 'input-group-nr', menuStyle: 'min-width: 115px;', editable: false, - data: this._arrHAlign + data: this._arrHAlign, + takeFocusOnClose: true }); this.cmbHAlign.setValue(this._state.HAlignType); this.cmbHAlign.on('selected', _.bind(this.onHAlignSelect, this)); @@ -641,7 +644,8 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat cls: 'input-group-nr', menuStyle: 'min-width: 115px;', editable: false, - data: this._arrHRelative + data: this._arrHRelative, + takeFocusOnClose: true }); this.cmbHRelative.setValue(this._state.HAlignFrom); this.cmbHRelative.on('selected', _.bind(this.onHRelativeSelect, this)); @@ -651,7 +655,8 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat cls: 'input-group-nr', menuStyle: 'min-width: 115px;', editable: false, - data: this._arrHRelative + data: this._arrHRelative, + takeFocusOnClose: true }); this.cmbHPosition.setDisabled(true); this.cmbHPosition.setValue(this._state.HPositionFrom); @@ -686,7 +691,8 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat cls: 'input-group-nr', menuStyle: 'min-width: 115px;', editable: false, - data: this._arrHRelativePc + data: this._arrHRelativePc, + takeFocusOnClose: true }); this.cmbHPositionPc.setDisabled(true); this.cmbHPositionPc.setValue(this._state.HPositionPcFrom); @@ -704,7 +710,8 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat cls: 'input-group-nr', menuStyle: 'min-width: 115px;', editable: false, - data: this._arrVAlign + data: this._arrVAlign, + takeFocusOnClose: true }); this.cmbVAlign.setValue(this._state.VAlignType); this.cmbVAlign.on('selected', _.bind(this.onVAlignSelect, this)); @@ -723,7 +730,8 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat cls: 'input-group-nr', menuStyle: 'min-width: 115px;', editable: false, - data: this._arrVRelative + data: this._arrVRelative, + takeFocusOnClose: true }); this.cmbVRelative.setValue(this._state.VAlignFrom); this.cmbVRelative.on('selected', _.bind(this.onVRelativeSelect, this)); @@ -733,7 +741,8 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat cls: 'input-group-nr', menuStyle: 'min-width: 115px;', editable: false, - data: this._arrVRelative + data: this._arrVRelative, + takeFocusOnClose: true }); this.cmbVPosition.setDisabled(true); this.cmbVPosition.setValue(this._state.VPositionFrom); @@ -768,7 +777,8 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat cls: 'input-group-nr', menuStyle: 'min-width: 115px;', editable: false, - data: this._arrVRelativePc + data: this._arrVRelativePc, + takeFocusOnClose: true }); this.cmbVPositionPc.setDisabled(true); this.cmbVPositionPc.setValue(this._state.VPositionPcFrom); @@ -936,7 +946,8 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat cls: 'input-group-nr', menuStyle: 'min-width: 100px;', editable: false, - data: this._arrCapType + data: this._arrCapType, + takeFocusOnClose: true }); this.cmbCapType.setValue(Asc.c_oAscLineCapType.Flat); this.cmbCapType.on('selected', _.bind(function(combo, record){ @@ -958,7 +969,8 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat cls: 'input-group-nr', menuStyle: 'min-width: 100px;', editable: false, - data: this._arrJoinType + data: this._arrJoinType, + takeFocusOnClose: true }); this.cmbJoinType.setValue(Asc.c_oAscLineJoinType.Round); this.cmbJoinType.on('selected', _.bind(function(combo, record){ @@ -1132,6 +1144,59 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat this.afterRender(); }, + getFocusedComponents: function() { + return [ + this.spnWidth, this.spnHeight, // 0 tab + this.spnShapeWidth , this.spnShapeWidthPc, this.cmbWidthPc, this.spnShapeHeight, this.spnShapeHeightPc, this.cmbHeightPc, // 1 tab + this.spnAngle, // 2 tab + this.spnTop, this.spnLeft, this.spnBottom, this.spnRight, // 3 tab + this.cmbHAlign , this.cmbHRelative, this.spnX, this.cmbHPosition, this.spnXPc, this.cmbHPositionPc, + this.cmbVAlign , this.cmbVRelative, this.spnY, this.cmbVPosition, this.spnYPc, this.cmbVPositionPc, // 4 tab + this.cmbCapType, this.cmbJoinType, // 5 tab + this.spnMarginTop, this.spnMarginLeft, this.spnMarginBottom, this.spnMarginRight, // 6 tab + this.inputAltTitle, this.textareaAltDescription // 7 tab + ]; + }, + + onCategoryClick: function(btn, index) { + Common.Views.AdvancedSettingsWindow.prototype.onCategoryClick.call(this, btn, index); + + var me = this; + setTimeout(function(){ + switch (index) { + case 0: + me.spnWidth.focus(); + break; + case 1: + me.spnShapeWidth.focus(); + break; + case 2: + me.spnAngle.focus(); + break; + case 3: + me.spnTop.focus(); + break; + case 4: + if (!me.cmbHAlign.isDisabled()) + me.cmbHAlign.focus(); + else if (!me.spnX.isDisabled()) + me.spnX.focus(); + else + me.spnXPc.focus(); + break; + case 5: + me.cmbCapType.focus(); + break; + case 6: + me.spnMarginTop.focus(); + break; + case 7: + me.inputAltTitle.focus(); + break; + } + }, 10); + }, + afterRender: function() { this.updateMetricUnit(); this._setDefaults(this._originalProps); @@ -1714,6 +1779,7 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat } if (newValue) { this.cmbHAlign.setDisabled(false); + this.cmbHAlign.focus(); this.cmbHRelative.setDisabled(false); this.spnX.setDisabled(true); this.cmbHPosition.setDisabled(true); @@ -1738,6 +1804,7 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat this.cmbHAlign.setDisabled(true); this.cmbHRelative.setDisabled(true); this.spnX.setDisabled(false); + this.spnX.focus(); this.cmbHPosition.setDisabled(false); this.spnXPc.setDisabled(true); this.cmbHPositionPc.setDisabled(true); @@ -1762,6 +1829,7 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat this.spnX.setDisabled(true); this.cmbHPosition.setDisabled(true); this.spnXPc.setDisabled(false); + this.spnXPc.focus(); this.cmbHPositionPc.setDisabled(false); } }, @@ -1780,6 +1848,7 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat } if (newValue) { this.cmbVAlign.setDisabled(false); + this.cmbVAlign.focus(); this.cmbVRelative.setDisabled(false); this.spnY.setDisabled(true); this.cmbVPosition.setDisabled(true); @@ -1806,6 +1875,7 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat this.cmbVAlign.setDisabled(true); this.cmbVRelative.setDisabled(true); this.spnY.setDisabled(false); + this.spnY.focus(); this.cmbVPosition.setDisabled(false); this.chMove.setValue(this._state.VPositionFrom==Asc.c_oAscRelativeFromV.Line || this._state.VPositionFrom==Asc.c_oAscRelativeFromV.Paragraph, true); this.chMove.setDisabled(false); @@ -1834,6 +1904,7 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat this.chMove.setValue(false, true); this.chMove.setDisabled(true); this.spnYPc.setDisabled(false); + this.spnYPc.focus(); this.cmbVPositionPc.setDisabled(false); } }, @@ -1850,6 +1921,7 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat this.cmbWidthPc.setDisabled(true); this.spnShapeWidthPc.setDisabled(true); this.spnShapeWidth.setDisabled(false); + this.spnShapeWidth.focus(); } }, @@ -1867,6 +1939,7 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat this.chRatio.setDisabled(true); this.cmbWidthPc.setDisabled(false); this.spnShapeWidthPc.setDisabled(false); + this.spnShapeWidthPc.focus(); this.spnShapeWidth.setDisabled(true); } }, @@ -1883,6 +1956,7 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat this.cmbHeightPc.setDisabled(true); this.spnShapeHeightPc.setDisabled(true); this.spnShapeHeight.setDisabled(false); + this.spnShapeHeight.focus(); } }, @@ -1900,6 +1974,7 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat this.chRatio.setDisabled(true); this.cmbHeightPc.setDisabled(false); this.spnShapeHeightPc.setDisabled(false); + this.spnShapeHeightPc.focus(); this.spnShapeHeight.setDisabled(true); } }, diff --git a/apps/documenteditor/main/app/view/ParagraphSettingsAdvanced.js b/apps/documenteditor/main/app/view/ParagraphSettingsAdvanced.js index 05cb13442..73ed8ec9e 100644 --- a/apps/documenteditor/main/app/view/ParagraphSettingsAdvanced.js +++ b/apps/documenteditor/main/app/view/ParagraphSettingsAdvanced.js @@ -237,7 +237,8 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem editable: false, data: this._arrLineRule, style: 'width: 85px;', - menuStyle : 'min-width: 85px;' + menuStyle : 'min-width: 85px;', + takeFocusOnClose: true }); this.cmbLineRule.setValue(this.CurLineRuleIdx); this.cmbLineRule.on('selected', _.bind(this.onLineRuleSelect, this)); @@ -265,7 +266,8 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem editable: false, data: this._arrSpecial, style: 'width: 85px;', - menuStyle : 'min-width: 85px;' + menuStyle : 'min-width: 85px;', + takeFocusOnClose: true }); this.cmbSpecial.setValue(''); this.cmbSpecial.on('selected', _.bind(this.onSpecialSelect, this)); @@ -289,7 +291,8 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem editable: false, data: this._arrTextAlignment, style: 'width: 173px;', - menuStyle : 'min-width: 173px;' + menuStyle : 'min-width: 173px;', + takeFocusOnClose: true }); this.cmbTextAlignment.setValue(''); @@ -299,7 +302,8 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem editable: false, data: this._arrOutlinelevel, style: 'width: 174px;', - menuStyle : 'min-width: 174px;' + menuStyle : 'min-width: 174px;', + takeFocusOnClose: true }); this.cmbOutlinelevel.setValue(-1); this.cmbOutlinelevel.on('selected', _.bind(this.onOutlinelevelSelect, this)); @@ -528,7 +532,8 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem '
<%= displayTabAlign %>
', '
<%= displayTabLeader %>
', '' - ].join('')) + ].join('')), + tabindex: 1 }); this.tabList.store.comparator = function(rec) { return rec.get("tabPos"); @@ -549,7 +554,8 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem menuStyle : 'min-width: 108px;', editable : false, cls : 'input-group-nr', - data : this._arrTabAlign + data : this._arrTabAlign, + takeFocusOnClose: true }); this.cmbAlign.setValue(Asc.c_oAscTabType.Left); @@ -559,7 +565,8 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem menuStyle : 'min-width: 108px;', editable : false, cls : 'input-group-nr', - data : this._arrTabLeader + data : this._arrTabLeader, + takeFocusOnClose: true }); this.cmbLeader.setValue(Asc.c_oAscTabLeader.None); @@ -656,6 +663,38 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem this.afterRender(); }, + getFocusedComponents: function() { + return [ + this.cmbTextAlignment, this.cmbOutlinelevel, this.numIndentsLeft, this.numIndentsRight, this.cmbSpecial, this.numSpecialBy, + this.numSpacingBefore, this.numSpacingAfter, this.cmbLineRule, this.numLineHeight, // 0 tab + this.numSpacing, this.numPosition, // 3 tab + this.numDefaultTab, this.numTab, this.cmbAlign, this.cmbLeader, {cmp: this.tabList, selector: '.listview'}, // 4 tab + this.spnMarginTop, this.spnMarginLeft, this.spnMarginBottom, this.spnMarginRight // 5 tab + ]; + }, + + onCategoryClick: function(btn, index) { + Common.Views.AdvancedSettingsWindow.prototype.onCategoryClick.call(this, btn, index); + + var me = this; + setTimeout(function(){ + switch (index) { + case 0: + me.cmbTextAlignment.focus(); + break; + case 3: + me.numSpacing.focus(); + break; + case 4: + me.numDefaultTab.focus(); + break; + case 5: + me.spnMarginTop.focus(); + break; + } + }, 10); + }, + getSettings: function() { if ( this.ChangedBorders === null ) { this._changedProps.put_Borders(this.Borders); diff --git a/apps/documenteditor/main/app/view/TableSettingsAdvanced.js b/apps/documenteditor/main/app/view/TableSettingsAdvanced.js index 770309761..1eac6b73c 100644 --- a/apps/documenteditor/main/app/view/TableSettingsAdvanced.js +++ b/apps/documenteditor/main/app/view/TableSettingsAdvanced.js @@ -182,7 +182,8 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat data : [ { value: 0, displayValue: (currmetric == Common.Utils.Metric.c_MetricUnits.pt) ? this.txtPt : ((currmetric == Common.Utils.Metric.c_MetricUnits.inch) ? this.txtInch : this.txtCm) }, { value: 1, displayValue: this.txtPercent } - ] + ], + takeFocusOnClose: true }); this.cmbUnit.on('selected', _.bind(function(combo, record) { if (this._changedProps) { @@ -475,7 +476,8 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat data : [ { value: 0, displayValue: (currmetric == Common.Utils.Metric.c_MetricUnits.pt) ? this.txtPt : ((currmetric == Common.Utils.Metric.c_MetricUnits.inch) ? this.txtInch : this.txtCm) }, { value: 1, displayValue: this.txtPercent } - ] + ], + takeFocusOnClose: true }); this.cmbPrefWidthUnit.on('selected', _.bind(function(combo, record) { if (this._changedProps) { @@ -736,7 +738,8 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat cls: 'input-group-nr', menuStyle: 'min-width: 115px;', editable: false, - data: this._arrHAlign + data: this._arrHAlign, + takeFocusOnClose: true }); this.cmbHAlign.setValue(this._state.HAlignType); this.cmbHAlign.on('selected', _.bind(this.onHAlignSelect, this)); @@ -752,7 +755,8 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat cls: 'input-group-nr', menuStyle: 'min-width: 115px;', editable: false, - data: this._arrHRelative + data: this._arrHRelative, + takeFocusOnClose: true }); this.cmbHRelative.setValue(this._state.HAlignFrom); this.cmbHRelative.on('selected', _.bind(this.onHRelativeSelect, this)); @@ -762,7 +766,8 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat cls: 'input-group-nr', menuStyle: 'min-width: 115px;', editable: false, - data: this._arrHRelative + data: this._arrHRelative, + takeFocusOnClose: true }); this.cmbHPosition.setDisabled(true); this.cmbHPosition.setValue(this._state.HPositionFrom); @@ -780,7 +785,8 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat cls: 'input-group-nr', menuStyle: 'min-width: 115px;', editable: false, - data: this._arrVAlign + data: this._arrVAlign, + takeFocusOnClose: true }); this.cmbVAlign.setValue(this._state.VAlignType); this.cmbVAlign.on('selected', _.bind(this.onVAlignSelect, this)); @@ -796,7 +802,8 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat cls: 'input-group-nr', menuStyle: 'min-width: 115px;', editable: false, - data: this._arrVRelative + data: this._arrVRelative, + takeFocusOnClose: true }); this.cmbVRelative.setValue(this._state.VAlignFrom); this.cmbVRelative.on('selected', _.bind(this.onVRelativeSelect, this)); @@ -806,7 +813,8 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat cls: 'input-group-nr', menuStyle: 'min-width: 115px;', editable: false, - data: this._arrVRelative + data: this._arrVRelative, + takeFocusOnClose: true }); this.cmbVPosition.setDisabled(true); this.cmbVPosition.setValue(this._state.VPositionFrom); @@ -998,11 +1006,53 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat this.afterRender(); }, + getFocusedComponents: function() { + return [ + this.nfWidth, this.cmbUnit, this.spnTableMarginTop, this.spnTableMarginLeft, this.spnTableMarginBottom, this.spnTableMarginRight, this.nfSpacing, // 0 tab + this.nfPrefWidth, this.cmbPrefWidthUnit, this.spnMarginTop, this.spnMarginLeft, this.spnMarginBottom, this.spnMarginRight, // 1 tab + this.cmbHAlign , this.cmbHRelative, this.spnX, this.cmbHPosition, + this.cmbVAlign , this.cmbVRelative, this.spnY, this.cmbVPosition, // 3 tab + this.spnIndentLeft, this.spnDistanceTop, this.spnDistanceLeft, this.spnDistanceBottom, this.spnDistanceRight, // 4 tab + this.inputAltTitle, this.textareaAltDescription // 5 tab + ]; + }, + onCategoryClick: function(btn, index) { Common.Views.AdvancedSettingsWindow.prototype.onCategoryClick.call(this, btn, index); - if (index==1) - this.onCellCategoryClick(btn); + var me = this; + setTimeout(function(){ + switch (index) { + case 0: + if (!me.nfWidth.isDisabled()) + me.nfWidth.focus(); + else + me.spnTableMarginTop.focus(); + break; + case 1: + me.onCellCategoryClick(btn); + if (!me.nfPrefWidth.isDisabled()) + me.nfPrefWidth.focus(); + else if (!me.spnMarginTop.isDisabled()) + me.spnMarginTop.focus(); + break; + case 3: + if (!me.cmbHAlign.isDisabled()) + me.cmbHAlign.focus(); + else + me.spnX.focus(); + break; + case 4: + if (me.spnIndentLeft.isVisible()) + me.spnIndentLeft.focus(); + else + me.spnDistanceTop.focus(); + break; + case 5: + me.inputAltTitle.focus(); + break; + } + }, 10); }, afterRender: function() { @@ -1444,6 +1494,7 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat this.spnIndentLeft.setDisabled(!this.btnAlignLeft.pressed); this._changedProps.put_TableIndent(Common.Utils.Metric.fnRecalcToMM(this.spnIndentLeft.getNumberValue())); } + !this.spnIndentLeft.isDisabled() && this.spnIndentLeft.focus(); }, onBtnFlowWrapClick: function(btn, e) { @@ -1473,6 +1524,7 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat this.radioHPosition.setValue(true); } } + this.spnDistanceTop.focus(); }, onHAlignSelect: function(combo, record){ @@ -1572,6 +1624,7 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat } if (newValue) { this.cmbHAlign.setDisabled(false); + this.cmbHAlign.focus(); this.cmbHRelative.setDisabled(false); this.spnX.setDisabled(true); this.cmbHPosition.setDisabled(true); @@ -1599,6 +1652,7 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat this.cmbHAlign.setDisabled(true); this.cmbHRelative.setDisabled(true); this.spnX.setDisabled(false); + this.spnX.focus(); this.cmbHPosition.setDisabled(false); this._state.alignChanged = false; } @@ -1618,6 +1672,7 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat } if (newValue) { this.cmbVAlign.setDisabled(false); + this.cmbVAlign.focus(); this.cmbVRelative.setDisabled(false); this.spnY.setDisabled(true); this.cmbVPosition.setDisabled(true); @@ -1644,6 +1699,7 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat this.cmbVAlign.setDisabled(true); this.cmbVRelative.setDisabled(true); this.spnY.setDisabled(false); + this.spnY.focus(); this.cmbVPosition.setDisabled(false); this.chMove.setValue(this._state.VPositionFrom==Asc.c_oAscVAnchor.Text, true); } diff --git a/apps/documenteditor/main/app/view/WatermarkSettingsDialog.js b/apps/documenteditor/main/app/view/WatermarkSettingsDialog.js index a1a3ef401..730107a61 100644 --- a/apps/documenteditor/main/app/view/WatermarkSettingsDialog.js +++ b/apps/documenteditor/main/app/view/WatermarkSettingsDialog.js @@ -148,6 +148,7 @@ define(['text!documenteditor/main/app/template/WatermarkSettings.template', // disable text this.props.put_Type(Asc.c_oAscWatermarkType.Image); this.disableControls(Asc.c_oAscWatermarkType.Image); + this.focusControls(); } }, this)); @@ -162,6 +163,7 @@ define(['text!documenteditor/main/app/template/WatermarkSettings.template', // disable image this.props.put_Type(Asc.c_oAscWatermarkType.Text); this.disableControls(Asc.c_oAscWatermarkType.Text); + this.focusControls(); } }, this)); @@ -198,7 +200,8 @@ define(['text!documenteditor/main/app/template/WatermarkSettings.template', el : $('#watermark-combo-scale'), cls : 'input-group-nr', menuStyle : 'min-width: 142px;', - data : this._arrScale + data : this._arrScale, + takeFocusOnClose: true }).on('selected', _.bind(function(combo, record) { }, this)); this.cmbScale.setValue(this._arrScale[0].value); @@ -211,7 +214,8 @@ define(['text!documenteditor/main/app/template/WatermarkSettings.template', editable : false, menuStyle : 'min-width: 100%;max-height: 210px;', scrollAlwaysVisible: true, - data : [] + data : [], + takeFocusOnClose: true }).on('selected', _.bind(this.onSelectLang, this)); this.cmbLang.setValue(Common.util.LanguageInfo.getLocalLanguageName(9)[1]);//en this.textControls.push(this.cmbLang); @@ -222,7 +226,8 @@ define(['text!documenteditor/main/app/template/WatermarkSettings.template', menuStyle : 'min-width: 100%;max-height: 210px;', scrollAlwaysVisible: true, displayField: 'value', - data : [{value: "ASAP"}, {value: "CONFIDENTIAL"}, {value: "COPY"}, {value: "DO NOT COPY"}, {value: "DRAFT"}, {value: "ORIGINAL"}, {value: "PERSONAL"}, {value: "SAMPLE"}, {value: "TOP SECRET"}, {value: "URGENT"} ] + data : [{value: "ASAP"}, {value: "CONFIDENTIAL"}, {value: "COPY"}, {value: "DO NOT COPY"}, {value: "DRAFT"}, {value: "ORIGINAL"}, {value: "PERSONAL"}, {value: "SAMPLE"}, {value: "TOP SECRET"}, {value: "URGENT"} ], + takeFocusOnClose: true }).on('selected', _.bind(function(combo, record) { }, this)); this.cmbText.setValue(this.cmbText.options.data[0].value); @@ -236,7 +241,8 @@ define(['text!documenteditor/main/app/template/WatermarkSettings.template', menuStyle : 'min-width: 100%;max-height: 270px;', store : new Common.Collections.Fonts(), recent : 0, - hint : this.tipFontName + hint : this.tipFontName, + takeFocusOnClose: true }).on('selected', _.bind(function(combo, record) { this.fontName = record.name; }, this)); @@ -266,7 +272,8 @@ define(['text!documenteditor/main/app/template/WatermarkSettings.template', menuCls : 'scrollable-menu', menuStyle: 'min-width: 55px;max-height: 270px;', hint: this.tipFontSize, - data: data + data: data, + takeFocusOnClose: true }); this.cmbFontSize.setValue(-1); this.textControls.push(this.cmbFontSize); @@ -376,6 +383,20 @@ define(['text!documenteditor/main/app/template/WatermarkSettings.template', this.afterRender(); }, + getFocusedComponents: function() { + return [ this.cmbLang, this.cmbText, this.cmbFonts, this.cmbFontSize, this.cmbScale ]; + }, + + focusControls: function() { + var me = this; + setTimeout(function(){ + if (!me.cmbLang.isDisabled()) + me.cmbLang.focus(); + else if (!me.cmbScale.isDisabled()) + me.cmbScale.focus(); + }, 10); + }, + onColorSelect: function(picker, color) { var clr_item = this.btnTextColor.menu.$el.find('#watermark-auto-color > a'); clr_item.hasClass('selected') && clr_item.removeClass('selected'); @@ -434,6 +455,8 @@ define(['text!documenteditor/main/app/template/WatermarkSettings.template', show: function() { Common.Views.AdvancedSettingsWindow.prototype.show.apply(this, arguments); + + this.focusControls(); }, loadLanguages: function() {