|
|
|
|
@ -3,6 +3,10 @@ |
|
|
|
|
// Выбор тем
|
|
|
|
|
(function () { |
|
|
|
|
var $themes_modal = $('.popup-window.themes'), |
|
|
|
|
$themes_select = $('#id_th'), |
|
|
|
|
$tags_select = $('#id_tg'), |
|
|
|
|
$selected_themes = $('#selected_themes'), |
|
|
|
|
$selected_tags = $('#selected_tags'), |
|
|
|
|
user_choice = { |
|
|
|
|
th: {}, |
|
|
|
|
tg: {} |
|
|
|
|
@ -12,6 +16,7 @@ |
|
|
|
|
return '<li>' + |
|
|
|
|
'<label>' + |
|
|
|
|
'<input type="checkbox" class="hidden_checkbox" name="' + data.name + '" value="' + data.id + '" />' + |
|
|
|
|
|
|
|
|
|
'<span class="custom_checkbox"></span>' + |
|
|
|
|
'<span class="label">' + data.text + '</span>' + |
|
|
|
|
'</label>' + |
|
|
|
|
@ -29,6 +34,14 @@ |
|
|
|
|
$sub_list |
|
|
|
|
.addClass('has_items') |
|
|
|
|
.append($sub_item); |
|
|
|
|
|
|
|
|
|
// $tags_select.find('option').each(function () {
|
|
|
|
|
// $themes_modal.find('.sub.has_items input[name="tg"][value="' + $(this).val() + '"]').prop('checked', true);
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
for (var id in user_choice['tg']){ |
|
|
|
|
$themes_modal.find('.sub.has_items input[name="tg"][value="' + id + '"]').prop('checked', true); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$loader.hide(); |
|
|
|
|
@ -44,6 +57,25 @@ |
|
|
|
|
'</li>' |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// Записываем данные в user_chice при инициализации
|
|
|
|
|
$themes_select.find('option').each(function () { |
|
|
|
|
$themes_modal.find('input[name="th"][value="' + $(this).val() + '"]').prop('checked', true); |
|
|
|
|
|
|
|
|
|
user_choice['th'][$(this).val()] = $(this).text(); |
|
|
|
|
|
|
|
|
|
var $theme = $(renderSelectedThemes($(this).val(), 'th', $(this).text())); |
|
|
|
|
$selected_themes.append($theme); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Записываем данные в user_chice при инициализации
|
|
|
|
|
$tags_select.find('option').each(function () { |
|
|
|
|
user_choice['tg'][$(this).val()] = $(this).text(); |
|
|
|
|
var $tag = $(renderSelectedThemes($(this).val(), 'tg', $(this).text())); |
|
|
|
|
$selected_tags.append($tag); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// открываем список тегов в теме
|
|
|
|
|
$themes_modal.on('click', '.trigger', function (e) { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
@ -78,10 +110,8 @@ |
|
|
|
|
$themes_modal.on('click', '.modal-approve', function (e) { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
|
|
var $selected_themes = $('#selected_themes'), |
|
|
|
|
$selected_tags = $('#selected_tags'); |
|
|
|
|
|
|
|
|
|
$selected_themes.html(''); |
|
|
|
|
$selected_tags.html(''); |
|
|
|
|
|
|
|
|
|
for (var theme_id in user_choice['th']) { |
|
|
|
|
var $theme = $(renderSelectedThemes(theme_id, 'th', user_choice['th'][theme_id])); |
|
|
|
|
@ -96,19 +126,47 @@ |
|
|
|
|
$.fancybox.close(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if (checked_th.length){ |
|
|
|
|
$.each(checked_th, function (i,val) { |
|
|
|
|
console.log(val); |
|
|
|
|
$('input[name="th"][value=' + val + ']').prop('checked', true); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
var removeCheckbox = function (type, id) { |
|
|
|
|
delete user_choice[type][id]; |
|
|
|
|
$('.modal_checkboxes').find('input[name="' + type + '"][value="' + id + '"]').prop('checked', false); |
|
|
|
|
console.log('#id_' + type); |
|
|
|
|
console.log('option[value="' + id + '"]'); |
|
|
|
|
$('#id_' + type).find('option[value="' + id + '"]').remove(); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Удаление выбранной темы
|
|
|
|
|
$selected_themes.on('click', 'a', function (event) { |
|
|
|
|
event.preventDefault(); |
|
|
|
|
|
|
|
|
|
var $input = $(this).siblings('input'); |
|
|
|
|
|
|
|
|
|
removeCheckbox($input.attr('name'), $input.val()); |
|
|
|
|
|
|
|
|
|
$(this).parent('li').remove(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Удаление выбранного тега
|
|
|
|
|
$selected_tags.find('a').on('click', function (event) { |
|
|
|
|
event.preventDefault(); |
|
|
|
|
|
|
|
|
|
var $input = $(this).siblings('input'); |
|
|
|
|
|
|
|
|
|
removeCheckbox($input.attr('name'), $input.val()); |
|
|
|
|
|
|
|
|
|
$(this).parent('li').remove(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Выбор городов
|
|
|
|
|
(function () { |
|
|
|
|
var $cities_modal = $('.popup-window.r_cities'), |
|
|
|
|
$selected_cities = $('#selected_cities'), |
|
|
|
|
$cities_select = $('#id_r_cities'), |
|
|
|
|
selected_cities = {}, |
|
|
|
|
|
|
|
|
|
renderSelectedCities = function (id, text) { |
|
|
|
|
@ -119,6 +177,16 @@ |
|
|
|
|
'</li>' |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// Записываем данные в user_chice при инициализации
|
|
|
|
|
$cities_select.find('option').each(function () { |
|
|
|
|
$cities_modal.find('input[name="r_cities"][value="' + $(this).val() + '"]').prop('checked', true); |
|
|
|
|
|
|
|
|
|
selected_cities[$(this).val()] = $(this).text(); |
|
|
|
|
|
|
|
|
|
var $city = $(renderSelectedCities($(this).val(), $(this).text())); |
|
|
|
|
$selected_cities.append($city); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$cities_modal.on('change', 'input[type="checkbox"]', function (e) { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
var $checkbox = $(this); |
|
|
|
|
@ -135,7 +203,6 @@ |
|
|
|
|
$cities_modal.on('click', '.modal-approve', function (e) { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
|
|
var $selected_cities = $('#selected_cities'); |
|
|
|
|
$selected_cities.html(''); |
|
|
|
|
|
|
|
|
|
for (var city_id in selected_cities) { |
|
|
|
|
@ -144,12 +211,30 @@ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$.fancybox.close(); |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Удаление выбранного тега
|
|
|
|
|
$selected_cities.on('click', 'a', function (event) { |
|
|
|
|
event.preventDefault(); |
|
|
|
|
|
|
|
|
|
var $input = $(this).siblings('input'); |
|
|
|
|
|
|
|
|
|
delete selected_cities[$input.val()]; |
|
|
|
|
$('.modal_checkboxes').find('input[name="' + $input.attr('name') + '"][value="' + $input.val() + '"]').prop('checked', false); |
|
|
|
|
$('#id_' + $input.attr('name')).find('option[value="' + $input.val() + '"]').remove(); |
|
|
|
|
|
|
|
|
|
$(this).parent('li').remove(); |
|
|
|
|
}); |
|
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
// Выбор стран
|
|
|
|
|
(function () { |
|
|
|
|
var $countries_modal = $('.popup-window.countries'), |
|
|
|
|
$areas_select = $('#id_area'), |
|
|
|
|
$co_select = $('#id_f_countries'), |
|
|
|
|
$selected_areas = $('#selected_areas'), |
|
|
|
|
$selected_co = $('#selected_countries'), |
|
|
|
|
user_countries = { |
|
|
|
|
area: {}, |
|
|
|
|
co: {} |
|
|
|
|
@ -176,6 +261,10 @@ |
|
|
|
|
$sub_list |
|
|
|
|
.addClass('has_items') |
|
|
|
|
.append($sub_item); |
|
|
|
|
|
|
|
|
|
for (var id in user_countries['co']){ |
|
|
|
|
$countries_modal.find('.sub.has_items input[name="co"][value="' + id + '"]').prop('checked', true); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$loader.hide(); |
|
|
|
|
@ -189,8 +278,33 @@ |
|
|
|
|
text + |
|
|
|
|
'<a href="#">×</a>' + |
|
|
|
|
'</li>' |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
removeCheckbox = function (type, id) { |
|
|
|
|
delete user_countries[type][id]; |
|
|
|
|
$('.modal_checkboxes').find('input[name="' + type + '"][value="' + id + '"]').prop('checked', false); |
|
|
|
|
$('#id_' + type).find('option[value="' + id + '"]').removeAttr('selected'); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// Записываем данные в user_countries при инициализации
|
|
|
|
|
$areas_select.find('option[selected]').each(function () { |
|
|
|
|
$countries_modal.find('input[name="area"][value="' + $(this).val() + '"]').prop('checked', true); |
|
|
|
|
|
|
|
|
|
user_countries['area'][$(this).val()] = $(this).text(); |
|
|
|
|
|
|
|
|
|
var $area = $(renderSelectedThemes($(this).val(), 'area', $(this).text())); |
|
|
|
|
$selected_areas.append($area); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$co_select.find('option[selected]').each(function () { |
|
|
|
|
user_countries['co'][$(this).val()] = $(this).text(); |
|
|
|
|
|
|
|
|
|
var $co = $(renderSelectedThemes($(this).val(), 'co', $(this).text())); |
|
|
|
|
$selected_co.append($co); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
console.log(user_countries); |
|
|
|
|
|
|
|
|
|
// открываем список тегов в теме
|
|
|
|
|
$countries_modal.on('click', '.trigger', function (e) { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
@ -204,6 +318,11 @@ |
|
|
|
|
$sub_list.slideToggle(100); |
|
|
|
|
} else { |
|
|
|
|
renderSublist($link.attr('href'), $sub_list); |
|
|
|
|
|
|
|
|
|
for( var city_id in user_countries['co'] ){ |
|
|
|
|
console.log(city_id); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
@ -225,22 +344,45 @@ |
|
|
|
|
$countries_modal.on('click', '.modal-approve', function (e) { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
|
|
var $selected_countries = $('#selected_countries'); |
|
|
|
|
$selected_co.html(''); |
|
|
|
|
$selected_areas.html(''); |
|
|
|
|
|
|
|
|
|
$selected_countries.html(''); |
|
|
|
|
|
|
|
|
|
for (var area_id in user_countries['area']) { |
|
|
|
|
var $theme = $(renderSelectedThemes(area_id, 'area', user_countries['area'][area_id])); |
|
|
|
|
$selected_countries.append($theme); |
|
|
|
|
var $area = $(renderSelectedThemes(area_id, 'area', user_countries['area'][area_id])); |
|
|
|
|
$selected_areas.append($area); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (var co_id in user_countries['co']) { |
|
|
|
|
var $tag = $(renderSelectedThemes(co_id, 'co', user_countries['co'][co_id])); |
|
|
|
|
$selected_countries.append($tag); |
|
|
|
|
var $co = $(renderSelectedThemes(co_id, 'co', user_countries['co'][co_id])); |
|
|
|
|
$selected_co.append($co); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$.fancybox.close(); |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Удаление выбранного континента
|
|
|
|
|
$selected_areas.on('click', 'a', function (event) { |
|
|
|
|
event.preventDefault(); |
|
|
|
|
|
|
|
|
|
var $input = $(this).siblings('input'); |
|
|
|
|
|
|
|
|
|
removeCheckbox($input.attr('name'), $input.val()); |
|
|
|
|
|
|
|
|
|
$(this).parent('li').remove(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Удаление выбранной страны
|
|
|
|
|
$selected_co.find('a').on('click', function (event) { |
|
|
|
|
event.preventDefault(); |
|
|
|
|
|
|
|
|
|
var $input = $(this).siblings('input'); |
|
|
|
|
|
|
|
|
|
removeCheckbox($input.attr('name'), $input.val()); |
|
|
|
|
|
|
|
|
|
$(this).parent('li').remove(); |
|
|
|
|
}); |
|
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
$(function () { |
|
|
|
|
@ -255,5 +397,4 @@ $(function () { |
|
|
|
|
|
|
|
|
|
$('.scroll-container').mCustomScrollbar(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|