2019-07-09 14:03:25 +00:00
/ *
*
* ( c ) Copyright Ascensio System SIA 2010 - 2019
*
* 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
*
* You can contact Ascensio System SIA at 20 A - 12 Ernesta Birznieka - Upisha
* street , Riga , Latvia , EU , LV - 1050.
*
* 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
*
* /
/ * *
* HeaderFooterDialog . js
*
* Created by Julia Radzhabova on 09.07 . 2019
* Copyright ( c ) 2019 Ascensio System SIA . All rights reserved .
*
* /
define ( [ 'text!presentationeditor/main/app/template/HeaderFooterDialog.template' ,
'common/main/lib/util/utils' ,
'common/main/lib/component/RadioBox' ,
'common/main/lib/component/InputField' ,
'common/main/lib/view/AdvancedSettingsWindow'
] , function ( template ) { 'use strict' ;
PE . Views . HeaderFooterDialog = Common . Views . AdvancedSettingsWindow . extend ( _ . extend ( {
options : {
contentWidth : 360 ,
2019-09-11 08:38:08 +00:00
height : 380 ,
buttons : null
2019-07-09 14:03:25 +00:00
} ,
initialize : function ( options ) {
var me = this ;
_ . extend ( this . options , {
title : this . textTitle ,
template : _ . template (
[
'<div class="box" style="height:' + ( me . options . height - 85 ) + 'px;">' ,
'<div class="content-panel" style="padding: 10px 5px;"><div class="inner-content">' ,
'<div class="settings-panel active">' ,
template ,
'</div></div>' ,
'</div>' ,
2020-06-05 13:10:48 +00:00
'<div class="separator"></div>' ,
2019-07-09 14:03:25 +00:00
'<div class="menu-panel" style="width: 130px; padding-top: 17px;">' ,
'<label style="display:block; margin-left: 15px;" class="input-label">' + me . textPreview + '</label>' ,
'<div style="width: 100px; height: 80px; padding: 5px; margin-left: 15px; border: 1px solid #AFAFAF; border-radius: 2px; background: #ffffff;">' ,
'<div id="hf-dlg-canvas-preview" style="width: 100%;height: 100%;"></div>' ,
'</div>' ,
'</div>' ,
'</div>' ,
2020-06-05 13:10:48 +00:00
'<div class="separator horizontal"></div>' ,
2019-07-09 14:03:25 +00:00
'<div class="footer center">' ,
2019-09-11 08:38:08 +00:00
'<button class="btn normal dlg-btn primary" result="all" style="width: auto; min-width: 86px;">' + me . applyAllText + '</button>' ,
'<button class="btn normal dlg-btn" result="ok" style="width: auto; min-width: 86px;">' + me . applyText + '</button>' ,
2019-07-09 14:03:25 +00:00
'<button class="btn normal dlg-btn" result="cancel">' + me . cancelButtonText + '</button>' ,
'</div>'
] . join ( '' )
) ( {
scope : this
} )
} , options ) ;
this . lang = options . lang ;
this . handler = options . handler ;
this . hfProps = options . props ;
this . api = options . api ;
this . dateControls = [ ] ;
Common . Views . AdvancedSettingsWindow . prototype . initialize . call ( this , this . options ) ;
} ,
render : function ( ) {
Common . Views . AdvancedSettingsWindow . prototype . render . call ( this ) ;
var me = this ;
this . chDateTime = new Common . UI . CheckBox ( {
el : $ ( '#hf-dlg-chb-datetime' ) ,
labelText : this . textDateTime
} ) ;
this . chDateTime . on ( 'change' , _ . bind ( this . setType , this , 'date' ) ) ;
this . chSlide = new Common . UI . CheckBox ( {
el : $ ( '#hf-dlg-chb-slide' ) ,
labelText : this . textSlideNum
} ) ;
this . chSlide . on ( 'change' , _ . bind ( this . setType , this , 'slide' ) ) ;
this . chFooter = new Common . UI . CheckBox ( {
el : $ ( '#hf-dlg-chb-text' ) ,
labelText : this . textFooter
} ) ;
this . chFooter . on ( 'change' , _ . bind ( this . setType , this , 'footer' ) ) ;
this . inputFooter = new Common . UI . InputField ( {
el : $ ( '#hf-dlg-text' ) ,
validateOnBlur : false ,
style : 'width: 100%;'
} ) ;
2021-08-02 13:52:33 +00:00
var data = [ { value : 0x042C } , { value : 0x0402 } , { value : 0x0405 } , { value : 0x0C07 } , { value : 0x0407 } , { value : 0x0807 } , { value : 0x0408 } , { value : 0x0C09 } , { value : 0x0809 } , { value : 0x0409 } , { value : 0x0C0A } , { value : 0x080A } ,
2022-03-01 14:17:02 +00:00
{ value : 0x040B } , { value : 0x040C } , { value : 0x100C } , { value : 0x0410 } , { value : 0x0810 } , { value : 0x0411 } , { value : 0x0412 } , { value : 0x0426 } , { value : 0x040E } , { value : 0x0413 } , { value : 0x0415 } , { value : 0x0416 } ,
2019-07-09 14:03:25 +00:00
{ value : 0x0816 } , { value : 0x0419 } , { value : 0x041B } , { value : 0x0424 } , { value : 0x081D } , { value : 0x041D } , { value : 0x041F } , { value : 0x0422 } , { value : 0x042A } , { value : 0x0804 } ] ;
data . forEach ( function ( item ) {
var langinfo = Common . util . LanguageInfo . getLocalLanguageName ( item . value ) ;
item . displayValue = langinfo [ 1 ] ;
item . langName = langinfo [ 0 ] ;
} ) ;
this . cmbLang = new Common . UI . ComboBox ( {
el : $ ( '#hf-dlg-combo-lang' ) ,
menuStyle : 'min-width: 100%; max-height: 185px;' ,
cls : 'input-group-nr' ,
editable : false ,
2020-09-26 21:27:07 +00:00
data : data ,
search : true ,
2020-10-13 19:49:04 +00:00
scrollAlwaysVisible : true ,
takeFocusOnClose : true
2019-07-09 14:03:25 +00:00
} ) ;
this . cmbLang . setValue ( 0x0409 ) ;
this . cmbLang . on ( 'selected' , _ . bind ( function ( combo , record ) {
this . updateFormats ( record . value ) ;
} , this ) ) ;
this . dateControls . push ( this . cmbLang ) ;
this . cmbFormat = new Common . UI . ComboBox ( {
el : $ ( '#hf-dlg-combo-format' ) ,
menuStyle : 'min-width: 100%; max-height: 185px;' ,
cls : 'input-group-nr' ,
editable : false ,
2020-10-13 19:49:04 +00:00
data : [ ] ,
takeFocusOnClose : true
2019-07-09 14:03:25 +00:00
} ) ;
this . dateControls . push ( this . cmbFormat ) ;
2019-07-23 14:09:30 +00:00
this . radioUpdate = new Common . UI . RadioBox ( {
el : $ ( '#hf-dlg-radio-update' ) ,
2019-07-09 14:03:25 +00:00
labelText : this . textUpdate ,
2019-07-23 14:09:30 +00:00
name : 'asc-radio-header-update' ,
checked : true
} ) . on ( 'change' , _ . bind ( this . setDateTimeType , this , 'update' ) ) ;
this . dateControls . push ( this . radioUpdate ) ;
this . radioFixed = new Common . UI . RadioBox ( {
el : $ ( '#hf-dlg-radio-fixed' ) ,
labelText : this . textFixed ,
name : 'asc-radio-header-update'
} ) . on ( 'change' , _ . bind ( this . setDateTimeType , this , 'fixed' ) ) ;
this . dateControls . push ( this . radioFixed ) ;
this . inputFixed = new Common . UI . InputField ( {
el : $ ( '#hf-dlg-input-fixed' ) ,
validateOnBlur : false ,
style : 'width: 100%;'
2019-07-09 14:03:25 +00:00
} ) ;
2019-07-23 14:09:30 +00:00
this . dateControls . push ( this . inputFixed ) ;
2019-07-09 14:03:25 +00:00
this . chNotTitle = new Common . UI . CheckBox ( {
el : $ ( '#hf-dlg-chb-not-title' ) ,
labelText : this . textNotTitle
} ) ;
this . afterRender ( ) ;
} ,
2020-10-13 19:49:04 +00:00
getFocusedComponents : function ( ) {
2021-04-14 08:01:41 +00:00
return [ this . chDateTime , this . radioUpdate , this . cmbFormat , this . cmbLang , this . radioFixed , this . inputFixed , this . chSlide , this . chFooter , this . inputFooter , this . chNotTitle ] ;
2020-10-13 19:49:04 +00:00
} ,
2020-10-22 10:53:58 +00:00
getDefaultFocusableComponent : function ( ) {
if ( ! this . cmbFormat . isDisabled ( ) )
return this . cmbFormat ;
else if ( ! this . inputFixed . isDisabled ( ) )
return this . inputFixed ;
else if ( ! this . inputFooter . isDisabled ( ) )
return this . inputFooter ;
2021-04-13 15:20:08 +00:00
else
return this . chDateTime ;
2020-10-13 19:49:04 +00:00
} ,
2020-10-22 10:53:58 +00:00
focusControls : function ( ) {
var el = this . getDefaultFocusableComponent ( ) ;
el && setTimeout ( function ( ) {
el . focus ( ) ;
} , 10 ) ;
2020-10-13 19:49:04 +00:00
} ,
2019-07-09 14:03:25 +00:00
afterRender : function ( ) {
var me = this ,
value = Common . Utils . InternalSettings . get ( "pe-settings-datetime-default" ) ,
arr = ( value ) ? value . split ( ';' ) : [ ] ;
this . defaultFormats = [ ] ;
arr . forEach ( function ( item ) {
var pair = item . split ( ' ' ) ;
me . defaultFormats [ parseInt ( pair [ 0 ] ) ] = pair [ 1 ] ;
} ) ;
this . _setDefaults ( this . hfProps ) ;
} ,
setType : function ( type , field , newValue ) {
2019-07-31 12:08:15 +00:00
var me = this ;
2019-07-09 14:03:25 +00:00
newValue = ( newValue == 'checked' ) ;
if ( type == 'date' ) {
_ . each ( this . dateControls , function ( item ) {
item . setDisabled ( ! newValue ) ;
} ) ;
2019-07-23 14:09:30 +00:00
newValue && this . setDateTimeType ( this . radioFixed . getValue ( ) ? 'fixed' : 'update' , null , true ) ;
2019-07-09 14:03:25 +00:00
this . props . put _ShowDateTime ( newValue ) ;
2020-10-13 19:49:04 +00:00
this . focusControls ( ) ;
2019-07-09 14:03:25 +00:00
} else if ( type == 'slide' ) {
this . props . put _ShowSlideNum ( newValue ) ;
} else if ( type == 'footer' ) {
this . inputFooter . setDisabled ( ! newValue ) ;
this . props . put _ShowFooter ( newValue ) ;
2019-07-31 12:08:15 +00:00
newValue && setTimeout ( function ( ) {
me . inputFooter . cmpEl . find ( 'input' ) . focus ( ) ;
} , 50 ) ;
2019-07-09 14:03:25 +00:00
}
this . props . updateView ( ) ;
} ,
2019-08-01 12:30:22 +00:00
updateFormats : function ( lang , format ) {
2019-07-09 14:03:25 +00:00
var props = new AscCommonSlide . CAscDateTime ( ) ;
props . put _Lang ( lang ) ;
var data = props . get _DateTimeExamples ( ) ,
arr = [ ] ;
for ( var name in data ) {
if ( data [ name ] ) {
arr . push ( {
value : name ,
displayValue : data [ name ]
} ) ;
}
}
this . cmbFormat . setData ( arr ) ;
2019-08-01 12:30:22 +00:00
format = format || this . defaultFormats [ lang ] ;
2019-07-09 14:03:25 +00:00
this . cmbFormat . setValue ( format ? format : arr [ 0 ] . value ) ;
} ,
2019-07-23 14:09:30 +00:00
setDateTimeType : function ( type , field , newValue ) {
if ( newValue ) {
2019-07-31 12:08:15 +00:00
var me = this ;
2019-07-23 14:09:30 +00:00
this . cmbLang . setDisabled ( type == 'fixed' ) ;
this . cmbFormat . setDisabled ( type == 'fixed' ) ;
this . inputFixed . setDisabled ( type == 'update' ) ;
2020-10-13 19:49:04 +00:00
this . focusControls ( ) ;
2019-07-23 14:09:30 +00:00
}
} ,
2019-07-09 14:03:25 +00:00
onSelectFormat : function ( format ) {
2019-07-23 14:09:30 +00:00
if ( this . radioUpdate . getValue ( ) ) {
format = format || this . cmbFormat . getValue ( ) ;
2019-07-09 14:03:25 +00:00
this . props . get _DateTime ( ) . put _DateTime ( format ) ;
} else {
this . props . get _DateTime ( ) . put _DateTime ( null ) ;
2019-07-23 14:09:30 +00:00
this . props . get _DateTime ( ) . put _CustomDateTime ( this . inputFixed . getValue ( ) ) ;
2019-07-09 14:03:25 +00:00
}
} ,
_setDefaults : function ( props ) {
if ( props ) {
var slideprops = props . get _Slide ( ) || new AscCommonSlide . CAscHFProps ( ) ;
var val = slideprops . get _ShowDateTime ( ) ;
this . chDateTime . setValue ( val , true ) ;
_ . each ( this . dateControls , function ( item ) {
item . setDisabled ( ! val ) ;
} ) ;
2019-08-01 12:30:22 +00:00
var format , fixed ,
2019-07-15 07:35:30 +00:00
datetime = slideprops . get _DateTime ( ) ,
2019-07-23 14:09:30 +00:00
item = this . cmbLang . store . findWhere ( { value : datetime ? ( datetime . get _Lang ( ) || this . lang ) : this . lang } ) ;
2019-07-15 07:35:30 +00:00
this . _originalLang = item ? item . get ( 'value' ) : 0x0409 ;
this . cmbLang . setValue ( this . _originalLang ) ;
2019-07-09 14:03:25 +00:00
if ( val ) {
format = datetime . get _DateTime ( ) ;
2019-07-23 14:09:30 +00:00
! format ? this . radioFixed . setValue ( true ) : this . radioUpdate . setValue ( true ) ;
2019-08-01 12:30:22 +00:00
! format && ( fixed = datetime . get _CustomDateTime ( ) || '' ) ;
2019-07-23 14:09:30 +00:00
this . setDateTimeType ( ! format ? 'fixed' : 'update' , null , true ) ;
2019-07-09 14:03:25 +00:00
}
2019-08-01 12:30:22 +00:00
this . updateFormats ( this . cmbLang . getValue ( ) , format ) ;
this . inputFixed . setValue ( ( fixed !== undefined ) ? fixed : this . cmbFormat . getRawValue ( ) ) ;
2019-07-09 14:03:25 +00:00
val = slideprops . get _ShowSlideNum ( ) ;
this . chSlide . setValue ( val , true ) ;
val = slideprops . get _ShowFooter ( ) ;
this . chFooter . setValue ( val , true ) ;
this . inputFooter . setDisabled ( ! val ) ;
val && this . inputFooter . setValue ( slideprops . get _Footer ( ) || '' ) ;
val = slideprops . get _ShowOnTitleSlide ( ) ;
this . chNotTitle . setValue ( ! val , true ) ;
this . props = slideprops ;
} else
this . props = new AscCommonSlide . CAscHFProps ( ) ;
this . props . put _DivId ( 'hf-dlg-canvas-preview' ) ;
this . props . put _Api ( this . api ) ;
this . props . updateView ( ) ;
} ,
getSettings : function ( ) {
2019-07-10 07:05:25 +00:00
var props = this . props ;
if ( props . get _ShowDateTime ( ) ) {
! props . get _DateTime ( ) && props . put _DateTime ( new AscCommonSlide . CAscDateTime ( ) ) ;
props . get _DateTime ( ) . put _Lang ( this . cmbLang . getValue ( ) ) ;
this . onSelectFormat ( ) ;
2019-07-09 14:03:25 +00:00
}
2019-07-10 07:05:25 +00:00
if ( props . get _ShowFooter ( ) ) {
props . put _Footer ( this . inputFooter . getValue ( ) ) ;
}
props . put _ShowOnTitleSlide ( this . chNotTitle . getValue ( ) != 'checked' ) ;
2019-07-09 14:03:25 +00:00
this . hfProps . put _Slide ( this . props ) ;
return this . hfProps ;
} ,
onDlgBtnClick : function ( event ) {
this . _handleInput ( event . currentTarget . attributes [ 'result' ] . value ) ;
} ,
onPrimary : function ( ) {
2019-08-01 12:30:22 +00:00
this . _handleInput ( 'all' ) ;
2019-07-09 14:03:25 +00:00
return false ;
} ,
_handleInput : function ( state ) {
2019-07-15 07:35:30 +00:00
if ( this . handler ) {
if ( state == 'ok' ) {
if ( this . cmbLang . getValue ( ) !== this . _originalLang ) {
Common . UI . warning ( {
title : this . notcriticalErrorTitle ,
maxwidth : 600 ,
msg : this . diffLanguage
} ) ;
return ;
}
}
this . handler . call ( this , state , this . getSettings ( ) ) ;
}
2019-07-09 14:03:25 +00:00
this . close ( ) ;
} ,
2019-11-28 10:27:01 +00:00
textTitle : 'Footer Settings' ,
2019-07-09 14:03:25 +00:00
applyAllText : 'Apply to all' ,
applyText : 'Apply' ,
textLang : 'Language' ,
textFormat : 'Formats' ,
textUpdate : 'Update automatically' ,
textDateTime : 'Date and time' ,
textSlideNum : 'Slide number' ,
textFooter : 'Text in footer' ,
textNotTitle : 'Don\'t show on title slide' ,
2019-07-15 07:35:30 +00:00
textPreview : 'Preview' ,
diffLanguage : 'You can’ t use a date format in a different language than the slide master.\nTo change the master, click \'Apply to all\' instead of \'Apply\'' ,
2019-07-23 14:09:30 +00:00
notcriticalErrorTitle : 'Warning' ,
textFixed : 'Fixed'
2019-07-09 14:03:25 +00:00
} , PE . Views . HeaderFooterDialog || { } ) )
} ) ;