1/* ----------------- Start Document ----------------- */ 2(function ($) { 3 ("use strict"); 4 5 // code that return the ad calculation from ajax request 6 // to be used in the ad calculation page 7 8 $(document).ready(function () { 9 10 $("#post-autocomplete").autocomplete({ 11 source: function (request, response) { 12 $.ajax({ 13 url: ad_calculation.ajax_url, 14 dataType: "json", 15 data: { 16 action: "post_title_autocomplete", 17 term: request.term, 18 }, 19 success: function (data) { 20 response(data); 21 }, 22 }); 23 }, 24 minLength: 2, 25 select: function (event, ui) { 26 $("#post-id").val(ui.item.id); 27 }, 28 }); 29 30 $("#submit-ad-form").on("change", "input, select, textarea", function () { 31 var budget = $("input[name='budget']").val(); 32 $(".ad-price-calc").addClass("loading"); 33 // get value of checkboxes with name placement 34 var placement = $("input[name='placement[]']:checked") 35 .map(function () { 36 return this.value; 37 }) 38 .get(); 39 var campaign_type = $("#ad_campaign_type").val(); 40 41 var ad = { 42 budget: budget, 43 placement: placement, 44 campaign_type: campaign_type, 45 }; 46 $.ajax({ 47 url: ad_calculation.ajax_url, 48 data: { 49 action: "listeo_get_ad_price", 50 ad: ad, 51 }, 52 type: "POST", 53 success: function (response) { 54 // change response.data json string to object 55 $("#ad-price-summary").show(); 56 if (response.data.home) { 57 $(".price-box.home-campaign").show(); 58 // set the value of the div with class .ad-price-home to the response.data 59 $(".price-box.home-campaign .price").html(response.data.home); 60 $(".ad-type").html(response.data.type); 61 } else { 62 $(".price-box.home-campaign").hide(); 63 } 64 if (response.data.sidebar) { 65 $(".price-box.sidebar-campaign").show(); 66 // set the value of the div with class .ad-price-home to the response.data 67 $(".price-box.sidebar-campaign .price").html(response.data.sidebar); 68 $(".ad-type").html(response.data.type); 69 } else { 70 $(".price-box.sidebar-campaign").hide(); 71 } 72 if (response.data.search) { 73 $(".price-box.search-campaign").show(); 74 // set the value of the div with class .ad-price-home to the response.data 75 $(".price-box.search-campaign .price").html(response.data.search); 76 $(".ad-type").html(response.data.type); 77 } else { 78 $(".price-box.search-campaign").hide(); 79 } 80 $(".ad-price-calc").removeClass("loading"); 81 // if response data is has only one value hide the other divs 82 if (!response.data.home && !response.data.sidebar && !response.data.search) { 83 $("#ad-price-summary").hide(); 84 85 } 86 }, 87 error: function (error) { 88 console.log(error); 89 $(".ad-price-calc").removeClass("loading"); 90 }, 91 }); 92 }); 93 94 // if value of select ad_campaign_type is changed show/hide the div with class .ad-price-click or .ad-price-views 95 96 $("#ad_campaign_type").on("change", function () { 97 var ad_campaign_type = $(this).val(); 98 99 if (ad_campaign_type == "ppc") { 100 $(".ppc-price").show(); 101 $(".ppv-price").hide(); 102 } else { 103 $(".ppc-price").hide(); 104 $(".ppv-price").show(); 105 } 106 }); 107 108 var ad_campaign_type = $("#ad_campaign_type").val(); 109 if (ad_campaign_type == "ppc") { 110 $(".ppc-price").show(); 111 $(".ppv-price").hide(); 112 } else { 113 $(".ppc-price").hide(); 114 $(".ppv-price").show(); 115 } 116 117 // add verificaiton and validation to the ad form, to check if the user has selected a placement and listing id 118 $("#submit-ad-form").on("submit", function (e) { 119 e.preventDefault(); 120 121 var placement = $("input[name='placement[]']:checked").length; 122 // scroll to the top of the page 123 $("html, body").animate({ scrollTop: 0 }, "slow"); 124 if (placement == 0) { 125 $("#placement-error").show(); 126 return; 127 } else { 128 $("#placement-error").hide(); 129 } 130 131 132 $(this).unbind("submit").submit(); 133 134 135 136 }); 137 }); 138})(this.jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.