1var timerHide = false; 2window.array = []; 3 4if(!funcDefined('showToggles')) 5{ 6 showToggles = function() 7 { 8 new DG.OnOffSwitchAuto({ 9 cls:'.block-item.active .custom-switch', 10 textOn:"", 11 height:33, 12 heightTrack:16, 13 textOff:"", 14 trackColorOff:"f5f5f5", 15 listener:function(name, checked){ 16 if(window.array.indexOf(name) == -1) { 17 18 window.array.push(name); 19 setTimeout(function(){ 20 window.array.splice(window.array.indexOf(name), 1); 21 }, 500); 22 var bNested = ($('input[name='+name+']').closest('.values').length && !$('input[name='+name+']').closest('.subs').length); 23 if(checked) 24 $('input[name='+name+']').val('Y'); 25 26 else 27 $('input[name='+name+']').val('N'); 28 29 if(bNested) 30 { 31 var ajax_btn = $('<div class="btn-ajax-block animation-opacity"></div>'), 32 option_wrapper = $('input[name='+name+']').closest('.option-wrapper'), 33 pos = BX.pos(option_wrapper[0], true), 34 current_index = $('input[name='+name+']').closest('.inner-wrapper').data('key'), 35 div_class = name.replace(current_index+'_',''), 36 top = 0; 37 38 ajax_btn.html($('.values > .apply-block').html()); 39 option_wrapper.toggleClass('disabled'); 40 top = pos.top+$('.style-switcher .header').actual('outerHeight'); 41 ajax_btn.css('top',top); 42 if($('.btn-ajax-block').length) 43 $('.btn-ajax-block').remove(); 44 ajax_btn.appendTo($('.style-switcher')); 45 ajax_btn.addClass('opacity1'); 46 47 if(checked) 48 { 49 /*if(div_class == 'INSTAGRAMM') 50 { 51 if(!$('.instagram_ajax .instagram').length) 52 { 53 $('.instagram_ajax').removeClass('loaded'); 54 $.ajax({ 55 type:"POST", 56 url:arMaxOptions['SITE_DIR']+"include/mainpage/comp_instagramm.php", 57 data:{'SHOW_INSTAGRAM':'Y', 'AJAX_REQUEST_INSTAGRAM':'Y'}, 58 success:function(html){ 59 $('.instagram_ajax').html(html); 60 } 61 }) 62 } 63 } 64 else*/ if(div_class == 'WITH_LEFT_BLOCK') 65 { 66 $('.wrapper_inner.front').removeClass('wide_page'); 67 $('.wrapper1.front_page').addClass('with_left_block'); 68 $('.wrapper_inner.front .container_inner > .right_block').removeClass('wide_Y').addClass('wide_N'); 69 $('.wrapper_inner.front .container_inner > .left_block').removeClass('hidden'); 70 71 if(typeof window['stickySidebar'] !== 'undefined') 72 { 73 window['stickySidebar'].updateSticky(); 74 } 75 76 } 77 $('.drag-block[data-class='+div_class.toLowerCase()+'_drag]').removeClass('hidden'); 78 $('.templates_block .item.'+name+'').removeClass('hidden'); 79 80 InitFlexSlider(); 81 $(window).resize(); 82 83 if(div_class == 'BIG_BANNER_INDEX') 84 { 85 $('.wrapper1').addClass('long_banner'); 86 $(window).resize(); 87 } 88 if(div_class == 'MAPS' && (typeof map !== 'undefined')) 89 { 90 setTimeout(function(){ 91 map.setBounds(clusterer.getBounds(), { 92 zoomMargin: 40, 93 // checkZoomRange: true 94 }); 95 }, 200) 96 } 97 } 98 else 99 { 100 $('.drag-block[data-class='+div_class.toLowerCase()+'_drag]').addClass('hidden'); 101 $('.templates_block .item.'+name+'').addClass('hidden'); 102 103 if(div_class == 'WITH_LEFT_BLOCK') 104 { 105 $('.wrapper_inner.front').addClass('wide_page'); 106 $('.wrapper1.front_page').removeClass('with_left_block'); 107 $('.wrapper_inner.front .container_inner > .right_block').removeClass('wide_N wide_').addClass('wide_Y'); 108 $('.wrapper_inner.front .container_inner > .left_block').addClass('hidden'); 109 110 $(window).resize(); 111 } 112 113 if(div_class == 'BIG_BANNER_INDEX') 114 { 115 $('.wrapper1').removeClass('long_banner'); 116 } 117 } 118 119 var eventdata = {action:'jsLoadBlock'}; 120 BX.onCustomEvent('onCompleteAction', [eventdata]); 121 122 //save option 123 $.post( 124 arMaxOptions['SITE_DIR']+"ajax/options_save_mainpage.php", 125 { 126 VALUE: $('input[name='+name+']').val(), 127 NAME: name 128 } 129 ); 130 } 131 132 setTimeout(function(){ 133 if(!bNested) 134 $('form[name=style-switcher]').submit(); 135 },200); 136 } 137 else 138 { 139 return false;
140 } 141 } 142 }); 143 } 144} 145 146$(document).ready(function() { 147 var timerDynamicLeftSide = false; 148 149 // selected thematic is current value by default 150 var selectedThematic = arMaxOptions.THEMATICS.VALUE; 151 152 // select current thematic value 153 var restoreThematics = function(){ 154 selectedThematic = arMaxOptions.THEMATICS.VALUE; 155 selectThematic(selectedThematic, false); 156 } 157 158 // select thematic 159 var selectThematic = function(thematic, bShowPresets){ 160 var $thematic = $thematic = $('.presets .thematik .item[data-code=' + thematic + ']'); 161 if($thematic.length){ 162 if(typeof arMaxOptions.THEMATICS.LIST[thematic] === 'object'){ 163 // thematic found 164 165 // save selected value 166 selectedThematic = thematic; 167 168 // mark as current 169 $thematic.addClass('active').siblings().removeClass('active'); 170 171 // set "-" on presets`s subtab 172 $('.presets .presets_subtabs .presets_subtab .desc').html('—'); 173 174 // set thematic title on thematics`s subtab 175 $('.presets .presets_subtabs .presets_subtab:first .desc').text(arMaxOptions.THEMATICS.LIST[thematic].TITLE); 176 177 // hide all presets 178 $('.presets .presets_block .conf .item').addClass('hidden'); 179 180 // show add new preset in preset editor 181 $('.presets .presets_block .conf .item .js-addpreset').closest('.item').removeClass('hidden'); // 182 183 if(typeof BX.admin !== 'object'){ 184 // if user is not admin, than hide APPLY buttons of all presets 185 $('.presets .presets_block .conf .apply_conf_block').addClass('hidden'); 186 } 187 188 // unmark current preset 189 $('.presets .presets_block .conf .item .preset-block.current').removeClass('current'); 190 191 for(var i in arMaxOptions.THEMATICS.LIST[thematic].PRESETS.LIST){ 192 //each thematic`s preset 193 194 var preset = arMaxOptions.THEMATICS.LIST[thematic].PRESETS.LIST[i]; 195 var $presetBlock = $('.presets .presets_block .conf .item .preset-block[data-id=' + preset + ']'); 196 197 if($presetBlock.length){ 198 if(typeof arMaxOptions.PRESETS.LIST[preset] === 'object'){ 199 // show preset 200 $presetBlock.closest('.item').removeClass('hidden'); 201 202 // if selected thematic is without URL, than hide APPLY buttons of it`s presets 203 if(arMaxOptions.THEMATICS.LIST[thematic].URL.length){ 204 // show APPLY button 205 $presetBlock.find('.apply_conf_block').removeClass('hidden'); 206 } 207 208 if(arMaxOptions.THEMATICS.VALUE == thematic){ 209 // selected current thematic 210 211 // show APPLY button 212 $presetBlock.find('.apply_conf_block').removeClass('hidden'); 213 214 if(arMaxOptions.PRESETS.VALUE == preset){ 215 // current preset 216 217 // mark as current preset 218 $presetBlock.addClass('current'); 219 220 // set preset title on presets`s subtab 221 $('.presets .presets_subtabs .presets_subtab:last .desc').text(arMaxOptions.PRESETS.LIST[preset].TITLE); 222 } 223 } 224 } 225 } 226 } 227 228 if(typeof bShowPresets !== 'undefined' && bShowPresets){ 229 // open presets list 230 $('.presets .presets_subtabs .presets_subtab').last().trigger('click'); 231 } 232 233 return; 234 } 235 } 236 } 237 238 // select preset 239 var selectPreset = function(preset){ 240 var $preset = $('.style-switcher .presets .preset-block[data-id=' + preset + ']'); 241 242 if($preset.length){ 243 if( 244 // selected preset is current already or editing 245 $preset.hasClass('current') || 246 $preset.hasClass('editing') 247 ){ 248 return; 249 } 250 251 if(typeof arMaxOptions.PRESETS.LIST[preset] === 'object'){ 252 // is dev 253 var bDev = location.hostname.indexOf('dev.aspro.ru') !== -1; 254 255 // is demo 256 var bDemo = !bDev && typeof arMaxOptions.THEMATICS.LIST[selectedThematic] === 'object' && arMaxOptions.THEMATICS.LIST[selectedThematic].URL.length; 257 258 // is selected thematic not current 259 var bPrepareWizard = !bDev && !bDemo && (selectedThematic != arMaxOptions.THEMATICS.VALUE); 260 261 if(bPrepareWizard){ 262 // install new thematic 263 prepareWizard(selectedThematic, preset); 264 } 265 else{ 266 // unmark current preset 267 $('.style-switcher .presets .preset-block.current').removeClass('current'); 268 269 // mark as current 270 $preset.addClass('current'); 271 272 // set preset title on presets`s subtab 273 $preset.closest('.presets').find('.presets_subtab.active .desc').text($preset.find('.info .title').text()); 274 275 // apply preset configuration 276 setConfiguration(selectedThematic, preset); 277 } 278 } 279 } 280 } 281 282 var setConfiguration = function(thematic, preset){ 283 if(typeof arMaxOptions.THEMATICS.LIST[thematic] === 'object'){ 284 if(typeof arMaxOptions.PRESETS.LIST[preset] === 'object'){ 285 // is dev 286 var bDev = location.hostname.indexOf('dev.aspro.ru') !== -1; 287 288 // is demo 289 var bDemo = !bDev && arMaxOptions.THEMATICS.LIST[thematic].URL.length; 290 291 if(bDemo && thematic !== arMaxOptions.THEMATICS.VALUE){ 292 location.href = arMaxOptions.THEMATICS.LIST[thematic].URL + '?aspro_preset=' + preset; 293 } 294 else{ 295 // order of main page blocks 296 var order = []; 297 298 // list of options to send 299 var options = { 300 'backurl': arMaxOptions['SITE_DIR'], 301 'THEMATIC': thematic 302 }; 303 304 var serialize = $('form[name=style-switcher]').serializeArray(); 305 for(j in serialize){ 306 // add each form option value 307 options[serialize[j].name] = serialize[j].value; 308 } 309 310 if(typeof arMaxOptions.PRESETS.LIST[preset]['OPTIONS'] === 'object'){ 311 for(j in arMaxOptions.PRESETS.LIST[preset]['OPTIONS']){ 312 // change value of each preset option in options list 313 314 var val = arMaxOptions.PRESETS.LIST[preset]['OPTIONS'][j]; 315 if(typeof val !== 'object'){ 316 options[j] = val; 317 } 318 else{ 319 if(typeof val.VALUE !== 'undefined'){ 320 options[j] = val.VALUE; 321 322 if(typeof val.ADDITIONAL_OPTIONS === 'object'){ 323 for(z in val.ADDITIONAL_OPTIONS){ 324 var addoption = val.ADDITIONAL_OPTIONS[z]; 325 if(typeof addoption === 'object'){ 326 for(addoptioncode in addoption){ 327 if(typeof addoption[addoptioncode] !== 'undefined'){ 328 options[addoptioncode + '_' + z] = addoption[addoptioncode]; 329 } 330 } 331 } 332 } 333 } 334 335 if(typeof val.SUB_PARAMS === 'object'){ 336 for(z in val.SUB_PARAMS){ 337 var subval = val.SUB_PARAMS[z]; 338 if(typeof subval !== 'object'){ 339 options[val.VALUE + '_' + z] = subval; 340 } 341 else{ 342 if(typeof subval.VALUE !== 'undefined'){ 343 options[val.VALUE + '_' + z] = subval.VALUE; 344 345 if(typeof subval.TEMPLATE !== 'undefined'){ 346 options[val.VALUE + '_' + z + '_TEMPLATE'] = subval.TEMPLATE; 347 348 if(typeof subval.ADDITIONAL_OPTIONS !== 'undefined'){ 349 for(addoptioncode in subval.ADDITIONAL_OPTIONS){ 350 options[val.VALUE + '_' + z + '_' + addoptioncode + '_' + subval.TEMPLATE] = subval.ADDITIONAL_OPTIONS[addoptioncode]; 351 } 352 } 353 } 354 355 if(typeof subval.FON !== 'undefined'){ 356 options['fon' + val.VALUE + z] = subval.FON; 357 } 358 } 359 } 360 } 361 } 362 363 if(typeof val.DEPENDENT_PARAMS === 'object'){ 364 for(z in val.DEPENDENT_PARAMS){ 365 var depval = val.DEPENDENT_PARAMS[z]; 366 if(typeof depval !== 'object'){ 367 options[z] = depval; 368 } 369 } 370 } 371 372 if(typeof val.ORDER === 'string'){ 373 order.push({ 374 NAME: 'SORT_ORDER_' + j + '_' + val.VALUE, 375 VALUE: val.ORDER 376 }); 377 378 options['SORT_ORDER_' + j + '_' + val.VALUE] = val.ORDER; 379 } 380 } 381 } 382 } 383 } 384 385 if(typeof arMaxOptions.THEMATICS.LIST[thematic]['OPTIONS'] === 'object'){ 386 for(j in arMaxOptions.THEMATICS.LIST[thematic]['OPTIONS']){ 387 // change value of each thematic option in options list 388 389 var val = arMaxOptions.THEMATICS.LIST[thematic]['OPTIONS'][j]; 390 if(typeof val !== 'object'){ 391 options[j] = val; 392 } 393 else{ 394 if(typeof val.VALUE !== 'undefined'){ 395 options[j] = val.VALUE; 396 397 if(typeof val.ADDITIONAL_OPTIONS === 'object'){ 398 for(z in val.ADDITIONAL_OPTIONS){ 399 var addoption = val.ADDITIONAL_OPTIONS[z]; 400 if(typeof addoption === 'object'){ 401 for(addoptioncode in addoption){ 402 if(typeof addoption[addoptioncode] !== 'undefined'){ 403 options[addoptioncode + '_' + z] = addoption[addoptioncode]; 404 } 405 } 406 } 407 } 408 } 409 410 if(typeof val.SUB_PARAMS === 'object'){ 411 for(z in val.SUB_PARAMS){ 412 var subval = val.SUB_PARAMS[z]; 413 if(typeof subval !== 'object'){ 414 options[val.VALUE + '_' + z] = subval; 415 } 416 else{ 417 if(typeof subval.VALUE !== 'undefined'){ 418 options[val.VALUE + '_' + z] = subval.VALUE; 419 420 if(typeof subval.TEMPLATE !== 'undefined'){ 421 options[val.VALUE + '_' + z + '_TEMPLATE'] = subval.TEMPLATE; 422 423 if(typeof subval.ADDITIONAL_OPTIONS !== 'undefined'){ 424 for(addoptioncode in subval.ADDITIONAL_OPTIONS){ 425 options[val.VALUE + '_' + z + '_' + addoptioncode + '_' + subval.TEMPLATE] = subval.ADDITIONAL_OPTIONS[addoptioncode]; 426 } 427 } 428 } 429 430 if(typeof subval.FON !== 'undefined'){ 431 options['fon' + val.VALUE + z] = subval.FON; 432 } 433 } 434 } 435 } 436 } 437 438 if(typeof val.DEPENDENT_PARAMS === 'object'){ 439 for(z in val.DEPENDENT_PARAMS){ 440 var depval = val.DEPENDENT_PARAMS[z]; 441 if(typeof depval !== 'object'){ 442 options[z] = depval; 443 } 444 } 445 } 446 447 if(typeof val.ORDER === 'string'){ 448 order.push({ 449 NAME: 'SORT_ORDER_' + j + '_' + val.VALUE, 450 VALUE: val.ORDER 451 }); 452 453 options['SORT_ORDER_' + j + '_' + val.VALUE] = val.ORDER; 454 } 455 } 456 } 457 } 458 } 459 460 function _sendOptions(){ 461 $.ajax({ 462 type: 'POST', 463 data: options, 464 success: function(){ 465 // close switcher 466 $('.style-switcher .presets_action').trigger('click'); 467 468 // go to main page 469 location.href = arMaxOptions['SITE_DIR']; 470 } 471 }); 472 } 473 474 function _sendOrder(){ 475 if(order.length){ 476 var sort = order.pop(); 477 $.ajax({ 478 url: arMaxOptions['SITE_DIR'] + 'ajax/options_save_mainpage.php', 479 type: 'POST', 480 data: sort, 481 success: function(){ 482 _sendOrder(); 483 } 484 }); 485 } 486 else{ 487 _sendOptions(); 488 } 489 } 490 491 // send each order array and than send options array 492 _sendOrder(); 493 } 494 } 495 } 496 } 497 498 // show prepare wizard page, can redefine 499 if(typeof prepareWizard === 'undefined'){ 500 prepareWizard = function(thematic, preset){ 501 if(typeof arMaxOptions.THEMATICS.LIST[thematic] === 'object'){ 502 if(typeof arMaxOptions.PRESETS.LIST[preset] === 'object'){ 503 $.ajax({ 504 url: $('.style-switcher .contents.wizard').data('script'), 505 type: 'POST', 506 data: { 507 action: 'getform', 508 thematic: thematic, 509 preset: preset 510 }, 511 success: function(response){ 512 // put response to content 513 $('.style-switcher .contents.wizard').html(response); 514 515 // show prepare wizard page 516 $('.style-switcher .contents.wizard').addClass('active'); 517 } 518 }); 519 } 520 } 521 } 522 } 523 524 /* get updates */ 525 // $.ajax({ 526 // url:'https://aspro.ru/demo/updates/index.php', 527 // type:'POST', 528 // data:{ 529 // 'AJAX_FORM': 'Y', 530 // }, 531 // success:function(html){ 532 // $('.section-block.updates_tab').removeClass('hidden'); 533 // $('.right-block .inner-content .contents.updates .body_block').html(html); 534 535 // $('.style-switcher .contents.updates .right-block .body_block').mCustomScrollbarDeferred({ 536 // mouseWheel: { 537 // scrollAmount: 150, 538 // preventDefault: true 539 // } 540 // }) 541 // }, 542 // error:function(jqXhr){ 543 // console.log(jqXhr); 544 // } 545 // }) 546 /**/ 547 548 HideHintBlock = function(bHideOverlay) 549 { 550 if(typeof bHideOverlay === 'undefined' || bHideOverlay){ 551 HideOverlay(); 552 } 553 $.cookie('clickedSwitcher', 'Y', {path: '/'}); 554 if($('.hint-theme').length) 555 { 556 $('.hint-theme').fadeIn(300, function(){ 557 $('.hint-theme').remove(); 558 }); 559 } 560 } 561 562 $('.style-switcher .presets .presets_block').mCustomScrollbar({ 563 mouseWheel: { 564 scrollAmount: 150, 565 preventDefault: true 566 }, 567 callbacks:{ 568 onScroll: function(){ 569 var topPositionPresets = $('.style-switcher .presets .mCSB_container').css('top').replace(/"/g, ''); 570 topPositionPresets = parseInt(topPositionPresets); 571 topPositionPresets = isNaN(topPositionPresets) ? 0 : topPositionPresets; 572 $.cookie('STYLE_SWITCHER_SCROLL_PRESET_POSITION', topPositionPresets, {path: arMaxOptions['SITE_DIR']}); 573 } 574 }, 575 setTop: (function() { 576 try { 577 return (typeof($.cookie('STYLE_SWITCHER_SCROLL_PRESET_POSITION')) !== 'undefined' ? $.cookie('STYLE_SWITCHER_SCROLL_PRESET_POSITION')+'px' : 0); 578 } catch(error){ 579 console.log(error); 580 return 0; 581 } 582 }()), 583 }); 584 585 $('.style-switcher .left-block').mCustomScrollbar({ 586 mouseWheel: { 587 scrollAmount: 150, 588 preventDefault: true 589 }, 590 callbacks:{ 591 onScroll: function(){ 592 var topPositionLeftBlock = $('.style-switcher .left-block .mCSB_container').css('top').replace(/"/g, ''); 593 topPositionLeftBlock = parseInt(topPositionLeftBlock); 594 topPositionLeftBlock = isNaN(topPositionLeftBlock) ? 0 : topPositionLeftBlock; 595 $.cookie('STYLE_SWITCHER_SCROLL_LEFT_POSITION', topPositionLeftBlock, {path: arMaxOptions['SITE_DIR']}); 596 } 597 }, 598 setTop: (function() { 599 try { 600 return (typeof($.cookie('STYLE_SWITCHER_SCROLL_LEFT_POSITION')) !== 'undefined' ? $.cookie('STYLE_SWITCHER_SCROLL_LEFT_POSITION')+'px' : 0); 601 } catch(error){ 602 console.log(error); 603 return 0; 604 } 605 }()), 606 }); 607 608 $('.style-switcher .contents.parametrs .right-block').mCustomScrollbar({ 609 mouseWheel: { 610 scrollAmount: 150, 611 preventDefault: true, 612 }, 613 callbacks:{ 614 onScroll: function(){ 615 var topPositionRightBlock = $('.style-switcher .parametrs .right-block .mCSB_container').css('top').replace(/"/g, ''); 616 topPositionRightBlock = parseInt(topPositionRightBlock); 617 topPositionRightBlock = isNaN(topPositionRightBlock) ? 0 : topPositionRightBlock; 618 $.cookie('STYLE_SWITCHER_SCROLL_RIGHT_POSITION', topPositionRightBlock, {path: arMaxOptions['SITE_DIR']}); 619 620 InitLazyLoad(); 621 } 622 }, 623 setTop: (function() { 624 try { 625 return (typeof($.cookie('STYLE_SWITCHER_SCROLL_RIGHT_POSITION')) !== 'undefined' ? $.cookie('STYLE_SWITCHER_SCROLL_RIGHT_POSITION')+'px' : 0); 626 } catch(error){ 627 console.log(error); 628 return 0; 629 } 630 }()), 631 }); 632 633 $('.style-switcher .contents.demos .right-block').mCustomScrollbarDeferred({
634 mouseWheel: { 635 scrollAmount: 150, 636 preventDefault: true, 637 }, 638 }); 639 640 $('.style-switcher .item input[type=checkbox]').on('change', function(){ 641 var _this = $(this); 642 if(_this.is(':checked')) 643 _this.val('Y'); 644 else 645 _this.val('N'); 646 if(typeof _this.data('dynamic') === undefined) 647 { 648 $('form[name=style-switcher]').submit(); 649 } 650 else 651 { 652 $('.'+_this.data('index_block')).toggleClass('grey_block'); 653 //save option 654 $.post( 655 arMaxOptions['SITE_DIR']+"ajax/options_save_mainpage.php", 656 { 657 VALUE: _this.val(), 658 NAME: _this.attr('name') 659 } 660 ); 661 } 662 }) 663 664 /* close search block */ 665 $("html, body").on('mousedown', function(e){ 666 if(typeof e.target.className == 'string' && e.target.className.indexOf('adm') < 0) 667 { 668 e.stopPropagation(); 669 if(!$(e.target).closest('.style-switcher .dynamic_left_side').length){ 670 $('.style-switcher .dynamic_left_side').removeClass('active'); 671 } 672 673 if(!$(e.target).closest('.style-switcher .contents.wizard').length){ 674 $('.style-switcher .contents.wizard').removeClass('active'); 675 } 676 } 677 }); 678 679 $('.dynamic_left_side').find('*').on('mousedown', function(e){ 680 e.stopPropagation(); 681 }); 682 683 $('.sup-params .values .subtitle').click(function(){ 684 var _this = $(this), 685 wrapper = _this.closest('.option-wrapper'); 686 if(wrapper.find('.template_block > .item').is(':visible')) 687 $.removeCookie('STYLE_SWITCHER_TEMPLATE'+wrapper.index(), {path: arMaxOptions['SITE_DIR']}); 688 else 689 $.cookie('STYLE_SWITCHER_TEMPLATE'+wrapper.index(), 'Y', {path: arMaxOptions['SITE_DIR']}); 690 691 wrapper.find('.template_block .item').slideToggle(); 692 }); 693 694 $('.presets .presets_subtabs .presets_subtab').on('click', function(){ 695 var _this = $(this); 696 _this.siblings().removeClass('active'); 697 _this.addClass('active'); 698 699 $('.presets .presets_block .options').removeClass('active'); 700 _this.closest('.presets').find('.options:eq('+_this.index()+')').addClass('active'); 701 702 // $('.dynamic_left_side .cl').click(); 703 if(_this.index() == 0){ 704 restoreThematics(); 705 } 706 707 $.cookie('STYLE_SWITCHER_CONFIG_BLOCK', _this.index(), {path: arMaxOptions['SITE_DIR']}); 708 }) 709 710 $(document).on('click', '.presets .thematik .item', function(){ 711 var thematic = $(this).data('code'); 712 selectThematic(thematic, true); 713 }) 714 715 $(document).on('click', '.style-switcher .presets .preset-block .apply_conf_block', function(e){ 716 var preset = $(this).closest('.preset-block').data('id'); 717 selectPreset(preset); 718 }); 719 720 $('.style-switcher .can_save .save_btn').on('click', function(){ 721 var _this = $(this); 722 723 if(timerHide){ 724 clearTimeout(timerHide); 725 timerHide = false;
726 } 727 728 $.ajax({ 729 type:"POST", 730 url:arMaxOptions['SITE_DIR']+"ajax/options_save.php", 731 data:{'SAVE_OPTIONS':'Y'}, 732 dataType:"json", 733 success:function(response){ 734 if("STATUS" in response) 735 { 736 if(!$('.save_config_status').length) 737 $('<div class="save_config_status"><span></span></div>').appendTo(_this.parent()); 738 if(response.STATUS === 'OK') 739 $('.save_config_status').addClass('success'); 740 else 741 $('.save_config_status').addClass('error'); 742 743 $('.save_config_status span').text(BX.message(response.MESSAGE)); 744 745 $('.save_config_status').slideDown(200); 746 timerHide = setTimeout(function(){ 747 // here delayed functions in event 748 $('.save_config_status').slideUp(200, function(){ 749 $(this).remove(); 750 $('.action_block.can_save').remove(); 751 }) 752 }, 1000); 753 } 754 } 755 }) 756 }) 757 758 showToggles(); //replace checkbox in custom toggle 759 760 if($.cookie('styleSwitcherType') === 'presets'){ 761 $('.style-switcher .presets').addClass('active'); 762 } 763 764 if($.cookie('styleSwitcher') === 'open'){ 765 $('.style-switcher').addClass('active'); 766 767 if($.cookie('styleSwitcherType') === 'presets'){ 768 $('.style-switcher .switch.presets_action').addClass('active'); 769 } 770 else{ 771 $('.style-switcher .switch').addClass('active'); 772 } 773 } 774 775 //sort order for main page 776 $('.refresh-block.sup-params .values .inner-wrapper').each(function(){ 777 var _th = $(this), 778 sort_block = _th[0]; 779 Sortable.create(sort_block,{ 780 handle: '.drag', 781 animation: 150, 782 forceFallback: true, 783 filter: '.no_drag', 784 // Element dragging started 785 onStart: function (/**Event*/evt){ 786 evt.oldIndex; // element index within parent 787 window.getSelection().removeAllRanges(); 788 789 $(evt.item).find('.template_block').addClass('hidden'); 790 }, 791 // Element dragging ended 792 onEnd: function (/**Event*/evt){ 793 $(evt.item).find('.template_block').removeClass('hidden'); 794 }, 795 onMove: function (evt) { 796 return evt.related.className.indexOf('no_drag') === -1; 797 }, 798 // Changed sorting within list 799 onUpdate: function (/**Event*/evt){ 800 var itemEl = evt.item; // dragged HTMLElement 801 var order = [], 802 current_type = _th.data('key'), 803 name = 'SORT_ORDER_INDEX_TYPE_'+current_type; 804 $(itemEl).find('.template_block').removeClass('hidden'); 805 806 _th.find('.option-wrapper').each(function(){ 807 order.push($(this).find('.blocks input[type="checkbox"]').attr('name').replace(current_type+'_', '')); 808 $('div[data-class="'+$(this).find('.blocks input[type="checkbox"]').attr('name').toLowerCase().replace(current_type+'_', '')+'_drag"]').attr('data-order', $(this).index()+1); 809 }) 810 811 $('input[name='+name+']').val(order.join(',')); 812 813 //save option 814 $.post( 815 arMaxOptions['SITE_DIR']+"ajax/options_save_mainpage.php", 816 { 817 VALUE: order.join(','), 818 NAME: name 819 } 820 ); 821 822 var eventdata = {action:'jsLoadBlock'}; 823 BX.onCustomEvent('onCompleteAction', [eventdata]); 824 }, 825 }); 826 }) 827 828 if($('.base_color_custom input[type=hidden]').length) 829 { 830 $('.base_color_custom input[type=hidden]').each(function(){ 831 var _this = $(this), 832 parent = $(this).closest('.base_color_custom'); 833 _this.spectrum({ 834 preferredFormat: 'hex', 835 showButtons: true, 836 showInput: true, 837 showPalette: false, 838 appendTo: parent, 839 chooseText: BX.message('CUSTOM_COLOR_CHOOSE'), 840 cancelText: BX.message('CUSTOM_COLOR_CANCEL'), 841 containerClassName: 'custom_picker_container', 842 replacerClassName: 'custom_picker_replacer', 843 clickoutFiresChange: false, 844 move: function(color) { 845 var colorCode = color.toHexString(); 846 /*parent.find('span span.vals').text(colorCode); 847 parent.find('span.animation-all').attr('style', 'border-color:' + colorCode); 848 */ 849 parent.find('span span.bg').attr('style', 'background:' + colorCode); 850 }, 851 hide: function(color) { 852 var colorCode = color.toHexString(); 853 /*parent.find('span span.vals').text(colorCode); 854 parent.find('span.animation-all').attr('style', 'border-color:' + colorCode); 855 */ 856 parent.find('span span.bg').attr('style', 'background:' + colorCode); 857 }, 858 change: function(color) { 859 var colorCode = color.toHexString(); 860 parent.addClass('current').siblings().removeClass('current'); 861 862 parent.find('span span.vals').text(colorCode); 863 parent.find('span.animation-all').attr('style', 'border-color:' + colorCode); 864 865 $('form[name=style-switcher] input[name=' + parent.find('.click_block').data('option-id') + ']').val(parent.find('.click_block').data('option-value')); 866 $('form[name=style-switcher]').submit(); 867 } 868 }); 869 }) 870 } 871 872 $('.base_color_custom').click(function(e) { 873 e.preventDefault(); 874 $('input[name='+$(this).data('name')+']').spectrum('toggle'); 875 return false;
876 }); 877 878 if($('.base_color.current').length) 879 { 880 $('.base_color.current').each(function(){ 881 var color_block = $(this).closest('.options').find('.base_color_custom'), 882 curcolor = $(this).data('color'); 883 if(curcolor != undefined && curcolor.length) 884 { 885 $('input[name='+color_block.data('name')+']').spectrum('set', curcolor); 886 color_block.find('span span').attr('style', 'background:' + curcolor); 887 } 888 }) 889 } 890 $('.style-switcher .switch,.style-switcher .presets_action').click(function(e){ 891 e.preventDefault(); 892 893 var styleswitcher = $(this).closest('.style-switcher'); 894 var presets = styleswitcher.find('.presets'); 895 var parametrs = styleswitcher.find('.parametrs'); 896 var bSwitchPresets = $(this).hasClass('presets_action'); 897 898 styleswitcher.find('.section-block').removeClass('active'); 899 900 try { 901 if(typeof($.cookie('STYLE_SWITCHER_SCROLL_RIGHT_POSITION')) !== 'undefined') { 902 //var rightPosition = isNaN(parseInt($.cookie('STYLE_SWITCHER_SCROLL_RIGHT_POSITION'))) ? 0 : $.cookie('STYLE_SWITCHER_SCROLL_RIGHT_POSITION'); 903 $('.style-switcher .contents.parametrs .right-block').mCustomScrollbar('scrollTo', $.cookie('STYLE_SWITCHER_SCROLL_RIGHT_POSITION')); 904 } 905 906 if(typeof($.cookie('STYLE_SWITCHER_SCROLL_LEFT_POSITION')) !== 'undefined') { 907 //var leftPosition = isNaN(parseInt($.cookie('STYLE_SWITCHER_SCROLL_LEFT_POSITION'))) ? 0 : $.cookie('STYLE_SWITCHER_SCROLL_LEFT_POSITION'); 908 $('.style-switcher .left-block').mCustomScrollbar('scrollTo', $.cookie('STYLE_SWITCHER_SCROLL_LEFT_POSITION')); 909 } 910 911 if(typeof($.cookie('STYLE_SWITCHER_SCROLL_PRESET_POSITION')) !== 'undefined') { 912 //var presetPosition = isNaN(parseInt($.cookie('STYLE_SWITCHER_SCROLL_PRESET_POSITION'))) ? 0 : $.cookie('STYLE_SWITCHER_SCROLL_PRESET_POSITION'); 913 $('.style-switcher .presets .presets_block').mCustomScrollbar('scrollTo', $.cookie('STYLE_SWITCHER_SCROLL_PRESET_POSITION')); 914 } 915 } catch(error) { 916 console.log(error); 917 } 918 919 if(styleswitcher.hasClass('active')){ 920 restoreThematics(); 921 922 // current switch type 923 var typeSwitcher = $.cookie('styleSwitcherType'); 924 925 // change switcher bgcolor 926 styleswitcher.find('.switch').removeClass('active'); 927 styleswitcher.find('.presets_action').removeClass('active'); 928 929 if((bSwitchPresets && typeSwitcher === 'presets') || (!bSwitchPresets && typeSwitcher === 'parametrs')){ 930 HideHintBlock(true); 931 932 // remove switcher type 933 $.removeCookie('styleSwitcherType', {path: '/'}); 934 935 // save switcher as hidden 936 $.removeCookie('styleSwitcher', {path: '/'}); 937 938 // hide switcher with transition 939 styleswitcher.addClass('closes'); 940 setTimeout(function(){ 941 styleswitcher.removeClass('active'); 942 }, 300) 943 } 944 else{ 945 HideHintBlock(false); 946 947 // save switcher type 948 $.cookie('styleSwitcherType', (bSwitchPresets ? 'presets' : 'parametrs'), {path: '/'}); 949 950 // hide switcher title 951 styleswitcher.find('.header .title').hide(); 952 953 // set presets visible or hidden with transition and change switcher bgcolor 954 if(bSwitchPresets){ 955 // styleswitcher.find('.header .title.title-presets').show(); 956 $('.section-block.presets_tab').addClass('active'); 957 presets.addClass('active'); 958 parametrs.removeClass('active'); 959 } 960 else if($(this).hasClass('demo_action')) 961 { 962 $('.section-block.demos_tab').removeClass('hidden').addClass('active'); 963 $('.inner-content .contents').removeClass('active'); 964 $('.inner-content .contents.demos').removeClass('hidden').addClass('active'); 965 966 $.removeCookie('styleSwitcherType', {path: '/'}); 967 $.removeCookie('styleSwitcher', {path: '/'}); 968 } 969 else{ 970 // styleswitcher.find('.header .title.title-parametrs').show(); 971 $('.section-block.parametrs_tab').addClass('active'); 972 presets.removeClass('active'); 973 parametrs.addClass('active'); 974 } 975 $(this).addClass('active'); 976 } 977 } 978 else{ 979 HideHintBlock(true); 980 981 // change switcher bgcolor 982 $(this).addClass('active'); 983 984 // save switcher type 985 $.cookie('styleSwitcherType', (bSwitchPresets ? 'presets' : 'parametrs'), {path: '/'}); 986 987 // save switcher as open 988 $.cookie('styleSwitcher', 'open', {path: '/'}); 989 990 // set presets visible or hidden immediately before adding .active to .style-switcher 991 if(bSwitchPresets){ 992 // styleswitcher.find('.header .title.title-presets').show(); 993 $('.section-block.presets_tab').addClass('active'); 994 presets.addClass('active'); 995 parametrs.removeClass('active'); 996 } 997 else if($(this).hasClass('demo_action')) 998 { 999 $('.section-block.demos_tab').removeClass('hidden').addClass('active'); 1000 $('.inner-content .contents').removeClass('active'); 1001 $('.inner-content .contents.demos').removeClass('hidden').addClass('active'); 1002 1003 $.removeCookie('styleSwitcherType', {path: '/'}); 1004 $.removeCookie('styleSwitcher', {path: '/'}); 1005 } 1006 else{ 1007 // styleswitcher.find('.header .title.title-parametrs').show(); 1008 $('.section-block.parametrs_tab').addClass('active'); 1009 presets.removeClass('active'); 1010 parametrs.addClass('active'); 1011 } 1012 1013 // show overlay 1014 ShowOverlay(); 1015 1016 // show switcher with transition 1017 styleswitcher.removeClass('closes').addClass('active'); 1018 1019 var lazyCounter = setInterval(function(){ 1020 if( $('.style-switcher').hasClass('active') ) { 1021 InitLazyLoad(); 1022 clearInterval(lazyCounter); 1023 } 1024 }, 500); 1025 1026 } 1027 1028 InitLazyLoad(); 1029 1030 }); 1031 1032 $('.item.groups-tab a[data-toggle="tab"].linked').on('shown.bs.tab', function(e){ 1033 var _this = $(this); 1034 1035 $.cookie('styleSwitcherTabs'+_this.closest('.tabs').data('parent'), _this.parent().index(), {path: '/'}); 1036 1037 setTimeout(function(){ 1038 InitLazyLoad(); 1039 }, 250) 1040 }) 1041 1042 $(document).on('click', '.close-overlay', function(){ 1043 HideHintBlock() 1044 }) 1045 1046 $('.close_block').click(function(){ 1047 $('.jqmOverlay').trigger('click'); 1048 }) 1049 1050 $(document).on('click', '.jqmOverlay', function(){ 1051 var styleswitcher = $('.style-switcher'); 1052 1053 if(!$('.hint-theme').length){ 1054 HideOverlay(); 1055 } 1056 1057 styleswitcher.each(function(){ 1058 var _this = $(this); 1059 _this.addClass('closes'); 1060 1061 setTimeout(function(){ 1062 _this.removeClass('active'); 1063 },300); 1064 1065 $('.form_demo-switcher').animate({ 1066 left: '-' + $('.form_demo-switcher').outerWidth() + 'px' 1067 }, 100).removeClass('active abs'); 1068 }) 1069 1070 $('.style-switcher .switch,.style-switcher .presets_action').removeClass('active'); 1071 1072 restoreThematics(); 1073 1074 $.removeCookie('styleSwitcherType', {path: '/'}); 1075 $.removeCookie('styleSwitcher', {path: '/'}); 1076 }) 1077
1078 $('.style-switcher .section-block').on('click', function(){ 1079 $(this).siblings().removeClass('active'); 1080 $(this).addClass('active'); 1081 1082 1083 $('.style-switcher .right-block .contents').removeClass('active'); 1084 $('.style-switcher .right-block .contents.' + $(this).data('type')).addClass('active'); 1085 1086 $.cookie('styleSwitcherType', $(this).data('type'), {path: '/'}); 1087 1088 // save switcher as open 1089 $.cookie('styleSwitcher', 'open', {path: '/'}); 1090 1091 if($(this).hasClass('demos_tab') || $(this).hasClass('updates_tab')) 1092 { 1093 $.removeCookie('styleSwitcherType', {path: '/'}); 1094 $.removeCookie('styleSwitcher', {path: '/'}); 1095 } 1096 1097 setTimeout(function(){ 1098 InitLazyLoad(); 1099 }, 250) 1100 }) 1101 1102 $('.style-switcher .subsection-block').on('click', function(){ 1103 $(this).siblings().removeClass('active'); 1104 $(this).addClass('active'); 1105 1106 $('.style-switcher .right-block .contents .content-body .block-item').removeClass('active'); 1107 $('.style-switcher .right-block .contents .content-body .block-item:eq('+$(this).index()+')').addClass('active'); 1108 1109 $.cookie('styleSwitcherSubType', $(this).index(), {path: '/'}); 1110 1111 //replace checkbox in custom toggle 1112 if(!$(this).hasClass('toggle_initied') && !$(this).hasClass('presets_tab')) 1113 showToggles(); 1114 $(this).addClass('toggle_initied'); 1115 1116 setTimeout(function(){ 1117 InitLazyLoad(); 1118 }, 250) 1119 }) 1120 1121 $('.style-switcher .reset').click(function(e){ 1122 $('form[name=style-switcher]').append('<input type="hidden" name="THEME" value="default" />'); 1123 $('form[name=style-switcher]').submit(); 1124 1125 $.removeCookie('styleSwitcherTabsCatalog', {path: '/'}); 1126 }); 1127 1128 $(document).on('click', '.style-switcher .apply', function(){ 1129 $('form[name=style-switcher]').submit(); 1130 }) 1131
1132 $('.style-switcher .sup-params.options .block-title').click(function(){ 1133 $(this).next().slideToggle(); 1134 setTimeout(function(){ 1135 InitLazyLoad(); 1136 }, 250) 1137 }) 1138 1139 $(document).on('click', '.style-switcher .preview_conf_block .btn', function(){ 1140 var _this = $(this); 1141 1142 if($('.dynamic_left_side').length) 1143 $('.dynamic_left_side').remove(); 1144 1145 $('<div class="dynamic_left_side"><div class="items_inner"><div class="titles_block"></div></div></div>').appendTo(_this.closest('.contents.presets .presets_block')); 1146 $('.dynamic_left_side .titles_block').html( 1147 '<div class="title">'+_this.closest('.preset-block').find('.info .title').text()+'</div>'+ 1148 '<div class="blocks_wrapper">'+ 1149 '<div class="cl" title="'+BX.message('FANCY_CLOSE')+'">'+$('.close_block .closes').html()+'</div>'+ 1150 (_this.closest('.preset-block').find('.apply_conf_block').hasClass('hidden') ? '' : '<div class="ch" data-id="'+_this.closest('.preset-block').data('id')+'">'+_this.closest('.preset-block').find('.apply_conf_block').html()+'</div>') + 1151 '</div>' 1152 ) 1153 1154 $('<div class="desc">'+_this.closest('.preset-block').find('.info .description').text()+'</div>').appendTo($('.dynamic_left_side .items_inner')); 1155 if(_this.closest('.preset-block').find('.info .description').data('img')) 1156 $('<div class="img"><img src="'+_this.closest('.preset-block').find('.info .description').data('img')+'" /></div>').appendTo($('.dynamic_left_side .items_inner')); 1157 1158 $('.dynamic_left_side').mCustomScrollbar({ 1159 mouseWheel: { 1160 scrollAmount: 150, 1161 preventDefault: true 1162 } 1163 }) 1164 if(timerDynamicLeftSide) 1165 { 1166 clearTimeout(timerDynamicLeftSide); 1167 timerDynamicLeftSide = false;
1168 } 1169 timerDynamicLeftSide = setTimeout(function(){ 1170 $('.dynamic_left_side').addClass('active'); 1171 }, 100) 1172 }) 1173 1174 $('.style-switcher .ext_hint_title').click(function(){ 1175 var _this = $(this); 1176 1177 if($('.dynamic_left_side').length) 1178 $('.dynamic_left_side').remove(); 1179 1180 $('<div class="dynamic_left_side"><div class="items_inner"></div></div>').appendTo(_this.closest('.contents.parametrs > .right-block')); 1181 $('<div class="cl" title="'+BX.message('FANCY_CLOSE')+'">'+$('.close_block .closes').html()+'</div>').appendTo($('.dynamic_left_side')); 1182 1183 $('.ext_hint_desc').find('iframe').attr('src', $('.ext_hint_desc').find('iframe').data('src')); 1184 1185 $('.dynamic_left_side .items_inner').html(_this.siblings('.ext_hint_desc').html()); 1186 1187 $('.dynamic_left_side').mCustomScrollbar({ 1188 mouseWheel: { 1189 scrollAmount: 150, 1190 preventDefault: true 1191 } 1192 }) 1193 if(timerDynamicLeftSide) 1194 { 1195 clearTimeout(timerDynamicLeftSide); 1196 timerDynamicLeftSide = false; 1197 } 1198 timerDynamicLeftSide = setTimeout(function(){ 1199 $('.dynamic_left_side').addClass('active'); 1200 }, 100) 1201 }) 1202 1203 $(document).on('click', '.dynamic_left_side .ch .btn', function(e){ 1204 var preset = $(this).parent().data('id'); 1205 selectPreset(preset); 1206 $('.dynamic_left_side').removeClass('active'); 1207 }) 1208 1209 $(document).on('click', '.dynamic_left_side .cl', function(e){ 1210 $('.dynamic_left_side').removeClass('active'); 1211 }) 1212
1213 $('.style-switcher .options > .link-item,.style-switcher .options > div:not(.base_color_custom) .link-item,.style-switcher .options > div:not(.base_color_custom) .click_block').click(function(e){ 1214 var _this = $(this); 1215 var bMulti = _this.data('type') == 'multi'; 1216 var bCurrent = _this.hasClass('current'); 1217 1218 if(!bMulti && bCurrent) 1219 return; 1220 1221 1222 if(bMulti) { 1223 _this.toggleClass('current'); 1224 } else { 1225 if(!_this.closest('.subs').length) 1226 _this.closest('.options').find('.link-item').removeClass('current'); 1227 1228 _this.siblings().removeClass('current'); 1229 _this.addClass('current'); 1230 } 1231 1232 1233 if(bMulti) { 1234 var input = $('form[name=style-switcher] input[name=' + _this.data('option-id') + ']'); 1235 var inputVal = input.val(); 1236 1237 if(!inputVal) { 1238 input.val(_this.data('option-value')); 1239 } else { 1240 inputVal = inputVal.split(','); 1241 if(bCurrent) { 1242 inputVal.splice( inputVal.indexOf(_this.data('option-value')), 1 ); 1243 } else { 1244 inputVal.push(_this.data('option-value')); 1245 } 1246 inputVal = inputVal.join(); 1247 input.val(inputVal); 1248 } 1249 } else { 1250 $('form[name=style-switcher] input[name=' + _this.data('option-id') + ']').val(_this.data('option-value')); 1251 } 1252 1253 if(_this.closest('.sup-params').length) 1254 $.removeCookie('styleSwitcher', {path: '/'}); 1255 1256 if(typeof($(this).data('option-type')) != 'undefined') // set cookie for scroll block 1257 $.cookie('scroll_block', $(this).data('option-type')); 1258 1259 if(typeof($(this).data('option-url')) != 'undefined') // set action form for redirect 1260 $('form[name=style-switcher]').prepend('<input type="hidden" name="backurl" value='+$(this).data('option-url')+' />'); 1261 1262 if(_this.closest('.options').hasClass('refresh-block')) 1263 { 1264 if(!_this.closest('.options').hasClass('sup-params')) 1265 var index = _this.index()-1; 1266 _this.closest('.item').find('.sup-params.options').removeClass('active'); 1267 _this.closest('.item').find('.sup-params.options.s_'+_this.data('option-value')+'').addClass('active'); 1268 $('form[name=style-switcher]').submit(); 1269 } 1270 else 1271 { 1272 $('form[name=style-switcher]').submit(); 1273 } 1274 }); 1275 1276 $('.tooltip-link').on('shown.bs.tooltip', function (e) { 1277 var tooltip_block = $(this).next(), 1278 wihdow_height = $(window).height(), 1279 scroll = $(this).closest('form').scrollTop(), 1280 pos = BX.pos($(this)[0], true), 1281 pos_tooltip = BX.pos(tooltip_block[0], true), 1282 pos_item_wrapper = BX.pos($(this).closest('.item')[0], true); 1283 1284 if(!$(this).closest('.item').next().length && pos_tooltip.bottom > pos_item_wrapper.bottom) 1285 { 1286 tooltip_block.removeClass('bottom').addClass('top'); 1287 tooltip_block.css({'top':(pos.top-tooltip_block.actual('outerHeight'))}); 1288 } 1289 }) 1290});
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.