From ae7f8854b0de0f73b2dfd95fe307f3421c92b560 Mon Sep 17 00:00:00 2001 From: ya_dim4ik Date: Tue, 4 Oct 2016 15:56:41 +0300 Subject: [PATCH 1/3] mailing settings initialize user settings --- static/mailing_settings/css/main.css | 43 +++++++++++++++ static/mailing_settings/js/main.js | 53 ++++++++++++++----- .../client/accounts/mailing_settings.html | 36 ++++++++++--- 3 files changed, 113 insertions(+), 19 deletions(-) diff --git a/static/mailing_settings/css/main.css b/static/mailing_settings/css/main.css index 75a35655..7ee670b9 100644 --- a/static/mailing_settings/css/main.css +++ b/static/mailing_settings/css/main.css @@ -583,4 +583,47 @@ h3{ .modal_checkboxes .label{ padding-left: 14px; +} + +.buttons_block{ + padding-top: 25px; +} + +.buttons_block button{ + display: inline-block; + vertical-align: top; + height: 40px; + border: 1px solid #fff; + outline: 0; + color: #fff; + font-family: dindisplay_pro,Arial,sans-serif; + font-weight: 700; + font-size: 15px; + line-height: 41px; + text-transform: uppercase; + padding: 0 25px; + border-radius: 4px; + -moz-box-sizing: border-box; + box-sizing: border-box; + box-shadow: 0 1px 0 rgba(0,0,0,.2),inset 0 1px 0 rgba(0,0,0,.2); + -webkit-filter: none; + filter: none; +} + +.buttons_block .modal-approve{ + background: #f60; + background: -webkit-gradient(linear,left top,left bottom,color-stop(0,#ff8000),color-stop(100%,#f60)); + background: -webkit-linear-gradient(top,#ff8000 0,#f60 100%); + background: -o-linear-gradient(top,#ff8000 0,#f60 100%); + background: -webkit-linear-gradient(top,#ff8000 0,#f60 100%); + background: -o-linear-gradient(top,#ff8000 0,#f60 100%); + background: linear-gradient(to bottom,#ff8000 0,#f60 100%); +} + +.buttons_block button:hover{ + margin-top: -1px; +} + +.modals{ + display: none; } \ No newline at end of file diff --git a/static/mailing_settings/js/main.js b/static/mailing_settings/js/main.js index 1aff1cbc..2abd1401 100644 --- a/static/mailing_settings/js/main.js +++ b/static/mailing_settings/js/main.js @@ -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 '
  • ' + '' + @@ -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 @@ '
  • ' }; + // Записываем данные в 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 @@ '' }; + // Записываем данные в 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) { diff --git a/templates/client/accounts/mailing_settings.html b/templates/client/accounts/mailing_settings.html index 68be3828..0dff0094 100644 --- a/templates/client/accounts/mailing_settings.html +++ b/templates/client/accounts/mailing_settings.html @@ -35,12 +35,12 @@ {{ form.th.label_tag }} {{ form.th }} + {% trans 'Уточнить темы' %} -

    {% trans 'Теги' %}

    - {{ form.tg.label_tag }} + {#

    {% trans 'Теги' %}

    #} + {{ form.tg }} -
    @@ -185,10 +185,32 @@ From 77eb4bcaf3232ab32e83d49e6ac44e0f6e6a8ee7 Mon Sep 17 00:00:00 2001 From: ya_dim4ik Date: Wed, 5 Oct 2016 09:18:41 +0300 Subject: [PATCH 2/3] profile mailing settings --- static/mailing_settings/js/main.js | 28 ++++++++++++++++++- .../client/accounts/mailing_settings.html | 1 + .../popups/mailing_settings_countries.html | 2 +- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/static/mailing_settings/js/main.js b/static/mailing_settings/js/main.js index 2abd1401..553fd85f 100644 --- a/static/mailing_settings/js/main.js +++ b/static/mailing_settings/js/main.js @@ -179,6 +179,10 @@ // Выбор стран (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: {} @@ -220,6 +224,29 @@ '' }; + // Записываем данные в 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 () { + var $co = $(renderSelectedThemes($(this).val(), 'co', $(this).text())); + $selected_co.append($co); + }); + + + // Записываем данные в 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); + // }); + // открываем список тегов в теме $countries_modal.on('click', '.trigger', function (e) { e.preventDefault(); @@ -284,5 +311,4 @@ $(function () { $('.scroll-container').mCustomScrollbar(); - }); diff --git a/templates/client/accounts/mailing_settings.html b/templates/client/accounts/mailing_settings.html index f82c73f9..c78b7a8f 100644 --- a/templates/client/accounts/mailing_settings.html +++ b/templates/client/accounts/mailing_settings.html @@ -85,6 +85,7 @@ {% trans 'Выбрать страны' %} +
        diff --git a/templates/client/popups/mailing_settings_countries.html b/templates/client/popups/mailing_settings_countries.html index 07f0ed6b..e3b9a470 100644 --- a/templates/client/popups/mailing_settings_countries.html +++ b/templates/client/popups/mailing_settings_countries.html @@ -35,7 +35,7 @@
        -
        +
        From 23abaaec7615d5c58c28b644e0b9ff66e0ca4db1 Mon Sep 17 00:00:00 2001 From: ya_dim4ik Date: Thu, 6 Oct 2016 12:21:09 +0300 Subject: [PATCH 3/3] mailing settings counties select --- static/mailing_settings/css/main.css | 8 ++ static/mailing_settings/js/main.js | 122 +++++++++++++++--- .../client/accounts/mailing_settings.html | 6 - .../popups/mailing_settings_countries.html | 2 +- 4 files changed, 113 insertions(+), 25 deletions(-) diff --git a/static/mailing_settings/css/main.css b/static/mailing_settings/css/main.css index 7ee670b9..6d0f2ddb 100644 --- a/static/mailing_settings/css/main.css +++ b/static/mailing_settings/css/main.css @@ -119,6 +119,14 @@ h3{ padding-top: 50px; } +.themes_block{ + padding-bottom: 55px; +} + +.themes_block h3 { + margin-bottom: 30px; +} + .subjects_block{ padding: 50px 0; } diff --git a/static/mailing_settings/js/main.js b/static/mailing_settings/js/main.js index 553fd85f..6c119889 100644 --- a/static/mailing_settings/js/main.js +++ b/static/mailing_settings/js/main.js @@ -35,9 +35,13 @@ .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); - }); + // $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(); @@ -121,6 +125,40 @@ $.fancybox.close(); }); + + + 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(); + }); + })(); @@ -173,7 +211,21 @@ } $.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(); + }); })(); // Выбор стран @@ -209,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(); @@ -222,6 +278,12 @@ text + '×' + '' + }, + + 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 при инициализации @@ -235,17 +297,13 @@ }); $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); }); - - // Записываем данные в 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); - // }); + console.log(user_countries); // открываем список тегов в теме $countries_modal.on('click', '.trigger', function (e) { @@ -260,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); + + } } }); @@ -281,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 () { diff --git a/templates/client/accounts/mailing_settings.html b/templates/client/accounts/mailing_settings.html index c78b7a8f..009217fa 100644 --- a/templates/client/accounts/mailing_settings.html +++ b/templates/client/accounts/mailing_settings.html @@ -69,9 +69,6 @@ {% trans 'Выбрать города' %}
          - - -
        • {{ form.r_cities }}
        • @@ -87,9 +84,6 @@ {% trans 'Выбрать страны' %}
              - - -
            • {{ form.area }} {{ form.f_countries }}
            • diff --git a/templates/client/popups/mailing_settings_countries.html b/templates/client/popups/mailing_settings_countries.html index 00ad41d3..eb6aafe7 100644 --- a/templates/client/popups/mailing_settings_countries.html +++ b/templates/client/popups/mailing_settings_countries.html @@ -17,7 +17,7 @@ {% for value, text in form.area.field.choices %}