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 3/28/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!spreadsheeteditor/main/app/template/ImageSettings.template',
|
|
|
|
'jquery',
|
|
|
|
'underscore',
|
|
|
|
'backbone',
|
|
|
|
'common/main/lib/component/Button',
|
|
|
|
'common/main/lib/component/MetricSpinner',
|
2017-01-19 07:59:20 +00:00
|
|
|
'common/main/lib/view/ImageFromUrlDialog',
|
|
|
|
'spreadsheeteditor/main/app/view/ImageSettingsAdvanced'
|
2016-03-11 00:48:53 +00:00
|
|
|
], function (menuTemplate, $, _, Backbone) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
SSE.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._nRatio = 1;
|
|
|
|
this._state = {
|
|
|
|
Width: 0,
|
|
|
|
Height: 0,
|
2016-05-24 11:45:53 +00:00
|
|
|
DisabledControls: false,
|
2016-07-07 13:33:13 +00:00
|
|
|
keepRatio: false,
|
2019-04-09 11:29:51 +00:00
|
|
|
isOleObject: false,
|
|
|
|
cropMode: false
|
2016-03-11 00:48:53 +00:00
|
|
|
};
|
|
|
|
this.spinners = [];
|
|
|
|
this.lockedControls = [];
|
|
|
|
this._locked = false;
|
|
|
|
|
|
|
|
this._noApply = false;
|
2016-08-29 14:26:34 +00:00
|
|
|
this._originalProps = null;
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
this.render();
|
2016-08-24 08:44:45 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
render: function () {
|
|
|
|
var el = $(this.el);
|
|
|
|
el.html(this.template({
|
|
|
|
scope: this
|
|
|
|
}));
|
2017-01-19 07:59:20 +00:00
|
|
|
|
|
|
|
this.linkAdvanced = $('#image-advanced-link');
|
2016-08-24 08:44:45 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
setApi: function(api) {
|
|
|
|
if ( api == undefined ) return;
|
|
|
|
this.api = api;
|
2019-04-09 07:22:01 +00:00
|
|
|
if (this.api) {
|
|
|
|
this.api.asc_registerCallback('asc_ChangeCropState', _.bind(this._changeCropState, this));
|
|
|
|
}
|
2016-08-24 08:44:45 +00:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2016-08-24 08:44:45 +00:00
|
|
|
createDelayedControls: function() {
|
|
|
|
var me = this;
|
2016-03-11 00:48:53 +00:00
|
|
|
this.spnWidth = new Common.UI.MetricSpinner({
|
|
|
|
el: $('#image-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: $('#image-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.btnRatio = new Common.UI.Button({
|
|
|
|
cls: 'btn-toolbar',
|
|
|
|
iconCls: 'advanced-btn-ratio',
|
|
|
|
style: 'margin-bottom: 1px;',
|
|
|
|
enableToggle: true,
|
|
|
|
hint: this.textKeepRatio
|
|
|
|
});
|
|
|
|
this.btnRatio.render($('#image-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();
|
|
|
|
}
|
2016-05-24 11:45:53 +00:00
|
|
|
if (this.api) {
|
|
|
|
var props = new Asc.asc_CImgProperty();
|
|
|
|
props.asc_putLockAspect(btn.pressed);
|
|
|
|
this.api.asc_setGraphicObjectProps(props);
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
}, this));
|
|
|
|
|
|
|
|
this.btnOriginalSize = new Common.UI.Button({
|
|
|
|
el: $('#image-button-original-size')
|
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnOriginalSize);
|
|
|
|
|
|
|
|
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.spnWidth.on('change', _.bind(this.onWidthChange, this));
|
|
|
|
this.spnHeight.on('change', _.bind(this.onHeightChange, this));
|
|
|
|
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.asc_changeImageFromFile();
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', this);
|
2017-08-29 09:29:54 +00:00
|
|
|
this._isFromFile = false;
|
2016-03-11 00:48:53 +00:00
|
|
|
}, 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
|
|
|
Common.NotificationCenter.trigger('edit:complete', this);
|
|
|
|
}, this));
|
2016-03-11 00:48:53 +00:00
|
|
|
this.btnInsertFromUrl.on('click', _.bind(this.insertFromUrl, this));
|
|
|
|
|
2016-07-07 13:33:13 +00:00
|
|
|
this.lblReplace = $('#image-lbl-replace');
|
2017-01-19 07:59:20 +00:00
|
|
|
|
2019-11-19 12:43:26 +00:00
|
|
|
var w = this.btnOriginalSize.cmpEl.outerWidth();
|
2019-04-09 07:22:01 +00:00
|
|
|
this.btnCrop = new Common.UI.Button({
|
|
|
|
cls: 'btn-text-split-default',
|
|
|
|
caption: this.textCrop,
|
|
|
|
split: true,
|
|
|
|
enableToggle: true,
|
|
|
|
allowDepress: true,
|
2019-04-09 11:29:51 +00:00
|
|
|
pressed: this._state.cropMode,
|
2019-11-19 12:43:26 +00:00
|
|
|
width: w,
|
2019-04-09 07:22:01 +00:00
|
|
|
menu : new Common.UI.Menu({
|
2019-11-19 12:43:26 +00:00
|
|
|
style : 'min-width:' + w + 'px;',
|
2019-04-09 07:22:01 +00:00
|
|
|
items: [
|
|
|
|
{
|
|
|
|
caption: this.textCrop,
|
|
|
|
checkable: true,
|
|
|
|
allowDepress: true,
|
2019-04-09 11:29:51 +00:00
|
|
|
checked: this._state.cropMode,
|
2019-04-09 07:22:01 +00:00
|
|
|
value: 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
caption: this.textCropFill,
|
|
|
|
value: 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
caption: this.textCropFit,
|
|
|
|
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);
|
|
|
|
|
2018-08-30 14:11:49 +00:00
|
|
|
this.btnRotate270 = new Common.UI.Button({
|
|
|
|
cls: 'btn-toolbar',
|
2019-11-21 16:15:47 +00:00
|
|
|
iconCls: 'toolbar__icon btn-rotate-270',
|
2018-08-30 14:11:49 +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 16:15:47 +00:00
|
|
|
iconCls: 'toolbar__icon btn-rotate-90',
|
2018-08-30 14:11:49 +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 16:15:47 +00:00
|
|
|
iconCls: 'toolbar__icon btn-flip-vert',
|
2018-08-30 14:11:49 +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 16:15:47 +00:00
|
|
|
iconCls: 'toolbar__icon btn-flip-hor',
|
2018-08-30 14:11:49 +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);
|
|
|
|
|
2017-01-19 07:59:20 +00:00
|
|
|
$(this.el).on('click', '#image-advanced-link', _.bind(this.openAdvancedSettings, this));
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
createDelayedElements: function() {
|
2016-08-24 08:44:45 +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
|
|
|
},
|
|
|
|
|
2017-01-19 07:59:20 +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.asc_getGraphicObjectProps();
|
|
|
|
if (selectedElements && selectedElements.length>0){
|
|
|
|
var elType, elValue;
|
|
|
|
for (var i = selectedElements.length - 1; i >= 0; i--) {
|
|
|
|
elType = selectedElements[i].asc_getObjectType();
|
|
|
|
elValue = selectedElements[i].asc_getObjectValue();
|
|
|
|
if (Asc.c_oAscTypeSelectElement.Image == elType) {
|
|
|
|
(new SSE.Views.ImageSettingsAdvanced(
|
|
|
|
{
|
|
|
|
imageProps: elValue,
|
|
|
|
api: me.api,
|
|
|
|
handler: function(result, value) {
|
|
|
|
if (result == 'ok') {
|
|
|
|
if (me.api) {
|
|
|
|
me.api.asc_setGraphicObjectProps(value.imageProps);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', me);
|
|
|
|
}
|
|
|
|
})).show();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
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-08-29 14:26:34 +00:00
|
|
|
this._originalProps = new Asc.asc_CImgProperty(props);
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
var value = props.asc_getWidth();
|
|
|
|
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.asc_getHeight();
|
|
|
|
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.asc_getHeight()>0)
|
|
|
|
this._nRatio = props.asc_getWidth()/props.asc_getHeight();
|
|
|
|
|
2016-05-24 11:45:53 +00:00
|
|
|
value = props.asc_getLockAspect();
|
|
|
|
if (this._state.keepRatio!==value) {
|
|
|
|
this.btnRatio.toggle(value);
|
|
|
|
this._state.keepRatio=value;
|
|
|
|
}
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
this.btnOriginalSize.setDisabled(props.asc_getImageUrl()===null || props.asc_getImageUrl()===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 = SSE.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
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
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) {
|
|
|
|
var props = new Asc.asc_CImgProperty();
|
|
|
|
props.asc_putWidth(Common.Utils.Metric.fnRecalcToMM(w));
|
|
|
|
props.asc_putHeight(Common.Utils.Metric.fnRecalcToMM(h));
|
|
|
|
this.api.asc_setGraphicObjectProps(props);
|
|
|
|
}
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', this);
|
|
|
|
},
|
|
|
|
|
|
|
|
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) {
|
|
|
|
var props = new Asc.asc_CImgProperty();
|
|
|
|
props.asc_putWidth(Common.Utils.Metric.fnRecalcToMM(w));
|
|
|
|
props.asc_putHeight(Common.Utils.Metric.fnRecalcToMM(h));
|
|
|
|
this.api.asc_setGraphicObjectProps(props);
|
|
|
|
}
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', this);
|
|
|
|
},
|
|
|
|
|
|
|
|
setOriginalSize: function() {
|
|
|
|
if (this.api) {
|
|
|
|
var imgsize = this.api.asc_getOriginalImageSize();
|
|
|
|
var w = imgsize.asc_getImageWidth();
|
|
|
|
var h = imgsize.asc_getImageHeight();
|
|
|
|
|
|
|
|
var properties = new Asc.asc_CImgProperty();
|
|
|
|
properties.asc_putWidth(w);
|
|
|
|
properties.asc_putHeight(h);
|
2019-04-11 10:09:28 +00:00
|
|
|
properties.put_ResetCrop(true);
|
2016-03-11 00:48:53 +00:00
|
|
|
this.api.asc_setGraphicObjectProps(properties);
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', this);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
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)) {
|
|
|
|
var props = new Asc.asc_CImgProperty();
|
|
|
|
props.asc_putImageUrl(checkUrl);
|
|
|
|
me.api.asc_setGraphicObjectProps(props);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', me);
|
|
|
|
}
|
|
|
|
})).show();
|
|
|
|
},
|
|
|
|
|
2019-04-09 07:22:01 +00:00
|
|
|
_changeCropState: function(state) {
|
2019-04-09 11:29:51 +00:00
|
|
|
this._state.cropMode = state;
|
|
|
|
|
|
|
|
if (!this.btnCrop) return;
|
2019-04-09 07:22:01 +00:00
|
|
|
this.btnCrop.toggle(state, true);
|
|
|
|
this.btnCrop.menu.items[0].setChecked(state, true);
|
|
|
|
},
|
|
|
|
|
|
|
|
onCrop: function(btn, e) {
|
|
|
|
if (this.api) {
|
|
|
|
btn.pressed ? this.api.asc_startEditCrop() : this.api.asc_endEditCrop();
|
|
|
|
}
|
2019-04-09 11:29:51 +00:00
|
|
|
Common.NotificationCenter.trigger('edit:complete', this);
|
2019-04-09 07:22:01 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
2019-04-09 11:29:51 +00:00
|
|
|
Common.NotificationCenter.trigger('edit:complete', this);
|
2019-04-09 07:22:01 +00:00
|
|
|
},
|
|
|
|
|
2018-08-30 14:11:49 +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-30 14:11:49 +00:00
|
|
|
this.api.asc_setGraphicObjectProps(properties);
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', 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-30 14:11:49 +00:00
|
|
|
else
|
2019-01-14 14:42:58 +00:00
|
|
|
properties.asc_putFlipVInvert(true);
|
2018-08-30 14:11:49 +00:00
|
|
|
this.api.asc_setGraphicObjectProps(properties);
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', this);
|
|
|
|
},
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
setLocked: function (locked) {
|
|
|
|
this._locked = locked;
|
|
|
|
},
|
|
|
|
|
|
|
|
disableControls: function(disable) {
|
2016-08-24 08:44:45 +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-19 07:59:20 +00:00
|
|
|
this.linkAdvanced.toggleClass('disabled', disable);
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
2019-04-09 07:22:01 +00:00
|
|
|
this.btnCrop.setDisabled(disable || !this.api.asc_canEditCrop());
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
textKeepRatio: 'Constant Proportions',
|
|
|
|
textSize: 'Size',
|
|
|
|
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',
|
2016-07-07 13:33:13 +00:00
|
|
|
textFromFile: 'From File',
|
|
|
|
textEditObject: 'Edit Object',
|
2017-01-19 07:59:20 +00:00
|
|
|
textEdit: 'Edit',
|
2018-08-30 14:11:49 +00:00
|
|
|
textAdvanced: 'Show advanced settings',
|
|
|
|
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-27 09:52:19 +00:00
|
|
|
textHintFlipV: 'Flip Vertically',
|
2019-04-09 07:22:01 +00:00
|
|
|
textHintFlipH: 'Flip Horizontally',
|
|
|
|
textCrop: 'Crop',
|
|
|
|
textCropFill: 'Fill',
|
|
|
|
textCropFit: 'Fit'
|
2016-03-11 00:48:53 +00:00
|
|
|
}, SSE.Views.ImageSettings || {}));
|
|
|
|
});
|