From 71a9c2227eeba7baf822132f918c40adb15d9ac6 Mon Sep 17 00:00:00 2001 From: Hoang Huu Date: Tue, 24 Mar 2020 10:22:00 +0700 Subject: [PATCH] Add search price input layout --- assets/opalestate.css | 23 ++++++++++++ assets/scss/opalestate/_form.scss | 20 +++++++++++ inc/admin/settings/property.php | 11 ++++++ inc/ajax-functions.php | 40 ++------------------- templates/search-box/fields/price-input.php | 16 +++++++++ templates/search-box/fields/price.php | 7 ++-- 6 files changed, 77 insertions(+), 40 deletions(-) create mode 100644 templates/search-box/fields/price-input.php diff --git a/assets/opalestate.css b/assets/opalestate.css index a4040036..c0ffe8ab 100755 --- a/assets/opalestate.css +++ b/assets/opalestate.css @@ -4009,3 +4009,26 @@ header#masthead { border: solid 1px #ebebeb; position: relative; } + +.opalestate-price-input-wrap { + display: flex; + align-items: center; +} + +.opalestate-price-input { + width: 45%; + display: inline-block; + position: relative; +} + +.opalestate-price-input-separator { + flex-grow: 1; + text-align: center; +} + +.opalestate-price-currency { + position: absolute; + right: 10px; + top: 50%; + transform: translateY(-50%); +} diff --git a/assets/scss/opalestate/_form.scss b/assets/scss/opalestate/_form.scss index b0bc5412..9a4eaaa2 100755 --- a/assets/scss/opalestate/_form.scss +++ b/assets/scss/opalestate/_form.scss @@ -566,5 +566,25 @@ button.opal-collapse-button{ } } +.opalestate-price-input-wrap { + display: flex; + align-items: center; +} +.opalestate-price-input { + width: 45%; + display: inline-block; + position: relative; +} +.opalestate-price-input-separator { + flex-grow: 1; + text-align: center; +} + +.opalestate-price-currency { + position: absolute; + right: 10px; + top: 50%; + transform: translateY(-50%); +} diff --git a/inc/admin/settings/property.php b/inc/admin/settings/property.php index 582044d1..c5044fee 100755 --- a/inc/admin/settings/property.php +++ b/inc/admin/settings/property.php @@ -256,6 +256,17 @@ class Opalestate_Settings_Property_Tab extends Opalestate_Settings_Base_Tab { ], ]; + $fields[] = [ + 'name' => esc_html__( 'Price input type', 'opalestate-pro' ), + 'options' => [ + 'slider' => esc_html__( 'Range slider', 'opalestate-pro' ), + 'input' => esc_html__( 'Input', 'opalestate-pro' ), + ], + 'id' => 'price_input_type', + 'type' => 'select', + 'default' => 'slider', + ]; + foreach ( $metas as $key => $meta ) { $fields[] = [ 'name' => $meta['name'], diff --git a/inc/ajax-functions.php b/inc/ajax-functions.php index 2a7f0e1b..b4a151d6 100755 --- a/inc/ajax-functions.php +++ b/inc/ajax-functions.php @@ -223,42 +223,6 @@ function opalestate_toggle_featured_property() { } - -/** - * load more properties by agency - */ -// add_action( 'wp_ajax_get_agency_property', 'opalestate_load_more_agency_property' ); -// add_action( 'wp_ajax_nopriv_get_agency_property', 'opalestate_load_more_agency_property' ); -// -// function opalestate_load_more_agency_property() { -// -// -// $post = [ -// 'post_id' => 0, -// 'paged' => 1, -// 'user_id' => 13, -// 'related' => '', -// 'limit' => apply_filters( 'opalesate_agency_properties_limit', 5 ), -// ]; -// -// $post = array_merge( $post, $_POST ); -// extract( $post ); -// -// $user_id = get_post_meta( absint( $post_id ), OPALESTATE_AGENCY_PREFIX . 'user_id', true ); -// $query = Opalestate_Query::get_agency_property( absint( $post_id ), absint( $user_id ), absint( $limit ), absint( $paged ) ); -// -// if ( $query->have_posts() ) : -// while ( $query->have_posts() ) : $query->the_post(); ?> - - - - 1, - 'id' => 13, + 'id' => '', 'limit' => apply_filters( 'opalesate_agent_properties_limit', 6 ), ]; @@ -312,7 +276,7 @@ function opalestate_get_agency_property() { $post = [ 'id' => 0, 'paged' => 1, - 'user_id' => 13, + 'user_id' => '', 'related' => '', 'limit' => apply_filters( 'opalesate_agency_properties_limit', 5 ), ]; diff --git a/templates/search-box/fields/price-input.php b/templates/search-box/fields/price-input.php new file mode 100644 index 00000000..9e5d80b4 --- /dev/null +++ b/templates/search-box/fields/price-input.php @@ -0,0 +1,16 @@ + +
+
+ + +
+ +
+ +
+ +
+ + +
+
diff --git a/templates/search-box/fields/price.php b/templates/search-box/fields/price.php index 14e58c33..136bf9a1 100755 --- a/templates/search-box/fields/price.php +++ b/templates/search-box/fields/price.php @@ -21,5 +21,8 @@ if ( opalestate_options( 'currency_position', 'before' ) == 'before' ) { $data['unit_position'] = 'prefix'; } -?> - +if ( 'input' === opalestate_get_option( 'price_input_type', 'slider' ) ) { + echo opalestate_load_template_path( 'search-box/fields/price-input', [ 'data' => $data ] ); +} else { + opalesate_property_slide_ranger_template( esc_html__( 'Price', 'opalestate-pro' ), $data ); +}