@@ -92,6 +92,8 @@ define([
92
92
this . ComboSettings = el . find ( '.form-combo' ) ;
93
93
this . CheckSettings = el . find ( '.form-checkbox' ) ;
94
94
this . RadioOnlySettings = el . find ( '.form-radiobox' ) ;
95
+ this . ButtonSettings = el . find ( '.form-button' ) ;
96
+ this . ImageOnlySettings = el . find ( '.form-image' ) ;
95
97
} ,
96
98
97
99
createDelayedElements : function ( ) {
@@ -448,6 +450,103 @@ define([
448
450
this . chUnison . on ( 'change' , this . onChUnison . bind ( this ) ) ;
449
451
this . lockedControls . push ( this . chUnison ) ;
450
452
453
+ // button
454
+ this . cmbLayout = new Common . UI . ComboBox ( {
455
+ el : $markup . findById ( '#form-combo-btn-layout' ) ,
456
+ cls : 'input-group-nr' ,
457
+ menuStyle : 'min-width: 100%;' ,
458
+ editable : false ,
459
+ data : [
460
+ { displayValue : this . textTextOnly , value : AscPDF . Api . Types . position . textOnly } ,
461
+ { displayValue : this . textIconOnly , value : AscPDF . Api . Types . position . iconOnly } ,
462
+ { displayValue : this . textIconTop , value : AscPDF . Api . Types . position . iconTextV } ,
463
+ { displayValue : this . textLabelTop , value : AscPDF . Api . Types . position . textIconV } ,
464
+ { displayValue : this . textIconLeft , value : AscPDF . Api . Types . position . iconTextH } ,
465
+ { displayValue : this . textLabelLeft , value : AscPDF . Api . Types . position . textIconH } ,
466
+ { displayValue : this . textOverlay , value : AscPDF . Api . Types . position . overlay }
467
+ ] ,
468
+ dataHint : '1' ,
469
+ dataHintDirection : 'bottom' ,
470
+ dataHintOffset : 'big'
471
+ } ) ;
472
+ this . cmbLayout . setValue ( AscPDF . Api . Types . position . textOnly ) ;
473
+ this . cmbLayout . on ( 'selected' , this . onLayoutChanged . bind ( this ) ) ;
474
+ this . lockedControls . push ( this . cmbLayout ) ;
475
+
476
+ this . chFit = new Common . UI . CheckBox ( {
477
+ el : $markup . findById ( '#form-chb-fit' ) ,
478
+ labelText : this . textFitBounds ,
479
+ dataHint : '1' ,
480
+ dataHintDirection : 'left' ,
481
+ dataHintOffset : 'small'
482
+ } ) ;
483
+ this . chFit . on ( 'change' , this . onChFit . bind ( this ) ) ;
484
+ this . lockedControls . push ( this . chFit ) ;
485
+
486
+ this . cmbScale = new Common . UI . ComboBox ( {
487
+ el : $markup . findById ( '#form-combo-scale' ) ,
488
+ cls : 'input-group-nr' ,
489
+ menuStyle : 'min-width: 100%;' ,
490
+ editable : false ,
491
+ data : [ { displayValue : this . textAlways , value : AscPDF . Api . Types . scaleWhen . always } ,
492
+ { displayValue : this . textNever , value : AscPDF . Api . Types . scaleWhen . never } ,
493
+ { displayValue : this . textTooBig , value : AscPDF . Api . Types . scaleWhen . tooBig } ,
494
+ { displayValue : this . textTooSmall , value : AscPDF . Api . Types . scaleWhen . tooSmall } ] ,
495
+ dataHint : '1' ,
496
+ dataHintDirection : 'bottom' ,
497
+ dataHintOffset : 'big'
498
+ } ) ;
499
+ this . cmbScale . setValue ( AscPDF . Api . Types . scaleWhen . always ) ;
500
+ this . lockedControls . push ( this . cmbScale ) ;
501
+ this . cmbScale . on ( 'selected' , this . onScaleChanged . bind ( this ) ) ;
502
+ this . cmbScale . on ( 'changed:after' , this . onScaleChanged . bind ( this ) ) ;
503
+ this . cmbScale . on ( 'hide:after' , this . onHideMenus . bind ( this ) ) ;
504
+
505
+ this . cmbHowScale = new Common . UI . ComboBox ( {
506
+ el : $markup . findById ( '#form-combo-how-scale' ) ,
507
+ cls : 'input-group-nr' ,
508
+ menuStyle : 'min-width: 100%;' ,
509
+ editable : false ,
510
+ data : [ { displayValue : this . textProportional , value : AscPDF . Api . Types . scaleHow . proportional } ,
511
+ { displayValue : this . textAnamorphic , value : AscPDF . Api . Types . scaleHow . anamorphic } ] ,
512
+ dataHint : '1' ,
513
+ dataHintDirection : 'bottom' ,
514
+ dataHintOffset : 'big'
515
+ } ) ;
516
+ this . cmbHowScale . setValue ( AscPDF . Api . Types . scaleHow . proportional ) ;
517
+ this . lockedControls . push ( this . cmbHowScale ) ;
518
+ this . cmbHowScale . on ( 'selected' , this . onHowScaleChanged . bind ( this ) ) ;
519
+ this . cmbHowScale . on ( 'changed:after' , this . onHowScaleChanged . bind ( this ) ) ;
520
+ this . cmbHowScale . on ( 'hide:after' , this . onHideMenus . bind ( this ) ) ;
521
+
522
+ this . imagePositionPreview = $markup . findById ( '#form-img-example' ) ;
523
+ this . imagePositionLabel = $markup . findById ( '#form-img-slider-value' ) ;
524
+
525
+ this . sldrPreviewPositionX = new Common . UI . SingleSlider ( {
526
+ el : $markup . findById ( '#form-img-slider-position-x' ) ,
527
+ width : 116 ,
528
+ minValue : 0 ,
529
+ maxValue : 100 ,
530
+ value : 50
531
+ } ) ;
532
+ this . sldrPreviewPositionX . on ( 'change' , _ . bind ( this . onImagePositionChange , this , 'x' ) ) ;
533
+ this . sldrPreviewPositionX . on ( 'changecomplete' , _ . bind ( this . onImagePositionChangeComplete , this , 'x' ) ) ;
534
+
535
+ this . sldrPreviewPositionY = new Common . UI . SingleSlider ( {
536
+ el : $markup . findById ( '#form-img-slider-position-y' ) ,
537
+ width : 116 ,
538
+ minValue : 0 ,
539
+ maxValue : 100 ,
540
+ value : 50 ,
541
+ direction : 'vertical'
542
+ } ) ;
543
+ this . sldrPreviewPositionY . on ( 'change' , _ . bind ( this . onImagePositionChange , this , 'y' ) ) ;
544
+ this . sldrPreviewPositionY . on ( 'changecomplete' , _ . bind ( this . onImagePositionChangeComplete , this , 'y' ) ) ;
545
+
546
+ var xValue = this . sldrPreviewPositionX . getValue ( ) ,
547
+ yValue = this . sldrPreviewPositionY . getValue ( ) ;
548
+ this . imagePositionLabel . text ( xValue + ',' + yValue ) ;
549
+
451
550
this . UpdateThemeColors ( ) ;
452
551
} ,
453
552
@@ -710,6 +809,70 @@ define([
710
809
}
711
810
} ,
712
811
812
+ onLayoutChanged : function ( combo , record ) {
813
+ if ( this . api && ! this . _noApply ) {
814
+ this . _state . Layout = undefined ;
815
+ this . api . SetButtonLayout ( record . value ) ;
816
+ this . fireEvent ( 'editcomplete' , this ) ;
817
+ }
818
+ } ,
819
+
820
+ onChFit : function ( field , newValue , oldValue , eOpts ) {
821
+ if ( this . api && ! this . _noApply ) {
822
+ this . api . SetButtonFitBounds ( field . getValue ( ) === 'checked' ) ;
823
+ this . fireEvent ( 'editcomplete' , this ) ;
824
+ }
825
+ } ,
826
+
827
+ onScaleChanged : function ( combo , record ) {
828
+ if ( this . api && ! this . _noApply ) {
829
+ this . _state . Scale = undefined ;
830
+ this . api . SetButtonScaleWhen ( record . value ) ;
831
+ this . fireEvent ( 'editcomplete' , this ) ;
832
+ }
833
+ } ,
834
+
835
+ onHowScaleChanged : function ( combo , record ) {
836
+ if ( this . api && ! this . _noApply ) {
837
+ this . _state . HowScale = undefined ;
838
+ this . api . SetButtonScaleHow ( record . value ) ;
839
+ this . fireEvent ( 'editcomplete' , this ) ;
840
+ }
841
+ } ,
842
+
843
+ onImagePositionChange : function ( type , field , newValue , oldValue ) {
844
+ var value = ( ( 130 - 80 ) * newValue ) / 100 - 1 ;
845
+ if ( type === 'x' ) {
846
+ this . imagePositionPreview . css ( { 'left' : value + 'px' } ) ;
847
+ this . _state . imgPositionX = newValue ;
848
+ } else {
849
+ this . imagePositionPreview . css ( { 'top' : value + 'px' } ) ;
850
+ this . _state . imgPositionY = newValue ;
851
+ }
852
+ if ( _ . isUndefined ( this . _state . imgPositionX ) ) {
853
+ this . _state . imgPositionX = 50 ;
854
+ } else if ( _ . isUndefined ( this . _state . imgPositionY ) ) {
855
+ this . _state . imgPositionY = 50 ;
856
+ }
857
+ this . imagePositionLabel . text ( Math . round ( this . _state . imgPositionX ) + ',' + Math . round ( this . _state . imgPositionY ) ) ;
858
+ } ,
859
+
860
+ onImagePositionChangeComplete : function ( type , field , newValue , oldValue ) {
861
+ if ( type === 'x' ) {
862
+ this . _state . imgPositionX = newValue ;
863
+ } else {
864
+ this . _state . imgPositionY = newValue ;
865
+ }
866
+ this . imgPositionApplyFunc ( type ) ;
867
+ } ,
868
+
869
+ imgPositionApplyFunc : function ( type ) {
870
+ if ( this . api && ! this . _noApply ) {
871
+ this . api . SetButtonIconPos ( this . _state . imgPositionX / 100 , this . _state . imgPositionY / 100 ) ;
872
+ this . fireEvent ( 'editcomplete' , this ) ;
873
+ }
874
+ } ,
875
+
713
876
ChangeSettings : function ( props , isShape ) {
714
877
if ( this . _initSettings )
715
878
this . createDelayedElements ( ) ;
@@ -918,9 +1081,60 @@ define([
918
1081
this . disableListButtons ( ) ;
919
1082
}
920
1083
921
- if ( type == AscPDF . FIELD_TYPES . button )
1084
+ if ( type === AscPDF . FIELD_TYPES . button ) {
922
1085
// this.labelFormName.text(props.is_Signature() ? this.textSignature : this.textImage);
923
- this . labelFormName . text ( this . textImage ) ;
1086
+ this . labelFormName . text ( this . textButton ) ;
1087
+ if ( specProps ) {
1088
+ val = specProps . asc_getLayout ( ) ;
1089
+ if ( this . _state . Layout !== val ) {
1090
+ this . cmbLayout . setValue ( val , '' ) ;
1091
+ this . _state . Layout = val ;
1092
+ }
1093
+
1094
+ if ( val !== AscPDF . Api . Types . position . textOnly ) {
1095
+ val = specProps . asc_getScaleWhen ( ) ;
1096
+ if ( this . _state . Scale !== val ) {
1097
+ this . cmbScale . setValue ( val , '' ) ;
1098
+ this . _state . Scale = val ;
1099
+ }
1100
+
1101
+ val = specProps . asc_getScaleHow ( ) ;
1102
+ if ( this . _state . HowScale !== val ) {
1103
+ this . cmbHowScale . setValue ( val , '' ) ;
1104
+ this . _state . HowScale = val ;
1105
+ }
1106
+
1107
+ val = specProps . asc_getIconPos ( ) ;
1108
+ if ( val ) {
1109
+ var x = val . X * 100 ,
1110
+ y = val . Y * 100 ;
1111
+ if ( this . _state . imgPositionX !== x ) {
1112
+ this . sldrPreviewPositionX . setValue ( x ) ;
1113
+ this . _state . imgPositionX = x ;
1114
+ }
1115
+ if ( this . _state . imgPositionY !== y ) {
1116
+ this . sldrPreviewPositionY . setValue ( y ) ;
1117
+ this . _state . imgPositionY = y ;
1118
+ }
1119
+ this . imagePositionLabel . text ( Math . round ( this . _state . imgPositionX ) + ',' + Math . round ( this . _state . imgPositionY ) ) ;
1120
+ val = ( ( 130 - 80 ) * this . _state . imgPositionX ) / 100 - 1 ;
1121
+ this . imagePositionPreview . css ( { 'left' : val + 'px' } ) ;
1122
+ val = ( ( 130 - 80 ) * this . _state . imgPositionY ) / 100 - 1 ;
1123
+ this . imagePositionPreview . css ( { 'top' : val + 'px' } ) ;
1124
+ }
1125
+
1126
+ val = specProps . asc_getFitBounds ( ) ;
1127
+ if ( this . _state . Fit !== val ) {
1128
+ this . chFit . setValue ( ! ! val , true ) ;
1129
+ this . _state . Fit = val ;
1130
+ }
1131
+ this . chFit . setDisabled ( this . _state . Scale === AscPDF . Api . Types . scaleWhen . never || this . _state . DisabledControls ) ;
1132
+ var disableSliders = this . _state . Scale === AscPDF . Api . Types . scaleWhen . always && ! this . _state . Fit || this . _state . DisabledControls ;
1133
+ this . sldrPreviewPositionX . setDisabled ( disableSliders ) ;
1134
+ this . sldrPreviewPositionY . setDisabled ( disableSliders ) ;
1135
+ }
1136
+ }
1137
+ }
924
1138
925
1139
if ( type == AscPDF . FIELD_TYPES . checkbox || type == AscPDF . FIELD_TYPES . radiobutton ) {
926
1140
var isCheckbox = type == AscPDF . FIELD_TYPES . checkbox ;
@@ -959,7 +1173,7 @@ define([
959
1173
960
1174
this . _noApply = false ;
961
1175
962
- if ( this . type !== type )
1176
+ if ( this . type !== type || type === AscPDF . FIELD_TYPES . button )
963
1177
this . showHideControls ( type , specProps ) ;
964
1178
965
1179
if ( this . type !== type )
@@ -1062,14 +1276,20 @@ define([
1062
1276
this . spnCombChars . setDisabled ( ! isComb || this . _state . DisabledControls ) ;
1063
1277
this . chMaxChars . setDisabled ( isComb || this . _state . DisabledControls ) ;
1064
1278
this . spnMaxChars . setDisabled ( isComb || this . chMaxChars . getValue ( ) !== 'checked' || this . _state . DisabledControls ) ;
1279
+ this . chFit . setDisabled ( this . _state . Scale === AscPDF . Api . Types . scaleWhen . never || this . _state . DisabledControls ) ;
1280
+ var disableSliders = this . _state . Scale === AscPDF . Api . Types . scaleWhen . always && ! this . _state . Fit || this . _state . DisabledControls ;
1281
+ this . sldrPreviewPositionX . setDisabled ( disableSliders ) ;
1282
+ this . sldrPreviewPositionY . setDisabled ( disableSliders ) ;
1065
1283
} ,
1066
1284
1067
1285
showHideControls : function ( type , specProps ) {
1068
1286
var isCombobox = type === AscPDF . FIELD_TYPES . combobox ,
1069
1287
isText = type === AscPDF . FIELD_TYPES . text ,
1070
1288
isListbox = type === AscPDF . FIELD_TYPES . listbox ,
1071
1289
isCheck = type === AscPDF . FIELD_TYPES . checkbox ,
1072
- isRadio = type === AscPDF . FIELD_TYPES . radiobutton ;
1290
+ isRadio = type === AscPDF . FIELD_TYPES . radiobutton ,
1291
+ isButton = type === AscPDF . FIELD_TYPES . button ,
1292
+ isImage = isButton && ( specProps . asc_getLayout ( ) !== AscPDF . Api . Types . position . textOnly ) ;
1073
1293
this . PlaceholderSettings . toggleClass ( 'hidden' , ! ( isCombobox || isText ) ) ;
1074
1294
this . AutofitSettings . toggleClass ( 'hidden' , ! ( isCombobox || isText ) ) ;
1075
1295
this . ListSettings . toggleClass ( 'hidden' , ! ( isCombobox || isListbox ) ) ;
@@ -1078,6 +1298,8 @@ define([
1078
1298
this . ListboxOnlySettings . toggleClass ( 'hidden' , ! isListbox ) ;
1079
1299
this . CheckSettings . toggleClass ( 'hidden' , ! ( isCheck || isRadio ) ) ;
1080
1300
this . RadioOnlySettings . toggleClass ( 'hidden' , ! isRadio ) ;
1301
+ this . ButtonSettings . toggleClass ( 'hidden' , ! isButton ) ;
1302
+ this . ImageOnlySettings . toggleClass ( 'hidden' , ! isImage ) ;
1081
1303
}
1082
1304
1083
1305
} , PDFE . Views . FormSettings || { } ) ) ;
0 commit comments