90 lines
2.9 KiB
Plaintext
90 lines
2.9 KiB
Plaintext
<br><br>
|
|
<form method="POST" id="form-real-estate-type">
|
|
<div class="center-align">
|
|
|
|
<div class="row">
|
|
<select class="segment-select" id="adType" name="adType">
|
|
<option value="<%= AD_TYPE.AD_TYPE_SALE.id %>"
|
|
<% if (selectedAdType === AD_TYPE.AD_TYPE_SALE.id) { %>
|
|
selected="selected"
|
|
<% } %>
|
|
><%= AD_TYPE.AD_TYPE_SALE.title %></option>
|
|
<option value="<%= AD_TYPE.AD_TYPE_RENT.id %>"
|
|
<% if (selectedAdType === AD_TYPE.AD_TYPE_RENT.id) { %>
|
|
selected="selected"
|
|
<% } %>
|
|
><%= AD_TYPE.AD_TYPE_RENT.title %></option>
|
|
</select>
|
|
</div>
|
|
|
|
<br>
|
|
<div id="realEstateTypeSelection" class="collection">
|
|
<% for(const realEstateType of realEstateTypes) { %>
|
|
|
|
<a class="waves-effect row collection-item"
|
|
id="<%= realEstateType.id %>"
|
|
href="#"
|
|
style="color: #02adba"
|
|
onclick="saveAndSubmit(this.id)"
|
|
>
|
|
<span class="center-align"><%= realEstateType.title %></span>
|
|
</a>
|
|
|
|
<% } %>
|
|
</div>
|
|
<input type="hidden" name="realEstateType" id="realEstateType" />
|
|
</div>
|
|
</form>
|
|
|
|
<script>
|
|
(function($) {
|
|
$.fn.extend({
|
|
Segment: function() {
|
|
$(this).each(function() {
|
|
const self = $(this);
|
|
const onchange = self.attr('onchange');
|
|
const wrapper = $("<div>", { class: "ui-segment" });
|
|
$(this)
|
|
.find("option")
|
|
.each(function() {
|
|
const option = $("<span>", {
|
|
class: "option",
|
|
onclick: onchange,
|
|
text: $(this).text(),
|
|
value: $(this).val(),
|
|
});
|
|
if ($(this).is(":selected")) {
|
|
option.addClass("active");
|
|
}
|
|
wrapper.append(option);
|
|
});
|
|
|
|
wrapper.find("span.option").click(function (){
|
|
wrapper.find("span.option").removeClass("active");
|
|
$(this).addClass("active");
|
|
self.val($(this).attr('value'));
|
|
});
|
|
|
|
$(this).after(wrapper);
|
|
$(this).hide();
|
|
});
|
|
}
|
|
});
|
|
})(jQuery);
|
|
|
|
$(document).ready(() => {
|
|
$(".segment-select").Segment();
|
|
});
|
|
|
|
function saveAndSubmit(id) {
|
|
$("#realEstateType").val(id);
|
|
$("#realEstateTypeSelection > a").attr("onclick", "");
|
|
$("#form-real-estate-type").submit();
|
|
}
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|