[SSE] Scale Dialog (add set defaults, get settings)
This commit is contained in:
parent
802ed94a99
commit
28d8ad8df7
|
@ -3364,6 +3364,11 @@ define([
|
||||||
var win = new SSE.Views.ScaleDialog({
|
var win = new SSE.Views.ScaleDialog({
|
||||||
api: me.api,
|
api: me.api,
|
||||||
handler: function(dlg, result) {
|
handler: function(dlg, result) {
|
||||||
|
if (dlg == 'ok') {
|
||||||
|
if (me.api && result) {
|
||||||
|
me.api.asc_SetPrintScale(result.width, result.height, result.scale);
|
||||||
|
}
|
||||||
|
}
|
||||||
Common.NotificationCenter.trigger('edit:complete');
|
Common.NotificationCenter.trigger('edit:complete');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -88,6 +88,8 @@ define([
|
||||||
|
|
||||||
this.options.tpl = _.template(this.template)(this.options);
|
this.options.tpl = _.template(this.template)(this.options);
|
||||||
|
|
||||||
|
this.api = this.options.api;
|
||||||
|
|
||||||
Common.UI.Window.prototype.initialize.call(this, this.options);
|
Common.UI.Window.prototype.initialize.call(this, this.options);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -137,18 +139,19 @@ define([
|
||||||
var $window = this.getChild();
|
var $window = this.getChild();
|
||||||
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
|
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
|
||||||
|
|
||||||
|
this.afterRender();
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleInput: function(state) {
|
afterRender: function() {
|
||||||
if (this.options.handler) {
|
this._setDefaults();
|
||||||
this.options.handler.call(this, this, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.close();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onBtnClick: function(event) {
|
onBtnClick: function(event) {
|
||||||
this._handleInput(event.currentTarget.attributes['result'].value);
|
var state = event.currentTarget.attributes['result'].value;
|
||||||
|
if (this.options.handler) {
|
||||||
|
this.options.handler.call(this, state, (state == 'ok') ? this.getSettings() : undefined);
|
||||||
|
}
|
||||||
|
this.close();
|
||||||
},
|
},
|
||||||
|
|
||||||
setDisabledScale: function() {
|
setDisabledScale: function() {
|
||||||
|
@ -160,6 +163,32 @@ define([
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_setDefaults: function (props) {
|
||||||
|
if (this.api) {
|
||||||
|
var pageSetup = this.api.asc_getPageOptions().asc_getPageSetup(),
|
||||||
|
width = pageSetup.asc_getFitToWidth(),
|
||||||
|
height = pageSetup.asc_getFitToHeight(),
|
||||||
|
scale = pageSetup.asc_getScale();
|
||||||
|
this._state.width = (width !== null && width !== undefined) ? width : 'Auto';
|
||||||
|
this._state.height = (height !== null && height !== undefined) ? height : 'Auto';
|
||||||
|
this.spnScaleWidth.setValue(this._state.width);
|
||||||
|
this.spnScaleHeight.setValue(this._state.height);
|
||||||
|
this.spnScale.setValue((scale !== null && scale !== undefined) ? scale : '100 %');
|
||||||
|
|
||||||
|
this.setDisabledScale();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getSettings: function () {
|
||||||
|
var width = this.spnScaleWidth.getValue(),
|
||||||
|
height = this.spnScaleHeight.getValue();
|
||||||
|
var props = {};
|
||||||
|
props.width = (width !== 'Auto') ? width : null;
|
||||||
|
props.height = (height !== 'Auto') ? height : null;
|
||||||
|
props.scale = !this.spnScale.disabled ? this.spnScale.getNumberValue() : null;
|
||||||
|
return props;
|
||||||
|
},
|
||||||
|
|
||||||
textTitle: 'Scale Settings',
|
textTitle: 'Scale Settings',
|
||||||
cancelButtonText: 'Cancel',
|
cancelButtonText: 'Cancel',
|
||||||
okButtonText: 'Ok',
|
okButtonText: 'Ok',
|
||||||
|
|
Loading…
Reference in a new issue