[SSE] Add methods for navigation in print preview
This commit is contained in:
parent
ac93b3b4f2
commit
eb08feee37
|
@ -53,6 +53,11 @@ define([
|
|||
this._changedProps = null;
|
||||
this._originalPageSettings = null;
|
||||
|
||||
this._navigationPreview = {
|
||||
pageCount: false,
|
||||
currentPage: 0
|
||||
};
|
||||
|
||||
this.addListeners({
|
||||
/*'MainSettingsPrint': {
|
||||
'show': _.bind(this.onShowMainSettingsPrint, this),
|
||||
|
@ -81,6 +86,12 @@ define([
|
|||
this.printSettings.cmbSheet.on('selected', _.bind(this.comboSheetsChange, this, this.printSettings));
|
||||
this.printSettings.btnSave.on('click', _.bind(this.querySavePrintSettings, this, false));
|
||||
this.printSettings.btnPrint.on('click', _.bind(this.querySavePrintSettings, this, true));
|
||||
this.printSettings.btnPrevPage.on('click', _.bind(this.onChangePreviewPage, this, false));
|
||||
this.printSettings.btnNextPage.on('click', _.bind(this.onChangePreviewPage, this, true));
|
||||
this.printSettings.txtNumberPage.on({
|
||||
'keypress:after': _.bind(this.onKeypressPageNumber, this),
|
||||
'keyup:after': _.bind(this.onKeyupPageNumber, this)
|
||||
});
|
||||
|
||||
this.fillComponents(this.printSettings);
|
||||
this.registerControlEvents(this.printSettings);
|
||||
|
@ -278,7 +289,9 @@ define([
|
|||
|
||||
this.fillPrintOptions(this.adjPrintParams, false);
|
||||
|
||||
this._pagePreviewCount = this.api.asc_initPrintPreview('print-preview');
|
||||
this._navigationPreview.pageCount = this.api.asc_initPrintPreview('print-preview');
|
||||
this.printSettings.updateCountOfPages(this._navigationPreview.pageCount);
|
||||
this.printSettings.updateCurrentPage(0);
|
||||
},
|
||||
|
||||
openPrintSettings: function(type, cmp, format, asUrl) {
|
||||
|
@ -583,6 +596,48 @@ define([
|
|||
this.api.asc_closePrintPreview(this._isPrint);
|
||||
},
|
||||
|
||||
onChangePreviewPage: function (next) {
|
||||
var index = this._navigationPreview.currentPage;
|
||||
if (next) {
|
||||
index++;
|
||||
index = Math.min(index, this._navigationPreview.pageCount - 1);
|
||||
} else {
|
||||
index--;
|
||||
index = Math.max(index, 0);
|
||||
}
|
||||
this.api.asc_drawPrintPreview(index);
|
||||
|
||||
this.printSettings.updateCurrentPage(index);
|
||||
this._navigationPreview.currentPage = index;
|
||||
},
|
||||
|
||||
onKeypressPageNumber: function (input, e) {
|
||||
if (e.keyCode === Common.UI.Keys.RETURN) {
|
||||
var box = this.$el.find('#print-number-page'),
|
||||
edit = box.find('input[type=text]'), page = parseInt(edit.val());
|
||||
if (!page || page-- > this._navigationPreview.pageCount || page < 0) {
|
||||
edit.select();
|
||||
return false;
|
||||
}
|
||||
|
||||
box.focus(); // for IE
|
||||
|
||||
this.api.asc_drawPrintPreview(page-1);
|
||||
this.api.asc_enableKeyEvents(true);
|
||||
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
onKeyupPageNumber: function (input, e) {
|
||||
if (e.keyCode === Common.UI.Keys.ESC) {
|
||||
var box = this.$el.find('#print-number-page');
|
||||
box.focus(); // for IE
|
||||
this.api.asc_enableKeyEvents(true);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
warnCheckMargings: 'Margins are incorrect',
|
||||
strAllSheets: 'All Sheets',
|
||||
textWarning: 'Warning',
|
||||
|
|
|
@ -3046,7 +3046,17 @@ define([
|
|||
el: $markup.findById('#print-number-page'),
|
||||
allowBlank: true,
|
||||
validateOnChange: true,
|
||||
style: 'width: 32px;',
|
||||
style: 'width: 50px;',
|
||||
maskExp: /[0-9]/,
|
||||
validation: function(value) {
|
||||
if (/(^[0-9]+$)/.test(value)) {
|
||||
value = parseInt(value);
|
||||
if (undefined !== value && value > 0 && value <= me.pageCount)
|
||||
return true;
|
||||
}
|
||||
|
||||
return me.txtPageNumInvalid;
|
||||
},
|
||||
dataHint: '2',
|
||||
dataHintDirection: 'left',
|
||||
dataHintOffset: 'small'
|
||||
|
@ -3190,6 +3200,7 @@ define([
|
|||
this.countOfPages.text(
|
||||
Common.Utils.String.format(this.txtOf, count)
|
||||
);
|
||||
this.pageCount = count;
|
||||
},
|
||||
|
||||
updateActiveSheet: function (name) {
|
||||
|
@ -3198,6 +3209,10 @@ define([
|
|||
);
|
||||
},
|
||||
|
||||
updateCurrentPage: function (index) {
|
||||
this.txtNumberPage.setValue(index + 1);
|
||||
},
|
||||
|
||||
txtPrint: 'Print',
|
||||
txtSave: 'Save',
|
||||
txtPrintRange: 'Print range',
|
||||
|
@ -3233,7 +3248,8 @@ define([
|
|||
txtIgnore: 'Ignore print area',
|
||||
txtPage: 'Page',
|
||||
txtOf: 'of {0}',
|
||||
txtSheet: 'Sheet: {0}'
|
||||
txtSheet: 'Sheet: {0}',
|
||||
txtPageNumInvalid: 'Page number invalid'
|
||||
}, SSE.Views.FileMenuPanels.PrintWithPreview || {}));
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue