|
|
|
|
@ -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,10 @@ |
|
|
|
|
$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); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$loader.hide(); |
|
|
|
|
@ -44,6 +53,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 +106,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])); |
|
|
|
|
@ -95,20 +121,14 @@ |
|
|
|
|
|
|
|
|
|
$.fancybox.close(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if (checked_th.length){ |
|
|
|
|
$.each(checked_th, function (i,val) { |
|
|
|
|
console.log(val); |
|
|
|
|
$('input[name="th"][value=' + val + ']').prop('checked', true); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Выбор городов
|
|
|
|
|
(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 +139,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 +165,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) { |
|
|
|
|
|