From f35ccd1b6df0a282012da4583463fe96e87088eb Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 25 Dec 2023 08:39:22 +0000 Subject: [PATCH] Update content of files --- data/web/promote.telegram.org/js/promote.js | 107 ++++---------------- 1 file changed, 20 insertions(+), 87 deletions(-) diff --git a/data/web/promote.telegram.org/js/promote.js b/data/web/promote.telegram.org/js/promote.js index 4fc4c9028d..84bc474f83 100644 --- a/data/web/promote.telegram.org/js/promote.js +++ b/data/web/promote.telegram.org/js/promote.js @@ -401,7 +401,6 @@ var Ads = { } }, onBlur: function(value) { - options.onBlur && options.onBlur(field, options.getDataOpts); options.onEnter && options.onEnter(field, value); }, onEnter: function(value) { @@ -497,7 +496,6 @@ var NewAd = { field: selectData.field, c_field: selectData.c_field, }, - onBlur: NewAd.onLocationSelectBlur, onUpdate: NewAd.onSelectUpdate, onChange: NewAd.onLocationSelectChange }); @@ -529,14 +527,10 @@ var NewAd = { state.targetTypeField.fieldEl().on('change.curPage', NewAd.onTargetTypeChange); state.pictureCheckbox = state.$form.field('picture'); state.pictureCheckbox.on('change.curPage', NewAd.onPictureChange); - state.intersectTopicsCheckbox = state.$form.field('intersect_topics'); - state.intersectTopicsCheckbox.on('change.curPage', NewAd.onIntersectTopicsChange); state.excludePoliticCheckbox = state.$form.field('exclude_politic'); state.excludePoliticCheckbox.on('change.curPage', NewAd.onExcludePoliticChange); state.onlyPoliticCheckbox = state.$form.field('only_politic'); state.onlyPoliticCheckbox.on('change.curPage', NewAd.onOnlyPoliticChange); - state.deviceField = state.$form.field('device'); - state.deviceField.on('ddchange.curPage', NewAd.onDeviceChange); state.confirmedCheckbox = state.$form.field('confirmed'); state.confirmedCheckbox.on('change.curPage', NewAd.onConfirmedChange); NewAd.updateAdPreview(state.$form, state.previewData); @@ -573,10 +567,8 @@ var NewAd = { state.targetTypeField.fieldEl().off('.curPage'); state.confirmedCheckbox.off('.curPage'); state.pictureCheckbox.off('.curPage'); - state.intersectTopicsCheckbox.off('.curPage'); state.excludePoliticCheckbox.off('.curPage'); state.onlyPoliticCheckbox.off('.curPage'); - state.deviceField.off('.curPage'); for (var i = 0; i < state.selectList.length; i++) { var selectData = state.selectList[i]; if (selectData.location_search) { @@ -605,10 +597,6 @@ var NewAd = { var $form = $(this.form); NewAd.adPostCheck($form); }, - onIntersectTopicsChange: function() { - NewAd.updateAdTargetOverview(); - NewAd.saveDraftAuto(true); - }, onExcludePoliticChange: function() { if ($(this).prop('checked')) { Aj.state.onlyPoliticCheckbox.prop('checked', false); @@ -672,13 +660,6 @@ var NewAd = { Ads.hideFieldError(buttonField); NewAd.adPostCheck($form); }, - onDeviceChange: function() { - var $form = $(this).parents('form'); - var devideField = $form.field('devide'); - Ads.hideFieldError(devideField); - NewAd.updateAdTargetOverview(); - NewAd.saveDraftAuto(true); - }, adPostCheck: function($form, try_index) { var textField = $form.field('text'); var promoteUrlField = $form.field('promote_url'); @@ -686,7 +667,6 @@ var NewAd = { var websiteNameField = $form.field('website_name'); var websitePhotoField = $form.field('website_photo'); var cpmField = $form.field('cpm'); - var deviceField = $form.field('device'); var text = textField.value(); var promote_url = promoteUrlField.value(); var button = buttonField.data('value'); @@ -694,7 +674,6 @@ var NewAd = { var website_photo = websitePhotoField.value(); var $formGroup = promoteUrlField.fieldEl().parents('.form-group'); var $cpmFormGroup = cpmField.fieldEl().parents('.form-group'); - var device = deviceField.data('value'); if (!text && !promote_url) { return false; } @@ -704,8 +683,7 @@ var NewAd = { promote_url: promote_url, button: button, website_name: website_name, - website_photo: website_photo, - device: device + website_photo: website_photo }; if (Aj.state.adId) { params.ad_id = Aj.state.adId; @@ -934,17 +912,6 @@ var NewAd = { }); return false; }, - onLocationSelectBlur: function(field, opts) { - var $form = Aj.state.$form; - var $cFieldEl = $form.field(opts.c_field); - var c_value = $cFieldEl.data('value'); - if (c_value.join) { - if (c_value.length > 1) { - Ads.hideFieldError($cFieldEl); - return false; - } - } - }, onLocationSelectChange: function(field, value, valueFull) { var $fieldEl = Aj.state.$form.field(field); Ads.hideFieldError($fieldEl); @@ -952,12 +919,11 @@ var NewAd = { onSelectUpdate: function(field, value, valueFull) { var $fieldEl = Aj.state.$form.field(field); if (field == 'user_topics') { - var user_topics_cnt = $fieldEl.data('value').length; - if (user_topics_cnt > 1) { - $('.js-intersect-topics-wrap', Aj.state.$form).slideShow(); - } else { - $('.js-intersect-topics-wrap', Aj.state.$form).slideHide(); + var has_user_topics = $fieldEl.data('value').length > 0; + if (has_user_topics) { + Aj.state.onlyPoliticCheckbox.prop('checked', false); } + Aj.state.onlyPoliticCheckbox.prop('disabled', has_user_topics); } var selOpts = $fieldEl.data('selOpts'); var paired_field = selOpts.pairedField; @@ -1226,18 +1192,6 @@ var NewAd = { updateAdTargetOverview: function() { var len = {}, lang_params = {}, need_outside_cb = false; var target_type = Aj.state.$form.field('target_type').value(); - var joinTargets = function(list, or, repeat) { - var lk = or ? 'WEB_AD_TARGET_OR' : 'WEB_AD_TARGET_AND'; - if (repeat && list.length > 2) { - var last_item = list.pop(); - return l(lk, {item1: joinTargets(list, or, repeat), item2: last_item}); - } - if (list.length > 1) { - var last_item = list.pop(); - list[list.length - 1] = l(lk, {item1: list[list.length - 1], item2: last_item}); - } - return list.join(', '); - }; for (var i = 0; i < Aj.state.selectList.length; i++) { var selectData = Aj.state.selectList[i]; var field = selectData.field; @@ -1254,16 +1208,16 @@ var NewAd = { need_outside_cb = true; } } - var list_or = (field == 'langs' || field == 'topics' || field == 'countries' || field == 'locations' || field == 'user_langs' || field == 'user_topics' && !Aj.state.intersectTopicsCheckbox.prop('checked') || field == 'user_channels' || field == 'audiences') - lang_params[field] = joinTargets(list, list_or); + if (list.length > 1) { + var last_item = list.pop(); + list[list.length - 1] = l('WEB_AD_TARGET_AND', {item1: list[list.length - 1], item2: last_item}); + } + lang_params[field] = list.join(', '); } else { lang_params[field] = ''; } Ads.hideFieldError($field); } - len.device = Aj.state.$form.field('device').data('value'); - lang_params.device = '' + Aj.state.$form.field('device').html() + ''; - var overview = ''; if (target_type == 'channels') { if ((len.langs || len.topics) && len.channels) { @@ -1316,33 +1270,27 @@ var NewAd = { if (len.user_topics > 0) { user_targets.push(l('WEB_AD_TARGET_USER_TOPICS', lang_params)); } - if (len.user_channels > 0) { - user_targets.push(l('WEB_AD_TARGET_USER_CHANNELS', lang_params)); - } if (len.audiences > 0) { user_targets.push(l('WEB_AD_TARGET_AUDIENCES', lang_params)); } - if (len.device) { - user_targets.push(l('WEB_AD_TARGET_DEVICE', lang_params)); + if (user_targets.length > 1) { + var last_user_target = user_targets.pop(); + user_targets[user_targets.length - 1] = l('WEB_AD_TARGET_AND', {item1: user_targets[user_targets.length - 1], item2: last_user_target}); } - user_targets = joinTargets(user_targets, false, true); if (Aj.state.onlyPoliticCheckbox.prop('checked')) { - overview += '
' + l('WEB_AD_TARGET_USERS_ONLY_POLITIC', {target: user_targets}) + '
'; + overview += '
' + l('WEB_AD_TARGET_USERS_ONLY_POLITIC', {target: user_targets.join(', ')}) + '
'; } else { - overview += '
' + l('WEB_AD_TARGET_USERS', {target: user_targets}) + '
'; + overview += '
' + l('WEB_AD_TARGET_USERS', {target: user_targets.join(', ')}) + '
'; } if (len.exclude_user_topics > 0) { overview += '
' + l('WEB_AD_TARGET_USER_EXCLUDE_TOPICS', lang_params) + '
'; } - if (len.exclude_user_channels > 0) { - overview += '
' + l('WEB_AD_TARGET_USER_EXCLUDE_CHANNELS', lang_params) + '
'; + if (Aj.state.excludePoliticCheckbox.prop('checked')) { + overview += '
' + l('WEB_AD_TARGET_EXCLUDE_POLITIC') + '
'; } if (len.exclude_audiences > 0) { overview += '
' + l('WEB_AD_TARGET_EXCLUDE_AUDIENCES', lang_params) + '
'; } - if (Aj.state.excludePoliticCheckbox.prop('checked')) { - overview += '
' + l('WEB_AD_TARGET_EXCLUDE_POLITIC') + '
'; - } } $('.js-exclude-outside').addClass('hide'); } else { @@ -1364,8 +1312,7 @@ var NewAd = { $form.field('cpm').value(), $form.field('views_per_user').value(), $form.field('budget').value(), - $form.field('target_type').value(), - $form.field('device').data('value') + $form.field('target_type').value() ]; if ($form.field('picture').prop('checked')) { values.push('picture'); @@ -1375,9 +1322,6 @@ var NewAd = { var vals = $form.field(selectData.field).data('value') || []; values.push(vals.join(';')); } - if ($form.field('intersect_topics').prop('checked')) { - values.push('intersect_topics'); - } if ($form.field('exclude_politic').prop('checked')) { values.push('exclude_politic'); } @@ -1423,7 +1367,6 @@ var NewAd = { var views_per_user = $form.field('views_per_user').value(); var budget = Ads.amountFieldValue($form, 'budget'); var target_type = $form.field('target_type').value(); - var device = $form.field('device').data('value'); if (!title.length) { $form.field('title').focus(); @@ -1457,8 +1400,7 @@ var NewAd = { cpm: cpm, views_per_user: views_per_user, budget: budget, - target_type: target_type, - device: device + target_type: target_type }; if ($form.field('picture').prop('checked')) { params.picture = 1; @@ -1468,9 +1410,6 @@ var NewAd = { var values = $form.field(selectData.field).data('value') || []; params[selectData.field] = values.join(';'); } - if ($form.field('intersect_topics').prop('checked')) { - params.intersect_topics = 1; - } if ($form.field('exclude_politic').prop('checked')) { params.exclude_politic = 1; } @@ -1526,7 +1465,6 @@ var NewAd = { var views_per_user = $form.field('views_per_user').value(); var budget = Ads.amountFieldValue($form, 'budget'); var target_type = $form.field('target_type').value(); - var device = $form.field('device').data('value'); var curFormData = NewAd.getFormData($form); if (Aj.state.initFormData == curFormData) { @@ -1544,8 +1482,7 @@ var NewAd = { cpm: cpm, views_per_user: views_per_user, budget: budget, - target_type: target_type, - device: device + target_type: target_type }; if ($form.field('picture').prop('checked')) { params.picture = 1; @@ -1555,9 +1492,6 @@ var NewAd = { var values = $form.field(selectData.field).data('value') || []; params[selectData.field] = values.join(';'); } - if ($form.field('intersect_topics').prop('checked')) { - params.intersect_topics = 1; - } if ($form.field('exclude_politic').prop('checked')) { params.exclude_politic = 1; } @@ -1600,7 +1534,6 @@ var NewAd = { $form.field('exclude_politic').prop('checked', false); $form.field('only_politic').prop('checked', false); $form.field('exclude_outside').prop('checked', false); - $form.field('device').trigger('selectval', ['']); Aj.state.titleField.focusAndSelect(); NewAd.updateAdPreview(Aj.state.$form, false); var curFormData = NewAd.getFormData($form);