2016-04-01 13:17:09 +00:00
|
|
|
/*
|
|
|
|
*
|
2019-01-17 13:05:03 +00:00
|
|
|
* (c) Copyright Ascensio System SIA 2010-2019
|
2016-04-01 13:17:09 +00:00
|
|
|
*
|
|
|
|
* This program is a free software product. You can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
|
|
|
* version 3 as published by the Free Software Foundation. In accordance with
|
|
|
|
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
|
|
|
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
|
|
|
* of any third-party rights.
|
|
|
|
*
|
|
|
|
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
|
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
|
|
|
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
|
|
|
*
|
2019-01-17 13:00:34 +00:00
|
|
|
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
|
|
|
* street, Riga, Latvia, EU, LV-1050.
|
2016-04-01 13:17:09 +00:00
|
|
|
*
|
|
|
|
* The interactive user interfaces in modified source and object code versions
|
|
|
|
* of the Program must display Appropriate Legal Notices, as required under
|
|
|
|
* Section 5 of the GNU AGPL version 3.
|
|
|
|
*
|
|
|
|
* Pursuant to Section 7(b) of the License you must retain the original Product
|
|
|
|
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
|
|
|
* grant you any rights under trademark law for use of our trademarks.
|
|
|
|
*
|
|
|
|
* All the Product's GUI elements, including illustrations and icon sets, as
|
|
|
|
* well as technical writing content are licensed under the terms of the
|
|
|
|
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
|
|
|
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
|
|
|
*
|
|
|
|
*/
|
2016-03-11 00:48:53 +00:00
|
|
|
/**
|
|
|
|
* ChartSettings.js
|
|
|
|
*
|
|
|
|
* Created by Julia Radzhabova on 4/11/14
|
2018-03-01 12:16:38 +00:00
|
|
|
* Copyright (c) 2018 Ascensio System SIA. All rights reserved.
|
2016-03-11 00:48:53 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
define([
|
|
|
|
'text!presentationeditor/main/app/template/ChartSettings.template',
|
|
|
|
'jquery',
|
|
|
|
'underscore',
|
|
|
|
'backbone',
|
2016-11-10 09:37:28 +00:00
|
|
|
'common/main/lib/component/Button',
|
2017-01-18 14:53:56 +00:00
|
|
|
'common/main/lib/component/ComboDataView',
|
|
|
|
'presentationeditor/main/app/view/ChartSettingsAdvanced'
|
2016-03-11 00:48:53 +00:00
|
|
|
], function (menuTemplate, $, _, Backbone) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
PE.Views.ChartSettings = Backbone.View.extend(_.extend({
|
|
|
|
el: '#id-chart-settings',
|
|
|
|
|
|
|
|
// Compile our stats template
|
|
|
|
template: _.template(menuTemplate),
|
|
|
|
|
|
|
|
// Delegated events for creating new items, and clearing completed ones.
|
|
|
|
events: {
|
|
|
|
},
|
|
|
|
|
|
|
|
options: {
|
|
|
|
alias: 'ChartSettings'
|
|
|
|
},
|
|
|
|
|
|
|
|
initialize: function () {
|
|
|
|
this._initSettings = true;
|
|
|
|
|
|
|
|
this._state = {
|
|
|
|
Width: 0,
|
|
|
|
Height: 0,
|
|
|
|
ChartStyle: 1,
|
|
|
|
ChartType: -1,
|
|
|
|
SeveralCharts: false,
|
2016-05-24 11:45:53 +00:00
|
|
|
DisabledControls: false,
|
|
|
|
keepRatio: false
|
2016-03-11 00:48:53 +00:00
|
|
|
};
|
|
|
|
this._nRatio = 1;
|
|
|
|
this.spinners = [];
|
|
|
|
this.lockedControls = [];
|
|
|
|
this._locked = false;
|
|
|
|
|
|
|
|
this._noApply = false;
|
|
|
|
this._originalProps = null;
|
|
|
|
|
|
|
|
this.render();
|
2016-10-07 13:31:11 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
render: function () {
|
|
|
|
var el = $(this.el);
|
|
|
|
el.html(this.template({
|
|
|
|
scope: this
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
|
|
|
setApi: function(api) {
|
|
|
|
this.api = api;
|
|
|
|
if (this.api) {
|
|
|
|
this.api.asc_registerCallback('asc_onUpdateChartStyles', _.bind(this._onUpdateChartStyles, this));
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
ChangeSettings: function(props) {
|
2016-10-14 10:48:04 +00:00
|
|
|
if (this._initSettings)
|
2016-10-07 13:31:11 +00:00
|
|
|
this.createDelayedElements();
|
|
|
|
|
|
|
|
this.disableControls(this._locked);
|
|
|
|
|
|
|
|
if (props){
|
2020-12-08 08:48:28 +00:00
|
|
|
this._originalProps = props;
|
2016-10-07 13:31:11 +00:00
|
|
|
this._noApply = true;
|
2020-12-08 08:48:28 +00:00
|
|
|
this.chartProps = props.get_ChartProperties();
|
2016-10-07 13:31:11 +00:00
|
|
|
|
|
|
|
var value = props.get_SeveralCharts() || this._locked;
|
|
|
|
if (this._state.SeveralCharts!==value) {
|
|
|
|
this.btnEditData.setDisabled(value);
|
|
|
|
this._state.SeveralCharts=value;
|
|
|
|
}
|
|
|
|
|
|
|
|
value = props.get_SeveralChartTypes();
|
|
|
|
if (this._state.SeveralCharts && value) {
|
2020-05-06 15:04:48 +00:00
|
|
|
this.btnChartType.setIconCls('svgicon');
|
2016-10-07 13:31:11 +00:00
|
|
|
this._state.ChartType = null;
|
|
|
|
} else {
|
|
|
|
var type = props.getType();
|
|
|
|
if (this._state.ChartType !== type) {
|
|
|
|
var record = this.mnuChartTypePicker.store.findWhere({type: type});
|
|
|
|
this.mnuChartTypePicker.selectRecord(record, true);
|
|
|
|
if (record) {
|
2020-05-06 15:04:48 +00:00
|
|
|
this.btnChartType.setIconCls('svgicon ' + 'chart-' + record.get('iconCls'));
|
2017-06-28 13:12:57 +00:00
|
|
|
} else
|
2020-05-06 15:04:48 +00:00
|
|
|
this.btnChartType.setIconCls('svgicon');
|
2016-10-07 13:31:11 +00:00
|
|
|
this.updateChartStyles(this.api.asc_getChartPreviews(type));
|
|
|
|
this._state.ChartType = type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
value = props.get_SeveralChartStyles();
|
|
|
|
if (this._state.SeveralCharts && value) {
|
2016-11-10 09:37:28 +00:00
|
|
|
this.cmbChartStyle.fieldPicker.deselectAll();
|
|
|
|
this.cmbChartStyle.menuPicker.deselectAll();
|
2016-10-07 13:31:11 +00:00
|
|
|
this._state.ChartStyle = null;
|
|
|
|
} else {
|
|
|
|
value = props.getStyle();
|
2016-11-10 09:37:28 +00:00
|
|
|
if (this._state.ChartStyle!==value || this._isChartStylesChanged) {
|
|
|
|
this.cmbChartStyle.suspendEvents();
|
|
|
|
var rec = this.cmbChartStyle.menuPicker.store.findWhere({data: value});
|
|
|
|
this.cmbChartStyle.menuPicker.selectRecord(rec);
|
|
|
|
this.cmbChartStyle.resumeEvents();
|
|
|
|
|
|
|
|
if (this._isChartStylesChanged) {
|
|
|
|
if (rec)
|
2019-06-27 11:18:01 +00:00
|
|
|
this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.getSelectedRec(),true);
|
2016-11-10 09:37:28 +00:00
|
|
|
else
|
|
|
|
this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.store.at(0), true);
|
2016-10-07 13:31:11 +00:00
|
|
|
}
|
|
|
|
this._state.ChartStyle=value;
|
|
|
|
}
|
|
|
|
}
|
2016-11-10 09:37:28 +00:00
|
|
|
this._isChartStylesChanged = false;
|
2016-10-07 13:31:11 +00:00
|
|
|
|
|
|
|
this._noApply = false;
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2016-10-07 13:31:11 +00:00
|
|
|
value = props.get_Width();
|
|
|
|
if ( Math.abs(this._state.Width-value)>0.001 ||
|
|
|
|
(this._state.Width===null || value===null)&&(this._state.Width!==value)) {
|
|
|
|
this.spnWidth.setValue((value!==null) ? Common.Utils.Metric.fnRecalcFromMM(value) : '', true);
|
|
|
|
this._state.Width = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
value = props.get_Height();
|
|
|
|
if ( Math.abs(this._state.Height-value)>0.001 ||
|
|
|
|
(this._state.Height===null || value===null)&&(this._state.Height!==value)) {
|
|
|
|
this.spnHeight.setValue((value!==null) ? Common.Utils.Metric.fnRecalcFromMM(value) : '', true);
|
|
|
|
this._state.Height = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (props.get_Height()>0)
|
|
|
|
this._nRatio = props.get_Width()/props.get_Height();
|
|
|
|
|
|
|
|
value = props.asc_getLockAspect();
|
|
|
|
if (this._state.keepRatio!==value) {
|
|
|
|
this.btnRatio.toggle(value);
|
|
|
|
this._state.keepRatio=value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
updateMetricUnit: function() {
|
|
|
|
if (this.spinners) {
|
|
|
|
for (var i=0; i<this.spinners.length; i++) {
|
|
|
|
var spinner = this.spinners[i];
|
|
|
|
spinner.setDefaultUnit(Common.Utils.Metric.getCurrentMetricName());
|
|
|
|
spinner.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt ? 1 : 0.1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
createDelayedControls: function() {
|
|
|
|
var me = this;
|
2016-03-11 00:48:53 +00:00
|
|
|
this.btnChartType = new Common.UI.Button({
|
|
|
|
cls : 'btn-large-dataview',
|
2020-05-06 15:04:48 +00:00
|
|
|
iconCls : 'svgicon chart-bar-normal',
|
2016-03-11 00:48:53 +00:00
|
|
|
menu : new Common.UI.Menu({
|
2021-01-14 09:57:22 +00:00
|
|
|
style: 'width: 364px;',
|
2016-03-11 00:48:53 +00:00
|
|
|
items: [
|
2021-01-14 09:57:22 +00:00
|
|
|
{ template: _.template('<div id="id-chart-menu-type" class="menu-insertchart"></div>') }
|
2016-03-11 00:48:53 +00:00
|
|
|
]
|
|
|
|
})
|
|
|
|
});
|
|
|
|
this.btnChartType.on('render:after', function(btn) {
|
|
|
|
me.mnuChartTypePicker = new Common.UI.DataView({
|
|
|
|
el: $('#id-chart-menu-type'),
|
|
|
|
parentMenu: btn.menu,
|
2021-01-14 09:57:22 +00:00
|
|
|
restoreHeight: 465,
|
2019-11-18 10:40:10 +00:00
|
|
|
groups: new Common.UI.DataViewGroupStore(Common.define.chartData.getChartGroupData()),
|
|
|
|
store: new Common.UI.DataViewStore(Common.define.chartData.getChartData()),
|
2020-05-06 15:04:48 +00:00
|
|
|
itemTemplate: _.template('<div id="<%= id %>" class="item-chartlist"><svg width="40" height="40" class=\"icon\"><use xlink:href=\"#chart-<%= iconCls %>\"></use></svg></div>')
|
2016-03-11 00:48:53 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
this.btnChartType.render($('#chart-button-type'));
|
|
|
|
this.mnuChartTypePicker.on('item:click', _.bind(this.onSelectType, this, this.btnChartType));
|
|
|
|
this.lockedControls.push(this.btnChartType);
|
|
|
|
|
|
|
|
this.btnEditData = new Common.UI.Button({
|
|
|
|
el: $('#chart-button-edit-data')
|
|
|
|
});
|
|
|
|
this.btnEditData.on('click', _.bind(this.setEditData, this));
|
|
|
|
this.lockedControls.push(this.btnEditData);
|
|
|
|
|
|
|
|
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));
|
2019-12-06 08:35:17 +00:00
|
|
|
this.spnWidth.on('inputleave', function(){ me.fireEvent('editcomplete', me);});
|
|
|
|
this.spnHeight.on('inputleave', function(){ me.fireEvent('editcomplete', me);});
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
this.btnRatio = new Common.UI.Button({
|
2020-04-29 07:36:53 +00:00
|
|
|
parentEl: $('#chart-button-ratio'),
|
2016-03-11 00:48:53 +00:00
|
|
|
cls: 'btn-toolbar',
|
2019-12-02 11:48:50 +00:00
|
|
|
iconCls: 'toolbar__icon advanced-btn-ratio',
|
2016-03-11 00:48:53 +00:00
|
|
|
style: 'margin-bottom: 1px;',
|
|
|
|
enableToggle: true,
|
|
|
|
hint: this.textKeepRatio
|
|
|
|
});
|
|
|
|
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();
|
|
|
|
}
|
2016-05-24 11:45:53 +00:00
|
|
|
if (this.api) {
|
|
|
|
var props = new Asc.CAscChartProp();
|
|
|
|
props.asc_putLockAspect(btn.pressed);
|
|
|
|
this.api.ChartApply(props);
|
|
|
|
}
|
|
|
|
this.fireEvent('editcomplete', this);
|
2016-03-11 00:48:53 +00:00
|
|
|
}, this));
|
|
|
|
|
2017-01-18 14:53:56 +00:00
|
|
|
this.linkAdvanced = $('#chart-advanced-link');
|
|
|
|
$(this.el).on('click', '#chart-advanced-link', _.bind(this.openAdvancedSettings, this));
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
createDelayedElements: function() {
|
2016-10-07 13:31:11 +00:00
|
|
|
this.createDelayedControls();
|
2016-03-11 00:48:53 +00:00
|
|
|
this.updateMetricUnit();
|
2016-10-14 10:48:04 +00:00
|
|
|
this._initSettings = false;
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
setEditData: function() {
|
|
|
|
var diagramEditor = PE.getController('Common.Controllers.ExternalDiagramEditor').getView('Common.Views.ExternalDiagramEditor');
|
|
|
|
if (diagramEditor) {
|
|
|
|
diagramEditor.setEditMode(true);
|
|
|
|
diagramEditor.show();
|
|
|
|
|
|
|
|
var chart = this.api.asc_getChartObject();
|
|
|
|
if (chart) {
|
|
|
|
diagramEditor.setChartData(new Asc.asc_CChartBinary(chart));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onSelectType: function(btn, picker, itemView, record) {
|
|
|
|
if (this._noApply) return;
|
|
|
|
|
|
|
|
var rawData = {},
|
|
|
|
isPickerSelect = _.isFunction(record.toJSON);
|
|
|
|
|
|
|
|
if (isPickerSelect){
|
|
|
|
if (record.get('selected')) {
|
|
|
|
rawData = record.toJSON();
|
|
|
|
} else {
|
|
|
|
// record deselected
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
rawData = record;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.api && !this._noApply) {
|
2020-12-08 08:48:28 +00:00
|
|
|
var isCombo = (rawData.type==Asc.c_oAscChartTypeSettings.comboBarLine || rawData.type==Asc.c_oAscChartTypeSettings.comboBarLineSecondary ||
|
|
|
|
rawData.type==Asc.c_oAscChartTypeSettings.comboAreaBar || rawData.type==Asc.c_oAscChartTypeSettings.comboCustom);
|
|
|
|
|
|
|
|
if (isCombo && this.chartProps.getSeries().length<2) {
|
|
|
|
Common.NotificationCenter.trigger('showerror', Asc.c_oAscError.ID.ComboSeriesError, Asc.c_oAscError.Level.NoCritical);
|
|
|
|
this.mnuChartTypePicker.selectRecord(this.mnuChartTypePicker.store.findWhere({type: this._originalProps.getType()}), true);
|
|
|
|
} else {
|
|
|
|
this.btnChartType.setIconCls('svgicon ' + 'chart-' + rawData.iconCls);
|
|
|
|
this._state.ChartType = -1;
|
|
|
|
this._originalProps.changeType(rawData.type);
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
},
|
|
|
|
|
2016-11-10 09:37:28 +00:00
|
|
|
onSelectStyle: function(combo, record) {
|
2016-03-11 00:48:53 +00:00
|
|
|
if (this._noApply) return;
|
|
|
|
|
|
|
|
if (this.api && !this._noApply) {
|
2016-04-05 12:57:51 +00:00
|
|
|
var props = new Asc.CAscChartProp();
|
2016-11-10 09:37:28 +00:00
|
|
|
props.putStyle(record.get('data'));
|
2016-03-11 00:48:53 +00:00
|
|
|
this.api.ChartApply(props);
|
|
|
|
}
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
},
|
|
|
|
|
|
|
|
_onUpdateChartStyles: function() {
|
|
|
|
if (this.api && this._state.ChartType!==null && this._state.ChartType>-1)
|
|
|
|
this.updateChartStyles(this.api.asc_getChartPreviews(this._state.ChartType));
|
|
|
|
},
|
|
|
|
|
|
|
|
updateChartStyles: function(styles) {
|
|
|
|
var me = this;
|
2016-11-10 09:37:28 +00:00
|
|
|
this._isChartStylesChanged = true;
|
|
|
|
|
|
|
|
if (!this.cmbChartStyle) {
|
|
|
|
this.cmbChartStyle = new Common.UI.ComboDataView({
|
|
|
|
itemWidth: 50,
|
|
|
|
itemHeight: 50,
|
|
|
|
menuMaxHeight: 270,
|
|
|
|
enableKeyEvents: true,
|
|
|
|
cls: 'combo-chart-style'
|
2016-10-07 13:31:11 +00:00
|
|
|
});
|
2016-11-10 09:37:28 +00:00
|
|
|
this.cmbChartStyle.render($('#chart-combo-style'));
|
|
|
|
this.cmbChartStyle.openButton.menu.cmpEl.css({
|
|
|
|
'min-width': 178,
|
|
|
|
'max-width': 178
|
2016-10-07 13:31:11 +00:00
|
|
|
});
|
2016-11-10 09:37:28 +00:00
|
|
|
this.cmbChartStyle.on('click', _.bind(this.onSelectStyle, this));
|
|
|
|
this.cmbChartStyle.openButton.menu.on('show:after', function () {
|
|
|
|
me.cmbChartStyle.menuPicker.scroller.update({alwaysVisibleY: true});
|
|
|
|
});
|
|
|
|
this.lockedControls.push(this.cmbChartStyle);
|
2016-10-07 13:31:11 +00:00
|
|
|
}
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
if (styles && styles.length>0){
|
2016-11-10 09:37:28 +00:00
|
|
|
var stylesStore = this.cmbChartStyle.menuPicker.store;
|
2016-03-11 00:48:53 +00:00
|
|
|
if (stylesStore) {
|
2016-11-10 09:37:28 +00:00
|
|
|
var count = stylesStore.length;
|
|
|
|
if (count>0 && count==styles.length) {
|
|
|
|
var data = stylesStore.models;
|
|
|
|
_.each(styles, function(style, index){
|
2019-06-11 15:24:00 +00:00
|
|
|
data[index].set('imageUrl', style.asc_getImage());
|
2016-03-11 00:48:53 +00:00
|
|
|
});
|
2016-11-10 09:37:28 +00:00
|
|
|
} else {
|
|
|
|
var stylearray = [],
|
|
|
|
selectedIdx = -1;
|
|
|
|
_.each(styles, function(item, index){
|
|
|
|
stylearray.push({
|
2019-06-11 15:24:00 +00:00
|
|
|
imageUrl: item.asc_getImage(),
|
|
|
|
data : item.asc_getName(),
|
|
|
|
tip : me.textStyle + ' ' + item.asc_getName()
|
2016-11-10 09:37:28 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
stylesStore.reset(stylearray, {silent: false});
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
2018-07-16 11:55:43 +00:00
|
|
|
} else {
|
|
|
|
this.cmbChartStyle.menuPicker.store.reset();
|
|
|
|
this.cmbChartStyle.clearComboView();
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
2018-07-16 11:55:43 +00:00
|
|
|
this.cmbChartStyle.setDisabled(!styles || styles.length<1 || this._locked);
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onWidthChange: function(field, newValue, oldValue, eOpts){
|
|
|
|
var w = field.getNumberValue();
|
|
|
|
var h = this.spnHeight.getNumberValue();
|
|
|
|
if (this.btnRatio.pressed) {
|
|
|
|
h = w/this._nRatio;
|
|
|
|
if (h>this.spnHeight.options.maxValue) {
|
|
|
|
h = this.spnHeight.options.maxValue;
|
|
|
|
w = h * this._nRatio;
|
|
|
|
this.spnWidth.setValue(w, true);
|
|
|
|
}
|
|
|
|
this.spnHeight.setValue(h, true);
|
|
|
|
}
|
|
|
|
if (this.api) {
|
2016-04-05 12:57:51 +00:00
|
|
|
var props = new Asc.CAscChartProp();
|
2016-03-11 00:48:53 +00:00
|
|
|
props.put_Width(Common.Utils.Metric.fnRecalcToMM(w));
|
|
|
|
props.put_Height(Common.Utils.Metric.fnRecalcToMM(h));
|
|
|
|
this.api.ChartApply(props);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onHeightChange: function(field, newValue, oldValue, eOpts){
|
|
|
|
var h = field.getNumberValue(), w = this.spnWidth.getNumberValue();
|
|
|
|
if (this.btnRatio.pressed) {
|
|
|
|
w = h * this._nRatio;
|
|
|
|
if (w>this.spnWidth.options.maxValue) {
|
|
|
|
w = this.spnWidth.options.maxValue;
|
|
|
|
h = w/this._nRatio;
|
|
|
|
this.spnHeight.setValue(h, true);
|
|
|
|
}
|
|
|
|
this.spnWidth.setValue(w, true);
|
|
|
|
}
|
|
|
|
if (this.api) {
|
2016-04-05 12:57:51 +00:00
|
|
|
var props = new Asc.CAscChartProp();
|
2016-03-11 00:48:53 +00:00
|
|
|
props.put_Width(Common.Utils.Metric.fnRecalcToMM(w));
|
|
|
|
props.put_Height(Common.Utils.Metric.fnRecalcToMM(h));
|
|
|
|
this.api.ChartApply(props);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-01-18 14:53:56 +00:00
|
|
|
openAdvancedSettings: function(e) {
|
|
|
|
if (this.linkAdvanced.hasClass('disabled')) return;
|
|
|
|
|
|
|
|
var me = this;
|
|
|
|
var win;
|
|
|
|
if (me.api && !this._locked){
|
|
|
|
var selectedElements = me.api.getSelectedElements();
|
|
|
|
if (selectedElements && selectedElements.length>0){
|
|
|
|
var elType, elValue;
|
|
|
|
for (var i = selectedElements.length - 1; i >= 0; i--) {
|
|
|
|
elType = selectedElements[i].get_ObjectType();
|
|
|
|
elValue = selectedElements[i].get_ObjectValue();
|
|
|
|
if (Asc.c_oAscTypeSelectElement.Chart == elType) {
|
|
|
|
(new PE.Views.ChartSettingsAdvanced(
|
|
|
|
{
|
|
|
|
chartProps: elValue,
|
|
|
|
handler: function(result, value) {
|
|
|
|
if (result == 'ok') {
|
|
|
|
if (me.api) {
|
|
|
|
me.api.ChartApply(value.chartProps);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
me.fireEvent('editcomplete', me);
|
|
|
|
}
|
|
|
|
})).show();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
setLocked: function (locked) {
|
|
|
|
this._locked = locked;
|
|
|
|
},
|
|
|
|
|
|
|
|
disableControls: function(disable) {
|
2016-10-07 13:31:11 +00:00
|
|
|
if (this._initSettings) return;
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
if (this._state.DisabledControls!==disable) {
|
|
|
|
this._state.DisabledControls = disable;
|
|
|
|
_.each(this.lockedControls, function(item) {
|
|
|
|
item.setDisabled(disable);
|
|
|
|
});
|
2017-01-18 14:53:56 +00:00
|
|
|
this.linkAdvanced.toggleClass('disabled', disable);
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
textKeepRatio: 'Constant Proportions',
|
|
|
|
textSize: 'Size',
|
|
|
|
textWidth: 'Width',
|
|
|
|
textHeight: 'Height',
|
|
|
|
textEditData: 'Edit Data',
|
|
|
|
textChartType: 'Change Chart Type',
|
2017-01-18 14:53:56 +00:00
|
|
|
textStyle: 'Style',
|
2019-11-18 10:40:10 +00:00
|
|
|
textAdvanced: 'Show advanced settings'
|
2016-03-11 00:48:53 +00:00
|
|
|
}, PE.Views.ChartSettings || {}));
|
|
|
|
});
|