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