diff --git a/apps/spreadsheeteditor/main/app/view/ChartSettings.js b/apps/spreadsheeteditor/main/app/view/ChartSettings.js index 923acfc3e..cb0d501e8 100644 --- a/apps/spreadsheeteditor/main/app/view/ChartSettings.js +++ b/apps/spreadsheeteditor/main/app/view/ChartSettings.js @@ -64,7 +64,6 @@ define([ }, initialize: function () { - var me = this; this._initSettings = true; this._state = { @@ -85,143 +84,6 @@ define([ this._originalProps = null; this.render(); - - this.btnChartType = new Common.UI.Button({ - cls : 'btn-large-dataview', - iconCls : 'item-chartlist bar-normal', - menu : new Common.UI.Menu({ - style: 'width: 560px;', - items: [ - { template: _.template('
') } - ] - }) - }); - this.btnChartType.on('render:after', function(btn) { - me.mnuChartTypePicker = new Common.UI.DataView({ - el: $('#id-chart-menu-type'), - parentMenu: btn.menu, - restoreHeight: 411, - groups: new Common.UI.DataViewGroupStore([ - { id: 'menu-chart-group-bar', caption: me.textColumn }, - { id: 'menu-chart-group-line', caption: me.textLine }, - { id: 'menu-chart-group-pie', caption: me.textPie }, - { id: 'menu-chart-group-hbar', caption: me.textBar }, - { id: 'menu-chart-group-area', caption: me.textArea }, - { id: 'menu-chart-group-scatter', caption: me.textPoint }, - { id: 'menu-chart-group-stock', caption: me.textStock } - ]), - store: new Common.UI.DataViewStore([ - { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barNormal, iconCls: 'column-normal', selected: true}, - { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barStacked, iconCls: 'column-stack'}, - { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barStackedPer, iconCls: 'column-pstack'}, - { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barNormal3d, iconCls: 'column-3d-normal'}, - { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barStacked3d, iconCls: 'column-3d-stack'}, - { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barStackedPer3d, iconCls: 'column-3d-pstack'}, - { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barNormal3dPerspective, iconCls: 'column-3d-normal-per'}, - { group: 'menu-chart-group-line', type: Asc.c_oAscChartTypeSettings.lineNormal, iconCls: 'line-normal'}, - { group: 'menu-chart-group-line', type: Asc.c_oAscChartTypeSettings.lineStacked, iconCls: 'line-stack'}, - { group: 'menu-chart-group-line', type: Asc.c_oAscChartTypeSettings.lineStackedPer, iconCls: 'line-pstack'}, - { group: 'menu-chart-group-line', type: Asc.c_oAscChartTypeSettings.line3d, iconCls: 'line-3d'}, - { group: 'menu-chart-group-pie', type: Asc.c_oAscChartTypeSettings.pie, iconCls: 'pie-normal'}, - { group: 'menu-chart-group-pie', type: Asc.c_oAscChartTypeSettings.doughnut, iconCls: 'pie-doughnut'}, - { group: 'menu-chart-group-pie', type: Asc.c_oAscChartTypeSettings.pie3d, iconCls: 'pie-3d-normal'}, - { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarNormal, iconCls: 'bar-normal'}, - { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarStacked, iconCls: 'bar-stack'}, - { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarStackedPer, iconCls: 'bar-pstack'}, - { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarNormal3d, iconCls: 'bar-3d-normal'}, - { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarStacked3d, iconCls: 'bar-3d-stack'}, - { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarStackedPer3d, iconCls: 'bar-3d-pstack'}, - { group: 'menu-chart-group-area', type: Asc.c_oAscChartTypeSettings.areaNormal, iconCls: 'area-normal'}, - { group: 'menu-chart-group-area', type: Asc.c_oAscChartTypeSettings.areaStacked, iconCls: 'area-stack'}, - { group: 'menu-chart-group-area', type: Asc.c_oAscChartTypeSettings.areaStackedPer, iconCls: 'area-pstack'}, - { group: 'menu-chart-group-scatter', type: Asc.c_oAscChartTypeSettings.scatter, iconCls: 'point-normal'}, - { group: 'menu-chart-group-stock', type: Asc.c_oAscChartTypeSettings.stock, iconCls: 'stock-normal'} - ]), - itemTemplate: _.template('') - }); - }); - this.btnChartType.render($('#chart-button-type')); - this.mnuChartTypePicker.on('item:click', _.bind(this.onSelectType, this, this.btnChartType)); - this.lockedControls.push(this.btnChartType); - - this.btnChartStyle = new Common.UI.Button({ - cls : 'btn-large-dataview', - iconCls : 'item-wrap', - menu : new Common.UI.Menu({ - menuAlign: 'tr-br', - items: [ - { template: _.template('') } - ] - }) - }); - this.btnChartStyle.on('render:after', function(btn) { - me.mnuChartStylePicker = new Common.UI.DataView({ - el: $('#id-chart-menu-style'), - style: 'max-height: 411px;', - parentMenu: btn.menu, - store: new Common.UI.DataViewStore(), - itemTemplate: _.template('') - }); - - if (me.btnChartStyle.menu) { - me.btnChartStyle.menu.on('show:after', function () { - me.mnuChartStylePicker.scroller.update({alwaysVisibleY: true}); - }); - } - }); - this.btnChartStyle.render($('#chart-button-style')); - this.mnuChartStylePicker.on('item:click', _.bind(this.onSelectStyle, this, this.btnChartStyle)); - this.lockedControls.push(this.btnChartStyle); - - this.spnWidth = new Common.UI.MetricSpinner({ - el: $('#chart-spin-width'), - step: .1, - width: 78, - defaultUnit : "cm", - value: '3 cm', - maxValue: 55.88, - minValue: 0 - }); - this.spinners.push(this.spnWidth); - this.lockedControls.push(this.spnWidth); - - this.spnHeight = new Common.UI.MetricSpinner({ - el: $('#chart-spin-height'), - step: .1, - width: 78, - defaultUnit : "cm", - value: '3 cm', - maxValue: 55.88, - minValue: 0 - }); - this.spinners.push(this.spnHeight); - this.lockedControls.push(this.spnHeight); - - this.spnWidth.on('change', _.bind(this.onWidthChange, this)); - this.spnHeight.on('change', _.bind(this.onHeightChange, this)); - - this.btnRatio = new Common.UI.Button({ - cls: 'btn-toolbar', - iconCls: 'advanced-btn-ratio', - style: 'margin-bottom: 1px;', - enableToggle: true, - hint: this.textKeepRatio - }); - this.btnRatio.render($('#chart-button-ratio')) ; - this.lockedControls.push(this.btnRatio); - - this.btnRatio.on('click', _.bind(function(btn, e) { - if (btn.pressed && this.spnHeight.getNumberValue()>0) { - this._nRatio = this.spnWidth.getNumberValue()/this.spnHeight.getNumberValue(); - } - if (this.api) { - var props = new Asc.asc_CImgProperty(); - props.asc_putLockAspect(btn.pressed); - this.api.asc_setGraphicObjectProps(props); - } - }, this)); - - $(this.el).on('click', '#chart-advanced-link', _.bind(this.openAdvancedSettings, this)); }, render: function () { @@ -229,8 +91,6 @@ define([ el.html(this.template({ scope: this })); - - this.linkAdvanced = $('#chart-advanced-link'); }, setApi: function(api) { @@ -334,7 +194,121 @@ define([ } }, + createDelayedControls: function() { + var me = this; + + this.btnChartType = new Common.UI.Button({ + cls : 'btn-large-dataview', + iconCls : 'item-chartlist bar-normal', + menu : new Common.UI.Menu({ + style: 'width: 560px;', + items: [ + { template: _.template('') } + ] + }) + }); + this.btnChartType.on('render:after', function(btn) { + me.mnuChartTypePicker = new Common.UI.DataView({ + el: $('#id-chart-menu-type'), + parentMenu: btn.menu, + restoreHeight: 411, + groups: new Common.UI.DataViewGroupStore([ + { id: 'menu-chart-group-bar', caption: me.textColumn }, + { id: 'menu-chart-group-line', caption: me.textLine }, + { id: 'menu-chart-group-pie', caption: me.textPie }, + { id: 'menu-chart-group-hbar', caption: me.textBar }, + { id: 'menu-chart-group-area', caption: me.textArea }, + { id: 'menu-chart-group-scatter', caption: me.textPoint }, + { id: 'menu-chart-group-stock', caption: me.textStock } + ]), + store: new Common.UI.DataViewStore([ + { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barNormal, iconCls: 'column-normal', selected: true}, + { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barStacked, iconCls: 'column-stack'}, + { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barStackedPer, iconCls: 'column-pstack'}, + { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barNormal3d, iconCls: 'column-3d-normal'}, + { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barStacked3d, iconCls: 'column-3d-stack'}, + { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barStackedPer3d, iconCls: 'column-3d-pstack'}, + { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barNormal3dPerspective, iconCls: 'column-3d-normal-per'}, + { group: 'menu-chart-group-line', type: Asc.c_oAscChartTypeSettings.lineNormal, iconCls: 'line-normal'}, + { group: 'menu-chart-group-line', type: Asc.c_oAscChartTypeSettings.lineStacked, iconCls: 'line-stack'}, + { group: 'menu-chart-group-line', type: Asc.c_oAscChartTypeSettings.lineStackedPer, iconCls: 'line-pstack'}, + { group: 'menu-chart-group-line', type: Asc.c_oAscChartTypeSettings.line3d, iconCls: 'line-3d'}, + { group: 'menu-chart-group-pie', type: Asc.c_oAscChartTypeSettings.pie, iconCls: 'pie-normal'}, + { group: 'menu-chart-group-pie', type: Asc.c_oAscChartTypeSettings.doughnut, iconCls: 'pie-doughnut'}, + { group: 'menu-chart-group-pie', type: Asc.c_oAscChartTypeSettings.pie3d, iconCls: 'pie-3d-normal'}, + { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarNormal, iconCls: 'bar-normal'}, + { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarStacked, iconCls: 'bar-stack'}, + { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarStackedPer, iconCls: 'bar-pstack'}, + { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarNormal3d, iconCls: 'bar-3d-normal'}, + { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarStacked3d, iconCls: 'bar-3d-stack'}, + { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarStackedPer3d, iconCls: 'bar-3d-pstack'}, + { group: 'menu-chart-group-area', type: Asc.c_oAscChartTypeSettings.areaNormal, iconCls: 'area-normal'}, + { group: 'menu-chart-group-area', type: Asc.c_oAscChartTypeSettings.areaStacked, iconCls: 'area-stack'}, + { group: 'menu-chart-group-area', type: Asc.c_oAscChartTypeSettings.areaStackedPer, iconCls: 'area-pstack'}, + { group: 'menu-chart-group-scatter', type: Asc.c_oAscChartTypeSettings.scatter, iconCls: 'point-normal'}, + { group: 'menu-chart-group-stock', type: Asc.c_oAscChartTypeSettings.stock, iconCls: 'stock-normal'} + ]), + itemTemplate: _.template('') + }); + }); + this.btnChartType.render($('#chart-button-type')); + this.mnuChartTypePicker.on('item:click', _.bind(this.onSelectType, this, this.btnChartType)); + this.lockedControls.push(this.btnChartType); + + this.spnWidth = new Common.UI.MetricSpinner({ + el: $('#chart-spin-width'), + step: .1, + width: 78, + defaultUnit : "cm", + value: '3 cm', + maxValue: 55.88, + minValue: 0 + }); + this.spinners.push(this.spnWidth); + this.lockedControls.push(this.spnWidth); + + this.spnHeight = new Common.UI.MetricSpinner({ + el: $('#chart-spin-height'), + step: .1, + width: 78, + defaultUnit : "cm", + value: '3 cm', + maxValue: 55.88, + minValue: 0 + }); + this.spinners.push(this.spnHeight); + this.lockedControls.push(this.spnHeight); + + this.spnWidth.on('change', _.bind(this.onWidthChange, this)); + this.spnHeight.on('change', _.bind(this.onHeightChange, this)); + + this.btnRatio = new Common.UI.Button({ + cls: 'btn-toolbar', + iconCls: 'advanced-btn-ratio', + style: 'margin-bottom: 1px;', + enableToggle: true, + hint: this.textKeepRatio + }); + this.btnRatio.render($('#chart-button-ratio')) ; + this.lockedControls.push(this.btnRatio); + + this.btnRatio.on('click', _.bind(function(btn, e) { + if (btn.pressed && this.spnHeight.getNumberValue()>0) { + this._nRatio = this.spnWidth.getNumberValue()/this.spnHeight.getNumberValue(); + } + if (this.api) { + var props = new Asc.asc_CImgProperty(); + props.asc_putLockAspect(btn.pressed); + this.api.asc_setGraphicObjectProps(props); + } + }, this)); + + this.linkAdvanced = $('#chart-advanced-link'); + $(this.el).on('click', '#chart-advanced-link', _.bind(this.openAdvancedSettings, this)); + }, + createDelayedElements: function() { + this.createDelayedControls(); this.updateMetricUnit(); }, @@ -473,6 +447,36 @@ define([ updateChartStyles: function(styles) { var me = this; + + if (!this.btnChartStyle) { + this.btnChartStyle = new Common.UI.Button({ + cls : 'btn-large-dataview', + iconCls : 'item-wrap', + menu : new Common.UI.Menu({ + menuAlign: 'tr-br', + items: [ + { template: _.template('') } + ] + }) + }); + this.btnChartStyle.render($('#chart-button-style')); + this.lockedControls.push(this.btnChartStyle); + this.mnuChartStylePicker = new Common.UI.DataView({ + el: $('#id-chart-menu-style'), + style: 'max-height: 411px;', + parentMenu: this.btnChartStyle.menu, + store: new Common.UI.DataViewStore(), + itemTemplate: _.template('') + }); + + if (this.btnChartStyle.menu) { + this.btnChartStyle.menu.on('show:after', function () { + me.mnuChartStylePicker.scroller.update({alwaysVisibleY: true}); + }); + } + this.mnuChartStylePicker.on('item:click', _.bind(this.onSelectStyle, this, this.btnChartStyle)); + } + if (styles && styles.length>0){ var stylesStore = this.mnuChartStylePicker.store; if (stylesStore) { @@ -508,6 +512,8 @@ define([ }, disableControls: function(disable) { + if (this._initSettings) return; + if (this._state.DisabledControls!==disable) { this._state.DisabledControls = disable; _.each(this.lockedControls, function(item) { diff --git a/apps/spreadsheeteditor/main/app/view/ImageSettings.js b/apps/spreadsheeteditor/main/app/view/ImageSettings.js index 3cbb70b3a..9ecb449d6 100644 --- a/apps/spreadsheeteditor/main/app/view/ImageSettings.js +++ b/apps/spreadsheeteditor/main/app/view/ImageSettings.js @@ -64,7 +64,6 @@ define([ }, initialize: function () { - var me = this; this._initSettings = true; this._nRatio = 1; @@ -82,7 +81,33 @@ define([ this._noApply = false; this.render(); + }, + render: function () { + var el = $(this.el); + el.html(this.template({ + scope: this + })); + }, + + setApi: function(api) { + if ( api == undefined ) return; + this.api = api; + return this; + }, + + updateMetricUnit: function() { + if (this.spinners) { + for (var i=0; i