diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js
index f4c714e1d..40139a084 100644
--- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js
+++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js
@@ -107,6 +107,7 @@ define([
if ( !this.leftMenu.panelHistory.isVisible() )
this.clickMenuFileItem(null, 'history');
}, this));
+ Common.NotificationCenter.on('file:print', _.bind(this.clickToolbarPrint, this));
},
onLaunch: function() {
@@ -534,6 +535,10 @@ define([
this.leftMenu.menuFile.hide();
},
+ clickToolbarPrint: function () {
+ this.leftMenu.showMenu('file:printpreview');
+ },
+
changeToolbarSaveState: function (state) {
var btnSave = this.leftMenu.menuFile.getButton('save');
btnSave && btnSave.setDisabled(state);
diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js
index 45cc3f9a7..8d80fb7d8 100644
--- a/apps/spreadsheeteditor/main/app/controller/Main.js
+++ b/apps/spreadsheeteditor/main/app/controller/Main.js
@@ -2522,7 +2522,8 @@ define([
this.getApplication().getController('RightMenu').updateMetricUnit();
this.getApplication().getController('Toolbar').getView('Toolbar').updateMetricUnit();
}
- this.getApplication().getController('Print').getView('MainSettingsPrint').updateMetricUnit();
+ //this.getApplication().getController('Print').getView('MainSettingsPrint').updateMetricUnit();
+ this.getApplication().getController('Print').getView('PrintWithPreview').updateMetricUnit();
},
_compareActionStrong: function(obj1, obj2){
@@ -2651,7 +2652,7 @@ define([
onPrint: function() {
if (!this.appOptions.canPrint || Common.Utils.ModalWindow.isVisible()) return;
- Common.NotificationCenter.trigger('print', this);
+ Common.NotificationCenter.trigger('file:print', this);
},
onPrintUrl: function(url) {
diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js
index 897c9f280..aac9e3507 100644
--- a/apps/spreadsheeteditor/main/app/controller/Print.js
+++ b/apps/spreadsheeteditor/main/app/controller/Print.js
@@ -39,12 +39,14 @@ define([
SSE.Controllers.Print = Backbone.Controller.extend(_.extend({
views: [
- 'MainSettingsPrint'
+ 'MainSettingsPrint',
+ 'PrintWithPreview'
],
initialize: function() {
var value = Common.localStorage.getItem("sse-print-settings-range");
value = (value!==null) ? parseInt(value) : Asc.c_oAscPrintType.ActiveSheets;
+ this._currentPrintType = value;
this.adjPrintParams = new Asc.asc_CAdjustPrint();
this.adjPrintParams.asc_setPrintType(value);
@@ -52,13 +54,25 @@ define([
this._changedProps = null;
this._originalPageSettings = null;
+ this._navigationPreview = {
+ pageCount: false,
+ currentPage: 0
+ };
+
+ this._isPreviewVisible = false;
+
this.addListeners({
- 'MainSettingsPrint': {
+ /*'MainSettingsPrint': {
'show': _.bind(this.onShowMainSettingsPrint, this),
'render:after': _.bind(this.onAfterRender, this)
+ },*/
+ 'PrintWithPreview': {
+ 'show': _.bind(this.onShowMainSettingsPrint, this),
+ 'render:after': _.bind(this.onAfterRender, this),
+ 'changerange': _.bind(this.onChangeRange, this, false)
},
'PrintSettings': {
- 'changerange': _.bind(this.onChangeRange,this)
+ 'changerange': _.bind(this.onChangeRange, this, true)
}
});
Common.NotificationCenter.on('print', _.bind(this.openPrintSettings, this, 'print'));
@@ -66,19 +80,42 @@ define([
},
onLaunch: function() {
- this.printSettings = this.createView('MainSettingsPrint');
+ //this.printSettings = this.createView('MainSettingsPrint');
+ this.printSettings = this.createView('PrintWithPreview');
},
onAfterRender: function(view) {
+ var me = this;
+ this.printSettings.menu.on('menu:hide', _.bind(this.onHidePrintMenu, this));
this.printSettings.cmbSheet.on('selected', _.bind(this.comboSheetsChange, this, this.printSettings));
- this.printSettings.btnOk.on('click', _.bind(this.querySavePrintSettings, this));
+ this.printSettings.btnsSave.forEach(function (btn) {
+ btn.on('click', _.bind(me.querySavePrintSettings, me, false));
+ });
+ this.printSettings.btnsPrint.forEach(function (btn) {
+ btn.on('click', _.bind(me.querySavePrintSettings, me, 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.printSettings.chIgnorePrintArea.on('change', _.bind(this.updatePreview, this));
+
this.fillComponents(this.printSettings);
this.registerControlEvents(this.printSettings);
+
+ Common.NotificationCenter.on('window:resize', _.bind(function () {
+ if (this._isPreviewVisible) {
+ this.api.asc_drawPrintPreview(this._navigationPreview.currentPage);
+ }
+ }, this));
},
setApi: function(o) {
this.api = o;
this.api.asc_registerCallback('asc_onSheetsChanged', _.bind(this.updateSheetsInfo, this));
+ this.api.asc_registerCallback('asc_onPrintPreviewSheetChanged', _.bind(this.onApiChangePreviewSheet, this));
},
updateSheetsInfo: function() {
@@ -187,22 +224,28 @@ define([
panel.btnPresetsLeft.menu.items[panel.btnPresetsLeft.menu.items[0].value == 'frozen' ? 0 : 1].setDisabled(!this.api.asc_getPrintTitlesRange(Asc.c_oAscPrintTitlesRangeType.frozen, true, sheet));
},
- fillPrintOptions: function(props) {
- this.printSettingsDlg.setRange(props.asc_getPrintType());
- this.printSettingsDlg.setIgnorePrintArea(!!props.asc_getIgnorePrintArea());
- this.onChangeRange();
+ fillPrintOptions: function(props, isDlg) {
+ var menu = isDlg ? this.printSettingsDlg : this.printSettings;
+ menu.setRange(props.asc_getPrintType());
+ menu.setIgnorePrintArea(!!props.asc_getIgnorePrintArea());
+ this.onChangeRange(isDlg);
},
- onChangeRange: function() {
- var printtype = this.printSettingsDlg.getRange(),
- store = this.printSettingsDlg.cmbSheet.store,
+ onChangeRange: function(isDlg) {
+ var menu = isDlg ? this.printSettingsDlg : this.printSettings;
+ var printtype = menu.getRange(),
+ store = menu.cmbSheet.store,
item = (printtype !== Asc.c_oAscPrintType.EntireWorkbook) ? store.findWhere({value: this.api.asc_getActiveWorksheetIndex()}) : store.at(0);
if (item) {
- this.printSettingsDlg.cmbSheet.setValue(item.get('value'));
- this.comboSheetsChange(this.printSettingsDlg, this.printSettingsDlg.cmbSheet, item.toJSON());
+ menu.cmbSheet.setValue(item.get('value'));
+ this.comboSheetsChange(menu, menu.cmbSheet, item.toJSON());
+ }
+ menu.cmbSheet.setDisabled(printtype !== Asc.c_oAscPrintType.EntireWorkbook);
+ menu.chIgnorePrintArea.setDisabled(printtype == Asc.c_oAscPrintType.Selection);
+
+ if (!isDlg) {
+ this.updatePreview();
}
- this.printSettingsDlg.cmbSheet.setDisabled(printtype !== Asc.c_oAscPrintType.EntireWorkbook);
- this.printSettingsDlg.chIgnorePrintArea.setDisabled(printtype == Asc.c_oAscPrintType.Selection);
},
getPageOptions: function(panel) {
@@ -264,11 +307,13 @@ define([
this.updateSettings(this.printSettings);
}
- var item = this.printSettings.cmbSheet.store.findWhere({value: this.api.asc_getActiveWorksheetIndex()});
- if (item) {
- this.printSettings.cmbSheet.setValue(item.get('value'));
- this.comboSheetsChange(this.printSettings, this.printSettings.cmbSheet, item.toJSON());
- }
+ this.fillPrintOptions(this.adjPrintParams, false);
+
+ this._navigationPreview.pageCount = this.api.asc_initPrintPreview('print-preview');
+ this.printSettings.updateCountOfPages(this._navigationPreview.pageCount);
+ this.printSettings.updateCurrentPage(0);
+
+ this._isPreviewVisible = true;
},
openPrintSettings: function(type, cmp, format, asUrl) {
@@ -289,7 +334,7 @@ define([
this.updateSettings(this.printSettingsDlg);
this.printSettingsDlg.cmbSheet.on('selected', _.bind(this.comboSheetsChange, this, this.printSettingsDlg));
this.fillComponents(this.printSettingsDlg, true);
- this.fillPrintOptions(this.adjPrintParams);
+ this.fillPrintOptions(this.adjPrintParams, true);
this.registerControlEvents(this.printSettingsDlg);
},this)
}));
@@ -330,10 +375,26 @@ define([
this.printSettingsDlg = null;
},
- querySavePrintSettings: function() {
+ querySavePrintSettings: function(print) {
if ( this.checkMargins(this.printSettings) ) {
this.savePageOptions(this.printSettings);
+ this._isPrint = print;
this.printSettings.applySettings();
+
+ if (print) {
+ var printType = this.printSettings.getRange();
+ this.adjPrintParams.asc_setPrintType(printType);
+ this.adjPrintParams.asc_setPageOptionsMap(this._changedProps);
+ this.adjPrintParams.asc_setIgnorePrintArea(this.printSettings.getIgnorePrintArea());
+ Common.localStorage.setItem("sse-print-settings-range", printType);
+
+ var opts = new Asc.asc_CDownloadOptions(null, Common.Utils.isChrome || Common.Utils.isSafari || Common.Utils.isOpera || Common.Utils.isGecko && Common.Utils.firefoxVersion>86);
+ opts.asc_setAdvancedOptions(this.adjPrintParams);
+ this.api.asc_Print(opts);
+ Common.NotificationCenter.trigger('edit:complete', view);
+
+ this._isPrint = false;
+ }
}
},
@@ -413,6 +474,7 @@ define([
me.setScaling(panel, me.fitWidth, me.fitHeight, me.fitScale);
if (me._changedProps) {
me._changedProps[panel.cmbSheet.getValue()] = me.getPageOptions(panel);
+ me.updatePreview();
}
}
} else {
@@ -430,6 +492,7 @@ define([
} else {
if (this._changedProps) {
this._changedProps[panel.cmbSheet.getValue()] = this.getPageOptions(panel);
+ this.updatePreview();
}
}
},
@@ -553,6 +616,97 @@ define([
}
},
+ onHidePrintMenu: function () {
+ if (this._isPreviewVisible) {
+ this.api.asc_closePrintPreview(this._isPrint);
+ this._isPreviewVisible = false;
+ }
+ },
+
+ 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.printSettings.$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.printSettings.$el.find('#print-number-page');
+ box.focus(); // for IE
+ this.api.asc_enableKeyEvents(true);
+ return false;
+ }
+ },
+
+ updatePreview: function () {
+ if (this._isPreviewVisible) {
+ var adjPrintParams = new Asc.asc_CAdjustPrint(),
+ printType = this.printSettings.getRange();
+ adjPrintParams.asc_setPrintType(printType);
+ adjPrintParams.asc_setPageOptionsMap(this._changedProps);
+ adjPrintParams.asc_setIgnorePrintArea(this.printSettings.getIgnorePrintArea());
+
+ var opts = new Asc.asc_CDownloadOptions(null, Common.Utils.isChrome || Common.Utils.isSafari || Common.Utils.isOpera || Common.Utils.isGecko && Common.Utils.firefoxVersion>86);
+ opts.asc_setAdvancedOptions(adjPrintParams);
+
+ var pageCount = this.api.asc_updatePrintPreview(opts);
+
+ var newPage;
+ if (this._currentPrintType !== printType) {
+ newPage = 0;
+ this._currentPrintType = printType;
+ } else if (this._navigationPreview.currentPage > pageCount - 1) {
+ newPage = pageCount - 1;
+ } else {
+ newPage = this._navigationPreview.currentPage;
+ }
+
+ this.api.asc_drawPrintPreview(newPage);
+
+ this._navigationPreview.currentPage = newPage;
+ this.printSettings.updateCurrentPage(newPage);
+ this._navigationPreview.pageCount = pageCount;
+ this.printSettings.updateCountOfPages(pageCount);
+ }
+ },
+
+ onApiChangePreviewSheet: function (index) {
+ var item = this.printSettings.cmbSheet.store.findWhere({value: index});
+ if (item) {
+ this.printSettings.cmbSheet.setValue(item.get('value'));
+ this.comboSheetsChange(this.printSettings, this.printSettings.cmbSheet, item.toJSON());
+ var sheetName = this.api.asc_getWorksheetName(index);
+ this.printSettings.updateActiveSheet(sheetName);
+ }
+ },
+
warnCheckMargings: 'Margins are incorrect',
strAllSheets: 'All Sheets',
textWarning: 'Warning',
diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js
index ac03e5f7f..5d238ee34 100644
--- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js
+++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js
@@ -396,6 +396,8 @@ define([
button.on('click', _.bind(me.onEditHeaderClick, me));
});
toolbar.btnPrintTitles.on('click', _.bind(this.onPrintTitlesClick, this));
+ toolbar.chPrintGridlines.on('change', _.bind(this.onPrintGridlinesChange, this));
+ toolbar.chPrintHeadings.on('change', _.bind(this.onPrintHeadingsChange, this));
if (toolbar.btnCondFormat.rendered) {
toolbar.btnCondFormat.menu.on('show:before', _.bind(this.onShowBeforeCondFormat, this, this.toolbar, 'toolbar'));
}
@@ -2246,6 +2248,8 @@ define([
this.onApiPageSize(opt.asc_getWidth(), opt.asc_getHeight());
this.onApiPageMargins(props.asc_getPageMargins());
this.onChangeScaleSettings(opt.asc_getFitToWidth(),opt.asc_getFitToHeight(),opt.asc_getScale());
+ this.onApiGridLines(props.asc_getGridLines());
+ this.onApiHeadings(props.asc_getHeadings());
this.api.asc_isLayoutLocked(currentSheet) ? this.onApiLockDocumentProps(currentSheet) : this.onApiUnLockDocumentProps(currentSheet);
this.toolbar.lockToolbar(SSE.enumLock.printAreaLock, this.api.asc_isPrintAreaLocked(currentSheet), {array: [this.toolbar.btnPrintArea]});
@@ -2256,6 +2260,14 @@ define([
this.onApiSheetChanged();
},
+ onApiGridLines: function (checked) {
+ this.toolbar.chPrintGridlines.setValue(checked, true);
+ },
+
+ onApiHeadings: function (checked) {
+ this.toolbar.chPrintHeadings.setValue(checked, true);
+ },
+
onApiPageSize: function(w, h) {
if (this._state.pgorient===undefined) return;
@@ -4068,6 +4080,16 @@ define([
}
},
+ onPrintGridlinesChange: function (field, value) {
+ this.api.asc_SetPrintGridlines(value === 'checked');
+ Common.NotificationCenter.trigger('edit:complete', this.toolbar);
+ },
+
+ onPrintHeadingsChange: function (field, value) {
+ this.api.asc_SetPrintHeadings(value === 'checked');
+ Common.NotificationCenter.trigger('edit:complete', this.toolbar);
+ },
+
textEmptyImgUrl : 'You need to specify image URL.',
warnMergeLostData : 'Operation can destroy data in the selected cells.
Continue?',
textWarning : 'Warning',
diff --git a/apps/spreadsheeteditor/main/app/template/FileMenu.template b/apps/spreadsheeteditor/main/app/template/FileMenu.template
index 3ad620221..8071eaded 100644
--- a/apps/spreadsheeteditor/main/app/template/FileMenu.template
+++ b/apps/spreadsheeteditor/main/app/template/FileMenu.template
@@ -7,7 +7,7 @@
-
+
@@ -34,4 +34,5 @@
+
\ No newline at end of file
diff --git a/apps/spreadsheeteditor/main/app/template/Toolbar.template b/apps/spreadsheeteditor/main/app/template/Toolbar.template
index 25f747f47..5602630d1 100644
--- a/apps/spreadsheeteditor/main/app/template/Toolbar.template
+++ b/apps/spreadsheeteditor/main/app/template/Toolbar.template
@@ -162,6 +162,15 @@
+
+
diff --git a/apps/spreadsheeteditor/main/app/view/FileMenu.js b/apps/spreadsheeteditor/main/app/view/FileMenu.js
index 0a7848e7f..b955aded7 100644
--- a/apps/spreadsheeteditor/main/app/view/FileMenu.js
+++ b/apps/spreadsheeteditor/main/app/view/FileMenu.js
@@ -140,9 +140,9 @@ define([
dataHintOffset: [2, 14]
});
- this.miPrint = new Common.UI.MenuItem({
- el : $markup.elementById('#fm-btn-print'),
- action : 'print',
+ this.miPrintWithPreview = new Common.UI.MenuItem({
+ el : $markup.elementById('#fm-btn-print-with-preview'),
+ action : 'printpreview',
caption : this.btnPrintCaption,
canFocused: false,
dataHint: 1,
@@ -267,7 +267,7 @@ define([
this.miDownload,
this.miSaveCopyAs,
this.miSaveAs,
- this.miPrint,
+ this.miPrintWithPreview,
this.miRename,
this.miProtect,
this.miRecent,
@@ -358,7 +358,7 @@ define([
this.miSaveAs[(this.mode.canDownload && this.mode.isDesktopApp && this.mode.isOffline)?'show':'hide']();
this.miSave[this.mode.isEdit && Common.UI.LayoutManager.isElementVisible('toolbar-file-save') ?'show':'hide']();
this.miEdit[!this.mode.isEdit && this.mode.canEdit && this.mode.canRequestEditRights ?'show':'hide']();
- this.miPrint[this.mode.canPrint?'show':'hide']();
+ this.miPrintWithPreview[this.mode.canPrint?'show':'hide']();
this.miRename[(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide']();
this.miProtect[this.mode.canProtect ?'show':'hide']();
separatorVisible = (this.mode.canDownload || this.mode.isEdit && Common.UI.LayoutManager.isElementVisible('toolbar-file-save') || this.mode.canPrint || this.mode.canProtect ||
@@ -444,6 +444,12 @@ define([
this.panels['opts'].SetDisabled(this.mode.disableEditing);
delete this.mode.disableEditing;
}
+
+ if (this.mode.canPrint) {
+ var printPanel = SSE.getController('Print').getView('PrintWithPreview');
+ printPanel.menu = this;
+ this.panels['printpreview'] = printPanel.render(this.$el.find('#panel-print'));
+ }
},
setMode: function(mode, delay) {
diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js
index 8d15242fe..ed20a0112 100644
--- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js
+++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js
@@ -210,9 +210,9 @@ define([
this.generalSettings.options = {alias:'MainSettingsGeneral'};
this.generalSettings.render($markup.findById('#panel-settings-general'));
- this.printSettings = SSE.getController('Print').getView('MainSettingsPrint');
- this.printSettings.menu = this.menu;
- this.printSettings.render($markup.findById('#panel-settings-print'));
+ //this.printSettings = SSE.getController('Print').getView('MainSettingsPrint');
+ //this.printSettings.menu = this.menu;
+ //this.printSettings.render($markup.findById('#panel-settings-print'));
this.spellcheckSettings = new SSE.Views.FileMenuPanels.MainSpellCheckSettings({menu: this.menu});
this.spellcheckSettings.render($markup.findById('#panel-settings-spellcheck'));
@@ -221,7 +221,7 @@ define([
el: $markup.findById('#id-settings-menu'),
store: new Common.UI.DataViewStore([
{name: this.txtGeneral, panel: this.generalSettings, iconCls:'toolbar__icon btn-settings', contentTarget: 'panel-settings-general', selected: true},
- {name: this.txtPageSettings, panel: this.printSettings, iconCls:'toolbar__icon btn-print', contentTarget: 'panel-settings-print'},
+ //{name: this.txtPageSettings, panel: this.printSettings, iconCls:'toolbar__icon btn-print', contentTarget: 'panel-settings-print'},
{name: this.txtSpellChecking, panel: this.spellcheckSettings, iconCls:'toolbar__icon btn-ic-docspell', contentTarget: 'panel-settings-spellcheck'}
]),
itemTemplate: _.template([
@@ -2683,4 +2683,581 @@ define([
}, SSE.Views.FileMenuPanels.ProtectDoc || {}));
+ SSE.Views.PrintWithPreview = Common.UI.BaseView.extend(_.extend({
+ el: '#panel-print',
+ menu: undefined,
+
+ template: _.template([
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '',
+ ' |
',
+ ' |
',
+ ' |
',
+ ' |
',
+ ' |
',
+ ' |
',
+ ' |
',
+ ' |
',
+ ' |
',
+ ' |
',
+ ' |
',
+ ' |
',
+ ' |
',
+ '',
+ '',
+ ' |
',
+ ' |
',
+ '',
+ '',
+ ' |
',
+ ' |
',
+ '',
+ '',
+ '',
+ '',
+ ' | ',
+ ' | ',
+ ' ',
+ '',
+ ' | ',
+ ' | ',
+ ' ',
+ '',
+ ' | ',
+ ' | ',
+ ' ',
+ '',
+ ' | ',
+ ' | ',
+ ' ',
+ '',
+ ' ',
+ ' |
',
+ ' |
',
+ ' |
',
+ ' |
',
+ ' |
',
+ //' |
',
+ '',
+ '',
+ ' |
',
+ '',
+ '
',
+ '
',
+ '
',
+ '',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
'
+ ].join('')),
+
+ initialize: function(options) {
+ Common.UI.BaseView.prototype.initialize.call(this,arguments);
+
+ this.menu = options.menu;
+
+ this.spinners = [];
+ this._initSettings = true;
+ },
+
+ render: function(node) {
+ var me = this;
+
+ var $markup = $(this.template({scope: this}));
+
+ this.cmbRange = new Common.UI.ComboBox({
+ el: $markup.findById('#print-combo-range'),
+ menuStyle: 'min-width: 248px;max-height: 280px;',
+ editable: false,
+ takeFocusOnClose: true,
+ cls: 'input-group-nr',
+ data: [
+ { value: Asc.c_oAscPrintType.ActiveSheets, displayValue: this.txtCurrentSheet },
+ { value: Asc.c_oAscPrintType.EntireWorkbook, displayValue: this.txtAllSheets },
+ { value: Asc.c_oAscPrintType.Selection, displayValue: this.txtSelection }
+ ],
+ dataHint: '2',
+ dataHintDirection: 'bottom',
+ dataHintOffset: 'big'
+ });
+ this.cmbRange.on('selected', _.bind(this.comboRangeChange, this));
+
+ this.chIgnorePrintArea = new Common.UI.CheckBox({
+ el: $markup.findById('#print-chb-ignore'),
+ labelText: this.txtIgnore,
+ dataHint: '2',
+ dataHintDirection: 'left',
+ dataHintOffset: 'small'
+ });
+
+ this.cmbSheet = new Common.UI.ComboBox({
+ el: $markup.findById('#print-combo-sheets'),
+ menuStyle: 'min-width: 248px;max-height: 280px;',
+ editable: false,
+ cls: 'input-group-nr',
+ data: [],
+ takeFocusOnClose: true,
+ dataHint: '2',
+ dataHintDirection: 'bottom',
+ dataHintOffset: 'big'
+ });
+
+ this.cmbPaperSize = new Common.UI.ComboBox({
+ el: $markup.findById('#print-combo-pages'),
+ menuStyle: 'max-height: 280px; min-width: 248px;',
+ editable: false,
+ takeFocusOnClose: true,
+ cls: 'input-group-nr',
+ data: [
+ {value:'215.9|279.4', displayValue:'US Letter (21,59cm x 27,94cm)', caption: 'US Letter'},
+ {value:'215.9|355.6', displayValue:'US Legal (21,59cm x 35,56cm)', caption: 'US Legal'},
+ {value:'210|297', displayValue:'A4 (21cm x 29,7cm)', caption: 'A4'},
+ {value:'148|210', displayValue:'A5 (14,8cm x 21cm)', caption: 'A5'},
+ {value:'176|250', displayValue:'B5 (17,6cm x 25cm)', caption: 'B5'},
+ {value:'104.8|241.3', displayValue:'Envelope #10 (10,48cm x 24,13cm)', caption: 'Envelope #10'},
+ {value:'110|220', displayValue:'Envelope DL (11cm x 22cm)', caption: 'Envelope DL'},
+ {value:'279.4|431.8', displayValue:'Tabloid (27,94cm x 43,18cm)', caption: 'Tabloid'},
+ {value:'297|420', displayValue:'A3 (29,7cm x 42cm)', caption: 'A3'},
+ {value:'304.8|457.1', displayValue:'Tabloid Oversize (30,48cm x 45,71cm)', caption: 'Tabloid Oversize'},
+ {value:'196.8|273', displayValue:'ROC 16K (19,68cm x 27,3cm)', caption: 'ROC 16K'},
+ {value:'119.9|234.9', displayValue:'Envelope Choukei 3 (11,99cm x 23,49cm)', caption: 'Envelope Choukei 3'},
+ {value:'330.2|482.5', displayValue:'Super B/A3 (33,02cm x 48,25cm)', caption: 'Super B/A3'}
+ ],
+ dataHint: '2',
+ dataHintDirection: 'bottom',
+ dataHintOffset: 'big'
+ });
+
+ this.cmbPaperOrientation = new Common.UI.ComboBox({
+ el : $markup.findById('#print-combo-orient'),
+ menuStyle : 'min-width: 134px;',
+ editable : false,
+ takeFocusOnClose: true,
+ cls : 'input-group-nr',
+ data : [
+ { value: Asc.c_oAscPageOrientation.PagePortrait, displayValue: this.txtPortrait },
+ { value: Asc.c_oAscPageOrientation.PageLandscape, displayValue: this.txtLandscape }
+ ],
+ dataHint: '2',
+ dataHintDirection: 'bottom',
+ dataHintOffset: 'big'
+ });
+
+ var itemsTemplate =
+ _.template([
+ '<% _.each(items, function(item) { %>',
+ '
class="border-top" style="margin-top: 5px;" <% } %> >',
+ '<%= scope.getDisplayValue(item) %>',
+ '',
+ '<% }); %>'
+ ].join(''));
+ this.cmbLayout = new Common.UI.ComboBox({
+ el : $markup.findById('#print-combo-layout'),
+ menuStyle : 'min-width: 248px;',
+ editable : false,
+ takeFocusOnClose: true,
+ cls : 'input-group-nr',
+ data : [
+ { value: 0, displayValue: this.txtActualSize },
+ { value: 1, displayValue: this.txtFitPage },
+ { value: 2, displayValue: this.txtFitCols },
+ { value: 3, displayValue: this.txtFitRows },
+ { value: 'customoptions', displayValue: this.txtCustomOptions }
+ ],
+ itemsTemplate: itemsTemplate,
+ dataHint: '2',
+ dataHintDirection: 'bottom',
+ dataHintOffset: 'big'
+ });
+
+ this.txtRangeTop = new Common.UI.InputField({
+ el: $markup.findById('#print-txt-top'),
+ allowBlank: true,
+ validateOnChange: true,
+ dataHint: '2',
+ dataHintDirection: 'left',
+ dataHintOffset: 'small'
+ });
+
+ this.btnPresetsTop = new Common.UI.Button({
+ parentEl: $markup.findById('#print-presets-top'),
+ cls: 'btn-text-menu-default',
+ caption: this.txtRepeat,
+ style: 'width: 77px;',
+ menu: true,
+ dataHint: '2',
+ dataHintDirection: 'bottom',
+ dataHintOffset: 'big'
+ });
+
+ this.txtRangeLeft = new Common.UI.InputField({
+ el: $markup.findById('#print-txt-left'),
+ allowBlank: true,
+ validateOnChange: true,
+ dataHint: '2',
+ dataHintDirection: 'left',
+ dataHintOffset: 'small'
+ });
+
+ this.btnPresetsLeft = new Common.UI.Button({
+ parentEl: $markup.findById('#print-presets-left'),
+ cls: 'btn-text-menu-default',
+ caption: this.txtRepeat,
+ style: 'width: 77px;',
+ menu: true,
+ dataHint: '2',
+ dataHintDirection: 'bottom',
+ dataHintOffset: 'big'
+ });
+
+ this.spnMarginTop = new Common.UI.MetricSpinner({
+ el: $markup.findById('#print-spin-margin-top'),
+ step: .1,
+ width: 120,
+ defaultUnit : "cm",
+ value: '0 cm',
+ maxValue: 48.25,
+ minValue: 0,
+ dataHint: '2',
+ dataHintDirection: 'bottom',
+ dataHintOffset: 'big'
+ });
+ this.spinners.push(this.spnMarginTop);
+
+ this.spnMarginBottom = new Common.UI.MetricSpinner({
+ el: $markup.findById('#print-spin-margin-bottom'),
+ step: .1,
+ width: 120,
+ defaultUnit : "cm",
+ value: '0 cm',
+ maxValue: 48.25,
+ minValue: 0,
+ dataHint: '2',
+ dataHintDirection: 'bottom',
+ dataHintOffset: 'big'
+ });
+ this.spinners.push(this.spnMarginBottom);
+
+ this.spnMarginLeft = new Common.UI.MetricSpinner({
+ el: $markup.findById('#print-spin-margin-left'),
+ step: .1,
+ width: 120,
+ defaultUnit : "cm",
+ value: '0.19 cm',
+ maxValue: 48.25,
+ minValue: 0,
+ dataHint: '2',
+ dataHintDirection: 'bottom',
+ dataHintOffset: 'big'
+ });
+ this.spinners.push(this.spnMarginLeft);
+
+ this.spnMarginRight = new Common.UI.MetricSpinner({
+ el: $markup.findById('#print-spin-margin-right'),
+ step: .1,
+ width: 120,
+ defaultUnit : "cm",
+ value: '0.19 cm',
+ maxValue: 48.25,
+ minValue: 0,
+ dataHint: '2',
+ dataHintDirection: 'bottom',
+ dataHintOffset: 'big'
+ });
+ this.spinners.push(this.spnMarginRight);
+
+ this.chPrintGrid = new Common.UI.CheckBox({
+ el: $markup.findById('#print-chb-grid'),
+ labelText: this.txtPrintGrid,
+ dataHint: '2',
+ dataHintDirection: 'left',
+ dataHintOffset: 'small'
+ });
+
+ this.chPrintRows = new Common.UI.CheckBox({
+ el: $markup.findById('#print-chb-rows'),
+ labelText: this.txtPrintHeadings,
+ dataHint: '2',
+ dataHintDirection: 'left',
+ dataHintOffset: 'small'
+ });
+
+ /*this.btnApplyAll = new Common.UI.Button({
+ el: $markup.findById('#print-apply-all')
+ });*/
+
+ this.pnlSettings = $markup.find('.flex-settings').addBack().filter('.flex-settings');
+ this.pnlApply = $markup.find('.fms-flex-apply').addBack().filter('.fms-flex-apply');
+ this.pnlTable = $(this.pnlSettings.find('table')[0]);
+ this.trApply = $markup.find('.fms-btn-apply');
+
+ this.btnsSave = [];
+ this.btnsPrint = [];
+ for (var i=0; i<2; i++) {
+ this.btnsSave.push(new Common.UI.Button({
+ el: $markup.findById('#print-btn-save-'+i)
+ }));
+ this.btnsPrint.push(new Common.UI.Button({
+ el: $markup.findById('#print-btn-print-'+i)
+ }));
+ }
+
+ this.btnPrevPage = new Common.UI.Button({
+ parentEl: $markup.findById('#print-prev-page'),
+ cls: 'btn-prev-page',
+ iconCls: 'arrow',
+ dataHint: '2',
+ dataHintDirection: 'top'
+ });
+
+ this.btnNextPage = new Common.UI.Button({
+ parentEl: $markup.findById('#print-next-page'),
+ cls: 'btn-next-page',
+ iconCls: 'arrow',
+ dataHint: '2',
+ dataHintDirection: 'top'
+ });
+
+ this.countOfPages = $markup.findById('#print-count-page');
+
+ this.txtNumberPage = new Common.UI.InputField({
+ el: $markup.findById('#print-number-page'),
+ allowBlank: true,
+ validateOnChange: true,
+ 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'
+ });
+
+ this.txtActiveSheet = $markup.findById('#print-active-sheet');
+
+ this.$el = $(node).html($markup);
+
+ this.$el.on('click', '#print-header-footer-settings', _.bind(this.openHeaderSettings, this));
+ this.$headerSettings = $('#print-header-footer-settings');
+
+ if (_.isUndefined(this.scroller)) {
+ this.scroller = new Common.UI.Scroller({
+ el: this.pnlSettings,
+ suppressScrollX: true,
+ alwaysVisibleY: true
+ });
+ }
+
+ Common.NotificationCenter.on({
+ 'window:resize': function() {
+ me.isVisible() && me.updateScroller();
+ }
+ });
+
+ this.updateMetricUnit();
+
+ this.fireEvent('render:after', this);
+
+ return this;
+ },
+
+ show: function() {
+ Common.UI.BaseView.prototype.show.call(this,arguments);
+ if (this._initSettings) {
+ this.updateMetricUnit();
+ this._initSettings = false;
+ }
+ this.updateScroller();
+ this.fireEvent('show', this);
+ },
+
+ updateScroller: function() {
+ if (this.scroller) {
+ Common.UI.Menu.Manager.hideAll();
+ var scrolled = this.$el.height()< this.pnlTable.height() + 25 + this.pnlApply.height();
+ this.pnlApply.toggleClass('hidden', !scrolled);
+ this.trApply.toggleClass('hidden', scrolled);
+ this.pnlSettings.css('overflow', scrolled ? 'hidden' : 'visible');
+ this.scroller.update();
+ this.pnlSettings.toggleClass('bordered', this.scroller.isVisible());
+ }
+ },
+
+ setMode: function(mode) {
+ this.mode = mode;
+ },
+
+ setApi: function(api) {
+
+ },
+
+ updateMetricUnit: function() {
+ if (this.spinners) {
+ for (var i=0; i