@@ -10,8 +10,11 @@ const AssetEdit = {
1010 base : null ,
1111 publicId : null ,
1212 size : null ,
13- transformationsInput : document . getElementById ( 'cld-asset-edit-transformations' ) ,
14- textOverlayTransformations : '' ,
13+ transformationsInput : document . getElementById ( 'edit_asset.transformations' ) ,
14+ textOverlayTextInput : document . getElementById ( 'edit_asset.text_overlay_text' ) ,
15+ textOverlayPositionInput : document . getElementById ( 'edit_asset.text_overlay_position' ) ,
16+ textOverlayXOffsetInput : document . getElementById ( 'edit_asset.text_overlay_x_offset' ) ,
17+ textOverlayYOffsetInput : document . getElementById ( 'edit_asset.text_overlay_y_offset' ) ,
1518 saveButton : document . getElementById ( 'cld-asset-edit-save' ) ,
1619 currentURL : null ,
1720 init ( ) {
@@ -33,7 +36,10 @@ const AssetEdit = {
3336 this . wrap . appendChild ( this . preview . createPreview ( 500 , 400 ) ) ;
3437 this . preview . setSrc ( this . base + this . transformationsInput . value + this . publicId , true ) ;
3538 this . transformationsInput . addEventListener ( 'input' , ( ev ) => {
36- this . preview . setSrc ( this . base + this . transformationsInput . value + this . publicId ) ;
39+ this . preview . setSrc ( this . getSrc ( ) ) ;
40+ } ) ;
41+ this . textOverlayTextInput . addEventListener ( 'input' , ( ev ) => {
42+ this . preview . setSrc ( this . getSrc ( ) ) ;
3743 } ) ;
3844 this . transformationsInput . addEventListener ( 'keydown' , ( ev ) => {
3945 if ( 'Enter' === ev . code ) {
@@ -86,6 +92,7 @@ const AssetEdit = {
8692 cell . addEventListener ( 'click' , ( ) => {
8793 grid . querySelectorAll ( '.edit-overlay-grid__cell--selected' ) . forEach ( c => c . classList . remove ( 'edit-overlay-grid__cell--selected' ) ) ;
8894 cell . classList . add ( 'edit-overlay-grid__cell--selected' ) ;
95+ this . textOverlayPositionInput . value = option ;
8996 } ) ;
9097
9198 grid . appendChild ( cell ) ;
@@ -127,6 +134,20 @@ const AssetEdit = {
127134
128135 frame . open ( ) ;
129136 } ) ;
137+ } ,
138+ getSrc ( ) {
139+ let textOverlay = 'l_text:Arial_80:' + this . textOverlayTextInput . value + '/fl_layer_apply' ;
140+ let position = this . textOverlayPositionInput . value ;
141+ let xOffset = this . textOverlayXOffsetInput . value ? ',x_' + this . textOverlayXOffsetInput . value : '' ;
142+ let yOffset = this . textOverlayYOffsetInput . value ? ',y_' + this . textOverlayYOffsetInput . value : '' ;
143+
144+ if ( this . textOverlayTextInput . value ) {
145+ textOverlay += ',g_' + position + xOffset + yOffset ;
146+ } else {
147+ textOverlay = '' ;
148+ }
149+ let src = this . base + this . transformationsInput . value + textOverlay + this . publicId ;
150+ return src ;
130151 }
131152} ;
132153
0 commit comments