1function addGlobalCheckbox(element) { 2 var checkOnlyRegister = false; 3 4 if (element.find('.register-form.state-form').length > 0) { 5 element = element.find('.register-form.state-form'); 6 checkOnlyRegister = true; 7 } 8 9 if (element.find('.login-form.state-form').length > 0 && !checkOnlyRegister) { 10 return function (params) { 11 return true; 12 }; 13 } 14 15 if (element.find('.form-content').length > 0) { 16 element = element.find('.form-content'); 17 } 18 19 function hasFormPaidOrder() { 20 var formPositionSum = 0; 21 22 element.find(".form-position-input, input[name='formParams[setted_offer_id]'], input.offer-select-input").each( 23 function () { 24 formPositionSum += $(this).data("price-value"); 25 } 26 ); 27 28 if (formPositionSum > 0) { 29 return true; 30 } 31 32 if (element.parent("form").find('input[name="formParams[willCreatePaidDeal]"]').val() > 0) { 33 return true; 34 } 35 36 return false; 37 } 38 39 var isOfertaCheckboxEnabled = window.globalCheckboxEnabled; 40 41 if (window.hasOwnProperty("globalCheckboxForPaidOnly")) { 42 if (window.globalCheckboxForPaidOnly && !hasFormPaidOrder()) { 43 isOfertaCheckboxEnabled = false; 44 } 45 } 46 47 if (isOfertaCheckboxEnabled) { 48 var checked = window.persodataConfirm ? 'checked' : ''; 49 var $checkboxEl = $('<div class="global-confirm-checkbox-block confirm-rules-checkbox">' + 50 '<label>' + 51 '<input class="global-confirm-checkbox" type="checkbox" ' + checked + ' name="globalConfirmCheckbox" >' + 52 '<span class="checkbox-text">' + window.globalCheckboxText + '</span>' + 53 '</label>' + 54 '</div>'); 55 56 var $checkboxInput = $checkboxEl.find('input') 57 var firstSubmitButton = element.find('button[type=submit]'); 58 // if (firstSubmitButton.length > 0 && false) { 59 // $checkboxEl.insertBefore(firstSubmitButton) 60 // } else { 61 $checkboxEl.appendTo(element); 62 // } 63 } 64 65 if (window.pdpCheckboxEnabled) { 66 var isPdpChecked = window.pdpConfirmedByDefault ? 'checked' : ''; 67 var $pdpCheckboxEl = $('<div class="global-confirm-checkbox-block confirm-rules-checkbox">' + 68 '<label>' + 69 '<input class="global-confirm-checkbox" type="checkbox" ' + isPdpChecked + ' name="pdpConfirmCheckbox" >' + 70 '<span class="checkbox-text">' + window.pdpCheckboxText + '</span>' + 71 '</label>' + 72 '</div>'); 73 74 var $pdpCheckboxInput = $pdpCheckboxEl.find('input') 75 76 $pdpCheckboxEl.appendTo(element); 77 } 78 79 var isMailingCheckboxEnabled = window.checkboxMailingEnabled; 80 if (window.hasOwnProperty("checkboxMailingForPaidOnly")) { 81 if (window.checkboxMailingForPaidOnly && !hasFormPaidOrder()) { 82 isMailingCheckboxEnabled = false; 83 } 84 } 85 86 if (isMailingCheckboxEnabled) { 87 var checked = window.checkboxMailingChecked ? 'checked' : ''; 88 var input = '<div class="xdget-formField">' + 89 '<label>' + 90 '<input type="checkbox" ' + checked + ' class="append-handle-input" name="confirmMailingCheckbox" />' + 91 '<span class="checkbox-text">' + window.checkboxMailingText + '</span>' + 92 '</label>' + 93 '</div>'; 94 95 var checkboxMailing = $(input); 96 97 if (element.find('.confirm-rules-checkbox').length === 1) { 98 checkboxMailing.appendTo(element.find('.confirm-rules-checkbox')); 99 } else { 100 checkboxMailing = $('<div class="global-confirm-checkbox-block confirm-mailing-checkbox">' + input + '</div>'); 101 102 var firstSubmitButton = element.find('button[type=submit]'); 103 checkboxMailing.appendTo(element); 104 } 105 } 106 107 return function (params) { 108 var str = ""; 109 if (isOfertaCheckboxEnabled && !$checkboxInput.prop('checked')) { 110 if (checkOnlyRegister && !(params && params.state == "register")) { 111 return true; 112 } 113 114 str = 'ЧÑÐ¾Ð±Ñ Ð¾ÑпÑавиÑÑ ÑоÑÐ¼Ñ Ð²Ñ Ð´Ð¾Ð»Ð¶Ð½Ñ ÑоглаÑиÑÑÑÑ Ñ ÑÑловиÑми договоÑа-оÑеÑÑÑ. ' 115 + 'ÐÑмеÑÑÑе ÑооÑвеÑÑÑвÑÑÑÑÑ Ð³Ð°Ð»Ð¾ÑкÑ'; 116 117 if (window.hasOwnProperty("isLegalReworkFeatureEnabled")) { 118 if (window.isLegalReworkFeatureEnabled === true) { 119 str = "ЧÑÐ¾Ð±Ñ Ð¿ÑодолжиÑÑ, Ð½ÐµÐ¾Ð±Ñ Ð¾Ð´Ð¸Ð¼Ð¾ ÑоглаÑиÑÑÑÑ Ñ ÑÑловиÑми оÑеÑÑÑ"; 120 } 121 } 122 123 if (typeof Yii != 'undefined') { 124 str = Yii.t('common', str); 125 } 126 127 alert(str); 128 129 return false;
130 } 131 132 if (window.pdpCheckboxEnabled && !$pdpCheckboxInput.prop('checked')) { 133 if (checkOnlyRegister && !(params && params.state == "register")) { 134 return true; 135 } 136 137 str = 'ЧÑÐ¾Ð±Ñ Ð¾ÑпÑавиÑÑ ÑоÑÐ¼Ñ Ð²Ñ Ð´Ð¾Ð»Ð¶Ð½Ñ ÑоглаÑиÑÑÑÑ Ñ ÑÑловиÑми на обÑабоÑÐºÑ Ð¿ÐµÑÑоналÑнÑÑ Ð´Ð°Ð½Ð½ÑÑ . ' 138 + 'ÐÑмеÑÑÑе ÑооÑвеÑÑÑвÑÑÑÑÑ Ð³Ð°Ð»Ð¾ÑкÑ'; 139 140 if (window.hasOwnProperty("isLegalReworkFeatureEnabled")) { 141 if (window.isLegalReworkFeatureEnabled === true) { 142 str = "ЧÑÐ¾Ð±Ñ Ð¿ÑодолжиÑÑ, Ð½ÐµÐ¾Ð±Ñ Ð¾Ð´Ð¸Ð¼Ð¾ ÑоглаÑиÑÑÑÑ Ñ ÑÑловиÑми обÑабоÑки пеÑÑоналÑнÑÑ Ð´Ð°Ð½Ð½ÑÑ "; 143 } 144 } 145 146 if (typeof Yii != 'undefined') { 147 str = Yii.t('common', str); 148 } 149 150 alert(str); 151 152 return false; 153 } 154 155 if (isMailingCheckboxEnabled) { 156 var isRequired = false; 157 if (window.hasOwnProperty("isMailingCheckboxRequired")) { 158 if (window.isMailingCheckboxRequired) { 159 isRequired = true; 160 } 161 } 162 163 if (window.hasOwnProperty("isMailingCheckboxRequiredForNotPaid")) { 164 if (window.isMailingCheckboxRequiredForNotPaid && !hasFormPaidOrder()) { 165 isRequired = true; 166 } 167 } 168 169 if (isRequired) { 170 if (!checkboxMailing.find("input").prop("checked")) { 171 if (checkOnlyRegister && !(params && params.state == "register")) { 172 return true; 173 } 174 175 str = "ÐÐ»Ñ Ñого, ÑÑÐ¾Ð±Ñ Ð¼Ñ Ð¼Ð¾Ð³Ð»Ð¸ оÑпÑавлÑÑÑ Ð²Ð°Ð¼ ÑообÑÐµÐ½Ð¸Ñ Ð½Ð° поÑÑÑ, " 176 + "Ð½ÐµÐ¾Ð±Ñ Ð¾Ð´Ð¸Ð¼Ð¾ ÑоглаÑиÑÑÑÑ Ð½Ð° полÑÑение пиÑем"; 177 178 if (typeof Yii != 'undefined') { 179 str = Yii.t('common', str); 180 } 181 182 alert(str); 183 184 return false; 185 } 186 } 187 } 188 189 return true; 190 }; 191} 192 193function fillCustomFields(settings) { 194 var isUtmAutoMapEnabled = !!settings.isUtmAutoMap; 195 var fields = settings.fields ? settings.fields : {}; 196 197 var utmFields = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content']; 198 var contexts = ['user', 'deal']; 199 200 function fillUtmField(name, value) { 201 var fields = []; 202 var nameWithPrefix = 'gc_system.' + name; 203 var selector = '[data-element="custom-field"][data-title="' + nameWithPrefix + '"]'; 204 var $field = $(selector).eq(0); 205 206 if ($field.length) { 207 fields.push($field); 208 } 209 210 for (var context of contexts) { 211 nameWithPrefix = 'gc_system_' + context + '_' + name; 212 selector = '[data-element="custom-field"][data-title="' + nameWithPrefix + '"]'; 213 $field = $(selector).eq(0); 214 215 if ($field.length) { 216 fields.push($field); 217 } 218 } 219 220 if (!fields.length) { 221 console.error('Utm field ' + name + ' not found'); 222 223 return; 224 } 225 226 for (var $f of fields) { 227 $input = $f.find('input').eq(0); 228 229 if (!$input.length) { 230 continue; 231 } 232 233 $input.val(value); 234 $input.trigger('change'); 235 } 236 } 237 238 function fillUtmFieldAuto(name) { 239 var searchParams = new URLSearchParams(window.location.search); 240 var value = searchParams.get(name); 241 242 if (!value) { 243 value = ''; 244 } 245 246 fillUtmField(name, value); 247 } 248 249 if (isUtmAutoMapEnabled) { 250 for (var utmField of utmFields) { 251 fillUtmFieldAuto(utmField); 252 } 253 } 254 255 for (var id of Object.keys(fields)) { 256 var isUtmField = utmFields.includes(id); 257 var selector = ''; 258 var $field = null; 259 var value = fields[id]; 260 261 if (isUtmField) { 262 fillUtmField(id, value); 263 264 continue; 265 } 266 267 selector = '[data-element="custom-field"][data-id="' + id + '"]'; 268 $field = $(selector).eq(0); 269 270 if (!$field.length) { 271 console.error('Custom field with id ' + id + ' not found'); 272 273 continue; 274 } 275 276 var type = $field.data('type'); 277 var $input; 278 279 switch (type) { 280 case 'string': 281 case 'date': 282 case 'numeric': { 283 $input = $field.find('input').eq(0); 284 285 if (!$input) { 286 continue; 287 } 288 289 $input.val(value); 290 291 break; 292 } 293 case 'text': { 294 $input = $field.find('textarea').eq(0); 295 296 if (!$input) { 297 continue; 298 } 299 300 $input.val(value); 301 302 break; 303 } 304 case 'checkbox': { 305 $input = $field.find('input[type="checkbox"]').eq(0); 306 307 if (!$input) { 308 continue; 309 } 310 311 $input.prop('checked', Boolean(value)); 312 313 break; 314 } 315 case 'select': { 316 $input = $field.find('select').eq(0); 317 318 if (!$input) { 319 continue; 320 } 321 322 var $options = $input.find('option'); 323 var valueToSelect; 324 325 $options.each(function (_, $option) { 326 var optionValue = $option.value; 327 328 if (optionValue === value) { 329 valueToSelect = optionValue; 330 } 331 }); 332 333 if (!valueToSelect) { 334 console.error('Value ' + value + ' is not exist in select field with id ' + id); 335 336 continue; 337 } 338 339 $input.val(valueToSelect); 340 341 break; 342 } 343 case 'file': { 344 console.error('File field type is not supported. Field id ' + id); 345 346 continue; 347 } 348 case 'multi_select': { 349 if (!Array.isArray(value)) { 350 console.error('Value must an array for field with multi_select type. Field id ' + id); 351 352 continue; 353 } 354 355 var $checkboxes = $field.find('input[type="checkbox"]'); 356 357 $checkboxes.each(function (_, checkbox) { 358 var $checkbox = $(checkbox); 359 360 if (value.includes($checkbox.val())) { 361 $checkbox.prop('checked', true); 362 } else { 363 $checkbox.prop('checked', false); 364 } 365 366 $checkbox.trigger('change'); 367 }); 368 369 break; 370 } 371 default: 372 console.error('Unknown field type. Field id ' + id); 373 374 continue; 375 } 376 377 if ($input) { 378 $input.trigger('change'); 379 } 380 } 381}
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.