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