Merge pull request #713 from ONLYOFFICE/feature/pe-slide-size
Feature/pe slide size
This commit is contained in:
commit
7d447f00ca
|
@ -110,11 +110,10 @@ define([
|
|||
};
|
||||
this._isAddingShape = false;
|
||||
this.slideSizeArr = [
|
||||
[254, 190.5], [254, 143], [254, 158.7], [254, 190.5], [338.3, 253.7], [355.6, 266.7],
|
||||
[275, 190.5], [300.7, 225.5], [199.1, 149.3], [285.7, 190.5], [254, 190.5], [203.2, 25.4]
|
||||
];
|
||||
{ size: [9144000, 6858000], ratio: 6858000/9144000, type: Asc.c_oAscSlideSZType.SzScreen4x3},
|
||||
{ size: [12192000, 6858000], ratio: 6858000/12192000, type: Asc.c_oAscSlideSZType.SzCustom} ];
|
||||
this.currentPageSize = {
|
||||
type: -1,
|
||||
type: Asc.c_oAscSlideSZType.SzCustom,
|
||||
width: 0,
|
||||
height: 0
|
||||
};
|
||||
|
@ -621,24 +620,25 @@ define([
|
|||
}
|
||||
},
|
||||
|
||||
onApiPageSize: function(width, height) {
|
||||
onApiPageSize: function(width, height, type) {
|
||||
if (Math.abs(this.currentPageSize.width - width) > 0.001 ||
|
||||
Math.abs(this.currentPageSize.height - height) > 0.001) {
|
||||
Math.abs(this.currentPageSize.height - height) > 0.001 ||
|
||||
this.currentPageSize.type !== type) {
|
||||
this.currentPageSize.width = width;
|
||||
this.currentPageSize.height = height;
|
||||
this.currentPageSize.type = -1;
|
||||
this.currentPageSize.type = type;
|
||||
|
||||
var portrait = (height>width);
|
||||
var ratio = height/width;
|
||||
var idx = -1;
|
||||
for (var i = 0; i < this.slideSizeArr.length; i++) {
|
||||
if (Math.abs(this.slideSizeArr[i][portrait ? 1 : 0] - this.currentPageSize.width) < 0.001 &&
|
||||
Math.abs(this.slideSizeArr[i][portrait ? 0 : 1] - this.currentPageSize.height) < 0.001) {
|
||||
this.currentPageSize.type = i;
|
||||
if (Math.abs(this.slideSizeArr[i].ratio - ratio) < 0.001 ) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.toolbar.btnSlideSize.menu.items[0].setChecked(this.currentPageSize.type == 0);
|
||||
this.toolbar.btnSlideSize.menu.items[1].setChecked(this.currentPageSize.type == 1);
|
||||
this.toolbar.btnSlideSize.menu.items[0].setChecked(idx == 0);
|
||||
this.toolbar.btnSlideSize.menu.items[1].setChecked(idx == 1);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1743,18 +1743,15 @@ define([
|
|||
|
||||
onSlideSize: function(menu, item) {
|
||||
if (item.value !== 'advanced') {
|
||||
var portrait = (this.currentPageSize.height > this.currentPageSize.width);
|
||||
var newwidth = (this.currentPageSize.height / this.slideSizeArr[item.value].ratio);
|
||||
this.currentPageSize = {
|
||||
type : item.value,
|
||||
width : this.slideSizeArr[item.value][portrait ? 1 : 0],
|
||||
height : this.slideSizeArr[item.value][portrait ? 0 : 1]
|
||||
type : this.slideSizeArr[item.value].type,
|
||||
width : newwidth,
|
||||
height : this.currentPageSize.height
|
||||
};
|
||||
|
||||
if (this.api)
|
||||
this.api.changeSlideSize(
|
||||
this.slideSizeArr[item.value][portrait ? 1 : 0],
|
||||
this.slideSizeArr[item.value][portrait ? 0 : 1]
|
||||
);
|
||||
this.api.changeSlideSize(this.currentPageSize.width, this.currentPageSize.height, this.currentPageSize.type);
|
||||
|
||||
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
|
||||
Common.component.Analytics.trackEvent('ToolBar', 'Slide Size');
|
||||
|
@ -1766,10 +1763,19 @@ define([
|
|||
if (result == 'ok') {
|
||||
props = dlg.getSettings();
|
||||
me.currentPageSize = { type: props[0], width: props[1], height: props[2] };
|
||||
me.toolbar.btnSlideSize.menu.items[0].setChecked(props[0] == 0);
|
||||
me.toolbar.btnSlideSize.menu.items[1].setChecked(props[0] == 1);
|
||||
var ratio = me.currentPageSize.height/me.currentPageSize.width,
|
||||
idx = -1;
|
||||
for (var i = 0; i < me.slideSizeArr.length; i++) {
|
||||
if (Math.abs(me.slideSizeArr[i].ratio - ratio) < 0.001 ) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
me.toolbar.btnSlideSize.menu.items[0].setChecked(idx == 0);
|
||||
me.toolbar.btnSlideSize.menu.items[1].setChecked(idx == 1);
|
||||
if (me.api)
|
||||
me.api.changeSlideSize(props[1], props[2]);
|
||||
me.api.changeSlideSize(props[1], props[2], props[0]);
|
||||
}
|
||||
|
||||
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
||||
|
|
|
@ -99,37 +99,37 @@ define([
|
|||
el: $('#slide-size-combo'),
|
||||
cls: 'input-group-nr',
|
||||
style: 'width: 100%;',
|
||||
menuStyle: 'min-width: 218px;',
|
||||
menuStyle: 'min-width: 218px;max-height: 185px;',
|
||||
editable: false,
|
||||
takeFocusOnClose: true,
|
||||
data: [
|
||||
{value:0, displayValue: this.txtStandard , size: [254, 190.5]},
|
||||
{value:1, displayValue: this.txtWidescreen1 , size: [254, 143]},
|
||||
{value:2, displayValue: this.txtWidescreen2 , size: [254, 158.7]},
|
||||
{value:3, displayValue: this.txtLetter , size: [254, 190.5]},
|
||||
{value:4, displayValue: this.txtLedger , size: [338.3, 253.7]},
|
||||
{value:5, displayValue: this.txtA3 , size: [355.6, 266.7]},
|
||||
{value:6, displayValue: this.txtA4 , size: [275, 190.5]},
|
||||
{value:7, displayValue: this.txtB4 , size: [300.7, 225.5]},
|
||||
{value:8, displayValue: this.txtB5 , size: [199.1, 149.3]},
|
||||
{value:9, displayValue: this.txt35 , size: [285.7, 190.5]},
|
||||
{value:10, displayValue: this.txtOverhead , size: [254, 190.5]},
|
||||
{value:11, displayValue: this.txtBanner , size: [203.2, 25.4]},
|
||||
{value:-1, displayValue: this.txtCustom , size: []}
|
||||
{value:Asc.c_oAscSlideSZType.SzScreen4x3, displayValue: this.txtStandard , size: [9144000, 6858000]},
|
||||
{value:Asc.c_oAscSlideSZType.SzScreen16x9, displayValue: this.txtWidescreen + ' (16:9)', size: [9144000, 5143500]},
|
||||
{value:Asc.c_oAscSlideSZType.SzScreen16x10, displayValue: this.txtWidescreen + ' (16:10)', size: [9144000, 5715000]},
|
||||
{value:Asc.c_oAscSlideSZType.SzLetter, displayValue: this.txtLetter , size: [9144000, 6858000]},
|
||||
{value:Asc.c_oAscSlideSZType.SzLedger, displayValue: this.txtLedger , size: [12179300, 9134475]},
|
||||
{value:Asc.c_oAscSlideSZType.SzA3, displayValue: this.txtA3 , size: [12801600, 9601200]},
|
||||
{value:Asc.c_oAscSlideSZType.SzA4, displayValue: this.txtA4 , size: [9906000, 6858000]},
|
||||
{value:Asc.c_oAscSlideSZType.SzB4ISO, displayValue: this.txtB4 , size: [10826750, 8120063]},
|
||||
{value:Asc.c_oAscSlideSZType.SzB5ISO, displayValue: this.txtB5 , size: [7169150, 5376863]},
|
||||
{value:Asc.c_oAscSlideSZType.Sz35mm, displayValue: this.txt35 , size: [10287000, 6858000]},
|
||||
{value:Asc.c_oAscSlideSZType.SzOverhead, displayValue: this.txtOverhead , size: [9144000, 6858000]},
|
||||
{value:Asc.c_oAscSlideSZType.SzBanner, displayValue: this.txtBanner , size: [7315200, 914400]},
|
||||
{value:Asc.c_oAscSlideSZType.SzWidescreen, displayValue: this.txtWidescreen , size: [12192000, 6858000]},
|
||||
{value:Asc.c_oAscSlideSZType.SzCustom, displayValue: this.txtCustom , size: [10058400, 7772400]}
|
||||
]
|
||||
});
|
||||
this.cmbSlideSize.setValue(0);
|
||||
this.cmbSlideSize.setValue(Asc.c_oAscSlideSZType.SzScreen4x3);
|
||||
this.cmbSlideSize.on('selected', _.bind(function(combo, record) {
|
||||
this._noApply = true;
|
||||
if (record.value<0) {
|
||||
// set current slide size
|
||||
} else {
|
||||
var w = record.size[0],
|
||||
h = record.size[1],
|
||||
orient = this.cmbSlideOrientation.getValue(),
|
||||
cond = orient==0 && w>h || orient==1 && h>w;
|
||||
this.spnWidth.setValue(Common.Utils.Metric.fnRecalcFromMM(cond ? h : w), true);
|
||||
this.spnHeight.setValue(Common.Utils.Metric.fnRecalcFromMM(cond ? w : h), true);
|
||||
var w = record.size[0]/36000,
|
||||
h = record.size[1]/36000,
|
||||
orient = this.cmbSlideOrientation.getValue();
|
||||
this.spnWidth.setValue(Common.Utils.Metric.fnRecalcFromMM(orient ? w : h), true);
|
||||
this.spnHeight.setValue(Common.Utils.Metric.fnRecalcFromMM(orient ? h : w), true);
|
||||
}
|
||||
this._noApply = false;
|
||||
}, this));
|
||||
|
@ -146,8 +146,8 @@ define([
|
|||
this.spinners.push(this.spnWidth);
|
||||
this.spnWidth.on('change', _.bind(function(field, newValue, oldValue, eOpts){
|
||||
if (!this._noApply) {
|
||||
if (this.cmbSlideSize.getValue() >-1)
|
||||
this.cmbSlideSize.setValue(-1);
|
||||
if (this.cmbSlideSize.getValue() !== Asc.c_oAscSlideSZType.SzCustom)
|
||||
this.cmbSlideSize.setValue(Asc.c_oAscSlideSZType.SzCustom);
|
||||
var w = this.spnWidth.getNumberValue(),
|
||||
h = this.spnHeight.getNumberValue();
|
||||
this.cmbSlideOrientation.setValue( h>w ? 0 : 1);
|
||||
|
@ -166,8 +166,8 @@ define([
|
|||
this.spinners.push(this.spnHeight);
|
||||
this.spnHeight.on('change', _.bind(function(field, newValue, oldValue, eOpts){
|
||||
if (!this._noApply) {
|
||||
if (this.cmbSlideSize.getValue() >-1)
|
||||
this.cmbSlideSize.setValue(-1);
|
||||
if (this.cmbSlideSize.getValue() !==Asc.c_oAscSlideSZType.SzCustom)
|
||||
this.cmbSlideSize.setValue(Asc.c_oAscSlideSZType.SzCustom);
|
||||
var w = this.spnWidth.getNumberValue(),
|
||||
h = this.spnHeight.getNumberValue();
|
||||
this.cmbSlideOrientation.setValue( h>w ? 0 : 1);
|
||||
|
@ -230,16 +230,42 @@ define([
|
|||
},
|
||||
|
||||
setSettings: function (type, pagewitdh, pageheight) {
|
||||
this.spnWidth.setValue(Common.Utils.Metric.fnRecalcFromMM(pagewitdh), true);
|
||||
this.spnHeight.setValue(Common.Utils.Metric.fnRecalcFromMM(pageheight), true);
|
||||
this.cmbSlideSize.setValue(type);
|
||||
this.spnWidth.setValue(Common.Utils.Metric.fnRecalcFromMM(pagewitdh/36000), true);
|
||||
this.spnHeight.setValue(Common.Utils.Metric.fnRecalcFromMM(pageheight/36000), true);
|
||||
this.cmbSlideOrientation.setValue((pageheight>pagewitdh) ? 0 : 1);
|
||||
|
||||
var portrait = pageheight>pagewitdh,
|
||||
w = portrait ? pageheight : pagewitdh,
|
||||
h = portrait ? pagewitdh : pageheight,
|
||||
store = this.cmbSlideSize.store,
|
||||
arr = [],
|
||||
preset = Asc.c_oAscSlideSZType.SzCustom;
|
||||
for (var i=0; i<store.length; i++) {
|
||||
var item = store.at(i);
|
||||
if (Math.abs(item.get('size')[0] - w) < 0.001 && Math.abs(item.get('size')[1] - h) < 0.001)
|
||||
arr.push(item.get('value'));
|
||||
}
|
||||
if (arr.length>1) {
|
||||
for (var i=0; i<arr.length; i++)
|
||||
(arr[i]==type) && (preset = arr[i]);
|
||||
} else if (arr.length>0)
|
||||
preset = arr[0];
|
||||
this.cmbSlideSize.setValue(preset);
|
||||
},
|
||||
|
||||
getSettings: function() {
|
||||
var props = [this.cmbSlideSize.getValue(), Common.Utils.Metric.fnRecalcToMM(this.spnWidth.getNumberValue()), Common.Utils.Metric.fnRecalcToMM(this.spnHeight.getNumberValue())];
|
||||
return props;
|
||||
var type = this.cmbSlideSize.getValue(),
|
||||
width, height;
|
||||
if (type==Asc.c_oAscSlideSZType.SzCustom) {
|
||||
width = Common.Utils.Metric.fnRecalcToMM(this.spnWidth.getNumberValue())*36000;
|
||||
height = Common.Utils.Metric.fnRecalcToMM(this.spnHeight.getNumberValue())*36000;
|
||||
} else {
|
||||
var record = this.cmbSlideSize.getSelectedRecord(),
|
||||
orient = this.cmbSlideOrientation.getValue();
|
||||
width = record.size[orient ? 0 : 1];
|
||||
height = record.size[orient ? 1 : 0];
|
||||
}
|
||||
|
||||
return [type, width, height];
|
||||
},
|
||||
|
||||
updateMetricUnit: function() {
|
||||
|
@ -271,6 +297,7 @@ define([
|
|||
txtCustom: 'Custom',
|
||||
textSlideOrientation: 'Slide Orientation',
|
||||
strPortrait: 'Portrait',
|
||||
strLandscape: 'Landscape'
|
||||
strLandscape: 'Landscape',
|
||||
txtWidescreen: 'Widescreen'
|
||||
}, PE.Views.SlideSizeSettings || {}))
|
||||
});
|
|
@ -1700,8 +1700,9 @@
|
|||
"PE.Views.SlideSizeSettings.txtLetter": "Letter Paper (8.5x11 in)",
|
||||
"PE.Views.SlideSizeSettings.txtOverhead": "Overhead",
|
||||
"PE.Views.SlideSizeSettings.txtStandard": "Standard (4:3)",
|
||||
"PE.Views.SlideSizeSettings.txtWidescreen1": "Widescreen (16:9)",
|
||||
"PE.Views.SlideSizeSettings.txtWidescreen2": "Widescreen (16:10)",
|
||||
"PE.Views.SlideSizeSettings.txtWidescreen": "Widescreen",
|
||||
"del_PE.Views.SlideSizeSettings.txtWidescreen1": "Widescreen (16:9)",
|
||||
"del_PE.Views.SlideSizeSettings.txtWidescreen2": "Widescreen (16:10)",
|
||||
"PE.Views.Statusbar.goToPageText": "Go to Slide",
|
||||
"PE.Views.Statusbar.pageIndexText": "Slide {0} of {1}",
|
||||
"PE.Views.Statusbar.textShowBegin": "Show from Beginning",
|
||||
|
|
|
@ -57,10 +57,11 @@ define([
|
|||
infoObj,
|
||||
modalView,
|
||||
_licInfo,
|
||||
_lang;
|
||||
_lang,
|
||||
_currentPageSize;
|
||||
|
||||
var _slideSizeArr = [
|
||||
[254, 190.5], [254, 143]
|
||||
[9144000, 6858000, Asc.c_oAscSlideSZType.SzScreen4x3], [12192000, 6858000, Asc.c_oAscSlideSZType.SzCustom]
|
||||
];
|
||||
|
||||
return {
|
||||
|
@ -330,10 +331,12 @@ define([
|
|||
// API handlers
|
||||
|
||||
onApiPageSize: function(width, height) {
|
||||
_currentPageSize = {width: width, height: height};
|
||||
var $input = $('#page-settings-view input[name="slide-size"]');
|
||||
if ($input.length > 0) {
|
||||
var ratio = height/width;
|
||||
for (var i = 0; i < _slideSizeArr.length; i++) {
|
||||
if (Math.abs(_slideSizeArr[i][0] - width) < 0.001 && Math.abs(_slideSizeArr[i][1] - height) < 0.001) {
|
||||
if (Math.abs(_slideSizeArr[i][1]/_slideSizeArr[i][0] - ratio) < 0.001 ) {
|
||||
$input.val([i]);
|
||||
break;
|
||||
}
|
||||
|
@ -404,8 +407,13 @@ define([
|
|||
_onSlideSize: function(e) {
|
||||
var $target = $(e.currentTarget).find('input');
|
||||
if ($target && this.api) {
|
||||
var value = parseFloat($target.prop('value'));
|
||||
this.api.changeSlideSize(_slideSizeArr[value][0], _slideSizeArr[value][1]);
|
||||
var value = parseFloat($target.prop('value')),
|
||||
ratio = _slideSizeArr[value][1] / _slideSizeArr[value][0];
|
||||
_currentPageSize = {
|
||||
width : ((_currentPageSize.height || _slideSizeArr[value][1]) / ratio),
|
||||
height : _currentPageSize.height
|
||||
};
|
||||
this.api.changeSlideSize(_currentPageSize.width, _currentPageSize.height, _slideSizeArr[value][2]);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue