1var icms = icms || {}; 2 3$(function(){ 4 for(var module in icms){ 5 if ( typeof(icms[module].onDocumentReady) === 'function' ) { 6 icms[module].onDocumentReady(); 7 } 8 } 9}); 10 11icms.template = (function ($) { 12 13 this.onDocumentReady = function(){ 14 this.initWidgetTabbed(); 15 this.initScrollTop(); 16 this.initTooltip(); 17 this.initCookieAlert(); 18 }; 19 20 this.initTooltip = function(){ 21 $('[data-toggle="tooltip"]').tooltip({trigger : 'hover'}); 22 }; 23 24 this.initWidgetTabbed = function(){ 25 $('.icms-widget__tabbed').each(function(){ 26 $('.nav.nav-tabs .nav-link', $(this)).click(function(){ 27 var wid = $(this).data('id'); 28 $('.links-wrap', $(this).closest('.card-header')).hide(); 29 $('#widget-links-'+wid).show(); 30 }); 31 }); 32 }; 33 34 this.initCookieAlert = function(){ 35 var block = $('#icms-cookiealert'); 36 if($(block).length === 0){ return; } 37 if(localStorage.getItem('cookiealert_hide')){ return; } 38 $(window).one('scroll', function() { 39 $(block).addClass('show'); 40 }); 41 $('.acceptcookies', block).on('click', function(t) { 42 localStorage.setItem('cookiealert_hide', 1); 43 $(block).removeClass('show'); 44 }); 45 }; 46 47 this.initScrollTop = function(){ 48 var link = $('#scroll-top'); 49 if($(link).length === 0){ return; } 50 if($(window).scrollTop() > 350){ 51 $(link).addClass('position-fixed'); 52 } 53 $(window).on('scroll', function() { 54 if($(this).scrollTop() > 350){ 55 $(link).addClass('position-fixed'); 56 } else { 57 $(link).removeClass('position-fixed'); 58 } 59 }); 60 $(link).on('click', function(t) { 61 $('html, body').scrollTop(0); 62 t.preventDefault(); 63 }); 64 }; 65 66 this.copyToBuffer = function (text, copy_text) { 67 68 let textArea = document.createElement("textarea"); 69 textArea.value = text; 70 textArea.class = 'd-none'; 71 document.body.appendChild(textArea); 72 textArea.select(); 73 document.execCommand("Copy"); 74 textArea.remove(); 75 76 copy_text = copy_text || 'СкопиÑовано'; 77 78 if(typeof (toastr) === 'undefined'){ 79 alert(copy_text); 80 } else { 81 toastr.success(copy_text); 82 } 83 84 return false; 85 }; 86 87 return this; 88 89}).call(icms.template || {},jQuery); 90 91icms.menu = (function ($) { 92 93 this.onDocumentReady = function(){ 94 95 this.horizontalMenuAutoScroll(); 96 97 var device_type = $('body').data('device'); 98 99 if(device_type === 'desktop'){ 100 $('.icms-menu-hovered a.dropdown-toggle').on( 'click', function (e) { 101 e.stopPropagation(); 102 }); 103 } else { 104 105 $('.dropdown-menu a.dropdown-toggle').on( 'click', function (e) { 106 var $el = $(this); 107 $el.toggleClass('active-dropdown'); 108 if (!$( this ).next().hasClass('show')) { 109 $( this ).parents('.dropdown-menu').first().find('.show').removeClass('show'); 110 } 111 $(this).next('.dropdown-menu').toggleClass('show'); 112 113 $(this).closest('li').toggleClass('show'); 114 115 $(this).parents('li.nav-item.dropdown.show').on('hidden.bs.dropdown', function ( e ) { 116 $('.dropdown-menu .show').removeClass('show'); 117 $el.removeClass('active-dropdown'); 118 }); 119 return false; 120 }); 121 122 $('.nav-item.dropdown').each(function (){ 123 var link = $(this).find('>a'); 124 if(link.attr('href').charAt(0) === '/'){ 125 $(this).find('>ul').append('<li class="dropdown-divider"></li>').append('<li class="nav-item"><a class="dropdown-item" href="'+link.attr('href')+'" >'+LANG_ALL+'</a></li>'); 126 } 127 }); 128 129 $('.icms-user-menu').each(function (){ 130 $(this).on('show.bs.dropdown', function () { 131 $('body').addClass('overflow-hidden'); 132 }).on('hide.bs.dropdown', function () { 133 $('body').removeClass('overflow-hidden'); 134 }); 135 var avatar = $(this).find('.icms-user-menu__summary .icms-user-avatar').clone(); 136 $(avatar).on('click', function(){ return false; }); 137 var nickname = $('<span class="ml-3 text-white">'+$(this).find('.icms-user-menu__nickname').text()+'</span>'); 138 $(nickname).on('click', function(){ return false; }); 139 var header = $('<li class="bg-primary d-flex align-items-center m-0 h5 p-3"><button type="button" class="btn ml-auto text-white p-0"><svg viewBox="0 0 352 512" style="width: 1rem;"><path d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"></path></svg></button></li>'); 140 $(header).prepend(nickname); 141 $(header).prepend(avatar); 142 $(this).find('.icms-user-menu__items').prepend(header); 143 }); 144 145 } 146 }; 147 148 this.horizontalMenuAutoScroll = function(){ 149 $('.mobile-menu-wrapper').each(function(){ 150 let active_link = $(this).find('.active'); 151 if(active_link.length > 0){ 152 $(active_link).get(0).scrollIntoView({block: "end", inline: "nearest"}); 153 } 154 }); 155 }; 156 157 this.initSwipe = function(selector, params){ 158 return $(selector).slick($.extend({ 159 infinite: false,
160 arrows: false, 161 mobileFirst: true, 162 variableWidth: false, 163 responsive: [ 164 {breakpoint: 1024, settings: "unslick"}, 165 {breakpoint: 650, settings: {slidesToShow: 3, slidesToScroll: 3}}, 166 {breakpoint: 320, settings: {slidesToShow: 2, slidesToScroll: 2}} 167 ] 168 }, (params ? params : {}))); 169 }; 170 171 return this; 172 173}).call(icms.menu || {},jQuery); 174 175icms.forms = (function ($) { 176 177 this.wysiwygs_insert_pool = {insert: {}, add: {}, init: {}, save: {}}; 178 this.submitted = false; 179 this.form_changed = false; 180 this.csrf_token = false; 181 182 var _this = this; 183 184 this.addWysiwygsInsertPool = function (field_name, callback){ 185 this.wysiwygs_insert_pool.insert[field_name] = callback; 186 }; 187 188 this.addWysiwygsAddPool = function (field_name, callback){ 189 this.wysiwygs_insert_pool.add[field_name] = callback; 190 }; 191 192 this.addWysiwygsInitPool = function (field_name, callback){ 193 this.wysiwygs_insert_pool.init[field_name] = callback; 194 }; 195 196 this.addWysiwygsSavePool = function (field_name, callback){ 197 this.wysiwygs_insert_pool.save[field_name] = callback; 198 }; 199 200 this.wysiwygBeforeSubmit = function (){ 201 for(var field_name in this.wysiwygs_insert_pool.save) { 202 if(this.wysiwygs_insert_pool.save.hasOwnProperty(field_name)){ 203 if (typeof(this.wysiwygs_insert_pool.save[field_name]) === 'function') { 204 this.wysiwygs_insert_pool.save[field_name](field_name); 205 } 206 } 207 } 208 return this; 209 }; 210 211 this.wysiwygInit = function (field_name){ 212 if (typeof(this.wysiwygs_insert_pool.init[field_name]) === 'function') { 213 this.wysiwygs_insert_pool.init[field_name](field_name); 214 } 215 return this; 216 }; 217 218 this.wysiwygInsertText = function (field_name, text){ 219 if (typeof(this.wysiwygs_insert_pool.insert[field_name]) === 'function') { 220 this.wysiwygs_insert_pool.insert[field_name](field_name, text); 221 } else { 222 $('#'+field_name).val(text).focus(); 223 } 224 return this; 225 }; 226 227 this.wysiwygAddText = function (field_name, text){ 228 if (typeof(this.wysiwygs_insert_pool.add[field_name]) === 'function') { 229 this.wysiwygs_insert_pool.add[field_name](field_name, text); 230 } else { 231 addTextToPosition($('#'+field_name), text); 232 } 233 return this; 234 }; 235 236 this.getCsrfToken = function (){ 237 if(this.csrf_token === false){ 238 this.csrf_token = $('meta[name="csrf-token"]').attr('content'); 239 } 240 return this.csrf_token; 241 }; 242 243 this.setCsrfToken = function (csrf_token){ 244 this.csrf_token = csrf_token; 245 }; 246 247 this.getFilterFormParams = function(form){ 248 249 var form_params = _this.toJSON(form); 250 251 var o = {}; 252 for(var name in form_params){if(form_params.hasOwnProperty(name)){ 253 if(name === 'page'){ continue; } 254 if(form_params[name] && form_params[name] !== ''){ 255 o[name] = form_params[name]; 256 } 257 }} 258 259 return o; 260 261 }; 262 263 this.initFilterForm = function(selector){ 264 265 var form = $(selector); 266 267 var filter_panel = $(form).closest('.icms-filter-panel'); 268 269 var filter_link_open = $(filter_panel).find('.icms-filter-link__open'); 270 var filter_link_close = $(filter_panel).find('.icms-filter-link__close'); 271 272 $(filter_link_open).on('click', function (){ 273 $(this).addClass('d-none'); 274 $(filter_panel).find('.icms-filter-container').removeClass('d-none'); 275 return false; 276 }); 277 $(filter_link_close).on('click', function (){ 278 $(filter_panel).find('.icms-filter-container').addClass('d-none'); 279 $(filter_link_open).removeClass('d-none'); 280 return false; 281 }); 282 283 var change = function (){ 284 285 var sbutton = $(form).find('.buttons button[type = submit]'); 286 287 $(sbutton).prop('disabled', true).addClass('is-busy'); 288 289 var o = _this.getFilterFormParams(form); 290 var submit_uri; 291 292 if(Object.keys(o).length > 0 || $(form).find('.cancel_filter_link').length === 0){ 293 submit_uri = $(form).attr('action'); 294 } else { 295 submit_uri = $(form).find('.cancel_filter_link').attr('href'); 296 } 297 298 o.show_count = 1; 299 300 var query_string = $.param(o); 301 302 $.get(submit_uri+'?'+query_string, function(result){ 303 if(result.filter_link){ 304 $(form).data('filter_link', result.filter_link); 305 } else { 306 $(form).removeData('filter_link'); 307 } 308 setTimeout(function (){ 309 $(sbutton).removeClass('is-busy').val(result.hint).prop('disabled', false).find('span').text(result.hint); 310 }, 200); 311 icms.events.run('icms_content_filter_changed', form); 312 }, 'json'); 313 314 }; 315
316 var delay = function () { 317 var timer = 0; 318 return function () { 319 var context = this, args = arguments; 320 clearTimeout(timer); 321 timer = setTimeout(function () { 322 change.apply(context, args); 323 }, 500); 324 }; 325 }; 326 327 $(form).find('select, input[type=checkbox]').on('change', change); 328 $(form).find('input:not([type=checkbox]), textarea').on('input', delay()); 329 330 $(form).find('.buttons button[type = submit]').on('click', function (){ 331 332 var filter_link = $(form).data('filter_link'); 333 334 if(filter_link){ 335 window.location.href = filter_link; 336 return false; 337 } 338 339 var submit_uri = $(form).attr('action'); 340 341 var o = _this.getFilterFormParams(form); 342 343 var query_string = $.param(o); 344 345 if(query_string.length > 0){ 346 window.location.href = submit_uri+'?'+query_string; 347 } else { 348 349 var cancel_filter_link = $(form).find('.cancel_filter_link').attr('href'); 350 351 if(!cancel_filter_link){ 352 cancel_filter_link = submit_uri; 353 } 354 355 window.location.href = cancel_filter_link; 356 } 357 358 return false; 359 360 }); 361 362 }; 363 364 this.initFormHelpers = function(){ 365 $('body').on('focus', '.field.ft_string input, .field.ft_text textarea', function (){ 366 $('.pattern_fields_panel').hide(); 367 $('.pattern_fields_panel_hint').show(); 368 $(this).closest('.field').find('.pattern_fields_panel_hint').hide(); 369 $(this).closest('.field').find('.pattern_fields_panel').show(); 370 }); 371 $('body').on('click', '.pattern_fields > ', function (){ 372 var spacer = $(this).closest('.hint').data('spacer') || false; 373 var spacer_stop = $(this).closest('.hint').data('spacer_stop') || false; 374 var id = $(this).closest('.icms-forms-pattern__fields').data('for_id'); 375 if (typeof(_this.wysiwygs_insert_pool.add[id]) === 'function') { 376 _this.wysiwygs_insert_pool.add[id](id, $(this).text()); return false; 377 } 378 return addTextToPosition($('#'+id), $(this).text(), spacer, spacer_stop); 379 }); 380 381 $('.auto_copy_value').on('click', function (){ 382 $(this).closest('.input-prefix-suffix').find('input').val($(this).data('value')); 383 return false; 384 }); 385 }; 386 387 this.initUnsaveNotice = function(){ 388 389 var init_data = {}; 390 391 $('form').each(function(i){ 392 init_data[i] = _this.toJSON($(this)); 393 $(this).attr('data-notice_id', i); 394 }); 395 396 $(document).on('change', '.form-tabs input, .form-tabs select, .form-tabs textarea', function (e) { 397 var form = $(this).closest('form'); 398 _this.form_changed = (JSON.stringify(init_data[form.attr('data-notice_id')]) !== JSON.stringify(_this.toJSON(form))) ? true : false; 399 }); 400 $(document).on('submit', 'form', function () { 401 $(this).find('.button-submit').addClass('disabled is-busy'); 402 icms.forms.submitted = true; 403 }); 404 $(window).on('beforeunload', function (e) { 405 if (icms.forms.form_changed && !icms.forms.submitted) { 406 var e = e || window.event; 407 var msg = LANG_SUBMIT_NOT_SAVE; 408 if (e) { 409 e.returnValue = msg; 410 } 411 return msg; 412 } 413 }); 414 415 }; 416 417 this.initCollapsedFieldset = function(form_id){ 418 $('#'+form_id).on('click', '.is_collapsed legend', function (){ 419 var _fieldset = $(this).closest('.is_collapsed'); 420 $(_fieldset).toggleClass('is_collapse do_expand'); 421 $.cookie('icms[fieldset_state]['+$(_fieldset).attr('id')+']', $(_fieldset).hasClass('do_expand')); 422 }); 423 $('.is_collapsed', $('#'+form_id)).each(function (){ 424 if($(this).find('.field_error').length > 0 || $.cookie('icms[fieldset_state]['+$(this).attr('id')+']') === 'true'){ 425 $(this).addClass('do_expand').removeClass('is_collapse'); return; 426 } 427 }); 428 }; 429 430 this.toJSON = function(form) { 431 _this.wysiwygBeforeSubmit(); 432 var o = {}; 433 var a = form.serializeArray(); 434 $.each(a, function() { 435 if (o[this.name] !== undefined) { 436 if (!o[this.name].push) { 437 o[this.name] = [o[this.name]]; 438 } 439 o[this.name].push(this.value || ''); 440 } else { 441 o[this.name] = this.value || ''; 442 } 443 }); 444 return o; 445 }; 446 447 this.submit = function(selector){ 448 selector = selector || '.button-submit'; 449 icms.forms.submitted = true; 450 $(selector).addClass('disabled is-busy').trigger('click'); 451 }; 452 453 this.initFieldsetChildList = function (form_id){ 454 $('#'+form_id+' .icms-form-tab__demand').each(function (){ 455 var demand_wrap = $(this).attr('href'); 456 var url = $(this).data('parent_url'); 457 $('#'+$(this).data('parent')).on('change', function (){ 458 var value = $(this).val(); 459 $.post(url, {value: value, form_id: form_id}, function(result){ 460 $(demand_wrap).html(result); 461 }, 'html'); 462 }); 463 }); 464 }; 465 466 this.updateChildList = function (child_id, url, value, current_value, filter_field_name) { 467 468 var child_list = $('#' + child_id); 469 470 $('#f_' + child_id + ' label').addClass('loading'); 471 472 child_list.html(''); 473 474 current_value = current_value || ''; 475 476 if (!$.isArray(current_value)) { 477 current_value = [current_value]; 478 } 479 480 $.post(url, {value: value, filter_field_name: filter_field_name}, function (result) { 481 482 for (var k in result) { 483 if (result.hasOwnProperty(k)) { 484 if (typeof result[k].value !== 'undefined') { 485 var _value = result[k].value; 486 var title = result[k].title; 487 } else { 488 var _value = k; 489 var title = result[k]; 490 } 491 child_list.append('<option value="' + _value + '"' + ($.inArray(_value, current_value) !== -1 ? ' selected' : '') + '>
491' + title + '</option>'); 492 } 493 } 494 495 $(child_list).trigger('chosen:updated'); 496 497 $('#f_' + child_id + ' label').removeClass('loading'); 498 499 icms.events.run('icms_forms_updatechildlist', { 500 result: result, 501 child_id: child_id, 502 value: value, 503 current_value: current_value, 504 filter_field_name: filter_field_name 505 }); 506 507 }, 'json'); 508 509 }; 510 511 this.submitAjax = function(form, additional_params){ 512 513 icms.forms.submitted = true; 514 515 /** 516 * СовмеÑÑимоÑÑÑ, пеÑедаÑÑÑÑ Ð² колбÑк 517 * @type coreforms.toJSON.o 518 */ 519 var form_data = this.toJSON($(form)); 520 521 var submit_btn = $(form).find('.button-submit'); 522 523 $(submit_btn).prop('disabled', true).addClass('is-busy'); 524 525 var formData = new FormData(form); 526 527 if(additional_params){ 528 for(var name in additional_params){ 529 formData.append(name, additional_params[name]); 530 } 531 } 532 533 $.ajax({ 534 url: $(form).attr('action'), 535 method: 'POST', 536 data: formData, 537 success: function (result) { 538 539 $('.field_error', form).removeClass('field_error'); 540 $('.is-invalid', form).removeClass('is-invalid'); 541 $('.invalid-feedback', form).remove(); 542 543 $(submit_btn).prop('disabled', false).removeClass('is-busy'); 544 545 if (result.errors === false){ 546 if ("callback" in result){ 547 548 var params = result.callback.split('.'); 549 550 var calling_func = window; 551 for(var id in params){ 552 calling_func = calling_func[params[id]]; 553 } 554 555 calling_func.apply(form, [form_data, result]); 556 557 return; 558 } 559 $('input[type=text], select, textarea', form).val('').triggerHandler('input'); 560 if (result.success_text){ 561 icms.modal.alert(result.success_text); 562 } 563 if (result.redirect_uri){ 564 window.location.href = result.redirect_uri; 565 } 566 return; 567 } 568 569 if (typeof(result.errors) === 'object'){ 570 if(result.message){ 571 icms.modal.alert(result.message, 'danger'); 572 } 573 for(var field_id in result.errors){ 574 var id = field_id.replace(':', '_'); 575 $('#'+id, form).addClass('is-invalid'); 576 $('#f_'+id, form).addClass('field_error').append('<div class="invalid-feedback">' + result.errors[field_id] + '</div>'); 577 $(form).find('ul.tabbed > li > a[href = "#'+$('#f_'+id, form).parents('.tab').attr('id')+'"]').trigger('click'); 578 } 579 580 icms.events.run('icms_forms_submitajax', result); 581 582 icms.modal.resize(); 583 584 icms.forms.submitted = false; 585 586 return; 587 588 } 589 }, 590 error: function (error) { 591 $(submit_btn).prop('disabled', false).removeClass('is-busy'); 592 icms.modal.alert('<div>Status: '+error.status+'</div>'+error.responseText, 'danger'); 593 }, 594 dataType: 'json', 595 cache: false, 596 contentType: false, 597 processData: false 598 }); 599 600 return false; 601 }; 602 603 this.initSymbolCount = function (field_id, max, min){ 604 $('#'+field_id).wrap("<div class='icms-form__symbols_count_wrap position-relative'></div>"); 605 $('#f_'+field_id+' .icms-form__symbols_count_wrap').append('<div class="symbols_count"><span class="symbols_num"></span></div>'); 606 var symbols_count = $('#f_'+field_id+' .symbols_count'); 607 var symbols_num = $('.symbols_num', symbols_count); 608 if(max){ 609 var type = 'left'; 610 } else { 611 var type = 'total'; 612 } 613 614 var field_id_el = $('#'+field_id); 615 616 $(symbols_num).on('click', function (){ 617 if(max){ 618 if(type === 'total'){ 619 type = 'left'; 620 } else { 621 type = 'total'; 622 } 623 render_symbols_count(); 624 } 625 }); 626 var render_symbols_count = function (){ 627 var num = +$(field_id_el).val().length; 628 if(!num){ 629 $(symbols_num).html(''); $(symbols_count).hide(); return; 630 } 631 if(min){ if(num < min){ 632 $(symbols_num).addClass('overflowing_min'); 633 } else { 634 $(symbols_num).removeClass('overflowing_min'); 635 }} 636 if(max && num > max){ 637 $(symbols_num).addClass('overflowing'); 638 } else { 639 $(symbols_num).removeClass('overflowing'); 640 } 641 if(type === 'total'){ 642 $(symbols_count).fadeIn(); 643 $(symbols_num).html(num); 644 } else { 645 $(symbols_count).fadeIn(); 646 if(num > max){ 647 num = max; 648 $(field_id_el).val($(field_id_el).val().substr(0, max)); 649 } 650 $(symbols_num).html((max - num)); 651 } 652 }; 653 $(field_id_el).on('input', render_symbols_count); 654 icms.events.on('autocomplete_select', function(){ render_symbols_count(); }); 655 render_symbols_count(); 656 }; 657 658 this.getInputVal = function(el){ 659 if($(el).is(':checkbox,:radio')){ 660 var v = $(el+':checked').val(); 661 return typeof v === 'undefined' ? '0' : v; 662 } 663 return $(el).val(); 664 }; 665 this.inputNameToId = function(name){ 666 name = name.replace(/\:|\|/g,'_'); 667 return name; 668 }; 669 this.inputNameToElName = function(name){ 670 name = name.split(':'); 671 return (typeof name !== 'string' && name.length > 1) ? name.shift()+'['+name.join('][')+']' : name; 672 }; 673 this.VDisDisplay = function(field_value, type){ 674 var display; 675 if (Array.isArray(field_value) && field_value.length > 0) { 676 for (var show_key in type) { 677 if ($.inArray(type[show_key], field_value) !== -1) { 678 display = true; 679 } else { 680 display = false;
681 break; 682 } 683 } 684 } else { 685 if (Array.isArray(field_value)) { 686 field_value = ''; 687 } 688 if ($.inArray(field_value, type) !== -1) { 689 return true; 690 } else { 691 display = false; 692 } 693 } 694 return display; 695 }; 696 this.VDListeners = {}; 697 this.VDListenersInitialized = []; 698 this.VDRules = {from:{},depends:{}}; 699 this.addVisibleDepend = function(form_id, field_id, rules){ 700 /* здеÑÑ Ð²Ñе завиÑимоÑÑи Ð¿Ð¾Ð»Ñ field_id */ 701 if(typeof this.VDRules.depends[form_id+'-'+field_id] === 'undefined'){ 702 /* array('is_cats' => array('show' => array('1'))) */ 703 this.VDRules.depends[form_id+'-'+field_id] = rules; 704 } else { 705 $.extend(this.VDRules.depends[form_id+'-'+field_id], rules); 706 } 707 for(var f in rules){if(rules.hasOwnProperty(f)){ 708 if(typeof this.VDRules.from[form_id+'-'+f] === 'undefined'){this.VDRules.from[form_id+'-'+f] = {};} 709 /* здеÑÑ Ð²Ñе, кÑо завиÑÐ¸Ñ Ð¾Ñ Ð¿Ð¾Ð»Ñ f */ 710 if(typeof this.VDRules.from[form_id+'-'+f][field_id] === 'undefined'){ 711 /* array('show' => array('1')) */ 712 this.VDRules.from[form_id+'-'+f][field_id] = rules[f]; 713 } else { 714 $.extend(this.VDRules.from[form_id+'-'+f][field_id], rules[f]); 715 } 716 if(typeof this.VDListeners[form_id+'-'+f] === 'undefined'){ 717 this.VDListeners[form_id+'-'+f] = '#'+form_id+' [name="'+this.inputNameToElName(f)+'"]'; 718 let field_obj = $(this.VDListeners[form_id+'-'+f]); 719 let field_event = field_obj.attr('type') === 'text' ? 'input' : 'change'; 720 field_obj.on(field_event, function (){ 721 722 let name = $(this).attr('name').replace(/\[/g, ':').replace(/\]/g, ''); 723 724 /* пеÑÐµÐ±Ð¾Ñ ÑÐµÑ , кÑо завиÑÐ¸Ñ Ð¾Ñ ÑÑого Ð¿Ð¾Ð»Ñ name */ 725 for(var field in _this.VDRules.from[form_id+'-'+name]){if(_this.VDRules.from[form_id+'-'+name].hasOwnProperty(field)){ 726 727 /* еÑли не бÑÐ´ÐµÑ show */ 728 var display = null; 729 730 /* пеÑÐµÐ±Ð¾Ñ ÑÐµÑ , Ð¾Ñ ÐºÐ¾Ð³Ð¾ завиÑÐ¸Ñ Ð¿Ð¾Ð»Ðµ field */ 731 for(var _from in _this.VDRules.depends[form_id+'-'+field]){if(_this.VDRules.depends[form_id+'-'+field].hasOwnProperty(_from)){ 732 if(typeof _this.VDRules.depends[form_id+'-'+field][_from]['show'] !== 'undefined'){ 733 display = _this.VDisDisplay(_this.getInputVal('#'+form_id+' [name="'+_this.inputNameToElName(_from)+'"]'), _this.VDRules.depends[form_id+'-'+field][_from]['show']); 734 if(display === true){ break; } 735 } 736 }} 737 738 if(display === null){display = true;} 739 740 /* ÑкÑÑÑие ÑилÑнее показа */ 741 if(display){ 742 /* пеÑÐµÐ±Ð¾Ñ ÑÐµÑ , Ð¾Ñ ÐºÐ¾Ð³Ð¾ завиÑÐ¸Ñ Ð¿Ð¾Ð»Ðµ field */ 743 for(var _from in _this.VDRules.depends[form_id+'-'+field]){if(_this.VDRules.depends[form_id+'-'+field].hasOwnProperty(_from)){ 744 if(typeof _this.VDRules.depends[form_id+'-'+field][_from]['hide'] !== 'undefined'){ 745 display = !_this.VDisDisplay(_this.getInputVal('#'+form_id+' [name="'+_this.inputNameToElName(_from)+'"]'), _this.VDRules.depends[form_id+'-'+field][_from]['hide']); 746 if(display === false){ break; } 747 } 748 }} 749 } 750 751 if(display){ 752 $('#f_'+_this.inputNameToId(field)).removeClass('hide_field').prev('.field_tabbed').removeClass('hide_field'); 753 } else { 754 $('#f_'+_this.inputNameToId(field)).addClass('hide_field').prev('.field_tabbed').addClass('hide_field'); 755 } 756 }} 757 }); 758 } 759 }} 760 return this; 761 }; 762 this.VDReInit = function(){ 763 for(var l in this.VDListeners){if(this.VDListeners.hasOwnProperty(l)){ 764 if(this.VDListenersInitialized.indexOf(this.VDListeners[l]) === -1) { 765 $(this.VDListeners[l]).triggerHandler('change'); 766 $(this.VDListeners[l]).triggerHandler('input'); 767 this.VDListenersInitialized.push(this.VDListeners[l]); 768 } 769 }} 770 }; 771 772 return this; 773 774}).call(icms.forms || {},jQuery); 775 776icms.head = (function ($) { 777 778 var self = this; 779 780 this.on_demand = {}; 781 this.loaded = {}; 782 this.loading = {}; 783 784 this.addJs = function(name, event){ 785 if(this.on_demand.js[name]){ 786 var filepath = this.on_demand.root + this.on_demand.js[name]; 787 if (this.loaded[filepath]){ 788 if(event){ 789 icms.events.run(event); 790 } 791 return; 792 } 793 if (!this.loading[filepath]){ 794 this.loading[filepath] = true; 795 var el = document.createElement('script'); 796 el.onload = function() { 797 if(event){ 798 icms.events.run(event); 799 } 800 self.loaded[filepath] = true; 801 }; 802 el.src = filepath; 803 document.body.appendChild(el); 804 } 805 } 806 return this; 807 }; 808 809 this.addCss = function(name){ 810 if(this.on_demand.css[name]){ 811 var filepath = this.on_demand.root + this.on_demand.css[name]; 812 if (!this.loading[filepath]){ 813 this.loading[filepath] = true; 814 var el = document.createElement('link'); 815 el.href = filepath; 816 el.type = 'text/css'; 817 el.rel = 'stylesheet'; 818 document.head.appendChild(el); 819 } 820 } 821 return this; 822 }; 823 824 return this; 825 826}).call(icms.head || {},jQuery); 827 828icms.events = (function ($) { 829 830 this.listeners = {}; 831 832 this.on = function(name, callback){ 833 if (typeof(this.listeners[name]) == 'object'){ 834 this.listeners[name].push(callback); 835 } else { 836 this.listeners[name] = [callback]; 837 } 838 return this; 839 }; 840 841 this.run = function(name, params){ 842 params = params || {}; 843 for(var event_name in this.listeners[name]) { 844 if(this.listeners[name].hasOwnProperty(event_name)){ 845 if (typeof(this.listeners[name][event_name]) === 'function') { 846 this.listeners[name][event_name](params); 847 } 848 } 849 } 850 return this; 851 }; 852 853 return this; 854 855}).call(icms.events || {},jQuery); 856 857icms.pagebar = function(id, initial_page, has_next, is_modal){ 858 859 initial_page = initial_page || 1; 860 861 var page = 1; 862 863 var link = $(id); 864 865 var showMore = function(){ 866 867 var list_wrap = $(link).prev(); 868 869 if(!has_next){ 870 if(initial_page > 1){ 871 return true; 872 } 873 $('body,html').animate({ 874 scrollTop: $(list_wrap).offset().top 875 }, 500 876 ); 877 return false;
878 } 879 880 $(link).addClass('is-busy'); 881 882 page += 1; 883 884 var post_params = $(link).data('url-params'); 885 post_params.page = page; 886 887 $.post($(link).data('url'), post_params, function(data){ 888 889 var first_page_url = $(link).data('first-page-url'); 890 891 $(link).removeClass('is-busy'); 892 893 if (!data.html) { return; } 894 895 has_next = data.has_next; 896 page = data.page; 897 898 $(list_wrap).append(data.html); 899 900 if(!has_next){ 901 $('span', link).html($('span', link).data('to-first')); 902 $(link).attr('href', first_page_url); 903 } 904 905 var _sep = first_page_url.indexOf('?') !== -1 ? '&' : '?'; 906 907 if(!is_modal){ 908 window.history.pushState({link: first_page_url+_sep+'page='+page}, '', first_page_url+_sep+'page='+page); 909 } 910 911 if(is_modal){ 912 icms.modal.resize(); 913 } 914 915 }, 'json'); 916 917 return false; 918 919 }; 920 921 $(link).on('click', function (){ 922 return showMore(); 923 }); 924 925}; 926 927$.expr[':'].Contains = $.expr.createPseudo(function(arg) { 928 return function( elem ) { 929 return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0; 930 }; 931}); 932function setCaretPosition(field, pos) { 933 var $field = $(field); 934 if ($field[0].setSelectionRange) { 935 $field.focus(); 936 $field[0].setSelectionRange(pos, pos); 937 } else if ($field[0].createTextRange) { 938 var range = $field[0].createTextRange(); 939 range.collapse(true); 940 range.moveEnd('character', pos); 941 range.moveStart('character', pos); 942 range.select(); 943 } 944} 945function getCaretPosition(field) { 946 var $field = $(field); 947 if($field.length){ 948 if (document.selection) { 949 $field.focus(); 950 var Sel = document.selection.createRange(); 951 Sel.moveStart ('character', -$field.val().length); 952 return Sel.text.length; 953 } else { 954 return $field[0].selectionStart || 0; 955 } 956 } 957 return 0; 958} 959function addTextToPosition(field_id, text, spacer, spacer_stop){ 960 var field = $(field_id); 961 var value = $(field).val(); 962 var pos = getCaretPosition(field); 963 var value1 = value.substring(0, pos); 964 var value2 = value.substring(pos, value.length); 965 if(spacer){ 966 var check1 = function(spacer){ // пÑовеÑка пеÑед вÑÑавлÑемÑм 967 if(value1.length >= spacer.length){ 968 if(value1.substring(pos - spacer.length, pos) !== spacer){ 969 return true; 970 } 971 } 972 return false; 973 }; 974 var check2 = function(spacer){ // пÑовеÑка поÑле вÑÑавлÑемого ÑекÑÑа 975 if(value2.length >= spacer.length){ 976 if(value2.substring(0, spacer.length) !== spacer){ 977 return true; 978 } 979 } 980 return false; 981 }; 982 var insert1 = true, insert2 = true; 983 if(spacer_stop){ 984 for(var ss in spacer_stop){if(spacer_stop.hasOwnProperty(ss)){ 985 if(insert1 && (!spacer_stop[ss] || spacer_stop[ss] == 1) && !check1(ss)){ 986 insert1 = false; 987 } 988 if(insert2 && (!spacer_stop[ss] || spacer_stop[ss] == 2) && !check2(ss)){ 989 insert2 = false; 990 } 991 }} 992 } 993 994 if(insert1 && check1(spacer)){ 995 text = spacer+text; 996 } 997 if(insert2 && check2(spacer)){ 998 text += spacer; 999 } 1000 } 1001 $(field).val(value1 + text + value2).trigger('input'); 1002 setCaretPosition(field, pos+text.length); 1003 return false; 1004} 1005function goBack(){ 1006 window.history.go(-1); 1007} 1008function spellcount (num, one, two, many){ 1009 if (num%10==1 && num%100!=11){ 1010 str = one; 1011 } else if(num%10>=2 && num%10<=4 && (num%100<10 || num%100>=20)){ 1012 str = two; 1013 } else { 1014 str = many; 1015 } 1016 return str; 1017} 1018function initMultyTabs(selector, tab_wrap_field){ 1019 tab_wrap_field = tab_wrap_field || '.field'; 1020 $(selector).each(function(indx, element){ 1021 var tab = $(' > li > a', $(this)); 1022 $(tab).eq(0).addClass('active'); 1023 $(tab).on('click', function() { 1024 var tab_field = $(this).attr('href'); 1025 $(this).addClass('active').closest('li').siblings().find('a').removeClass('active'); 1026 $(element).nextAll(tab_wrap_field+':lt('+$(tab).closest('li').length+')').hide(); 1027 $(tab_field).show(); 1028 return false;
1029 }); 1030 }); 1031}
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.