1 2function property() { 3 4 var list = document.body.querySelectorAll('input:not([type="hidden"])'); 5 var select = document.body.querySelectorAll('select'); 6 var textarea = document.body.querySelectorAll('textarea'); 7 var checkbox = document.body.querySelectorAll('input[type="checkbox"]'); 8 var listImage = document.body.querySelectorAll('[data-list]'); 9 var cond = document.querySelectorAll('.radio-change'); 10 var sort = document.querySelectorAll('[data-sort]'); 11 12 function isTrue(el) { 13 if(el != null && el != undefined) return true; else return false; 14 } 15 16 var inactive = document.body.querySelectorAll('.sf4_property_inactive'); 17 18 if(isTrue(inactive)) { 19 for(var k = 0; k < inactive.length; k++) { 20 var el = inactive[k]; 21 el.addEventListener('click', function(e) { 22 e.currentTarget.classList.remove('sf4_property_inactive'); 23 var input = e.currentTarget.querySelector('.hidden-input'), 24 allElements = e.currentTarget.querySelectorAll('[disabled=""]'); 25 26 for(var k = 0; k < allElements.length; k++) 27 if(allElements[k].hasAttribute('disabled')) allElements[k].removeAttribute('disabled'); 28 if(isTrue(input)) { 29 input.setAttribute('value', "Y"); 30 input.value = "Y"; 31 } 32 var allInput = e.currentTarget.querySelectorAll('input'), 33 event = new Event('input'); 34 if(isTrue(allInput)) { 35 for(var x = 0; x < allInput.length; x++) { 36 var eIn = allInput[x]; 37 if(eIn.classList.contains('hidden-input')) { 38 eIn.focus(); 39 } 40 } 41 } 42 }) 43 } 44 } 45 46 47 var btnMulti = document.body.querySelectorAll('input[data-button-property=""]'); 48 if(btnMulti != null) { 49 for(var k = 0; k < btnMulti.length; k++) { 50 btnMulti[k].onclick = function(e) { 51 addField(e); 52 } 53 } 54 } 55 56 57 // ----------- SELECT ------------- // 58 59 if(select != null) { 60 for(var k = 0; k < select.length; k++) { 61 var slc = select[k]; 62 slc.addEventListener('change', function(e) { 63 var el = e.currentTarget; 64 var chang = el.parentNode.querySelector('[if-type="checkbox"]'); 65 for(var s = 0; s < el.options.length; s++) { 66 var opt = el.options[s]; 67 if(opt.selected) { 68 opt.setAttribute('selected', ''); 69 if (chang != null) { 70 chang.setAttribute('checked', 'checked'); 71 chang.setAttribute('value', opt.value); 72 } 73 } else { 74 opt.removeAttribute('selected'); 75 if (chang != null) { 76 chang.removeAttribute('checked'); 77 } 78 } 79 } 80 var chan = new Event('change'); 81 if (chang != null) { 82 chang.dispatchEvent(chan); 83 } 84 }); 85 } 86 } 87 88 if(isTrue(list)) { 89 for(var k = 0; k < list.length; k++) { 90 var el = list[k]; 91 el.addEventListener('input', function(e) { 92 var input = e.target, 93 condition = input.nextElementSibling, 94 event = new Event('change'); 95 if(condition.type != "hidden" || condition.type != "hidden") { 96 if(isTrue(condition)) { 97 condition.setAttribute('value', linkConditionSetValue(input) + input.value) 98 condition.setAttribute('checked', 'checked'); 99 condition.dispatchEvent(event); 100 if(input.hasAttribute('data-protocol')) { 101 condition.value = linkConditionSetValue(input) + input.value; 102 } else condition.value = input.value; 103 condition.checked = true; 104 } 105 if(isTrue(input)) { 106 if(input.classList.contains('form-check-input')) { 107 if(input.checked) { 108 input.value = "Y"; 109 input.checked = true; 110 input.setAttribute('value', 'Y'); 111 input.setAttribute('checked', 'checked'); 112 } else { 113 input.setAttribute('value', 'N'); 114 input.removeAttribute('checked'); 115 input.checked = false; 116 input.value = "N"; 117 } 118 } 119 } 120 } 121 122 123 }); 124 } 125 } 126 127 function linkConditionSetValue(input) { 128 if(input) { 129 if(input.hasAttribute('data-protocol')) { 130 131 var container = input.parentNode, 132 selectProtocol = container.querySelector('select[data-protocol=""]'); 133 if(selectProtocol) { 134 for(var k = 0; k < selectProtocol.options.length; k++) { 135 var opt = selectProtocol.options[k]; 136 if(opt.selected) { 137 return opt.value; 138 } 139 } 140 } 141 } 142 } 143 } 144 145 if(isTrue(textarea)) { 146 for(var k = 0; k < textarea.length; k++) { 147 var el = textarea[k]; 148 el.addEventListener('input', function(e) { 149 var input = e.target, 150 condition = input.nextElementSibling, 151 event = new Event('change'); 152 if(isTrue(condition)) { 153 condition.setAttribute('value', input.value) 154 condition.setAttribute('checked', 'checked'); 155 condition.dispatchEvent(event); 156 condition.value = input.value; 157 condition.checked = true; 158 } 159 }) 160 } 161 } 162 163 if(isTrue(listImage)) { 164 for(var k = 0; k < listImage.length; k++) { 165 var data = listImage[k]; 166 if(data.hasAttribute('data-list')) { 167 var dataList = data.getAttribute('data-list'); 168 //imageAction(data); 169 } 170 } 171 } 172 173 // ----------- CHECKBOX ------------- // 174 175 if(checkbox != null) { 176 for(var k = 0; k < checkbox.length; k++) { 177 var check = checkbox[k], 178 chang = check.nextElementSibling; 179 180 if(check.checked) { 181 check.setAttribute('checked', ''); 182 if(chang != null && chang != undefined) 183 chang.setAttribute('checked', 'checked'); 184 } else { 185 check.removeAttribute('checked', ''); 186 if(chang != null && chang != undefined) 187 chang.removeAttribute('checked'); 188 } 189 190 if(chang != null && chang != undefined) { 191 var chan = new Event('change'); 192 chang.dispatchEvent(chan); 193 } 194 } 195 } 196 197 var checkbox = document.body.querySelectorAll('[data-property-checkbox]'); 198 199 if(checkbox != null) { 200 for(var k = 0; k < checkbox.length; k++) { 201 checkbox[k].addEventListener('change', function(e) { 202 var el = e.target, 203 chang = el.nextElementSibling 204 if(el.checked) { 205 el.value = 'Y' 206 el.setAttribute('value', 'Y'); 207 el.setAttribute('checked', ''); 208 chang.setAttribute('checked', 'checked'); 209 chang.setAttribute('value', el.value); 210 } else { 211 el.value = "N"; 212 el.setAttribute('value', 'N'); 213 el.setAttribute('checked', ''); 214 el.removeAttribute('checked'); 215 chang.removeAttribute('checked'); 216 chang.setAttribute('value', el.value); 217 } 218 var chan = new Event('change'); 219 chang.dispatchEvent(chan); 220 }); 221 } 222 } 223 if(inactive != null) { 224 for(var i = 0; i < inactive.length; i++) { 225 226 var input = inactive[i].querySelectorAll('input'), 227 select = inactive[i].querySelectorAll('select'), 228 textarea = inactive[i].querySelectorAll('textarea'); 229 230 if(inactive[i].hasAttribute('data-input')) { 231 inactive[i].ondragend = function(e) { 232 e.target.parentNode.parentNode.querySelector('.hidden-input').value = 'Y'; 233 searchParent(e.target); 234 } 235 } 236 237 if(input != null) { 238 for(var k = 0; k < input.length; k++) { 239 var data = input[k]; 240 241 242 243 if(data.hasAttribute('data-property-checkbox')) { 244 var dataCheck = data.getAttribute('data-property-checkbox'); 245 data.addEventListener('input', function(e) { 246 var el = e.target, 247 elHidden = el.parentNode.querySelector('.hidden-input'); 248 249 if(el.checked) { 250 el.value = 'Y'; 251 el.setAttribute('value', 'Y'); 252 el.setAttribute('checked', 'checked'); 253 } else { 254 el.value = 'N'; 255 el.setAttribute('value', 'N'); 256 el.removeAttribute('checked') 257 } 258 259 if(elHidden != null) { 260 elHidden.value = 'Y'; 261 elHidden.setAttribute('value', 'Y'); 262 } 263 searchParent(el); 264 }); 265 } 266 267 if(data.hasAttribute('data-entity')) { 268 if(data.getAttribute('data-entity')) { 269 270 var btn = data.parentNode.querySelector('input[type="button"]'); 271 if(btn != null) { 272 btn.addEventListener('click', function(e) { 273 var el = e.target; 274 var hidden = el.parentNode.parentNode.querySelector('.hidden-input'); 275 hidden.value = "Y"; 276 hidden.setAttribute('value', 'Y'); 277 searchParent(el); 278 }); 279 } 280 } 281 } 282 283 if(data.hasAttribute('data-datetime')) { 284 if(data.getAttribute('data-datetime') == 'inactive-public') { 285 data.addEventListener('click', function(e) { 286 data.classList.remove("sf4_property_inactive"); 287 }) 288 inactiveMode(data); 289 } 290 } 291 } 292 } 293 } 294 } 295 296 297 if(list != null) { 298 for(var k = 0; k < list.length; k++) { 299 var listOne = list[k]; 300 301 if(listOne.hasAttribute('data-list')) { 302 switch(listOne.getAttribute('data-list')) { 303 case 'public-button':
304 imageAction(listOne, true); 305 break; 306 case 'public-button-radio': 307 imageAction(listOne, true); 308 break; 309 case 'public-image-list-one': 310 imageAction(listOne); 311 break; 312 case 'public-image-list-multi': 313 imageAction(listOne); 314 break; 315 } 316 } 317 318 if(listOne.hasAttribute('data-number')) { 319 switch(listOne.getAttribute('data-number')) { 320 case 'public-one': 321 322 listOne.addEventListener('input', function(e) { 323 var chang = e.target.nextElementSibling; 324 chang.setAttribute('value', e.target.value); 325 chang.setAttribute('checked', 'checked') 326 var chan = new Event('change'); 327 chang.dispatchEvent(chan); 328 }); 329 break; 330 } 331 } 332 } 333 } 334 335 function addField(e) { 336 var btn = e.target, 337 container = btn.parentNode; 338 if(container != null) { 339 var el = container.querySelectorAll("*"); 340 var propContainerElement = btn.parentNode.parentNode.querySelectorAll('*'); 341 var input = [], 342 entity = [], 343 string = [], 344 text = [], 345 number = [], 346 phone = [], 347 url = [], 348 link = [], 349 date = []; 350 351 for(var i = 0; i < el.length; i++) { 352 if(el[i].hasAttribute('data-property-field')) { 353 switch(el[i].getAttribute('data-property-field')) { 354 case 'entity': 355 entity.push(el[i]); 356 break; 357 case 'string': 358 string.push(el[i]); 359 break; 360 case 'text': 361 text.push(el[i]); 362 break; 363 case 'number': 364 number.push(el[i]); 365 break; 366 case 'phone': 367 phone.push(el[i]); 368 break; 369 case 'url': 370 url.push(el[i]); 371 break; 372 /*case 'link': 373 link.push(el[i]); 374 break;*/ 375 case 'date': 376 date.push(el[i]); 377 break; 378 } 379 } 380 } 381 for(var k = 0; k < propContainerElement.length; k++) { 382 if(propContainerElement[k].hasAttribute('data-property-field')) { 383 switch(propContainerElement[k].getAttribute('data-property-field')) { 384 case 'link': 385 link.push(propContainerElement[k]); 386 break; 387 } 388 } 389 } 390 if(entity.length != 0) addEntity(entity, e); 391 if(text.length != 0) addText(text, e); 392 if(string.length != 0) addString(string, e); 393 if(number.length != 0) addString(number, e); 394 if(phone.length != 0) addString(phone, e); 395 if(url.length != 0) addString(url, e); 396 if(link.length != 0) addStringLink(link, e); 397 if(date.length != 0) addDate(date, e); 398 } 399 } 400 401 function inactiveMode(input) { 402 403 404 input.addEventListener('input', function(e) { 405 var el = e.target; 406 el.parentNode.parentNode.querySelector('.hidden-input').value = 'Y'; 407 searchParent(el); 408 }); 409 410 input.addEventListener('change', function(e) { 411 var el = e.target; 412 el.parentNode.parentNode.querySelector('.hidden-input').value = 'Y'; 413 searchParent(el); 414 }); 415 } 416 417 function imageAction(input, active) { 418 input.addEventListener('click', function(e) { 419 var el = e.target; 420 var radio = el.parentNode.parentNode.querySelectorAll('input'); 421 422 423 var chang = el.nextElementSibling; 424 if(isTrue(chang)) 425 var par = chang.parentNode.parentNode.querySelectorAll('.radio-ch
425ange'); 426 else { 427 chang = el.parentNode.parentNode.querySelector('.radio-change'); 428 par = el.parentNode.parentNode.querySelectorAll('.radio-change'); 429 } 430 431 var checkedValue = ''; 432 433 for(var k = 0; k < radio.length; k++) { 434 if(radio[k].checked && radio.length == 1) { 435 checkedValue += radio[k].value 436 } else if(radio[k].checked && radio.length > 1) { 437 checkedValue += radio[k].value; 438 } 439 } 440 441 par[0].setAttribute('value', checkedValue) 442 443 chang.setAttribute('checked', 'checked') 444 445 446 var chan = new Event('change'); 447 chang.dispatchEvent(chan); 448 par[0].dispatchEvent(chan) 449 chang.setAttribute('value', el.value); 450 451 452 if(input.type == 'radio') { 453 for(var k = 0; k < radio.length; k++) { 454 radio[k].checked = false; 455 radio[k].removeAttribute('checked'); 456 if(active) radio[k].parentNode.classList.remove('active'); 457 } 458 el.checked = true; 459 el.setAttribute('checked', ''); 460 if(active) el.parentNode.classList.add('active'); 461 } else if(input.type == 'checkbox') { 462 if(!el.checked) { 463 el.checked = false; 464 el.removeAttribute('checked'); 465 if(active) el.parentNode.classList.remove('active'); 466 } else { 467 el.checked = true; 468 el.setAttribute('checked', ''); 469 if(active) el.parentNode.classList.add('active'); 470 } 471 } 472 }); 473 } 474 475 function searchParent(el) { 476 if(el != null && el.tagName != 'BODY') { 477 if(!el.parentNode.classList.contains('sf4_property_inactive')) searchParent(el.parentNode); 478 else el.parentNode.classList.remove('sf4_property_inactive'); 479 } 480 } 481 482 function rand() { 483 return Math.random() * (500000000000000000 - 50000000000000000) + 50000000000000000; 484 } 485 486 function addStringLink(link, e) { 487 var btnContainer = document.createElement('div'); 488 btnContainer.className = e.currentTarget.parentNode.getAttribute('class'); 489 var endClone = link[link.length - 1].cloneNode(true), 490 btnClone = e.currentTarget.cloneNode(true), 491 input = endClone.querySelectorAll('input'), 492 name = []; 493 if(input) { 494 for(var k = 0; k < input.length; k++) name.push(input[k].name); 495 for(var k = 0; k < input.length; k++) { 496 input[k].value = ''; 497 input[k].name = fieldIncrementName(name[k], link); 498 input[k].removeAttribute('required'); 499 } 500 btnClone.onclick = function(ev) { 501 addField(ev); 502 } 503 btnContainer.appendChild(btnClone); 504 link.push(endClone); 505 link.push(btnContainer); 506 var parent = link[0].parentNode; 507 parent.innerHTML = ''; 508 for(var i = 0; i < link.length; i++) parent.appendChild(link[i]); 509 } 510 } 511 512 function addString(string, e) { 513 var endClone = string[string.length - 1].cloneNode(true), 514 btnClone = e.target.cloneNode(true), 515 input = endClone.querySelectorAll('input'), 516 name = input[0].name; 517 btnClone.onclick = function(e) { 518 addField(e); 519 } 520 if(input == null) 521 input = endClone.querySelectorAll('textarea'); 522 input[0].value = ''; 523 input[0].name = nameReplace(name, string); 524 input[0].removeAttribute('required'); 525 526 if(input[0].hasAttribute('data-phone')) { 527 var id = 'phone_mask_' + rand(); 528 input[0].id = id; 529 id = '#' + id; 530 531 jQuery(function($) { 532 $(id).mask('+9 (999) 999-9999'); 533 }); 534 } 535 536 if(input[0].hasAttribute('data-url')) { 537 var id = rand(); 538 input[0].id = id; 539 var btn = input[1]; 540 if(btn != null) { 541 btn.addEventListener('click', function(e) { 542 BX.adminShowMenu(this, [ 543 {'TEXT':'Site directory','TITLE':'#SITE_DIR# - Site directory','ONCLICK':'SF.SFSetUrlVar(\'#
543SITE_DIR#\', \''+ id + '\')'}, 544 {'SEPARATOR':true}, 545 {'TEXT':'Storage id','TITLE':'#STORAGE_ID# - Storage id','ONCLICK':'SF.SFSetUrlVar(\'#STORAGE_ID#\', \''+ id + '\')'}, 546 {'TEXT':'Section id','TITLE':'#SECTION_ID# - Section id','ONCLICK':'SF.SFSetUrlVar(\'#SECTION_ID#\', \''+ id + '\')'}, 547 {'TEXT':'Item id','TITLE':'#ITEM_ID# - Item id','ONCLICK':'SF.SFSetUrlVar(\'#ITEM_ID#\', \''+ id + '\')'}], '' 548 ); 549 }); 550 } 551 } 552 553 string.push(endClone); 554 string.push(btnClone); 555 var parent = string[0].parentNode; 556 parent.innerHTML = ''; 557 for(var i = 0; i < string.length; i++) parent.appendChild(string[i]); 558 } 559 560 function addDate(date, e) { 561 var endClone = date[date.length - 1].cloneNode(true), 562 btnClone = e.target.cloneNode(true); 563 var input = endClone.querySelectorAll('input'), 564 name = input[0].name; 565 btnClone.onclick = function(e) { 566 addField(e); 567 } 568 input[0].value = ''; 569 input[0].name = nameReplace(name, date); 570 input[0].removeAttribute('required'); 571 date.push(endClone); 572 date.push(btnClone); 573 var parent = date[0].parentNode; 574 parent.innerHTML = ''; 575 for(var i = 0; i < date.length; i++) parent.appendChild(date[i]); 576 577 jQuery(function($) { 578 $('input[name="' + input[0].name + '"]').flatpickr({ 579 dateFormat: "d.m.Y", 580 allowInput: true, 581 locale: 'ru', 582 }); 583 }); 584 } 585 586 function addText(text, e) { 587 var endClone = text[text.length - 1].cloneNode(true), 588 btnClone = e.target.cloneNode(true), 589 textArea = endClone.querySelectorAll('textarea'), 590 name = textArea[0].name; 591 btnClone.onclick = function(e) { 592 addField(e); 593 } 594 var newText = document.createElement('textarea'), 595 conText = document.createElement('div'); 596 conText.className = 'form-group'; 597 conText.setAttribute('data-property-field', 'text'); 598 newText.name = nameReplace(name, text); 599 newText.className = 'form-control'; 600 newText.removeAttribute('required'); 601 newText.rows = textArea[0].rows; 602 newText.cols = textArea[0].cols; 603 conText.appendChild(newText); 604 text.push(conText); 605 text.push(btnClone); 606 var parent = text[0].parentNode; 607 parent.innerHTML = ''; 608 for(var i = 0; i < text.length; i++) parent.appendChild(text[i]); 609 } 610 611 function nameReplace(name, text) { 612 /*var startIndex = name.indexOf('[n', 0); 613 var length = 2; 614 if (startIndex < 0) { 615 startIndex = name.indexOf('[', 0); 616 length = 1; 617 } 618 619 if(text.length > 11) { 620 var index = name.substr(startIndex + length, 2); 621 var name = name.substr(0, name.length - 3); 622 } 623 else { 624 var index = name.substr(startIndex + length, 1); 625 var name = name.substr(0, name.length - 2); 626 } 627 628 name += (Number(index)) + rand() + ']';*/ 629 630 var name_arr = name.split('[n'); 631 var n_index = name_arr.pop(); 632 if (n_index && name_arr.length > 0) 633 { 634 n_index = '0' + n_index.replace(/\D+/g,""); 635 n_index = parseInt(n_index); 636 n_index ++; 637 name = name_arr.join('[n'); 638 name += '[n' + n_index + ']'; 639 } 640 else 641 { 642 var name_arr = name.split('['); 643 name_arr.pop();
644 name = name_arr.join('['); 645 name += '[n0]'; 646 } 647 648 return name; 649 } 650 651 function fieldIncrementName(name, text) { 652 var limit = name.substr(name.indexOf('[n', 0) + 2), 653 index = name.substr(name.indexOf('[n', 0) + 2, limit.length - 2), 654 name = name.substr(0, name.indexOf('[n', 0) + 2); 655 index++; 656 return name + index + '1]'; 657 } 658 659 function addEntity(entity, e) { 660 var cI = entity[entity.length - 1].cloneNode(true), 661 cB = e.target.cloneNode(true), 662 inp = cI.querySelectorAll('input'), 663 id = inp[0].id, 664 btn = inp[1].getAttribute('onclick'), 665 name = inp[0].name, 666 randId = rand(); 667 668 cB.onclick = function(e) { 669 addField(e); 670 } 671 btn = btn.replace(id, randId); 672 inp[0].value = ''; 673 inp[0].name = nameReplace(name, entity); 674 inp[0].setAttribute('id', randId); 675 inp[1].setAttribute('onclick', btn); 676 entity.push(cI); 677 entity.push(cB); 678 var parent = entity[0].parentNode; 679 parent.innerHTML = ''; 680 for(var j = 0; j < entity.length; j++) parent.appendChild(entity[j]); 681 } 682 683 684 // #region Link 685 686 var link = document.body.querySelectorAll('.container-link'); 687 for(var k = 0; k < link.length; k++) { 688 var container = link[k].querySelectorAll('.property_link'); 689 for(var w = 0; w < container.length; w++) { 690 var input = container[w].querySelectorAll('input'); 691 var select = container[w].querySelector('select'); 692 for(var h = 0; h < input.length; h++) { 693 if(input[h].hasAttribute('data-protocol')) { 694 deleteSpace(input[h]); 695 replaiceProtocol(select, input[h]); 696 identifyProtocol(input[h]); 697 } 698 } 699 } 700 } 701 702 /* window.addEventListener('click', function(e) { 703 var el = e.target; 704 if(el.oninput != null) 705 identifyProtocol(el); 706 if(el.hasAttribute('data-protocol')) 707 identifyProtocol(el); 708 });*/ 709 710 function deleteSpace(input) { 711 var str = ''; 712 for(var s = 0; s < input.value.length; s++) if(input.value[s] != ' ') str += input.value[s]; 713 input.value = str; 714 } 715 716 function identifyProtocol(el) { 717 if(el.hasAttribute('data-protocol')) { 718 var input = el; 719 var select = el.parentNode.querySelector('select'); 720 if(input != null) { 721 if(input.hasAttribute('data-protocol')) { 722 el.elSelect = select; 723 select.elInput = el; 724 el.oninput = function(e) { 725 let input = e.currentTarget; 726 replaiceProtocol(input.elSelect, input); 727 } 728 select.addEventListener('change', function(e) { 729 var sel = e.currentTarget; 730 replaiceProtocol(sel, sel.elInput); 731 }) 732 } 733 } 734 } 735 } 736 737 function replaiceProtocol(select, input) { 738 deleteSpace(input); 739 var fullLink = select.parentNode.querySelector('input[data-link-full=""]'); 740 for(var j = 0; j < select.options.length; j++) { 741 var options = select.options[j]; 742 if(input.value.substring(0, options.value.length) == options.value) { 743 select.selectedIndex = j; 744 input.value = input.value.substring(options.value.length, input.value.length); 745 select.options[j].setAttribute('selected', ''); 746 select.options[j].selected = true; 747 } else if(input.value.substring(0, 1) === '/') { 748 select.selectedIndex = 2; 749 select.options[2].selected = true; 750 select.options[2].setAttribute('selected', ''); 751 } else if(input.value.substring(0, options.value.length) === './') { 752 select.selectedIndex = 3; 753 select.options[3].selected = true; 754 select.options[3].setAttribute('selected', ''); 755 } else if(input.value.substring(0, options.value.length) === '../') { 756 select.selectedIndex = 4; 757 select.options[4].selected = true; 758 select.options[4].setAttribute('selected', ''); 759 } 760 } 761 if(input.value != "") fullLink.value = setFullLink(select) + input.value; 762 else fullLink.value = ''; 763 } 764 765 function setFullLink(select) { 766 for(var k = 0; k < select.options.length; k++) if(select.options[k].selected) return select.options[k].value; 767 return false; 768 } 769 770 if(isTrue(cond)) { 771 for(var k = 0; k < cond.length; k++) { 772 var el = cond[k], 773 event = new Event('change'); 774 el.dispatchEvent(event); 775 } 776 } 777 778 // #endregion Link 779 780 SF.SFSetUrlVar = function(id, el_id) {
781 var obj_ta = BX(el_id); 782 //IE 783 if (document.selection) { 784 obj_ta.focus(); 785 var sel = document.selection.createRange(); 786 sel.text = id; 787 //var range = obj_ta.createTextRange(); 788 //range.move('character', caretPos); 789 //range.select(); 790 } 791 //FF 792 else if (obj_ta.selectionStart || obj_ta.selectionStart == '0') 793 { 794 var startPos = obj_ta.selectionStart; 795 var endPos = obj_ta.selectionEnd; 796 var caretPos = startPos + id.length; 797 obj_ta.value = obj_ta.value.substring(0, startPos) + id + obj_ta.value.substring(endPos, obj_ta.value.length); 798 obj_ta.setSelectionRange(caretPos, caretPos); 799 obj_ta.focus(); 800 } 801 else 802 { 803 obj_ta.value += id; 804 obj_ta.focus(); 805 } 806 807 BX.fireEvent(obj_ta, 'change'); 808 obj_ta.focus(); 809} 810 811 812'use strict'; 813 814;( function ( document, window, index ) { 815 var inputs = document.querySelectorAll( '[data-file=""]' ); 816 817 Array.prototype.forEach.call( inputs, function( input ) 818 { 819 var label = input.nextElementSibling, 820 labelVal = label.innerHTML; 821 822 input.addEventListener( 'change', function(e) { 823 var fileName = ''; 824 if( this.files && this.files.length > 1 ) 825 fileName = ( this.getAttribute( 'data-multiple-caption' ) || '' ).replace( '{count}', this.files.length ); 826 else fileName = e.target.value.split( '\\' ).pop(); 827 828 if( fileName ) { 829 if(fileName.length > 16) 830 label.querySelector( 'span' ).innerHTML = fileName.slice(0, 16) + '...'; 831 else label.querySelector( 'span' ).innerHTML = fileName; 832 } 833 else label.innerHTML = labelVal; 834 835 // ÐÐ»Ñ ÑвойÑÑв 836 var el = e.target; 837 if(el.hasAttribute('data-inactive')) 838 el.parentNode.parentNode.classList.remove('sf4_property_inactive') 839 }); 840 841 // Firefox bug fix 842 input.addEventListener( 'focus', function(){ input.classList.add( 'has-focus' ); }); 843 input.addEventListener( 'blur', function(){ input.classList.remove( 'has-focus' ); }); 844 }); 845}( document, window, 0 )); 846 847 848}; 849 850 851try { 852 property(); 853} catch(error) { 854 window.addEventListener('DOMContentLoaded', function(e) { 855 property(); 856 }); 857} 858 859 860 861 862 863SF.send = function(event, element) { 864 if(document.createEvent){ 865 var e = document.createEvent('Events'); 866 e.initEvent(event, true, false); 867 } 868 else if(document.createEventObject()) { 869 var e = document.createEventObject(); 870 } 871 else return; 872 873 if(element.dispatchEvent) 874 element.dispatchEvent(e); 875 else if(element.fireEvent) element.fireEvent(event, e); 876} 877 878SF.receive = function(event, el, handler) { 879 if(window.addEventListener) 880 el.addEventListener(event, handler, false); 881 else if(window.attachEvent) 882 el.attachEvent(event, handler); 883} 884 885SF.receive('open-setting', window, property); 886
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.