@@ -68,7 +68,8 @@ define([
68
68
69
69
this . _state = {
70
70
DisabledControls : undefined ,
71
- LockDelete : undefined
71
+ LockDelete : undefined ,
72
+ ButtonCaption : { }
72
73
} ;
73
74
this . spinners = [ ] ;
74
75
this . lockedControls = [ ] ;
@@ -94,6 +95,7 @@ define([
94
95
this . CheckSettings = el . find ( '.form-checkbox' ) ;
95
96
this . RadioOnlySettings = el . find ( '.form-radiobox' ) ;
96
97
this . ButtonSettings = el . find ( '.form-button' ) ;
98
+ this . ButtonTextOnlySettings = el . find ( '.form-button-text' ) ;
97
99
this . ImageOnlySettings = el . find ( '.form-image' ) ;
98
100
} ,
99
101
@@ -474,6 +476,57 @@ define([
474
476
this . cmbLayout . on ( 'selected' , this . onLayoutChanged . bind ( this ) ) ;
475
477
this . lockedControls . push ( this . cmbLayout ) ;
476
478
479
+ this . cmbBehavior = new Common . UI . ComboBox ( {
480
+ el : $markup . findById ( '#form-combo-behavior' ) ,
481
+ cls : 'input-group-nr' ,
482
+ menuStyle : 'min-width: 100%;' ,
483
+ editable : false ,
484
+ data : [ { displayValue : this . textNone , value : AscPDF . BUTTON_HIGHLIGHT_TYPES . none } ,
485
+ { displayValue : this . textPush , value : AscPDF . BUTTON_HIGHLIGHT_TYPES . push } ,
486
+ { displayValue : this . textOutline , value : AscPDF . BUTTON_HIGHLIGHT_TYPES . outline } ,
487
+ { displayValue : this . textInvert , value : AscPDF . BUTTON_HIGHLIGHT_TYPES . invert } ] ,
488
+ dataHint : '1' ,
489
+ dataHintDirection : 'bottom' ,
490
+ dataHintOffset : 'big'
491
+ } ) ;
492
+ this . cmbBehavior . setValue ( AscPDF . BUTTON_HIGHLIGHT_TYPES . none ) ;
493
+ this . cmbBehavior . on ( 'selected' , this . onBehaviorChanged . bind ( this ) ) ;
494
+ this . lockedControls . push ( this . cmbBehavior ) ;
495
+
496
+ this . cmbState = new Common . UI . ComboBox ( {
497
+ el : $markup . findById ( '#form-combo-state' ) ,
498
+ cls : 'input-group-nr' ,
499
+ menuStyle : 'min-width: 100%;' ,
500
+ editable : false ,
501
+ data : [ { displayValue : this . textNormal , value : AscPDF . APPEARANCE_TYPES . normal } ,
502
+ { displayValue : this . textDown , value : AscPDF . APPEARANCE_TYPES . mouseDown } ,
503
+ { displayValue : this . textHover , value : AscPDF . APPEARANCE_TYPES . rollover } ] ,
504
+ dataHint : '1' ,
505
+ dataHintDirection : 'bottom' ,
506
+ dataHintOffset : 'big'
507
+ } ) ;
508
+ this . cmbState . setValue ( AscPDF . APPEARANCE_TYPES . normal ) ;
509
+ this . cmbState . on ( 'selected' , this . onStateChanged . bind ( this ) ) ;
510
+ this . lockedControls . push ( this . cmbState ) ;
511
+
512
+ this . txtLabel = new Common . UI . InputField ( {
513
+ el : $markup . findById ( '#form-txt-label' ) ,
514
+ allowBlank : true ,
515
+ validateOnChange : false ,
516
+ validateOnBlur : false ,
517
+ style : 'width: 100%;' ,
518
+ value : '' ,
519
+ dataHint : '1' ,
520
+ dataHintDirection : 'left' ,
521
+ dataHintOffset : 'small'
522
+ } ) ;
523
+ this . lockedControls . push ( this . txtLabel ) ;
524
+ this . txtLabel . on ( 'changed:after' , this . onLabelChanged . bind ( this ) ) ;
525
+ this . txtLabel . on ( 'inputleave' , function ( ) { me . fireEvent ( 'editcomplete' , me ) ; } ) ;
526
+ this . txtLabel . cmpEl . on ( 'focus' , 'input.form-control' , function ( ) {
527
+ setTimeout ( function ( ) { me . txtLabel . _input && me . txtLabel . _input . select ( ) ; } , 1 ) ;
528
+ } ) ;
529
+
477
530
this . chFit = new Common . UI . CheckBox ( {
478
531
el : $markup . findById ( '#form-chb-fit' ) ,
479
532
labelText : this . textFitBounds ,
@@ -819,6 +872,34 @@ define([
819
872
}
820
873
} ,
821
874
875
+ onBehaviorChanged : function ( combo , record ) {
876
+ if ( this . api && ! this . _noApply ) {
877
+ this . _state . Behavior = undefined ;
878
+ this . api . SetButtonFieldBehavior ( record . value ) ;
879
+ this . fireEvent ( 'editcomplete' , this ) ;
880
+ }
881
+ } ,
882
+
883
+ onStateChanged : function ( combo , record ) {
884
+ if ( this . api && ! this . _noApply ) {
885
+ this . _state . State = record . value ;
886
+ if ( this . _originalSpecProps ) {
887
+ this . _originalSpecProps . asc_putCurrentState ( record . value ) ;
888
+ this . _state . ButtonLabel = this . _state . ButtonCaption [ record . value ] ;
889
+ this . txtLabel . setValue ( this . _state . ButtonLabel || '' ) ;
890
+ }
891
+ }
892
+ } ,
893
+
894
+ onLabelChanged : function ( input , newValue , oldValue , e ) {
895
+ this . _state . ButtonLabel = undefined ;
896
+ if ( this . api && ! this . _noApply && ( newValue !== oldValue ) ) {
897
+ this . api . SetButtonFieldLabel ( newValue , this . _state . State ) ;
898
+ if ( ! e . relatedTarget || ( e . relatedTarget . localName != 'input' && e . relatedTarget . localName != 'textarea' ) || ! / f o r m - c o n t r o l / . test ( e . relatedTarget . className ) )
899
+ this . fireEvent ( 'editcomplete' , this ) ;
900
+ }
901
+ } ,
902
+
822
903
onChFit : function ( field , newValue , oldValue , eOpts ) {
823
904
if ( this . api && ! this . _noApply ) {
824
905
this . api . SetButtonFieldFitBounds ( field . getValue ( ) === 'checked' ) ;
@@ -1087,13 +1168,43 @@ define([
1087
1168
// this.labelFormName.text(props.is_Signature() ? this.textSignature : this.textImage);
1088
1169
this . labelFormName . text ( this . textButton ) ;
1089
1170
if ( specProps ) {
1090
- val = specProps . asc_getLayout ( ) ;
1091
- if ( this . _state . Layout !== val ) {
1092
- this . cmbLayout . setValue ( val , '' ) ;
1093
- this . _state . Layout = val ;
1171
+ var layout = specProps . asc_getLayout ( ) ;
1172
+ if ( this . _state . Layout !== layout ) {
1173
+ this . cmbLayout . setValue ( layout , '' ) ;
1174
+ this . _state . Layout = layout ;
1175
+ }
1176
+
1177
+ val = specProps . asc_getBehavior ( ) ;
1178
+ if ( this . _state . Behavior !== val ) {
1179
+ this . cmbBehavior . setValue ( val , '' ) ;
1180
+ this . _state . Behavior = val ;
1181
+ this . cmbState . setDisabled ( val !== AscPDF . BUTTON_HIGHLIGHT_TYPES . push || this . _state . DisabledControls ) ;
1182
+ }
1183
+ if ( this . _state . Behavior === AscPDF . BUTTON_HIGHLIGHT_TYPES . push ) {
1184
+ val = specProps . asc_getCurrentState ( ) ;
1185
+ if ( this . _state . State !== val ) {
1186
+ this . cmbState . setValue ( val , '' ) ;
1187
+ this . _state . State = val ;
1188
+ }
1189
+ this . _state . ButtonCaption = { } ;
1190
+ this . _state . ButtonCaption [ AscPDF . APPEARANCE_TYPES . normal ] = specProps . asc_getNormalCaption ( ) ;
1191
+ this . _state . ButtonCaption [ AscPDF . APPEARANCE_TYPES . mouseDown ] = specProps . asc_getDownCaption ( ) ;
1192
+ this . _state . ButtonCaption [ AscPDF . APPEARANCE_TYPES . rollover ] = specProps . asc_getHoverCaption ( ) ;
1193
+ } else {
1194
+ this . _state . State = AscPDF . APPEARANCE_TYPES . normal ;
1195
+ this . cmbState . setValue ( this . _state . State ) ;
1196
+ this . _state . ButtonCaption = { } ;
1197
+ this . _state . ButtonCaption [ this . _state . State ] = specProps . asc_getNormalCaption ( ) ;
1198
+ }
1199
+
1200
+ if ( layout !== AscPDF . Api . Types . position . iconOnly ) {
1201
+ if ( this . _state . ButtonLabel !== this . _state . ButtonCaption [ this . _state . State ] ) {
1202
+ this . _state . ButtonLabel = this . _state . ButtonCaption [ this . _state . State ] ;
1203
+ this . txtLabel . setValue ( this . _state . ButtonLabel || '' ) ;
1204
+ }
1094
1205
}
1095
1206
1096
- if ( val !== AscPDF . Api . Types . position . textOnly ) {
1207
+ if ( layout !== AscPDF . Api . Types . position . textOnly ) {
1097
1208
val = specProps . asc_getScaleWhen ( ) ;
1098
1209
if ( this . _state . Scale !== val ) {
1099
1210
this . cmbScale . setValue ( val , '' ) ;
@@ -1276,6 +1387,8 @@ define([
1276
1387
this . chMaxChars . setDisabled ( isComb || this . _state . DisabledControls ) ;
1277
1388
this . spnMaxChars . setDisabled ( isComb || this . chMaxChars . getValue ( ) !== 'checked' || this . _state . DisabledControls ) ;
1278
1389
this . cmbHowScale . setDisabled ( this . _state . Scale === AscPDF . Api . Types . scaleWhen . never || this . _state . DisabledControls ) ;
1390
+ this . cmbState . setDisabled ( this . _state . Behavior !== AscPDF . BUTTON_HIGHLIGHT_TYPES . push || this . _state . DisabledControls ) ;
1391
+
1279
1392
} ,
1280
1393
1281
1394
showHideControls : function ( type , specProps ) {
@@ -1285,7 +1398,8 @@ define([
1285
1398
isCheck = type === AscPDF . FIELD_TYPES . checkbox ,
1286
1399
isRadio = type === AscPDF . FIELD_TYPES . radiobutton ,
1287
1400
isButton = type === AscPDF . FIELD_TYPES . button ,
1288
- isImage = isButton && ( specProps . asc_getLayout ( ) !== AscPDF . Api . Types . position . textOnly ) ;
1401
+ isImage = isButton && ( specProps . asc_getLayout ( ) !== AscPDF . Api . Types . position . textOnly ) ,
1402
+ isButtonText = isButton && ( specProps . asc_getLayout ( ) !== AscPDF . Api . Types . position . iconOnly ) ;
1289
1403
this . PlaceholderSettings . toggleClass ( 'hidden' , ! ( isCombobox || isText ) ) ;
1290
1404
this . AutofitSettings . toggleClass ( 'hidden' , ! ( isCombobox || isText ) ) ;
1291
1405
this . ListSettings . toggleClass ( 'hidden' , ! ( isCombobox || isListbox ) ) ;
@@ -1296,6 +1410,7 @@ define([
1296
1410
this . RadioOnlySettings . toggleClass ( 'hidden' , ! isRadio ) ;
1297
1411
this . ButtonSettings . toggleClass ( 'hidden' , ! isButton ) ;
1298
1412
this . ImageOnlySettings . toggleClass ( 'hidden' , ! isImage ) ;
1413
+ this . ButtonTextOnlySettings . toggleClass ( 'hidden' , ! isButtonText ) ;
1299
1414
}
1300
1415
1301
1416
} , PDFE . Views . FormSettings || { } ) ) ;
0 commit comments