diff --git a/apps/documenteditor/main/app/template/TableSettingsAdvanced.template b/apps/documenteditor/main/app/template/TableSettingsAdvanced.template index 0888606d6143a76f1b0201a1696c161e8fa39bcd..3649e21b1f3d5816ebfbbb28739a289d5c6325c2 100644 --- a/apps/documenteditor/main/app/template/TableSettingsAdvanced.template +++ b/apps/documenteditor/main/app/template/TableSettingsAdvanced.template @@ -1,18 +1,23 @@ <div id="id-adv-table-width" class="settings-panel active"> <div class="inner-content"> - <table cols="2" style="width: 100%;"> + <table cols="1" style="width: 100%;"> <tr> <td class="padding-small" width="125px"> <div id="tableadv-checkbox-width"></div> </td> + </tr> + <tr> + <td class="padding-large"> + <div id="tableadv-number-width" style="display: inline-block; margin-right: 10px;"></div> + <div id="tableadv-cmb-unit" style="display: inline-block;"></div> + </td> + </tr> + <tr> <td class="padding-small"> <div id="tableadv-checkbox-spacing"></div> </td> </tr> <tr> - <td class="padding-large"> - <div id="tableadv-number-width"></div> - </td> <td class="padding-large"> <div id="tableadv-number-spacing"></div> </td> diff --git a/apps/documenteditor/main/app/view/DocumentHolder.js b/apps/documenteditor/main/app/view/DocumentHolder.js index c544944439d7e91045e58721ad43b98e104dd9cd..d5e5a0890267f991738f25e313b41904d89a04d2 100644 --- a/apps/documenteditor/main/app/view/DocumentHolder.js +++ b/apps/documenteditor/main/app/view/DocumentHolder.js @@ -2199,6 +2199,7 @@ define([ tableStylerColumns : (elValue.get_CellBorders().get_InsideV()===null && elValue.get_CellSelect()==true) ? 1 : 2, tableProps : elValue, borderProps : me.borderAdvancedProps, + sectionProps : me.api.asc_GetSectionProps(), handler : function(result, value) { if (result == 'ok') { if (me.api) { diff --git a/apps/documenteditor/main/app/view/TableSettings.js b/apps/documenteditor/main/app/view/TableSettings.js index d8522181b6117149ca2e26bd38b24413a1f64d67..4e9a3f68d9d02de3cacd6b3f061f5ed460293362 100644 --- a/apps/documenteditor/main/app/view/TableSettings.js +++ b/apps/documenteditor/main/app/view/TableSettings.js @@ -740,6 +740,7 @@ define([ tableStylerColumns: (elValue.get_CellBorders().get_InsideV()===null && elValue.get_CellSelect()==true) ? 1 : 2, tableProps: elValue, borderProps: me.borderAdvancedProps, + sectionProps: me.api.asc_GetSectionProps(), handler: function(result, value) { if (result == 'ok') { if (me.api) { diff --git a/apps/documenteditor/main/app/view/TableSettingsAdvanced.js b/apps/documenteditor/main/app/view/TableSettingsAdvanced.js index f06a0d721b26a92ecc7be96f206b78dbab1c84f0..d58f311f53626111c92a2780a239f9594bd4af37 100644 --- a/apps/documenteditor/main/app/view/TableSettingsAdvanced.js +++ b/apps/documenteditor/main/app/view/TableSettingsAdvanced.js @@ -91,6 +91,7 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat this.tableStylerRows = this.options.tableStylerRows; this.tableStylerColumns = this.options.tableStylerColumns; this.borderProps = this.options.borderProps; + this.pageWidth = (this.options.sectionProps) ? this.options.sectionProps.get_W() - this.options.sectionProps.get_LeftMargin() - this.options.sectionProps.get_RightMargin() : 210; this._originalProps = new CTableProp(this.options.tableProps); }, @@ -114,9 +115,10 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat this.chWidth.on('change', _.bind(function(field, newValue, oldValue, eOpts){ var value = (newValue=='checked'); this.nfWidth.setDisabled(!value); + this.cmbUnit.setDisabled(!value); if (this._changedProps) { if (value && this.nfWidth.getNumberValue()>0) - this._changedProps.put_Width(Common.Utils.Metric.fnRecalcToMM(this.nfWidth.getNumberValue())); + this._changedProps.put_Width(this.cmbUnit.getValue() ? -field.getNumberValue() : Common.Utils.Metric.fnRecalcToMM(this.nfWidth.getNumberValue())); else this._changedProps.put_Width(null); } @@ -133,9 +135,30 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat }); this.nfWidth.on('change', _.bind(function(field, newValue, oldValue, eOpts){ if (this._changedProps) - this._changedProps.put_Width(Common.Utils.Metric.fnRecalcToMM(field.getNumberValue())); + this._changedProps.put_Width(this.cmbUnit.getValue() ? -field.getNumberValue() : Common.Utils.Metric.fnRecalcToMM(field.getNumberValue())); + }, this)); + + this.cmbUnit = new Common.UI.ComboBox({ + el : $('#tableadv-cmb-unit'), + style : 'width: 85px;', + menuStyle : 'min-width: 85px;', + editable : false, + cls : 'input-group-nr', + data : [ + { value: 0, displayValue: (Common.Utils.Metric.getCurrentMetric() == Common.Utils.Metric.c_MetricUnits['pt']) ? this.txtPt : this.txtCm }, + { value: 1, displayValue: this.txtPercent } + ] + }); + this.cmbUnit.on('selected', _.bind(function(combo, record) { + if (this._changedProps) { + var maxwidth = Common.Utils.Metric.fnRecalcFromMM(558); + this.nfWidth.setDefaultUnit(record.value ? '%' : Common.Utils.Metric.metricName[Common.Utils.Metric.getCurrentMetric()]); + this.nfWidth.setMaxValue(record.value ? parseFloat(100 * maxwidth/this.pageWidth).toFixed(2) : maxwidth); + this.nfWidth.setStep((record.value || Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt) ? 1 : 0.1); + this.nfWidth.setValue((record.value) ? 100*this.nfWidth.getNumberValue()/this.pageWidth : this.pageWidth*this.nfWidth.getNumberValue()/100); + this._changedProps.put_Width(record.value ? -this.nfWidth.getNumberValue() : Common.Utils.Metric.fnRecalcToMM(this.nfWidth.getNumberValue())); + } }, this)); - this.spinners.push(this.nfWidth); this.chAllowSpacing = new Common.UI.CheckBox({ el: $('#tableadv-checkbox-spacing'), @@ -1047,11 +1070,20 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat var value; // main props var TableWidth = props.get_Width(); - if (TableWidth !== null) { - this.nfWidth.setValue(Common.Utils.Metric.fnRecalcFromMM(TableWidth), true); - } + + this.cmbUnit.store.at(0).set('displayValue', (Common.Utils.Metric.getCurrentMetric() == Common.Utils.Metric.c_MetricUnits['pt']) ? this.txtPt : this.txtCm); + this.cmbUnit.setValue(TableWidth<0 ? 1 : 0); + this.nfWidth.setDefaultUnit(TableWidth<0 ? '%' : Common.Utils.Metric.metricName[Common.Utils.Metric.getCurrentMetric()]); + if (TableWidth<0) //% + this.nfWidth.setMaxValue(parseFloat(100 * Common.Utils.Metric.fnRecalcFromMM(558)/this.pageWidth).toFixed(2)); + this.nfWidth.setStep((TableWidth<0 || Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt) ? 1 : 0.1); + if (TableWidth !== null) + this.nfWidth.setValue(TableWidth>0 ? Common.Utils.Metric.fnRecalcFromMM(TableWidth) : -TableWidth , true); + this.chWidth.setValue(TableWidth !== null, true); - this.nfWidth.setDisabled(this.chWidth.getValue()!=='checked'); + value = (this.chWidth.getValue()!=='checked'); + this.nfWidth.setDisabled(value); + this.cmbUnit.setDisabled(value); var TableSpacing = props.get_Spacing(); if (TableSpacing !== null) { @@ -1924,6 +1956,8 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat spinner.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.cm ? 0.1 : 1); } } + if (this.pageWidth) + this.pageWidth = Common.Utils.Metric.fnRecalcFromMM(this.pageWidth); }, updateThemeColors: function() { @@ -2006,7 +2040,10 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat tipCellInner: 'Set Vertical and Horizontal Lines for Inner Cells Only', tipTableOuterCellInner: 'Set Outer Border and Vertical and Horizontal Lines for Inner Cells', tipCellOuter: 'Set Outer Borders for Inner Cells Only', - tipTableOuterCellOuter: 'Set Table Outer Border and Outer Borders for Inner Cells' + tipTableOuterCellOuter: 'Set Table Outer Border and Outer Borders for Inner Cells', + txtPercent: 'Percent', + txtCm: 'Centimeter', + txtPt: 'Point' }, DE.Views.TableSettingsAdvanced || {})); });