1(function (window) { 2 3if (!!window.JCCatalogSection) 4{ 5 return; 6} 7 8var BasketButton = function(params) 9{ 10 BasketButton.superclass.constructor.apply(this, arguments); 11 this.nameNode = BX.create('span', { 12 props : { className : 'bx_medium bx_bt_button', id : this.id }, 13 text: params.text 14 }); 15 this.buttonNode = BX.create('span', { 16 attrs: { className: params.ownerClass }, 17 style: { marginBottom: '0', borderBottom: '0 none transparent' }, 18 children: [this.nameNode], 19 events : this.contextEvents 20 }); 21 if (BX.browser.IsIE()) 22 { 23 this.buttonNode.setAttribute("hideFocus", "hidefocus"); 24 } 25}; 26BX.extend(BasketButton, BX.PopupWindowButton); 27 28window.JCCatalogSection = function (arParams) 29{ 30 this.productType = 0; 31 this.showQuantity = true; 32 this.showAbsent = true; 33 this.secondPict = false; 34 this.showOldPrice = false; 35 this.showPercent = false; 36 this.showSkuProps = false; 37 this.visual = { 38 ID: '', 39 PICT_ID: '', 40 SECOND_PICT_ID: '', 41 QUANTITY_ID: '', 42 QUANTITY_UP_ID: '', 43 QUANTITY_DOWN_ID: '', 44 PRICE_ID: '', 45 DSC_PERC: '', 46 SECOND_DSC_PERC: '', 47 DISPLAY_PROP_DIV: '', 48 BASKET_PROP_DIV: '' 49 }; 50 this.product = { 51 checkQuantity: false, 52 maxQuantity: 0, 53 stepQuantity: 1, 54 isDblQuantity: false, 55 canBuy: true, 56 canSubscription: true, 57 name: '', 58 pict: {}, 59 id: 0, 60 addUrl: '', 61 buyUrl: '' 62 }; 63 this.basketData = { 64 useProps: false, 65 emptyProps: false, 66 quantity: 'quantity', 67 props: 'prop', 68 basketUrl: '' 69 }; 70 71 this.defaultPict = { 72 pict: null, 73 secondPict: null 74 }; 75 76 this.checkQuantity = false; 77 this.maxQuantity = 0; 78 this.stepQuantity = 1; 79 this.isDblQuantity = false; 80 this.canBuy = true; 81 this.canSubscription = true; 82 this.precision = 6; 83 this.precisionFactor = Math.pow(10,this.precision); 84 85 this.offers = []; 86 this.offerNum = 0; 87 this.treeProps = []; 88 this.obTreeRows = []; 89 this.showCount = []; 90 this.showStart = []; 91 this.selectedValues = {}; 92 93 this.obProduct = null; 94 this.obQuantity = null; 95 this.obQuantityUp = null; 96 this.obQuantityDown = null; 97 this.obPict = null; 98 this.obSecondPict = null; 99 this.obPrice = null; 100 this.obTree = null; 101 this.obBuyBtn = null; 102 this.obDscPerc = null; 103 this.obSecondDscPerc = null; 104 this.obSkuProps = null; 105 this.obMeasure = null; 106 107 this.obPopupWin = null; 108 this.basketUrl = ''; 109 this.basketParams = {}; 110 111 this.treeRowShowSize = 5; 112 this.treeEnableArrow = { display: '', cursor: 'pointer', opacity: 1 }; 113 this.treeDisableArrow = { display: '', cursor: 'default', opacity:0.2 }; 114 115 this.lastElement = false; 116 this.containerHeight = 0; 117 118 this.errorCode = 0; 119 120 if ('object' === typeof arParams) 121 { 122 this.productType = parseInt(arParams.PRODUCT_TYPE, 10); 123 this.showQuantity = arParams.SHOW_QUANTITY; 124 this.showAbsent = arParams.SHOW_ABSENT; 125 this.secondPict = !!arParams.SECOND_PICT; 126 this.showOldPrice = !!arParams.SHOW_OLD_PRICE; 127 this.showPercent = !!arParams.SHOW_DISCOUNT_PERCENT; 128 this.showSkuProps = !!arParams.SHOW_SKU_PROPS; 129 130 this.visual = arParams.VISUAL; 131 switch (this.productType) 132 { 133 case 1://product 134 case 2://set 135 if (!!arParams.PRODUCT && 'object' === typeof(arParams.PRODUCT)) 136 { 137 if (this.showQuantity) 138 { 139 this.product.checkQuantity = arParams.PRODUCT.CHECK_QUANTITY; 140 this.product.isDblQuantity = arParams.PRODUCT.QUANTITY_FLOAT; 141 if (this.product.checkQuantity) 142 { 143 this.product.maxQuantity = (this.product.isDblQuantity ? parseFloat(arParams.PRODUCT.MAX_QUANTITY) : parseInt(arParams.PRODUCT.MAX_QUANTITY, 10)); 144 } 145 this.product.stepQuantity = (this.product.isDblQuantity ? parseFloat(arParams.PRODUCT.STEP_QUANTITY) : parseInt(arParams.PRODUCT.STEP_QUANTITY, 10)); 146 147 this.checkQuantity = this.product.checkQuantity; 148 this.isDblQuantity = this.product.isDblQuantity; 149 this.maxQuantity = this.product.maxQuantity; 150 this.stepQuantity = this.product.stepQuantity; 151 if (this.isDblQuantity) 152 { 153 this.stepQuantity = Math.round(this.stepQuantity*this.precisionFactor)/this.precisionFactor; 154 } 155 } 156 this.product.canBuy = arParams.PRODUCT.CAN_BUY; 157 this.product.canSubscription = arParams.PRODUCT.SUBSCRIPTION; 158 159 this.canBuy = this.product.canBuy; 160 this.canSubscription = this.product.canSubscription; 161
162 this.product.name = arParams.PRODUCT.NAME; 163 this.product.pict = arParams.PRODUCT.PICT; 164 this.product.id = arParams.PRODUCT.ID; 165 if (!!arParams.PRODUCT.ADD_URL) 166 { 167 this.product.addUrl = arParams.PRODUCT.ADD_URL; 168 } 169 if (!!arParams.PRODUCT.BUY_URL) 170 { 171 this.product.buyUrl = arParams.PRODUCT.BUY_URL; 172 } 173 if (!!arParams.BASKET && 'object' === typeof(arParams.BASKET)) 174 { 175 this.basketData.useProps = !!arParams.BASKET.ADD_PROPS; 176 this.basketData.emptyProps = !!arParams.BASKET.EMPTY_PROPS; 177 } 178 } 179 else 180 { 181 this.errorCode = -1; 182 } 183 break; 184 case 3://sku 185 if (!!arParams.OFFERS && BX.type.isArray(arParams.OFFERS)) 186 { 187 if (!!arParams.PRODUCT && 'object' === typeof(arParams.PRODUCT)) 188 { 189 this.product.name = arParams.PRODUCT.NAME; 190 this.product.id = arParams.PRODUCT.ID; 191 } 192 this.offers = arParams.OFFERS; 193 this.offerNum = 0; 194 if (!!arParams.OFFER_SELECTED) 195 { 196 this.offerNum = parseInt(arParams.OFFER_SELECTED, 10); 197 } 198 if (isNaN(this.offerNum)) 199 { 200 this.offerNum = 0; 201 } 202 if (!!arParams.TREE_PROPS) 203 { 204 this.treeProps = arParams.TREE_PROPS; 205 } 206 if (!!arParams.DEFAULT_PICTURE) 207 { 208 this.defaultPict.pict = arParams.DEFAULT_PICTURE.PICTURE; 209 this.defaultPict.secondPict = arParams.DEFAULT_PICTURE.PICTURE_SECOND; 210 } 211 } 212 else 213 { 214 this.errorCode = -1; 215 } 216 break; 217 default: 218 this.errorCode = -1; 219 } 220 if (!!arParams.BASKET && 'object' === typeof(arParams.BASKET)) 221 { 222 if (!!arParams.BASKET.QUANTITY) 223 { 224 this.basketData.quantity = arParams.BASKET.QUANTITY; 225 } 226 if (!!arParams.BASKET.PROPS) 227 { 228 this.basketData.props = arParams.BASKET.PROPS; 229 } 230 if (!!arParams.BASKET.BASKET_URL) 231 { 232 this.basketData.basketUrl = arParams.BASKET.BASKET_URL; 233 } 234 } 235 this.lastElement = (!!arParams.LAST_ELEMENT && 'Y' === arParams.LAST_ELEMENT); 236 } 237 if (0 === this.errorCode) 238 { 239 BX.ready(BX.delegate(this.Init,this)); 240 } 241}; 242 243window.JCCatalogSection.prototype.Init = function() 244{ 245 var i = 0, 246 strPrefix = '', 247 TreeItems = null; 248 249 this.obProduct = BX(this.visual.ID); 250 if (!this.obProduct) 251 { 252 this.errorCode = -1; 253 } 254 this.obPict = BX(this.visual.PICT_ID); 255 if (!this.obPict) 256 { 257 this.errorCode = -2; 258 } 259 if (this.secondPict && !!this.visual.SECOND_PICT_ID) 260 { 261 this.obSecondPict = BX(this.visual.SECOND_PICT_ID); 262 } 263 this.obPrice = BX(this.visual.PRICE_ID); 264 if (!this.obPrice) 265 { 266 this.errorCode = -16; 267 } 268 if (this.showQuantity && !!this.visual.QUANTITY_ID) 269 { 270 this.obQuantity = BX(this.visual.QUANTITY_ID); 271 if (!!this.visual.QUANTITY_UP_ID) 272 { 273 this.obQuantityUp = BX(this.visual.QUANTITY_UP_ID); 274 } 275 if (!!this.visual.QUANTITY_DOWN_ID) 276 { 277 this.obQuantityDown = BX(this.visual.QUANTITY_DOWN_ID); 278 } 279 } 280 if (3 === this.productType) 281 { 282 if (!!this.visual.TREE_ID) 283 { 284 this.obTree = BX(this.visual.TREE_ID); 285 if (!this.obTree) 286 { 287 this.errorCode = -256; 288 } 289 strPrefix = this.visual.TREE_ITEM_ID; 290 for (i = 0; i < this.treeProps.length; i++) 291 { 292 this.obTreeRows[i] = { 293 LEFT: BX(strPrefix+this.treeProps[i].ID+'_left'), 294 RIGHT: BX(strPrefix+this.treeProps[i].ID+'_right'), 295 LIST: BX(strPrefix+this.treeProps[i].ID+'_list'), 296 CONT: BX(strPrefix+this.treeProps[i].ID+'_cont') 297 }; 298 if (!this.obTreeRows[i].LEFT || !this.obTreeRows[i].RIGHT || !this.obTreeRows[i].LIST || !this.obTreeRows[i].CONT) 299 { 300 this.errorCode = -512; 301 break; 302 } 303 } 304 } 305 if (!!this.visual.QUANTITY_MEASURE) 306 { 307 this.obMeasure = BX(this.visual.QUANTITY_MEASURE); 308 } 309 } 310 if (!!this.visual.BUY_ID) 311 { 312 this.obBuyBtn = BX(this.visual.BUY_ID); 313 } 314 315 if (this.showPercent) 316 { 317 if (!!this.visual.DSC_PERC) 318 { 319 this.obDscPerc = BX(this.visual.DSC_PERC); 320 } 321 if (this.secondPict && !!this.visual.SECOND_DSC_PERC) 322 { 323 this.obSecondDscPerc = BX(this.visual.SECOND_DSC_PERC); 324 } 325 } 326 327 if (this.showSkuProps) 328 { 329 if (!!this.visual.DISPLAY_PROP_DIV) 330 { 331 this.obSkuProps = BX(this.visual.DISPLAY_PROP_DIV); 332 } 333 } 334 335 if (0 === this.errorCode) 336 { 337 if (this.showQuantity) 338 { 339 if (!!this.obQuantityUp) 340 { 341 BX.bind(this.obQuantityUp, 'click', BX.delegate(this.QuantityUp, this)); 342 } 343 if (!!this.obQuantityDown) 344 { 345 BX.bind(this.obQuantityDown, 'click', BX.delegate(this.QuantityDown, this)); 346 } 347 if (!!this.obQuantity) 348 { 349 BX.bind(this.obQuantity, 'change', BX.delegate(this.QuantityChange, this)); 350 } 351 } 352 switch (this.productType) 353 { 354 case 1://product 355 break; 356 case 3://sku 357 TreeItems = BX.findChildren(this.obTree, {tagName: 'li'}, true); 358 if (!!TreeItems && 0 < TreeItems.length) 359 { 360 for (i = 0; i < TreeItems.length; i++) 361 { 362 BX.bind(TreeItems[i], 'click', BX.delegate(this.SelectOfferProp, this)); 363 } 364 } 365 for (i = 0; i < this.obTreeRows.length; i++) 366 { 367 BX.bind(this.obTreeRows[i].LEFT, 'click', BX.delegate(this.RowLeft, this)); 368 BX.bind(this.obTreeRows[i].RIGHT, 'click', BX.delegate(this.RowRight, this)); 369 } 370 this.SetCurrent(); 371 break; 372 } 373 if (!!this.obBuyBtn) 374 { 375 BX.bind(this.obBuyBtn, 'click', BX.delegate(this.Basket, this)); 376 } 377 if (this.lastElement) 378 { 379 this.containerHeight = parseInt(this.obProduct.parentNode.offsetHeight, 10); 380 if (isNaN(this.containerHeight)) 381 { 382 this.containerHeight = 0; 383 } 384 this.setHeight(); 385 BX.bind(window, 'resize', BX.delegate(this.checkHeight, this)); 386 BX.bind(this.obProduct.parentNode, 'mouseover', BX.delegate(this.setHeight, this)); 387 BX.bind(this.obProduct.parentNode, 'mouseout', BX.delegate(this.clearHeight, this)); 388 } 389 } 390}; 391 392window.JCCatalogSection.prototype.checkHeight = function() 393{ 394 this.containerHeight = parseInt(this.obProduct.parentNode.offsetHeight, 10); 395 if (isNaN(this.containerHeight)) 396 { 397 this.containerHeight = 0; 398 } 399}; 400 401window.JCCatalogSection.prototype.setHeight = function() 402{ 403 if (0 < this.containerHeight) 404 { 405 BX.adjust(this.obProduct.parentNode, {style: { height: this.containerHeight+'px'}}); 406 } 407}; 408 409window.JCCatalogSection.prototype.clearHeight = function() 410{ 411 BX.adjust(this.obProduct.parentNode, {style: { height: 'auto'}}); 412}; 413 414window.JCCatalogSection.prototype.QuantityUp = function() 415{ 416 var curValue = 0, 417 boolSet = true; 418 419 if (0 === this.errorCode && this.showQuantity && this.canBuy) 420 { 421 curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10)); 422 if (!isNaN(curValue)) 423 { 424 curValue += this.stepQuantity; 425 if (this.checkQuantity) 426 { 427 if (curValue > this.maxQuantity) 428 { 429 boolSet = false;
430 } 431 } 432 if (boolSet) 433 { 434 if (this.isDblQuantity) 435 { 436 curValue = Math.round(curValue*this.precisionFactor)/this.precisionFactor; 437 } 438 this.obQuantity.value = curValue; 439 } 440 } 441 } 442}; 443 444window.JCCatalogSection.prototype.QuantityDown = function() 445{ 446 var curValue = 0, 447 boolSet = true; 448 449 if (0 === this.errorCode && this.showQuantity && this.canBuy) 450 { 451 curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value): parseInt(this.obQuantity.value, 10)); 452 if (!isNaN(curValue)) 453 { 454 curValue -= this.stepQuantity; 455 if (curValue < this.stepQuantity) 456 { 457 boolSet = false; 458 } 459 if (boolSet) 460 { 461 if (this.isDblQuantity) 462 { 463 curValue = Math.round(curValue*this.precisionFactor)/this.precisionFactor; 464 } 465 this.obQuantity.value = curValue; 466 } 467 } 468 } 469}; 470 471window.JCCatalogSection.prototype.QuantityChange = function() 472{ 473 var curValue = 0, 474 boolSet = true; 475 476 if (0 === this.errorCode && this.showQuantity) 477 { 478 if (this.canBuy) 479 { 480 curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10)); 481 if (!isNaN(curValue)) 482 { 483 if (this.checkQuantity) 484 { 485 if (curValue > this.maxQuantity) 486 { 487 boolSet = false; 488 curValue = this.maxQuantity; 489 } 490 else if (curValue < this.stepQuantity) 491 { 492 boolSet = false; 493 curValue = this.stepQuantity; 494 } 495 } 496 if (!boolSet) 497 { 498 this.obQuantity.value = curValue; 499 } 500 } 501 else 502 { 503 this.obQuantity.value = this.stepQuantity; 504 } 505 } 506 else 507 { 508 this.obQuantity.value = this.stepQuantity; 509 } 510 } 511}; 512 513window.JCCatalogSection.prototype.QuantitySet = function(index) 514{ 515 if (0 === this.errorCode) 516 { 517 this.canBuy = this.offers[index].CAN_BUY; 518 if (this.canBuy) 519 { 520 BX.addClass(this.obBuyBtn, 'bx_bt_button'); 521 BX.removeClass(this.obBuyBtn, 'bx_bt_button_type_2'); 522 this.obBuyBtn.innerHTML = BX.message('MESS_BTN_BUY'); 523 } 524 else 525 { 526 BX.addClass(this.obBuyBtn, 'bx_bt_button_type_2'); 527 BX.removeClass(this.obBuyBtn, 'bx_bt_button'); 528 this.obBuyBtn.innerHTML = BX.message('MESS_NOT_AVAILABLE'); 529 } 530 if (this.showQuantity) 531 { 532 this.isDblQuantity = this.offers[index].QUANTITY_FLOAT; 533 this.checkQuantity = this.offers[index].CHECK_QUANTITY; 534 if (this.isDblQuantity) 535 { 536 this.maxQuantity = parseFloat(this.offers[index].MAX_QUANTITY); 537 this.stepQuantity = Math.round(parseFloat(this.offers[index].STEP_QUANTITY)*this.precisionFactor)/this.precisionFactor; 538 } 539 else 540 { 541 this.maxQuantity = parseInt(this.offers[index].MAX_QUANTITY, 10); 542 this.stepQuantity = parseInt(this.offers[index].STEP_QUANTITY, 10); 543 } 544 545 this.obQuantity.value = this.stepQuantity; 546 this.obQuantity.disabled = !this.canBuy; 547 if (!!this.obMeasure) 548 { 549 if (!!this.offers[index].MEASURE) 550 { 551 BX.adjust(this.obMeasure, { html : this.offers[index].MEASURE}); 552 } 553 else 554 { 555 BX.adjust(this.obMeasure, { html : ''}); 556 } 557 } 558 } 559 } 560}; 561 562window.JCCatalogSection.prototype.SelectOfferProp = function() 563{ 564 var i = 0, 565 value = '', 566 strTreeValue = '', 567 arTreeItem = [], 568 RowItems = null, 569 target = BX.proxy_context; 570 571 if (!!target && target.hasAttribute('data-treevalue')) 572 { 573 strTreeValue = target.getAttribute('data-treevalue'); 574 arTreeItem = strTreeValue.split('_'); 575 if (this.SearchOfferPropIndex(arTreeItem[0], arTreeItem[1])) 576 { 577 RowItems = BX.findChildren(target.parentNode, {tagName: 'li'}, false); 578 if (!!RowItems && 0 < RowItems.length) 579 { 580 for (i = 0; i < RowItems.length; i++) 581 { 582 value = RowItems[i].getAttribute('data-onevalue'); 583 if (value === arTreeItem[1]) 584 { 585 BX.addClass(RowItems[i], 'bx_active'); 586 } 587 else 588 { 589 BX.removeClass(RowItems[i], 'bx_active'); 590 } 591 } 592 } 593 } 594 } 595}; 596 597window.JCCatalogSection.prototype.SearchOfferPropIndex = function(strPropID, strPropValue) 598{ 599 var strName = '', 600 arShowValues = false, 601 i, j, 602 arCanBuyValues = [], 603 index = -1, 604 arFilter = {}, 605 tmpFilter = []; 606 607 for (i = 0; i < this.treeProps.length; i++) 608 { 609 if (this.treeProps[i].ID === strPropID) 610 { 611 index = i; 612 break; 613 } 614 } 615 616 if (-1 < index) 617 { 618 for (i = 0; i < index; i++) 619 { 620 strName = 'PROP_'+this.treeProps[i].ID; 621 arFilter[strName] = this.selectedValues[strName]; 622 } 623 strName = 'PROP_'+this.treeProps[index].ID; 624 arShowValues = this.GetRowValues(arFilter, strName); 625 if (!arShowValues) 626 { 627 return false;
628 } 629 if (!BX.util.in_array(strPropValue, arShowValues)) 630 { 631 return false; 632 } 633 arFilter[strName] = strPropValue; 634 for (i = index+1; i < this.treeProps.length; i++) 635 { 636 strName = 'PROP_'+this.treeProps[i].ID; 637 arShowValues = this.GetRowValues(arFilter, strName); 638 if (!arShowValues) 639 { 640 return false; 641 } 642 if (this.showAbsent) 643 { 644 arCanBuyValues = []; 645 tmpFilter = []; 646 tmpFilter = BX.clone(arFilter, true); 647 for (j = 0; j < arShowValues.length; j++) 648 { 649 tmpFilter[strName] = arShowValues[j]; 650 if (this.GetCanBuy(tmpFilter)) 651 { 652 arCanBuyValues[arCanBuyValues.length] = arShowValues[j]; 653 } 654 } 655 } 656 else 657 { 658 arCanBuyValues = arShowValues; 659 } 660 if (!!this.selectedValues[strName] && BX.util.in_array(this.selectedValues[strName], arCanBuyValues)) 661 { 662 arFilter[strName] = this.selectedValues[strName]; 663 } 664 else 665 { 666 arFilter[strName] = arCanBuyValues[0]; 667 } 668 this.UpdateRow(i, arFilter[strName], arShowValues, arCanBuyValues); 669 } 670 this.selectedValues = arFilter; 671 this.ChangeInfo(); 672 } 673 return true; 674}; 675 676window.JCCatalogSection.prototype.RowLeft = function() 677{ 678 var i = 0, 679 strTreeValue = '', 680 index = -1, 681 target = BX.proxy_context; 682 683 if (!!target && target.hasAttribute('data-treevalue')) 684 { 685 strTreeValue = target.getAttribute('data-treevalue'); 686 for (i = 0; i < this.treeProps.length; i++) 687 { 688 if (this.treeProps[i].ID === strTreeValue) 689 { 690 index = i; 691 break; 692 } 693 } 694 if (-1 < index && this.treeRowShowSize < this.showCount[index]) 695 { 696 if (0 > this.showStart[index]) 697 { 698 this.showStart[index]++; 699 BX.adjust(this.obTreeRows[index].LIST, { style: { marginLeft: this.showStart[index]*20+'%' }}); 700 BX.adjust(this.obTreeRows[index].RIGHT, { style: this.treeEnableArrow }); 701 } 702 703 if (0 <= this.showStart[index]) 704 { 705 BX.adjust(this.obTreeRows[index].LEFT, { style: this.treeDisableArrow }); 706 } 707 } 708 } 709}; 710 711window.JCCatalogSection.prototype.RowRight = function() 712{ 713 var i = 0, 714 strTreeValue = '', 715 index = -1, 716 target = BX.proxy_context; 717 718 if (!!target && target.hasAttribute('data-treevalue')) 719 { 720 strTreeValue = target.getAttribute('data-treevalue'); 721 for (i = 0; i < this.treeProps.length; i++) 722 { 723 if (this.treeProps[i].ID === strTreeValue) 724 { 725 index = i; 726 break; 727 } 728 } 729 if (-1 < index && this.treeRowShowSize < this.showCount[index]) 730 { 731 if ((this.treeRowShowSize - this.showStart[index]) < this.showCount[index]) 732 { 733 this.showStart[index]--; 734 BX.adjust(this.obTreeRows[index].LIST, { style: { marginLeft: this.showStart[index]*20+'%' }}); 735 BX.adjust(this.obTreeRows[index].LEFT, { style: this.treeEnableArrow }); 736 } 737 738 if ((this.treeRowShowSize - this.showStart[index]) >= this.showCount[index]) 739 { 740 BX.adjust(this.obTreeRows[index].RIGHT, { style: this.treeDisableArrow }); 741 } 742 } 743 } 744}; 745 746window.JCCatalogSection.prototype.UpdateRow = function(intNumber, activeID, showID, canBuyID) 747{ 748 var i = 0, 749 value = '', 750 countShow = 0, 751 strNewLen = '', 752 obData = {}, 753 pictMode = false, 754 extShowMode = false, 755 isCurrent = false, 756 selectIndex = 0, 757 obLeft = this.treeEnableArrow, 758 obRight = this.treeEnableArrow, 759 currentShowStart = 0, 760 RowItems = null; 761 762 if (-1 < intNumber && intNumber < this.obTreeRows.length) 763 { 764 RowItems = BX.findChildren(this.obTreeRows[intNumber].LIST, {tagName: 'li'}, false); 765 if (!!RowItems && 0 < RowItems.length) 766 { 767 pictMode = ('PICT' === this.treeProps[intNumber].SHOW_MODE); 768 countShow = showID.length; 769 extShowMode = this.treeRowShowSize < countShow; 770 strNewLen = (extShowMode ? (100/countShow)+'%' : '20%'); 771 obData = { 772 props: { className: '' }, 773 style: { 774 width: strNewLen 775 } 776 }; 777 if (pictMode) 778 { 779 obData.style.paddingTop = strNewLen; 780 } 781 for (i = 0; i < RowItems.length; i++) 782 { 783 value = RowItems[i].getAttribute('data-onevalue'); 784 isCurrent = (value === activeID); 785 if (BX.util.in_array(value, canBuyID)) 786 { 787 obData.props.className = (isCurrent ? 'bx_active' : ''); 788 } 789 else 790 { 791 obData.props.className = (isCurrent ? 'bx_active bx_missing' : 'bx_missing'); 792 } 793 obData.style.display = 'none'; 794 if (BX.util.in_array(value, showID)) 795 { 796 obData.style.display = ''; 797 if (isCurrent) 798 { 799 selectIndex = i; 800 } 801 } 802 BX.adjust(RowItems[i], obData); 803 } 804 805 obData = { 806 style: { 807 width: (extShowMode ? 20*countShow : 100)+'%', 808 marginLeft: '0%' 809 } 810 }; 811 if (pictMode) 812 { 813 BX.adjust(this.obTreeRows[intNumber].CONT, {props: {className: (extShowMode ? 'bx_item_detail_scu full' : 'bx_item_detail_scu')}}); 814 } 815 else 816 {
817 BX.adjust(this.obTreeRows[intNumber].CONT, {props: {className: (extShowMode ? 'bx_item_detail_size full' : 'bx_item_detail_size')}}); 818 } 819 if (extShowMode) 820 { 821 if (selectIndex +1 === countShow) 822 { 823 obRight = this.treeDisableArrow; 824 } 825 if (this.treeRowShowSize <= selectIndex) 826 { 827 currentShowStart = this.treeRowShowSize - selectIndex - 1; 828 obData.style.marginLeft = currentShowStart*20+'%'; 829 } 830 if (0 === currentShowStart) 831 { 832 obLeft = this.treeDisableArrow; 833 } 834 BX.adjust(this.obTreeRows[intNumber].LEFT, {style: obLeft }); 835 BX.adjust(this.obTreeRows[intNumber].RIGHT, {style: obRight }); 836 } 837 else 838 { 839 BX.adjust(this.obTreeRows[intNumber].LEFT, {style: {display: 'none'}}); 840 BX.adjust(this.obTreeRows[intNumber].RIGHT, {style: {display: 'none'}}); 841 } 842 BX.adjust(this.obTreeRows[intNumber].LIST, obData); 843 this.showCount[intNumber] = countShow; 844 this.showStart[intNumber] = currentShowStart; 845 } 846 } 847}; 848 849window.JCCatalogSection.prototype.GetRowValues = function(arFilter, index) 850{ 851 var i = 0, 852 j, 853 arValues = [], 854 boolSearch = false, 855 boolOneSearch = true; 856 857 if (0 === arFilter.length) 858 { 859 for (i = 0; i < this.offers.length; i++) 860 { 861 if (!BX.util.in_array(this.offers[i].TREE[index], arValues)) 862 { 863 arValues[arValues.length] = this.offers[i].TREE[index]; 864 } 865 } 866 boolSearch = true; 867 } 868 else 869 { 870 for (i = 0; i < this.offers.length; i++) 871 { 872 boolOneSearch = true; 873 for (j in arFilter) 874 { 875 if (arFilter[j] !== this.offers[i].TREE[j]) 876 { 877 boolOneSearch = false; 878 break; 879 } 880 } 881 if (boolOneSearch) 882 { 883 if (!BX.util.in_array(this.offers[i].TREE[index], arValues)) 884 { 885 arValues[arValues.length] = this.offers[i].TREE[index]; 886 } 887 boolSearch = true; 888 } 889 } 890 } 891 return (boolSearch ? arValues : false); 892}; 893 894window.JCCatalogSection.prototype.GetCanBuy = function(arFilter) 895{ 896 var i = 0, 897 j, 898 boolSearch = false, 899 boolOneSearch = true; 900 901 for (i = 0; i < this.offers.length; i++) 902 { 903 boolOneSearch = true; 904 for (j in arFilter) 905 { 906 if (arFilter[j] !== this.offers[i].TREE[j]) 907 { 908 boolOneSearch = false; 909 break; 910 } 911 } 912 if (boolOneSearch) 913 { 914 if (this.offers[i].CAN_BUY) 915 { 916 boolSearch = true; 917 break; 918 } 919 } 920 } 921 return boolSearch; 922}; 923 924window.JCCatalogSection.prototype.SetCurrent = function() 925{ 926 var i = 0, 927 j = 0, 928 arCanBuyValues = [], 929 strName = '', 930 arShowValues = false, 931 arFilter = {}, 932 tmpFilter = [], 933 current = this.offers[this.offerNum].TREE; 934 935 for (i = 0; i < this.treeProps.length; i++) 936 { 937 strName = 'PROP_'+this.treeProps[i].ID; 938 arShowValues = this.GetRowValues(arFilter, strName); 939 if (!arShowValues) 940 { 941 break; 942 } 943 if (BX.util.in_array(current[strName], arShowValues)) 944 { 945 arFilter[strName] = current[strName]; 946 } 947 else 948 { 949 arFilter[strName] = arShowValues[0]; 950 this.offerNum = 0; 951 } 952 if (this.showAbsent) 953 { 954 arCanBuyValues = []; 955 tmpFilter = []; 956 tmpFilter = BX.clone(arFilter, true); 957 for (j = 0; j < arShowValues.length; j++) 958 { 959 tmpFilter[strName] = arShowValues[j]; 960 if (this.GetCanBuy(tmpFilter)) 961 { 962 arCanBuyValues[arCanBuyValues.length] = arShowValues[j]; 963 } 964 } 965 } 966 else 967 { 968 arCanBuyValues = arShowValues; 969 } 970 this.UpdateRow(i, arFilter[strName], arShowValues, arCanBuyValues); 971 } 972 this.selectedValues = arFilter; 973 this.ChangeInfo(); 974}; 975 976window.JCCatalogSection.prototype.ChangeInfo = function() 977{ 978 var i = 0, 979 j, 980 index = -1, 981 obData = {}, 982 boolOneSearch = true, 983 strPrice = ''; 984 985 for (i = 0; i < this.offers.length; i++) 986 { 987 boolOneSearch = true; 988 for (j in this.selectedValues) 989 { 990 if (this.selectedValues[j] !== this.offers[i].TREE[j]) 991 { 992 boolOneSearch = false; 993 break; 994 } 995 } 996 if (boolOneSearch) 997 { 998 index = i; 999 break; 1000 } 1001 } 1002 if (-1 < index) 1003 { 1004 if (!!this.obPict) 1005 { 1006 if (!!this.offers[index].PREVIEW_PICTURE) 1007 { 1008 BX.adjust(this.obPict, {style: {backgroundImage: 'url('+this.offers[index].PREVIEW_PICTURE.SRC+')'}}); 1009 } 1010 else 1011 { 1012 BX.adjust(this.obPict, {style: {backgroundImage: 'url('+this.defaultPict.pict.SRC+')'}}); 1013 } 1014 } 1015 if (this.secondPict && !!this.obSecondPict) 1016 { 1017 if (!!this.offers[index].PREVIEW_PICTURE_SECOND) 1018 { 1019 BX.adjust(this.obSecondPict, {style: {backgroundImage: 'url('+this.offers[index].PREVIEW_PICTURE_SECOND.SRC+')'}}); 1020 } 1021 else if (!!this.offers[index].PREVIEW_PICTURE.SRC) 1022 { 1023 BX.adjust(this.obSecondPict, {style: {backgroundImage: 'url('+this.offers[index].PREVIEW_PICTURE.SRC+')'}}); 1024 } 1025 else if (!!this.defaultPict.secondPict) 1026 { 1027 BX.adjust(this.obSecondPict, {style: {backgroundImage: 'url('+this.defaultPict.secondPict.SRC+')'}}); 1028 } 1029 else 1030 {
1031 BX.adjust(this.obSecondPict, {style: {backgroundImage: 'url('+this.defaultPict.pict.SRC+')'}}); 1032 } 1033 } 1034 if (this.showSkuProps && !!this.obSkuProps) 1035 { 1036 if (0 === this.offers[index].DISPLAY_PROPERTIES.length) 1037 { 1038 BX.adjust(this.obSkuProps, {style: {display: 'none'}, html: ''}); 1039 } 1040 else 1041 { 1042 BX.adjust(this.obSkuProps, {style: {display: ''}, html: this.offers[index].DISPLAY_PROPERTIES}); 1043 } 1044 } 1045 if (!!this.obPrice) 1046 { 1047 strPrice = this.offers[index].PRICE.PRINT_DISCOUNT_VALUE; 1048 if (this.showOldPrice && (this.offers[index].PRICE.DISCOUNT_VALUE !== this.offers[index].PRICE.VALUE)) 1049 { 1050 strPrice += ' <span>'+this.offers[index].PRICE.PRINT_VALUE+'</span>'; 1051 } 1052 BX.adjust(this.obPrice, {html: strPrice}); 1053 if (this.showPercent) 1054 { 1055 if (this.offers[index].PRICE.DISCOUNT_VALUE !== this.offers[index].PRICE.VALUE) 1056 { 1057 obData = { 1058 style: { 1059 display: '' 1060 }, 1061 html: this.offers[index].PRICE.DISCOUNT_DIFF_PERCENT 1062 }; 1063 } 1064 else 1065 { 1066 obData = { 1067 style: { 1068 display: 'none' 1069 }, 1070 html: '' 1071 }; 1072 } 1073 if (!!this.obDscPerc) 1074 { 1075 BX.adjust(this.obDscPerc, obData); 1076 } 1077 if (!!this.obSecondDscPerc) 1078 { 1079 BX.adjust(this.obSecondDscPerc, obData); 1080 } 1081 } 1082 } 1083 this.offerNum = index; 1084 this.QuantitySet(this.offerNum); 1085 } 1086}; 1087 1088window.JCCatalogSection.prototype.InitBasketUrl = function() 1089{ 1090 switch (this.productType) 1091 { 1092 case 1://product 1093 case 2://set 1094 this.basketUrl = this.product.addUrl; 1095 break; 1096 case 3://sku 1097 this.basketUrl = this.offers[this.offerNum].ADD_URL; 1098 break; 1099 } 1100 this.basketParams = { 1101 'ajax_basket': 'Y' 1102 }; 1103 if (this.showQuantity) 1104 { 1105 this.basketParams[this.basketData.quantity] = this.obQuantity.value; 1106 } 1107}; 1108 1109window.JCCatalogSection.prototype.FillBasketProps = function() 1110{ 1111 if (!this.visual.BASKET_PROP_DIV) 1112 { 1113 return; 1114 } 1115 var 1116 i = 0, 1117 propCollection = null, 1118 foundValues = false, 1119 obBasketProps = null; 1120 1121 if (this.basketData.useProps && !this.basketData.emptyProps) 1122 { 1123 if (!!this.obPopupWin && !!this.obPopupWin.contentContainer) 1124 { 1125 obBasketProps = this.obPopupWin.contentContainer; 1126 } 1127 } 1128 else 1129 { 1130 obBasketProps = BX(this.visual.BASKET_PROP_DIV); 1131 } 1132 if (!obBasketProps) 1133 { 1134 return; 1135 } 1136 propCollection = obBasketProps.getElementsByTagName('select'); 1137 if (!!propCollection && !!propCollection.length) 1138 { 1139 for (i = 0; i < propCollection.length; i++) 1140 { 1141 if (!propCollection[i].disabled) 1142 { 1143 switch(propCollection[i].type.toLowerCase()) 1144 { 1145 case 'select-one': 1146 this.basketParams[propCollection[i].name] = propCollection[i].value; 1147 foundValues = true; 1148 break; 1149 default: 1150 break; 1151 } 1152 } 1153 } 1154 } 1155 propCollection = obBasketProps.getElementsByTagName('input'); 1156 if (!!propCollection && !!propCollection.length) 1157 { 1158 for (i = 0; i < propCollection.length; i++) 1159 { 1160 if (!propCollection[i].disabled) 1161 { 1162 switch(propCollection[i].type.toLowerCase()) 1163 { 1164 case 'hidden': 1165 this.basketParams[propCollection[i].name] = propCollection[i].value; 1166 foundValues = true; 1167 break; 1168 case 'radio': 1169 if (propCollection[i].checked) 1170 { 1171 this.basketParams[propCollection[i].name] = propCollection[i].value; 1172 foundValues = true; 1173 } 1174 break; 1175 default: 1176 break; 1177 } 1178 } 1179 } 1180 } 1181 if (!foundValues) 1182 { 1183 this.basketParams[this.basketData.props] = []; 1184 this.basketParams[this.basketData.props][0] = 0; 1185 } 1186}; 1187 1188window.JCCatalogSection.prototype.SendToBasket = function() 1189{ 1190 if (!this.canBuy) 1191 { 1192 return; 1193 } 1194 this.InitBasketUrl(); 1195 this.FillBasketProps(); 1196 BX.ajax.loadJSON( 1197 this.basketUrl, 1198 this.basketParams, 1199 BX.delegate(this.BasketResult, this) 1200 ); 1201}; 1202 1203window.JCCatalogSection.prototype.Basket = function() 1204{ 1205 var contentBasketProps = ''; 1206 if (!this.canBuy) 1207 { 1208 return; 1209 } 1210 switch (this.productType) 1211 { 1212 case 1://product 1213 case 2://set 1214 if (this.basketData.useProps && !this.basketData.emptyProps) 1215 { 1216 this.InitPopupWindow(); 1217 this.obPopupWin.setTitleBar({ 1218 content: BX.create('div', { 1219 style: { marginRight: '30px', whiteSpace: 'nowrap' }, 1220 text: BX.message('TITLE_BASKET_PROPS') 1221 }) 1222 }); 1223 if (BX(this.visual.BASKET_PROP_DIV)) 1224 { 1225 contentBasketProps = BX(this.visual.BASKET_PROP_DIV).innerHTML; 1226 } 1227 this.obPopupWin.setContent(contentBasketProps); 1228 this.obPopupWin.setButtons([ 1229 new BasketButton({ 1230 ownerClass: this.obProduct.parentNode.parentNode.className, 1231 text: BX.message('BTN_MESSAGE_SEND_PROPS'), 1232 events: { 1233 click: BX.delegate(this.SendToBasket, this) 1234 } 1235 }) 1236 ]); 1237 this.obPopupWin.show(); 1238 } 1239 else 1240 { 1241 this.SendToBasket(); 1242 } 1243 break; 1244 case 3://sku 1245 this.SendToBasket(); 1246 break; 1247 } 1248}; 1249 1250window.JCCatalogSection.prototype.BasketResult = function(arResult) 1251{ 1252 var strContent = '', 1253 strName = '', 1254 strPict = '', 1255 successful = true, 1256 buttons = []; 1257 1258 if (!!this.obPopupWin) 1259 { 1260 this.obPopupWin.close(); 1261 } 1262 if ('object' !== typeof arResult) 1263 { 1264 return false;
1265 } 1266 successful = ('OK' === arResult.STATUS); 1267 if (successful) 1268 { 1269 BX.onCustomEvent('OnBasketChange'); 1270 strName = this.product.name; 1271 switch(this.productType) 1272 { 1273 case 1:// 1274 case 2:// 1275 strPict = this.product.pict.SRC; 1276 break; 1277 case 3: 1278 strPict = (!!this.offers[this.offerNum].PREVIEW_PICTURE ? 1279 this.offers[this.offerNum].PREVIEW_PICTURE.SRC : 1280 this.defaultPict.pict.SRC 1281 ); 1282 break; 1283 } 1284 strContent = '<div style="width: 96%; margin: 10px 2%; text-align: center;"><img src="'+strPict+'" height="130"><p>'+strName+'</p></div>'; 1285 buttons = [ 1286 new BasketButton({ 1287 ownerClass: this.obProduct.parentNode.parentNode.className, 1288 text: BX.message("BTN_MESSAGE_BASKET_REDIRECT"), 1289 events: { 1290 click: BX.delegate(function(){ 1291 location.href = (!!this.basketData.basketUrl ? this.basketData.basketUrl : BX.message('BASKET_URL')); 1292 }, this) 1293 } 1294 }) 1295 ]; 1296 } 1297 else 1298 { 1299 strContent = (!!arResult.MESSAGE ? arResult.MESSAGE : BX.message('BASKET_UNKNOWN_ERROR')); 1300 buttons = [ 1301 new BasketButton({ 1302 ownerClass: this.obProduct.parentNode.parentNode.className, 1303 text: BX.message('BTN_MESSAGE_CLOSE'), 1304 events: { 1305 click: BX.delegate(this.obPopupWin.close, this.obPopupWin) 1306 } 1307 }) 1308 ]; 1309 } 1310 this.InitPopupWindow(); 1311 this.obPopupWin.setTitleBar({ 1312 content: BX.create('div', { 1313 style: { marginRight: '30px', whiteSpace: 'nowrap' }, 1314 text: (successful ? BX.message('TITLE_SUCCESSFUL') : BX.message('TITLE_ERROR')) 1315 }) 1316 }); 1317 this.obPopupWin.setContent(strContent); 1318 this.obPopupWin.setButtons(buttons); 1319 this.obPopupWin.show(); 1320}; 1321 1322window.JCCatalogSection.prototype.InitPopupWindow = function() 1323{ 1324 if (!!this.obPopupWin) 1325 { 1326 return; 1327 } 1328 this.obPopupWin = BX.PopupWindowManager.create('CatalogSectionBasket_'+this.visual.ID, null, { 1329 autoHide: false, 1330 offsetLeft: 0, 1331 offsetTop: 0, 1332 overlay : true, 1333 closeByEsc: true, 1334 titleBar: true, 1335 closeIcon: {top: '10px', right: '10px'} 1336 }); 1337}; 1338})(window); 1339 1340$(document).ready(function(){ 1341 $('.products-slider').bxSlider({ 1342 slideWidth: 148, 1343 minSlides:1, 1344 maxSlides: 5, 1345 moveSlides: 1, 1346 slideMargin: 3, 1347 pager:false, 1348 infiniteLoop:false, 1349 }); 1350});
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.