1var 2layerPopup = 0, 3windowWidth = document.documentElement.clientWidth, 4windowHeight = document.documentElement.clientHeight; 5 6 7 8function cptStoriesHideAdv() 9{ 10 11 var hideAdv = document.querySelector(".js-cpt-stories-hide-adv"), 12 siteID = document.querySelector('.cpt-stories-site_id'); 13 14 if(hideAdv) 15 { 16 cptStoriesXMLrequest({ 17 'path':'/bitrix/tools/concept.stories/hide_adv.php', 18 'data': { 19 'siteID':siteID.value, 20 'check':'Y', 21 'USER_ID': hideAdv.getAttribute('data-user-id'), 22 }, 23 'NODE':null, 24 'HIDE_ADV':'Y' 25 }); 26 } 27} 28 29(function(window){ 30 31 window.CptStories = function(arParams) 32 { 33 this.product = arParams; 34 this.nodes = {}; 35 this.eventsCustom = {}; 36 this.intervalId = null; 37 this.time = 5; 38 this.start = 0; 39 this.setForLocalStorage = {}; 40 this.error = 0; 41 42 this.initConfig(); 43 44 45 if(this.product.SLIDER.ITEMS_CNT === '0') 46 this.error = -100; 47 48 if(this.error === 0) 49 BX.ready(BX.delegate(this.init, this)); 50 }; 51 52 window.CptStories.prototype = 53 { 54 initConfig: function(){ 55 56 /*this.product.SLIDER.SELECTED = parseInt(this.product.SLIDER.SELECTED,10); 57 58 if(this.product.SLIDER.ITEMS.length>0) 59 { 60 for (var i = 0; i < this.product.SLIDER.ITEMS.length; i++) { 61 this.product.SLIDER.ITEMS[i].SELECTED = parseInt(this.product.SLIDER.ITEMS[i].SELECTED); 62 } 63 }*/ 64 }, 65 66 initNodes: function(){ 67 68 if(this.product.NODE) 69 { 70 this.nodes.obStories = document.querySelector("#"+this.product.NODE); 71 72 var clone = this.nodes.obStories.cloneNode(true); 73 74 this.nodes.obStories.remove(); 75 76 document.body.appendChild(clone); 77 78 this.nodes.obStories = clone; 79 80 this.nodes.obWindow = this.nodes.obStories.querySelector(".js-cpt-stories-modal-guts"); 81 this.nodes.obCloseBtn = this.nodes.obStories.querySelector(".js-cpt-stories-close-button"); 82 this.nodes.obPauseBtn = this.nodes.obStories.querySelector(".js-cpt-stories-pause-button"); 83 84 this.nodes.obBtnNext = this.nodes.obStories.querySelectorAll(".js-cpt-stories-window-next"); 85 this.nodes.obBtnPrev = this.nodes.obStories.querySelectorAll(".js-cpt-stories-window-prev"); 86 87 this.nodes.obWrSlides = this.nodes.obStories.querySelector(".js-cpt-stories-slides"); 88 this.nodes.obSlides = this.nodes.obWrSlides.querySelectorAll(".js-cpt-stories-slide"); 89 90 this.nodes.obFrames = this.nodes.obWrSlides.querySelectorAll(".js-cpt-stories-frame"); 91 92 this.nodes.obOverlay = this.nodes.obStories.querySelector(".js-cpt-stories-modal-overlay"); 93 this.nodes.obOverlayUser = this.nodes.obStories.querySelector(".js-cpt-stories-modal-overlay-user"); 94 this.nodes.obShadow = this.nodes.obStories.querySelector(".js-cpt-stories-bg-shadow"); 95 96 97 this.nodes.obStoriesPreview = document.querySelector("#"+this.product.NODE_PREVIEW); 98 99 this.nodes.obWrSlidesPreview = this.nodes.obStoriesPreview.querySelectorAll(".js-cpt-stories-preview-slide"); 100 101 102 this.nodes.obBtns = this.nodes.obWrSlides.querySelectorAll(".js-cpt-stories-frame-btn"); 103 this.nodes.obFrameTitles = this.nodes.obWrSlides.querySelectorAll(".js-cpt-stories-frame-title"); 104 this.nodes.obFrameSubTitles = this.nodes.obWrSlides.querySelectorAll(".js-cpt-stories-frame-subtitle"); 105 this.nodes.obFrameText = this.nodes.obWrSlides.querySelectorAll(".js-cpt-stories-frame-text"); 106 107 /*this.nodes.obVideos = this.nodes.obWrSlides.querySelectorAll(".js-cpt-stories-video");*/ 108 109 } 110 111 if(this.product.IS_WG === 'Y') 112 { 113 this.nodes.obFixBlock = document.querySelector(".js-cpt-stories-fixblock"); 114 this.nodes.obHideFixBlockBtn = this.nodes.obFixBlock.querySelector(".js-cpt-stories-close-button"); 115 } 116 }, 117 118 setFontsSize: function() 119 { 120 var curFSize = null, 121 result = 0, 122 ratio = 100, 123 windowWidth = document.documentElement.clientWidth; 124 125 126 if(windowWidth >= 1200) 127 { 128 ratio = 0; 129 } 130 else if(windowWidth >= 992 && windowWidth <= 1199) 131 { 132 ratio = 0; 133 } 134 else if(windowWidth >= 768 && windowWidth <= 991) 135 { 136 ratio = 10; 137 } 138 else 139 { 140 ratio = 15; 141 } 142 143 144 if(this.nodes.obBtns) 145 for (var i = 0; i < this.nodes.obBtns.length; i++) 146 { 147 this.nodes.obBtns[i].style.fontSize=''; 148 curFSize = parseInt(window.getComputedStyle(this.nodes.obBtns[i]).fontSize); 149 result = curFSize - (curFSize * ratio / 100); 150 this.nodes.obBtns[i].style.fontSize=result+'px'; 151 this.nodes.obBtns[i].style.lineHeight=(result+4)+'px'; 152 } 153 154 if(this.nodes.obFrameTitles) 155 for (var i = 0; i < this.nodes.obFrameTitles.length; i++) 156 { 157 this.nodes.obFrameTitles[i].style.fontSize=''; 158 curFSize = parseInt(window.getComputedStyle(this.nodes.obFrameTitles[i]).fontSize); 159 result = curFSize - (curFSize * ratio / 100); 160 this.nodes.obFrameTitles[i].style.fontSize=result+'px'; 161 this.nodes.obFrameTitles[i].style.lineHeight=(result+4)+'px'; 162 } 163 164 if(this.nodes.obFrameSubTitles) 165 for (var i = 0; i < this.nodes.obFrameSubTitles.length; i++) 166 { 167 this.nodes.obFrameSubTitles[i].style.fontSize=''; 168 curFSize = parseInt(window.getComputedStyle(this.nodes.obFrameSubTitles[i]).fontSize); 169 result = curFSize - (curFSize * ratio / 100); 170 this.nodes.obFrameSubTitles[i].style.fontSize=result+'px'; 171 this.nodes.obFrameSubTitles[i].style.lineHeight=(result+6)+'px'; 172 } 173 174 if(this.nodes.obFrameText) 175 for (var i = 0; i < this.nodes.obFrameText.length; i++) 176 { 177 this.nodes.obFrameText[i].style.fontSize=''; 178 curFSize = parseInt(window.getComputedStyle(this.nodes.obFrameText[i]).fontSize); 179 result = curFSize - (curFSize * ratio / 100); 180 this.nodes.obFrameText[i].style.fontSize=result+'px'; 181 this.nodes.obFrameText[i].style.lineHeight=(result+4)+'px'; 182 } 183 }, 184 185 bindAnaliticsBtns: function() 186 { 187 var that = this; 188 for (var i = 0; i < this.nodes.obBtns.length; i++) 189 { 190 191 var slideID = null, 192 frameID = null, 193 nodeFrame = null; 194 195 196 this.nodes.obBtns[i].addEventListener('click', function() 197 { 198 199 var target = event.target; 200
201 if(target.closest(".js-cpt-stories-frame")) 202 { 203 204 nodeFrame = target.closest(".js-cpt-stories-frame"); 205 slideID = nodeFrame.getAttribute('data-story'); 206 frameID = nodeFrame.getAttribute('data-frame'); 207 208 if(that.product.SLIDER.ITEMS[slideID].ITEMS[frameID].ANALYTIC_BTN_CLICK) 209 cptStoriesAddScript(that.product.SLIDER.ITEMS[slideID].ITEMS[frameID].ANALYTIC_BTN_CLICK); 210 211 } 212 213 }); 214 215 } 216 }, 217 218 bindBtns: function() 219 { 220 var that = this; 221 222 for (var i = 0; i < this.nodes.obBtns.length; i++) 223 { 224 this.nodes.obBtns[i].addEventListener('click', that.hidePopupStories.bind(that)); 225 } 226 }, 227 228 bindPauseFromFrame: function() 229 { 230 var that = this; 231 232 233 for (var i = 0; i < this.nodes.obFrames.length; i++) 234 { 235 this.nodes.obFrames[i].addEventListener("mousedown", that.pauseFrame.bind(that)); 236 this.nodes.obFrames[i].addEventListener("mouseup", that.playFrame.bind(that)); 237 this.nodes.obFrames[i].addEventListener("touchstart", that.pauseFrame.bind(that)); 238 this.nodes.obFrames[i].addEventListener("touchend", that.playFrame.bind(that)); 239 } 240 241 242 }, 243 244 245 246 bindPrevNextBtns: function() 247 { 248 var that = this; 249 250 if(this.nodes.obBtnNext) 251 { 252 for (var i = 0; i < this.nodes.obBtnNext.length; i++) 253 { 254 this.nodes.obBtnNext[i].addEventListener("click", function(e) 255 { 256 e.preventDefault(); 257 that.next(); 258 }); 259 /*this.nodes.obBtnNext[i].addEventListener("mouseup", function(e) 260 { 261 e.preventDefault(); 262 that.playFrame(); 263 });*/ 264 265 } 266 } 267 268 if(this.nodes.obBtnPrev) 269 { 270 271 for (var i = 0; i < this.nodes.obBtnPrev.length; i++) 272 { 273 this.nodes.obBtnPrev[i].addEventListener("click", function(e) 274 { 275 e.preventDefault(); 276 that.prev(); 277 }); 278 /*this.nodes.obBtnPrev[i].addEventListener("mouseup", function(e) 279 { 280 e.preventDefault(); 281 that.playFrame(); 282 });*/ 283 } 284 } 285 }, 286 287 bindShowPopupStories: function() 288 { 289 var that = this; 290 291 if(this.nodes.obWrSlidesPreview) 292 { 293 for (var i = 0; i < this.nodes.obWrSlidesPreview.length; i++) 294 { 295 this.nodes.obWrSlidesPreview[i].addEventListener("click", that.showPopupStories.bind(that)); 296 } 297 298 } 299 }, 300 301 bindHidePopupStories: function() 302 { 303 var that = this; 304 if(this.nodes.obCloseBtn) 305 this.nodes.obCloseBtn.addEventListener('click', that.hidePopupStories.bind(that)); 306 307 if(this.nodes.obShadow) 308 this.nodes.obShadow.addEventListener('click', that.hidePopupStories.bind(that)); 309 }, 310 311 bindTooglePlayPause: function() 312 { 313 var target = event.target; 314 event.preventDefault(); 315 316 317 if(target.closest(".cpt-stories-pause")) 318 { 319 this.pauseFrame(); 320 } 321 else if(target.closest(".cpt-stories-play")) 322 { 323 this.playFrame(); 324 } 325 }, 326 327 showPopupStories: function() 328 { 329 var target = event.target, slide = null; 330 331 if(slide = target.closest(".js-cpt-stories-preview-slide")) 332 { 333 event.preventDefault(); 334 335 setBodyOverflowHidden(); 336 337 338 if(document.documentElement.clientWidth <= 576) 339 { 340 if(document.documentElement.requestFullScreen) { 341 document.documentElement.requestFullScreen(); 342 } else if(document.documentElement.mozRequestFullScreen) { 343 document.documentElement.mozRequestFullScreen(); 344 } else if(document.documentElement.webkitRequestFullScreen) { 345 document.documentElement.webkitRequestFullScreen(); 346 } 347 } 348 349 350 351 this.product.SLIDER.SELECTED = slide.getAttribute('data-story'); 352 353 this.changeSlide(); 354 this.changeFrame(); 355 356 this.getCurrentStory(); 357 this.ComplitedFramesNav(); 358 this.startFrameNav(); 359 360 this.nodes.obStories.classList.remove('cpt-stories-d-none'); 361 362 363 364 if(this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].ANALYTICS_START_WATCH) 365 cptStoriesAddScript(this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].ANALYTICS_START_WATCH); 366 367 368 369 370 } 371 372 }, 373 374 hidePopupStories: function() 375 { 376 377 if(document.documentElement.clientWidth <= 576) 378 { 379 if(document.cancelFullScreen) 380 document.cancelFullScreen(); 381 382 else if(document.mozCancelFullScreen) 383 document.mozCancelFullScreen(); 384 385 else if(document.webkitCancelFullScreen) 386 document.webkitCancelFullScreen(); 387 } 388 389 390 this.setBtnPlay(); 391 this.nodes.obStories.classList.add('cpt-stories-d-none'); 392 clearInterval(this.intervalId); 393 deleteBodyOverflowHidden(); 394 395 }, 396 397 bindEvents: function() 398 { 399 this.bindShowPopupStories(); 400 this.bindHidePopupStories(); 401 this.bindPrevNextBtns();
402 this.bindPauseFromFrame(); 403 this.bindBtns(); 404 this.bindAnaliticsBtns(); 405 406 if(this.product.IS_WG === 'Y') 407 this.bindHideFixBlockBtn(); 408 409 var that = this; 410 if(this.nodes.obPauseBtn) 411 this.nodes.obPauseBtn.addEventListener('click', that.bindTooglePlayPause.bind(that)); 412 }, 413 414 415 preViewSlides: function() 416 { 417 var data = JSON.parse(localStorage.getItem('cpt-stories-'+this.product.ID)), 418 newDate = {}; 419 420 if(data) 421 { 422 423 if(Object.keys(data).length > 30) 424 { 425 localStorage.removeItem('cpt-stories-'+this.product.ID); 426 } 427 else 428 { 429 430 if(this.product.SLIDER.ITEMS) 431 { 432 for (var pair in this.product.SLIDER.ITEMS){ 433 434 if(this.product.SLIDER.ITEMS[pair].ITEMS_CNT === data[pair]) 435 { 436 newDate[pair] = data[pair]; 437 } 438 } 439 } 440 441 if(Object.keys(newDate).length > 0) 442 { 443 444 this.setForLocalStorage = newDate; 445 446 for (var i = 0; i < this.nodes.obWrSlidesPreview.length; i++) 447 { 448 var dataStory = this.nodes.obWrSlidesPreview[i].getAttribute('data-story'); 449 450 for (var pair in this.setForLocalStorage){ 451 if(dataStory == pair) 452 this.nodes.obWrSlidesPreview[i].classList.remove('cpt-stories-preview-slide-active'); 453 454 } 455 // this.nodes.obWrSlidesPreview[data[i]].classList.remove('cpt-stories-preview-slide-active'); 456 } 457 } 458 } 459 } 460 }, 461 462 startWg: function(){ 463 this.product.WG_START_TIMER = parseFloat(this.product.WG_START_TIMER); 464 var that = this, 465 now = Date.now(), 466 data = JSON.parse(localStorage.getItem('cpt-stories-timer')); 467 468 if(data) 469 { 470 if(now>=data[0]) 471 { 472 localStorage.removeItem('cpt-stories-timer'); 473 } 474 else 475 { 476 that.product.WG_START_TIMER = data[0] - now; 477 } 478 } 479 480 481 setTimeout( 482 function() 483 { 484 that.nodes.obFixBlock.classList.add('cpt-stories-show'); 485 486 setTimeout( 487 function() 488 { 489 var previmg = that.nodes.obFixBlock.querySelector('.js-cpt-stories-fixblock-img'); 490 if(previmg) 491 previmg.classList.add('cpt-stories-animate-rotate'); 492 },1000 493 ); 494 495 496 },that.product.WG_START_TIMER 497 ); 498 499 }, 500 501 hideFixBlock: function() 502 { 503 this.nodes.obFixBlock.classList.remove('cpt-stories-show'); 504 505 this.product.WG_HIDDEN_TIMER = parseInt(this.product.WG_HIDDEN_TIMER); 506 507 if(this.product.WG_HIDDEN_TIMER > 0) 508 { 509 var now = Date.now(); 510 localStorage.setItem('cpt-stories-timer', JSON.stringify([this.product.WG_HIDDEN_TIMER + now])); 511 } 512 }, 513 514 bindHideFixBlockBtn: function(){ 515 516 if(this.nodes.obHideFixBlockBtn) 517 { 518 var that = this; 519 this.nodes.obHideFixBlockBtn.addEventListener('click', that.hideFixBlock.bind(that)); 520 } 521 522 }, 523 524 init: function() 525 { 526 527 this.initNodes(); 528 this.preViewSlides(); 529 this.setupFrameParams(); 530 window.addEventListener("resize", {handleEvent: this.setupFrameParams, context: this}); 531 532 533 if(this.product.IS_WG === 'Y') 534 this.startWg(); 535 536 this.changeSlide(); 537 this.changeFrame(); 538 539 this.bindEvents(); 540 541 this.getCurrentStory(); 542 543 }, 544 545 getCurrentStory: function(){ 546 this.getCurrentSlide(); 547 this.getCurrentFrame(); 548 }, 549 550 resetFrames: function(){ 551 var obFrameNavs = this.nodes.obStories.querySelectorAll(".js-cpt-stories-slide-progress-item[data-story='"+this.product.SLIDER_SELECTED+"']"); 552 553 for (var i = 0; i < obFrameNavs.length; i++) 554 { 555 obFrameNavs[i].style.width = '0%'; 556 } 557 }, 558 559 560 ComplitedFramesNav: function(){ 561 562 this.resetFrames(); 563 564 var obFrameNavs = this.nodes.obStories.querySelectorAll(".js-cpt-stories-slide-progress-item[data-story='"+this.product.SLIDER_SELECTED+"']"); 565 566 for (var i = 0; i < obFrameNavs.length; i++) 567 { 568 if(parseInt(this.product.SLIDER.ITEMS[this.product.SLIDER_SELECTED].ITEMS[this.product.FRAME_SELECTED].INDEX) === i) 569 break; 570 571 obFrameNavs[i].style.width = '100%'; 572 } 573 574 }, 575 576 setBtnPlay: function() 577 { 578 this.nodes.obPauseBtn.classList.add("cpt-stories-pause"); 579 this.nodes.obPauseBtn.classList.remove("cpt-stories-play"); 580 }, 581 582 setBtnPause: function() 583 { 584 this.nodes.obPauseBtn.classList.add("cpt-stories-play"); 585 this.nodes.obPauseBtn.classList.remove("cpt-stories-pause"); 586 }, 587 588 playFrame: function(){ 589 this.moveFrameNav(); 590 this.setBtnPlay(); 591 }, 592 593 pauseFrame: function(){ 594 595 if(this.intervalId) 596 { 597 clearInterval(this.intervalId); 598 this.setBtnPause(); 599 } 600 601 }, 602 603 moveFrameNav: function(){ 604 var that = this; 605 var obFrameNav = this.nodes.obStories.querySelector(".js-cpt-stories-slide-progress-item[data-story='"+this.product.SLIDER_SELECTED+"'][data-frame='"+this.product.FRAME_SELECTED+"']"); 606 607 this.intervalId = setInterval(function(){ 608 obFrameNav.style.width = that.start+'%'; 609 that.start++; 610 611 if(that.start > 100) 612 { 613 that.next(); 614 } 615 616 }, that.time); 617 }, 618 619 startFrameNav: function(){ 620 621 this.time = (parseFloat(this.product.CURRENT_FRAME.TIMER) * 1000) / 100; 622 this.start = 0; 623 624 if(this.intervalId) 625 clearInterval(this.intervalId); 626 627 this.moveFrameNav(); 628 }, 629 630 complitedFrameNav: function(){ 631 this.setBtnPlay(); 632 var obFrameNav = this.nodes.obStories.querySelector(".js-cpt-stories-slide-progress-item[data-story='"+this.product.SLIDER.SELECTED+"'][data-frame='"+this.product.SLIDER.ITEMS[this.product.SLIDER_SELECTED].SELECTED+"']"); 633 obFrameNav.style.width = '100%'; 634 }, 635 prevFrameNav: function(){ 636 this.setBtnPlay(); 637 var obFrameNav = this.nodes.obStories.querySelector(".js-cpt-stories-slide-progress-item[data-story='"+this.product.SLIDER.SELECTED+"'][data-frame='"+this.product.SLIDER.ITEMS[this.product.SLIDER_SELECTED].SELECTED+"']"); 638 obFrameNav.style.width = '0%'; 639 }, 640 641 setupSlideParams: function() 642 { 643 var that = this, prepareHeight = -65;
644 this.nodes.obSlides.forEach(function(item) { 645 item.style.width = that.product.frameWidth+'px'; 646 item.style.height = that.product.frameHeigth+'px'; 647 }); 648 649 if(document.documentElement.clientWidth < 576) 650 prepareHeight = 0 651 652 653 654 this.nodes.obFrames.forEach(function(item) { 655 item.style.width = that.product.frameWidth+'px'; 656 item.style.height = (that.product.frameHeigth + prepareHeight)+'px'; 657 }); 658 659 660 this.changeSlide(); 661 this.cptStoriesResponsive(); 662 this.setFontSize(); 663 }, 664 setFontSize: function () 665 { 666 /*var titles = this.nodes.obStories.querySelectorAll('.cpt-stories-frame-title'), 667 subtitles = this.nodes.obStories.querySelectorAll('.cpt-stories-frame-subtitle'), 668 texts = this.nodes.obStories.querySelectorAll('.cpt-stories-frame-text'), 669 btns = this.nodes.obStories.querySelectorAll('.cpt-stories-frame-btn'); 670 671 if(titles) 672 { 673 for (var i = 0; i < titles.length; i++) { 674 console.log(titles[i]); 675 } 676 } 677 if(subtitles) 678 { 679 for (var i = 0; i < subtitles.length; i++) { 680 681 } 682 } 683 if(texts) 684 { 685 for (var i = 0; i < texts.length; i++) { 686 687 } 688 } 689 if(btns) 690 { 691 for (var i = 0; i < btns.length; i++) { 692 693 } 694 }*/ 695 696 }, 697 698 cptStoriesResponsive: function () 699 { 700 701 if(this.product.frameWidth >= 750) 702 { 703 cssClass='cpt-stories-frame-xl'; 704 } 705 else if(this.product.frameWidth >= 600 && this.product.frameWidth <= 749) 706 { 707 cssClass='cpt-stories-frame-lg'; 708 } 709 else if(this.product.frameWidth >= 400 && this.product.frameWidth <= 599) 710 { 711 cssClass='cpt-stories-frame-md'; 712 } 713 else 714 { 715 cssClass='cpt-stories-frame-sm'; 716 } 717 718 this.nodes.obStories.classList.remove('cpt-stories-frame-xl', 'cpt-stories-frame-lg', 'cpt-stories-frame-md', 'cpt-stories-frame-sm'); 719 this.nodes.obStories.classList.add(cssClass); 720 721 722 }, 723 724 setupFrameParams: function() 725 { 726 windowWidth = document.documentElement.clientWidth, 727 windowHeight = document.documentElement.clientHeight; 728 729 730 if(windowHeight>900) 731 windowHeight = 900; 732 733 var that = this; 734 735 if(this.context) 736 that = this.context; 737 738 if(windowWidth<576) 739 { 740 that.product.frameWidth = parseInt(windowWidth, 10); 741 } 742 else 743 { 744 that.product.frameWidth = parseInt(windowHeight * that.product.CONFIG.RATIO, 10); 745 } 746 747 that.product.frameHeigth = parseInt(windowHeight, 10); 748 749 that.nodes.obWindow.style.width = that.product.frameWidth+'px'; 750 that.nodes.obWindow.style.height = that.product.frameHeigth+'px'; 751 752 that.changeFrame(); 753 that.setupSlideParams(); 754 that.setFontsSize(); 755 756 }, 757 758 changeSlide: function() 759 { 760 761 var translateX = this.product.frameWidth * parseInt(this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].INDEX); 762 this.nodes.obWrSlides.style.transform = "translate3d(-" + translateX + "px, 0px, 0px)"; 763 764 }, 765 766 changeFrame: function() 767 { 768 var obWrFrames = this.nodes.obStories.querySelector(".js-cpt-stories-slide[data-story='"+this.product.SLIDER.SELECTED+"'] .js-cpt-stories-frames"); 769 770 var translateX = this.product.frameWidth * parseInt(this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].ITEMS[this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].SELECTED].INDEX); 771 obWrFrames.style.transform = "translate3d(-" + translateX + "px, 0px, 0px)"; 772 773 774 this.setBg(); 775 776 }, 777 778 hasNextSlide: function() 779 { 780 return (this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].NEXT_ID)?true:false; 781 }, 782 783 hasPrevSlide: function() 784 { 785 return (this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].PREV_ID && this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].PREV_ID != this.product.SLIDER.SELECTED)?true:false; 786 }, 787 788 hasNextFrame: function() 789 { 790 var curFrameSelected = this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].SELECTED; 791 return (this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].ITEMS[curFrameSelected].NEXT_ID)?true:false; 792 }, 793 794 hasPrevFrame: function() 795 { 796 var curFrameSelected = this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].SELECTED; 797 return (this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].ITEMS[curFrameSelected].PREV_ID && this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].ITEMS[curFrameSelected].PREV_ID != curFrameSelected)?true:false; 798 }, 799 800 resetStories:function() 801 { 802 this.product.SLIDER.SELECTED = this.product.SLIDER.FIRST_SELECTED; 803 804 if(this.product.SLIDER.ITEMS.length>0) 805 { 806 for (var i = 0; i < this.product.SLIDER.ITEMS.length; i++) { 807 this.product.SLIDER.ITEMS[i].SELECTED = this.product.SLIDER.ITEMS[i].FIRST_SELECTED; 808 } 809 810 } 811 }, 812 813 complitedSlide: function() 814 { 815 this.resetSlide(); 816 817 this.nodes.obWrSlidesPreview[this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].INDEX].classList.remove('cpt-stories-preview-slide-active'); 818 819 this.setForLocalStorage[this.product.SLIDER.SELECTED]=this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].ITEMS_CNT; 820 821 /*if(!this.setForLocalStorage.includes(this.product.SLIDER.SELECTED)) 822 this.setForLocalStorage.push(this.product.SLIDER.SELECTED);*/ 823 824 localStorage.setItem('cpt-stories-'+this.product.ID, JSON.stringify(this.setForLocalStorage)); 825 }, 826 827 resetSlide: function() 828 { 829 this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].SELECTED = this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].FIRST_SELECTED; 830 this.resetFrames(); 831 }, 832 833 next: function() 834 { 835 var finish = false; 836 837 if(this.hasNextFrame()) 838 { 839 this.complitedFrameNav(); 840 this.nextFrame(); 841 this.changeFrame(); 842 843 if(this.product.SLIDER.ITEMS[this.product.SLIDER_SELECTED].ITEMS[this.product.FRAME_SELECTED].ANALYTIC_FINISH_WATCH) 844 cptStoriesAddScript(this.product.SLIDER.ITEMS[this.product.SLIDER_SELECTED].ITEMS[this.product.FRAME_SELECTED].ANALYTIC_FINISH_WATCH); 845 846 } 847 else if (this.hasNextSlide()) 848 { 849 this.complitedSlide(); 850 this.nextSlide(); 851 this.changeSlide(); 852 this.changeFrame(); 853 } 854 else 855 { 856 finish = true; 857 this.complitedSlide(); 858 this.hidePopupStories(); 859 } 860 861 if(finish) 862 { 863 this.resetStories(); 864 } 865 else 866 { 867 this.getCurrentStory(); 868 this.startFrameNav(); 869 } 870 871 872 }, 873 874 875 prev: function() 876 { 877 var finish = false; 878 879 if(this.hasPrevFrame()) 880 { 881 this.prevFrameNav(); 882 this.prevFrame(); 883 this.changeFrame(); 884 } 885 else if (this.hasPrevSlide()) 886 { 887 this.prevSlide(); 888 this.changeSlide(); 889 890 891 this.changeFrame(); 892 } 893 else 894 { 895 finish = true; 896 this.hidePopupStories(); 897 } 898 899 if(finish) 900 { 901 902 } 903 else 904 { 905 this.getCurrentStory(); 906 this.startFrameNav(); 907 } 908 909 }, 910 911 nextFrame: function() 912 { 913 var curFrameSelected = this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].SELECTED; 914 this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].SELECTED = this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].ITEMS[curFrameSelected].NEXT_ID; 915 }, 916 prevFrame: function() 917 { 918 var curFrameSelected = this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].SELECTED; 919 this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].SELECTED = this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].ITEMS[curFrameSelected].PREV_ID; 920 }, 921 922 nextSlide: function() 923 { 924 this.product.SLIDER.SELECTED = this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].NEXT_ID; 925 }, 926 prevSlide: function() 927 { 928 this.product.SLIDER.SELECTED = this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].PREV_ID; 929 }, 930 931 setBg: function() 932 { 933 this.nodes.obOverlay.style.backgroundImage = "url('"+this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].ITEMS[this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].SELECTED].BG+"')"; 934 935 936 if(this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].ITEMS[this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].SELECTED].BG_USER.length>0) 937 { 938 this.nodes.obOverlayUser.classList.remove('cpt-stories-d-none'); 939 this.nodes.obOverlayUser.style.backgroundImage = "url('"+this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].ITEMS[this.product.SLIDER.ITEMS[this.product.SLIDER.SELECTED].SELECTED].BG_USER+"')"; 940 } 941 else 942 { 943 this.nodes.obOverlayUser.classList.add('cpt-stories-d-none'); 944 } 945 }, 946 947 getCurrentSlide: function() 948 { 949 this.product.SLIDER_SELECTED = this.product.SLIDER.SELECTED; 950 951 952 if(this.product.SLIDER.ITEMS[this.product.SLIDER_SELECTED]) 953 this.product.CURRENT_SLIDE = this.product.SLIDER.ITEMS[this.product.SLIDER_SELECTED]; 954 else 955 { 956 957 } 958 }, 959 960 getCurrentFrame: function() 961 { 962 this.product.FRAME_SELECTED = this.product.SLIDER.ITEMS[this.product.SLIDER_SELECTED].SELECTED; 963 964 if(this.product.SLIDER.ITEMS[this.product.SLIDER_SELECTED].ITEMS[this.product.FRAME_SELECTED]) 965 this.product.CURRENT_FRAME = this.product.SLIDER.ITEMS[this.product.SLIDER_SELECTED].ITEMS[this.product.FRAME_SELECTED]; 966 else 967 { 968 969 } 970 }, 971 972 }; 973 974})(window); 975 976 977function initCptStartParams() 978{ 979 windowWidth = document.documentElement.clientWidth; 980 windowHeight = document.documentElement.clientHeight; 981} 982 983/*initCptStartParams(); 984cptStoriesHideAdv(); 985buildStories();*/ 986 987function initCptdocReady() 988{ 989 cptAddHTML(); 990 cptStoriesResponsive(); 991 initCptStartParams(); 992 buildStories(); 993 cptStoriesHideAdv(); 994 995 996} 997 998function cptAddHTML() 999{ 1000 var html = '', 1001 adminMode = document.querySelector('.cpt-stories-admin-mode'), 1002 hideAdvMode = document.querySelector('.cpt-stories-hide-adv-mode'), 1003 urlTrue = document.querySelector('.cpt-stories-url-true'), 1004 urlFalse = document.querySelector('.cpt-stories-url-false'); 1005 1006 html = "<div class=\"js-cpt-stories-ajax-wg\" data-url-true=\""+urlTrue.value+"\" data-url-false=\""+urlFalse.value+"\"></div>"; 1007 1008 1009 if(adminMode) 1010 html += "<div class=\"js-cpt-stories-ajax-public-admin\"></div>"; 1011 1012 1013 if(hideAdvMode) 1014 html += "<div class='js-cpt-stories-hide-adv' data-user-id='"+hideAdvMode.value+"'></div>"; 1015 1016 document.body.insertAdjacentHTML("beforeEnd", html); 1017} 1018 1019function cptStoriesResponsive() 1020{ 1021 1022 windowWidth = document.documentElement.clientWidth; 1023 1024 var cptStories = document.querySelectorAll(".cpt-stories"), 1025 cssClass=''; 1026 1027 if(cptStories.length>0) 1028 { 1029 if(windowWidth >= 1200) 1030 { 1031 cssClass='cpt-stories-xl'; 1032 } 1033 else if(windowWidth >= 992 && windowWidth <= 1199) 1034 { 1035 cssClass='cpt-stories-lg'; 1036 } 1037 else if(windowWidth >= 768 && windowWidth <= 991) 1038 { 1039 cssClass='cpt-stories-md'; 1040 } 1041 else 1042 { 1043 cssClass='cpt-stories-sm'; 1044 } 1045 1046 for (var i = 0; i < cptStories.length; i++) { 1047 cptStories[i].classList.remove('cpt-stories-xl', 'cpt-stories-lg', 'cpt-stories-md', 'cpt-stories-sm'); 1048 } 1049 1050 for (var i = 0; i < cptStories.length; i++) { 1051 cptStories[i].classList.add(cssClass); 1052 } 1053 1054 } 1055} 1056 1057window.addEventListener("resize", cptStoriesResponsive); 1058document.addEventListener("DOMContentLoaded", initCptdocReady); 1059 1060 1061function buildStoriesBlocks(){ 1062 var blocks = document.querySelectorAll('.js-cpt-stories-ajax'), 1063 siteID = document.querySelector('.cpt-stories-site_id'), 1064 params = []; 1065 1066 if(blocks) 1067 { 1068 for (var i = 0; i < blocks.length; i++) 1069 { 1070 params[i]={ 1071 'path':'/bitrix/tools/concept.stories/init.php', 1072 'data': { 1073 'siteID':siteID.value, 1074 'ID':blocks[i].getAttribute('data-id'), 1075 'IS_WG':'' 1076 }, 1077 'NODE':blocks[i] 1078 }; 1079 1080 blocks[i].classList.remove('js-cpt-stories-ajax'); 1081 1082 } 1083 1084 if(params) 1085 { 1086 for (var i = 0; i < params.length; i++) 1087 { 1088 cptStoriesXMLrequest(params[i]); 1089 } 1090 } 1091 } 1092 1093} 1094 1095function buildStoriesBlock(node, data){ 1096 var siteID = document.querySelector('.cpt-stories-site_id'); 1097 1098 data = data || {}; 1099 data.ID = node.getAttribute('data-id'); 1100 data.siteID = siteID.value; 1101 data.IS_WG = ''; 1102 1103 1104 params = { 1105 'path':'/bitrix/tools/concept.stories/init.php', 1106 'data':data, 1107 'NODE':node 1108 }; 1109 1110 if(node) 1111 { 1112 node.classList.remove('js-cpt-stories-ajax'); 1113 cptStoriesXMLrequest(params); 1114 } 1115 1116} 1117 1118function buildStoriesWG(){ 1119 var siteID = document.querySelector('.cpt-stories-site_id'), 1120 wg = document.querySelector('.js-cpt-stories-ajax-wg'); 1121 1122 1123 cptStoriesXMLrequest({ 1124 'path':'/bitrix/tools/concept.stories/init.php', 1125 'data': { 1126 'siteID':siteID.value, 1127 'IS_WG':'Y', 1128 'URL_TRUE':wg.getAttribute('data-url-true'),
1129 'URL_FALSE':wg.getAttribute('data-url-false') 1130 }, 1131 'NODE':wg 1132 }); 1133} 1134 1135function buildStoriesAdmin(){ 1136 1137 var admin = document.querySelector('.js-cpt-stories-ajax-public-admin'), 1138 siteID = document.querySelector('.cpt-stories-site_id'); 1139 1140 1141 if(admin) 1142 { 1143 cptStoriesXMLrequest({ 1144 'path':'/bitrix/tools/concept.stories/public_admin.php', 1145 'data': { 1146 'siteID':siteID.value, 1147 'admin':'Y' 1148 }, 1149 'NODE':admin 1150 }); 1151 } 1152} 1153 1154function buildStories(){ 1155 buildStoriesWG(); 1156 buildStoriesBlocks(); 1157 buildStoriesAdmin(); 1158} 1159function cptStoriesAddScript(code) 1160{ 1161 1162 if(code) 1163 { 1164 var script = document.createElement('script'); 1165 script.text = code; 1166 document.body.appendChild(script); 1167 } 1168} 1169 1170function cptStoriesXMLrequest(arParams){ 1171 1172 arParams = arParams || false; 1173 var path = arParams.path || false, 1174 emptySend = arParams.emptySend || false, 1175 formData = arParams.data || false; 1176 1177 var request = new XMLHttpRequest(); 1178 1179 request.open('POST',path,true); 1180 1181 request.addEventListener('readystatechange', function() 1182 { 1183 if ((request.readyState==4) && (request.status==200)){ 1184 1185 1186 if(!emptySend) 1187 { 1188 /*cptStoriesXMLrequest({ 1189 'path':'/', 1190 'emptySend':true 1191 });*/ 1192 1193 //arParams.NODE.insertAdjacentHTML("beforeEnd", request.responseText); 1194 if(arParams.NODE) 1195 { 1196 arParams.NODE.innerHTML = request.responseText; 1197 1198 var scripts = arParams.NODE.querySelectorAll('script'), script = null; 1199 1200 if(scripts) 1201 { 1202 for (var i = 0; i < scripts.length; i++) 1203 { 1204 script = document.createElement('script'); 1205 script.text = scripts[i].text; 1206 document.body.appendChild(script); 1207 } 1208 1209 } 1210 1211 if(formData.admin === 'Y') 1212 { 1213 script = document.createElement('script'); 1214 script.src = '/bitrix/tools/concept.stories/js/public_admin.js'; 1215 document.body.appendChild(script); 1216 } 1217 1218 cptStoriesResponsive(); 1219 } 1220 1221 if(arParams.HIDE_ADV) 1222 { 1223 var resJson = JSON.parse(request.responseText); 1224 1225 if(resJson.OK === 'Y') 1226 setAdvHideScript(); 1227 1228 1229 } 1230 1231 1232 } 1233 1234 1235 } 1236 }); 1237 1238 var params = "", 1239 i = 0; 1240 1241 1242 for (var pair in formData) { 1243 if(i!==0) 1244 params += "&"; 1245 1246
1247 params += pair+ '='+formData[pair]; 1248 i++; 1249 } 1250 1251 1252 request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded') 1253 1254 request.send(params); 1255} 1256function setAdvHideScript() 1257{ 1258 var script; 1259 script = document.createElement('script'); 1260 script.text = '
vendor: 286 bytes, line 1260
1260(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)}; m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)}) (window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym"); ym(
126054591493
vendor: 75 bytes, line 1260
1260, "init", { clickmap:false, trackLinks:false, accurateTrackBounce:false });
1260'; 1261 document.body.appendChild(script); 1262 1263 script = document.createElement('noscript'); 1264 script.innerHTML = "<div><img src='https://mc.yandex.ru/watch/54591493' style='position:absolute; left:-9999px;'' alt='' /></div>"; 1265 document.body.appendChild(script); 1266 1267 setTimeout( 1268 function() 1269 { 1270 script = document.createElement('script'); 1271 script.text = 'ym(54591493, \'reachGoal\', \'hide_stories\');'; 1272 document.body.appendChild(script); 1273 },2000); 1274} 1275function setBodyOverflowHidden() 1276{ 1277 document.body.classList.add('cpt-stories-overflow-hidden'); 1278 layerPopup++; 1279} 1280 1281function deleteBodyOverflowHidden() 1282{ 1283 layerPopup--; 1284 1285 if(layerPopup === 0) 1286 document.body.classList.remove('cpt-stories-overflow-hidden'); 1287}
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.