1 2; /* Start:"a:4:{s:4:"full";s:94:"/bitrix/templates/innet_focus_s2/components/bitrix/news.list/stories/script.js?171776126954406";s:6:"source";s:78:"/bitrix/templates/innet_focus_s2/components/bitrix/news.list/stories/script.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 3"use strict"; 4 5/* 6 zuck.js 7 https://github.com/ramon82/zuck.js 8 MIT License 9*/ 10(function (window) { 11 /* Utilities */ 12 var query = function query(qs) { 13 return document.querySelectorAll(qs)[0]; 14 }; 15 16 var get = function get(array, what) { 17 if (array) { 18 return array[what] || ''; 19 } else { 20 return ''; 21 } 22 }; 23 24 var each = function each(arr, func) { 25 if (arr) { 26 var total = arr.length; 27 28 for (var i = 0; i < total; i++) { 29 func(i, arr[i]); 30 } 31 } 32 }; 33 34 var setVendorVariable = function setVendorVariable(ref, variable, value) { 35 var variables = [variable.toLowerCase(), "webkit".concat(variable), "MS".concat(variable), "o".concat(variable)]; 36 each(variables, function (i, val) { 37 ref[val] = value; 38 }); 39 }; 40 41 var addVendorEvents = function addVendorEvents(el, func, event) { 42 var events = [event.toLowerCase(), "webkit".concat(event), "MS".concat(event), "o".concat(event)]; 43 each(events, function (i, val) { 44 el.addEventListener(val, func, false); 45 }); 46 }; 47 48 var onAnimationEnd = function onAnimationEnd(el, func) { 49 addVendorEvents(el, func, 'AnimationEnd'); 50 }; 51 52 var onTransitionEnd = function onTransitionEnd(el, func) { 53 if (!el.transitionEndEvent) { 54 el.transitionEndEvent = true; 55 addVendorEvents(el, func, 'TransitionEnd'); 56 } 57 }; 58 59 var prepend = function prepend(parent, child) { 60 if (parent.firstChild) { 61 parent.insertBefore(child, parent.firstChild); 62 } else { 63 parent.appendChild(child); 64 } 65 }; 66 67 var generateId = function generateId() { 68 return 'stories-' + Math.random().toString(36).substr(2, 9); 69 }; 70 /* Zuckera */ 71 72 73 var ZuckJS = function ZuckJS(timeline, options) { 74 var zuck = this; 75 76 var option = function option(name, prop) { 77 var type = function type(what) { 78 return typeof what !== 'undefined'; 79 }; 80 81 if (prop) { 82 if (type(options[name])) { 83 return type(options[name][prop]) ? options[name][prop] : optionsDefault[name][prop]; 84 } else { 85 return optionsDefault[name][prop]; 86 } 87 } else { 88 return type(options[name]) ? options[name] : optionsDefault[name]; 89 } 90 }; 91 92 var fullScreen = function fullScreen(elem, cancel) { 93 var func = 'RequestFullScreen'; 94 var elFunc = 'requestFullScreen'; // crappy vendor prefixes. 95 96 try { 97 if (cancel) { 98 if (document.fullscreenElement || document['webkitFullscreenElement'] || document['mozFullScreenElement'] || document['msFullscreenElement']) { 99 if (document.exitFullscreen) { 100 document.exitFullscreen().catch(function () {}); 101 } else if (document['mozCancelFullScreen']) { 102 document['mozCancelFullScreen']().catch(function () {}); 103 } else if (document['mozCancelFullScreen']) { 104 document['mozCancelFullScreen']().catch(function () {}); 105 } 106 } 107 } else { 108 if (elem[elFunc]) { 109 elem[elFunc](); 110 } else if (elem["ms".concat(func)]) { 111 elem["ms".concat(func)](); 112 } else if (elem["moz".concat(func)]) { 113 elem["moz".concat(func)]();
114 } else if (elem["webkit".concat(func)]) { 115 elem["webkit".concat(func)](); 116 } 117 } 118 } catch (e) { 119 console.warn('[Zuck.js] Can\'t access fullscreen'); 120 } 121 }; 122 123 var translate = function translate(element, to, duration, ease) { 124 var direction = to > 0 ? 1 : -1; 125 var to3d = Math.abs(to) / query('#zuck-modal').offsetWidth * 90 * direction; 126 127 if (option('cubeEffect')) { 128 var scaling = to3d === 0 ? 'scale(0.95)' : 'scale(0.930,0.930)'; 129 setVendorVariable(query('#zuck-modal-content').style, 'Transform', scaling); 130 131 if (to3d < -90 || to3d > 90) { 132 return false; 133 } 134 } 135 136 var transform = !option('cubeEffect') ? "translate3d(".concat(to, "px, 0, 0)") : "rotateY(".concat(to3d, "deg)"); 137 138 if (element) { 139 setVendorVariable(element.style, 'TransitionTimingFunction', ease); 140 setVendorVariable(element.style, 'TransitionDuration', "".concat(duration, "ms")); 141 setVendorVariable(element.style, 'Transform', transform); 142 } 143 }; 144 145 var findPos = function findPos(obj, offsetY, offsetX, stop) { 146 var curleft = 0; 147 var curtop = 0; 148 149 if (obj) { 150 if (obj.offsetParent) { 151 do { 152 curleft += obj.offsetLeft; 153 curtop += obj.offsetTop; 154 155 if (obj === stop) { 156 break; 157 } 158 } while (obj = obj.offsetParent); 159 } 160 161 if (offsetY) { 162 curtop = curtop - offsetY; 163 } 164 165 if (offsetX) { 166 curleft = curleft - offsetX; 167 } 168 } 169 170 return [curleft, curtop]; 171 }; 172 173 if (typeof timeline === 'string') { 174 timeline = document.getElementById(timeline); 175 } 176 177 if (!timeline.id) { 178 timeline.setAttribute('id', generateId()); 179 } 180 181 var timeAgo = function timeAgo(time) { 182 time = Number(time) * 1000; 183 var dateObj = new Date(time); 184 var dateStr = dateObj.getTime(); 185 var seconds = (new Date().getTime() - dateStr) / 1000; 186 var language = option('language', 'time'); 187 var formats = [[60, " ".concat(language['seconds']), 1], // 60 188 [120, "1 ".concat(language['minute']), ''], // 60*2 189 [3600, " ".concat(language['minutes']), 60], // 60*60, 60 190 [7200, "1 ".concat(language['hour']), ''], // 60*60*2 191 [86400, " ".concat(language['hours']), 3600], // 60*60*24, 60*60 192 [172800, " ".concat(language['yesterday']), ''], // 60*60*24*2 193 [604800, " ".concat(language['days']), 86400]]; 194 var currentFormat = 1; 195 196 if (seconds < 0) { 197 seconds = Math.abs(seconds); 198 currentFormat = 2; 199 } 200 201 var i = 0; 202 var format = void 0; 203 204 while (format = formats[i++]) { 205 if (seconds < format[0]) { 206 if (typeof format[2] === 'string') { 207 return format[currentFormat]; 208 } else { 209 return Math.floor(seconds / format[2]) + format[1]; 210 } 211 } 212 } 213 214 var day = dateObj.getDate(); 215 var month = dateObj.getMonth(); 216 var year = dateObj.getFullYear(); 217 return "".concat(day, "/").concat(month + 1, "/").concat(year); 218 }; 219 /* options */ 220 221 222 var id = timeline.id; 223 var optionsDefault = { 224 skin: 'snapgram', 225 avatars: true, 226 stories: [], 227 backButton: true, 228 backNative: false,
229 paginationArrows: false, 230 previousTap: true, 231 autoFullScreen: false, 232 openEffect: true, 233 cubeEffect: false, 234 list: false, 235 localStorage: true, 236 callbacks: { 237 onOpen: function onOpen(storyId, callback) { 238 callback(); 239 }, 240 onView: function onView(storyId) {}, 241 onEnd: function onEnd(storyId, callback) { 242 callback(); 243 }, 244 onClose: function onClose(storyId, callback) { 245 callback(); 246 }, 247 onNextItem: function onNextItem(storyId, nextStoryId, callback) { 248 callback(); 249 }, 250 onNavigateItem: function onNavigateItem(storyId, nextStoryId, callback) { 251 callback(); 252 } 253 }, 254 template: { 255 timelineItem: function timelineItem(itemData) { 256 return "\n <div class=\"story ".concat(get(itemData, 'seen') === true ? 'seen' : '', "\">\n <a class=\"item-link\" href=\"").concat(get(itemData, 'link'), "\">\n <span class=\"item-preview\">\n <img lazy=\"eager\" src=\"").concat(option('avatars') || !get(itemData, 'currentPreview') ? get(itemData, 'photo') : get(itemData, 'currentPreview'), "\" />\n </span>\n <span class=\"info\" itemProp=\"author\" itemScope itemType=\"http://schema.org/Person\">\n <strong class=\"name\" itemProp=\"name\">").concat(get(itemData, 'name'), "</strong>\n <span class=\"time\">").concat(get(itemData, 'lastUpdatedAgo'), "</span>\n </span>\n </a>\n \n <ul class=\"items\"></ul>\n </div>"); 257 }, 258 timelineStoryItem: function timelineStoryItem(itemData) { 259 return "<a href=\"".concat(get(itemData, 'src'), "\"\n data-link=\"").concat(get(itemData, 'link'), "\"\n data-linkText=\"").concat(get(itemData, 'linkText'), "\"\n data-time=\"").concat(get(itemData, 'time'), "\"\n data-type=\"").concat(get(itemData, 'type'), "\"\n data-length=\"").concat(get(itemData, 'length'), "\">\n <img loading=\"auto\" src=\"").concat(get(itemData, 'preview'), "\" />\n </a>"); 260 }, 261 viewerItem: function viewerItem(storyData, currentStoryItem) { 262 return "<div class=\"story-viewer\">\n <div class=\"head\">\n <div class=\"left\">\n ".concat(option('backButton') ? '<a class="back">‹</a>' : '', "\n\n <span class=\"item-preview\">\n <img lazy=\"eager\" class=\"profilePhoto\" src=\"").concat(get(storyData, 'photo'), "\" />\n </span>\n\n <div class=\"info\">\n <strong class=\"name\">").concat(get(storyData, 'name'), "</strong>\n <span class=\"time\">").concat(get(storyData, 'timeAgo'), "</span>\n </div>\n </div>\n \n <div class=\"right\">\n <span class=\"time\">").concat(get(currentStoryItem, 'timeAgo'), "</span>\n <span class=\"loading\"></span>\n <a class=\"close\" tabIndex=\"2\">×</a>\n </div>\n </div>\n\n <div class=\"slides-pointers\">\n <div class=\"wrap\"></div>\n </div>\n\n ").concat(option('paginationArrows') ? "<div class=\"slides-pagination\">\n <span class=\"previous\">‹</span>
262\n <span class=\"next\">›</span>\n </div>" : "", "\n </div>"); 263 }, 264 viewerItemPointer: function viewerItemPointer(index, currentIndex, item) { 265 return "<span \n class=\"".concat(currentIndex === index ? 'active' : '', " ").concat(get(item, 'seen') === true ? 'seen' : '', "\"\n data-index=\"").concat(index, "\" data-item-id=\"").concat(get(item, 'id'), "\">\n <b style=\"animation-duration:").concat(get(item, 'length') === '' ? '3' : get(item, 'length'), "s\"></b>\n </span>"); 266 }, 267 viewerItemBody: function viewerItemBody(index, currentIndex, item) { 268 return "<div \n class=\"item ".concat(get(item, 'seen') === true ? 'seen' : '', " ").concat(currentIndex === index ? 'active' : '', "\"\n data-time=\"").concat(get(item, 'time'), "\" data-type=\"").concat(get(item, 'type'), "\" data-index=\"").concat(index, "\" data-item-id=\"").concat(get(item, 'id'), "\">\n ").concat(get(item, 'type') === 'video' ? "<video class=\"media\" muted webkit-playsinline playsinline preload=\"auto\" src=\"".concat(get(item, 'src'), "\" ").concat(get(item, 'type'), "></video>\n <b class=\"tip muted\">").concat(option('language', 'unmute'), "</b>") : "<img loading=\"auto\" class=\"media\" src=\"".concat(get(item, 'src'), "\" ").concat(get(item, 'type'), " />\n "), "\n\n ").concat(get(item, 'link') ? "<a class=\"tip link\" href=\"".concat(get(item, 'link'), "\" rel=\"noopener\" target=\"_blank\">\n ").concat(!get(item, 'linkText') || get(item, 'linkText') === '' ? option('language', 'visitLink') : get(item, 'linkText'), "\n </a>") : "", "\n </div>"); 269 } 270 }, 271 language: { 272 unmute: 'Touch to unmute', 273 keyboardTip: 'Press space to see next', 274 visitLink: 'Visit link', 275 time: { 276 ago: 'ago', 277 hour: 'hour ago', 278 hours: 'hours ago', 279 minute: 'minute ago', 280 minutes: 'minutes ago', 281 fromnow: 'from now', 282 seconds: 'seconds ago', 283 yesterday: 'yesterday', 284 tomorrow: 'tomorrow', 285 days: 'days ago' 286 } 287 } 288 }; 289 /* modal */ 290 291 var ZuckModal = function ZuckModal() { 292 var modalZuckContainer = query('#zuck-modal'); 293 294 if (!modalZuckContainer && !window['Zuck'].hasModal) { 295 window['Zuck'].hasModal = true; 296 modalZuckContainer = document.createElement('div'); 297 modalZuckContainer.id = 'zuck-modal'; 298 299 if (option('cubeEffect')) { 300 modalZuckContainer.className = 'with-cube'; 301 } 302 303 modalZuckContainer.innerHTML = '<div id="zuck-modal-content"></div>'; 304 modalZuckContainer.style.display = 'none'; 305 modalZuckContainer.setAttribute('tabIndex', '1'); 306 307 modalZuckContainer.onkeyup = function (_ref) { 308 var keyCode = _ref.keyCode; 309 var code = keyCode; 310 311 if (code === 27) { 312 modal.close(); 313 } else if (code === 13 || code === 32) { 314 modal.next(); 315 } 316 }; 317 318 if (option('openEffect')) { 319 modalZuckContainer.classList.add('with-effects'); 320 } 321 322 onTransitionEnd(modalZuckContainer, function () { 323 if (modalZuckContainer.classList.contains('closed')) { 324 modalContent.innerHTML = ''; 325 modalZuckContainer.style.display = 'none'; 326 modalZuckContainer.classList.remove('closed'); 327 modalZuckContainer.classList.remove('animated'); 328 } 329 }); 330 document.body.appendChild(modalZuckContainer); 331 } 332 333 var modalContent = query('#zuck-modal-content'); 334 335 var moveStoryItem = function moveStoryItem(direction) { 336 var modalContainer = query('#zuck-modal'); 337 var target = ''; 338 var useless = ''; 339 var transform = 0; 340 var modalSlider = query("#zuck-modal-slider-".concat(id)); 341 var slideItems = { 342 previous: query('#zuck-modal .story-viewer.previous'), 343 next: query('#zuck-modal .story-viewer.next'), 344 viewing: query('#zuck-modal .story-viewer.viewing') 345 }; 346 347 if (!slideItems['previous'] && !direction || !slideItems['next'] && direction) { 348 return false; 349 } 350 351 if (!direction) { 352 target = 'previous'; 353 useless = 'next'; 354 } else { 355 target = 'next'; 356 useless = 'previous'; 357 } 358 359 var transitionTime = 600; 360 361 if (option('cubeEffect')) { 362 if (target === 'previous') { 363 transform = modalContainer.slideWidth; 364 } else if (target === 'next') { 365 transform = modalContainer.slideWidth * -1; 366 } 367 } else { 368 transform = findPos(slideItems[target])[0] * -1; 369 } 370 371 translate(modalSlider, transform, transitionTime, null); 372 setTimeout(function () { 373 if (target !== '' && slideItems[target] && useless !== '') { 374 var currentStory = slideItems[target].getAttribute('data-story-id'); 375 zuck.internalData['currentStory'] = currentStory; 376 var oldStory = query("#zuck-modal .story-viewer.".concat(useless)); 377 378 if (oldStory) { 379 oldStory.parentNode.removeChild(oldStory); 380 } 381 382 if (slideItems['viewing']) { 383 slideItems['viewing'].classList.add('stopped'); 384 slideItems['viewing'].classList.add(useless); 385 slideItems['viewing'].classList.remove('viewing'); 386 } 387 388 if (slideItems[target]) { 389 slideItems[target].classList.remove('stopped'); 390 slideItems[target].classList.remove(target); 391 slideItems[target].classList.add('viewing'); 392 } 393 394 var newStoryData = getStoryMorningGlory(target); 395 396 if (newStoryData) { 397 createStoryViewer(newStoryData, target); 398 } 399 400 var storyId = zuck.internalData['currentStory']; 401 var items = query("#zuck-modal [data-story-id=\"".concat(storyId, "\"]")); 402 403 if (items) { 404 items = items.querySelectorAll('[data-index].active'); 405 var duration = items[0].firstElementChild; 406 zuck.data[storyId]['currentItem'] = parseInt(items[0].getAttribute('data-index'), 10); 407 items[0].innerHTML = "<b style=\"".concat(duration.style.cssText, "\"></b>"); 408 onAnimationEnd(items[0].firstElementChild, function () { 409 zuck.nextItem(false); 410 }); 411 } 412 413 translate(modalSlider, '0', 0, null); 414 415 if (items) { 416 var storyViewer = query("#zuck-modal .story-viewer[data-story-id=\"".concat(currentStory, "\"]")); 417 playVideoItem(storyViewer, [items[0], items[1]], true); 418 } 419 420 option('callbacks', 'onView')(zuck.internalData['currentStory']); 421 } 422 }, transitionTime + 50); 423 }; 424 425 var createStoryViewer = function createStoryViewer(storyData, className, forcePlay) { 426 var modalSlider = query("#zuck-modal-slider-".concat(id)); 427 var storyItems = get(storyData, 'items'); 428 storyData.timeAgo = storyItems && storyItems[0] ? timeAgo(get(storyItems[0], 'time')) : ''; 429 var htmlItems = ''; 430 var pointerItems = ''; 431 var storyId = get(storyData, 'id'); 432 var slides = document.createElement('div'); 433 var currentItem = get(storyData, 'currentItem') || 0; 434 var exists = query("#zuck-modal .story-viewer[data-story-id=\"".concat(storyId, "\"]")); 435 var currentItemTime = ''; 436 437 if (exists) { 438 return false; 439 } 440 441 slides.className = 'slides'; 442 each(storyItems, function (i, item) { 443 item.timeAgo = timeAgo(get(item, 'time')); 444 445 if (currentItem > i) { 446 storyData['items'][i]['timeAgo'] = item.timeAgo; 447 storyData['items'][i]['seen'] = true; 448 item['seen'] = true; 449 } 450 451 if (currentItem === i) { 452 currentItemTime = item.timeAgo; 453 } 454
455 pointerItems += option('template', 'viewerItemPointer')(i, currentItem, item); 456 htmlItems += option('template', 'viewerItemBody')(i, currentItem, item); 457 }); 458 slides.innerHTML = htmlItems; 459 var video = slides.querySelector('video'); 460 461 var addMuted = function addMuted(video) { 462 if (video.muted) { 463 storyViewer.classList.add('muted'); 464 } else { 465 storyViewer.classList.remove('muted'); 466 } 467 }; 468 469 if (video) { 470 video.onwaiting = function (e) { 471 if (video.paused) { 472 storyViewer.classList.add('paused'); 473 storyViewer.classList.add('loading'); 474 } 475 }; 476 477 video.onplay = function () { 478 addMuted(video); 479 storyViewer.classList.remove('stopped'); 480 storyViewer.classList.remove('paused'); 481 storyViewer.classList.remove('loading'); 482 }; 483 484 video.onload = video.onplaying = video.oncanplay = function () { 485 addMuted(video); 486 storyViewer.classList.remove('loading'); 487 }; 488 489 video.onvolumechange = function () { 490 addMuted(video); 491 }; 492 } 493 494 var storyViewerWrap = document.createElement('div'); 495 storyViewerWrap.innerHTML = option('template', 'viewerItem')(storyData, currentItem); 496 var storyViewer = storyViewerWrap.firstElementChild; 497 storyViewer.className = "story-viewer muted ".concat(className, " ").concat(!forcePlay ? 'stopped' : '', " ").concat(option('backButton') ? 'with-back-button' : ''); 498 storyViewer.setAttribute('data-story-id', storyId); 499 storyViewer.querySelector('.slides-pointers .wrap').innerHTML = pointerItems; 500 each(storyViewer.querySelectorAll('.close, .back'), function (i, el) { 501 el.onclick = function (e) { 502 e.preventDefault(); 503 modal.close(); 504 }; 505 }); 506 storyViewer.appendChild(slides); 507 508 if (className === 'viewing') { 509 playVideoItem(storyViewer, storyViewer.querySelectorAll("[data-index=\"".concat(currentItem, "\"].active")), false); 510 } 511 512 each(storyViewer.querySelectorAll('.slides-pointers [data-index] > b'), function (i, el) { 513 onAnimationEnd(el, function () { 514 zuck.nextItem(false); 515 }); 516 }); 517 518 if (className === 'previous') { 519 prepend(modalSlider, storyViewer); 520 } else { 521 modalSlider.appendChild(storyViewer); 522 } 523 }; 524 525 var createStoryTouchEvents = function createStoryTouchEvents(modalSliderElement) { 526 var modalContainer = query('#zuck-modal'); 527 var enableMouseEvents = true; 528 var modalSlider = modalSliderElement; 529 var position = {}; 530 var touchOffset = void 0; 531 var isScrolling = void 0; 532 var delta = void 0; 533 var timer = void 0; 534 var nextTimer = void 0; 535 536 var touchStart = function touchStart(event) { 537 var storyViewer = query('#zuck-modal .viewing'); 538 539 if (event.target.nodeName === 'A') { 540 return true; 541 } else { 542 event.preventDefault(); 543 } 544 545 var touches = event.touches ? event.touches[0] : event; 546 var pos = findPos(query('#zuck-modal .story-viewer.viewing'));
547 modalContainer.slideWidth = query('#zuck-modal .story-viewer').offsetWidth; 548 position = { 549 x: pos[0], 550 y: pos[1] 551 }; 552 var pageX = touches.pageX; 553 var pageY = touches.pageY; 554 touchOffset = { 555 x: pageX, 556 y: pageY, 557 time: Date.now() 558 }; 559 isScrolling = undefined; 560 delta = {}; 561 562 if (enableMouseEvents) { 563 modalSlider.addEventListener('mousemove', touchMove); 564 modalSlider.addEventListener('mouseup', touchEnd); 565 modalSlider.addEventListener('mouseleave', touchEnd); 566 } 567 568 modalSlider.addEventListener('touchmove', touchMove); 569 modalSlider.addEventListener('touchend', touchEnd); 570 571 if (storyViewer) { 572 storyViewer.classList.add('paused'); 573 } 574 575 pauseVideoItem(); 576 timer = setTimeout(function () { 577 storyViewer.classList.add('longPress'); 578 }, 600); 579 nextTimer = setTimeout(function () { 580 clearInterval(nextTimer); 581 nextTimer = false; 582 }, 250); 583 }; 584 585 var touchMove = function touchMove(event) { 586 var touches = event.touches ? event.touches[0] : event; 587 var pageX = touches.pageX; 588 var pageY = touches.pageY; 589 590 if (touchOffset) { 591 delta = { 592 x: pageX - touchOffset.x, 593 y: pageY - touchOffset.y 594 }; 595 596 if (typeof isScrolling === 'undefined') { 597 isScrolling = !!(isScrolling || Math.abs(delta.x) < Math.abs(delta.y)); 598 } 599 600 if (!isScrolling && touchOffset) { 601 event.preventDefault(); 602 translate(modalSlider, position.x + delta.x, 0, null); 603 } 604 } 605 }; 606 607 var touchEnd = function touchEnd(event) { 608 var storyViewer = query('#zuck-modal .viewing'); 609 var lastTouchOffset = touchOffset; 610 611 if (delta) { 612 var duration = touchOffset ? Date.now() - touchOffset.time : undefined; 613 var isValid = Number(duration) < 300 && Math.abs(delta.x) > 25 || Math.abs(delta.x) > modalContainer.slideWidth / 3; 614 var direction = delta.x < 0; 615 var index = direction ? query('#zuck-modal .story-viewer.next') : query('#zuck-modal .story-viewer.previous'); 616 var isOutOfBounds = direction && !index || !direction && !index; 617 618 if (!isScrolling) { 619 if (isValid && !isOutOfBounds) { 620 moveStoryItem(direction); 621 } else { 622 translate(modalSlider, position.x, 300); 623 } 624 } 625 626 touchOffset = undefined; 627 628 if (enableMouseEvents) { 629 modalSlider.removeEventListener('mousemove', touchMove); 630 modalSlider.removeEventListener('mouseup', touchEnd); 631 modalSlider.removeEventListener('mouseleave', touchEnd); 632 } 633 634 modalSlider.removeEventListener('touchmove', touchMove); 635 modalSlider.removeEventListener('touchend', touchEnd); 636 } 637 638 var video = zuck.internalData['currentVideoElement']; 639 640 if (timer) { 641 clearInterval(timer); 642 } 643 644 if (storyViewer) { 645 playVideoItem(storyViewer, storyViewer.querySelectorAll('.active'), false); 646 storyViewer.classList.remove('longPress'); 647 storyViewer.classList.remove('paused'); 648 } 649 650 if (nextTimer) { 651 clearInterval(nextTimer); 652 nextTimer = false; 653 654 var navigateItem = function navigateItem() { 655 if (lastTouchOffset.x > window.screen.width / 3 || !option('previousTap')) { 656 zuck.navigateItem('next', event); 657 } else { 658 zuck.navigateItem('previous', event); 659 } 660 }; 661 662 var storyViewerViewing = query('#zuck-modal .viewing'); 663 664 if (storyViewerViewing && video) { 665 if (storyViewerViewing.classList.contains('muted')) { 666 unmuteVideoItem(video, storyViewerViewing); 667 } else { 668 navigateItem(); 669 } 670 } else { 671 navigateItem(); 672 return false; 673 } 674 } 675 }; 676 677 modalSlider.addEventListener('touchstart', touchStart); 678 679 if (enableMouseEvents) { 680 modalSlider.addEventListener('mousedown', touchStart); 681 } 682 }; 683 684 return { 685 show: function show(storyId, page) { 686 var modalContainer = query('#zuck-modal'); 687 688 var callback = function callback() { 689 modalContent.innerHTML = "<div id=\"zuck-modal-slider-".concat(id, "\" class=\"slider\"></div>"); 690 var storyData = zuck.data[storyId]; 691 var currentItem = storyData['currentItem'] || 0; 692 var modalSlider = query("#zuck-modal-slider-".concat(id)); 693 createStoryTouchEvents(modalSlider); 694 zuck.internalData['currentStory'] = storyId; 695 storyData['currentItem'] = currentItem; 696 697 if (option('backNative')) { 698 window.location.hash = "#!".concat(id); 699 } 700 701 var previousItemData = getStoryMorningGlory('previous'); 702 703 if (previousItemData) { 704 createStoryViewer(previousItemData, 'previous'); 705 } 706 707 createStoryViewer(storyData, 'viewing', true); 708 var nextItemData = getStoryMorningGlory('next'); 709 710 if (nextItemData) { 711 createStoryViewer(nextItemData, 'next'); 712 } 713 714 if (option('autoFullScreen')) { 715 modalContainer.classList.add('fullscreen'); 716 } 717 718 var tryFullScreen = function tryFullScreen() { 719 if (modalContainer.classList.contains('fullscreen') && option('autoFullScreen') && window.screen.width <= 1024) { 720 fullScreen(modalContainer); 721 } 722 723 modalContainer.focus(); 724 }; 725 726 if (option('openEffect')) { 727 var storyEl = query("#".concat(id, " [data-id=\"").concat(storyId, "\"] .item-preview")); 728 var pos = findPos(storyEl); 729 modalContainer.style.marginLeft = "".concat(pos[0] + storyEl.offsetWidth / 2, "px"); 730 modalContainer.style.marginTop = "".concat(pos[1] + storyEl.offsetHeight / 2, "px"); 731 modalContainer.style.display = 'block'; 732 modalContainer.slideWidth = query('#zuck-modal .story-viewer').offsetWidth; 733 setTimeout(function () { 734 modalContainer.classList.add('animated'); 735 }, 10); 736 setTimeout(function () { 737 tryFullScreen(); 738 }, 300); // because effects 739 } else { 740 modalContainer.style.display = 'block'; 741 modalContainer.slideWidth = query('#zuck-modal .story-viewer').offsetWidth; 742 tryFullScreen(); 743 } 744 745 option('callbacks', 'onView')(storyId); 746 }; 747 748 option('callbacks', 'onOpen')(storyId, callback); 749 $('body').css({'overflow-':'hidden'}); 750 }, 751 next: function next(unmute) { 752 var callback = function callback() { 753 var lastStory = zuck.internalData['currentStory']; 754 var lastStoryTimelineElement = query("#".concat(id, " [data-id=\"").concat(lastStory, "\"]")); 755 756 if (lastStoryTimelineElement) { 757 lastStoryTimelineElement.classList.add('seen'); 758 zuck.data[lastStory]['seen'] = true; 759 zuck.internalData['seenItems'][lastStory] = true; 760 saveLocalData('seenItems', zuck.internalData['seenItems']); 761 updateStorySeenPosition(); 762 } 763 764 var stories = query('#zuck-modal .story-viewer.next'); 765 766 if (!stories) { 767 modal.close(); 768 } else { 769 moveStoryItem(true); 770 } 771 }; 772 773 option('callbacks', 'onEnd')(zuck.internalData['currentStory'], callback); 774 }, 775 close: function close() { 776 var modalContainer = query('#zuck-modal'); 777 778 var callback = function callback() { 779 if (option('backNative')) { 780 window.location.hash = ''; 781 } 782 783 fullScreen(modalContainer, true); 784 785 if (option('openEffect')) { 786 modalContainer.classList.add('closed'); 787 } else { 788 modalContent.innerHTML = ''; 789 modalContainer.style.display = 'none'; 790 } 791 }; 792 793 option('callbacks', 'onClose')(zuck.internalData['currentStory'], callback); 794 $('body').css({'overflow-y':'auto'}); 795 } 796 }; 797 }; 798 799 var modal = ZuckModal(); 800 /* parse functions */ 801
802 var parseItems = function parseItems(story, forceUpdate) { 803 var storyId = story.getAttribute('data-id'); 804 var storyItems = document.querySelectorAll("#".concat(id, " [data-id=\"").concat(storyId, "\"] .items > li")); 805 var items = []; 806 807 if (!option('reactive') || forceUpdate) { 808 each(storyItems, function (i, _ref2) { 809 var firstElementChild = _ref2.firstElementChild; 810 var a = firstElementChild; 811 var img = a.firstElementChild; 812 items.push({ 813 id: a.getAttribute('data-id'), 814 src: a.getAttribute('href'), 815 length: a.getAttribute('data-length'), 816 type: a.getAttribute('data-type'), 817 time: a.getAttribute('data-time'), 818 link: a.getAttribute('data-link'), 819 linkText: a.getAttribute('data-linkText'), 820 preview: img.getAttribute('src') 821 }); 822 }); 823 zuck.data[storyId].items = items; 824 var callback = option('callbacks', 'onDataUpdate'); 825 826 if (callback) { 827 callback(zuck.data, function () {}); 828 } 829 } 830 }; 831 832 var parseStory = function parseStory(story, returnCallback) { 833 var storyId = story.getAttribute('data-id'); 834 var seen = false; 835 836 if (zuck.internalData['seenItems'][storyId]) { 837 seen = true; 838 } 839 /* 840 REACT 841 if (seen) { 842 story.classList.add('seen'); 843 } else { 844 story.classList.remove('seen'); 845 } 846 */ 847 848 849 try { 850 if (!zuck.data[storyId]) { 851 zuck.data[storyId] = {}; 852 } 853 854 zuck.data[storyId].id = storyId; // story id 855 856 zuck.data[storyId].photo = story.getAttribute('data-photo'); // story preview (or user photo) 857 858 zuck.data[storyId].name = story.querySelector('.name').innerText; 859 zuck.data[storyId].link = story.querySelector('.item-link').getAttribute('href'); 860 zuck.data[storyId].lastUpdated = story.getAttribute('data-last-updated'); 861 zuck.data[storyId].seen = seen; 862 863 if (!zuck.data[storyId].items) { 864 zuck.data[storyId].items = []; 865 zuck.data[storyId].noItems = true; 866 } 867 } catch (e) { 868 zuck.data[storyId] = { 869 items: [] 870 }; 871 } 872 873 story.onclick = function (e) { 874 e.preventDefault(); 875 modal.show(storyId); 876 }; 877 878 var callback = option('callbacks', 'onDataUpdate'); 879 880 if (callback) { 881 callback(zuck.data, function () {}); 882 } 883 }; // BIBLICAL 884 885 886 var getStoryMorningGlory = function getStoryMorningGlory(what) { 887 // my wife told me to stop singing Wonderwall. I SAID MAYBE. 888 var currentStory = zuck.internalData['currentStory']; 889 var whatElementYouMean = "".concat(what, "ElementSibling"); 890 891 if (currentStory) { 892 var foundStory = query("#".concat(id, " [data-id=\"").concat(currentStory, "\"]"))[whatElementYouMean]; 893 894 if (foundStory) { 895 var storyId = foundStory.getAttribute('data-id'); 896 var data = zuck.data[storyId] || false; 897 return data; 898 } 899 } 900 901 return false; 902 }; 903 904 var updateStorySeenPosition = function updateStorySeenPosition() { 905 each(document.querySelectorAll("#".concat(id, " .story.seen")), function (i, el) { 906 var newData = zuck.data[el.getAttribute('data-id')]; 907 var timeline = el.parentNode; 908 909 if (!option('reactive')) { 910 timeline.removeChild(el); 911 } 912 913 zuck.update(newData, true); 914 }); 915 }; 916 917 var playVideoItem = function playVideoItem(storyViewer, elements, unmute) { 918 var itemElement = elements[1]; 919 var itemPointer = elements[0]; 920 921 if (!itemElement || !itemPointer) { 922 return false; 923 } 924 925 var cur = zuck.internalData['currentVideoElement']; 926 927 if (cur) { 928 cur.pause(); 929 } 930 931 if (itemElement.getAttribute('data-type') === 'video') { 932 var video = itemElement.getElementsByTagName('video')[0]; 933 934 if (!video) { 935 zuck.internalData['currentVideoElement'] = false; 936 return false; 937 } 938 939 var setDuration = function setDuration() { 940 if (video.duration) { 941 setVendorVariable(itemPointer.getElementsByTagName('b')[0].style, 'AnimationDuration', "".concat(video.duration, "s")); 942 } 943 }; 944 945 setDuration(); 946 video.addEventListener('loadedmetadata', setDuration); 947 zuck.internalData['currentVideoElement'] = video; 948 video.play(); 949 950 if (unmute && unmute.target) { 951 unmuteVideoItem(video, storyViewer); 952 } 953 } else { 954 zuck.internalData['currentVideoElement'] = false; 955 } 956 }; 957 958 var pauseVideoItem = function pauseVideoItem() { 959 var video = zuck.internalData['currentVideoElement']; 960 961 if (video) { 962 try { 963 video.pause(); 964 } catch (e) {} 965 } 966 }; 967 968 var unmuteVideoItem = function unmuteVideoItem(video, storyViewer) { 969 video.muted = false; 970 video.volume = 1.0; 971 video.removeAttribute('muted'); 972 video.play(); 973 974 if (video.paused) { 975 video.muted = true; 976 video.play(); 977 } 978 979 if (storyViewer) { 980 storyViewer.classList.remove('paused'); 981 } 982 }; 983 /* data functions */ 984 985 986 var saveLocalData = function saveLocalData(key, data) { 987 try { 988 if (option('localStorage')) { 989 var keyName = "zuck-".concat(id, "-").concat(key); 990 window.localStorage[keyName] = JSON.stringify(data); 991 } 992 } catch (e) {} 993 }; 994 995 var getLocalData = function getLocalData(key) { 996 if (option('localStorage')) { 997 var keyName = "zuck-".concat(id, "-").concat(key); 998 return window.localStorage[keyName] ? JSON.parse(window.localStorage[keyName]) : false; 999 } else { 1000 return false; 1001 } 1002 }; 1003 /* api */ 1004 1005 1006 zuck.data = option('stories') || {}; 1007 zuck.internalData = {}; 1008 zuck.internalData['seenItems'] = getLocalData('seenItems') || {}; 1009 1010 zuck.add = zuck.update = function (data, append) { 1011 var storyId = get(data, 'id'); 1012 var storyEl = query("#".concat(id, " [data-id=\"").concat(storyId, "\"]")); 1013 var items = get(data, 'items'); 1014 var story = undefined; 1015 var preview = false; 1016 1017 if (items[0]) { 1018 preview = items[0]['preview'] || ''; 1019 } 1020 1021 if (zuck.internalData['seenItems'][storyId] === true) { 1022 data.seen = true; 1023 } 1024 1025 data.currentPreview = preview; 1026 1027 if (!storyEl) { 1028 var storyItem = document.createElement('div'); 1029 storyItem.innerHTML = option('template', 'timelineItem')(data); 1030 story = storyItem.firstElementChild; 1031 } else { 1032 story = storyEl; 1033 } 1034 1035 if (data['seen'] === false) { 1036 zuck.internalData['seenItems'][storyId] = false; 1037 saveLocalData('seenItems', zuck.internalData['seenItems']); 1038 } 1039 1040 story.setAttribute('data-id', storyId); 1041 story.setAttribute('data-photo', get(data, 'photo')); 1042 story.setAttribute('data-last-updated', get(data, 'lastUpdated')); 1043 parseStory(story); 1044 1045 if (!storyEl && !option('reactive')) { 1046 if (append) { 1047 timeline.appendChild(story); 1048 } else { 1049 prepend(timeline, story); 1050 } 1051 } 1052 1053 each(items, function (i, item) { 1054 zuck.addItem(storyId, item, append); 1055 }); 1056 1057 if (!append) { 1058 updateStorySeenPosition(); 1059 } 1060 }; 1061 1062 zuck.next = function () { 1063 modal.next(); 1064 }; 1065 1066 zuck.remove = function (storyId) { 1067 var story = query("#".concat(id, " > [data-id=\"").concat(storyId, "\"]")); 1068 story.parentNode.removeChild(story); 1069 }; 1070 1071 zuck.addItem = function (storyId, data, append) { 1072 var story = query("#".concat(id, " > [data-id=\"").concat(storyId, "\"]")); 1073 1074 if (!option('reactive')) { 1075 var li = document.createElement('li'); 1076 var el = story.querySelectorAll('.items')[0]; 1077 li.className = get(data, 'seen') ? 'seen' : ''; 1078 li.setAttribute('data-id', get(data, 'id')); // wow, too much jsx 1079 1080 li.innerHTML = option('template', 'timelineStoryItem')(data); 1081 1082 if (append) { 1083 el.appendChild(li); 1084 } else { 1085 prepend(el, li); 1086 } 1087 } 1088 1089 parseItems(story); 1090 }; 1091 1092 zuck.removeItem = function (storyId, itemId) { 1093 var item = query("#".concat(id, " > [data-id=\"").concat(storyId, "\"] [data-id=\"").concat(itemId, "\"]")); 1094 1095 if (!option('reactive')) { 1096 timeline.parentNode.removeChild(item); 1097 } 1098 }; 1099 1100 zuck.navigateItem = zuck.nextItem = function (direction, event) { 1101 var currentStory = zuck.internalData['currentStory']; 1102 var currentItem = zuck.data[currentStory]['currentItem']; 1103 var storyViewer = query("#zuck-modal .story-viewer[data-story-id=\"".concat(currentStory, "\"]")); 1104 var directionNumber = direction === 'previous' ? -1 : 1; 1105 1106 if (!storyViewer || storyViewer.touchMove === 1) { 1107 return false; 1108 } 1109 1110 var currentItemElements = storyViewer.querySelectorAll("[data-index=\"".concat(currentItem, "\"]")); 1111 var currentPointer = currentItemElements[0]; 1112 var currentItemElement = currentItemElements[1]; 1113 var navigateItem = currentItem + directionNumber; 1114 var nextItems = storyViewer.querySelectorAll("[data-index=\"".concat(navigateItem, "\"]")); 1115 var nextPointer = nextItems[0]; 1116 var nextItem = nextItems[1]; 1117 1118 if (storyViewer && nextPointer && nextItem) { 1119 var navigateItemCallback = function navigateItemCallback() { 1120 if (direction === 'previous') { 1121 currentPointer.classList.remove('seen'); 1122 currentItemElement.classList.remove('seen'); 1123 } else { 1124 currentPointer.classList.add('seen'); 1125 currentItemElement.classList.add('seen'); 1126 } 1127 1128 currentPointer.classList.remove('active'); 1129 currentItemElement.classList.remove('active'); 1130 nextPointer.classList.remove('seen'); 1131 nextPointer.classList.add('active'); 1132 nextItem.classList.remove('seen'); 1133 nextItem.classList.add('active'); 1134 each(storyViewer.querySelectorAll('.time'), function (i, el) { 1135 el.innerText = timeAgo(nextItem.getAttribute('data-time')); 1136 }); 1137 zuck.data[currentStory]['currentItem'] = zuck.data[currentStory]['currentItem'] + directionNumber; 1138 playVideoItem(storyViewer, nextItems, event); 1139 }; 1140 1141 var callback = option('callbacks', 'onNavigateItem'); 1142 callback = !callback ? option('callbacks', 'onNextItem') : option('callbacks', 'onNavigateItem'); 1143 callback(currentStory, nextItem.getAttribute('data-story-id'), navigateItemCallback); 1144 } else if (storyViewer) { 1145 if (direction !== 'previous') { 1146 modal.next(event); 1147 } 1148 } 1149 }; 1150
1151 var init = function init() { 1152 if (timeline && timeline.querySelector('.story')) { 1153 each(timeline.querySelectorAll('.story'), function (storyIndex, story) { 1154 parseStory(story); 1155 }); 1156 } 1157 1158 if (option('backNative')) { 1159 if (window.location.hash === "#!".concat(id)) { 1160 window.location.hash = ''; 1161 } 1162 1163 window.addEventListener('popstate', function (e) { 1164 if (window.location.hash !== "#!".concat(id)) { 1165 window.location.hash = ''; 1166 } 1167 }, false); 1168 } 1169 1170 if (!option('reactive')) { 1171 var seenItems = getLocalData('seenItems'); 1172 1173 for (var key in seenItems) { 1174 if (seenItems.hasOwnProperty(key)) { 1175 if (zuck.data[key]) { 1176 zuck.data[key].seen = seenItems[key]; 1177 } 1178 } 1179 } 1180 } 1181 1182 each(option('stories'), function (i, item) { 1183 zuck.add(item, true); 1184 }); 1185 updateStorySeenPosition(); 1186 var avatars = option('avatars') ? 'user-icon' : 'story-preview'; 1187 var list = option('list') ? 'list' : 'carousel'; 1188 timeline.className += " stories ".concat(avatars, " ").concat(list, " ").concat("".concat(option('skin')).toLowerCase()); 1189 return zuck; 1190 }; 1191 1192 return init(); 1193 }; 1194 /* Helpers */ 1195 1196 1197 ZuckJS.buildTimelineItem = function (id, photo, name, link, lastUpdated, items) { 1198 var timelineItem = { 1199 id: id, 1200 photo: photo, 1201 name: name, 1202 link: link, 1203 lastUpdated: lastUpdated, 1204 items: [] 1205 }; 1206 each(items, function (itemIndex, itemArgs) { 1207 timelineItem.items.push(ZuckJS.buildStoryItem.apply(ZuckJS, itemArgs)); 1208 }); 1209 return timelineItem; 1210 }; 1211 1212 ZuckJS.buildStoryItem = function (id, type, length, src, preview, link, linkText, seen, time) { 1213 return { 1214 id: id, 1215 type: type, 1216 length: length, 1217 src: src, 1218 preview: preview, 1219 link: link, 1220 linkText: linkText, 1221 seen: seen, 1222 time: time 1223 }; 1224 }; 1225 /* Legacy code */ 1226 1227 1228 ZuckJS.buildItem = ZuckJS.buildStoryItem; // CommonJS and Node.js module support. 1229 1230 if (typeof exports !== 'undefined') { 1231 // Support Node.js specific `module.exports` (which can be a function) 1232 if (typeof module !== 'undefined' && module.exports) { 1233 exports = module.exports = ZuckJS; 1234 } // But always support CommonJS module 1.1.1 spec (`exports` cannot be a function) 1235 1236 1237 exports.ZuckJS = ZuckJS; 1238 } else { 1239 /* Too much zuck zuck to maintain legacy */ 1240 window['ZuckitaDaGalera'] = window['Zuck'] = ZuckJS; 1241 } 1242 1243 return ZuckJS; 1244})(window); 1245/* End */ 1246; 1247; /* Start:"a:4:{s:4:"full";s:103:"/bitrix/templates/innet_focus_s2/components/bitrix/catalog.section/wide_slider/script.js?16440949398298";s:6:"source";s:88:"/bitrix/templates/innet_focus_s2/components/bitrix/catalog.section/wide_slider/script.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 1248(function() { 1249 'use strict'; 1250 1251 if (!!window.JCCatalogSectionComponent) 1252 return; 1253 1254 window.JCCatalogSectionComponent = function(params) { 1255 this.formPosting = false; 1256 this.siteId = params.siteId || ''; 1257 this.ajaxId = params.ajaxId || ''; 1258 this.template = params.template || ''; 1259 this.componentPath = params.componentPath || ''; 1260 this.parameters = params.parameters || ''; 1261 1262 if (params.navParams) 1263 { 1264 this.navParams = { 1265 NavNum: params.navParams.NavNum || 1, 1266 NavPageNomer: parseInt(params.navParams.NavPageNomer) || 1, 1267 NavPageCount: parseInt(params.navParams.NavPageCount) || 1 1268 }; 1269 } 1270 1271 this.bigData = params.bigData || {enabled: false}; 1272 this.container = document.querySelector('[data-entity="' + params.container + '"]'); 1273 this.showMoreButton = null; 1274 this.showMoreButtonMessage = null; 1275 1276 if (this.bigData.enabled && BX.util.object_keys(this.bigData.rows).length > 0) 1277 { 1278 BX.cookie_prefix = this.bigData.js.cookiePrefix || ''; 1279 BX.cookie_domain = this.bigData.js.cookieDomain || ''; 1280 BX.current_server_time = this.bigData.js.serverTime; 1281 1282 BX.ready(BX.delegate(this.bigDataLoad, this)); 1283 } 1284 1285 if (params.initiallyShowHeader) 1286 { 1287 BX.ready(BX.delegate(this.showHeader, this)); 1288 } 1289 1290 if (params.deferredLoad) 1291 { 1292 BX.ready(BX.delegate(this.deferredLoad, this)); 1293 } 1294 1295 if (params.lazyLoad) 1296 { 1297 this.showMoreButton = document.querySelector('[data-use="show-more-' + this.navParams.NavNum + '"]'); 1298 this.showMoreButtonMessage = this.showMoreButton.innerHTML; 1299 BX.bind(this.showMoreButton, 'click', BX.proxy(this.showMore, this)); 1300 } 1301 1302 if (params.loadOnScroll) 1303 { 1304 BX.bind(window, 'scroll', BX.proxy(this.loadOnScroll, this)); 1305 } 1306 }; 1307 1308 window.JCCatalogSectionComponent.prototype = 1309 { 1310 checkButton: function() 1311 { 1312 if (this.showMoreButton) 1313 { 1314 if (this.navParams.NavPageNomer == this.navParams.NavPageCount) 1315 { 1316 BX.remove(this.showMoreButton); 1317 } 1318 else 1319 { 1320 this.container.appendChild(this.showMoreButton); 1321 } 1322 } 1323 }, 1324 1325 enableButton: function() 1326 { 1327 if (this.showMoreButton) 1328 { 1329 BX.removeClass(this.showMoreButton, 'disabled'); 1330 this.showMoreButton.innerHTML = this.showMoreButtonMessage; 1331 } 1332 }, 1333 1334 disableButton: function() 1335 { 1336 if (this.showMoreButton) 1337 { 1338 BX.addClass(this.showMoreButton, 'disabled'); 1339 this.showMoreButton.innerHTML = BX.message('BTN_MESSAGE_LAZY_LOAD_WAITER'); 1340 } 1341 }, 1342 1343 loadOnScroll: function() 1344 { 1345 var scrollTop = BX.GetWindowScrollPos().scrollTop, 1346 containerBottom = BX.pos(this.container).bottom; 1347 1348 if (scrollTop + window.innerHeight > containerBottom) 1349 { 1350 this.showMore(); 1351 } 1352 }, 1353 1354 showMore: function() 1355 { 1356 if (this.navParams.NavPageNomer < this.navParams.NavPageCount) 1357 { 1358 var data = {}; 1359 data['action'] = 'showMore'; 1360 data['PAGEN_' + this.navParams.NavNum] = this.navParams.NavPageNomer + 1; 1361 1362 if (!this.formPosting) 1363 { 1364 this.formPosting = true; 1365 this.disableButton(); 1366 this.sendRequest(data); 1367 } 1368 } 1369 }, 1370 1371 bigDataLoad: function() 1372 { 1373 var url = 'https://analytics.bitrix.info/crecoms/v1_0/recoms.php',
1374 data = BX.ajax.prepareData(this.bigData.params); 1375 1376 if (data) 1377 { 1378 url += (url.indexOf('?') !== -1 ? '&' : '?') + data; 1379 } 1380 1381 var onReady = BX.delegate(function(result){ 1382 this.sendRequest({ 1383 action: 'deferredLoad', 1384 bigData: 'Y', 1385 items: result && result.items || [], 1386 rid: result && result.id, 1387 count: this.bigData.count, 1388 rowsRange: this.bigData.rowsRange, 1389 shownIds: this.bigData.shownIds 1390 }); 1391 }, this); 1392 1393 BX.ajax({ 1394 method: 'GET', 1395 dataType: 'json', 1396 url: url, 1397 timeout: 3, 1398 onsuccess: onReady, 1399 onfailure: onReady 1400 }); 1401 }, 1402 1403 deferredLoad: function() 1404 { 1405 this.sendRequest({action: 'deferredLoad'}); 1406 }, 1407 1408 sendRequest: function(data) 1409 { 1410 var defaultData = { 1411 siteId: this.siteId, 1412 template: this.template, 1413 parameters: this.parameters 1414 }; 1415 1416 if (this.ajaxId) 1417 { 1418 defaultData.AJAX_ID = this.ajaxId; 1419 } 1420 1421 BX.ajax({ 1422 url: this.componentPath + '/ajax.php' + (document.location.href.indexOf('clear_cache=Y') !== -1 ? '?clear_cache=Y' : ''), 1423 method: 'POST', 1424 dataType: 'json', 1425 timeout: 60, 1426 data: BX.merge(defaultData, data), 1427 onsuccess: BX.delegate(function(result){ 1428 if (!result || !result.JS) 1429 return; 1430 1431 BX.ajax.processScripts( 1432 BX.processHTML(result.JS).SCRIPT, 1433 false, 1434 BX.delegate(function(){this.showAction(result, data);}, this) 1435 ); 1436 }, this) 1437 }); 1438 }, 1439 1440 showAction: function(result, data) 1441 { 1442 if (!data) 1443 return; 1444 1445 switch (data.action) 1446 { 1447 case 'showMore': 1448 this.processShowMoreAction(result); 1449 break; 1450 case 'deferredLoad': 1451 this.processDeferredLoadAction(result, data.bigData === 'Y'); 1452 break; 1453 } 1454 }, 1455 1456 processShowMoreAction: function(result) 1457 { 1458 this.formPosting = false; 1459 this.enableButton(); 1460 1461 if (result) 1462 { 1463 this.navParams.NavPageNomer++; 1464 this.processItems(result.items); 1465 this.processPagination(result.pagination); 1466 this.checkButton(); 1467 } 1468 }, 1469 1470 processDeferredLoadAction: function(result, bigData) 1471 { 1472 if (!result) 1473 return; 1474 1475 var position = bigData ? this.bigData.rows : {}; 1476 1477 this.processItems(result.items, BX.util.array_keys(position)); 1478 }, 1479 1480 processItems: function(itemsHtml, position) 1481 { 1482 if (!itemsHtml) 1483 return; 1484 1485 var processed = BX.processHTML(itemsHtml, false), 1486 temporaryNode = BX.create('DIV'); 1487 1488 var items, k, origRows; 1489 1490 temporaryNode.innerHTML = processed.HTML; 1491 items = temporaryNode.querySelectorAll('[data-entity="items-row"]'); 1492 1493 if (items.length) 1494 { 1495 this.showHeader(true); 1496 1497 for (k in items) 1498 { 1499 if (items.hasOwnProperty(k)) 1500 { 1501 origRows = position ? this.container.querySelectorAll('[data-entity="items-row"]') : false; 1502 items[k].style.opacity = 0; 1503 1504 if (origRows && BX.type.isDomNode(origRows[position[k]])) 1505 { 1506 origRows[position[k]].parentNode.insertBefore(items[k], origRows[position[k]]); 1507 } 1508 else 1509 { 1510 this.container.appendChild(items[k]); 1511 } 1512 } 1513 } 1514 1515 new BX.easing({ 1516 duration: 2000, 1517 start: {opacity: 0}, 1518 finish: {opacity: 100}, 1519 transition: BX.easing.makeEaseOut(BX.easing.transitions.quad), 1520 step: function(state){ 1521 for (var k in items) 1522 { 1523 if (items.hasOwnProperty(k)) 1524 { 1525 items[k].style.opacity = state.opacity / 100; 1526 } 1527 } 1528 }, 1529 complete: function(){ 1530 for (var k in items) 1531 { 1532 if (items.hasOwnProperty(k)) 1533 { 1534 items[k].removeAttribute('style'); 1535 } 1536 } 1537 } 1538 }).animate(); 1539 } 1540 1541 BX.ajax.processScripts(processed.SCRIPT); 1542 }, 1543 1544 processPagination: function(paginationHtml) 1545 { 1546 if (!paginationHtml) 1547 return; 1548 1549 var pagination = document.querySelectorAll('[data-pagination-num="' + this.navParams.NavNum + '"]'); 1550 for (var k in pagination) 1551 { 1552 if (pagination.hasOwnProperty(k)) 1553 { 1554 pagination[k].innerHTML = paginationHtml; 1555 } 1556 } 1557 }, 1558 1559 showHeader: function(animate) 1560 { 1561 var parentNode = BX.findParent(this.container, {attr: {'data-entity': 'parent-container'}}), 1562 header; 1563 1564 if (parentNode && BX.type.isDomNode(parentNode)) 1565 { 1566 header = parentNode.querySelector('[data-entity="header"]'); 1567 1568 if (header && header.getAttribute('data-showed') != 'true') 1569 { 1570 header.style.display = ''; 1571 1572 if (animate) 1573 { 1574 new BX.easing({ 1575 duration: 2000, 1576 start: {opacity: 0}, 1577 finish: {opacity: 100}, 1578 transition: BX.easing.makeEaseOut(BX.easing.transitions.quad), 1579 step: function(state){ 1580 header.style.opacity = state.opacity / 100; 1581 }, 1582 complete: function(){ 1583 header.removeAttribute('style'); 1584 header.setAttribute('data-showed', 'true'); 1585 } 1586 }).animate(); 1587 } 1588 else 1589 { 1590 header.style.opacity = 100; 1591 } 1592 } 1593 } 1594 } 1595 }; 1596})(); 1597/* End */ 1598; 1599; /* Start:"a:4:{s:4:"full";
1599s:101:"/bitrix/templates/innet_focus_s2/components/bitrix/catalog.item/innet_slide/script.js?167733398074799";s:6:"source";s:85:"/bitrix/templates/innet_focus_s2/components/bitrix/catalog.item/innet_slide/script.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 1600(function (window){ 1601 'use strict'; 1602 1603 if (window.JCCatalogItem) 1604 return; 1605 1606 var BasketButton = function(params) 1607 { 1608 BasketButton.superclass.constructor.apply(this, arguments); 1609 this.buttonNode = BX.create('span', { 1610 props: {className: 'custom-btn custom-btn--style-1 btn-md', id: this.id}, 1611 style: typeof params.style === 'object' ? params.style : {}, 1612 text: params.text, 1613 events: this.contextEvents 1614 }); 1615 1616 if (BX.browser.IsIE()) 1617 { 1618 this.buttonNode.setAttribute("hideFocus", "hidefocus"); 1619 } 1620 }; 1621 BX.extend(BasketButton, BX.PopupWindowButton); 1622 1623 window.JCCatalogItem = function (arParams) 1624 { 1625 this.productType = 0; 1626 this.showQuantity = true; 1627 this.showAbsent = true; 1628 this.secondPict = false; 1629 this.showOldPrice = false; 1630 this.showMaxQuantity = 'N'; 1631 this.relativeQuantityFactor = 5; 1632 this.showPercent = false; 1633 this.showSkuProps = false; 1634 this.basketAction = 'ADD'; 1635 this.showClosePopup = false; 1636 this.useCompare = false; 1637 this.useDelay = false; 1638 this.showSubscription = false; 1639 this.visual = { 1640 ID: '', 1641 PICT_ID: '', 1642 SECOND_PICT_ID: '', 1643 PICT_SLIDER_ID: '', 1644 QUANTITY_ID: '', 1645 QUANTITY_UP_ID: '', 1646 QUANTITY_DOWN_ID: '', 1647 PRICE_ID: '', 1648 PRICE_OLD_ID: '', 1649 DSC_PERC: '', 1650 SECOND_DSC_PERC: '', 1651 DISPLAY_PROP_DIV: '', 1652 BASKET_PROP_DIV: '', 1653 SUBSCRIBE_ID: '' 1654 }; 1655 this.product = { 1656 checkQuantity: false, 1657 maxQuantity: 0, 1658 stepQuantity: 1, 1659 isDblQuantity: false, 1660 canBuy: true, 1661 name: '', 1662 pict: {}, 1663 id: 0, 1664 addUrl: '', 1665 buyUrl: '' 1666 }; 1667 1668 this.basketMode = ''; 1669 this.basketData = { 1670 useProps: false, 1671 emptyProps: false, 1672 quantity: 'quantity', 1673 props: 'prop', 1674 basketUrl: '', 1675 sku_props: '', 1676 sku_props_var: 'basket_props', 1677 add_url: '', 1678 buy_url: '' 1679 }; 1680 1681 this.compareData = { 1682 compareUrl: '', 1683 compareDeleteUrl: '', 1684 comparePath: '' 1685 }; 1686 1687 this.delayData = { 1688 delayUrl: '', 1689 delayDeleteUrl: '', 1690 delayPath: '' 1691 }; 1692 1693 this.defaultPict = { 1694 pict: null, 1695 secondPict: null 1696 }; 1697 1698 this.defaultSliderOptions = { 1699 interval: 3000, 1700 wrap: true 1701 }; 1702 this.slider = { 1703 options: {}, 1704 items: [], 1705 active: null, 1706 sliding: null, 1707 paused: null, 1708 interval: null, 1709 progress: null 1710 }; 1711 this.touch = null; 1712 1713 this.checkQuantity = false; 1714 this.maxQuantity = 0; 1715 this.minQuantity = 0; 1716 this.stepQuantity = 1; 1717 this.isDblQuantity = false; 1718 this.canBuy = true; 1719 this.precision = 6; 1720 this.precisionFactor = Math.pow(10, this.precision); 1721 this.bigData = false; 1722 this.fullDisplayMode = false; 1723 this.viewMode = ''; 1724 this.templateTheme = ''; 1725 1726 this.currentPriceMode = ''; 1727 this.currentPrices = []; 1728 this.currentPriceSelected = 0; 1729 this.currentQuantityRanges = []; 1730 this.currentQuantityRangeSelected = 0; 1731 1732 this.offers = []; 1733 this.offerNum = 0; 1734 this.treeProps = []; 1735 this.selectedValues = {}; 1736 1737 this.obProduct = null; 1738 this.blockNodes = {}; 1739 this.obQuantity = null; 1740 this.obQuantityUp = null; 1741 this.obQuantityDown = null; 1742 this.obQuantityLimit = {}; 1743 this.obPict = null; 1744 this.obSecondPict = null; 1745 this.obPictSlider = null; 1746 this.obPictSliderIndicator = null; 1747 this.obPrice = null; 1748 this.obTree = null; 1749 this.obBuyBtn = null; 1750 this.obBasketActions = null; 1751 this.obNotAvail = null; 1752 this.obSubscribe = null; 1753 this.obDscPerc = null; 1754 this.obSecondDscPerc = null; 1755 this.obSkuProps = null; 1756 this.obMeasure = null; 1757 this.obCompare = null; 1758 this.obDelay = null; 1759 1760 this.obPopupWin = null; 1761 this.basketUrl = ''; 1762 this.basketParams = {}; 1763 this.isTouchDevice = BX.hasClass(document.documentElement, 'bx-touch'); 1764 this.hoverTimer = null; 1765 this.hoverStateChangeForbidden = false; 1766 this.mouseX = null; 1767 this.mouseY = null; 1768 1769 this.useEnhancedEcommerce = false; 1770 this.dataLayerName = 'dataLayer'; 1771 this.brandProperty = false; 1772 1773 this.errorCode = 0; 1774 1775 if (typeof arParams === 'object') 1776 { 1777 if (arParams.PRODUCT_TYPE) 1778 { 1779 this.productType = parseInt(arParams.PRODUCT_TYPE, 10); 1780 } 1781
1782 this.showQuantity = arParams.SHOW_QUANTITY; 1783 this.showAbsent = arParams.SHOW_ABSENT; 1784 this.secondPict = arParams.SECOND_PICT; 1785 this.showOldPrice = arParams.SHOW_OLD_PRICE; 1786 this.showMaxQuantity = arParams.SHOW_MAX_QUANTITY; 1787 this.relativeQuantityFactor = parseInt(arParams.RELATIVE_QUANTITY_FACTOR); 1788 this.showPercent = arParams.SHOW_DISCOUNT_PERCENT; 1789 this.showSkuProps = arParams.SHOW_SKU_PROPS; 1790 this.showSubscription = arParams.USE_SUBSCRIBE; 1791 1792 if (arParams.ADD_TO_BASKET_ACTION) 1793 { 1794 this.basketAction = arParams.ADD_TO_BASKET_ACTION; 1795 } 1796 1797 this.showClosePopup = arParams.SHOW_CLOSE_POPUP; 1798 this.useCompare = arParams.DISPLAY_COMPARE; 1799 this.useDelay = arParams.DISPLAY_DELAY; 1800 this.fullDisplayMode = arParams.PRODUCT_DISPLAY_MODE === 'Y'; 1801 this.bigData = arParams.BIG_DATA; 1802 this.viewMode = arParams.VIEW_MODE || ''; 1803 this.templateTheme = arParams.TEMPLATE_THEME || ''; 1804 this.useEnhancedEcommerce = arParams.USE_ENHANCED_ECOMMERCE === 'Y'; 1805 this.dataLayerName = arParams.DATA_LAYER_NAME; 1806 this.brandProperty = arParams.BRAND_PROPERTY; 1807 1808 this.visual = arParams.VISUAL; 1809 1810 switch (this.productType) 1811 { 1812 case 0: // no catalog 1813 case 1: // product 1814 case 2: // set 1815 if (arParams.PRODUCT && typeof arParams.PRODUCT === 'object') 1816 {
1817 this.currentPriceMode = arParams.PRODUCT.ITEM_PRICE_MODE; 1818 this.currentPrices = arParams.PRODUCT.ITEM_PRICES; 1819 this.currentPriceSelected = arParams.PRODUCT.ITEM_PRICE_SELECTED; 1820 this.currentQuantityRanges = arParams.PRODUCT.ITEM_QUANTITY_RANGES; 1821 this.currentQuantityRangeSelected = arParams.PRODUCT.ITEM_QUANTITY_RANGE_SELECTED; 1822 1823 if (this.showQuantity) 1824 { 1825 this.product.checkQuantity = arParams.PRODUCT.CHECK_QUANTITY; 1826 this.product.isDblQuantity = arParams.PRODUCT.QUANTITY_FLOAT; 1827 1828 if (this.product.checkQuantity) 1829 { 1830 this.product.maxQuantity = (this.product.isDblQuantity ? parseFloat(arParams.PRODUCT.MAX_QUANTITY) : parseInt(arParams.PRODUCT.MAX_QUANTITY, 10)); 1831 } 1832 1833 this.product.stepQuantity = (this.product.isDblQuantity ? parseFloat(arParams.PRODUCT.STEP_QUANTITY) : parseInt(arParams.PRODUCT.STEP_QUANTITY, 10)); 1834 1835 this.checkQuantity = this.product.checkQuantity; 1836 this.isDblQuantity = this.product.isDblQuantity; 1837 this.stepQuantity = this.product.stepQuantity; 1838 this.maxQuantity = this.product.maxQuantity; 1839 this.minQuantity = this.currentPriceMode === 'Q' 1840 ? parseFloat(this.currentPrices[this.currentPriceSelected].MIN_QUANTITY) 1841 : this.stepQuantity; 1842 1843 if (this.isDblQuantity) 1844 { 1845 this.stepQuantity = Math.round(this.stepQuantity * this.precisionFactor) / this.precisionFactor; 1846 } 1847 } 1848 1849 this.product.canBuy = arParams.PRODUCT.CAN_BUY; 1850 1851 if (arParams.PRODUCT.MORE_PHOTO_COUNT) 1852 { 1853 this.product.morePhotoCount = arParams.PRODUCT.MORE_PHOTO_COUNT; 1854 this.product.morePhoto = arParams.PRODUCT.MORE_PHOTO; 1855 } 1856 1857 if (arParams.PRODUCT.RCM_ID) 1858 { 1859 this.product.rcmId = arParams.PRODUCT.RCM_ID; 1860 } 1861 1862 this.canBuy = this.product.canBuy; 1863 this.product.name = arParams.PRODUCT.NAME; 1864 this.product.pict = arParams.PRODUCT.PICT; 1865 this.product.id = arParams.PRODUCT.ID; 1866 this.product.DETAIL_PAGE_URL = arParams.PRODUCT.DETAIL_PAGE_URL; 1867 1868 if (arParams.PRODUCT.ADD_URL) 1869 { 1870 this.product.addUrl = arParams.PRODUCT.ADD_URL; 1871 } 1872 1873 if (arParams.PRODUCT.BUY_URL) 1874 { 1875 this.product.buyUrl = arParams.PRODUCT.BUY_URL; 1876 } 1877 1878 if (arParams.BASKET && typeof arParams.BASKET === 'object') 1879 { 1880 this.basketData.useProps = arParams.BASKET.ADD_PROPS; 1881 this.basketData.emptyProps = arParams.BASKET.EMPTY_PROPS; 1882 } 1883 } 1884 else 1885 { 1886 this.errorCode = -1; 1887 } 1888 1889 break; 1890 case 3: // sku 1891 if (arParams.PRODUCT && typeof arParams.PRODUCT === 'object') 1892 { 1893 this.product.name = arParams.PRODUCT.NAME; 1894 this.product.id = arParams.PRODUCT.ID; 1895 this.product.DETAIL_PAGE_URL = arParams.PRODUCT.DETAIL_PAGE_URL; 1896 this.product.morePhotoCount = arParams.PRODUCT.MORE_PHOTO_COUNT; 1897 this.product.morePhoto = arParams.PRODUCT.MORE_PHOTO; 1898 1899 if (arParams.PRODUCT.RCM_ID) 1900 { 1901 this.product.rcmId = arParams.PRODUCT.RCM_ID; 1902 } 1903 } 1904 1905 if (arParams.OFFERS && BX.type.isArray(arParams.OFFERS)) 1906 { 1907 this.offers = arParams.OFFERS; 1908 this.offerNum = 0; 1909 1910 if (arParams.OFFER_SELECTED) 1911 { 1912 this.offerNum = parseInt(arParams.OFFER_SELECTED, 10); 1913 } 1914 1915 if (isNaN(this.offerNum)) 1916 { 1917 this.offerNum = 0; 1918 } 1919 1920 if (arParams.TREE_PROPS) 1921 { 1922 this.treeProps = arParams.TREE_PROPS; 1923 } 1924 1925 if (arParams.DEFAULT_PICTURE) 1926 { 1927 this.defaultPict.pict = arParams.DEFAULT_PICTURE.PICTURE; 1928 this.defaultPict.secondPict = arParams.DEFAULT_PICTURE.PICTURE_SECOND; 1929 } 1930 } 1931 1932 break; 1933 default: 1934 this.errorCode = -1; 1935 } 1936 if (arParams.BASKET && typeof arParams.BASKET === 'object') 1937 { 1938 if (arParams.BASKET.QUANTITY) 1939 { 1940 this.basketData.quantity = arParams.BASKET.QUANTITY; 1941 } 1942 1943 if (arParams.BASKET.PROPS) 1944 {
1945 this.basketData.props = arParams.BASKET.PROPS; 1946 } 1947 1948 if (arParams.BASKET.BASKET_URL) 1949 { 1950 this.basketData.basketUrl = arParams.BASKET.BASKET_URL; 1951 } 1952 1953 if (3 === this.productType) 1954 { 1955 if (arParams.BASKET.SKU_PROPS) 1956 { 1957 this.basketData.sku_props = arParams.BASKET.SKU_PROPS; 1958 } 1959 } 1960 1961 if (arParams.BASKET.ADD_URL_TEMPLATE) 1962 { 1963 this.basketData.add_url = arParams.BASKET.ADD_URL_TEMPLATE; 1964 } 1965 1966 if (arParams.BASKET.BUY_URL_TEMPLATE) 1967 { 1968 this.basketData.buy_url = arParams.BASKET.BUY_URL_TEMPLATE; 1969 } 1970 1971 if (this.basketData.add_url === '' && this.basketData.buy_url === '') 1972 { 1973 this.errorCode = -1024; 1974 } 1975 } 1976 1977 if (this.useCompare) 1978 { 1979 if (arParams.COMPARE && typeof arParams.COMPARE === 'object') 1980 { 1981 if (arParams.COMPARE.COMPARE_PATH) 1982 { 1983 this.compareData.comparePath = arParams.COMPARE.COMPARE_PATH; 1984 } 1985 1986 if (arParams.COMPARE.COMPARE_URL_TEMPLATE) 1987 { 1988 this.compareData.compareUrl = arParams.COMPARE.COMPARE_URL_TEMPLATE; 1989 } 1990 else 1991 { 1992 this.useCompare = false; 1993 } 1994 1995 if (arParams.COMPARE.COMPARE_DELETE_URL_TEMPLATE) 1996 { 1997 this.compareData.compareDeleteUrl = arParams.COMPARE.COMPARE_DELETE_URL_TEMPLATE; 1998 } 1999 else 2000 { 2001 this.useCompare = false; 2002 } 2003 } 2004 else 2005 { 2006 this.useCompare = false; 2007 } 2008 } 2009 2010 if (this.useDelay) 2011 { 2012 if (arParams.DELAY && typeof arParams.DELAY === 'object') 2013 { 2014 if (arParams.DELAY.DELAY_PATH) 2015 { 2016 this.delayData.delayPath = arParams.DELAY.DELAY_PATH; 2017 } 2018 2019 if (arParams.DELAY.DELAY_URL_TEMPLATE) 2020 { 2021 this.delayData.delayUrl = arParams.DELAY.DELAY_URL_TEMPLATE; 2022 } 2023 else 2024 { 2025 this.useDelay = false; 2026 } 2027 2028 if (arParams.DELAY.DELAY_DELETE_URL_TEMPLATE) 2029 { 2030 this.delayData.delayDeleteUrl = arParams.DELAY.DELAY_DELETE_URL_TEMPLATE; 2031 } 2032 else 2033 { 2034 this.useDelay = false; 2035 } 2036 } 2037 else 2038 { 2039 this.useDelay = false; 2040 } 2041 } 2042 } 2043 2044 if (this.errorCode === 0) 2045 { 2046 BX.ready(BX.delegate(this.init,this)); 2047 } 2048 }; 2049 2050 window.JCCatalogItem.prototype = { 2051 init: function() 2052 { 2053 var i = 0, 2054 treeItems = null; 2055 2056 this.obProduct = BX(this.visual.ID); 2057 if (!this.obProduct) 2058 { 2059 this.errorCode = -1; 2060 } 2061 2062 this.obPict = BX(this.visual.PICT_ID); 2063 if (!this.obPict) 2064 { 2065 //Commented out, because it does not add to the cart product without trade offers 2066 //this.errorCode = -2; 2067 } 2068 2069 if (this.secondPict && this.visual.SECOND_PICT_ID) 2070 { 2071 this.obSecondPict = BX(this.visual.SECOND_PICT_ID); 2072 } 2073 2074 this.obPictSlider = BX(this.visual.PICT_SLIDER_ID); 2075 this.obPictSliderIndicator = BX(this.visual.PICT_SLIDER_ID + '_indicator'); 2076 this.obPictSliderProgressBar = BX(this.visual.PICT_SLIDER_ID + '_progress_bar'); 2077 if (!this.obPictSlider) 2078 { 2079 this.errorCode = -4; 2080 } 2081 2082 this.obPrice = BX(this.visual.PRICE_ID); 2083 this.obPriceOld = BX(this.visual.PRICE_OLD_ID); 2084 this.obPriceTotal = BX(this.visual.PRICE_TOTAL_ID); 2085 if (!this.obPrice) 2086 { 2087 this.errorCode = -16; 2088 } 2089 2090 if (this.showQuantity && this.visual.QUANTITY_ID) 2091 { 2092 this.obQuantity = BX(this.visual.QUANTITY_ID); 2093 this.blockNodes.quantity = this.obProduct.querySelector('[data-entity="quantity-block"]'); 2094 2095 if (!this.isTouchDevice) 2096 { 2097 BX.bind(this.obQuantity, 'focus', BX.proxy(this.onFocus, this)); 2098 BX.bind(this.obQuantity, 'blur', BX.proxy(this.onBlur, this)); 2099 } 2100 2101 if (this.visual.QUANTITY_UP_ID) 2102 { 2103 this.obQuantityUp = BX(this.visual.QUANTITY_UP_ID); 2104 } 2105 2106 if (this.visual.QUANTITY_DOWN_ID) 2107 { 2108 this.obQuantityDown = BX(this.visual.QUANTITY_DOWN_ID); 2109 } 2110 } 2111 2112 if (this.visual.QUANTITY_LIMIT && this.showMaxQuantity !== 'N') 2113 { 2114 this.obQuantityLimit.all = BX(this.visual.QUANTITY_LIMIT); 2115 if (this.obQuantityLimit.all) 2116 { 2117 this.obQuantityLimit.value = this.obQuantityLimit.all.querySelector('[data-entity="quantity-limit-value"]'); 2118 if (!this.obQuantityLimit.value) 2119 { 2120 this.obQuantityLimit.all = null; 2121 } 2122 } 2123 } 2124 2125 if (this.productType === 3 && this.fullDisplayMode) 2126 { 2127 if (this.visual.TREE_ID) 2128 { 2129 this.obTree = BX(this.visual.TREE_ID); 2130 if (!this.obTree) 2131 { 2132 this.errorCode = -256; 2133 } 2134 } 2135 2136 if (this.visual.QUANTITY_MEASURE) 2137 { 2138 this.obMeasure = BX(this.visual.QUANTITY_MEASURE); 2139 } 2140 } 2141 2142 this.obBasketActions = BX(this.visual.BASKET_ACTIONS_ID); 2143 if (this.obBasketActions) 2144 { 2145 if (this.visual.BUY_ID) 2146 { 2147 this.obBuyBtn = BX(this.visual.BUY_ID); 2148 } 2149 } 2150 2151 this.obNotAvail = BX(this.visual.NOT_AVAILABLE_MESS);
2152 2153 if (this.showSubscription) 2154 { 2155 this.obSubscribe = BX(this.visual.SUBSCRIBE_ID); 2156 } 2157 2158 if (this.showPercent) 2159 { 2160 if (this.visual.DSC_PERC) 2161 { 2162 this.obDscPerc = BX(this.visual.DSC_PERC); 2163 } 2164 if (this.secondPict && this.visual.SECOND_DSC_PERC) 2165 { 2166 this.obSecondDscPerc = BX(this.visual.SECOND_DSC_PERC); 2167 } 2168 } 2169 2170 if (this.showSkuProps) 2171 { 2172 if (this.visual.DISPLAY_PROP_DIV) 2173 { 2174 this.obSkuProps = BX(this.visual.DISPLAY_PROP_DIV); 2175 } 2176 } 2177 2178 if (this.errorCode === 0) 2179 { 2180 // product slider events 2181 if (this.isTouchDevice) 2182 { 2183 BX.bind(this.obPictSlider, 'touchstart', BX.proxy(this.touchStartEvent, this)); 2184 BX.bind(this.obPictSlider, 'touchend', BX.proxy(this.touchEndEvent, this)); 2185 BX.bind(this.obPictSlider, 'touchcancel', BX.proxy(this.touchEndEvent, this)); 2186 } 2187 else 2188 { 2189 if (this.viewMode === 'CARD') 2190 { 2191 // product hover events 2192 BX.bind(this.obProduct, 'mouseenter', BX.proxy(this.hoverOn, this)); 2193 BX.bind(this.obProduct, 'mouseleave', BX.proxy(this.hoverOff, this)); 2194 } 2195 2196 // product slider events 2197 BX.bind(this.obProduct, 'mouseenter', BX.proxy(this.cycleSlider, this)); 2198 BX.bind(this.obProduct, 'mouseleave', BX.proxy(this.stopSlider, this)); 2199 } 2200 2201 if (this.bigData) 2202 { 2203 var links = BX.findChildren(this.obProduct, {tag:'a'}, true); 2204 if (links) 2205 { 2206 for (i in links) 2207 { 2208 if (links.hasOwnProperty(i)) 2209 { 2210 if (links[i].getAttribute('href') == this.product.DETAIL_PAGE_URL) 2211 { 2212 BX.bind(links[i], 'click', BX.proxy(this.rememberProductRecommendation, this)); 2213 } 2214 } 2215 } 2216 } 2217 } 2218 2219 if (this.showQuantity) 2220 { 2221 if (this.obQuantityUp) 2222 { 2223 BX.bind(this.obQuantityUp, 'click', BX.delegate(this.quantityUp, this)); 2224 } 2225 2226 if (this.obQuantityDown) 2227 { 2228 BX.bind(this.obQuantityDown, 'click', BX.delegate(this.quantityDown, this)); 2229 } 2230 2231 if (this.obQuantity) 2232 { 2233 BX.bind(this.obQuantity, 'change', BX.delegate(this.quantityChange, this)); 2234 BX.bind(this.obQuantity, 'click', BX.delegate(this.quantityChange, this)); 2235 } 2236 } 2237 2238 switch (this.productType) 2239 { 2240 case 0: // no catalog 2241 case 1: // product 2242 case 2: // set 2243 if (parseInt(this.product.morePhotoCount) > 1 && this.obPictSlider) 2244 { 2245 this.initializeSlider(); 2246 } 2247 2248 this.checkQuantityControls(); 2249 2250 break; 2251 case 3: // sku 2252 if (this.offers.length > 0) 2253 { 2254 treeItems = BX.findChildren(this.obTree, {tagName: 'li'}, true); 2255 2256 if (treeItems && treeItems.length) 2257 { 2258 for (i = 0; i < treeItems.length; i++) 2259 { 2260 BX.bind(treeItems[i], 'click', BX.delegate(this.selectOfferProp, this)); 2261 } 2262 } 2263 2264 this.setCurrent(); 2265 } 2266 else if (parseInt(this.product.morePhotoCount) > 1 && this.obPictSlider) 2267 { 2268 this.initializeSlider(); 2269 } 2270 2271 break; 2272 } 2273 2274 if (this.obBuyBtn) 2275 { 2276 if (this.basketAction === 'ADD') 2277 { 2278 BX.bind(this.obBuyBtn, 'click', BX.proxy(this.add2Basket, this)); 2279 } 2280 else 2281 { 2282 BX.bind(this.obBuyBtn, 'click', BX.proxy(this.buyBasket, this)); 2283 } 2284 } 2285 2286 if (this.useCompare) 2287 { 2288 this.obCompare = BX(this.visual.COMPARE_LINK_ID); 2289 if (this.obCompare) 2290 { 2291 BX.bind(this.obCompare, 'click', BX.proxy(this.compare, this)); 2292 } 2293 2294 BX.addCustomEvent('onCatalogDeleteCompare', BX.proxy(this.checkDeletedCompare, this)); 2295 } 2296 2297 if (this.useDelay) 2298 { 2299 this.obDelay = BX(this.visual.DELAY_LINK_ID); 2300 if (this.obDelay) 2301 { 2302 BX.bind(this.obDelay, 'click', BX.proxy(this.delay, this)); 2303 } 2304 2305 BX.addCustomEvent('onCatalogDeleteDelay', BX.proxy(this.checkDeletedDelay, this)); 2306 } 2307 }/* else { 2308 console.log('Error code: '+this.errorCode); 2309 console.log(this.visual); 2310 }*/ 2311 }, 2312 2313 setAnalyticsDataLayer: function(action) 2314 { 2315 if (!this.useEnhancedEcommerce || !this.dataLayerName) 2316 return; 2317 2318 var item = {}, 2319 info = {}, 2320 variants = [], 2321 i, k, j, propId, skuId, propValues; 2322 2323 switch (this.productType) 2324 { 2325 case 0: //no catalog 2326 case 1: //product 2327 case 2: //set 2328 item = { 2329 'id': this.product.id, 2330 'name': this.product.name, 2331 'price': this.currentPrices[this.currentPriceSelected] && this.currentPrices[this.currentPriceSelected].PRICE, 2332 'brand': BX.type.isArray(this.brandProperty) ? this.brandProperty.join('/') : this.brandProperty 2333 }; 2334 break; 2335 case 3: //sku 2336 for (i in this.offers[this.offerNum].TREE) 2337 { 2338 if (this.offers[this.offerNum].TREE.hasOwnProperty(i)) 2339 { 2340 propId = i.substring(5); 2341 skuId = this.offers[this.offerNum].TREE[i]; 2342 2343 for (k in this.treeProps) 2344 { 2345 if (this.treeProps.hasOwnProperty(k) && this.treeProps[k].ID == propId) 2346 { 2347 for (j in this.treeProps[k].VALUES) 2348 { 2349 propValues = this.treeProps[k].VALUES[j]; 2350 if (propValues.ID == skuId) 2351 { 2352 variants.push(propValues.NAME); 2353 break; 2354 } 2355 } 2356 2357 } 2358 } 2359 } 2360 } 2361 2362 item = { 2363 'id': this.offers[this.offerNum].ID, 2364 'name': this.offers[this.offerNum].NAME, 2365 'price': this.currentPrices[this.currentPriceSelected] && this.currentPrices[this.currentPriceSelected].PRICE, 2366 'brand': BX.type.isArray(this.brandProperty) ? this.brandProperty.join('/') : this.brandProperty, 2367 'variant': variants.join('/') 2368 }; 2369 break; 2370 } 2371 2372 switch (action) 2373 { 2374 case 'addToCart': 2375 info = { 2376 'event': 'addToCart', 2377 'ecommerce': { 2378 'currencyCode': this.currentPrices[this.currentPriceSelected] && this.currentPrices[this.currentPriceSelected].CURRENCY || '', 2379 'add': { 2380 'products': [{ 2381 'name': item.name || '', 2382 'id': item.id || '', 2383 'price': item.price || 0, 2384 'brand': item.brand || '', 2385 'category': item.category || '', 2386 'variant': item.variant || '', 2387 'quantity': this.showQuantity && this.obQuantity ? this.obQuantity.value : 1 2388 }] 2389 } 2390 } 2391 }; 2392 break; 2393 } 2394 2395 window[this.dataLayerName] = window[this.dataLayerName] || []; 2396 window[this.dataLayerName].push(info); 2397 }, 2398 2399 hoverOn: function(event) 2400 { 2401 clearTimeout(this.hoverTimer); 2402 this.obProduct.style.height = getComputedStyle(this.obProduct).height; 2403 BX.addClass(this.obProduct, 'hover'); 2404 2405 BX.PreventDefault(event); 2406 }, 2407 2408 hoverOff: function(event) 2409 { 2410 if (this.hoverStateChangeForbidden) 2411 return; 2412 2413 BX.removeClass(this.obProduct, 'hover'); 2414 this.hoverTimer = setTimeout( 2415 BX.delegate(function(){ 2416 this.obProduct.style.height = 'auto'; 2417 }, this), 2418 300 2419 ); 2420 2421 BX.PreventDefault(event); 2422 }, 2423 2424 onFocus: function() 2425 { 2426 this.hoverStateChangeForbidden = true; 2427 BX.bind(document, 'mousemove', BX.proxy(this.captureMousePosition, this)); 2428 }, 2429 2430 onBlur: function() 2431 { 2432 this.hoverStateChangeForbidden = false; 2433 BX.unbind(document, 'mousemove', BX.proxy(this.captureMousePosition, this)); 2434 2435 var cursorElement = document.elementFromPoint(this.mouseX, this.mouseY); 2436 if (!cursorElement || !this.obProduct.contains(cursorElement)) 2437 { 2438 this.hoverOff(); 2439 } 2440 }, 2441 2442 captureMousePosition: function(event) 2443 { 2444 this.mouseX = event.clientX; 2445 this.mouseY = event.clientY; 2446 }, 2447 2448 getCookie: function(name) 2449 { 2450 var matches = document.cookie.match(new RegExp( 2451 "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" 2452 )); 2453 2454 return matches ? decodeURIComponent(matches[1]) : null; 2455 }, 2456 2457 rememberProductRecommendation: function() 2458 { 2459 // save to RCM_PRODUCT_LOG 2460 var cookieName = BX.cookie_prefix + '_RCM_PRODUCT_LOG', 2461 cookie = this.getCookie(cookieName), 2462 itemFound = false; 2463 2464 var cItems = [], 2465 cItem; 2466 2467 if (cookie) 2468 {
2469 cItems = cookie.split('.'); 2470 } 2471 2472 var i = cItems.length; 2473 2474 while (i--) 2475 { 2476 cItem = cItems[i].split('-'); 2477 2478 if (cItem[0] == this.product.id) 2479 { 2480 // it's already in recommendations, update the date 2481 cItem = cItems[i].split('-'); 2482 2483 // update rcmId and date 2484 cItem[1] = this.product.rcmId; 2485 cItem[2] = BX.current_server_time; 2486 2487 cItems[i] = cItem.join('-'); 2488 itemFound = true; 2489 } 2490 else 2491 { 2492 if ((BX.current_server_time - cItem[2]) > 3600 * 24 * 30) 2493 { 2494 cItems.splice(i, 1); 2495 } 2496 } 2497 } 2498 2499 if (!itemFound) 2500 { 2501 // add recommendation 2502 cItems.push([this.product.id, this.product.rcmId, BX.current_server_time].join('-')); 2503 } 2504 2505 // serialize 2506 var plNewCookie = cItems.join('.'), 2507 cookieDate = new Date(new Date().getTime() + 1000 * 3600 * 24 * 365 * 10).toUTCString(); 2508 2509 document.cookie = cookieName + "=" + plNewCookie + "; path=/; expires=" + cookieDate + "; domain=" + BX.cookie_domain; 2510 }, 2511 2512 quantityUp: function() 2513 { 2514 var curValue = 0, 2515 boolSet = true; 2516 2517 if (this.errorCode === 0 && this.showQuantity && this.canBuy) 2518 { 2519 curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10)); 2520 if (!isNaN(curValue)) 2521 { 2522 curValue += this.stepQuantity; 2523 if (this.checkQuantity) 2524 { 2525 if (curValue > this.maxQuantity) 2526 { 2527 boolSet = false; 2528 } 2529 } 2530 2531 if (boolSet) 2532 { 2533 if (this.isDblQuantity) 2534 { 2535 curValue = Math.round(curValue * this.precisionFactor) / this.precisionFactor; 2536 } 2537 2538 this.obQuantity.value = curValue; 2539 2540 this.setPrice(); 2541 } 2542 } 2543 } 2544 }, 2545 2546 quantityDown: function() 2547 { 2548 var curValue = 0, 2549 boolSet = true; 2550 2551 if (this.errorCode === 0 && this.showQuantity && this.canBuy) 2552 { 2553 curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10)); 2554 if (!isNaN(curValue)) 2555 { 2556 curValue -= this.stepQuantity; 2557 2558 this.checkPriceRange(curValue); 2559 2560 if (curValue < this.minQuantity) 2561 { 2562 boolSet = false; 2563 } 2564 2565 if (boolSet) 2566 { 2567 if (this.isDblQuantity) 2568 { 2569 curValue = Math.round(curValue * this.precisionFactor) / this.precisionFactor; 2570 } 2571 2572 this.obQuantity.value = curValue; 2573 2574 this.setPrice(); 2575 } 2576 } 2577 } 2578 }, 2579 2580 quantityChange: function() 2581 { 2582 var curValue = 0, 2583 intCount; 2584 2585 if (this.errorCode === 0 && this.showQuantity) 2586 { 2587 if (this.canBuy) 2588 { 2589 curValue = this.isDblQuantity ? parseFloat(this.obQuantity.value) : Math.round(this.obQuantity.value); 2590 if (!isNaN(curValue)) 2591 { 2592 if (this.checkQuantity) 2593 { 2594 if (curValue > this.maxQuantity) 2595 { 2596 curValue = this.maxQuantity; 2597 } 2598 } 2599 2600 this.checkPriceRange(curValue); 2601 2602 if (curValue < this.minQuantity) 2603 { 2604 curValue = this.minQuantity; 2605 } 2606 else 2607 { 2608 intCount = Math.round( 2609 Math.round(curValue * this.precisionFactor / this.stepQuantity) / this.precisionFactor 2610 ) || 1; 2611 curValue = (intCount <= 1 ? this.stepQuantity : intCount * this.stepQuantity); 2612 curValue = Math.round(curValue * this.precisionFactor) / this.precisionFactor; 2613 } 2614 2615 this.obQuantity.value = curValue; 2616 } 2617 else 2618 { 2619 this.obQuantity.value = this.minQuantity; 2620 } 2621 } 2622 else 2623 { 2624 this.obQuantity.value = this.minQuantity; 2625 } 2626 2627 var finVal = parseFloat(this.obQuantity.getAttribute('data-quant')); 2628 if(!isNaN(finVal)) 2629 this.obQuantity.value = finVal; 2630 2631 this.setPrice(); 2632 } 2633 }, 2634 2635 quantitySet: function(index) 2636 { 2637 var resetQuantity, strLimit; 2638 2639 var newOffer = this.offers[index], 2640 oldOffer = this.offers[this.offerNum]; 2641 2642 if (this.errorCode === 0) 2643 { 2644 this.canBuy = newOffer.CAN_BUY; 2645 2646 this.currentPriceMode = newOffer.ITEM_PRICE_MODE; 2647 this.currentPrices = newOffer.ITEM_PRICES; 2648 this.currentPriceSelected = newOffer.ITEM_PRICE_SELECTED; 2649 this.currentQuantityRanges = newOffer.ITEM_QUANTITY_RANGES; 2650 this.currentQuantityRangeSelected = newOffer.ITEM_QUANTITY_RANGE_SELECTED; 2651 2652 if (this.canBuy) 2653 { 2654 if (this.blockNodes.quantity) 2655 { 2656 BX.style(this.blockNodes.quantity, 'display', ''); 2657 } 2658 2659 if (this.obBasketActions) 2660 { 2661 BX.style(this.obBasketActions, 'display', ''); 2662 } 2663 2664 if (this.obNotAvail) 2665 { 2666 BX.style(this.obNotAvail, 'display', 'none'); 2667 } 2668 2669 if (this.obSubscribe) 2670 { 2671 BX.style(this.obSubscribe, 'display', 'none'); 2672 } 2673 } 2674 else 2675 { 2676 if (this.blockNodes.quantity) 2677 { 2678 BX.style(this.blockNodes.quantity, 'display', 'none'); 2679 } 2680 2681 if (this.obBasketActions) 2682 { 2683 BX.style(this.obBasketActions, 'display', 'none'); 2684 } 2685 2686 if (this.obNotAvail) 2687 { 2688 BX.style(this.obNotAvail, 'display', ''); 2689 } 2690 2691 if (this.obSubscribe) 2692 { 2693 if (newOffer.CATALOG_SUBSCRIBE === 'Y') 2694 { 2695 BX.style(this.obSubscribe, 'display', ''); 2696 this.obSubscribe.setAttribute('data-item', newOffer.ID); 2697 BX(this.visual.SUBSCRIBE_ID + '_hidden').click(); 2698 } 2699 else 2700 { 2701 BX.style(this.obSubscribe, 'display', 'none'); 2702 } 2703 } 2704 } 2705 2706 this.isDblQuantity = newOffer.QUANTITY_FLOAT; 2707 this.checkQuantity = newOffer.CHECK_QUANTITY; 2708 2709 if (this.isDblQuantity) 2710 { 2711 this.stepQuantity = Math.round(parseFloat(newOffer.STEP_QUANTITY) * this.precisionFactor) / this.precisionFactor; 2712 this.maxQuantity = parseFloat(newOffer.MAX_QUANTITY); 2713 this.minQuantity = this.currentPriceMode === 'Q' ? parseFloat(this.currentPrices[this.currentPriceSelected].MIN_QUANTITY) : this.stepQuantity; 2714 } 2715 else 2716 { 2717 this.stepQuantity = parseInt(newOffer.STEP_QUANTITY, 10); 2718 this.maxQuantity = parseInt(newOffer.MAX_QUANTITY, 10); 2719 this.minQuantity = this.currentPriceMode === 'Q' ? parseInt(this.currentPrices[this.currentPriceSelected].MIN_QUANTITY) : this.stepQuantity; 2720 } 2721 2722 if (this.showQuantity) 2723 { 2724 var isDifferentMinQuantity = oldOffer.ITEM_PRICES.length 2725 && oldOffer.ITEM_PRICES[oldOffer.ITEM_PRICE_SELECTED] 2726 && oldOffer.ITEM_PRICES[oldOffer.ITEM_PRICE_SELECTED].MIN_QUANTITY != this.minQuantity; 2727 2728 if (this.isDblQuantity) 2729 { 2730 resetQuantity = Math.round(parseFloat(oldOffer.STEP_QUANTITY) * this.precisionFactor) / this.precisionFactor !== this.stepQuantity 2731 || isDifferentMinQuantity 2732 || oldOffer.MEASURE !== newOffer.MEASURE 2733 || ( 2734 this.checkQuantity 2735 && parseFloat(oldOffer.MAX_QUANTITY) > this.maxQuantity 2736 && parseFloat(this.obQuantity.value) > this.maxQuantity 2737 ); 2738 } 2739 else 2740 { 2741 resetQuantity = parseInt(oldOffer.STEP_QUANTITY, 10) !== this.stepQuantity 2742 || isDifferentMinQuantity 2743 || oldOffer.MEASURE !== newOffer.MEASURE 2744 || ( 2745 this.checkQuantity 2746 && parseInt(oldOffer.MAX_QUANTITY, 10) > this.maxQuantity 2747 && parseInt(this.obQuantity.value, 10) > this.maxQuantity 2748 ); 2749 } 2750 2751 this.obQuantity.disabled = !this.canBuy; 2752 2753 if (resetQuantity) 2754 { 2755 this.obQuantity.value = this.minQuantity; 2756 } 2757 2758 if (this.obMeasure) 2759 { 2760 if (newOffer.MEASURE) 2761 { 2762 BX.adjust(this.obMeasure, {html: newOffer.MEASURE}); 2763 } 2764 else 2765 { 2766 BX.adjust(this.obMeasure, {html: ''}); 2767 } 2768 } 2769 } 2770 2771 if (this.obQuantityLimit.all) 2772 { 2773 if (!this.checkQuantity || this.maxQuantity == 0) 2774 { 2775 BX.adjust(this.obQuantityLimit.value, {html: ''}); 2776 BX.adjust(this.obQuantityLimit.all, {style: {display: 'none'}}); 2777 } 2778 else 2779 { 2780 if (this.showMaxQuantity === 'M') 2781 { 2782 strLimit = (this.maxQuantity / this.stepQuantity >= this.relativeQuantityFactor) 2783 ? BX.message('RELATIVE_QUANTITY_MANY') 2784 : BX.message('RELATIVE_QUANTITY_FEW'); 2785 } 2786 else 2787 { 2788 strLimit = this.maxQuantity; 2789 2790 if (newOffer.MEASURE) 2791 { 2792 strLimit += (' ' + newOffer.MEASURE); 2793 } 2794 } 2795 2796 BX.adjust(this.obQuantityLimit.value, {html: strLimit}); 2797 BX.adjust(this.obQuantityLimit.all, {style: {display: ''}}); 2798 } 2799 } 2800 } 2801 }, 2802 2803 initializeSlider: function() 2804 {
2805 var wrap = this.obPictSlider.getAttribute('data-slider-wrap'); 2806 if (wrap) 2807 { 2808 this.slider.options.wrap = wrap === 'true'; 2809 } 2810 else 2811 { 2812 this.slider.options.wrap = this.defaultSliderOptions.wrap; 2813 } 2814 2815 if (this.isTouchDevice) 2816 { 2817 this.slider.options.interval = false; 2818 } 2819 else 2820 { 2821 this.slider.options.interval = parseInt(this.obPictSlider.getAttribute('data-slider-interval')) || this.defaultSliderOptions.interval; 2822 // slider interval must be more than 700ms because of css transitions 2823 if (this.slider.options.interval < 700) 2824 { 2825 this.slider.options.interval = 700; 2826 } 2827 2828 if (this.obPictSliderIndicator) 2829 { 2830 var controls = this.obPictSliderIndicator.querySelectorAll('[data-go-to]'); 2831 for (var i in controls) 2832 { 2833 if (controls.hasOwnProperty(i)) 2834 { 2835 BX.bind(controls[i], 'click', BX.proxy(this.sliderClickHandler, this)); 2836 } 2837 } 2838 } 2839 2840 if (this.obPictSliderProgressBar) 2841 { 2842 if (this.slider.progress) 2843 { 2844 this.resetProgress(); 2845 this.cycleSlider(); 2846 } 2847 else 2848 { 2849 this.slider.progress = new BX.easing({ 2850 transition: BX.easing.transitions.linear, 2851 step: BX.delegate(function(state){ 2852 this.obPictSliderProgressBar.style.width = state.width / 10 + '%'; 2853 }, this) 2854 }); 2855 } 2856 } 2857 } 2858 }, 2859 2860 checkTouch: function(event) 2861 { 2862 if (!event || !event.changedTouches) 2863 return false; 2864 2865 return event.changedTouches[0].identifier === this.touch.identifier; 2866 }, 2867 2868 touchStartEvent: function(event) 2869 { 2870 if (event.touches.length != 1) 2871 return; 2872 2873 this.touch = event.changedTouches[0]; 2874 }, 2875 2876 touchEndEvent: function(event) 2877 { 2878 if (!this.checkTouch(event)) 2879 return; 2880 2881 var deltaX = this.touch.pageX - event.changedTouches[0].pageX, 2882 deltaY = this.touch.pageY - event.changedTouches[0].pageY; 2883 2884 if (Math.abs(deltaX) >= Math.abs(deltaY) + 10) 2885 { 2886 if (deltaX > 0) 2887 { 2888 this.slideNext(); 2889 } 2890 2891 if (deltaX < 0) 2892 { 2893 this.slidePrev(); 2894 } 2895 } 2896 }, 2897 2898 sliderClickHandler: function(event) 2899 { 2900 var target = BX.getEventTarget(event), 2901 slideIndex = target.getAttribute('data-go-to'); 2902 2903 if (slideIndex) 2904 { 2905 this.slideTo(slideIndex) 2906 } 2907 2908 BX.PreventDefault(event); 2909 }, 2910 2911 slideNext: function() 2912 { 2913 if (this.slider.sliding) 2914 return; 2915 2916 return this.slide('next'); 2917 }, 2918 2919 slidePrev: function() 2920 { 2921 if (this.slider.sliding) 2922 return; 2923 2924 return this.slide('prev'); 2925 }, 2926 2927 slideTo: function(pos) 2928 { 2929 this.slider.active = BX.findChild(this.obPictSlider, {className: 'item active'}, true, false); 2930 this.slider.progress && (this.slider.interval = true); 2931 2932 var activeIndex = this.getItemIndex(this.slider.active); 2933 2934 if (pos > (this.slider.items.length - 1) || pos < 0) 2935 return; 2936 2937 if (this.slider.sliding) 2938 return false; 2939 2940 if (activeIndex == pos) 2941 { 2942 this.stopSlider(); 2943 this.cycleSlider(); 2944 return; 2945 } 2946 2947 return this.slide(pos > activeIndex ? 'next' : 'prev', this.eq(this.slider.items, pos)); 2948 }, 2949 2950 slide: function(type, next) 2951 { 2952 var active = BX.findChild(this.obPictSlider, {className: 'item active'}, true, false), 2953 isCycling = this.slider.interval, 2954 direction = type === 'next' ? 'left' : 'right'; 2955 2956 next = next || this.getItemForDirection(type, active); 2957 2958 if (BX.hasClass(next, 'active')) 2959 { 2960 return (this.slider.sliding = false); 2961 } 2962 2963 this.slider.sliding = true; 2964 2965 isCycling && this.stopSlider(); 2966 2967 if (this.obPictSliderIndicator) 2968 { 2969 BX.removeClass(this.obPictSliderIndicator.querySelector('.active'), 'active'); 2970 var nextIndicator = this.obPictSliderIndicator.querySelectorAll('[data-go-to]')[this.getItemIndex(next)]; 2971 nextIndicator && BX.addClass(nextIndicator, 'active'); 2972 } 2973 2974 if (BX.hasClass(this.obPictSlider, 'slide') && !BX.browser.IsIE()) 2975 { 2976 var self = this; 2977 BX.addClass(next, type); 2978 next.offsetWidth; // force reflow 2979 BX.addClass(active, direction); 2980 BX.addClass(next, direction); 2981 setTimeout(function() { 2982 BX.addClass(next, 'active'); 2983 BX.removeClass(active, 'active'); 2984 BX.removeClass(active, direction); 2985 BX.removeClass(next, type); 2986 BX.removeClass(next, direction); 2987 self.slider.sliding = false; 2988 }, 700); 2989 } 2990 else 2991 { 2992 BX.addClass(next, 'active'); 2993 this.slider.sliding = false; 2994 } 2995 2996 this.obPictSliderProgressBar && this.resetProgress(); 2997 isCycling && this.cycleSlider(); 2998 }, 2999 3000 stopSlider: function(event) 3001 { 3002 event || (this.slider.paused = true); 3003 3004 this.slider.interval && clearInterval(this.slider.interval); 3005 3006 if (this.slider.progress) 3007 { 3008 this.slider.progress.stop(); 3009 3010 var width = parseInt(this.obPictSliderProgressBar.style.width); 3011 3012 this.slider.progress.options.duration = this.slider.options.interval * width / 200; 3013 this.slider.progress.options.start = {width: width * 10}; 3014 this.slider.progress.options.finish = {width: 0}; 3015 this.slider.progress.options.complete = null; 3016 this.slider.progress.animate(); 3017 } 3018 }, 3019 3020 cycleSlider: function(event) 3021 { 3022 event || (this.slider.paused = false); 3023 3024 this.slider.interval && clearInterval(this.slider.interval); 3025 3026 if (this.slider.options.interval && !this.slider.paused) 3027 { 3028 if (this.slider.progress) 3029 { 3030 this.slider.progress.stop(); 3031 3032 var width = parseInt(this.obPictSliderProgressBar.style.width); 3033 3034 this.slider.progress.options.duration = this.slider.options.interval * (100 - width) / 100; 3035 this.slider.progress.options.start = {width: width * 10}; 3036 this.slider.progress.options.finish = {width: 1000}; 3037 this.slider.progress.options.complete = BX.delegate(function(){ 3038 this.slider.interval = true; 3039 this.slideNext(); 3040 }, this); 3041 this.slider.progress.animate(); 3042 } 3043 else 3044 { 3045 this.slider.interval = setInterval(BX.proxy(this.slideNext, this), this.slider.options.interval); 3046 } 3047 } 3048 }, 3049 3050 resetProgress: function() 3051 { 3052 this.slider.progress && this.slider.progress.stop(); 3053 this.obPictSliderProgressBar.style.width = 0; 3054 }, 3055 3056 getItemForDirection: function(direction, active) 3057 { 3058 var activeIndex = this.getItemIndex(active), 3059 willWrap = direction === 'prev' && activeIndex === 0 3060 || direction === 'next' && activeIndex == (this.slider.items.length - 1); 3061 3062 if (willWrap && !this.slider.options.wrap) 3063 return active; 3064 3065 var delta = direction === 'prev' ? -1 : 1, 3066 itemIndex = (activeIndex + delta) % this.slider.items.length; 3067 3068 return this.eq(this.slider.items, itemIndex); 3069 }, 3070 3071 getItemIndex: function(item) 3072 { 3073 this.slider.items = BX.findChildren(item.parentNode, {className: 'item'}, true); 3074 3075 return this.slider.items.indexOf(item || this.slider.active); 3076 }, 3077 3078 eq: function(obj, i) 3079 { 3080 var len = obj.length, 3081 j = +i + (i < 0 ? len : 0); 3082 3083 return j >= 0 && j < len ? obj[j] : {}; 3084 }, 3085 3086 selectOfferProp: function() 3087 { 3088 var i = 0, 3089 value = '', 3090 strTreeValue = '', 3091 arTreeItem = [], 3092 rowItems = null, 3093 target = BX.proxy_context; 3094 3095 if (target && target.hasAttribute('data-treevalue')) 3096 { 3097 if (BX.hasClass(target, 'selected')) 3098 return; 3099 3100 strTreeValue = target.getAttribute('data-treevalue'); 3101 arTreeItem = strTreeValue.split('_'); 3102 if (this.searchOfferPropIndex(arTreeItem[0], arTreeItem[1])) 3103 { 3104 rowItems = BX.findChildren(target.parentNode, {tagName: 'li'}, false); 3105 if (rowItems && 0 < rowItems.length) 3106 { 3107 for (i = 0; i < rowItems.length; i++) 3108 { 3109 value = rowItems[i].getAttribute('data-onevalue'); 3110 if (value === arTreeItem[1]) 3111 { 3112 BX.addClass(rowItems[i], 'selected'); 3113 } 3114 else 3115 { 3116 BX.removeClass(rowItems[i], 'selected'); 3117 } 3118 } 3119 } 3120 } 3121 } 3122 }, 3123 3124 searchOfferPropIndex: function(strPropID, strPropValue) 3125 { 3126 var strName = '', 3127 arShowValues = false, 3128 i, j, 3129 arCanBuyValues = [], 3130 allValues = [], 3131 index = -1, 3132 arFilter = {}, 3133 tmpFilter = []; 3134 3135 for (i = 0; i < this.treeProps.length; i++) 3136 { 3137 if (this.treeProps[i].ID === strPropID) 3138 { 3139 index = i; 3140 break; 3141 } 3142 } 3143 3144 if (-1 < index) 3145 { 3146 for (i = 0; i < index; i++) 3147 { 3148 strName = 'PROP_'+this.treeProps[i].ID; 3149 arFilter[strName] = this.selectedValues[strName]; 3150 } 3151 strName = 'PROP_'+this.treeProps[index].ID; 3152 arShowValues = this.getRowValues(arFilter, strName); 3153 if (!arShowValues) 3154 { 3155 return false; 3156 } 3157 if (!BX.util.in_array(strPropValue, arShowValues)) 3158 { 3159 return false; 3160 } 3161 arFilter[strName] = strPropValue; 3162 for (i = index+1; i < this.treeProps.length; i++) 3163 { 3164 strName = 'PROP_'+this.treeProps[i].ID; 3165 arShowValues = this.getRowValues(arFilter, strName); 3166 if (!arShowValues) 3167 { 3168 return false; 3169 } 3170 allValues = [];
3171 if (this.showAbsent) 3172 { 3173 arCanBuyValues = []; 3174 tmpFilter = []; 3175 tmpFilter = BX.clone(arFilter, true); 3176 for (j = 0; j < arShowValues.length; j++) 3177 { 3178 tmpFilter[strName] = arShowValues[j]; 3179 allValues[allValues.length] = arShowValues[j]; 3180 if (this.getCanBuy(tmpFilter)) 3181 arCanBuyValues[arCanBuyValues.length] = arShowValues[j]; 3182 } 3183 } 3184 else 3185 { 3186 arCanBuyValues = arShowValues; 3187 } 3188 if (this.selectedValues[strName] && BX.util.in_array(this.selectedValues[strName], arCanBuyValues)) 3189 { 3190 arFilter[strName] = this.selectedValues[strName]; 3191 } 3192 else 3193 { 3194 if (this.showAbsent) 3195 arFilter[strName] = (arCanBuyValues.length > 0 ? arCanBuyValues[0] : allValues[0]); 3196 else 3197 arFilter[strName] = arCanBuyValues[0]; 3198 } 3199 this.updateRow(i, arFilter[strName], arShowValues, arCanBuyValues); 3200 } 3201 this.selectedValues = arFilter; 3202 this.changeInfo(); 3203 } 3204 return true; 3205 }, 3206 3207 updateRow: function(intNumber, activeID, showID, canBuyID) 3208 { 3209 var i = 0, 3210 value = '', 3211 isCurrent = false, 3212 rowItems = null; 3213 3214 var lineContainer = this.obTree.querySelectorAll('[data-entity="sku-line-block"]'), 3215 listContainer; 3216 3217 if (intNumber > -1 && intNumber < lineContainer.length) 3218 { 3219 listContainer = lineContainer[intNumber].querySelector('ul'); 3220 rowItems = BX.findChildren(listContainer, {tagName: 'li'}, false); 3221 if (rowItems && 0 < rowItems.length) 3222 { 3223 for (i = 0; i < rowItems.length; i++) 3224 { 3225 value = rowItems[i].getAttribute('data-onevalue'); 3226 isCurrent = value === activeID; 3227 3228 if (isCurrent) 3229 { 3230 BX.addClass(rowItems[i], 'selected'); 3231 } 3232 else 3233 { 3234 BX.removeClass(rowItems[i], 'selected'); 3235 } 3236 3237 if (BX.util.in_array(value, canBuyID)) 3238 { 3239 BX.removeClass(rowItems[i], 'notallowed'); 3240 } 3241 else 3242 { 3243 BX.addClass(rowItems[i], 'notallowed'); 3244 } 3245 3246 rowItems[i].style.display = BX.util.in_array(value, showID) ? '' : 'none'; 3247 3248 if (isCurrent) 3249 { 3250 lineContainer[intNumber].style.display = (value == 0 && canBuyID.length == 1) ? 'none' : ''; 3251 } 3252 } 3253 } 3254 } 3255 }, 3256 3257 getRowValues: function(arFilter, index) 3258 { 3259 var i = 0, 3260 j, 3261 arValues = [], 3262 boolSearch = false, 3263 boolOneSearch = true; 3264 3265 if (0 === arFilter.length) 3266 { 3267 for (i = 0; i < this.offers.length; i++) 3268 { 3269 if (!BX.util.in_array(this.offers[i].TREE[index], arValues)) 3270 { 3271 arValues[arValues.length] = this.offers[i].TREE[index]; 3272 } 3273 } 3274 boolSearch = true; 3275 } 3276 else 3277 { 3278 for (i = 0; i < this.offers.length; i++) 3279 { 3280 boolOneSearch = true; 3281 for (j in arFilter) 3282 { 3283 if (arFilter[j] !== this.offers[i].TREE[j]) 3284 { 3285 boolOneSearch = false; 3286 break; 3287 } 3288 } 3289 if (boolOneSearch) 3290 { 3291 if (!BX.util.in_array(this.offers[i].TREE[index], arValues)) 3292 { 3293 arValues[arValues.length] = this.offers[i].TREE[index]; 3294 } 3295 boolSearch = true; 3296 } 3297 } 3298 } 3299 return (boolSearch ? arValues : false); 3300 }, 3301 3302 getCanBuy: function(arFilter) 3303 { 3304 var i, j, 3305 boolSearch = false, 3306 boolOneSearch = true; 3307 3308 for (i = 0; i < this.offers.length; i++) 3309 { 3310 boolOneSearch = true; 3311 for (j in arFilter) 3312 { 3313 if (arFilter[j] !== this.offers[i].TREE[j]) 3314 { 3315 boolOneSearch = false; 3316 break; 3317 } 3318 } 3319 if (boolOneSearch) 3320 { 3321 if (this.offers[i].CAN_BUY) 3322 { 3323 boolSearch = true; 3324 break; 3325 } 3326 } 3327 } 3328 3329 return boolSearch; 3330 }, 3331 3332 setCurrent: function() 3333 { 3334 var i, 3335 j = 0, 3336 arCanBuyValues = [], 3337 strName = '', 3338 arShowValues = false, 3339 arFilter = {}, 3340 tmpFilter = [], 3341 current = this.offers[this.offerNum].TREE; 3342 3343 for (i = 0; i < this.treeProps.length; i++) 3344 { 3345 strName = 'PROP_'+this.treeProps[i].ID; 3346 arShowValues = this.getRowValues(arFilter, strName); 3347 if (!arShowValues) 3348 { 3349 break; 3350 } 3351 if (BX.util.in_array(current[strName], arShowValues)) 3352 { 3353 arFilter[strName] = current[strName]; 3354 } 3355 else 3356 { 3357 arFilter[strName] = arShowValues[0]; 3358 this.offerNum = 0; 3359 }
3360 if (this.showAbsent) 3361 { 3362 arCanBuyValues = []; 3363 tmpFilter = []; 3364 tmpFilter = BX.clone(arFilter, true); 3365 for (j = 0; j < arShowValues.length; j++) 3366 { 3367 tmpFilter[strName] = arShowValues[j]; 3368 if (this.getCanBuy(tmpFilter)) 3369 { 3370 arCanBuyValues[arCanBuyValues.length] = arShowValues[j]; 3371 } 3372 } 3373 } 3374 else 3375 { 3376 arCanBuyValues = arShowValues; 3377 } 3378 this.updateRow(i, arFilter[strName], arShowValues, arCanBuyValues); 3379 } 3380 this.selectedValues = arFilter; 3381 this.changeInfo(); 3382 }, 3383 3384 changeInfo: function() 3385 { 3386 var i, j, 3387 index = -1, 3388 boolOneSearch = true, 3389 quantityChanged; 3390 3391 for (i = 0; i < this.offers.length; i++) 3392 { 3393 boolOneSearch = true; 3394 for (j in this.selectedValues) 3395 { 3396 if (this.selectedValues[j] !== this.offers[i].TREE[j]) 3397 { 3398 boolOneSearch = false; 3399 break; 3400 } 3401 } 3402 if (boolOneSearch) 3403 { 3404 index = i; 3405 break; 3406 } 3407 } 3408 if (index > -1) 3409 { 3410 if (parseInt(this.offers[index].MORE_PHOTO_COUNT) > 1 && this.obPictSlider) 3411 { 3412 // hide pict and second_pict containers 3413 if (this.obPict) 3414 { 3415 this.obPict.style.display = 'none'; 3416 } 3417 3418 if (this.obSecondPict) 3419 { 3420 this.obSecondPict.style.display = 'none'; 3421 } 3422 3423 // clear slider container 3424 BX.cleanNode(this.obPictSlider); 3425 3426 // fill slider container with slides 3427 for (i in this.offers[index].MORE_PHOTO) 3428 { 3429 if (this.offers[index].MORE_PHOTO.hasOwnProperty(i)) 3430 { 3431 this.obPictSlider.appendChild( 3432 BX.create('SPAN', { 3433 props: {className: 'product-item-image-slide item' + (i == 0 ? ' active' : '')}, 3434 style: {backgroundImage: 'url(' + this.offers[index].MORE_PHOTO[i].SRC + ')'} 3435 }) 3436 ); 3437 } 3438 } 3439 3440 // fill slider indicator if exists 3441 if (this.obPictSliderIndicator) 3442 { 3443 BX.cleanNode(this.obPictSliderIndicator); 3444 3445 for (i in this.offers[index].MORE_PHOTO) 3446 { 3447 if (this.offers[index].MORE_PHOTO.hasOwnProperty(i)) 3448 { 3449 this.obPictSliderIndicator.appendChild( 3450 BX.create('DIV', { 3451 attrs: {'data-go-to': i}, 3452 props: {className: 'product-item-image-slider-control' + (i == 0 ? ' active' : '')} 3453 }) 3454 ); 3455 this.obPictSliderIndicator.appendChild(document.createTextNode(' ')); 3456 } 3457 } 3458 3459 this.obPictSliderIndicator.style.display = ''; 3460 } 3461 3462 if (this.obPictSliderProgressBar) 3463 { 3464 this.obPictSliderProgressBar.style.display = ''; 3465 } 3466 3467 // show slider container 3468 this.obPictSlider.style.display = ''; 3469 this.initializeSlider(); 3470 } 3471 else 3472 { 3473 // hide slider container 3474 if (this.obPictSlider) 3475 { 3476 this.obPictSlider.style.display = 'none'; 3477 } 3478 3479 if (this.obPictSliderIndicator) 3480 { 3481 this.obPictSliderIndicator.style.display = 'none'; 3482 } 3483 3484 if (this.obPictSliderProgressBar) 3485 { 3486 this.obPictSliderProgressBar.style.display = 'none'; 3487 } 3488 3489 // show pict and pict_second containers 3490 if (this.obPict) 3491 { 3492 if (this.offers[index].PREVIEW_PICTURE) 3493 { 3494 BX.adjust(this.obPict, {style: {backgroundImage: 'url(' + this.offers[index].PREVIEW_PICTURE.SRC + ')'}}); 3495 } 3496 else 3497 { 3498 BX.adjust(this.obPict, {style: {backgroundImage: 'url(' + this.defaultPict.pict.SRC + ')'}}); 3499 } 3500 3501 this.obPict.style.display = ''; 3502 } 3503 3504 if (this.secondPict && this.obSecondPict) 3505 { 3506 if (this.offers[index].PREVIEW_PICTURE_SECOND) 3507 { 3508 BX.adjust(this.obSecondPict, {style: {backgroundImage: 'url(' + this.offers[index].PREVIEW_PICTURE_SECOND.SRC + ')'}}); 3509 } 3510 else if (this.offers[index].PREVIEW_PICTURE.SRC) 3511 { 3512 BX.adjust(this.obSecondPict, {style: {backgroundImage: 'url(' + this.offers[index].PREVIEW_PICTURE.SRC + ')'}}); 3513 } 3514 else if (this.defaultPict.secondPict) 3515 { 3516 BX.adjust(this.obSecondPict, {style: {backgroundImage: 'url(' + this.defaultPict.secondPict.SRC + ')'}}); 3517 } 3518 else 3519 { 3520 BX.adjust(this.obSecondPict, {style: {backgroundImage: 'url(' + this.defaultPict.pict.SRC + ')'}}); 3521 } 3522 3523 this.obSecondPict.style.display = ''; 3524 } 3525 } 3526 3527 if (this.showSkuProps && this.obSkuProps) 3528 { 3529 if (this.offers[index].DISPLAY_PROPERTIES.length) 3530 { 3531 BX.adjust(this.obSkuProps, {style: {display: ''}, html: this.offers[index].DISPLAY_PROPERTIES}); 3532 } 3533 else 3534 { 3535 BX.adjust(this.obSkuProps, {style: {display: 'none'}, html: ''}); 3536 } 3537 } 3538 3539 this.quantitySet(index); 3540 this.setPrice(); 3541 this.setCompared(this.offers[index].COMPARED); 3542 this.setDelayed(this.offers[index].DELAY); 3543 this.offerNum = index; 3544 } 3545 }, 3546 3547 checkPriceRange: function(quantity) 3548 { 3549 if (typeof quantity === 'undefined'|| this.currentPriceMode != 'Q') 3550 return; 3551 3552 var range, found = false; 3553 3554 for (var i in this.currentQuantityRanges) 3555 { 3556 if (this.currentQuantityRanges.hasOwnProperty(i)) 3557 { 3558 range = this.currentQuantityRanges[i]; 3559 3560 if ( 3561 parseInt(quantity) >= parseInt(range.SORT_FROM) 3562 && ( 3563 range.SORT_TO == 'INF' 3564 || parseInt(quantity) <= parseInt(range.SORT_TO) 3565 ) 3566 ) 3567 { 3568 found = true; 3569 this.currentQuantityRangeSelected = range.HASH; 3570 break; 3571 } 3572 } 3573 } 3574 3575 if (!found && (range = this.getMinPriceRange())) 3576 { 3577 this.currentQuantityRangeSelected = range.HASH; 3578 } 3579 3580 for (var k in this.currentPrices) 3581 { 3582 if (this.currentPrices.hasOwnProperty(k)) 3583 { 3584 if (this.currentPrices[k].QUANTITY_HASH == this.currentQuantityRangeSelected) 3585 { 3586 this.currentPriceSelected = k; 3587 break; 3588 } 3589 } 3590 } 3591 }, 3592 3593 getMinPriceRange: function() 3594 { 3595 var range; 3596 3597 for (var i in this.currentQuantityRanges) 3598 { 3599 if (this.currentQuantityRanges.hasOwnProperty(i)) 3600 { 3601 if ( 3602 !range 3603 || parseInt(this.currentQuantityRanges[i].SORT_FROM) < parseInt(range.SORT_FROM) 3604 ) 3605 { 3606 range = this.currentQuantityRanges[i]; 3607 } 3608 } 3609 } 3610 3611 return range; 3612 }, 3613
3614 checkQuantityControls: function() 3615 { 3616 if (!this.obQuantity) 3617 return; 3618 3619 var reachedTopLimit = this.checkQuantity && parseFloat(this.obQuantity.value) + this.stepQuantity > this.maxQuantity, 3620 reachedBottomLimit = parseFloat(this.obQuantity.value) - this.stepQuantity < this.minQuantity; 3621 3622 if (reachedTopLimit) 3623 { 3624 BX.addClass(this.obQuantityUp, 'product-item-amount-field-btn-disabled'); 3625 } 3626 else if (BX.hasClass(this.obQuantityUp, 'product-item-amount-field-btn-disabled')) 3627 { 3628 BX.removeClass(this.obQuantityUp, 'product-item-amount-field-btn-disabled'); 3629 } 3630 3631 if (reachedBottomLimit) 3632 { 3633 BX.addClass(this.obQuantityDown, 'product-item-amount-field-btn-disabled'); 3634 } 3635 else if (BX.hasClass(this.obQuantityDown, 'product-item-amount-field-btn-disabled')) 3636 { 3637 BX.removeClass(this.obQuantityDown, 'product-item-amount-field-btn-disabled'); 3638 } 3639 3640 if (reachedTopLimit && reachedBottomLimit) 3641 { 3642 this.obQuantity.setAttribute('disabled', 'disabled'); 3643 } 3644 else 3645 { 3646 this.obQuantity.removeAttribute('disabled'); 3647 } 3648 }, 3649 3650 setPrice: function() 3651 { 3652 var obData, price; 3653 3654 if (this.obQuantity) 3655 { 3656 this.checkPriceRange(this.obQuantity.value); 3657 } 3658 3659 this.checkQuantityControls(); 3660 3661 price = this.currentPrices[this.currentPriceSelected]; 3662 var kef = 1; 3663 if(price['MIN_QUANTITY'] && (parseFloat(price['MIN_QUANTITY']) < 1)){ 3664 kef = 1/parseFloat(price['MIN_QUANTITY']); 3665 } 3666 3667 var msr = 'ÑÑ'; 3668 if(kef != 1){ 3669 msr = 'м3'; 3670 } 3671 console.log(kef); 3672 if (this.obPrice) 3673 { 3674 if (price) 3675 { 3676 BX.adjust(this.obPrice, {html: BX.Currency.currencyFormat(price.RATIO_PRICE*kef, price.CURRENCY, true) + ' / '+msr}); 3677 } 3678 else 3679 { 3680 BX.adjust(this.obPrice, {html: ''}); 3681 } 3682 3683 if (this.showOldPrice && this.obPriceOld) 3684 { 3685 if (price && price.RATIO_PRICE !== price.RATIO_BASE_PRICE) 3686 { 3687 BX.adjust(this.obPriceOld, { 3688 style: {display: ''}, 3689 html: BX.Currency.currencyFormat(price.RATIO_BASE_PRICE*kef, price.CURRENCY, true) 3690 }); 3691 } 3692 else 3693 { 3694 BX.adjust(this.obPriceOld, { 3695 style: {display: 'none'}, 3696 html: '' 3697 }); 3698 } 3699 } 3700 3701 if (this.obPriceTotal) 3702 { 3703 if (price && this.obQuantity && this.obQuantity.value != this.stepQuantity) 3704 { 3705 BX.adjust(this.obPriceTotal, { 3706 html: BX.message('PRICE_TOTAL_PREFIX') + ' <strong>' 3707 + BX.Currency.currencyFormat(price.PRICE * this.obQuantity.value, price.CURRENCY, true) 3708 + '</strong>', 3709 style: {display: ''} 3710 }); 3711 } 3712 else 3713 { 3714 BX.adjust(this.obPriceTotal, { 3715 html: '', 3716 style: {display: 'none'} 3717 }); 3718 } 3719 } 3720 3721 if (this.showPercent) 3722 { 3723 if (price && parseInt(price.DISCOUNT) > 0) 3724 { 3725 obData = {style: {display: ''}, html: -price.PERCENT + '%'}; 3726 } 3727 else 3728 { 3729 obData = {style: {display: 'none'}, html: ''}; 3730 } 3731 3732 if (this.obDscPerc) 3733 { 3734 BX.adjust(this.obDscPerc, obData); 3735 } 3736 3737 if (this.obSecondDscPerc) 3738 { 3739 BX.adjust(this.obSecondDscPerc, obData); 3740 } 3741 } 3742 } 3743 }, 3744 3745 compare: function(event) 3746 { 3747 /*var checkbox = this.obCompare.querySelector('[data-entity="compare-checkbox"]'), 3748 target = BX.getEventTarget(event), 3749 checked = true; 3750 3751 if (checkbox) 3752 { 3753 checked = target === checkbox ? checkbox.checked : !checkbox.checked; 3754 }*/ 3755 3756 var checked = !this.obCompare.classList.contains("active") ? 1 : 0; 3757 3758 console.log(this.compareData); 3759 //var url = checked ? this.compareData.compareUrl : this.compareData.compareDeleteUrl, 3760 var url = !this.obCompare.classList.contains("active") ? this.compareData.compareUrl : this.compareData.compareDeleteUrl, 3761 compareLink; 3762 3763 if (url) 3764 { 3765 //if (target !== checkbox) { 3766 BX.PreventDefault(event); 3767 this.setCompared(checked); 3768 //} 3769 3770 switch (this.productType) 3771 { 3772 case 0: // no catalog 3773 case 1: // product 3774 case 2: // set 3775 compareLink = url.replace('#ID#', this.product.id.toString()); 3776 break; 3777 case 3: // sku 3778 compareLink = url.replace('#ID#', this.offers[this.offerNum].ID); 3779 break; 3780 } 3781 3782 BX.ajax({ 3783 method: 'POST', 3784 dataType: checked ? 'json' : 'html', 3785 url: compareLink + (compareLink.indexOf('?') !== -1 ? '&' : '?') + 'ajax_action=Y', 3786 onsuccess: checked 3787 ? BX.proxy(this.compareResult, this) 3788 : BX.proxy(this.compareDeleteResult, this) 3789 }); 3790 } 3791 }, 3792 3793 compareResult: function(result) 3794 { 3795 var popupContent, popupButtons; 3796 3797 if (this.obPopupWin) 3798 { 3799 this.obPopupWin.close(); 3800 } 3801 3802 if (!BX.type.isPlainObject(result)) 3803 return; 3804 3805 this.initPopupWindow(); 3806 3807 if (this.offers.length > 0) 3808 { 3809 this.offers[this.offerNum].COMPARED = result.STATUS === 'OK'; 3810 } 3811 3812 if (result.STATUS === 'OK') 3813 { 3814 BX.onCustomEvent('OnCompareChange'); 3815 3816 popupContent = '<div style="width: 100%; margin: 0; text-align: center;"><p>' 3817 + BX.message('COMPARE_MESSAGE_OK') 3818 + '</p></div>'; 3819 3820 3821 if (this.showClosePopup) 3822 { 3823 popupButtons = [ 3824 new BasketButton({ 3825 text: BX.message('BTN_MESSAGE_COMPARE_REDIRECT'), 3826 events: { 3827 click: BX.delegate(this.compareRedirect, this) 3828 }, 3829 style: {marginRight: '10px'} 3830 }), 3831 new BasketButton({ 3832 text: BX.message('BTN_MESSAGE_CLOSE_POPUP'), 3833 events: { 3834 click: BX.delegate(this.obPopupWin.close, this.obPopupWin) 3835 } 3836 }) 3837 ]; 3838 } 3839 else 3840 { 3841 popupButtons = [ 3842 new BasketButton({ 3843 text: BX.message('BTN_MESSAGE_COMPARE_REDIRECT'), 3844 events: { 3845 click: BX.delegate(this.compareRedirect, this) 3846 } 3847 }) 3848 ]; 3849 } 3850 } 3851 else 3852 { 3853 popupContent = '<div style="width: 100%; margin: 0; text-align: center;"><p>' 3854 + (result.MESSAGE ? result.MESSAGE : BX.message('COMPARE_UNKNOWN_ERROR')) 3855 + '</p></div>'; 3856 popupButtons = [ 3857 new BasketButton({ 3858 text: BX.message('BTN_MESSAGE_CLOSE'), 3859 events: { 3860 click: BX.delegate(this.obPopupWin.close, this.obPopupWin) 3861 } 3862 }) 3863 ]; 3864 } 3865 3866 this.obPopupWin.setTitleBar(BX.message('COMPARE_TITLE')); 3867 this.obPopupWin.setContent(popupContent); 3868 this.obPopupWin.setButtons(popupButtons); 3869 this.obPopupWin.show(); 3870 }, 3871 3872 compareDeleteResult: function() 3873 { 3874 BX.onCustomEvent('OnCompareChange'); 3875 3876 this.obCompare.classList.remove("active"); 3877 3878 if (this.offers && this.offers.length) 3879 { 3880 this.offers[this.offerNum].COMPARED = false; 3881 } 3882 }, 3883 3884 setCompared: function(state) 3885 { 3886 if (!this.obCompare) 3887 return; 3888 3889 if (state){ 3890 this.obCompare.classList.add("active"); 3891 } 3892 else 3893 this.obCompare.classList.remove("active"); 3894 3895 /*var checkbox = this.obCompare.querySelector('[data-entity="compare-checkbox"]'); 3896 if (checkbox) 3897 { 3898 checkbox.checked = state; 3899 }*/ 3900 }, 3901 3902 setCompareInfo: function(comparedIds) 3903 { 3904 if (!BX.type.isArray(comparedIds)) 3905 return; 3906 3907 for (var i in this.offers) 3908 { 3909 if (this.offers.hasOwnProperty(i)) 3910 { 3911 this.offers[i].COMPARED = BX.util.in_array(this.offers[i].ID, comparedIds); 3912 } 3913 } 3914 }, 3915 3916 compareRedirect: function() 3917 { 3918 if (this.compareData.comparePath) 3919 { 3920 location.href = this.compareData.comparePath; 3921 } 3922 else 3923 { 3924 this.obPopupWin.close(); 3925 } 3926 }, 3927 3928 checkDeletedCompare: function(id) 3929 { 3930 switch (this.productType) 3931 { 3932 case 0: // no catalog 3933 case 1: // product 3934 case 2: // set 3935 if (this.product.id == id) 3936 { 3937 this.setCompared(false); 3938 } 3939 3940 break; 3941 case 3: // sku 3942 var i = this.offers.length; 3943 while (i--) 3944 { 3945 if (this.offers[i].ID == id) 3946 { 3947 this.offers[i].COMPARED = false; 3948 3949 if (this.offerNum == i) 3950 { 3951 this.setCompared(false); 3952 } 3953 3954 break; 3955 } 3956 } 3957 } 3958 }, 3959 3960 3961 3962 delay: function(event) 3963 { 3964 /*var checkbox = this.obDelay.querySelector('[data-entity="delay-checkbox"]'), 3965 target = BX.getEventTarget(event), 3966 checked = true; 3967 3968 if (checkbox) 3969 { 3970 checked = target === checkbox ? checkbox.checked : !checkbox.checked; 3971 }*/ 3972 3973 var checked = !this.obDelay.classList.contains("active") ? 1 : 0; 3974 3975 //var url = checked ? this.delayData.delayUrl : this.delayData.delayDeleteUrl, 3976 var url = !this.obDelay.classList.contains("active") ? this.delayData.delayUrl : this.delayData.delayDeleteUrl, 3977 delayLink; 3978 3979 if (url) 3980 { 3981 //if (target !== checkbox) { 3982 BX.PreventDefault(event); 3983 this.setDelayed(checked); 3984 //} 3985 3986 switch (this.productType) 3987 { 3988 case 0: // no catalog 3989 case 1: // product 3990 case 2: // set 3991 delayLink = url.replace('#ID#', this.product.id.toString()); 3992 break; 3993 case 3: // sku 3994 delayLink = url.replace('#ID#', this.offers[this.offerNum].ID); 3995 break; 3996 } 3997 3998 BX.ajax({ 3999 method: 'POST', 4000 dataType: checked ? 'json' : 'html', 4001 url: delayLink, 4002 onsuccess: checked 4003 ? BX.proxy(this.delayResult, this) 4004 : BX.proxy(this.delayDeleteResult, this) 4005 }); 4006 } 4007 }, 4008 4009 delayResult: function(result) 4010 { 4011 var popupContent, popupButtons; 4012 4013 if (this.obPopupWin) 4014 { 4015 this.obPopupWin.close(); 4016 } 4017 4018 if (result){ 4019 var status = 'OK'; 4020 } else { 4021 4022 } 4023 4024 //if (!BX.type.isPlainObject(result)) 4025 // return; 4026 4027 this.initPopupWindow(); 4028 4029 if (this.offers.length > 0) 4030 { 4031 this.offers[this.offerNum].DELAY = status === 'OK'; 4032 } 4033 4034 if (status === 'OK') 4035 {
4036 BX.onCustomEvent('OnDelayChange'); 4037 this.delayChange(result); 4038 4039 popupContent = '<div style="width: 100%; margin: 0; text-align: center;"><p>' 4040 + BX.message('DELAY_MESSAGE_OK') 4041 + '</p></div>'; 4042 4043 4044 if (this.showClosePopup) 4045 { 4046 popupButtons = [ 4047 new BasketButton({ 4048 text: BX.message('BTN_MESSAGE_DELAY_REDIRECT'), 4049 events: { 4050 click: BX.delegate(this.delayRedirect, this) 4051 }, 4052 style: {marginRight: '10px'} 4053 }), 4054 new BasketButton({ 4055 text: BX.message('BTN_MESSAGE_CLOSE_POPUP'), 4056 events: { 4057 click: BX.delegate(this.obPopupWin.close, this.obPopupWin) 4058 } 4059 }) 4060 ]; 4061 } 4062 else 4063 { 4064 popupButtons = [ 4065 new BasketButton({ 4066 text: BX.message('BTN_MESSAGE_DELAY_REDIRECT'), 4067 events: { 4068 click: BX.delegate(this.delayRedirect, this) 4069 } 4070 }) 4071 ]; 4072 } 4073 } 4074 else 4075 { 4076 popupContent = '<div style="width: 100%; margin: 0; text-align: center;"><p>' 4077 + (result.MESSAGE ? result.MESSAGE : BX.message('DELAY_UNKNOWN_ERROR')) 4078 + '</p></div>'; 4079 popupButtons = [ 4080 new BasketButton({ 4081 text: BX.message('BTN_MESSAGE_CLOSE'), 4082 events: { 4083 click: BX.delegate(this.obPopupWin.close, this.obPopupWin) 4084 } 4085 }) 4086 ]; 4087 } 4088 4089 this.obPopupWin.setTitleBar(BX.message('DELAY_TITLE')); 4090 this.obPopupWin.setContent(popupContent); 4091 this.obPopupWin.setButtons(popupButtons); 4092 this.obPopupWin.show(); 4093 }, 4094 4095 delayDeleteResult: function(result) 4096 { 4097 BX.onCustomEvent('OnDelayChange'); 4098 4099 if (result) 4100 this.delayChange(result); 4101 else 4102 this.delayChange(); 4103 4104 this.obDelay.classList.remove("active"); 4105 4106 if (this.offers && this.offers.length) 4107 { 4108 this.offers[this.offerNum].DELAY = false; 4109 } 4110 }, 4111 4112 delayChange: function(result) 4113 { 4114 var obCountDelay = BX("count_delay"), 4115 obCountDelayMobile = BX("count_delay_mobile"); 4116 4117 if (obCountDelay) 4118 this.delayChangeObject(obCountDelay, result); 4119 4120 if (obCountDelayMobile) 4121 this.delayChangeObject(obCountDelayMobile, result); 4122 }, 4123 4124 delayChangeObject: function(object, result) 4125 { 4126 if (result) 4127 { 4128 object.style.display = "block"; 4129 object.innerHTML = result; 4130 } 4131 else 4132 { 4133 object.style.display = "none"; 4134 object.innerHTML = ''; 4135 } 4136 }, 4137 4138 setDelayed: function(state) 4139 { 4140 if (!this.obDelay) 4141 return; 4142 4143 if (state){ 4144 this.obDelay.classList.add("active"); 4145 } 4146 else 4147 this.obDelay.classList.remove("active"); 4148 4149 /*var checkbox = this.obCompare.querySelector('[data-entity="delay-checkbox"]'); 4150 if (checkbox) 4151 { 4152 checkbox.checked = state; 4153 }*/ 4154 }, 4155 4156 setDelayInfo: function(delayedIds) 4157 { 4158 if (!BX.type.isArray(delayedIds)) 4159 return; 4160 4161 for (var i in this.offers) 4162 { 4163 if (this.offers.hasOwnProperty(i)) 4164 { 4165 this.offers[i].DELAY = BX.util.in_array(this.offers[i].ID, delayedIds); 4166 } 4167 } 4168 }, 4169 4170 delayRedirect: function() 4171 { 4172 if (this.delayData.delayPath) 4173 { 4174 location.href = this.delayData.delayPath; 4175 } 4176 else 4177 { 4178 this.obPopupWin.close(); 4179 } 4180 }, 4181 4182 checkDeletedDelay: function(id) 4183 { 4184 switch (this.productType) 4185 { 4186 case 0: // no catalog 4187 case 1: // product 4188 case 2: // set 4189 if (this.product.id == id) 4190 { 4191 this.setDelayed(false); 4192 } 4193 4194 break; 4195 case 3: // sku 4196 var i = this.offers.length; 4197 while (i--) 4198 { 4199 if (this.offers[i].ID == id) 4200 { 4201 this.offers[i].DELAY = false; 4202 4203 if (this.offerNum == i) 4204 { 4205 this.setDelayed(false); 4206 } 4207 4208 break; 4209 } 4210 } 4211 } 4212 }, 4213 4214 initBasketUrl: function() 4215 { 4216 this.basketUrl = (this.basketMode === 'ADD' ? this.basketData.add_url : this.basketData.buy_url); 4217 switch (this.productType) 4218 { 4219 case 1: // product 4220 case 2: // set 4221 this.basketUrl = this.basketUrl.replace('#ID#', this.product.id.toString()); 4222 break; 4223 case 3: // sku 4224 this.basketUrl = this.basketUrl.replace('#ID#', this.offers[this.offerNum].ID); 4225 break; 4226 } 4227 this.basketParams = { 4228 'ajax_basket': 'Y' 4229 }; 4230 if (this.showQuantity) 4231 { 4232 this.basketParams[this.basketData.quantity] = this.obQuantity.value; 4233 } 4234 if (this.basketData.sku_props) 4235 { 4236 this.basketParams[this.basketData.sku_props_var] = this.basketData.sku_props; 4237 } 4238 }, 4239 4240 fillBasketProps: function() 4241 { 4242 if (!this.visual.BASKET_PROP_DIV) 4243 { 4244 return; 4245 } 4246 var 4247 i = 0, 4248 propCollection = null, 4249 foundValues = false, 4250 obBasketProps = null; 4251 4252 if (this.basketData.useProps && !this.basketData.emptyProps) 4253 { 4254 if (this.obPopupWin && this.obPopupWin.contentContainer) 4255 { 4256 obBasketProps = this.obPopupWin.contentContainer; 4257 } 4258 } 4259 else 4260 { 4261 obBasketProps = BX(this.visual.BASKET_PROP_DIV); 4262 } 4263 if (obBasketProps) 4264 { 4265 propCollection = obBasketProps.getElementsByTagName('select'); 4266 if (propCollection && propCollection.length) 4267 { 4268 for (i = 0; i < propCollection.length; i++) 4269 { 4270 if (!propCollection[i].disabled) 4271 { 4272 switch (propCollection[i].type.toLowerCase()) 4273 { 4274 case 'select-one': 4275 this.basketParams[propCollection[i].name] = propCollection[i].value; 4276 foundValues = true; 4277 break; 4278 default: 4279 break; 4280 } 4281 } 4282 } 4283 } 4284 propCollection = obBasketProps.getElementsByTagName('input'); 4285 if (propCollection && propCollection.length) 4286 { 4287 for (i = 0; i < propCollection.length; i++) 4288 { 4289 if (!propCollection[i].disabled) 4290 { 4291 switch (propCollection[i].type.toLowerCase()) 4292 { 4293 case 'hidden': 4294 this.basketParams[propCollection[i].name] = propCollection[i].value; 4295 foundValues = true; 4296 break; 4297 case 'radio': 4298 if (propCollection[i].checked) 4299 { 4300 this.basketParams[propCollection[i].name] = propCollection[i].value; 4301 foundValues = true; 4302 } 4303 break; 4304 default: 4305 break; 4306 } 4307 } 4308 } 4309 } 4310 } 4311 if (!foundValues) 4312 { 4313 this.basketParams[this.basketData.props] = []; 4314 this.basketParams[this.basketData.props][0] = 0; 4315 } 4316 }, 4317 4318 add2Basket: function() 4319 { 4320 this.basketMode = 'ADD'; 4321 this.basket(); 4322 }, 4323 4324 buyBasket: function() 4325 { 4326 this.basketMode = 'BUY'; 4327 this.basket(); 4328 }, 4329 4330 sendToBasket: function() 4331 { 4332 if (!this.canBuy) 4333 { 4334 return; 4335 } 4336 4337 // check recommendation 4338 if (this.product && this.product.id && this.bigData) 4339 { 4340 this.rememberProductRecommendation(); 4341 } 4342 4343 this.initBasketUrl(); 4344 this.fillBasketProps(); 4345 BX.ajax({ 4346 method: 'POST', 4347 dataType: 'json', 4348 url: this.basketUrl, 4349 data: this.basketParams, 4350 onsuccess: BX.proxy(this.basketResult, this) 4351 }); 4352 }, 4353 4354 basket: function() 4355 { 4356 var contentBasketProps = ''; 4357 if (!this.canBuy) 4358 { 4359 return; 4360 } 4361 switch (this.productType) 4362 { 4363 case 1: // product 4364 case 2: // set 4365 if (this.basketData.useProps && !this.basketData.emptyProps) 4366 { 4367 this.initPopupWindow(); 4368 this.obPopupWin.setTitleBar(BX.message('TITLE_BASKET_PROPS')); 4369 if (BX(this.visual.BASKET_PROP_DIV)) 4370 { 4371 contentBasketProps = BX(this.visual.BASKET_PROP_DIV).innerHTML; 4372 } 4373 this.obPopupWin.setContent(contentBasketProps); 4374 this.obPopupWin.setButtons([ 4375 new BasketButton({ 4376 text: BX.message('BTN_MESSAGE_SEND_PROPS'), 4377 events: { 4378 click: BX.delegate(this.sendToBasket, this) 4379 } 4380 }) 4381 ]); 4382 this.obPopupWin.show(); 4383 } 4384 else 4385 { 4386 this.sendToBasket(); 4387 } 4388 break; 4389 case 3: // sku 4390 this.sendToBasket(); 4391 break; 4392 } 4393 }, 4394 4395 basketResult: function(arResult) 4396 { 4397 var strContent = '', 4398 strPict = '', 4399 successful, 4400 buttons = []; 4401 4402 if (this.obPopupWin) 4403 this.obPopupWin.close(); 4404 4405 if (!BX.type.isPlainObject(arResult)) 4406 return; 4407 4408 successful = arResult.STATUS === 'OK'; 4409 4410 if (successful) 4411 { 4412 this.setAnalyticsDataLayer('addToCart'); 4413 } 4414 4415 if (successful && this.basketAction === 'BUY') 4416 { 4417 this.basketRedirect(); 4418 } 4419 else 4420 { 4421 this.initPopupWindow(); 4422 4423 if (successful) 4424 { 4425 BX.onCustomEvent('OnBasketChange'); 4426 4427 if (BX.findParent(this.obProduct, {className: 'bx_sale_gift_main_products'}, 10)) 4428 { 4429 BX.onCustomEvent('onAddToBasketMainProduct', [this]); 4430 } 4431 4432 switch (this.productType) 4433 { 4434 case 1: // product 4435 case 2: // set 4436 strPict = this.product.pict.SRC; 4437 break; 4438 case 3: // sku 4439 strPict = (this.offers[this.offerNum].PREVIEW_PICTURE ? 4440 this.offers[this.offerNum].PREVIEW_PICTURE.SRC : 4441 this.defaultPict.pict.SRC 4442 ); 4443 break; 4444 } 4445 4446 strContent = '<div style="width: 100%; margin: 0; text-align: center;"><img src="' 4447 + strPict + '" height="130" style="max-height:130px"><p>' + this.product.name + '</p></div>'; 4448 4449 if (this.showClosePopup) 4450 { 4451 buttons = [ 4452 new BasketButton({ 4453 text: BX.message("BTN_MESSAGE_BASKET_REDIRECT"), 4454 events: { 4455 click: BX.delegate(this.basketRedirect, this) 4456 }, 4457 style: {marginRight: '10px'} 4458 }), 4459 new BasketButton({ 4460 text: BX.message("BTN_MESSAGE_CLOSE_POPUP"), 4461 events: { 4462 click: BX.delegate(this.obPopupWin.close, this.obPopupWin) 4463 } 4464 }) 4465 ]; 4466 } 4467 else 4468 { 4469 buttons = [ 4470 new BasketButton({ 4471 text: BX.message("BTN_MESSAGE_BASKET_REDIRECT"), 4472 events: { 4473 click: BX.delegate(this.basketRedirect, this) 4474 } 4475 }) 4476 ]; 4477 } 4478 } 4479 else 4480 { 4481 strContent = '<div style="width: 100%; margin: 0; text-align: center;"><p>' 4482 + (arResult.MESSAGE ? arResult.MESSAGE : BX.message('BASKET_UNKNOWN_ERROR')) 4483 + '</p></div>'; 4484 buttons = [ 4485 new BasketButton({ 4486 text: BX.message('BTN_MESSAGE_CLOSE'), 4487 events: { 4488 click: BX.delegate(this.obPopupWin.close, this.obPopupWin) 4489 } 4490 }) 4491 ]; 4492 } 4493 this.obPopupWin.setTitleBar(successful ? BX.message('TITLE_SUCCESSFUL') : BX.message('TITLE_ERROR')); 4494 this.obPopupWin.setContent(strContent); 4495 this.obPopupWin.setButtons(buttons); 4496 this.obPopupWin.show(); 4497 } 4498 }, 4499 4500 basketRedirect: function() 4501 { 4502 location.href = (this.basketData.basketUrl ? this.basketData.basketUrl : BX.message('BASKET_URL')); 4503 }, 4504 4505 initPopupWindow: function() 4506 { 4507 if (this.obPopupWin) 4508 return; 4509 4510 this.obPopupWin = BX.PopupWindowManager.create('CatalogSectionBasket_' + this.visual.ID, null, { 4511 autoHide: true, 4512 offsetLeft: 0, 4513 offsetTop: 0, 4514 overlay : true, 4515 closeByEsc: true, 4516 titleBar: true, 4517 closeIcon: true, 4518 contentColor: 'white', 4519 className: this.templateTheme ? 'bx-' + this.templateTheme : '' 4520 }); 4521 } 4522 }; 4523})(window); 4524/* End */ 4525; 4526; /* Start:"a:4:{s:4:"full";s:118:"/bitrix/templates/innet_focus_s2/components/bitrix/news/partnersmap/bitrix/news.list/.default/script.js?17222797454887";s:6:"source";s:103:"/bitrix/templates/innet_focus_s2/components/bitrix/news/partnersmap/bitrix/news.list/.default/script.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 4527(function() { 4528 'use strict'; 4529 4530 if (!!window.awz_group_map) { 4531 return; 4532 } 4533 4534 window.awz_group_map = function(options) { 4535 this.init(options); 4536 }; 4537 4538 window.awz_group_map.prototype = { 4539 map: null, 4540 mapObjectsArray: [], 4541 init: function(options){ 4542 var parent = this; 4543 parent.initOb(options.ITEMS_GEO); 4544 parent.initMap(options); 4545 }, 4546 reinit: function(options){ 4547 var parent = this; 4548 this.mapObjectManager.removeAll(); 4549 this.mapObjectsArray = []; 4550 this.initOb(options.ITEMS_GEO); 4551 this.mapObjectManager.add(this.mapObjectsArray);
4552 this.map.geoObjects.add(this.mapObjectManager); 4553 this.map.setBounds(this.map.geoObjects.getBounds(), {checkZoomRange:true}); 4554 }, 4555 initOb: function(ob){ 4556 var parent = this; 4557 ob.forEach(function(item){ 4558 if(!item['group']) item['group'] = 'icon_offical'; 4559 parent.mapObjectsArray.push({ 4560 "type": "Feature", 4561 "id": item.id, 4562 "geometry": { 4563 "type": "Point", 4564 "coordinates": [item.position.latitude,item.position.longitude] 4565 }, 4566 "options":{ 4567 iconLayout: 'default#image', 4568 iconImageHref: "/bitrix/templates/innet_focus_s2/components/bitrix/news/partnersmap/bitrix/news.list/.default/images/"+item['group']+".svg", 4569 iconImageSize: [64, 64], 4570 iconImageOffset: [-32, -54], 4571 preset: 'islands#blackClusterIcons', 4572 openEmptyBalloon: true 4573 }, 4574 "properties":{ 4575 balloonContent: item.html, 4576 id: item.id 4577 } 4578 }); 4579 }); 4580 }, 4581 initMap: function(options){ 4582 var parent = this; 4583 var controls = ['zoomControl']; 4584 4585 this.map = new ymaps.Map("awz_group_map",{ 4586 center: [53.873516, 27.416178], 4587 zoom: 14, 4588 controls: controls 4589 },{ 4590 balloonMaxWidth: 280 4591 }); 4592 4593 this.customBalloonContentLayout = ymaps.templateLayoutFactory.createClass('<div class="yd-popup-balloon-content"></div>'); 4594 this.mapObjectManager = new ymaps.ObjectManager({ 4595 clusterize: true, 4596 clusterBalloonContentLayout: this.customBalloonContentLayout, 4597 geoObjectOpenBalloonOnClick: false 4598 }); 4599 this.mapObjectManager.clusters.options.set('preset', 'islands#blackClusterIcons'); 4600 this.mapObjectManager.clusters.events.add(['balloonopen'], function(e){ 4601 //console.log(e); 4602 }); 4603 this.mapObjectManager.objects.events.add(['click'], function(e){ 4604 //console.log(e, params); 4605 //window.awz_ep_modal.loadBaloonAjax(e, params); 4606 4607 //var objectId = e.get('objectId'); 4608 //obj = parent.mapObjectManager.objects.getById(objectId); 4609 parent.mapObjectManager.objects.balloon.open(e.get('objectId')); 4610 parent.setActive(e.get('objectId'), true); 4611 4612 }); 4613 4614 this.mapObjectManager.add(this.mapObjectsArray); 4615 4616 this.map.geoObjects.add(this.mapObjectManager); 4617 4618 this.map.setBounds(this.map.geoObjects.getBounds(), {checkZoomRange:true}); 4619 4620 4621 }, 4622 setItem: function(id){ 4623 this.mapObjectManager.objects.balloon.open(id); 4624 this.setActive(id); 4625 }, 4626 setActive: function(id, scroll){ 4627 $('.map-list .item-map').removeClass('active'); 4628 $('.map-list .item-map[data-id="'+id+'"]').addClass('active'); 4629 if(!!scroll){ 4630 $('.map-list').animate({ 4631 scrollTop : $('.map-list').scrollTop() + $('.map-list .item-map[data-id="'+id+'"]').offset().top - $('.map-list').height() - $('.map-list .item-map[data-id="'+id+'"]').height() 4632 }); 4633 } 4634 }, 4635 getAjaxMap: function(){ 4636 var formData = $('form[name="partnerFilter_form"]').serialize(); 4637 formData += '&ajax=Y'; 4638 $.ajax({
4639 url: '/company/partners-on-maps/', 4640 method: 'POST', 4641 data: formData, 4642 type: 'html', 4643 success: function(resp){ 4644 $('.aj-wrapper').html(resp); 4645 }, 4646 error: function(){ 4647 4648 } 4649 }); 4650 } 4651 }; 4652 4653})(); 4654/* End */ 4655;; /* /bitrix/templates/innet_focus_s2/components/bitrix/news.list/stories/script.js?171776126954406*/ 4656; /* /bitrix/templates/innet_focus_s2/components/bitrix/catalog.section/wide_slider/script.js?16440949398298*/ 4657; /* /bitrix/templates/innet_focus_s2/components/bitrix/catalog.item/innet_slide/script.js?167733398074799*/ 4658; /* /bitrix/templates/innet_focus_s2/components/bitrix/news/partnersmap/bitrix/news.list/.default/script.js?17222797454887*/
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.