$(document).on('click', function (e) {
if ($(e.target).closest("#inputFilterList").length === 0) {
$("#inputFilterList").hide();
}
if ($(e.target).closest("#inputFilterList2").length === 0) {
$("#inputFilterList2").hide();
}
});
$('#filter_keyword2').keyup(function () {
var keyword = $(this).val();
$.ajax({
url: '{{ route('search_language') }}',
data: 'keyword=' + keyword + '&_token={!! csrf_token() !!}',
type: 'POST',
success: function(response) {
$("#inputFilterList2").show();
$('#inputFilterList2').html(response).addClass('show');
}
});
});
$('#filter_keyword').keyup(function () {
var keyword = $(this).val();
$.ajax({
url: '{{ route('search_language') }}',
data: 'keyword=' + keyword + '&_token={!! csrf_token() !!}',
type: 'POST',
success: function(response) {
$("#inputFilterList").show();
$('#inputFilterList').html(response).addClass('show');
}
});
});
$('input[name="school_id[]"]').click(function () {
var school_id = $(this).val();
var checked = ($(this).prop('checked')) ? 1 : 0;
var obj = $(this);
$.ajax({
url: '{{ route('compare_change') }}',
data: 'school_id=' + school_id + '&checked=' + checked + '&_token={!! csrf_token() !!}',
type: 'POST',
success: function(length) {
if (length > 3) {
obj.prop('checked', false);
$('#modal-limit').modal('show');
return false;
}
}
});
});
$('.cancel').click(function () {
$('input[name="school_id[]"]:checked').prop('checked', false);
$.ajax({
url: '{{ route('compare_change') }}',
data: 'clear=1&_token={!! csrf_token() !!}',
type: 'POST',
success: function(length) {
}
});
});
$('.compare').click(function () {
$.ajax({
url: '{{ route('search_compare') }}',
data: '_token={!! csrf_token() !!}',
type: 'POST',
success: function(response) {
if (response == '0' || response == '1') {
$('#modal-limit2').modal('show');
} else {
$('.compare_body').html(response);
$('#modal-compare3').modal();
}
}
});
});
{{--
$('input[name="city[]"]').click(function () {
var length = $(this).parent().parent().parent().parent().find('input[name="city[]"]:checked').length;
console.log(length)
if (length > 4) {
return false;
}
});
--}}
$('.course_clear').click(function () {
$('input[name="course[]"]').prop('checked', false);
$('.course_select').click();
});
$('.course_select').click(function () {
var course_list = [];
$.each($(this).parent().parent().find('input[name="course[]"]:checked'), function (k, v) {
var course = $(this).val();
if (course_list.indexOf(course) == -1) {
course_list.push(course);
}
});
@if (request()->segment(2) == 'language-school-search-list')
location.href = '{!! route('search_language-school-search-list') . $FrontendPresenter->getQuery('course') !!}course=' + course_list.join()
@else
location.href = '{!! route('search_language-school-search-map') . $FrontendPresenter->getQuery('course') !!}course=' + course_list.join()
@endif
});
$('.city_clear').click(function () {
$('input[name="city[]"]').prop('checked', false);
$('.city_select').click();
});
$('.city_select').click(function () {
var city_list = [];
$.each($(this).parent().parent().parent().find('input[name="city[]"]:checked'), function (k, v) {
var city = $(this).val();
if (city_list.indexOf(city) == -1) {
city_list.push(city);
}
});
@if (request()->segment(2) == 'language-school-search-list')
location.href = '{!! route('search_language-school-search-list') . $FrontendPresenter->getQuery('city') !!}city=' + city_list.join();
@else
location.href = '{!! route('search_language-school-search-map') . $FrontendPresenter->getQuery('city') !!}city=' + city_list.join();
@endif
});