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
|
|
|
/**
|
|
|
|
* ImageSettings.js
|
|
|
|
*
|
|
|
|
* Created by Julia Radzhabova on 2/05/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!documenteditor/main/app/template/ImageSettings.template',
|
|
|
|
'jquery',
|
|
|
|
'underscore',
|
|
|
|
'backbone',
|
|
|
|
'common/main/lib/component/Button',
|
|
|
|
'common/main/lib/view/ImageFromUrlDialog',
|
|
|
|
'documenteditor/main/app/view/ImageSettingsAdvanced'
|
|
|
|
], function (menuTemplate, $, _, Backbone) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
DE.Views.ImageSettings = Backbone.View.extend(_.extend({
|
|
|
|
el: '#id-image-settings',
|
|
|
|
|
|
|
|
// Compile our stats template
|
|
|
|
template: _.template(menuTemplate),
|
|
|
|
|
|
|
|
// Delegated events for creating new items, and clearing completed ones.
|
|
|
|
events: {
|
|
|
|
},
|
|
|
|
|
|
|
|
options: {
|
|
|
|
alias: 'ImageSettings'
|
|
|
|
},
|
|
|
|
|
|
|
|
initialize: function () {
|
|
|
|
this._initSettings = true;
|
|
|
|
|
|
|
|
this._state = {
|
2016-04-05 11:52:34 +00:00
|
|
|
WrappingStyle: Asc.c_oAscWrapStyle2.Inline,
|
2016-03-11 00:48:53 +00:00
|
|
|
CanBeFlow: true,
|
|
|
|
Width: 0,
|
|
|
|
Height: 0,
|
|
|
|
FromGroup: false,
|
2016-07-07 13:33:13 +00:00
|
|
|
DisabledControls: false,
|
2019-04-09 10:41:08 +00:00
|
|
|
isOleObject: false,
|
2020-01-29 11:12:29 +00:00
|
|
|
cropMode: false,
|
|
|
|
isPictureControl: false
|
2016-03-11 00:48:53 +00:00
|
|
|
};
|
|
|
|
this.lockedControls = [];
|
|
|
|
this._locked = false;
|
|
|
|
|
|
|
|
this._originalProps = null;
|
|
|
|
|
|
|
|
this.render();
|
2016-08-17 09:55:21 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
render: function () {
|
2019-08-23 10:09:39 +00:00
|
|
|
var el = this.$el || $(this.el);
|
2016-08-17 09:55:21 +00:00
|
|
|
el.html(this.template({
|
|
|
|
scope: this
|
|
|
|
}));
|
2019-08-23 10:09:39 +00:00
|
|
|
|
|
|
|
this.labelWidth = el.find('#image-label-width');
|
|
|
|
this.labelHeight = el.find('#image-label-height');
|
2016-08-17 09:55:21 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
setApi: function(api) {
|
|
|
|
this.api = api;
|
2019-04-05 14:36:15 +00:00
|
|
|
if (this.api) {
|
2016-08-17 09:55:21 +00:00
|
|
|
this.api.asc_registerCallback('asc_onImgWrapStyleChanged', _.bind(this._ImgWrapStyleChanged, this));
|
2019-04-05 14:36:15 +00:00
|
|
|
this.api.asc_registerCallback('asc_ChangeCropState', _.bind(this._changeCropState, this));
|
|
|
|
}
|
2016-08-17 09:55:21 +00:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
updateMetricUnit: function() {
|
|
|
|
var value = Common.Utils.Metric.fnRecalcFromMM(this._state.Width);
|
2019-11-26 11:24:08 +00:00
|
|
|
this.labelWidth[0].innerHTML = this.textWidth + ': ' + value.toFixed(2) + ' ' + Common.Utils.Metric.getCurrentMetricName();
|
2016-08-17 09:55:21 +00:00
|
|
|
|
|
|
|
value = Common.Utils.Metric.fnRecalcFromMM(this._state.Height);
|
2019-11-26 11:24:08 +00:00
|
|
|
this.labelHeight[0].innerHTML = this.textHeight + ': ' + value.toFixed(2) + ' ' + Common.Utils.Metric.getCurrentMetricName();
|
2016-08-17 09:55:21 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
createDelayedControls: function() {
|
|
|
|
var me = this,
|
|
|
|
viewData = [
|
2017-04-26 13:28:36 +00:00
|
|
|
{ offsetx: 0, data: Asc.c_oAscWrapStyle2.Inline, tip: this.txtInline, selected: true },
|
|
|
|
{ offsetx: 50, data: Asc.c_oAscWrapStyle2.Square, tip: this.txtSquare },
|
|
|
|
{ offsetx: 100, data: Asc.c_oAscWrapStyle2.Tight, tip: this.txtTight },
|
|
|
|
{ offsetx: 150, data: Asc.c_oAscWrapStyle2.Through, tip: this.txtThrough },
|
|
|
|
{ offsetx: 200, data: Asc.c_oAscWrapStyle2.TopAndBottom, tip: this.txtTopAndBottom },
|
|
|
|
{ offsetx: 250, data: Asc.c_oAscWrapStyle2.InFront, tip: this.txtInFront },
|
|
|
|
{ offsetx: 300, data: Asc.c_oAscWrapStyle2.Behind, tip: this.txtBehind }
|
2016-03-11 00:48:53 +00:00
|
|
|
];
|
|
|
|
|
2017-04-26 13:28:36 +00:00
|
|
|
this.cmbWrapType = new Common.UI.ComboDataView({
|
|
|
|
itemWidth: 50,
|
|
|
|
itemHeight: 50,
|
|
|
|
menuMaxHeight: 300,
|
|
|
|
enableKeyEvents: true,
|
|
|
|
store: new Common.UI.DataViewStore(viewData),
|
2017-04-27 13:26:12 +00:00
|
|
|
cls: 'combo-chart-style'
|
2016-03-11 00:48:53 +00:00
|
|
|
});
|
2017-04-26 13:28:36 +00:00
|
|
|
this.cmbWrapType.menuPicker.itemTemplate = this.cmbWrapType.fieldPicker.itemTemplate = _.template([
|
|
|
|
'<div class="style" id="<%= id %>">',
|
|
|
|
'<img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="combo-wrap-item" ',
|
|
|
|
'width="' + this.cmbWrapType.itemWidth + '" height="' + this.cmbWrapType.itemHeight + '" ',
|
|
|
|
'style="background-position: -<%= offsetx %>px 0;"/>',
|
|
|
|
'</div>'
|
|
|
|
].join(''));
|
|
|
|
this.cmbWrapType.render($('#image-combo-wrap'));
|
|
|
|
this.cmbWrapType.openButton.menu.cmpEl.css({
|
|
|
|
'min-width': 178,
|
|
|
|
'max-width': 178
|
|
|
|
});
|
|
|
|
this.cmbWrapType.on('click', _.bind(this.onSelectWrap, this));
|
|
|
|
this.cmbWrapType.openButton.menu.on('show:after', function () {
|
|
|
|
me.cmbWrapType.menuPicker.scroller.update({alwaysVisibleY: true});
|
2016-03-11 00:48:53 +00:00
|
|
|
});
|
2017-04-26 13:28:36 +00:00
|
|
|
this.lockedControls.push(this.cmbWrapType);
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
this.btnOriginalSize = new Common.UI.Button({
|
|
|
|
el: $('#image-button-original-size')
|
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnOriginalSize);
|
|
|
|
|
2017-04-27 11:49:17 +00:00
|
|
|
this.btnFitMargins = new Common.UI.Button({
|
|
|
|
el: $('#image-button-fit-margins')
|
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnFitMargins);
|
|
|
|
|
2019-11-19 12:43:26 +00:00
|
|
|
var w = Math.max(this.btnOriginalSize.cmpEl.width(), this.btnFitMargins.cmpEl.width());
|
|
|
|
this.btnOriginalSize.cmpEl.width(w);
|
|
|
|
this.btnFitMargins.cmpEl.width(w);
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
this.btnInsertFromFile = new Common.UI.Button({
|
|
|
|
el: $('#image-button-from-file')
|
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnInsertFromFile);
|
|
|
|
|
|
|
|
this.btnInsertFromUrl = new Common.UI.Button({
|
|
|
|
el: $('#image-button-from-url')
|
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnInsertFromUrl);
|
|
|
|
|
2016-07-07 13:33:13 +00:00
|
|
|
this.btnEditObject = new Common.UI.Button({
|
|
|
|
el: $('#image-button-edit-object')
|
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnEditObject);
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
this.btnOriginalSize.on('click', _.bind(this.setOriginalSize, this));
|
|
|
|
this.btnInsertFromFile.on('click', _.bind(function(btn){
|
2017-08-29 09:29:54 +00:00
|
|
|
if (this._isFromFile) return;
|
|
|
|
this._isFromFile = true;
|
2016-03-11 00:48:53 +00:00
|
|
|
if (this.api) this.api.ChangeImageFromFile();
|
|
|
|
this.fireEvent('editcomplete', this);
|
2017-08-29 09:29:54 +00:00
|
|
|
this._isFromFile = false;
|
2016-03-11 00:48:53 +00:00
|
|
|
}, this));
|
|
|
|
this.btnInsertFromUrl.on('click', _.bind(this.insertFromUrl, this));
|
2016-07-07 13:33:13 +00:00
|
|
|
this.btnEditObject.on('click', _.bind(function(btn){
|
2016-11-23 11:15:14 +00:00
|
|
|
if (this.api) this.api.asc_startEditCurrentOleObject();
|
2016-07-07 13:33:13 +00:00
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
}, this));
|
2017-04-27 11:49:17 +00:00
|
|
|
this.btnFitMargins.on('click', _.bind(this.setFitMargins, this));
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2018-08-10 06:16:15 +00:00
|
|
|
this.btnRotate270 = new Common.UI.Button({
|
|
|
|
cls: 'btn-toolbar',
|
2019-11-21 07:58:05 +00:00
|
|
|
iconCls: 'toolbar__icon btn-rotate-270',
|
2018-08-10 06:16:15 +00:00
|
|
|
value: 0,
|
|
|
|
hint: this.textHint270
|
|
|
|
});
|
|
|
|
this.btnRotate270.render( $('#image-button-270', me.$el));
|
|
|
|
this.btnRotate270.on('click', _.bind(this.onBtnRotateClick, this));
|
|
|
|
this.lockedControls.push(this.btnRotate270);
|
|
|
|
|
|
|
|
this.btnRotate90 = new Common.UI.Button({
|
|
|
|
cls: 'btn-toolbar',
|
2019-11-21 07:58:05 +00:00
|
|
|
iconCls: 'toolbar__icon btn-rotate-90',
|
2018-08-10 06:16:15 +00:00
|
|
|
value: 1,
|
|
|
|
hint: this.textHint90
|
|
|
|
});
|
|
|
|
this.btnRotate90.render( $('#image-button-90', me.$el));
|
|
|
|
this.btnRotate90.on('click', _.bind(this.onBtnRotateClick, this));
|
|
|
|
this.lockedControls.push(this.btnRotate90);
|
|
|
|
|
|
|
|
this.btnFlipV = new Common.UI.Button({
|
|
|
|
cls: 'btn-toolbar',
|
2019-11-21 07:58:05 +00:00
|
|
|
iconCls: 'toolbar__icon btn-flip-vert',
|
2018-08-10 06:16:15 +00:00
|
|
|
value: 0,
|
|
|
|
hint: this.textHintFlipV
|
|
|
|
});
|
|
|
|
this.btnFlipV.render( $('#image-button-flipv', me.$el));
|
|
|
|
this.btnFlipV.on('click', _.bind(this.onBtnFlipClick, this));
|
|
|
|
this.lockedControls.push(this.btnFlipV);
|
|
|
|
|
|
|
|
this.btnFlipH = new Common.UI.Button({
|
|
|
|
cls: 'btn-toolbar',
|
2019-11-21 07:58:05 +00:00
|
|
|
iconCls: 'toolbar__icon btn-flip-hor',
|
2018-08-10 06:16:15 +00:00
|
|
|
value: 1,
|
|
|
|
hint: this.textHintFlipH
|
|
|
|
});
|
|
|
|
this.btnFlipH.render( $('#image-button-fliph', me.$el));
|
|
|
|
this.btnFlipH.on('click', _.bind(this.onBtnFlipClick, this));
|
|
|
|
this.lockedControls.push(this.btnFlipH);
|
|
|
|
|
2019-11-19 12:43:26 +00:00
|
|
|
var w = this.btnOriginalSize.cmpEl.outerWidth();
|
2019-04-05 14:36:15 +00:00
|
|
|
this.btnCrop = new Common.UI.Button({
|
|
|
|
cls: 'btn-text-split-default',
|
2019-04-09 07:21:03 +00:00
|
|
|
caption: this.textCrop,
|
2019-04-05 14:36:15 +00:00
|
|
|
split: true,
|
|
|
|
enableToggle: true,
|
|
|
|
allowDepress: true,
|
2019-04-09 10:41:08 +00:00
|
|
|
pressed: this._state.cropMode,
|
2019-11-19 12:43:26 +00:00
|
|
|
width: w,
|
2019-04-05 14:36:15 +00:00
|
|
|
menu : new Common.UI.Menu({
|
2019-11-19 12:43:26 +00:00
|
|
|
style : 'min-width:' + w + 'px;',
|
2019-04-05 14:36:15 +00:00
|
|
|
items: [
|
|
|
|
{
|
2019-04-09 07:21:03 +00:00
|
|
|
caption: this.textCrop,
|
2019-04-05 14:36:15 +00:00
|
|
|
checkable: true,
|
|
|
|
allowDepress: true,
|
2019-04-09 10:41:08 +00:00
|
|
|
checked: this._state.cropMode,
|
2019-04-05 14:36:15 +00:00
|
|
|
value: 0
|
|
|
|
},
|
|
|
|
{
|
2019-04-09 07:21:03 +00:00
|
|
|
caption: this.textCropFill,
|
2019-04-05 14:36:15 +00:00
|
|
|
value: 1
|
|
|
|
},
|
|
|
|
{
|
2019-04-09 07:21:03 +00:00
|
|
|
caption: this.textCropFit,
|
2019-04-05 14:36:15 +00:00
|
|
|
value: 2
|
|
|
|
}]
|
|
|
|
})
|
|
|
|
});
|
|
|
|
this.btnCrop.render( $('#image-button-crop')) ;
|
|
|
|
this.btnCrop.on('click', _.bind(this.onCrop, this));
|
|
|
|
this.btnCrop.menu.on('item:click', _.bind(this.onCropMenu, this));
|
|
|
|
this.lockedControls.push(this.btnCrop);
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
this.linkAdvanced = $('#image-advanced-link');
|
2016-07-07 13:33:13 +00:00
|
|
|
this.lblReplace = $('#image-lbl-replace');
|
2016-08-17 09:55:21 +00:00
|
|
|
$(this.el).on('click', '#image-advanced-link', _.bind(this.openAdvancedSettings, this));
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
2019-04-05 14:36:15 +00:00
|
|
|
|
|
|
|
_changeCropState: function(state) {
|
2019-04-09 10:41:08 +00:00
|
|
|
this._state.cropMode = state;
|
|
|
|
|
|
|
|
if (!this.btnCrop) return;
|
2019-04-05 14:36:15 +00:00
|
|
|
this.btnCrop.toggle(state, true);
|
|
|
|
this.btnCrop.menu.items[0].setChecked(state, true);
|
|
|
|
},
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
createDelayedElements: function() {
|
2016-08-17 09:55:21 +00:00
|
|
|
this.createDelayedControls();
|
2016-03-11 00:48:53 +00:00
|
|
|
this.updateMetricUnit();
|
2016-10-12 15:38:10 +00:00
|
|
|
this._initSettings = false;
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
ChangeSettings: function(props) {
|
2016-10-12 15:38:10 +00:00
|
|
|
if (this._initSettings)
|
2016-03-11 00:48:53 +00:00
|
|
|
this.createDelayedElements();
|
|
|
|
|
|
|
|
this.disableControls(this._locked);
|
|
|
|
|
|
|
|
if (props ){
|
2016-04-18 12:21:15 +00:00
|
|
|
this._originalProps = new Asc.asc_CImgProperty(props);
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
var value = props.get_WrappingStyle();
|
|
|
|
if (this._state.WrappingStyle!==value) {
|
2017-04-26 13:28:36 +00:00
|
|
|
this.cmbWrapType.suspendEvents();
|
|
|
|
var rec = this.cmbWrapType.menuPicker.store.findWhere({
|
|
|
|
data: value
|
|
|
|
});
|
|
|
|
this.cmbWrapType.menuPicker.selectRecord(rec);
|
|
|
|
this.cmbWrapType.resumeEvents();
|
2016-03-11 00:48:53 +00:00
|
|
|
this._state.WrappingStyle=value;
|
|
|
|
}
|
|
|
|
|
|
|
|
value = props.get_CanBeFlow() && !this._locked;
|
|
|
|
var fromgroup = props.get_FromGroup() || this._locked;
|
2020-01-29 11:12:29 +00:00
|
|
|
var control_props = this.api.asc_IsContentControl() ? this.api.asc_GetContentControlProperties() : null,
|
|
|
|
isPictureControl = !!control_props && (control_props.get_SpecificType()==Asc.c_oAscContentControlSpecificType.Picture) || this._locked;
|
|
|
|
if (this._state.CanBeFlow!==value || this._state.FromGroup!==fromgroup || this._state.isPictureControl!==isPictureControl) {
|
|
|
|
this.cmbWrapType.setDisabled(!value || fromgroup || isPictureControl);
|
2016-03-11 00:48:53 +00:00
|
|
|
this._state.CanBeFlow=value;
|
|
|
|
this._state.FromGroup=fromgroup;
|
2020-01-29 11:12:29 +00:00
|
|
|
this._state.isPictureControl=isPictureControl;
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
value = props.get_Width();
|
|
|
|
if ( Math.abs(this._state.Width-value)>0.001 ) {
|
2019-11-26 11:24:08 +00:00
|
|
|
this.labelWidth[0].innerHTML = this.textWidth + ': ' + Common.Utils.Metric.fnRecalcFromMM(value).toFixed(2) + ' ' + Common.Utils.Metric.getCurrentMetricName();
|
2016-03-11 00:48:53 +00:00
|
|
|
this._state.Width = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
value = props.get_Height();
|
|
|
|
if ( Math.abs(this._state.Height-value)>0.001 ) {
|
2019-11-26 11:24:08 +00:00
|
|
|
this.labelHeight[0].innerHTML = this.textHeight + ': ' + Common.Utils.Metric.fnRecalcFromMM(value).toFixed(2) + ' ' + Common.Utils.Metric.getCurrentMetricName();
|
2016-03-11 00:48:53 +00:00
|
|
|
this._state.Height = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.btnOriginalSize.setDisabled(props.get_ImageUrl()===null || props.get_ImageUrl()===undefined || this._locked);
|
2016-07-07 13:33:13 +00:00
|
|
|
|
|
|
|
var pluginGuid = props.asc_getPluginGuid();
|
|
|
|
value = (pluginGuid !== null && pluginGuid !== undefined);
|
|
|
|
if (this._state.isOleObject!==value) {
|
|
|
|
this.btnInsertFromUrl.setVisible(!value);
|
|
|
|
this.btnInsertFromFile.setVisible(!value);
|
|
|
|
this.btnEditObject.setVisible(value);
|
|
|
|
this.lblReplace.text(value ? this.textEditObject : this.textInsert);
|
2019-02-25 12:11:33 +00:00
|
|
|
this.btnRotate270.setDisabled(value);
|
|
|
|
this.btnRotate90.setDisabled(value);
|
|
|
|
this.btnFlipV.setDisabled(value);
|
|
|
|
this.btnFlipH.setDisabled(value);
|
2016-07-07 13:33:13 +00:00
|
|
|
this._state.isOleObject=value;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this._state.isOleObject) {
|
|
|
|
var plugin = DE.getCollection('Common.Collections.Plugins').findWhere({guid: pluginGuid});
|
2016-08-29 13:45:10 +00:00
|
|
|
this.btnEditObject.setDisabled(plugin===null || plugin ===undefined || this._locked);
|
2016-07-07 13:33:13 +00:00
|
|
|
} else {
|
2016-08-29 13:45:10 +00:00
|
|
|
this.btnInsertFromUrl.setDisabled(pluginGuid===null || this._locked);
|
|
|
|
this.btnInsertFromFile.setDisabled(pluginGuid===null || this._locked);
|
2016-07-07 13:33:13 +00:00
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_ImgWrapStyleChanged: function(style) {
|
2017-04-26 13:28:36 +00:00
|
|
|
if (!this.cmbWrapType) return;
|
2016-03-11 00:48:53 +00:00
|
|
|
if (this._state.WrappingStyle!==style) {
|
2017-04-26 13:28:36 +00:00
|
|
|
this.cmbWrapType.suspendEvents();
|
|
|
|
var rec = this.cmbWrapType.menuPicker.store.findWhere({
|
|
|
|
data: style
|
|
|
|
});
|
|
|
|
this.cmbWrapType.menuPicker.selectRecord(rec);
|
|
|
|
this.cmbWrapType.resumeEvents();
|
2016-03-11 00:48:53 +00:00
|
|
|
this._state.WrappingStyle=style;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-04-26 13:28:36 +00:00
|
|
|
onSelectWrap: function(combo, record){
|
2016-03-11 00:48:53 +00:00
|
|
|
if (this.api) {
|
2017-04-26 13:28:36 +00:00
|
|
|
var props = new Asc.asc_CImgProperty(),
|
|
|
|
data = record.get('data');
|
|
|
|
props.put_WrappingStyle(data);
|
|
|
|
if (this._state.WrappingStyle===Asc.c_oAscWrapStyle2.Inline && data!==Asc.c_oAscWrapStyle2.Inline ) {
|
2016-04-05 12:57:51 +00:00
|
|
|
props.put_PositionH(new Asc.CImagePositionH());
|
2016-03-11 00:48:53 +00:00
|
|
|
props.get_PositionH().put_UseAlign(false);
|
2016-04-05 11:52:34 +00:00
|
|
|
props.get_PositionH().put_RelativeFrom(Asc.c_oAscRelativeFromH.Column);
|
|
|
|
var val = this._originalProps.get_Value_X(Asc.c_oAscRelativeFromH.Column);
|
2016-03-11 00:48:53 +00:00
|
|
|
props.get_PositionH().put_Value(val);
|
|
|
|
|
2016-04-05 12:57:51 +00:00
|
|
|
props.put_PositionV(new Asc.CImagePositionV());
|
2016-03-11 00:48:53 +00:00
|
|
|
props.get_PositionV().put_UseAlign(false);
|
2016-04-05 11:52:34 +00:00
|
|
|
props.get_PositionV().put_RelativeFrom(Asc.c_oAscRelativeFromV.Paragraph);
|
|
|
|
val = this._originalProps.get_Value_Y(Asc.c_oAscRelativeFromV.Paragraph);
|
2016-03-11 00:48:53 +00:00
|
|
|
props.get_PositionV().put_Value(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.api.ImgApply(props);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
},
|
|
|
|
|
|
|
|
setOriginalSize: function() {
|
|
|
|
if (this.api) {
|
|
|
|
var imgsize = this.api.get_OriginalSizeImage();
|
|
|
|
var w = imgsize.get_ImageWidth();
|
|
|
|
var h = imgsize.get_ImageHeight();
|
|
|
|
|
2019-11-26 11:24:08 +00:00
|
|
|
this.labelWidth[0].innerHTML = this.textWidth + ': ' + Common.Utils.Metric.fnRecalcFromMM(w).toFixed(2) + ' ' + Common.Utils.Metric.getCurrentMetricName();
|
|
|
|
this.labelHeight[0].innerHTML = this.textHeight + ': ' + Common.Utils.Metric.fnRecalcFromMM(h).toFixed(2) + ' ' + Common.Utils.Metric.getCurrentMetricName();
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2016-04-18 12:21:15 +00:00
|
|
|
var properties = new Asc.asc_CImgProperty();
|
2016-03-11 00:48:53 +00:00
|
|
|
properties.put_Width(w);
|
|
|
|
properties.put_Height(h);
|
2019-04-11 10:09:28 +00:00
|
|
|
properties.put_ResetCrop(true);
|
2016-03-11 00:48:53 +00:00
|
|
|
this.api.ImgApply(properties);
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-04-27 11:49:17 +00:00
|
|
|
setFitMargins: function() {
|
|
|
|
if (this.api) {
|
|
|
|
var section = this.api.asc_GetSectionProps(),
|
|
|
|
ratio = (this._state.Height>0) ? this._state.Width/this._state.Height : 1,
|
2018-04-17 11:09:31 +00:00
|
|
|
pagew = (this.api.asc_GetCurrentColumnWidth) ? this.api.asc_GetCurrentColumnWidth() : (section.get_W() - section.get_LeftMargin() - section.get_RightMargin()),
|
2017-04-27 11:49:17 +00:00
|
|
|
pageh = section.get_H() - section.get_TopMargin() - section.get_BottomMargin(),
|
|
|
|
pageratio = pagew/pageh,
|
|
|
|
w, h;
|
|
|
|
|
|
|
|
if (ratio>pageratio) {
|
|
|
|
w = pagew;
|
|
|
|
h = w/ratio;
|
|
|
|
} else if (ratio<pageratio) {
|
|
|
|
h = pageh;
|
|
|
|
w = h * ratio;
|
|
|
|
} else {
|
|
|
|
w = pagew;
|
|
|
|
h = pageh;
|
|
|
|
}
|
|
|
|
|
2019-11-26 11:24:08 +00:00
|
|
|
this.labelWidth[0].innerHTML = this.textWidth + ': ' + Common.Utils.Metric.fnRecalcFromMM(w).toFixed(2) + ' ' + Common.Utils.Metric.getCurrentMetricName();
|
|
|
|
this.labelHeight[0].innerHTML = this.textHeight + ': ' + Common.Utils.Metric.fnRecalcFromMM(h).toFixed(2) + ' ' + Common.Utils.Metric.getCurrentMetricName();
|
2017-04-27 11:49:17 +00:00
|
|
|
|
|
|
|
var properties = new Asc.asc_CImgProperty();
|
|
|
|
properties.put_Width(w);
|
|
|
|
properties.put_Height(h);
|
|
|
|
|
|
|
|
if (this._state.WrappingStyle!==Asc.c_oAscWrapStyle2.Inline) {
|
|
|
|
if (ratio>=1) {
|
|
|
|
var position = new Asc.CImagePositionH();
|
|
|
|
position.put_UseAlign(true);
|
|
|
|
position.put_Percent(false);
|
|
|
|
position.put_RelativeFrom(Asc.c_oAscRelativeFromH.Margin);
|
|
|
|
position.put_Align(Asc.c_oAscAlignH.Left);
|
|
|
|
properties.put_PositionH(position);
|
|
|
|
}
|
|
|
|
if (ratio<=1) {
|
|
|
|
position = new Asc.CImagePositionV();
|
|
|
|
position.put_UseAlign(true);
|
|
|
|
position.put_Percent(false);
|
|
|
|
position.put_RelativeFrom(Asc.c_oAscRelativeFromV.Margin);
|
|
|
|
position.put_Align(Asc.c_oAscAlignV.Top);
|
|
|
|
properties.put_PositionV(position);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.api.ImgApply(properties);
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
insertFromUrl: function() {
|
|
|
|
var me = this;
|
|
|
|
(new Common.Views.ImageFromUrlDialog({
|
|
|
|
handler: function(result, value) {
|
|
|
|
if (result == 'ok') {
|
|
|
|
if (me.api) {
|
|
|
|
var checkUrl = value.replace(/ /g, '');
|
|
|
|
if (!_.isEmpty(checkUrl)) {
|
2016-04-18 12:21:15 +00:00
|
|
|
var props = new Asc.asc_CImgProperty();
|
2016-03-11 00:48:53 +00:00
|
|
|
props.put_ImageUrl(checkUrl);
|
|
|
|
me.api.ImgApply(props);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
me.fireEvent('editcomplete', me);
|
|
|
|
}
|
|
|
|
})).show();
|
|
|
|
},
|
|
|
|
|
2018-08-10 06:16:15 +00:00
|
|
|
onBtnRotateClick: function(btn) {
|
|
|
|
var properties = new Asc.asc_CImgProperty();
|
2019-01-14 14:42:58 +00:00
|
|
|
properties.asc_putRotAdd((btn.options.value==1 ? 90 : 270) * 3.14159265358979 / 180);
|
2018-08-10 06:16:15 +00:00
|
|
|
this.api.ImgApply(properties);
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
},
|
|
|
|
|
|
|
|
onBtnFlipClick: function(btn) {
|
|
|
|
var properties = new Asc.asc_CImgProperty();
|
|
|
|
if (btn.options.value==1)
|
2019-01-14 14:42:58 +00:00
|
|
|
properties.asc_putFlipHInvert(true);
|
2018-08-10 06:16:15 +00:00
|
|
|
else
|
2019-01-14 14:42:58 +00:00
|
|
|
properties.asc_putFlipVInvert(true);
|
2018-08-10 06:16:15 +00:00
|
|
|
this.api.ImgApply(properties);
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
},
|
|
|
|
|
2019-04-08 08:04:34 +00:00
|
|
|
onCrop: function(btn, e) {
|
|
|
|
if (this.api) {
|
|
|
|
btn.pressed ? this.api.asc_startEditCrop() : this.api.asc_endEditCrop();
|
|
|
|
}
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
},
|
|
|
|
|
|
|
|
onCropMenu: function(menu, item) {
|
|
|
|
if (this.api) {
|
|
|
|
if (item.value == 1) {
|
|
|
|
this.api.asc_cropFill();
|
|
|
|
} else if (item.value == 2) {
|
|
|
|
this.api.asc_cropFit();
|
|
|
|
} else {
|
|
|
|
item.checked ? this.api.asc_startEditCrop() : this.api.asc_endEditCrop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
},
|
|
|
|
|
2016-03-11 00:48:53 +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();
|
2016-04-05 11:52:34 +00:00
|
|
|
if (Asc.c_oAscTypeSelectElement.Image == elType) {
|
2016-03-11 00:48:53 +00:00
|
|
|
var imgsizeOriginal;
|
|
|
|
if (!me.btnOriginalSize.isDisabled()) {
|
|
|
|
imgsizeOriginal = me.api.get_OriginalSizeImage();
|
|
|
|
if (imgsizeOriginal)
|
|
|
|
imgsizeOriginal = {width:imgsizeOriginal.get_ImageWidth(), height:imgsizeOriginal.get_ImageHeight()};
|
|
|
|
}
|
|
|
|
(new DE.Views.ImageSettingsAdvanced(
|
|
|
|
{
|
|
|
|
imageProps: elValue,
|
|
|
|
sizeOriginal: imgsizeOriginal,
|
2016-03-17 13:31:57 +00:00
|
|
|
sectionProps: me.api.asc_GetSectionProps(),
|
2016-03-11 00:48:53 +00:00
|
|
|
handler: function(result, value) {
|
|
|
|
if (result == 'ok') {
|
|
|
|
if (me.api) {
|
|
|
|
me.api.ImgApply(value.imageProps);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
me.fireEvent('editcomplete', me);
|
|
|
|
}
|
|
|
|
})).show();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
setLocked: function (locked) {
|
|
|
|
this._locked = locked;
|
|
|
|
},
|
|
|
|
|
|
|
|
disableControls: function(disable) {
|
2016-08-17 09:55:21 +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);
|
|
|
|
});
|
|
|
|
this.linkAdvanced.toggleClass('disabled', disable);
|
|
|
|
}
|
2019-04-08 08:04:34 +00:00
|
|
|
|
|
|
|
this.btnCrop.setDisabled(disable || !this.api.asc_canEditCrop());
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
textSize: 'Size',
|
|
|
|
textWrap: 'Wraping Style',
|
|
|
|
textWidth: 'Width',
|
|
|
|
textHeight: 'Height',
|
2019-11-06 08:11:30 +00:00
|
|
|
textOriginalSize: 'Actual Size',
|
2016-07-07 13:33:13 +00:00
|
|
|
textInsert: 'Replace Image',
|
2016-03-11 00:48:53 +00:00
|
|
|
textFromUrl: 'From URL',
|
|
|
|
textFromFile: 'From File',
|
|
|
|
textAdvanced: 'Show advanced settings',
|
|
|
|
txtInline: 'Inline',
|
|
|
|
txtSquare: 'Square',
|
|
|
|
txtTight: 'Tight',
|
|
|
|
txtThrough: 'Through',
|
|
|
|
txtTopAndBottom: 'Top and bottom',
|
|
|
|
txtBehind: 'Behind',
|
2016-07-07 13:33:13 +00:00
|
|
|
txtInFront: 'In front',
|
|
|
|
textEditObject: 'Edit Object',
|
2017-04-27 11:49:17 +00:00
|
|
|
textEdit: 'Edit',
|
2018-08-10 06:16:15 +00:00
|
|
|
textFitMargins: 'Fit to Margin',
|
|
|
|
textRotation: 'Rotation',
|
|
|
|
textRotate90: 'Rotate 90°',
|
|
|
|
textFlip: 'Flip',
|
2019-02-27 10:11:28 +00:00
|
|
|
textHint270: 'Rotate 90° Counterclockwise',
|
|
|
|
textHint90: 'Rotate 90° Clockwise',
|
2019-02-26 15:59:16 +00:00
|
|
|
textHintFlipV: 'Flip Vertically',
|
2019-04-09 07:21:03 +00:00
|
|
|
textHintFlipH: 'Flip Horizontally',
|
|
|
|
textCrop: 'Crop',
|
|
|
|
textCropFill: 'Fill',
|
|
|
|
textCropFit: 'Fit'
|
2016-03-11 00:48:53 +00:00
|
|
|
}, DE.Views.ImageSettings || {}));
|
|
|
|
});
|