Skip to content

Commit eba6ed1

Browse files
committed
Reorganize the preview
1 parent ba6822a commit eba6ed1

File tree

6 files changed

+159
-127
lines changed

6 files changed

+159
-127
lines changed

css/cloudinary.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/asset-edit.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

php/ui/component/class-asset-preview-settings.php

Lines changed: 0 additions & 104 deletions
This file was deleted.

src/css/components/_edit_overlay.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,12 @@
7474
}
7575
}
7676
}
77+
78+
.cld-asset-edit-button {
79+
&.button-primary {
80+
margin-right: auto;
81+
padding: 7px 14px;
82+
}
83+
}
7784
}
7885

src/js/asset-edit.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)