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 20 A - 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
/ * *
* PrintSettings . js
*
* Created by Julia Radzhabova on 4 / 03 / 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/PrintSettings.template' ,
'common/main/lib/view/AdvancedSettingsWindow' ,
'common/main/lib/component/MetricSpinner' ,
'common/main/lib/component/CheckBox' ,
'common/main/lib/component/RadioBox' ,
'common/main/lib/component/ListView'
] , function ( contentTemplate ) {
'use strict' ;
SSE . Views . PrintSettings = Common . Views . AdvancedSettingsWindow . extend ( _ . extend ( {
options : {
alias : 'PrintSettings' ,
contentWidth : 280 ,
2020-03-17 14:55:37 +00:00
height : 575 ,
2020-10-13 11:30:52 +00:00
buttons : null
2016-03-11 00:48:53 +00:00
} ,
initialize : function ( options ) {
2018-04-05 11:29:37 +00:00
this . type = options . type || 'print' ;
2016-03-11 00:48:53 +00:00
_ . extend ( this . options , {
2018-04-05 11:29:37 +00:00
title : ( this . type == 'print' ) ? this . textTitle : this . textTitlePDF ,
2016-03-11 00:48:53 +00:00
template : [
'<div class="box" style="height:' + ( this . options . height - 85 ) + 'px;">' ,
'<div class="menu-panel" style="overflow: hidden;">' ,
2019-03-19 14:33:09 +00:00
'<div style="height: 54px; line-height: 42px;" class="div-category">' + ( ( this . type == 'print' ) ? this . textPrintRange : this . textRange ) + '</div>' ,
2016-04-01 13:01:12 +00:00
'<div style="height: 52px; line-height: 66px;" class="div-category">' + this . textSettings + '</div>' ,
'<div style="height: 38px; line-height: 38px;" class="div-category">' + this . textPageSize + '</div>' ,
'<div style="height: 38px; line-height: 38px;" class="div-category">' + this . textPageOrientation + '</div>' ,
2016-06-16 12:51:51 +00:00
'<div style="height: 38px; line-height: 38px;" class="div-category">' + this . textPageScaling + '</div>' ,
2020-03-17 14:55:37 +00:00
'<div style="height: 98px; line-height: 33px;" class="div-category">' + this . strPrintTitles + '</div>' ,
2016-04-01 13:01:12 +00:00
'<div style="height: 108px; line-height: 33px;" class="div-category">' + this . strMargins + '</div>' ,
2018-04-05 11:29:37 +00:00
'<div style="height: 58px; line-height: 40px;" class="div-category">' + ( ( this . type == 'print' ) ? this . strPrint : this . strShow ) + '</div>' ,
2016-03-11 00:48:53 +00:00
'</div>' ,
'<div class="content-panel">' + _ . template ( contentTemplate ) ( { scope : this } ) + '</div>' ,
'</div>' ,
2020-06-05 13:10:48 +00:00
'<div class="separator horizontal"></div>' ,
2016-03-11 00:48:53 +00:00
'<div class="footer justify">' ,
2021-11-24 18:29:08 +00:00
'<button id="printadv-dlg-btn-hide" class="btn btn-text-default" style="min-width: 100px;width: auto;">' + this . textHideDetails + '</button>' ,
'<button class="btn normal dlg-btn" result="cancel" style="width: 86px;float: right;">' + this . cancelButtonText + '</button>' ,
'<button class="btn normal dlg-btn primary" result="ok" style="margin-left: 10px; width: 150px;float: right;">' + ( ( this . type == 'print' ) ? this . btnPrint : this . btnDownload ) + '</button>' ,
2016-03-11 00:48:53 +00:00
'</div>'
] . join ( '' )
} , options ) ;
Common . Views . AdvancedSettingsWindow . prototype . initialize . call ( this , this . options ) ;
this . spinners = [ ] ;
} ,
render : function ( ) {
Common . Views . AdvancedSettingsWindow . prototype . render . call ( this ) ;
2016-04-01 13:01:12 +00:00
this . cmbRange = new Common . UI . ComboBox ( {
el : $ ( '#printadv-dlg-combo-range' ) ,
style : 'width: 132px;' ,
menuStyle : 'min-width: 132px;max-height: 280px;' ,
editable : false ,
2020-09-26 14:01:53 +00:00
takeFocusOnClose : true ,
2016-04-01 13:01:12 +00:00
cls : 'input-group-nr' ,
data : [
2016-04-05 11:52:34 +00:00
{ value : Asc . c _oAscPrintType . ActiveSheets , displayValue : this . textCurrentSheet } ,
{ value : Asc . c _oAscPrintType . EntireWorkbook , displayValue : this . textAllSheets } ,
{ value : Asc . c _oAscPrintType . Selection , displayValue : this . textSelection }
2016-04-01 13:01:12 +00:00
]
2016-03-11 00:48:53 +00:00
} ) ;
2016-04-01 13:01:12 +00:00
this . cmbRange . on ( 'selected' , _ . bind ( this . comboRangeChange , this ) ) ;
2016-03-11 00:48:53 +00:00
2019-03-19 14:33:09 +00:00
this . chIgnorePrintArea = new Common . UI . CheckBox ( {
el : $ ( '#printadv-dlg-chb-ignore' ) ,
labelText : this . textIgnore
} ) ;
2016-04-01 13:01:12 +00:00
this . cmbSheet = new Common . UI . ComboBox ( {
el : $ ( '#printadv-dlg-combo-sheets' ) ,
style : 'width: 242px;' ,
menuStyle : 'min-width: 242px;max-height: 280px;' ,
editable : false ,
cls : 'input-group-nr' ,
2020-09-26 14:01:53 +00:00
data : [ ] ,
takeFocusOnClose : true
2016-03-11 00:48:53 +00:00
} ) ;
this . cmbPaperSize = new Common . UI . ComboBox ( {
el : $ ( '#printadv-dlg-combo-pages' ) ,
2016-04-01 13:01:12 +00:00
style : 'width: 242px;' ,
menuStyle : 'max-height: 280px; min-width: 242px;' ,
2016-03-11 00:48:53 +00:00
editable : false ,
2020-09-26 14:01:53 +00:00
takeFocusOnClose : true ,
2016-03-11 00:48:53 +00:00
cls : 'input-group-nr' ,
data : [
2016-04-07 10:49:15 +00:00
{ 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' } ,
2018-06-28 09:27:11 +00:00
{ value : '148|210' , displayValue : 'A5 (14,8cm x 21cm)' , caption : 'A5' } ,
{ value : '176|250' , displayValue : 'B5 (17,6cm x 25cm)' , caption : 'B5' } ,
2016-04-07 10:49:15 +00:00
{ value : '104.8|241.3' , displayValue : 'Envelope #10 (10,48cm x 24,13cm)' , caption : 'Envelope #10' } ,
2018-06-28 09:27:11 +00:00
{ 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' } ,
2016-04-07 10:49:15 +00:00
{ 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' }
2016-03-11 00:48:53 +00:00
]
} ) ;
this . cmbPaperOrientation = new Common . UI . ComboBox ( {
el : $ ( '#printadv-dlg-combo-orient' ) ,
2016-04-01 13:01:12 +00:00
style : 'width: 132px;' ,
menuStyle : 'min-width: 132px;' ,
2016-03-11 00:48:53 +00:00
editable : false ,
2020-09-26 14:01:53 +00:00
takeFocusOnClose : true ,
2016-03-11 00:48:53 +00:00
cls : 'input-group-nr' ,
data : [
2016-04-05 11:52:34 +00:00
{ value : Asc . c _oAscPageOrientation . PagePortrait , displayValue : this . strPortrait } ,
{ value : Asc . c _oAscPageOrientation . PageLandscape , displayValue : this . strLandscape }
2016-03-11 00:48:53 +00:00
]
} ) ;
this . chPrintGrid = new Common . UI . CheckBox ( {
el : $ ( '#printadv-dlg-chb-grid' ) ,
2018-04-05 11:29:37 +00:00
labelText : ( this . type == 'print' ) ? this . textPrintGrid : this . textShowGrid
2016-03-11 00:48:53 +00:00
} ) ;
this . chPrintRows = new Common . UI . CheckBox ( {
el : $ ( '#printadv-dlg-chb-rows' ) ,
2018-04-05 11:29:37 +00:00
labelText : ( this . type == 'print' ) ? this . textPrintHeadings : this . textShowHeadings
2016-03-11 00:48:53 +00:00
} ) ;
this . spnMarginTop = new Common . UI . MetricSpinner ( {
el : $ ( '#printadv-dlg-spin-margin-top' ) ,
step : . 1 ,
2016-04-01 13:01:12 +00:00
width : 110 ,
2016-03-11 00:48:53 +00:00
defaultUnit : "cm" ,
value : '0 cm' ,
maxValue : 48.25 ,
minValue : 0
} ) ;
this . spinners . push ( this . spnMarginTop ) ;
this . spnMarginBottom = new Common . UI . MetricSpinner ( {
el : $ ( '#printadv-dlg-spin-margin-bottom' ) ,
step : . 1 ,
2016-04-01 13:01:12 +00:00
width : 110 ,
2016-03-11 00:48:53 +00:00
defaultUnit : "cm" ,
value : '0 cm' ,
maxValue : 48.25 ,
minValue : 0
} ) ;
this . spinners . push ( this . spnMarginBottom ) ;
this . spnMarginLeft = new Common . UI . MetricSpinner ( {
el : $ ( '#printadv-dlg-spin-margin-left' ) ,
step : . 1 ,
2016-04-01 13:01:12 +00:00
width : 110 ,
2016-03-11 00:48:53 +00:00
defaultUnit : "cm" ,
value : '0.19 cm' ,
maxValue : 48.25 ,
minValue : 0
} ) ;
this . spinners . push ( this . spnMarginLeft ) ;
this . spnMarginRight = new Common . UI . MetricSpinner ( {
el : $ ( '#printadv-dlg-spin-margin-right' ) ,
step : . 1 ,
2016-04-01 13:01:12 +00:00
width : 110 ,
2016-03-11 00:48:53 +00:00
defaultUnit : "cm" ,
value : '0.19 cm' ,
maxValue : 48.25 ,
minValue : 0
} ) ;
this . spinners . push ( this . spnMarginRight ) ;
2019-10-15 12:07:03 +00:00
var itemsTemplate =
_ . template ( [
'<% _.each(items, function(item) { %>' ,
2021-09-14 15:45:18 +00:00
'<li id="<%= item.id %>" data-value="<%= item.value %>" <% if (item.value === "customoptions") { %> class="border-top" style="margin-top: 5px;" <% } %> ><a tabindex="-1" type="menuitem">' ,
2019-10-15 12:07:03 +00:00
'<%= scope.getDisplayValue(item) %>' ,
'</a></li>' ,
'<% }); %>'
] . join ( '' ) ) ;
2016-04-01 13:01:12 +00:00
this . cmbLayout = new Common . UI . ComboBox ( {
el : $ ( '#printadv-dlg-combo-layout' ) ,
style : 'width: 242px;' ,
menuStyle : 'min-width: 242px;' ,
editable : false ,
2020-09-26 14:01:53 +00:00
takeFocusOnClose : true ,
2016-04-01 13:01:12 +00:00
cls : 'input-group-nr' ,
data : [
{ value : 0 , displayValue : this . textActualSize } ,
{ value : 1 , displayValue : this . textFitPage } ,
{ value : 2 , displayValue : this . textFitCols } ,
2019-09-04 12:09:04 +00:00
{ value : 3 , displayValue : this . textFitRows } ,
2019-10-15 12:07:03 +00:00
{ value : 'customoptions' , displayValue : this . textCustomOptions }
] ,
itemsTemplate : itemsTemplate
2016-04-01 13:01:12 +00:00
} ) ;
2016-03-11 00:48:53 +00:00
2020-04-06 14:46:22 +00:00
this . txtRangeTop = new Common . UI . InputFieldBtn ( {
2020-03-17 14:55:37 +00:00
el : $ ( '#printadv-dlg-txt-top' ) ,
2020-03-18 10:06:18 +00:00
style : 'width: 147px;' ,
2020-03-17 14:55:37 +00:00
allowBlank : true ,
validateOnChange : true
} ) ;
this . btnPresetsTop = new Common . UI . Button ( {
2020-04-29 07:36:53 +00:00
parentEl : $ ( '#printadv-dlg-presets-top' ) ,
2020-03-17 14:55:37 +00:00
cls : 'btn-text-menu-default' ,
caption : this . textRepeat ,
2020-03-18 10:06:18 +00:00
style : 'width: 85px;' ,
2020-03-17 14:55:37 +00:00
menu : true
} ) ;
2020-04-06 14:46:22 +00:00
this . txtRangeLeft = new Common . UI . InputFieldBtn ( {
2020-03-17 14:55:37 +00:00
el : $ ( '#printadv-dlg-txt-left' ) ,
2020-03-18 10:06:18 +00:00
style : 'width: 147px;' ,
2020-03-17 14:55:37 +00:00
allowBlank : true ,
validateOnChange : true
} ) ;
this . btnPresetsLeft = new Common . UI . Button ( {
2020-04-29 07:36:53 +00:00
parentEl : $ ( '#printadv-dlg-presets-left' ) ,
2020-03-17 14:55:37 +00:00
cls : 'btn-text-menu-default' ,
caption : this . textRepeat ,
2020-03-18 10:06:18 +00:00
style : 'width: 85px;' ,
2020-03-17 14:55:37 +00:00
menu : true
} ) ;
2016-03-11 00:48:53 +00:00
this . btnHide = new Common . UI . Button ( {
el : $ ( '#printadv-dlg-btn-hide' )
} ) ;
this . btnHide . on ( 'click' , _ . bind ( this . handlerShowDetails , this ) ) ;
this . panelDetails = $ ( '#printadv-dlg-content-to-hide' ) ;
this . updateMetricUnit ( ) ;
this . options . afterrender && this . options . afterrender . call ( this ) ;
2016-03-31 11:13:16 +00:00
var value = Common . localStorage . getItem ( "sse-hide-print-settings" ) ;
this . extended = ( value !== null && parseInt ( value ) == 0 ) ;
this . handlerShowDetails ( this . btnHide ) ;
2016-03-11 00:48:53 +00:00
} ,
2020-10-13 11:30:52 +00:00
getFocusedComponents : function ( ) {
2021-04-13 22:12:59 +00:00
return [ this . cmbRange , this . chIgnorePrintArea , this . cmbSheet , this . cmbPaperSize , this . cmbPaperOrientation , this . cmbLayout , this . txtRangeTop , this . txtRangeLeft ,
this . spnMarginTop , this . spnMarginBottom , this . spnMarginLeft , this . spnMarginRight , this . chPrintGrid , this . chPrintRows ] ;
2020-10-13 11:30:52 +00:00
} ,
2020-10-22 10:53:58 +00:00
getDefaultFocusableComponent : function ( ) {
if ( this . _alreadyRendered ) return ; // focus only at first show
this . _alreadyRendered = true ;
return this . cmbRange ;
} ,
2019-10-15 12:07:03 +00:00
addCustomScale : function ( add ) {
if ( add ) {
this . cmbLayout . setData ( [
{ value : 0 , displayValue : this . textActualSize } ,
{ value : 1 , displayValue : this . textFitPage } ,
{ value : 2 , displayValue : this . textFitCols } ,
{ value : 3 , displayValue : this . textFitRows } ,
{ value : 4 , displayValue : this . textCustom } ,
{ value : 'customoptions' , displayValue : this . textCustomOptions }
] ) ;
} else {
this . cmbLayout . setData ( [
{ value : 0 , displayValue : this . textActualSize } ,
{ value : 1 , displayValue : this . textFitPage } ,
{ value : 2 , displayValue : this . textFitCols } ,
{ value : 3 , displayValue : this . textFitRows } ,
{ value : 'customoptions' , displayValue : this . textCustomOptions }
] ) ;
}
} ,
2016-03-11 00:48:53 +00:00
setRange : function ( value ) {
2016-04-01 13:01:12 +00:00
this . cmbRange . setValue ( value ) ;
2016-03-11 00:48:53 +00:00
} ,
getRange : function ( ) {
2016-04-01 13:01:12 +00:00
return this . cmbRange . getValue ( ) ;
2016-03-11 00:48:53 +00:00
} ,
2019-03-19 14:33:09 +00:00
setIgnorePrintArea : function ( value ) {
this . chIgnorePrintArea . setValue ( value ) ;
} ,
getIgnorePrintArea : function ( ) {
return ( this . chIgnorePrintArea . getValue ( ) == 'checked' ) ;
} ,
2016-04-01 13:01:12 +00:00
comboRangeChange : function ( combo , record ) {
this . fireEvent ( 'changerange' , this ) ;
2016-03-11 00:48:53 +00:00
} ,
updateMetricUnit : function ( ) {
if ( this . spinners ) {
for ( var i = 0 ; i < this . spinners . length ; i ++ ) {
var spinner = this . spinners [ i ] ;
2016-04-06 13:38:54 +00:00
spinner . setDefaultUnit ( Common . Utils . Metric . getCurrentMetricName ( ) ) ;
2016-04-06 15:17:40 +00:00
spinner . setStep ( Common . Utils . Metric . getCurrentMetric ( ) == Common . Utils . Metric . c _MetricUnits . pt ? 1 : 0.1 ) ;
2016-03-11 00:48:53 +00:00
}
}
2016-04-07 10:49:15 +00:00
var store = this . cmbPaperSize . store ;
for ( var i = 0 ; i < store . length ; i ++ ) {
var item = store . at ( i ) ,
value = item . get ( 'value' ) ,
pagewidth = /^\d{3}\.?\d*/ . exec ( value ) ,
pageheight = /\d{3}\.?\d*$/ . exec ( value ) ;
2016-04-07 12:13:16 +00:00
item . set ( 'displayValue' , item . get ( 'caption' ) + ' (' + parseFloat ( Common . Utils . Metric . fnRecalcFromMM ( pagewidth ) . toFixed ( 2 ) ) + Common . Utils . Metric . getCurrentMetricName ( ) + ' x ' +
parseFloat ( Common . Utils . Metric . fnRecalcFromMM ( pageheight ) . toFixed ( 2 ) ) + Common . Utils . Metric . getCurrentMetricName ( ) + ')' ) ;
2016-04-07 10:49:15 +00:00
}
this . cmbPaperSize . onResetItems ( ) ;
2016-03-11 00:48:53 +00:00
} ,
handlerShowDetails : function ( btn ) {
if ( ! this . extended ) {
this . extended = true ;
this . panelDetails . css ( { 'display' : 'none' } ) ;
2019-03-19 14:33:09 +00:00
this . setHeight ( 314 ) ;
2016-03-11 00:48:53 +00:00
btn . setCaption ( this . textShowDetails ) ;
2016-03-31 11:13:16 +00:00
Common . localStorage . setItem ( "sse-hide-print-settings" , 1 ) ;
2016-03-11 00:48:53 +00:00
} else {
this . extended = false ;
this . panelDetails . css ( { 'display' : 'block' } ) ;
2020-03-17 14:55:37 +00:00
this . setHeight ( 585 ) ;
2016-03-11 00:48:53 +00:00
btn . setCaption ( this . textHideDetails ) ;
2016-03-31 11:13:16 +00:00
Common . localStorage . setItem ( "sse-hide-print-settings" , 0 ) ;
2016-03-11 00:48:53 +00:00
}
} ,
textTitle : 'Print Settings' ,
strLeft : 'Left' ,
strRight : 'Right' ,
strTop : 'Top' ,
strBottom : 'Bottom' ,
strPortrait : 'Portrait' ,
strLandscape : 'Landscape' ,
textPrintGrid : 'Print Gridlines' ,
textPrintHeadings : 'Print Rows and Columns Headings' ,
textPageSize : 'Page Size' ,
textPageOrientation : 'Page Orientation' ,
strMargins : 'Margins' ,
strPrint : 'Print' ,
btnPrint : 'Save & Print' ,
textPrintRange : 'Print Range' ,
textLayout : 'Layout' ,
textCurrentSheet : 'Current Sheet' ,
textAllSheets : 'All Sheets' ,
textSelection : 'Selection' ,
textActualSize : 'Actual Size' ,
2016-04-01 13:01:12 +00:00
textFitPage : 'Fit Sheet on One Page' ,
textFitCols : 'Fit All Columns on One Page' ,
textFitRows : 'Fit All Rows on One Page' ,
2016-03-11 00:48:53 +00:00
textShowDetails : 'Show Details' ,
2016-04-01 13:01:12 +00:00
textHideDetails : 'Hide Details' ,
2016-06-16 12:51:51 +00:00
textPageScaling : 'Scaling' ,
2018-04-05 11:29:37 +00:00
textSettings : 'Sheet Settings' ,
textTitlePDF : 'PDF Settings' ,
textShowGrid : 'Show Gridlines' ,
textShowHeadings : 'Show Rows and Columns Headings' ,
strShow : 'Show' ,
btnDownload : 'Save & Download' ,
2019-03-19 14:33:09 +00:00
textRange : 'Range' ,
2019-09-04 07:53:56 +00:00
textIgnore : 'Ignore Print Area' ,
2019-10-15 12:07:03 +00:00
textCustomOptions : 'Custom Options' ,
2020-03-17 14:55:37 +00:00
textCustom : 'Custom' ,
strPrintTitles : 'Print Titles' ,
textRepeatTop : 'Repeat rows at top' ,
textRepeatLeft : 'Repeat columns at left' ,
textRepeat : 'Repeat...'
2018-04-05 11:29:37 +00:00
2016-03-11 00:48:53 +00:00
} , SSE . Views . PrintSettings || { } ) ) ;
} ) ;