You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

158 lines
5.6 KiB

// `
function findProjects() {
console.log("Find");
const url = '/projects/test_page';
let keywords = $('input[name=keywords]').val();
let obj = {keywords};
console.log("obj --> string", JSON.stringify(obj));
window.location.href = `${url}?keywords=про`;
// $.ajax({
// url: "/projects/test_page",
// data: {'foo': 'bar'},
// async: false
// });
}
$(function () {
function createFilterSpecs(_data) {
// SPECIALIZATIONS FILTER
let data = _data.results;
let sb_main = new SelectBox($('#select-box-1'), data, true);
sb_main.setHeader("Специализации");
let select_container = new SelectedContainer($('#selected-spec'), data);
sb_main.connectSelectedContainer(select_container);
let sb_1 = new SelectBox($('#select-box-2'), data, null, true);
let sb_2 = new SelectBox($('#select-box-3'), data, null, true);
let sb_3 = new SelectBox($('#select-box-4'), data, null, true);
let sb_4 = new SelectBox($('#select-box-5'), data, null, true);
sb_1.connectSelectedContainer(select_container);
sb_2.connectSelectedContainer(select_container);
sb_3.connectSelectedContainer(select_container);
sb_4.connectSelectedContainer(select_container);
sb_main.setNearbySelectBox(sb_1);
sb_1.setNearbySelectBox(sb_2, sb_main);
sb_2.setNearbySelectBox(sb_3, sb_1);
sb_3.setNearbySelectBox(sb_4, sb_2);
sb_4.setNearbySelectBox("", sb_3);
}
function createFilterBuildingClass(_data) {
// BUILDING-CLASSIFICATION FILTER
let data = _data.results;
let sb_build_main = new SelectBox($('#sb-building-classification'), data, false);
sb_build_main.setHeader("Классификация здания");
let sb_build_1 = new SelectBox($('#sb-building-sub-classification'), data, null, true);
let select_build_container = new SelectedContainer($('#selected-building-classification'), data, true);
sb_build_main.connectSelectedContainer(select_build_container);
sb_build_1.connectSelectedContainer(select_build_container);
sb_build_main.setNearbySelectBox(sb_build_1);
sb_build_1.setNearbySelectBox("", sb_build_main);
}
function createFilterConstructionType(_data) {
let data = _data.results;
let sb_constr_main = new SimpleSelect($('#sb-construction-type'), data);
sb_constr_main.setHeader("Вид строительства");
let select_constr_type = new SimpleSelectedContainer($('#selected-construction-type'), data);
sb_constr_main.connectSelectedContainer(select_constr_type);
}
function createFilerLocations(data) {
let sb_loc_main = new SelectBox($('#sb-location-1'), data);
sb_loc_main.setHeader("Местоположение");
let select_loc = new SelectedContainer($('#selected-location'), data, true);
sb_loc_main.connectSelectedContainer(select_loc);
let sb_loc_1 = new SelectBox($('#sb-location-2'), data, null, true);
let sb_loc_2 = new SelectBox($('#sb-location-3'), data, null, true);
sb_loc_1.connectSelectedContainer(select_loc);
sb_loc_2.connectSelectedContainer(select_loc);
sb_loc_main.setNearbySelectBox(sb_loc_1);
sb_loc_1.setNearbySelectBox(sb_loc_2, sb_loc_main);
sb_loc_2.setNearbySelectBox("", sb_loc_1);
//TODO: Временно прелоадер на самом тяжелом объекте
hidePreloader()
}
$.ajax({
url: '/api/specializations_flat',
dataType: 'json',
data: {},
success: createFilterSpecs
});
$.ajax({
url: '/api/building_classifications',
dataType: 'json',
data: {},
success: createFilterBuildingClass
});
$.ajax({
url: '/api/construction_type',
dataType: 'json',
data: {},
success: createFilterConstructionType
});
let data = [];
function fullData(_data) {
data = data.concat(_data.results.length ? _data.results : []);
let url = _data.next;
if (url) {
$.ajax({
url: url,
dataType: 'json',
data: {},
success: fullData
});
} else {
createFilerLocations(data);
}
return data;
}
fullData({next: '/api/locations_flat', results: []});
function tuneCheckBoxes($boxes) {
$boxes.each(function () {
if ($(this).find("input").prop("checked")) $(this).toggleClass('checked')
});
$boxes.on("click", function (e) {
$(e.target).toggleClass('checked');
$(e.target).attr('data-state', $(e.target).attr('data-state') == 'enabled' ? 'disabled' : 'enabled')
let inside_checkBox = $(e.target).find("input");
inside_checkBox.prop("checked", !inside_checkBox.prop("checked"));
});
}
tuneCheckBoxes($('.custom-check'));
// $(window).on('load',
function hidePreloader() {
var $preloader = $('#page-preloader'),
$spinner = $preloader.find('.spinner');
$spinner.fadeOut();
$preloader.delay(350).fadeOut('slow');
}
// $("#myBtn").click(function () {
// $('<div class="alert alert-success alert-dismissable">' +
// '<button type="button" class="close" ' +
// 'data-dismiss="alert" aria-hidden="true">' +
// '&times;' +
// '</button>' +
// 'modal info...' +
// '</div>').appendTo("#alerts");
// });
});