1 2sliceItemBlock = function(){ 3 $('.catalog_block .catalog_item_wrapp .catalog_item .item_info:visible .item-title').sliceHeight({mobile: true}); 4 $('.catalog_block .catalog_item_wrapp .catalog_item .item_info:visible .cost').sliceHeight({mobile: true}); 5 $('.catalog_block .catalog_item_wrapp .item_info:visible').sliceHeight({mobile: true}); 6 if(isMobile) 7 $('.catalog_block .catalog_item_wrapp:visible .footer_button .sku_props').sliceHeight({mobile: true}); 8 $('.catalog_block .catalog_item_wrapp:visible').sliceHeight({classNull: '.footer_button', mobile: true}); 9} 10 11BX.addCustomEvent(window, "onAjaxSuccess", function(eventdata){ 12 if(typeof eventdata !== 'undefined' && typeof eventdata !== 'string' && eventdata !== null) 13 { 14 if('action' in eventdata && eventdata.action == 'ajaxContentLoadedTab') 15 { 16 setTimeout(function(){ 17 $('.catalog_block .catalog_item_wrapp .catalog_item .item-title').sliceHeight({resize: false, mobile: true}); 18 $('.catalog_block .catalog_item_wrapp .catalog_item .cost').sliceHeight({resize: false, mobile: true}); 19 $('.catalog_block .catalog_item_wrapp .item_info').sliceHeight({resize: false, mobile: true}); 20 $('.catalog_block .catalog_item_wrapp').sliceHeight({classNull: '.footer_button', resize: false, mobile: true}); 21 }, 100); 22 } 23 } 24}); 25 26(function (window) { 27if (!window.JCCatalogSectionOnlyElement) 28{ 29 30 window.JCCatalogSectionOnlyElement = function (arParams) 31 { 32 if (typeof arParams === 'object') 33 { 34 this.params = arParams; 35 36 this.obProduct = null; 37 this.set_quantity = 1; 38 39 this.currentPriceMode = ''; 40 this.currentPrices = []; 41 this.currentPriceSelected = 0; 42 this.currentQuantityRanges = []; 43 this.currentQuantityRangeSelected = 0; 44 45 if (this.params.MESS) 46 { 47 this.mess = this.params.MESS; 48 } 49 50 this.init(); 51 } 52 } 53 window.JCCatalogSectionOnlyElement.prototype = { 54 init: function() 55 { 56 var i = 0, 57 j = 0, 58 treeItems = null; 59 60 this.obProduct = BX(this.params.ID); 61 62 if(!!this.obProduct) 63 { 64 $(this.obProduct).find('.counter_wrapp .counter_block input').data('product', 'ob'+this.obProduct.id+'el'); 65 this.currentPriceMode = this.params.ITEM_PRICE_MODE; 66 this.currentPrices = this.params.ITEM_PRICES; 67 this.currentQuantityRanges = this.params.ITEM_QUANTITY_RANGES; 68 } 69 70 }, 71 72 setPriceAction: function() 73 { 74 this.set_quantity = this.params.MIN_QUANTITY_BUY; 75 if($(this.obProduct).find('input[name=quantity]').length) 76 this.set_quantity = $(this.obProduct).find('input[name=quantity]').val(); 77 78 this.checkPriceRange(this.set_quantity); 79 80 $(this.obProduct).find('.not_matrix').hide(); 81 $(this.obProduct).find('.with_matrix .price_value_block').html(getCurrentPrice(this.currentPrices[this.currentPriceSelected].PRICE, this.currentPrices[this.currentPriceSelected].CURRENCY, this.currentPrices[this.currentPriceSelected].PRINT_PRICE)); 82 83 if($(this.obProduct).find('.with_matrix .discount')) 84 { 85 $(this.obProduct).find('.with_matrix .discount').html(getCurrentPrice(this.currentPrices[this.currentPriceSelected].BASE_PRICE, this.currentPrices[this.currentPriceSelected].CURRENCY, this.currentPrices[this.currentPriceSelected].PRINT_BASE_PRICE)); 86 } 87 88 if(this.params.SHOW_DISCOUNT_PERCENT_NUMBER == 'Y') 89 { 90 if(this.currentPrices[this.currentPriceSelected].PERCENT > 0 && this.currentPrices[this.currentPriceSelected].PERCENT < 100) 91 { 92 if(!$(this.obProduct).find('.with_matrix .sale_block .sale_wrapper .value').length) 93 $('<div class="value"></div>').insertBefore($(this.obProduct).find('.with_matrix .sale_block .sale_wrapper .text')); 94 95 $(this.obProduct).find('.with_matrix .sale_block .sale_wrapper .value').html('-<span>'+this.currentPrices[this.currentPriceSelected].PERCENT+'</span>%'); 96 } 97 else 98 { 99 if($(this.obProduct).find('.with_matrix .sale_block .sale_wrapper .value').length) 100 $(this.obProduct).find('.with_matrix .sale_block .sale_wrapper .value').remove(); 101 } 102 } 103 $(this.obProduct).find('.with_matrix .sale_block .text .values_wrapper').html(getCurrentPrice(this.currentPrices[this.currentPriceSelected].DISCOUNT, this.currentPrices[this.currentPriceSelected].CURRENCY, this.currentPrices[this.currentPriceSelected].PRINT_DISCOUNT)); 104 105 $(this.obProduct).find('.with_matrix').show(); 106 107 if(arTires2Options['THEME']['SHOW_TOTAL_SUMM'] == 'Y') 108 { 109 if(typeof this.currentPrices[this.currentPriceSelected] !== 'undefined') 110 setPriceItem($(this.obProduct), this.set_quantity, this.currentPrices[this.currentPriceSelected].PRICE); 111 } 112 }, 113 114 checkPriceRange: function(quantity) 115 { 116 if (typeof quantity === 'undefined'|| this.currentPriceMode != 'Q') 117 return; 118 119 var range, found = false;
120 121 for (var i in this.currentQuantityRanges) 122 { 123 if (this.currentQuantityRanges.hasOwnProperty(i)) 124 { 125 range = this.currentQuantityRanges[i]; 126 127 if ( 128 parseInt(quantity) >= parseInt(range.SORT_FROM) 129 && ( 130 range.SORT_TO == 'INF' 131 || parseInt(quantity) <= parseInt(range.SORT_TO) 132 ) 133 ) 134 { 135 found = true; 136 this.currentQuantityRangeSelected = range.HASH; 137 break; 138 } 139 } 140 } 141 142 if (!found && (range = this.getMinPriceRange())) 143 { 144 this.currentQuantityRangeSelected = range.HASH; 145 } 146 147 for (var k in this.currentPrices) 148 { 149 if (this.currentPrices.hasOwnProperty(k)) 150 { 151 if (this.currentPrices[k].QUANTITY_HASH == this.currentQuantityRangeSelected) 152 { 153 this.currentPriceSelected = k; 154 break; 155 } 156 } 157 } 158 }, 159 160 getMinPriceRange: function() 161 { 162 var range; 163 164 for (var i in this.currentQuantityRanges) 165 { 166 if (this.currentQuantityRanges.hasOwnProperty(i)) 167 { 168 if ( 169 !range 170 || parseInt(this.currentQuantityRanges[i].SORT_FROM) < parseInt(range.SORT_FROM) 171 ) 172 { 173 range = this.currentQuantityRanges[i]; 174 } 175 } 176 } 177 178 return range; 179 } 180 } 181} 182 183 184if (!!window.JCCatalogSection) 185{ 186 return; 187} 188 189window.JCCatalogSection = function (arParams) 190{ 191 this.skuVisualParams = { 192 SELECT: 193 { 194 TAG_BIND: 'select', 195 TAG: 'option', 196 ACTIVE_CLASS: 'active', 197 HIDE_CLASS: 'hidden', 198 EVENT: 'change', 199 }, 200 LI: 201 { 202 TAG_BIND: 'li', 203 TAG: 'li', 204 ACTIVE_CLASS: 'active', 205 HIDE_CLASS: 'missing', 206 EVENT: 'click', 207 } 208 }; 209 this.productType = 0; 210 this.showQuantity = true; 211 this.showAbsent = true; 212 this.secondPict = false; 213 this.showOldPrice = false; 214 this.showPercent = false; 215 this.showSkuProps = false; 216 this.basketAction = 'ADD'; 217 this.basketLinkURL = ''; 218 this.showClosePopup = false; 219 this.useCompare = false; 220 this.showPercentNumber = false; 221 this.visual = { 222 ID: '', 223 PICT_ID: '', 224 SECOND_PICT_ID: '', 225 QUANTITY_ID: '', 226 QUANTITY_UP_ID: '', 227 QUANTITY_DOWN_ID: '', 228 STORE_QUANTITY: '', 229 PRICE_ID: '', 230 PRICE_OLD_ID: '', 231 DSC_PERC: '', 232 SECOND_DSC_PERC: '', 233 DISPLAY_PROP_DIV: '', 234 BASKET_PROP_DIV: '' 235 }; 236 this.product = { 237 checkQuantity: false, 238 maxQuantity: 0, 239 stepQuantity: 1, 240 isDblQuantity: false, 241 canBuy: true, 242 canSubscription: true, 243 name: '', 244 pict: {}, 245 id: 0, 246 addUrl: '', 247 buyUrl: '' 248 }; 249 250 this.basketMode = ''; 251 this.basketData = { 252 useProps: false, 253 emptyProps: false, 254 quantity: 'quantity', 255 props: 'prop', 256 basketUrl: '', 257 sku_props: '', 258 sku_props_var: 'basket_props', 259 add_url: '', 260 buy_url: '' 261 }; 262 263 this.compareData = { 264 compareUrl: '', 265 comparePath: '' 266 }; 267 268 this.defaultPict = { 269 pict: null, 270 secondPict: null 271 }; 272 273 this.checkQuantity = false; 274 this.maxQuantity = 0; 275 this.stepQuantity = 1; 276 this.defaultCount = 1; 277 this.isDblQuantity = false; 278 this.canBuy = true; 279 this.currentBasisPrice = {}; 280 this.canSubscription = true; 281 this.precision = 6; 282 this.precisionFactor = Math.pow(10,this.precision); 283 284 this.currentPriceMode = ''; 285 this.currentPrices = []; 286 this.currentPriceSelected = 0; 287 this.currentQuantityRanges = []; 288 this.currentQuantityRangeSelected = 0; 289 290 this.offers = []; 291 this.offerNum = 0; 292 this.treeProps = []; 293 this.obTreeRows = []; 294 this.showCount = []; 295 this.showStart = []; 296 this.selectedValues = {}; 297 298 this.obProduct = null; 299 this.obQuantity = null; 300 this.obQuantityUp = null; 301 this.obQuantityDown = null; 302 this.obPict = null; 303 this.obSecondPict = null; 304 this.obPrice = null; 305 this.obTree = null; 306 this.obBuyBtn = null; 307 this.obBasketBtn = null; 308 this.obBasketActions = null; 309 this.obNotAvail = null; 310 this.obDscPerc = null; 311 this.obSecondDscPerc = null; 312 this.obSkuProps = null; 313 this.obMeasure = null; 314 this.obCompare = null; 315 316 this.obPopupWin = null; 317 this.basketUrl = ''; 318 this.basketParams = {}; 319 320 this.treeRowShowSize = 5; 321 this.treeEnableArrow = { display: '', cursor: 'pointer', opacity: 1 }; 322 this.treeDisableArrow = { display: '', cursor: 'default', opacity:0.2 }; 323 324 this.lastElement = false; 325 this.containerHeight = 0; 326 327 this.errorCode = 0; 328 329 if ('object' === typeof arParams) 330 { 331 this.productType = parseInt(arParams.PRODUCT_TYPE, 10);
332 this.showQuantity = arParams.SHOW_QUANTITY; 333 this.showAbsent = arParams.SHOW_ABSENT; 334 this.secondPict = !!arParams.SECOND_PICT; 335 this.showOldPrice = !!arParams.SHOW_OLD_PRICE; 336 this.showPercent = !!arParams.SHOW_DISCOUNT_PERCENT; 337 this.showPercentNumber = (arParams.SHOW_DISCOUNT_PERCENT_NUMBER == "Y"); 338 this.showSkuProps = !!arParams.SHOW_SKU_PROPS; 339 if (!!arParams.ADD_TO_BASKET_ACTION) 340 { 341 this.basketAction = arParams.ADD_TO_BASKET_ACTION; 342 } 343 this.showClosePopup = !!arParams.SHOW_CLOSE_POPUP; 344 this.useCompare = !!arParams.DISPLAY_COMPARE; 345 346 this.visual = arParams.VISUAL; 347 this.defaultCount = arParams.DEFAULT_COUNT; 348 this.basketLinkURL = arParams.BASKET_URL; 349 switch (this.productType) 350 { 351 case 1://product 352 case 2://set 353 if (!!arParams.PRODUCT && 'object' === typeof(arParams.PRODUCT)) 354 { 355 if (this.showQuantity) 356 { 357 this.product.checkQuantity = arParams.PRODUCT.CHECK_QUANTITY; 358 this.product.isDblQuantity = arParams.PRODUCT.QUANTITY_FLOAT; 359 if (this.product.checkQuantity) 360 { 361 this.product.maxQuantity = (this.product.isDblQuantity ? parseFloat(arParams.PRODUCT.MAX_QUANTITY) : parseInt(arParams.PRODUCT.MAX_QUANTITY, 10)); 362 } 363 this.product.stepQuantity = (this.product.isDblQuantity ? parseFloat(arParams.PRODUCT.STEP_QUANTITY) : parseInt(arParams.PRODUCT.STEP_QUANTITY, 10)); 364 365 this.checkQuantity = this.product.checkQuantity; 366 this.isDblQuantity = this.product.isDblQuantity; 367 this.maxQuantity = this.product.maxQuantity; 368 this.stepQuantity = this.product.stepQuantity; 369 if (this.isDblQuantity) 370 { 371 this.stepQuantity = Math.round(this.stepQuantity*this.precisionFactor)/this.precisionFactor; 372 } 373 } 374 this.product.canBuy = arParams.PRODUCT.CAN_BUY; 375 this.product.canSubscription = arParams.PRODUCT.SUBSCRIPTION; 376 if (!!arParams.PRODUCT.BASIS_PRICE) 377 { 378 this.currentBasisPrice = arParams.PRODUCT.BASIS_PRICE; 379 } 380 381 this.canBuy = this.product.canBuy; 382 this.canSubscription = this.product.canSubscription; 383 384 this.product.name = arParams.PRODUCT.NAME; 385 this.product.pict = arParams.PRODUCT.PICT; 386 this.product.id = arParams.PRODUCT.ID; 387 if (!!arParams.PRODUCT.ADD_URL) 388 { 389 this.product.addUrl = arParams.PRODUCT.ADD_URL; 390 } 391 if (!!arParams.PRODUCT.BUY_URL) 392 { 393 this.product.buyUrl = arParams.PRODUCT.BUY_URL; 394 } 395 if (!!arParams.BASKET && 'object' === typeof(arParams.BASKET)) 396 { 397 this.basketData.useProps = !!arParams.BASKET.ADD_PROPS; 398 this.basketData.emptyProps = !!arParams.BASKET.EMPTY_PROPS; 399 } 400 } 401 else 402 { 403 this.errorCode = -1; 404 } 405 break; 406 case 3://sku 407 if (!!arParams.OFFERS && BX.type.isArray(arParams.OFFERS)) 408 { 409 if (!!arParams.PRODUCT && 'object' === typeof(arParams.PRODUCT)) 410 { 411 this.product.name = arParams.PRODUCT.NAME; 412 this.product.id = arParams.PRODUCT.ID; 413 } 414 this.offers = arParams.OFFERS; 415 this.offerNum = 0; 416 if (!!arParams.OFFER_SELECTED) 417 { 418 this.offerNum = parseInt(arParams.OFFER_SELECTED, 10); 419 } 420 if (isNaN(this.offerNum)) 421 { 422 this.offerNum = 0; 423 } 424 if (!!arParams.TREE_PROPS) 425 { 426 this.treeProps = arParams.TREE_PROPS; 427 } 428 if (!!arParams.DEFAULT_PICTURE) 429 { 430 this.defaultPict.pict = arParams.DEFAULT_PICTURE.PICTURE; 431 this.defaultPict.secondPict = arParams.DEFAULT_PICTURE.PICTURE_SECOND; 432 } 433 } 434 else 435 { 436 this.errorCode = -1; 437 } 438 break; 439 default: 440 this.errorCode = -1; 441 } 442 if (!!arParams.BASKET && 'object' === typeof(arParams.BASKET)) 443 { 444 if (!!arParams.BASKET.QUANTITY) 445 { 446 this.basketData.quantity = arParams.BASKET.QUANTITY; 447 } 448 if (!!arParams.BASKET.PROPS) 449 { 450 this.basketData.props = arParams.BASKET.PROPS; 451 } 452 if (!!arParams.BASKET.BASKET_URL) 453 { 454 this.basketData.basketUrl = arParams.BASKET.BASKET_URL; 455 } 456 if (3 === this.productType) 457 { 458 if (!!arParams.BASKET.SKU_PROPS) 459 { 460 this.basketData.sku_props = arParams.BASKET.SKU_PROPS; 461 } 462 } 463 if (!!arParams.BASKET.ADD_URL_TEMPLATE) 464 {
465 this.basketData.add_url = arParams.BASKET.ADD_URL_TEMPLATE; 466 } 467 if (!!arParams.BASKET.BUY_URL_TEMPLATE) 468 { 469 this.basketData.buy_url = arParams.BASKET.BUY_URL_TEMPLATE; 470 } 471 if (this.basketData.add_url === '' && this.basketData.buy_url === '') 472 { 473 this.errorCode = -1024; 474 } 475 } 476 if (this.useCompare) 477 { 478 if (!!arParams.COMPARE && typeof(arParams.COMPARE) === 'object') 479 { 480 if (!!arParams.COMPARE.COMPARE_PATH) 481 { 482 this.compareData.comparePath = arParams.COMPARE.COMPARE_PATH; 483 } 484 if (!!arParams.COMPARE.COMPARE_URL_TEMPLATE_DEL) 485 { 486 this.compareData.compareUrlDel = arParams.COMPARE.COMPARE_URL_TEMPLATE_DEL; 487 } 488 if (!!arParams.COMPARE.COMPARE_URL_TEMPLATE) 489 { 490 this.compareData.compareUrl = arParams.COMPARE.COMPARE_URL_TEMPLATE; 491 } 492 else 493 { 494 this.useCompare = false; 495 } 496 } 497 else 498 { 499 this.useCompare = false; 500 } 501 } 502 503 this.lastElement = (!!arParams.LAST_ELEMENT && 'Y' === arParams.LAST_ELEMENT); 504 } 505 if (0 === this.errorCode) 506 { 507 BX.ready(BX.delegate(this.Init,this)); 508 } 509}; 510 511window.JCCatalogSection.prototype.Init = function() 512{ 513 var i = 0, 514 strPrefix = '', 515 TreeItems = null; 516 517 this.obProduct = BX(this.visual.ID); 518 if (!this.obProduct) 519 { 520 this.errorCode = -1; 521 } 522 this.obPict = BX(this.visual.PICT_ID); 523 if (!this.obPict) 524 { 525 this.errorCode = -2; 526 } 527 if (this.secondPict && !!this.visual.SECOND_PICT_ID) 528 { 529 this.obSecondPict = BX(this.visual.SECOND_PICT_ID); 530 } 531 this.storeQuanity = BX(this.visual.STORE_QUANTITY); 532 this.obPrice = BX(this.visual.PRICE_ID); 533 this.obPriceOld = BX(this.visual.PRICE_OLD_ID); 534 if (!this.obPrice) 535 { 536 this.errorCode = -16; 537 } 538 if (this.showQuantity && !!this.visual.QUANTITY_ID) 539 { 540 this.obQuantity = BX(this.visual.QUANTITY_ID); 541 if (!!this.visual.QUANTITY_UP_ID) 542 { 543 this.obQuantityUp = BX(this.visual.QUANTITY_UP_ID); 544 } 545 if (!!this.visual.QUANTITY_DOWN_ID) 546 { 547 this.obQuantityDown = BX(this.visual.QUANTITY_DOWN_ID); 548 } 549 } 550 if (3 === this.productType) 551 { 552 if (!!this.visual.TREE_ID) 553 { 554 this.obTree = BX(this.visual.TREE_ID); 555 if (!this.obTree) 556 { 557 this.errorCode = -256; 558 } 559 strPrefix = this.visual.TREE_ITEM_ID; 560 for (i = 0; i < this.treeProps.length; i++) 561 { 562 this.obTreeRows[i] = { 563 LIST: BX(strPrefix+this.treeProps[i].ID+'_list'), 564 CONT: BX(strPrefix+this.treeProps[i].ID+'_cont') 565 }; 566 if (!this.obTreeRows[i].LIST || !this.obTreeRows[i].CONT) 567 { 568 this.errorCode = -512; 569 break; 570 } 571 } 572 } 573 if (!!this.visual.QUANTITY_MEASURE) 574 { 575 this.obMeasure = BX(this.visual.QUANTITY_MEASURE); 576 } 577 } 578 579 this.obBasketActions = BX(this.visual.BASKET_ACTIONS_ID); 580 if (!!this.obBasketActions) 581 { 582 if (!!this.visual.BUY_ID) 583 { 584 this.obBuyBtn = BX(this.visual.BUY_ID); 585 } 586 if (!!this.visual.BASKET_LINK) 587 { 588 this.obBasketBtn = BX(this.visual.BASKET_LINK); 589 } 590 } 591 this.obNotAvail = BX(this.visual.NOT_AVAILABLE_MESS); 592 593 if (this.showPercent) 594 { 595 if (!!this.visual.DSC_PERC) 596 { 597 this.obDscPerc = BX(this.visual.DSC_PERC); 598 } 599 if (this.secondPict && !!this.visual.SECOND_DSC_PERC) 600 { 601 this.obSecondDscPerc = BX(this.visual.SECOND_DSC_PERC); 602 } 603 } 604 605 if (this.showSkuProps) 606 { 607 if (!!this.visual.DISPLAY_PROP_DIV) 608 { 609 this.obSkuProps = BX(this.visual.DISPLAY_PROP_DIV); 610 } 611 } 612 613 if (0 === this.errorCode) 614 { 615 if (this.showQuantity) 616 { 617 if (!!this.obQuantityUp) 618 { 619 BX.bind(this.obQuantityUp, 'click', BX.delegate(this.QuantityUp, this)); 620 } 621 if (!!this.obQuantityDown) 622 { 623 BX.bind(this.obQuantityDown, 'click', BX.delegate(this.QuantityDown, this)); 624 } 625 if (!!this.obQuantity) 626 { 627 BX.bind(this.obQuantity, 'change', BX.delegate(this.QuantityChange, this)); 628 } 629 } 630 switch (this.productType) 631 { 632 case 1://product 633 break; 634 case 3://sku 635 for(var key in this.skuVisualParams){ 636 var TreeItems = BX.findChildren(this.obTree, {tagName: this.skuVisualParams[key].TAG_BIND}, true); 637 if (!!TreeItems && 0 < TreeItems.length){ 638 for (i = 0; i < TreeItems.length; i++){ 639 $(TreeItems[i]).on(this.skuVisualParams[key].EVENT, BX.delegate(this.SelectOfferProp, this)); 640 //BX.bind(TreeItems[i], this.skuVisualParams[key].EVENT, BX.delegate(this.SelectOfferProp, this)); 641 } 642 } 643 } 644 this.SetCurrent('init'); 645 break; 646 } 647 // $(this.obProduct).find(".read_more.to-cart").on('click', BX.delegate(this.Add2Basket, this)); 648 if (!!this.obBuyBtn) 649 { 650 if (this.basketAction === 'ADD') 651 { 652 // BX.bind(this.obBuyBtn, 'click', BX.delegate(this.Add2Basket, this)); 653 654 655 } 656 else 657 {
658 BX.bind(this.obBuyBtn, 'click', BX.delegate(this.BuyBasket, this)); 659 } 660 } 661 if (this.useCompare){ 662 this.obCompare = BX(this.visual.COMPARE_LINK_ID); 663 } 664 } 665}; 666 667window.JCCatalogSection.prototype.checkHeight = function() 668{ 669 this.containerHeight = parseInt(this.obProduct.parentNode.offsetHeight, 10); 670 if (isNaN(this.containerHeight)){ 671 this.containerHeight = 0; 672 } 673}; 674 675window.JCCatalogSection.prototype.setHeight = function() 676{ 677 if (0 < this.containerHeight){ 678 BX.adjust(this.obProduct.parentNode, {style: { height: this.containerHeight+'px'}}); 679 } 680}; 681 682window.JCCatalogSection.prototype.clearHeight = function() 683{ 684 BX.adjust(this.obProduct.parentNode, {style: { height: 'auto'}}); 685}; 686 687window.JCCatalogSection.prototype.QuantityUp = function() 688{ 689 var curValue = 0, 690 boolSet = true, 691 calcPrice; 692 693 if (0 === this.errorCode && this.showQuantity && this.canBuy) 694 { 695 curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10)); 696 if (!isNaN(curValue)) 697 { 698 curValue += this.stepQuantity; 699 if (this.checkQuantity) 700 { 701 if (curValue > this.maxQuantity) 702 { 703 boolSet = false; 704 } 705 } 706 if (boolSet) 707 { 708 if (this.isDblQuantity) 709 { 710 curValue = Math.round(curValue*this.precisionFactor)/this.precisionFactor; 711 } 712 this.obQuantity.value = curValue; 713 } 714 } 715 } 716}; 717 718window.JCCatalogSection.prototype.QuantityDown = function() 719{ 720 var curValue = 0, 721 boolSet = true, 722 calcPrice; 723 724 if (0 === this.errorCode && this.showQuantity && this.canBuy) 725 { 726 curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value): parseInt(this.obQuantity.value, 10)); 727 if (!isNaN(curValue)) 728 { 729 curValue -= this.stepQuantity; 730 if (curValue < this.stepQuantity) 731 { 732 boolSet = false; 733 } 734 if (boolSet) 735 { 736 if (this.isDblQuantity) 737 { 738 curValue = Math.round(curValue*this.precisionFactor)/this.precisionFactor; 739 } 740 this.obQuantity.value = curValue; 741 } 742 } 743 } 744}; 745 746window.JCCatalogSection.prototype.QuantityChange = function() 747{ 748 var curValue = 0, 749 calcPrice, 750 intCount, 751 count; 752 753 if (0 === this.errorCode && this.showQuantity) 754 { 755 if (this.canBuy) 756 { 757 curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10)); 758 if (!isNaN(curValue)) 759 { 760 if (this.checkQuantity) 761 { 762 if (curValue > this.maxQuantity) 763 { 764 curValue = this.maxQuantity; 765 } 766 } 767 if (curValue < this.stepQuantity) 768 { 769 curValue = this.stepQuantity; 770 } 771 else 772 { 773 count = curValue/this.stepQuantity; 774 intCount = parseInt(count, 10); 775 if (isNaN(intCount)) 776 { 777 intCount = 1; 778 count = 1.1; 779 } 780 if (count > intCount) 781 { 782 curValue = (intCount <= 1 ? this.stepQuantity : intCount*this.stepQuantity); 783 curValue = Math.round(curValue*this.precisionFactor)/this.precisionFactor; 784 } 785 } 786 this.obQuantity.value = curValue; 787 } 788 else 789 { 790 this.obQuantity.value = this.stepQuantity; 791 } 792 } 793 else 794 { 795 this.obQuantity.value = this.stepQuantity; 796 } 797 } 798}; 799 800window.JCCatalogSection.prototype.QuantitySet = function(index) 801{ 802 if (0 === this.errorCode) 803 { 804 this.canBuy = this.offers[index].CAN_BUY; 805 this.currentPriceMode = this.offers[index].ITEM_PRICE_MODE; 806 this.currentPrices = this.offers[index].ITEM_PRICES; 807 this.currentPriceSelected = this.offers[index].ITEM_PRICE_SELECTED; 808 this.currentQuantityRanges = this.offers[index].ITEM_QUANTITY_RANGES; 809 this.currentQuantityRangeSelected = this.offers[index].ITEM_QUANTITY_RANGE_SELECTED; 810 811 if (this.canBuy) 812 { 813 if (!!this.obBasketActions) 814 { 815 BX.style(this.obBasketActions, 'display', ''); 816 } 817 if (!!this.obNotAvail) 818 { 819 BX.style(this.obNotAvail, 'display', 'none'); 820 } 821 } 822 else 823 { 824 if (!!this.obBasketActions) 825 { 826 //BX.style(this.obBasketActions, 'display', 'none'); 827 BX.style(this.obBasketActions, 'opacity', '0'); 828 BX.style(BX.findParent(BX(this.obQuantity), { 'class':'counter_block' }), 'display', 'none'); 829 } 830 if (!!this.obNotAvail) 831 { 832 BX.style(this.obNotAvail, 'display', ''); 833 } 834 } 835 if (this.showQuantity) 836 { 837 this.isDblQuantity = this.offers[index].QUANTITY_FLOAT; 838 this.checkQuantity = this.offers[index].CHECK_QUANTITY; 839 if (this.isDblQuantity) 840 { 841 this.maxQuantity = parseFloat(this.offers[index].MAX_QUANTITY); 842 this.stepQuantity = Math.round(parseFloat(this.offers[index].STEP_QUANTITY)*this.precisionFactor)/this.precisionFactor; 843 } 844 else 845 {
846 this.maxQuantity = parseInt(this.offers[index].MAX_QUANTITY, 10); 847 this.stepQuantity = parseInt(this.offers[index].STEP_QUANTITY, 10); 848 } 849 if(!!this.obQuantity){ 850 this.obQuantity.value = this.defaultCount; 851 this.obQuantity.disabled = !this.canBuy; 852 } 853 if (!!this.obMeasure) 854 { 855 if (!!this.offers[index].MEASURE) 856 { 857 BX.adjust(this.obMeasure, { html : this.offers[index].MEASURE}); 858 } 859 else 860 { 861 BX.adjust(this.obMeasure, { html : ''}); 862 } 863 } 864 } 865 this.currentBasisPrice = this.offers[index].BASIS_PRICE; 866 } 867}; 868 869window.JCCatalogSection.prototype.SelectOfferProp = function() 870{ 871 var i = 0, 872 value = '', 873 strTreeValue = '', 874 arTreeItem = [], 875 RowItems = null, 876 target = BX.proxy_context; 877 if(typeof target.options !== 'undefined' && typeof target.options[target.selectedIndex] !== 'undefined') 878 target = target.options[target.selectedIndex]; 879 880 if (!!target && target.hasAttribute('data-treevalue')) 881 { 882 strTreeValue = target.getAttribute('data-treevalue'); 883 propModes = target.getAttribute('data-showtype'); 884 arTreeItem = strTreeValue.split('_'); 885 if (this.SearchOfferPropIndex(arTreeItem[0], arTreeItem[1])) 886 { 887 RowItems = BX.findChildren(target.parentNode, {tagName: this.skuVisualParams[propModes.toUpperCase()].TAG}, false); 888 889 if (!!RowItems && 0 < RowItems.length) 890 { 891 for (i = 0; i < RowItems.length; i++) 892 { 893 value = RowItems[i].getAttribute('data-onevalue'); 894 895 // for SELECTBOXES 896 if(propModes == 'TEXT'){ 897 if (value === arTreeItem[1]){ 898 RowItems[i].setAttribute('selected', 'selected'); 899 }else{ 900 RowItems[i].removeAttribute('selected'); 901 } 902 }else{ 903 if (value === arTreeItem[1]){ 904 $(RowItems[i]).addClass(this.skuVisualParams[propModes.toUpperCase()].ACTIVE_CLASS); 905 }else{ 906 $(RowItems[i]).removeClass(this.skuVisualParams[propModes.toUpperCase()].ACTIVE_CLASS); 907 } 908 } 909 } 910 } 911 } 912 } 913}; 914 915window.JCCatalogSection.prototype.SearchOfferPropIndex = function(strPropID, strPropValue) 916{ 917 var strName = '', 918 arShowValues = false, 919 i, j, 920 arCanBuyValues = [], 921 allValues = [], 922 index = -1, 923 arFilter = {}, 924 tmpFilter = []; 925 926 for (i = 0; i < this.treeProps.length; i++) 927 { 928 if (this.treeProps[i].ID === strPropID) 929 { 930 index = i; 931 break; 932 } 933 } 934 935 if (-1 < index) 936 { 937 for (i = 0; i < index; i++) 938 { 939 strName = 'PROP_'+this.treeProps[i].ID; 940 arFilter[strName] = this.selectedValues[strName]; 941 } 942 strName = 'PROP_'+this.treeProps[index].ID; 943 arShowValues = this.GetRowValues(arFilter, strName); 944 if (!arShowValues) 945 { 946 return false; 947 } 948 if (!BX.util.in_array(strPropValue, arShowValues)) 949 { 950 return false; 951 } 952 arFilter[strName] = strPropValue; 953 for (i = index+1; i < this.treeProps.length; i++) 954 { 955 strName = 'PROP_'+this.treeProps[i].ID; 956 arShowValues = this.GetRowValues(arFilter, strName); 957 958 if (!arShowValues) 959 { 960 break; 961 } 962 allValues = []; 963 if (this.showAbsent) 964 { 965 arCanBuyValues = []; 966 tmpFilter = []; 967 tmpFilter = BX.clone(arFilter, true); 968 for (j = 0; j < arShowValues.length; j++) 969 { 970 tmpFilter[strName] = arShowValues[j]; 971 allValues[allValues.length] = arShowValues[j]; 972 if (this.GetCanBuy(tmpFilter)) 973 { 974 arCanBuyValues[arCanBuyValues.length] = arShowValues[j]; 975 } 976 } 977 } 978 else 979 { 980 arCanBuyValues = arShowValues; 981 } 982 983 if (this.selectedValues[strName] && BX.util.in_array(this.selectedValues[strName], arCanBuyValues)) 984 { 985 arFilter[strName] = this.selectedValues[strName]; 986 } 987 else 988 { 989 if (this.showAbsent) 990 { 991 arFilter[strName] = (arCanBuyValues.length ? arCanBuyValues[0] : allValues[0]); 992 } 993 else 994 { 995 arFilter[strName] = arCanBuyValues[0]; 996 } 997 } 998 999 this.UpdateRow(i, arFilter[strName], arShowValues, arCanBuyValues); 1000 } 1001 this.selectedValues = arFilter; 1002 this.ChangeInfo('click'); 1003 } 1004 return true; 1005}; 1006 1007window.JCCatalogSection.prototype.UpdateRow = function(intNumber, activeID, showID, canBuyID) 1008{ 1009 var i = 0, 1010 showI = 0, 1011 value = '', 1012 countShow = 0, 1013 strNewLen = '', 1014 obData = {}, 1015 obDataCont = {}, 1016 pictMode = false, 1017 extShowMode = false, 1018 isCurrent = false, 1019 selectIndex = 0, 1020 obLeft = this.treeEnableArrow, 1021 obRight = this.treeEnableArrow, 1022 currentShowStart = 0, 1023 RowItems = null; 1024 1025 if (-1 < intNumber && intNumber < this.obTreeRows.length){ 1026 propMode = this.treeProps[intNumber].DISPLAY_TYPE; 1027 RowItems = BX.findChildren(this.obTreeRows[intNumber].LIST, {tagName: this.skuVisualParams[propMode].TAG}, false); 1028 if (!!RowItems && 0 < RowItems.length){ 1029 selectMode = ('SELECT' === this.treeProps[intNumber].DISPLAY_TYPE); 1030 countShow = showID.length; 1031 obData = { 1032 style: {}, 1033 props: { 1034 disabled: '', 1035 selected: '', 1036 }, 1037 }; 1038 obDataCont = { 1039 style: {}, 1040 }; 1041 1042 for (i = 0; i < RowItems.length; i++){ 1043 value = RowItems[i].getAttribute('data-onevalue'); 1044 isCurrent = (value === activeID && value !=0); 1045 if (BX.util.in_array(value, canBuyID)){ 1046 obData.props.className = (isCurrent ? this.skuVisualParams[propMode].ACTIVE_CLASS : ''); 1047 }else{ 1048 obData.props.className = (isCurrent ? this.skuVisualParams[propMode].ACTIVE_CLASS+' '+this.skuVisualParams[propMode].HI
1048DE_CLASS : this.skuVisualParams[propMode].HIDE_CLASS); 1049 } 1050 // obData.props.className = (isCurrent ? this.skuVisualParams[propMode].ACTIVE_CLASS : ''); 1051 1052 if(selectMode){ 1053 obData.props.disabled = 'disabled'; 1054 obData.props.selected = (isCurrent ? 'selected' : ''); 1055 }else{ 1056 obData.style.display = 'none'; 1057 } 1058 1059 if (BX.util.in_array(value, showID)){ 1060 if(selectMode){ 1061 obData.props.disabled = ''; 1062 }else{ 1063 obData.style.display = ''; 1064 } 1065 if (isCurrent){ 1066 selectIndex = showI; 1067 } 1068 showI++; 1069 } 1070 BX.adjust(RowItems[i], obData); 1071 } 1072 1073 if(!showI) 1074 obDataCont.style.display = 'none'; 1075 else 1076 obDataCont.style.display = ''; 1077 BX.adjust(this.obTreeRows[intNumber].CONT, obDataCont); 1078 1079 if(selectMode){ 1080 if($(this.obTreeRows[intNumber].LIST).parent().hasClass('ik_select')) 1081 $(this.obTreeRows[intNumber].LIST).ikSelect('reset'); 1082 } 1083 1084 this.showCount[intNumber] = countShow; 1085 this.showStart[intNumber] = currentShowStart; 1086 } 1087 } 1088}; 1089 1090window.JCCatalogSection.prototype.GetRowValues = function(arFilter, index) 1091{ 1092 var i = 0, 1093 j, 1094 arValues = [], 1095 boolSearch = false, 1096 boolOneSearch = true; 1097 1098 if (0 === arFilter.length) 1099 { 1100 for (i = 0; i < this.offers.length; i++) 1101 { 1102 if (!BX.util.in_array(this.offers[i].TREE[index], arValues)) 1103 { 1104 arValues[arValues.length] = this.offers[i].TREE[index]; 1105 } 1106 } 1107 boolSearch = true; 1108 } 1109 else 1110 { 1111 for (i = 0; i < this.offers.length; i++) 1112 { 1113 boolOneSearch = true; 1114 for (j in arFilter) 1115 { 1116 if (arFilter[j] !== this.offers[i].TREE[j]) 1117 { 1118 boolOneSearch = false; 1119 break; 1120 } 1121 } 1122 if (boolOneSearch) 1123 { 1124 if (!BX.util.in_array(this.offers[i].TREE[index], arValues)) 1125 { 1126 arValues[arValues.length] = this.offers[i].TREE[index]; 1127 } 1128 boolSearch = true; 1129 } 1130 } 1131 } 1132 return (boolSearch ? arValues : false); 1133}; 1134 1135window.JCCatalogSection.prototype.GetCanBuy = function(arFilter) 1136{ 1137 var i = 0, 1138 j, 1139 boolSearch = false, 1140 boolOneSearch = true; 1141 1142 for (i = 0; i < this.offers.length; i++) 1143 { 1144 boolOneSearch = true; 1145 for (j in arFilter) 1146 { 1147 if (arFilter[j] !== this.offers[i].TREE[j]) 1148 { 1149 boolOneSearch = false; 1150 break; 1151 } 1152 } 1153 if (boolOneSearch) 1154 { 1155 if (this.offers[i].CAN_BUY) 1156 { 1157 boolSearch = true; 1158 break; 1159 } 1160 } 1161 } 1162 return boolSearch; 1163}; 1164 1165window.JCCatalogSection.prototype.SetCurrent = function(type) 1166{ 1167 var i = 0, 1168 j = 0, 1169 arCanBuyValues = [], 1170 strName = '', 1171 arShowValues = false, 1172 arFilter = {}, 1173 tmpFilter = [], 1174 current = this.offers[this.offerNum].TREE; 1175 for (i = 0; i < this.treeProps.length; i++) 1176 { 1177 strName = 'PROP_'+this.treeProps[i].ID; 1178 arShowValues = this.GetRowValues(arFilter, strName); 1179 if (!arShowValues) 1180 { 1181 break; 1182 } 1183 if (BX.util.in_array(current[strName], arShowValues)) 1184 { 1185 arFilter[strName] = current[strName]; 1186 } 1187 else 1188 { 1189 arFilter[strName] = arShowValues[0]; 1190 this.offerNum = 0; 1191 } 1192 if (this.showAbsent) 1193 { 1194 arCanBuyValues = []; 1195 tmpFilter = []; 1196 tmpFilter = BX.clone(arFilter, true); 1197 for (j = 0; j < arShowValues.length; j++) 1198 { 1199 tmpFilter[strName] = arShowValues[j]; 1200 if (this.GetCanBuy(tmpFilter)) 1201 { 1202 arCanBuyValues[arCanBuyValues.length] = arShowValues[j]; 1203 } 1204 } 1205 } 1206 else 1207 { 1208 arCanBuyValues = arShowValues; 1209 } 1210 this.UpdateRow(i, arFilter[strName], arShowValues, arCanBuyValues); 1211 } 1212 this.selectedValues = arFilter; 1213 this.ChangeInfo(type); 1214}; 1215 1216window.JCCatalogSection.prototype.ChangeInfo = function(type) 1217{ 1218 var i = 0, 1219 j, 1220 index = -1, 1221 compareParams, 1222 boolOneSearch = true; 1223 1224 for (i = 0; i < this.offers.length; i++) 1225 { 1226 boolOneSearch = true; 1227 for (j in this.selectedValues) 1228 { 1229 if (this.selectedValues[j] !== this.offers[i].TREE[j]) 1230 { 1231 boolOneSearch = false; 1232 break; 1233 } 1234 } 1235 if (boolOneSearch) 1236 { 1237 index = i; 1238 break; 1239 } 1240 } 1241 if (-1 < index){ 1242 if (!!this.obPict){ 1243 var obData = { 1244 attrs: {} 1245 }; 1246 1247 if (!!this.offers[index].PREVIEW_PICTURE){ 1248 obData.attrs.src = this.offers[index].PREVIEW_PICTURE.SRC; 1249 }else{ 1250 obData.attrs.src = this.defaultPict.pict.SRC; 1251 } 1252 BX.adjust(BX.findChild(this.obPict, {"tag": "img"}), obData); 1253 } 1254 if (this.secondPict && !!this.obSecondPict) 1255 { 1256 if (!!this.offers[index].PREVIEW_PICTURE_SECOND) 1257 { 1258 BX.adjust(this.obSecondPict, {style: {backgroundImage: 'url('+this.offers[index].PREVIEW_PICTURE_SECOND.SRC+')'}}); 1259 } 1260 else if (!!this.offers[index].PREVIEW_PICTURE.SRC) 1261 { 1262 BX.adjust(this.obSecondPict, {style: {backgroundImage: 'url('+this.offers[index].PREVIEW_PICTURE.SRC+')'}}); 1263 } 1264 else if (!!this.defaultPict.secondPict) 1265 { 1266 BX.adjust(this.obSecondPict, {style: {backgroundImage: 'url('+this.defaultPict.secondPict.SRC+')'}}); 1267 } 1268 else 1269 {
1270 BX.adjust(this.obSecondPict, {style: {backgroundImage: 'url('+this.defaultPict.pict.SRC+')'}}); 1271 } 1272 } 1273 if (this.showSkuProps && !!this.obSkuProps) 1274 { 1275 if (0 === this.offers[index].DISPLAY_PROPERTIES.length) 1276 { 1277 BX.adjust(this.obSkuProps, {style: {display: 'none'}, html: ''}); 1278 } 1279 else 1280 { 1281 BX.adjust(this.obSkuProps, {style: {display: ''}, html: this.offers[index].DISPLAY_PROPERTIES}); 1282 } 1283 } 1284 1285 if($(this.obProduct).find('.article_block')) 1286 { 1287 var article_text = (this.offers[index].ARTICLE ? this.offers[index].ARTICLE : ''); 1288 if(!article_text && this.offers[index].SHOW_ARTICLE_SKU == 'Y' && this.offers[index].ARTICLE_SKU) 1289 article_text = this.offers[index].ARTICLE_SKU; 1290 $(this.obProduct).find('.article_block').text(article_text); 1291 } 1292 $(this.obBuyBtn).data("item", this.offers[index].ID); 1293 $(this.obBasketBtn).data("item", this.offers[index].ID); 1294 1295 $(this.obBasketActions).closest('.counter_wrapp').css('opacity', 0); 1296 1297 this.setQuantityStore(this.offers[index].MAX_QUANTITY, this.offers[index].AVAILIABLE.TEXT); 1298 this.offerNum = index; 1299 this.QuantitySet(this.offerNum); 1300 1301 $(this.obProduct).find('.item-title a').attr('href', this.offers[this.offerNum].URL); 1302 $(this.obProduct).find('.image_wrapper_block > a').attr('href', this.offers[this.offerNum].URL); 1303 1304 /*quantity discount start*/ 1305 1306 if($(this.obProduct).find('.quantity_block .values').length) 1307 $(this.obProduct).find('.quantity_block .values .item span.value').text(this.offers[index].MAX_QUANTITY).css({'opacity':'1'}); 1308 1309 if(this.offers[index].SHOW_DISCOUNT_TIME_EACH_SKU == 'Y') 1310 initCountdownTime($(this.obProduct), this.offers[index].DISCOUNT_ACTIVE); 1311 1312 /*quantity discount end*/ 1313 1314 var obj=this.offers[index], 1315 th=$(this.obProduct).closest('.catalog_item_wrapp'), 1316 _th = this; 1317 if(typeof type !== 'undefined') 1318 this.init_type = type; 1319 1320 if(typeof arBasketAspro !=="undefined"){ 1321 this.setActualDataBlock(th, obj); 1322 }else{ 1323 if(typeof window.frameCacheVars !== "undefined"){ 1324 BX.addCustomEvent("onFrameDataReceived", function(){ 1325 _th.setActualDataBlock(th, obj); 1326 }); 1327 } 1328 } 1329 } 1330}; 1331 1332/*set blocks start*/ 1333window.JCCatalogSection.prototype.setActualDataBlock = function(th, obj) 1334{ 1335 /*like block start*/ 1336 this.setLikeBlock(th, '.like_icons .wish_item_button', obj, 'DELAY'); 1337 this.setLikeBlock(th, '.like_icons .compare_item_button',obj, 'COMPARE'); 1338 /*like block end*/ 1339 1340 /*buy block start*/ 1341 this.setBuyBlock(th, obj); 1342 /*buy block end*/ 1343} 1344/*set blocks end*/ 1345 1346/*set compare/wish*/ 1347window.JCCatalogSection.prototype.setLikeBlock = function(th, className, obj, type) 1348{ 1349 var block=th; 1350 if(type=="DELAY"){ 1351 if(obj.CAN_BUY){ 1352 block.find(className).css('display','block'); 1353 }else{ 1354 block.find(className).hide(); 1355 } 1356 } 1357 block.find(className).attr('data-item', obj.ID); 1358 block.find(className).find('span').attr('data-item', obj.ID); 1359 if(arBasketAspro[type]){ 1360 block.find(className).find('.to').removeClass('added').css('display','block'); 1361 block.find(className).find('.in').hide(); 1362 1363 if(arBasketAspro[type][obj.ID]!==undefined){ 1364 block.find(className).find('.to').hide(); 1365 block.find(className).find('.in').css('display','block'); 1366 } 1367 } 1368} 1369 1370/*set buy*/ 1371window.JCCatalogSection.prototype.setBuyBlock = function(th, obj) 1372{ 1373 var buyBlock=th.find('.offer_buy_block'), 1374 input_value = obj.CONFIG.MIN_QUANTITY_BUY; 1375 1376 if(buyBlock.find('.counter_wrapp .counter_block').length){ 1377 buyBlock.find('.counter_wrapp .counter_block').attr('data-item', obj.ID); 1378 } 1379 1380 if(this.offers[this.offerNum].offer_set_quantity) 1381 input_value = this.offers[this.offerNum].offer_set_quantity; 1382 1383 if((obj.CONFIG.OPTIONS.USE_PRODUCT_QUANTITY_DETAIL && obj.CONFIG.ACTION == "ADD") && obj.CAN_BUY){ 1384 var max=(obj.CONFIG.MAX_QUANTITY_BUY>0 ? "data-max='"+obj.CONFIG.MAX_QUANTITY_BUY+"'" : ""), 1385 counterHtml='<span class="minus">-</span>'+ 1386 '<input type="text" class="text" name="'+obj.PRODUCT_QUANTITY_VARIABLE+'" value="'+input_value+'" />'+ 1387 '<span class="plus" '+max+'>+</span>'; 1388 if(arBasketAspro["BASKET"] && arBasketAspro["BASKET"][obj.ID]!==undefined){ 1389 if(buyBlock.find('.counter_wrapp .counter_block').length){ 1390 buyBlock.find('.counter_wrapp .counter_block').hide(); 1391 }else{ 1392 buyBlock.find('.counter_wrapp').prepend('<div class="counter_block" data-item="'+obj.ID+'"></div>'); 1393 buyBlock.find('.counter_wrapp .counter_block').html(counterHtml).hide(); 1394 } 1395 }else{ 1396 if(buyBlock.find('.counter_wrapp .counter_block').length){ 1397 buyBlock.find('.counter_wrapp .counter_block').html(counterHtml).show(); 1398 }else{ 1399 buyBlock.find('.counter_wrapp').prepend('<div class="counter_block" data-item="'+obj.ID+'"></div>'); 1400 buyBlock.find('.counter_wrapp .counter_block').html(counterHtml); 1401 } 1402 } 1403 }else{ 1404 if(buyBlock.find('.counter_wrapp .counter_block').length){ 1405 buyBlock.find('.counter_wrapp .counter_block').hide(); 1406 } 1407 } 1408 1409 var className=((obj.CONFIG.ACTION == "ORDER") || !obj.CAN_BUY || !obj.CONFIG.OPTIONS.USE_PRODUCT_QUANTITY_DETAIL || (
1409obj.CONFIG.ACTION == "SUBSCRIBE" && obj.CATALOG_SUBSCRIBE == "Y") ? "wide" : "" ), 1410 buyBlockBtn=$('<div class="button_block"></div>'); 1411 1412 if(buyBlock.find('.counter_wrapp').find('.button_block').length){ 1413 if(arBasketAspro["BASKET"] && arBasketAspro["BASKET"][obj.ID]!==undefined){ 1414 buyBlock.find('.counter_wrapp').find('.button_block').addClass('wide').html(obj.HTML); 1415 markProductAddBasket(obj.ID); 1416 }else{ 1417 if(className){ 1418 buyBlock.find('.counter_wrapp').find('.button_block').addClass('wide').html(obj.HTML); 1419 if(arBasketAspro["SUBSCRIBE"] && arBasketAspro["SUBSCRIBE"][obj.ID]!==undefined){ 1420 markProductSubscribe(obj.ID); 1421 } 1422 }else{ 1423 buyBlock.find('.counter_wrapp').find('.button_block').removeClass('wide').html(obj.HTML); 1424 } 1425 } 1426 }else{ 1427 buyBlock.find('.counter_wrapp').append('<div class="button_block '+className+'">'+obj.HTML+'</div>'); 1428 if(arBasketAspro["BASKET"] && arBasketAspro["BASKET"][obj.ID]!==undefined) 1429 markProductAddBasket(obj.ID); 1430 if(arBasketAspro["SUBSCRIBE"] && arBasketAspro["SUBSCRIBE"][obj.ID]!==undefined) 1431 markProductSubscribe(obj.ID); 1432 } 1433 1434 if(obj.CONFIG.ACTION !== "NOTHING"){ 1435 if(obj.CONFIG.ACTION == "ADD" && obj.CAN_BUY && obj.SHOW_ONE_CLICK_BUY!="N"){ 1436 var ocb='<span class="transparent big_btn type_block button one_click" data-offers="Y" data-item="'+obj.ID+'" data-iblockID="'+obj.IBLOCK_ID+'" data-quantity="'+obj.CONFIG.MIN_QUANTITY_BUY+'" data-props="'+obj.OFFER_PROPS+'" onclick="oneClickBuy('+obj.ID+', '+obj.IBLOCK_ID+', this)">'+ 1437 '<span>'+obj.ONE_CLICK_BUY+'</span>'+ 1438 '</span>'; 1439 if(buyBlock.find('.wrapp_one_click').length){ 1440 buyBlock.find('.wrapp_one_click').html(ocb); 1441 }else{ 1442 buyBlock.append('<div class="wrapp_one_click">'+ocb+'</div>'); 1443 } 1444 }else{ 1445 if(buyBlock.find('.wrapp_one_click').length){ 1446 buyBlock.find('.wrapp_one_click').remove(); 1447 } 1448 } 1449 }else{ 1450 if(buyBlock.find('.wrapp_one_click').length){ 1451 buyBlock.find('.wrapp_one_click').remove(); 1452 } 1453 } 1454 1455 buyBlock.fadeIn(); 1456 1457 1458 buyBlock.find('.counter_wrapp .counter_block input').data('product', 'ob'+this.obProduct.id); 1459 this.setPriceAction('', 'Y'); 1460 1461 if(arTires2Options['THEME']['CHANGE_TITLE_ITEM'] == 'Y') 1462 { 1463 $(this.obProduct).find('.item-title a').html(obj.NAME); 1464 } 1465 1466 if('init_type' in this && this.init_type == 'click') 1467 { 1468 $('.catalog_block .catalog_item_wrapp .catalog_item .item-title').sliceHeight({resize: false, mobile: true}); 1469 $('.catalog_block .catalog_item_wrapp .catalog_item .cost').sliceHeight({resize: false, mobile: true}); 1470 $('.catalog_block .catalog_item_wrapp .item_info').sliceHeight({resize: false, mobile: true}); 1471 $('.catalog_block .catalog_item_wrapp').sliceHeight({classNull: '.footer_button', resize: false, mobile: true}); 1472 } 1473} 1474 1475/*get compare sku*/ 1476window.JCCatalogSection.prototype.CompareCountResult = function(result) 1477{ 1478 if(result.COMPARE_COUNT){ 1479 for(var i in result.ITEMS){ 1480 if(result.ITEMS[i]==this.offers[this.offerNum].ID){ 1481 this.offers[this.offerNum].COMPARE_ACTIVE=true; 1482 break; 1483 }else{ 1484 this.offers[this.offerNum].COMPARE_ACTIVE=false; 1485 } 1486 } 1487 if(this.offers[this.offerNum].COMPARE_ACTIVE){ 1488 $(this.obCompare).find('.compare_item.to').hide(); 1489 $(this.obCompare).find('.compare_item.added').show(); 1490 }else{ 1491 $(this.obCompare).find('.compare_item.added').hide(); 1492 $(this.obCompare).find('.compare_item.to').show(); 1493 } 1494 } 1495} 1496 1497/*get item info*/ 1498window.JCCatalogSection.prototype.ItemInfoResult = function(result) 1499{ 1500 if(result.HTML){ 1501 $(this.obBasketActions).html(result.HTML); 1502 $(this.obBasketActions).show(); 1503 this.obBuyBtn = BX(this.visual.BUY_ID); 1504 this.obBasketBtn = BX(this.visual.BASKET_LINK); 1505 this.obSubscribeBtn = BX(this.visual.SUBSCRIBE_ID); 1506 this.obSubscribedBtn = BX(this.visual.SUBSCRIBED_ID); 1507 BX.bind(this.obBuyBtn, 'click', BX.delegate(this.Add2Basket, this)); 1508 $(this.obBasketActions).removeClass('wide'); 1509 this.ajax_type_item=result.BUYMISSINGGOODS; 1510 if(result.BUYMISSINGGOODS!="ADD" && !this.canBuy){ 1511 $(this.obBasketActions).addClass('wide'); 1512 }else{ 1513 $(this.obQuantity).css('display',''); 1514 } 1515 } 1516 //if(this.canBuy){ 1517 basketParams = { 1518 ajax_action: 'Y' 1519 }; 1520 BX.ajax.loadJSON(
1521 arTires2Options['SITE_DIR']+'ajax/get_basket_count.php', 1522 basketParams, 1523 BX.delegate(this.BasketCountResult, this) 1524 ); 1525 //} 1526} 1527 1528/*get basket items*/ 1529window.JCCatalogSection.prototype.BasketCountResult = function(result) 1530{ 1531 //if(result.TOTAL_COUNT){ 1532 for(var i in result.ITEMS){ 1533 if(result.ITEMS[i].PRODUCT_ID==this.offers[this.offerNum].ID){ 1534 this.offers[this.offerNum].BASKET_ACTIVE=true; 1535 break; 1536 }else{ 1537 this.offers[this.offerNum].BASKET_ACTIVE=false; 1538 } 1539 } 1540 for(var i in result.SUBSCRIBE_ITEMS){ 1541 if(result.SUBSCRIBE_ITEMS[i].PRODUCT_ID==this.offers[this.offerNum].ID){ 1542 this.offers[this.offerNum].SUBSCRIBE_ACTIVE=true; 1543 break; 1544 }else{ 1545 this.offers[this.offerNum].SUBSCRIBE_ACTIVE=false; 1546 } 1547 } 1548 1549 this.BasketStateRefresh(); 1550 //} 1551} 1552 1553window.JCCatalogSection.prototype.BasketStateRefresh = function(buy_basket) 1554{ 1555 /*if(this.offers[this.offerNum].SUBSCRIBE_ACTIVE){ 1556 $(this.obBasketActions).addClass('wide'); 1557 $(this.obSubscribeBtn).hide(); 1558 $(this.obSubscribedBtn).show(); 1559 }else{ 1560 $(this.obBasketActions).addClass('wide'); 1561 $(this.obSubscribedBtn).hide(); 1562 $(this.obSubscribeBtn).show(); 1563 } 1564 if(this.offers[this.offerNum].BASKET_ACTIVE){ 1565 $(this.obBuyBtn).hide(); 1566 $(this.obBasketBtn).show(); 1567 $(this.obQuantity).closest('.counter_wrapp').find('.counter_block').hide(); 1568 $(this.obBasketActions).addClass('wide'); 1569 }else{ 1570 $(this.obBasketActions).removeClass('wide'); 1571 $(this.obBasketBtn).hide(); 1572 $(this.obBuyBtn).show(); 1573 if(this.ajax_type_item=="ADD" || this.canBuy) 1574 $(this.obQuantity).closest('.counter_wrapp').find('.counter_block').show(); 1575 1576 } 1577 if(!this.canBuy){ 1578 $(this.obBasketActions).addClass('wide'); 1579 }*/ 1580 if(this.offers[this.offerNum].SUBSCRIBE_ACTIVE){ 1581 $(this.obProduct).find('.hover_block .o_'+this.offers[this.offerNum].ID+' .to-subscribe').hide(); 1582 $(this.obProduct).find('.hover_block .o_'+this.offers[this.offerNum].ID+' .in-subscribe').show(); 1583 }else{ 1584 $(this.obProduct).find('.hover_block .o_'+this.offers[this.offerNum].ID+' .to-subscribe').show(); 1585 $(this.obProduct).find('.hover_block .o_'+this.offers[this.offerNum].ID+' .in-subscribe').hide(); 1586 } 1587 if(this.offers[this.offerNum].BASKET_ACTIVE){ 1588 $(this.obProduct).find('.hover_block .o_'+this.offers[this.offerNum].ID).addClass('wide'); 1589 $(this.obProduct).find('.hover_block .o_'+this.offers[this.offerNum].ID+' .button_block').addClass('wide'); 1590 $(this.obProduct).find('.hover_block .o_'+this.offers[this.offerNum].ID+' .to-cart').hide(); 1591 $(this.obProduct).find('.hover_block .o_'+this.offers[this.offerNum].ID+' .in-cart').show(); 1592 $(this.obProduct).find('.hover_block .o_'+this.offers[this.offerNum].ID+' .counter_block').hide(); 1593 }else{ 1594 $(this.obProduct).find('.hover_block .o_'+this.offers[this.offerNum].ID).removeClass('wide'); 1595 $(this.obProduct).find('.hover_block .o_'+this.offers[this.offerNum].ID+' .button_block').removeClass('wide'); 1596 $(this.obProduct).find('.hover_block .o_'+this.offers[this.offerNum].ID+' .to-cart').show(); 1597 $(this.obProduct).find('.hover_block .o_'+this.offers[this.offerNum].ID+' .in-cart').hide(); 1598 $(this.obProduct).find('.hover_block .o_'+this.offers[this.offerNum].ID+' .counter_block').show(); 1599 1600 } 1601 BX.style(this.obBasketActions, 'opacity', '1'); 1602 $(this.obBasketActions).closest('.counter_wrapp').css('opacity', 1); 1603 if(buy_basket!== 'undefined' && buy_basket=="Y"){ 1604 if($("#basket_line .basket_fly").length && $(window).outerWidth()>768) 1605 { 1606 // preAnimateBasketFly($("#basket_line .basket_fly"), 200, 333); 1607 basketFly('open'); 1608 } 1609 else if($("#basket_line .cart").length) 1610 { 1611 if($("#basket_line .cart").is(".empty_cart")) 1612 { 1613 $("#basket_line .cart").removeClass("empty_cart").find(".cart_wrapp a.basket_link").removeAttr("href").addClass("cart-call"); 1614 touchBasket('.cart:not(.empty_cart) .basket_block .link'); 1615 } 1616 reloadTopBasket('add', $('#basket_line'), 200, 2000, 'Y'); 1617 /*if($(window).outerWidth() > 520){ 1618 //if(arTires2Options['THEME']['SHOW_BASKET_ONADDTOCART'] !== 'N'){ 1619 preAnimateBasketPopup('', $('.card_popup_frame'), 0, 200); 1620 //} 1621 };*/ 1622 } 1623 animateBasketLine(200); 1624 } 1625} 1626
1627window.JCCatalogSection.prototype.setPriceAction = function(change, sku) 1628{ 1629 var measure = this.offers[this.offerNum].MEASURE && this.offers[this.offerNum].SHOW_MEASURE=="Y" ? this.offers[this.offerNum].MEASURE : ''; 1630 var product = $(this.obProduct), 1631 check_quantity = '', 1632 is_sku = (typeof sku !== 'undefined' && sku == 'Y'); 1633 1634 this.offers[this.offerNum].offer_set_quantity = this.offers[this.offerNum].CONFIG.MIN_QUANTITY_BUY; 1635 if($(product).find('input[name=quantity]').length) 1636 this.offers[this.offerNum].offer_set_quantity = $(product).find('input[name=quantity]').val(); 1637 1638 1639 if(this.offers[this.offerNum].USE_PRICE_COUNT && this.offers[this.offerNum].PRICE_MATRIX) 1640 { 1641 this.checkPriceRange(this.offers[this.offerNum].offer_set_quantity); 1642 this.setPriceMatrix(this.offers[this.offerNum].PRICE_MATRIX); 1643 } 1644 else 1645 { 1646 if('PRICES' in this.offers[this.offerNum] && this.offers[this.offerNum].PRICES) 1647 this.setPrice(this.offers[this.offerNum].PRICES, measure); 1648 } 1649 1650 if(arTires2Options['THEME']['SHOW_TOTAL_SUMM'] == 'Y') 1651 { 1652 if(this.offers[this.offerNum].check_quantity) 1653 check_quantity = 'Y'; 1654 else 1655 { 1656 var check_quantity = ((typeof change !== 'undefined' && change == 'Y') ? change : ''); 1657 if(check_quantity) 1658 this.offers[this.offerNum].check_quantity = true; 1659 } 1660 if(typeof this.currentPrices[this.currentPriceSelected] !== 'undefined') 1661 { 1662 if(arTires2Options["THEME"]["SHOW_TOTAL_SUMM_TYPE"] == "ALWAYS") 1663 check_quantity = is_sku = ''; 1664 setPriceItem(product, this.offers[this.offerNum].offer_set_quantity, this.currentPrices[this.currentPriceSelected].PRICE, check_quantity, is_sku); 1665 } 1666 } 1667} 1668 1669window.JCCatalogSection.prototype.setPriceMatrix = function(sPriceMatrix) 1670{ 1671 var prices = ''; 1672 if (!!this.obPrice) 1673 { 1674 var measure = this.offers[this.offerNum].MEASURE && this.offers[this.offerNum].SHOW_MEASURE=="Y" ? this.offers[this.offerNum].MEASURE : '', 1675 strPrice = ''; 1676 strPrice = getCurrentPrice(this.currentPrices[this.currentPriceSelected].PRICE, this.currentPrices[this.currentPriceSelected].CURRENCY, this.currentPrices[this.currentPriceSelected].PRINT_PRICE); 1677 if(measure) 1678 strPrice += '<span class="price_measure">/'+measure+'</span>'; 1679 $(this.obProduct).find('.not_matrix').hide(); 1680 $(this.obProduct).find('.with_matrix .price_value_block').html(strPrice); 1681 1682 if (this.showOldPrice) 1683 { 1684 if(parseFloat(this.currentPrices[this.currentPriceSelected].BASE_PRICE) > parseFloat(this.currentPrices[this.currentPriceSelected].PRICE)) 1685 { 1686 $(this.obProduct).find('.with_matrix .discount').html(getCurrentPrice(this.currentPrices[this.currentPriceSelected].BASE_PRICE, this.currentPrices[this.currentPriceSelected].CURRENCY, this.currentPrices[this.currentPriceSelected].PRINT_BASE_PRICE)); 1687 $(this.obProduct).find('.with_matrix .discount').css('display', 'inline-block'); 1688 } 1689 else 1690 { 1691 $(this.obProduct).find('.with_matrix .discount').html(''); 1692 $(this.obProduct).find('.with_matrix .discount').css('display', 'none'); 1693 } 1694 } 1695 else 1696 { 1697 $(this.obProduct).find('.with_matrix .discount').html(''); 1698 $(this.obProduct).find('.with_matrix .discount').css('display', 'none'); 1699 } 1700 1701 if(this.currentPrices[this.currentPriceSelected].PERCENT > 0) 1702 { 1703 if(this.showPercentNumber) 1704 { 1705 if(this.currentPrices[this.currentPriceSelected].PERCENT > 0 && this.currentPrices[this.currentPriceSelected].PERCENT < 100) 1706 { 1707 if(!$(this.obProduct).find('.with_matrix .sale_block .sale_wrapper .value').length) 1708 $('<div class="value"></div>').insertBefore($(this.obProduct).find('.with_matrix .sale_block .sale_wrapper .text')); 1709 1710 $(this.obProduct).find('.with_matrix .sale_block .sale_wrapper .value').html('-<span>'+this.currentPrices[this.currentPriceSelected].PERCENT+'</span>%'); 1711 } 1712 else 1713 { 1714 if($(this.obProduct).find('.with_matrix .sale_block .sale_wrapper .value').length) 1715 $(this.obProduct).find('.with_matrix .sale_block .sale_wrapper .value').remove(); 1716 } 1717 } 1718 1719 $(this.obProduct).find('.with_matrix .sale_block .text .values_wrapper').html(getCurrentPrice(this.currentPrices[this.currentPriceSelected].DISCOUNT, this.currentPrices[this.currentPriceSelected].CURRENCY, this.currentPrices[this.currentPriceSelected].PRINT_DISCOUNT)); 1720 $(this.obProduct).find('.with_matrix .sale_block').show(); 1721 } 1722 else 1723 { 1724 $(this.obProduct).find('.with_matrix .sale_block').hide(); 1725 } 1726 1727 $(this.obProduct).find('.sale_block.normal').hide(); 1728 $(this.obProduct).find('.with_matrix').show(); 1729 1730 if(this.showPercent) 1731 { 1732 $(this.obPrice).closest('.cost').find('.sale_block:not(.matrix)').hide(); 1733 $(this.obPrice).closest('.cost').find('.sale_block:not(.matrix) .text span').html(''); 1734 } 1735 if(this.showOldPrice) 1736 { 1737 $(this.obPrice).closest('.cost').find('.price.discount').hide(); 1738 } 1739 1740 BX.adjust(this.obPrice, {html: sPriceMatrix}); 1741 1742 var eventdata = {product: $(this.obProduct), measure: measure, config: this.config, offer: this.offers[this.offerNum], obPrice: this.currentPrices[this.currentPriceSelected]}; 1743 BX.onCustomEvent('onAsproSkuSetPriceMatrix', [eventdata]) 1744 } 1745} 1746
1747window.JCCatalogSection.prototype.setPrice = function(obPrices, measure) 1748{ 1749 var strPrice, 1750 obData; 1751 1752 if (!!this.obPrice){ 1753 var measure = this.offers[this.offerNum].MEASURE && this.offers[this.offerNum].SHOW_MEASURE=="Y" ? this.offers[this.offerNum].MEASURE : '', 1754 product = $(this.obProduct), 1755 obPrices = this.offers[this.offerNum].PRICES; 1756 if(typeof(obPrices) == 'object') 1757 { 1758 var strPrice = '', 1759 count = Object.keys(obPrices).length, 1760 arStikePrices = []; 1761 1762 if(arTires2Options['THEME']['DISCOUNT_PRICE']) 1763 { 1764 arStikePrices = arTires2Options['THEME']['DISCOUNT_PRICE'].split(','); 1765 } 1766 1767 strPrice = '<div class="offers_price_wrapper">'; 1768 $(this.obProduct).find('.with_matrix').hide(); 1769 $(this.obProduct).find('.not_matrix').show(); 1770 for(var j in obPrices) 1771 { 1772 if(obPrices[j] && obPrices[j].VALUE > 0) 1773 { 1774 if('GROUP_NAME' in obPrices[j]) 1775 { 1776 if(count > 1) 1777 { 1778 strPrice += '<div class="offers_price_title">'; 1779 strPrice += obPrices[j].GROUP_NAME; 1780 strPrice += '</div>'; 1781 } 1782 } 1783 strPrice += '<div class="offers_price'+(arStikePrices ? (BX.util.in_array(obPrice
1783s[j].PRICE_ID, arStikePrices) ? ' strike_block' : '') : '')+'">'; 1784 strPrice += '<span class="values_wrapper">'+getCurrentPrice(obPrices[j].DISCOUNT_VALUE, obPrices[j].CURRENCY, obPrices[j].PRINT_DISCOUNT_VALUE)+'</span>'; 1785 if(measure) 1786 strPrice += '<span class="price_measure">/'+measure+'</span>'; 1787 1788 strPrice += '</div>'; 1789 if (obPrices[j].DISCOUNT_VALUE !== obPrices[j].VALUE) 1790 { 1791 if(this.showOldPrice) 1792 { 1793 strPrice += '<div class="offers_price_old">'; 1794 strPrice += '<span class="values_wrapper">'+getCurrentPrice(obPrices[j].VALUE, obPrices[j].CURRENCY, obPrices[j].PRINT_VALUE)+'</span>'; 1795 strPrice += '</div>'; 1796 } 1797 if(this.showPercent) 1798 { 1799 if(!this.showPercentNumber || (this.showPercentNumber && (obPrices[j].DISCOUNT_DIFF_PERCENT <= 0 && obPrices[j].DISCOUNT_DIFF_PERCENT >= 100))) 1800 { 1801 strPrice += '<div class="sale_block matrix"><div class="sale_wrapper">'; 1802 strPrice += '<span class="title">'+BX.message('ITEM_ECONOMY')+'</span>'; 1803 strPrice += '<div class="text">'; 1804 strPrice += '<span class="values_wrapper">'+getCurrentPrice(obPrices[j].DISCOUNT_DIFF, obPrices[j].CURRENCY, obPrices[j].PRINT_DISCOUNT_DIFF)+'</span>'; 1805 strPrice += '</div>'; 1806 strPrice += '<div class="clearfix"></div></div></div>'; 1807 } 1808 else 1809 { 1810 strPrice += '<div class="sale_block matrix"><div class="sale_wrapper">'; 1811 strPrice += '<div class="value">-<span>'+obPrices[j].DISCOUNT_DIFF_PERCENT+'</span>%</div>'; 1812 strPrice += '<div class="text">'; 1813 strPrice += '<span class="title">'+BX.message('ITEM_ECONOMY')+'</span> '; 1814 strPrice += '<span class="values_wrapper">'+getCurrentPrice(obPrices[j].DISCOUNT_DIFF, obPrices[j].CURRENCY, obPrices[j].PRINT_DISCOUNT_DIFF)+'</span>'; 1815 strPrice += '</div>'; 1816 strPrice += '<div class="clearfix"></div></div></div>'; 1817 } 1818 } 1819 } 1820 $('.prices_block .cost.prices').show(); 1821 } 1822 else 1823 { 1824 $('.prices_block .cost.prices').hide(); 1825 } 1826 } 1827 if(this.showPercent) 1828 { 1829 $(this.obPrice).closest('.cost').find('.sale_block:not(.matrix)').hide(); 1830 $(this.obPrice).closest('.cost').find('.sale_block:not(.matrix) .text span').html(''); 1831 } 1832 if(this.showOldPrice) 1833 { 1834 $(this.obPrice).closest('.cost').find('.price.discount').hide(); 1835 } 1836 1837 strPrice += '</div>'; 1838 BX.adjust(this.obPrice, {html: strPrice}); 1839 1840 var eventdata = {product: product, measure: measure, config: this.config, offer: this.offers[this.offerNum], obPrices: obPrices}; 1841 BX.onCustomEvent('onAsproSkuSetPrice', [eventdata]) 1842 } 1843 } 1844}; 1845 1846window.JCCatalogSection.prototype.checkPriceRange = function(quantity) 1847{ 1848 if (typeof quantity === 'undefined'|| this.currentPriceMode != 'Q') 1849 return; 1850 1851 var range, found = false; 1852 for (var i in this.currentQuantityRanges) 1853 { 1854 if (this.currentQuantityRanges.hasOwnProperty(i)) 1855 { 1856 range = this.currentQuantityRanges[i]; 1857 1858 if ( 1859 parseInt(quantity) >= parseInt(range.SORT_FROM) 1860 && ( 1861 range.SORT_TO == 'INF' 1862 || parseInt(quantity) <= parseInt(range.SORT_TO) 1863 ) 1864 ) 1865 { 1866 found = true; 1867 this.currentQuantityRangeSelected = range.HASH; 1868 break; 1869 } 1870 } 1871 } 1872 1873 if (!found && (range = this.getMinPriceRange())) 1874 { 1875 this.currentQuantityRangeSelected = range.HASH; 1876 } 1877 1878 for (var k in this.currentPrices) 1879 { 1880 if (this.currentPrices.hasOwnProperty(k)) 1881 { 1882 if (this.currentPrices[k].QUANTITY_HASH == this.currentQuantityRangeSelected) 1883 { 1884 this.currentPriceSelected = k; 1885 break; 1886 } 1887 } 1888 } 1889}; 1890 1891window.JCCatalogSection.prototype.getMinPriceRange = function() 1892{ 1893 var range; 1894 1895 for (var i in this.currentQuantityRanges) 1896 { 1897 if (this.currentQuantityRanges.hasOwnProperty(i)) 1898 { 1899 if ( 1900 !range 1901 || parseInt(this.currentQuantityRanges[i].SORT_FROM) < parseInt(range.SORT_FROM) 1902 ) 1903 { 1904 range = this.currentQuantityRanges[i]; 1905 } 1906 } 1907 } 1908 1909 return range; 1910} 1911 1912/*set store quantity*/ 1913window.JCCatalogSection.prototype.setQuantityStore = function(quantity, text) 1914{ 1915 if(parseFloat(quantity)>0){ 1916 $(this.storeQuanity).find('.icon').removeClass('order').addClass('stock'); 1917 }else{ 1918 $(this.storeQuanity).find('.icon').removeClass('stock').addClass('order'); 1919 } 1920 $(this.storeQuanity).find('.icon + span').html(text); 1921} 1922 1923window.JCCatalogSection.prototype.Compare = function() 1924{ 1925 var compareParams, compareLink; 1926 $(this.obProduct).find('.like_icons .o_'+this.offers[this.offerNum].ID).data('changed','Y'); 1927 // if($(this.obCompare).find('.compare_item.added').is(':visible')){ 1928 if($(this.obProduct).find('.like_icons .o_'+this.offers[this.offerNum].ID).find('.compare_item.added').is(':visible')){ 1929 compareLink = this.compareData.compareUrlDel; 1930 this.compareData.Added = false;
1931 }else{ 1932 compareLink = this.compareData.compareUrl; 1933 this.compareData.Added = true; 1934 } 1935 if (!!compareLink){ 1936 switch (this.productType){ 1937 case 1://product 1938 case 2://set 1939 compareLink = compareLink.replace('#ID#', this.product.id.toString()); 1940 break; 1941 case 3://sku 1942 compareLink = compareLink.replace('#ID#', this.offers[this.offerNum].ID); 1943 break; 1944 } 1945 compareParams = { 1946 ajax_action: 'Y' 1947 }; 1948 BX.ajax.loadJSON( 1949 compareLink, 1950 compareParams, 1951 BX.proxy(this.CompareResult, this) 1952 ); 1953 } 1954}; 1955 1956window.JCCatalogSection.prototype.CompareResult = function(result) 1957{ 1958 var popupContent, popupButtons, popupTitle; 1959 1960 if (typeof result !== 'object'){ 1961 return false; 1962 } 1963 1964 if (result.STATUS === 'OK'){ 1965 BX.onCustomEvent('OnCompareChange'); 1966 /*if(!this.compareData.Added){ 1967 $(this.obCompare).find('.in').hide(); 1968 $(this.obCompare).find('.to').show(); 1969 } 1970 else{ 1971 $(this.obCompare).find('.to').hide(); 1972 $(this.obCompare).find('.in').show(); 1973 }*/ 1974 if(!this.compareData.Added){ 1975 $(this.obProduct).find('.like_icons .o_'+this.offers[this.offerNum].ID).find('.in').hide(); 1976 $(this.obProduct).find('.like_icons .o_'+this.offers[this.offerNum].ID).find('.to').show(); 1977 } 1978 else{ 1979 $(this.obProduct).find('.like_icons .o_'+this.offers[this.offerNum].ID).find('.to').hide(); 1980 $(this.obProduct).find('.like_icons .o_'+this.offers[this.offerNum].ID).find('.in').show(); 1981 } 1982 jsAjaxUtil.InsertDataToNode(arTires2Options['SITE_DIR'] + 'ajax/show_compare_preview_top.php', 'compare_line', false); 1983 }else{ 1984 console.log(BX.message('ADD_ERROR_COMPARE')); 1985 } 1986 return false; 1987}; 1988 1989window.JCCatalogSection.prototype.CompareRedirect = function() 1990{ 1991 if (!!this.compareData.comparePath){ 1992 location.href = this.compareData.comparePath; 1993 }else{ 1994 this.obPopupWin.close(); 1995 } 1996}; 1997 1998window.JCCatalogSection.prototype.InitBasketUrl = function() 1999{ 2000 this.basketUrl = (this.basketMode === 'ADD' ? this.basketData.add_url : this.basketData.buy_url); 2001 switch (this.productType) 2002 { 2003 case 1://product 2004 case 2://set 2005 this.basketUrl = this.basketUrl.replace('#ID#', this.product.id.toString()); 2006 break; 2007 case 3://sku 2008 this.basketUrl = this.basketUrl.replace('#ID#', this.offers[this.offerNum].ID); 2009 break; 2010 } 2011 this.basketParams = { 2012 'ajax_basket': 'Y' 2013 }; 2014 if (this.showQuantity) 2015 { 2016 // this.basketParams[this.basketData.quantity] = this.obQuantity.value; 2017 this.basketParams[this.basketData.quantity] = $(this.obProduct).find('.counter_wrapp').find('.counter_block .text').val(); 2018 } 2019 if (!!this.basketData.sku_props) 2020 { 2021 this.basketParams[this.basketData.sku_props_var] = this.basketData.sku_props; 2022 } 2023}; 2024 2025window.JCCatalogSection.prototype.FillBasketProps = function() 2026{ 2027 if (!this.visual.BASKET_PROP_DIV) 2028 { 2029 return; 2030 } 2031 var 2032 i = 0, 2033 propCollection = null, 2034 foundValues = false, 2035 obBasketProps = null; 2036 2037 if (this.basketData.useProps && !this.basketData.emptyProps) 2038 { 2039 if (!!this.obPopupWin && !!this.obPopupWin.contentContainer) 2040 { 2041 obBasketProps = this.obPopupWin.contentContainer; 2042 } 2043 } 2044 else 2045 { 2046 obBasketProps = BX(this.visual.BASKET_PROP_DIV); 2047 } 2048 if (!!obBasketProps) 2049 { 2050 propCollection = obBasketProps.getElementsByTagName('select'); 2051 if (!!propCollection && !!propCollection.length) 2052 { 2053 for (i = 0; i < propCollection.length; i++) 2054 { 2055 if (!propCollection[i].disabled) 2056 { 2057 switch(propCollection[i].type.toLowerCase()) 2058 { 2059 case 'select-one': 2060 this.basketParams[propCollection[i].name] = propCollection[i].value; 2061 foundValues = true; 2062 break; 2063 default: 2064 break; 2065 } 2066 } 2067 } 2068 } 2069 propCollection = obBasketProps.getElementsByTagName('input'); 2070 if (!!propCollection && !!propCollection.length) 2071 { 2072 for (i = 0; i < propCollection.length; i++) 2073 { 2074 if (!propCollection[i].disabled) 2075 { 2076 switch(propCollection[i].type.toLowerCase()) 2077 { 2078 case 'hidden': 2079 this.basketParams[propCollection[i].name] = propCollection[i].value; 2080 foundValues = true; 2081 break; 2082 case 'radio': 2083 if (propCollection[i].checked) 2084 { 2085 this.basketParams[propCollection[i].name] = propCollection[i].value; 2086 foundValues = true; 2087 } 2088 break; 2089 default: 2090 break; 2091 } 2092 } 2093 } 2094 } 2095 } 2096 if (!foundValues) 2097 { 2098 this.basketParams[this.basketData.props] = []; 2099 this.basketParams[this.basketData.props][0] = 0; 2100 } 2101}; 2102 2103window.JCCatalogSection.prototype.Add2Basket = function() 2104{ 2105 this.basketMode = 'ADD'; 2106 this.Basket(); 2107}; 2108 2109window.JCCatalogSection.prototype.BuyBasket = function() 2110{ 2111 this.basketMode = 'BUY'; 2112 this.Basket(); 2113}; 2114 2115window.JCCatalogSection.prototype.SendToBasket = function() 2116{ 2117 if (!this.canBuy){ 2118 return; 2119 } 2120 2121 this.InitBasketUrl(); 2122 this.FillBasketProps(); 2123 2124 BX.ajax.loadJSON( 2125 this.basketUrl, 2126 this.basketParams, 2127 BX.delegate(this.BasketResult, this) 2128 ); 2129}; 2130 2131window.JCCatalogSection.prototype.Basket = function() 2132{ 2133 var contentBasketProps = ''; 2134 if (!this.canBuy){ 2135 return; 2136 } 2137 2138 this.SendToBasket(); 2139}; 2140 2141window.JCCatalogSection.prototype.BasketResult = function(arResult) 2142{ 2143 var strContent = '', 2144 strPict = '', 2145 successful, 2146 buttons = []; 2147 2148 if (!!this.obPopupWin){ 2149 this.obPopupWin.close(); 2150 } 2151 if ('object' !== typeof arResult){ 2152 return false;
2153 } 2154 successful = (arResult.STATUS === 'OK'); 2155 if (successful && this.basketAction === 'BUY'){ 2156 this.BasketRedirect(); 2157 }else{ 2158 if (successful){ 2159 getActualBasket(); 2160 markProductAddBasket(this.offers[this.offerNum].ID); 2161 BX.onCustomEvent('OnBasketChange'); 2162 this.offers[this.offerNum].BASKET_ACTIVE=true; 2163 this.BasketStateRefresh("Y"); 2164 $(this.obProduct).find('.hover_block .o_'+this.offers[this.offerNum].ID).data('changed','Y'); 2165 2166 }else{ 2167 console.log(BX.message('ADD_ERROR_BASKET')); 2168 } 2169 } 2170}; 2171 2172window.JCCatalogSection.prototype.BasketRedirect = function() 2173{ 2174 location.href = (!!this.basketData.basketUrl ? this.basketData.basketUrl : BX.message('BASKET_URL')); 2175}; 2176 2177})(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.