Skip to content

Commit

Permalink
Fix - Image choice design issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dipuchaudhary committed Feb 7, 2024
1 parent 833b960 commit 089ba43
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
23 changes: 23 additions & 0 deletions assets/js/admin/form-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,7 @@
this.single_row();
this.manage_required_fields();
this.manage_label_hidden_fields();
this.manage_image_choice_class();
},
single_row: function () {
if (
Expand Down Expand Up @@ -1796,6 +1797,28 @@
}
);
},
/**
* toggleclass if image choice option is enabled.
*/
manage_image_choice_class: function () {
$('input[data-field="image_choice"]').each(
function () {
if ($(this).is(":checked")) {
$(this)
.closest(".ur-selected-item")
.find(".ur-admin-template")
.find(".ur-field")
.addClass("user-registration-image-options");
} else {
$(this)
.closest(".ur-selected-item")
.find(".ur-admin-template")
.find(".ur-field")
.removeClass("user-registration-image-options");
}
}
);
},
/**
* Information about required fields
*/
Expand Down
9 changes: 6 additions & 3 deletions includes/abstracts/abstract-ur-form-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ function ( $option ) {
$label = is_array( $option ) ? $option['label'] : $option->label;
$image = is_array( $option ) ? $option['image'] : $option->image;
$style = ( empty( $image ) ) ? 'style="display: none;"' : '';
$media_style = ( ! empty( $image ) ) ? 'style="display: none;"' : '';
$general_setting_wrapper .= '<li>';
$general_setting_wrapper .= '<div class="ur-options-value-wrapper"><div class="editor-block-mover__control-drag-handle editor-block-mover__control">
<svg width="18" height="18" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" role="img" aria-hidden="true" focusable="false"><path d="M13,8c0.6,0,1-0.4,1-1s-0.4-1-1-1s-1,0.4-1,1S12.4,8,13,8z M5,6C4.4,6,4,6.4,4,7s0.4,1,1,1s1-0.4,1-1S5.6,6,5,6z M5,10 c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S5.6,10,5,10z M13,10c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S13.6,10,13,10z M9,6 C8.4,6,8,6.4,8,7s0.4,1,1,1s1-0.4,1-1S9.6,6,9,6z M9,10c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S9.6,10,9,10z"></path></svg>
Expand All @@ -652,7 +653,7 @@ function ( $option ) {
if ( 'radio' === $strip_prefix ) {
$general_setting_wrapper .= '<div class="ur-image-choice-wrapper">';
$general_setting_wrapper .= '<input type="hidden" class="ur-general-setting-field ur-type-image-choice" data-field="' . esc_attr( $setting_key ) . '" data-field-name="image-choice" name="' . esc_attr( $unique ) . '_image" value="' . esc_url( $image ) . '">';
$general_setting_wrapper .= '<button type="button" class="upload-button ur-media-btn">Upload Image</button>';
$general_setting_wrapper .= '<button type="button" class="upload-button ur-media-btn" ' . $media_style . '>Upload Image</button>';
$general_setting_wrapper .= '<div class="ur-thumbnail-image" style="max-width:100px;max-height:100px;overflow:hidden;"><img src="' . esc_url( $image ) . '" style="max-width:100%;"></div>';
$general_setting_wrapper .= '<div class="ur-actions"><button type="button" class="button ur-remove-btn" ' . $style . '>Remove</button></div></div>';
}
Expand Down Expand Up @@ -758,6 +759,7 @@ function ( $option ) {
$sell_value = ( is_array( $option ) && isset( $option['sell_value'] ) ) ? $option['sell_value'] : ( ( is_object( $option ) && isset( $option->sell_value ) ) ? $option->sell_value : null );
$image = ( is_array( $option ) && isset( $option['image'] ) ) ? $option['image'] : ( ( is_object( $option ) && isset( $option->image ) ) ? $option->image : null );
$style = ( empty( $image ) ) ? 'style="display: none;"' : '';
$media_style = ( ! empty( $image ) ) ? 'style="display: none;"' : '';
$currency = get_option( 'user_registration_payment_currency', 'USD' );
$currencies = ur_payment_integration_get_currencies();
$currency = $currency . ' ' . $currencies[ $currency ]['symbol'];
Expand All @@ -782,7 +784,7 @@ function ( $option ) {
$general_setting_wrapper .= '<a class="remove" href="#"><i class="dashicons dashicons-minus"></i></a></div>';
$general_setting_wrapper .= '<div class="ur-image-choice-wrapper">';
$general_setting_wrapper .= '<input type="hidden" class="ur-general-setting-field ur-type-image-choice" data-field="' . esc_attr( $setting_key ) . '" data-field-name="' . esc_attr( $strip_prefix ) . '" name="' . esc_attr( $unique ) . '_image" value="' . esc_url( $image ) . '">';
$general_setting_wrapper .= '<button type="button" class="upload-button ur-media-btn">Upload Image</button>';
$general_setting_wrapper .= '<button type="button" class="upload-button ur-media-btn" ' . $media_style . '>Upload Image</button>';
$general_setting_wrapper .= '<div class="ur-thumbnail-image" style="max-width:100px;max-height:100px;overflow:hidden;"><img src="' . esc_url( $image ) . '" style="max-width:100%;"></div>';
$general_setting_wrapper .= '<div class="ur-actions"><button type="button" class="button ur-remove-btn" ' . $style . '>Remove</button></div></div>';
$general_setting_wrapper .= '</li>';
Expand All @@ -792,6 +794,7 @@ function ( $option ) {
$label = is_array( $option ) ? $option['label'] : $option->label;
$image = is_array( $option ) ? $option['image'] : $option->image;
$style = ( empty( $image ) ) ? 'style="display: none;"' : '';
$media_style = ( ! empty( $image ) ) ? 'style="display: none;"' : '';
$general_setting_wrapper .= '<li>';
$general_setting_wrapper .= '<div class="ur-options-value-wrapper"><div class="editor-block-mover__control-drag-handle editor-block-mover__control">
<svg width="18" height="18" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" role="img" aria-hidden="true" focusable="false"><path d="M13,8c0.6,0,1-0.4,1-1s-0.4-1-1-1s-1,0.4-1,1S12.4,8,13,8z M5,6C4.4,6,4,6.4,4,7s0.4,1,1,1s1-0.4,1-1S5.6,6,5,6z M5,10 c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S5.6,10,5,10z M13,10c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S13.6,10,13,10z M9,6 C8.4,6,8,6.4,8,7s0.4,1,1,1s1-0.4,1-1S9.6,6,9,6z M9,10c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S9.6,10,9,10z"></path></svg>
Expand All @@ -814,7 +817,7 @@ function ( $option ) {
$general_setting_wrapper .= '<a class="remove" href="#"><i class="dashicons dashicons-minus"></i></a></div>';
$general_setting_wrapper .= '<div class="ur-image-choice-wrapper">';
$general_setting_wrapper .= '<input type="hidden" class="ur-general-setting-field ur-type-image-choice" data-field="' . esc_attr( $setting_key ) . '" data-field-name="image-choice" name="' . esc_attr( $unique ) . '_image" value="' . esc_url( $image ) . '">';
$general_setting_wrapper .= '<button type="button" class="upload-button ur-media-btn">Upload Image</button>';
$general_setting_wrapper .= '<button type="button" class="upload-button ur-media-btn" ' . $media_style . '>Upload Image</button>';
$general_setting_wrapper .= '<div class="ur-thumbnail-image" style="max-width:100px;max-height:100px;overflow:hidden;"><img src="' . esc_url( $image ) . '" style="max-width:100%;"></div>';
$general_setting_wrapper .= '<div class="ur-actions"><button type="button" class="button ur-remove-btn" ' . $style . '>Remove</button></div></div>';
$general_setting_wrapper .= '</li>';
Expand Down

0 comments on commit 089ba43

Please sign in to comment.