1(function (window) { 2 3if (!!window.JCCatalogElement) 4{ 5 return; 6} 7 8var BasketButton = function(params) 9{ 10 BasketButton.superclass.constructor.apply(this, arguments); 11 this.nameNode = BX.create('span', { 12 props : { className : 'bx_medium bx_bt_button', id : this.id }, 13 style: typeof(params.style) === 'object' ? params.style : {}, 14 text: params.text 15 }); 16 this.buttonNode = BX.create('span', { 17 attrs: { className: params.ownerClass }, 18 children: [this.nameNode], 19 events : this.contextEvents 20 }); 21 if (BX.browser.IsIE()) 22 { 23 this.buttonNode.setAttribute("hideFocus", "hidefocus"); 24 } 25}; 26BX.extend(BasketButton, BX.PopupWindowButton); 27 28window.JCCatalogElement = function (arParams) 29{ 30 this.productType = 0; 31 32 this.config = { 33 useCatalog: true, 34 showQuantity: true, 35 showPrice: true, 36 showAbsent: true, 37 showOldPrice: false, 38 showPercent: false, 39 showSkuProps: false, 40 showOfferGroup: false, 41 useCompare: false, 42 mainPictureMode: 'IMG', 43 showBasisPrice: false, 44 basketAction: ['BUY'], 45 showClosePopup: false 46 }; 47 48 this.checkQuantity = false; 49 this.maxQuantity = 0; 50 this.stepQuantity = 1; 51 this.isDblQuantity = false; 52 this.canBuy = true; 53 this.currentBasisPrice = {}; 54 this.currentPrices = {}; 55 this.canSubscription = true; 56 this.currentIsSet = false; 57 this.updateViewedCount = false; 58 59 this.precision = 6; 60 this.precisionFactor = Math.pow(10,this.precision); 61 62 this.listID = { 63 main: ['PICT_ID', 'PICT_SUB_ID', 'BIG_SLIDER_ID', 'BIG_IMG_CONT_ID'], 64 stickers: ['STICKER_ID'], 65 productSlider: ['SLIDER_CONT', 'SLIDER_LIST', 'SLIDER_LEFT', 'SLIDER_RIGHT'], 66 offerSlider: ['SLIDER_CONT_OF_ID', 'SLIDER_LIST_OF_ID', 'SLIDER_LEFT_OF_ID', 'SLIDER_RIGHT_OF_ID'], 67 offers: ['TREE_ID', 'TREE_ITEM_ID', 'DISPLAY_PROP_DIV', 'PROP_TABLE', 'ARTNUMBER_DIV', 'LIKED_COMPARE_ID', 'BUY_1_CLICK_ID', 'OFFER_GROUP'], 68 quantity: ['QUANTITY_ID', 'QUANTITY_UP_ID', 'QUANTITY_DOWN_ID', 'QUANTITY_MEASURE', 'QUANTITY_LIMIT', 'QUANTITY_MAX', 'BASIS_PRICE'], 69 price: ['PRICE_ID'], 70 oldPrice: ['OLD_PRICE_ID', 'DISCOUNT_VALUE_ID', 'ACTION_ECONOMY_ID'], 71 discountPerc: ['DISCOUNT_PERC_ID'], 72 basket: ['BASKET_PROP_DIV', 'BUY_ID', 'ADD_BASKET_ID', 'BASKET_ACTIONS_ID', 'NOT_AVAILABLE_MESS'], 73 magnifier: ['MAGNIFIER_ID', 'MAGNIFIER_AREA_ID'], 74 compare: ['COMPARE_LINK_ID'] 75 }; 76 77 this.visualPostfix = { 78 // main pict 79 PICT_ID: '_pict', 80 PICT_SUB_ID: '_pict_sub', 81 BIG_SLIDER_ID: '_big_slider', 82 BIG_IMG_CONT_ID: '_bigimg_cont', 83 // stickers 84 STICKER_ID: '_sticker', 85 // product pict slider 86 SLIDER_CONT: '_slider_cont', 87 SLIDER_LIST: '_slider_list', 88 SLIDER_LEFT: '_slider_left', 89 SLIDER_RIGHT: '_slider_right', 90 // offers sliders 91 SLIDER_CONT_OF_ID: '_slider_cont_', 92 SLIDER_LIST_OF_ID: '_slider_list_', 93 SLIDER_LEFT_OF_ID: '_slider_left_', 94 SLIDER_RIGHT_OF_ID: '_slider_right_', 95 // offers 96 TREE_ID: '_skudiv', 97 TREE_ITEM_ID: '_prop_', 98 DISPLAY_PROP_DIV: '_sku_prop', 99 PROP_TABLE: '_prop_table_', 100 ARTNUMBER_DIV: '_articul_', 101 LIKED_COMPARE_ID: '_add_liked_compare_', 102 BUY_1_CLICK_ID: '_buy_1_click_', 103 ACTION_ECONOMY_ID: '_action_economy', 104 // quantity 105 QUANTITY_ID: '_quantity', 106 QUANTITY_UP_ID: '_quant_up', 107 QUANTITY_DOWN_ID: '_quant_down', 108 QUANTITY_MEASURE: '_quant_measure', 109 QUANTITY_LIMIT: '_quant_limit', 110 QUANTITY_MAX: '_quant_max_', 111 BASIS_PRICE: '_basis_price', 112 // price and discount 113 PRICE_ID: '_price', 114 OLD_PRICE_ID: '_old_price', 115 DISCOUNT_VALUE_ID: '_price_discount', 116 DISCOUNT_PERC_ID: '_dsc_pict', 117 // basket 118 BASKET_PROP_DIV: '_basket_prop', 119 BUY_ID: '_buy_link', 120 ADD_BASKET_ID: '_add_basket_link', 121 BASKET_ACTIONS_ID: '_basket_actions', 122 NOT_AVAILABLE_MESS: '_not_avail', 123 // magnifier 124 MAGNIFIER_ID: '_magnifier', 125 MAGNIFIER_AREA_ID: '_magnifier_area', 126 // offer groups 127 OFFER_GROUP: '_set_group_', 128 // compare 129 COMPARE_LINK_ID: '_compare_link' 130 }; 131 132 this.visual = {}; 133 134 this.basketMode = ''; 135 this.product = { 136 checkQuantity: false, 137 maxQuantity: 0, 138 stepQuantity: 1, 139 startQuantity: 1, 140 isDblQuantity: false, 141 canBuy: true, 142 canSubscription: true, 143 name: '', 144 pict: {}, 145 id: 0, 146 addUrl: '', 147 buyUrl: '', 148 slider: {}, 149 sliderCount: 0, 150 useSlider: false, 151 sliderPict: [] 152 }; 153 this.mess = {}; 154 155 this.basketData = { 156 useProps: false, 157 emptyProps: false, 158 quantity: 'quantity', 159 props: 'prop', 160 basketUrl: '', 161 sku_props: '', 162 sku_props_var: 'basket_props', 163 add_url: '', 164 buy_url: '' 165 }; 166 this.compareData = { 167 compareUrl: '', 168 comparePath: '' 169 }; 170 171 this.defaultPict = { 172 preview: null, 173 detail: null 174 }; 175 176 this.offers = []; 177 this.offerNum = 0; 178 this.treeProps = []; 179 this.obTreeRows = []; 180 this.showCount = []; 181 this.showStart = []; 182 this.selectedValues = {}; 183 this.sliders = []; 184 185 this.obProduct = null; 186 this.obQuantity = null; 187 this.obQuantityUp = null; 188 this.obQuantityDown = null; 189 this.obBasisPrice = null; 190 this.obPict = null; 191 this.obPictAligner = null; 192 this.obPrice = { 193 price: null, 194 full: null, 195 discount: null, 196 percent: null 197 }; 198 this.obTree = null; 199 this.obBuyBtn = null; 200 this.obAddToBasketBtn = null; 201 this.obBasketActions = null; 202 this.obNotAvail = null; 203 this.obSkuProps = null; 204 this.obSlider = null; 205 this.obMeasure = null; 206 this.obQuantityLimit = { 207 all: null, 208 value: null 209 }; 210 this.obCompare = null; 211 this.obArtnumber = null; 212 this.obQuantityMax = null; 213 this.obPropTable = null; 214 215 this.viewedCounter = { 216 path: '/bitrix/components/bitrix/catalog.element/ajax.php', 217 params: { 218 AJAX: 'Y', 219 SITE_ID: '', 220 PRODUCT_ID: 0, 221 PARENT_ID: 0 222 } 223 }; 224 225 this.currentImg = { 226 src: '', 227 width: 0, 228 height: 0, 229 screenWidth: 0, 230 screenHeight: 0, 231 screenOffsetX: 0, 232 screenOffsetY: 0, 233 scale: 1 234 }; 235 236 this.obPopupWin = null; 237 this.basketUrl = ''; 238 this.basketParams = {}; 239 240 this.obPopupPict = null; 241 this.magnify = { 242 obMagnifier: null, 243 obMagnifyPict: null, 244 obMagnifyArea: null, 245 obBigImg: null, 246 obBigSlider: null, 247 magnifyShow: false, 248 areaParams : { 249 width: 100, 250 height: 130, 251 left: 0, 252 top: 0, 253 scaleFactor: 1, 254 globalLeft: 0, 255 globalTop: 0, 256 globalRight: 0, 257 globalBottom: 0 258 }, 259 magnifierParams: { 260 top: 0, 261 left: 0, 262 width: 0, 263 height: 0, 264 ratioX: 10, 265 ratioY: 13, 266 defaultScale: 1 267 }, 268 magnifyPictParams: { 269 marginTop: 0, 270 marginLeft: 0, 271 width: 0, 272 height: 0 273 } 274 }; 275 276 this.treeRowShowSize = 5; 277 this.treeEnableArrow = { display: '', cursor: 'pointer', opacity: 1 }; 278 this.treeDisableArrow = { display: '', cursor: 'default', opacity: 0.2 }; 279 this.sliderRowShowSize = 5; 280 this.sliderEnableArrow = { display: '', cursor: 'pointer', opacity: 1 }; 281 this.sliderDisableArrow = { display: '', cursor: 'default', opacity: 0.2 }; 282 283 this.errorCode = 0; 284 285 if (typeof arParams === 'object') 286 {
287 this.params = arParams; 288 this.initConfig(); 289 290 if (!!this.params.MESS) 291 { 292 this.mess = this.params.MESS; 293 } 294 switch (this.productType) 295 { 296 case 0:// no catalog 297 case 1://product 298 case 2://set 299 this.initProductData(); 300 break; 301 case 3://sku 302 this.initOffersData(); 303 break; 304 default: 305 this.errorCode = -1; 306 } 307 this.initBasketData(); 308 this.initCompareData(); 309 } 310 if (0 === this.errorCode) 311 { 312 BX.ready(BX.delegate(this.Init,this)); 313 } 314 this.params = {}; 315}; 316 317window.JCCatalogElement.prototype.Init = function() 318{ 319 var i = 0, 320 j = 0, 321 strPrefix = '', 322 SliderImgs = null, 323 TreeItems = null; 324 325 this.obProduct = BX(this.visual.ID); 326 if (!this.obProduct) 327 { 328 this.errorCode = -1; 329 } 330 this.obPict = BX(this.visual.PICT_ID); 331 this.obPictSub = BX(this.visual.PICT_SUB_ID); 332 if (!this.obPict) 333 { 334 this.errorCode = -2; 335 } 336 else 337 { 338 this.obPictAligner = this.obPict.parentNode; 339 } 340 341 if (this.config.showPrice) 342 { 343 this.obPrice.price = BX(this.visual.PRICE_ID); 344 if (!this.obPrice.price && this.config.useCatalog) 345 { 346 this.errorCode = -16; 347 } 348 this.obBasketActions = BX(this.visual.BASKET_ACTIONS_ID); 349 if (!!this.obBasketActions) 350 { 351 if (BX.util.in_array('BUY', this.config.basketAction) || BX.util.in_array('ADD', this.config.basketAction)) 352 { 353 this.obBuyBtn = BX(this.visual.BUY_ID); 354 } 355 } 356 this.obNotAvail = BX(this.visual.NOT_AVAILABLE_MESS); 357 } 358 359 if (this.config.showQuantity) 360 { 361 this.obQuantity = BX(this.visual.QUANTITY_ID); 362 if (!!this.visual.QUANTITY_UP_ID) 363 { 364 this.obQuantityUp = BX(this.visual.QUANTITY_UP_ID); 365 } 366 if (!!this.visual.QUANTITY_DOWN_ID) 367 { 368 this.obQuantityDown = BX(this.visual.QUANTITY_DOWN_ID); 369 } 370 if (this.config.showBasisPrice) 371 { 372 this.obBasisPrice = BX(this.visual.BASIS_PRICE); 373 } 374 } 375 if (3 === this.productType) 376 { 377 if (!!this.visual.TREE_ID) 378 { 379 this.obTree = BX(this.visual.TREE_ID); 380 if (!this.obTree) 381 { 382 this.errorCode = -256; 383 } 384 strPrefix = this.visual.TREE_ITEM_ID; 385 for (i = 0; i < this.treeProps.length; i++) 386 { 387 this.obTreeRows[i] = { 388 LEFT: BX(strPrefix+this.treeProps[i].ID+'_left'), 389 RIGHT: BX(strPrefix+this.treeProps[i].ID+'_right'), 390 LIST: BX(strPrefix+this.treeProps[i].ID+'_list'), 391 CONT: BX(strPrefix+this.treeProps[i].ID+'_cont') 392 }; 393 if (!this.obTreeRows[i].LEFT || !this.obTreeRows[i].RIGHT || !this.obTreeRows[i].LIST || !this.obTreeRows[i].CONT) 394 { 395 this.errorCode = -512; 396 break; 397 } 398 } 399 } 400 if (!!this.visual.QUANTITY_MEASURE) 401 { 402 this.obMeasure = BX(this.visual.QUANTITY_MEASURE); 403 } 404 if (!!this.visual.QUANTITY_LIMIT) 405 { 406 this.obQuantityLimit.all = BX(this.visual.QUANTITY_LIMIT); 407 if (!!this.obQuantityLimit.all) 408 { 409 this.obQuantityLimit.value = BX.findChild(this.obQuantityLimit.all, {tagName: 'span'}, false, false); 410 if (!this.obQuantityLimit.value) 411 { 412 this.obQuantityLimit.all = null; 413 } 414 } 415 } 416 } 417 418 if (this.config.showSkuProps) 419 { 420 if (!!this.visual.DISPLAY_PROP_DIV) 421 { 422 this.obSkuProps = BX(this.visual.DISPLAY_PROP_DIV); 423 } 424 } 425 if (this.config.useCompare) 426 { 427 this.obCompare = BX(this.visual.COMPARE_LINK_ID); 428 } 429 if (0 === this.errorCode) 430 { 431 if (this.config.showQuantity) 432 { 433 if (!!this.obQuantityUp) 434 { 435 BX.bind(this.obQuantityUp, 'click', BX.delegate(this.QuantityUp, this)); 436 } 437 if (!!this.obQuantityDown) 438 { 439 BX.bind(this.obQuantityDown, 'click', BX.delegate(this.QuantityDown, this)); 440 } 441 if (!!this.obQuantity) 442 { 443 BX.bind(this.obQuantity, 'change', BX.delegate(this.QuantityChange, this)); 444 } 445 } 446 switch (this.productType) 447 { 448 case 0://no catalog 449 case 1://product 450 case 2://set 451 if (this.product.useSlider) 452 { 453 this.product.slider = { 454 COUNT: this.product.sliderCount, 455 ID: this.visual.SLIDER_CONT, 456 CONT: BX(this.visual.SLIDER_CONT), 457 LIST: BX(this.visual.SLIDER_LIST), 458 LEFT: BX(this.visual.SLIDER_LEFT), 459 RIGHT: BX(this.visual.SLIDER_RIGHT), 460 START: 0 461 }; 462 SliderImgs = BX.findChildren(this.product.slider.LIST, {tagName: 'li'}, true); 463 if (!!SliderImgs && 0 < SliderImgs.length) 464 { 465 for (j = 0; j < SliderImgs.length; j++) 466 { 467 BX.bind(SliderImgs[j], 'click', BX.delegate(this.ProductSelectSliderImg, this)); 468 } 469 } 470 if (!!this.product.slider.LEFT) 471 { 472 BX.bind(this.product.slider.LEFT, 'click', BX.delegate(this.ProductSliderRowLeft, this)); 473 BX.adjust(this.product.slider.LEFT, { style: this.sliderDisableArrow } ); 474 475 } 476 if (!!this.product.slider.RIGHT) 477 { 478 BX.bind(this.product.slider.RIGHT, 'click', BX.delegate(this.ProductSliderRowRight, this)); 479 BX.adjust(this.product.slider.RIGHT, { style: this.sliderEnableArrow } ); 480 } 481 this.setCurrentImg(this.product.sliderPict[0], true); 482 } 483 break; 484 case 3://sku 485 TreeItems = BX.findChildren(this.obTree, {tagName: 'div'}, true); 486 if (!!TreeItems && 0 < TreeItems.length) 487 { 488 for (i = 0; i < TreeItems.length; i++) 489 { 490 BX.bind(TreeItems[i], 'click', BX.delegate(this.SelectOfferProp, this)); 491 } 492 } 493 for (i = 0; i < this.obTreeRows.length; i++) 494 { 495 BX.bind(this.obTreeRows[i].LEFT, 'click', BX.delegate(this.RowLeft, this)); 496 BX.bind(this.obTreeRows[i].RIGHT, 'click', BX.delegate(this.RowRight, this)); 497 } 498 for (i = 0; i < this.offers.length; i++) 499 { 500 this.offers[i].SLIDER_COUNT = parseInt(this.offers[i].SLIDER_COUNT, 10); 501 if (isNaN(this.offers[i].SLIDER_COUNT)) 502 { 503 this.offers[i].SLIDER_COUNT = 0; 504 } 505 if (0 === this.offers[i].SLIDER_COUNT) 506 { 507 this.sliders[i] = { 508 COUNT: this.offers[i].SLIDER_COUNT, 509 ID: '' 510 }; 511 } 512 else 513 { 514 for (j = 0; j < this.offers[i].SLIDER.length; j++) 515 { 516 this.offers[i].SLIDER[j].WIDTH = parseInt(this.offers[i].SLIDER[j].WIDTH, 10); 517 this.offers[i].SLIDER[j].HEIGHT = parseInt(this.offers[i].SLIDER[j].HEIGHT, 10); 518 } 519 this.sliders[i] = { 520 COUNT: this.offers[i].SLIDER_COUNT, 521 OFFER_ID: this.offers[i].ID, 522 ID: this.visual.SLIDER_CONT_OF_ID+this.offers[i].ID, 523 CONT: BX(this.visual.SLIDER_CONT_OF_ID+this.offers[i].ID), 524 LIST: BX(this.visual.SLIDER_LIST_OF_ID+this.offers[i].ID), 525 LEFT: BX(this.visual.SLIDER_LEFT_OF_ID+this.offers[i].ID), 526 RIGHT: BX(this.visual.SLIDER_RIGHT_OF_ID+this.offers[i].ID), 527 START: 0 528 }; 529 SliderImgs = BX.findChildren(this.sliders[i].LIST, {tagName: 'div'}, true); 530 if (!!SliderImgs && 0 < SliderImgs.length) 531 { 532 for (j = 0; j < SliderImgs.length; j++) 533 { 534 BX.bind(SliderImgs[j], 'click', BX.delegate(this.SelectSliderImg, this)); 535 } 536 } 537 if (!!this.sliders[i].LEFT) 538 { 539 BX.bind(this.sliders[i].LEFT, 'click', BX.delegate(this.SliderRowLeft, this)); 540 } 541 if (!!this.sliders[i].RIGHT) 542 { 543 BX.bind(this.sliders[i].RIGHT, 'click', BX.delegate(this.SliderRowRight, this)); 544 } 545 } 546 if (!!this.obBasketActions) { 547 var buyButton = BX(this.visual.BUY_ID + this.offers[i].ID); 548 if (BX.util.in_array('ADD', this.config.basketAction)) 549 BX.bind(buyButton, 'click', BX.proxy(this.Add2Basket, this)); 550 else 551 BX.bind(buyButton, 'click', BX.proxy(this.BuyBasket, this)); 552 } 553 if (!!this.config.useCompare) 554 { 555 var obOfferCompare = BX(this.visual.COMPARE_LINK_ID + this.offers[i].ID); 556 if (!!obOfferCompare) { 557 BX.bind(obOfferCompare, 'click', BX.proxy(this.Compare, this)); 558 } 559 } 560 } 561 this.SetCurrent(); 562 break; 563 } 564 565 if (3 != this.productType) { 566 if (BX.util.in_array('ADD', this.config.basketAction)) { 567 BX.bind(this.obBuyBtn, 'click', BX.proxy(this.Add2Basket, this)); 568 } else { 569 BX.bind(this.obBuyBtn, 'click', BX.proxy(this.BuyBasket, this)); 570 } 571 if (!!this.obCompare) { 572 BX.bind(this.obCompare, 'click', BX.proxy(this.Compare, this)); 573 } 574 } 575 576 this.setMainPictHandler(); 577 } 578}; 579 580window.JCCatalogElement.prototype.initConfig = function() 581{ 582 this.productType = parseInt(this.params.PRODUCT_TYPE, 10); 583 if (!!this.params.CONFIG && typeof(this.params.CONFIG) === 'object') 584 { 585 if (this.params.CONFIG.USE_CATALOG !== 'undefined' && BX.type.isBoolean(this.params.CONFIG.USE_CATALOG)) 586 { 587 this.config.useCatalog = this.params.CONFIG.USE_CATALOG;
588 } 589 this.config.showQuantity = !!this.params.CONFIG.SHOW_QUANTITY; 590 this.config.showPrice = !!this.params.CONFIG.SHOW_PRICE; 591 this.config.showPercent = !!this.params.CONFIG.SHOW_DISCOUNT_PERCENT; 592 this.config.showOldPrice = !!this.params.CONFIG.SHOW_OLD_PRICE; 593 this.config.showSkuProps = !!this.params.CONFIG.SHOW_SKU_PROPS; 594 this.config.showOfferGroup = !!this.params.CONFIG.OFFER_GROUP; 595 this.config.useCompare = !!this.params.CONFIG.DISPLAY_COMPARE; 596 if (!!this.params.CONFIG.MAIN_PICTURE_MODE) 597 { 598 this.config.mainPictureMode = this.params.CONFIG.MAIN_PICTURE_MODE; 599 } 600 this.config.showBasisPrice = !!this.params.CONFIG.SHOW_BASIS_PRICE; 601 if (!!this.params.CONFIG.ADD_TO_BASKET_ACTION) 602 { 603 this.config.basketAction = this.params.CONFIG.ADD_TO_BASKET_ACTION; 604 } 605 this.config.showClosePopup = !!this.params.CONFIG.SHOW_CLOSE_POPUP; 606 this.config.economyHtml = this.params.VISUAL.ECONOMY_HTML; 607 } 608 else 609 { 610 // old version 611 if (this.params.USE_CATALOG !== 'undefined' && BX.type.isBoolean(this.params.USE_CATALOG)) 612 { 613 this.config.useCatalog = this.params.USE_CATALOG; 614 } 615 this.config.showQuantity = !!this.params.SHOW_QUANTITY; 616 this.config.showPrice = !!this.params.SHOW_PRICE; 617 this.config.showPercent = !!this.params.SHOW_DISCOUNT_PERCENT; 618 this.config.showOldPrice = !!this.params.SHOW_OLD_PRICE; 619 this.config.showSkuProps = !!this.params.SHOW_SKU_PROPS; 620 this.config.showOfferGroup = !!this.params.OFFER_GROUP; 621 this.config.useCompare = !!this.params.DISPLAY_COMPARE; 622 if (!!this.params.MAIN_PICTURE_MODE) 623 { 624 this.config.mainPictureMode = this.params.MAIN_PICTURE_MODE; 625 } 626 this.config.showBasisPrice = !!this.params.SHOW_BASIS_PRICE; 627 if (!!this.params.ADD_TO_BASKET_ACTION) 628 { 629 this.config.basketAction = this.params.ADD_TO_BASKET_ACTION; 630 } 631 this.config.showClosePopup = !!this.params.SHOW_CLOSE_POPUP; 632 } 633 634 if (!this.params.VISUAL || typeof(this.params.VISUAL) !== 'object' || !this.params.VISUAL.ID) 635 { 636 this.errorCode = -1; 637 return; 638 } 639 this.visual.ID = this.params.VISUAL.ID; 640 this.initVisualParams('main'); 641 if (this.config.showQuantity) 642 { 643 this.initVisualParams('quantity'); 644 } 645 if (this.config.showPrice) 646 { 647 this.initVisualParams('price'); 648 } 649 if (this.config.showOldPrice) 650 { 651 this.initVisualParams('oldPrice'); 652 } 653 if (this.config.showPercent) 654 { 655 this.initVisualParams('discountPerc'); 656 } 657 this.initVisualParams('basket'); 658 if (this.config.mainPictureMode === 'MAGNIFIER') 659 { 660 this.initVisualParams('magnifier'); 661 } 662 if (this.config.useCompare) 663 { 664 this.initVisualParams('compare'); 665 } 666}; 667 668window.JCCatalogElement.prototype.initVisualParams = function(ID) 669{ 670 var i = 0, 671 key = ''; 672 673 if (!this.listID[ID]) 674 { 675 this.errorCode = -1; 676 return; 677 } 678 for (i = 0; i < this.listID[ID].length; i++) 679 { 680 key = this.listID[ID][i]; 681 this.visual[key] = (!!this.params.VISUAL[key] ? this.params.VISUAL[key] : this.visual.ID+this.visualPostfix[key]); 682 } 683}; 684 685window.JCCatalogElement.prototype.initProductData = function() 686{ 687 var j = 0; 688 this.initVisualParams('productSlider'); 689 if (!!this.params.PRODUCT && 'object' === typeof(this.params.PRODUCT)) 690 { 691 if (this.config.showQuantity) 692 { 693 this.product.checkQuantity = this.params.PRODUCT.CHECK_QUANTITY; 694 this.product.isDblQuantity = this.params.PRODUCT.QUANTITY_FLOAT; 695 if (this.product.checkQuantity) 696 { 697 this.product.maxQuantity = (this.product.isDblQuantity ? parseFloat(this.params.PRODUCT.MAX_QUANTITY) : parseInt(this.params.PRODUCT.MAX_QUANTITY, 10)); 698 } 699 this.product.stepQuantity = (this.product.isDblQuantity ? parseFloat(this.params.PRODUCT.STEP_QUANTITY) : parseInt(this.params.PRODUCT.STEP_QUANTITY, 10)); 700 701 this.checkQuantity = this.product.checkQuantity; 702 this.isDblQuantity = this.product.isDblQuantity; 703 this.maxQuantity = this.product.maxQuantity; 704 this.stepQuantity = this.product.stepQuantity; 705 if (this.isDblQuantity) 706 { 707 this.stepQuantity = Math.round(this.stepQuantity*this.precisionFactor)/this.precisionFactor; 708 } 709 } 710 this.product.canBuy = this.params.PRODUCT.CAN_BUY; 711 this.product.canSubscription = this.params.PRODUCT.SUBSCRIPTION; 712 if (this.config.showPrice) 713 { 714 this.currentBasisPrice = this.params.PRODUCT.BASIS_PRICE; 715 if (!!this.params.PRODUCT.PRICES && BX.type.isArray(this.params.PRODUCT.PRICES)) { 716 this.currentPrices = this.params.PRODUCT.PRICES; 717 } 718 } 719 720 this.canBuy = this.product.canBuy; 721 this.canSubscription = this.product.canSubscription; 722 723 this.product.name = this.params.PRODUCT.NAME; 724 this.product.pict = this.params.PRODUCT.PICT; 725 this.product.id = this.params.PRODUCT.ID; 726 727 if (!!this.params.PRODUCT.ADD_URL) 728 { 729 this.product.addUrl = this.params.PRODUCT.ADD_URL; 730 } 731 if (!!this.params.PRODUCT.BUY_URL) 732 { 733 this.product.buyUrl = this.params.PRODUCT.BUY_URL; 734 } 735 736 if (!!this.params.PRODUCT.SLIDER_COUNT) 737 { 738 this.product.sliderCount = parseInt(this.params.PRODUCT.SLIDER_COUNT, 10); 739 if (isNaN(this.product.sliderCount)) 740 { 741 this.product.sliderCount = 0; 742 } 743 if (0 < this.product.sliderCount && !!this.params.PRODUCT.SLIDER.length && 0 < this.params.PRODUCT.SLIDER.length) 744 { 745 for (j = 0; j < this.params.PRODUCT.SLIDER.length; j++) 746 { 747 this.product.useSlider = true; 748 this.params.PRODUCT.SLIDER[j].WIDTH = parseInt(this.params.PRODUCT.SLIDER[j].WIDTH, 10); 749 this.params.PRODUCT.SLIDER[j].HEIGHT = parseInt(this.params.PRODUCT.SLIDER[j].HEIGHT, 10); 750 } 751 this.product.sliderPict = this.params.PRODUCT.SLIDER; 752 this.setCurrentImg(this.product.sliderPict[0], false); 753 } 754 } 755 this.currentIsSet = true; 756 } 757 else 758 { 759 this.errorCode = -1; 760 } 761}; 762 763window.JCCatalogElement.prototype.initOffersData = function() 764{ 765 this.initVisualParams('offerSlider'); 766 this.initVisualParams('offers'); 767 if (!!this.params.OFFERS && BX.type.isArray(this.params.OFFERS)) 768 { 769 this.offers = this.params.OFFERS; 770 this.offerNum = 0; 771 if (!!this.params.OFFER_SELECTED) 772 { 773 this.offerNum = parseInt(this.params.OFFER_SELECTED, 10); 774 } 775 if (isNaN(this.offerNum)) 776 { 777 this.offerNum = 0; 778 } 779 if (!!this.params.TREE_PROPS) 780 { 781 this.treeProps = this.params.TREE_PROPS; 782 } 783 if (!!this.params.DEFAULT_PICTURE) 784 { 785 this.defaultPict.preview = this.params.DEFAULT_PICTURE.PREVIEW_PICTIRE; 786 this.defaultPict.detail = this.params.DEFAULT_PICTURE.DETAIL_PICTURE; 787 } 788 if (!!this.params.PRODUCT && typeof(this.params.PRODUCT) === 'object') 789 { 790 this.product.id = parseInt(this.params.PRODUCT.ID, 10); 791 this.product.name = this.params.PRODUCT.NAME; 792 } 793 } 794 else 795 { 796 this.errorCode = -1; 797 } 798}; 799 800window.JCCatalogElement.prototype.initBasketData = function() 801{ 802 if (!!this.params.BASKET && 'object' === typeof(this.params.BASKET)) 803 { 804 if (1 === this.productType || 2 === this.productType) 805 { 806 this.basketData.useProps = !!this.params.BASKET.ADD_PROPS; 807 this.basketData.emptyProps = !!this.params.BASKET.EMPTY_PROPS; 808 } 809 810 if (!!this.params.BASKET.QUANTITY) 811 { 812 this.basketData.quantity = this.params.BASKET.QUANTITY; 813 } 814 if (!!this.params.BASKET.PROPS) 815 { 816 this.basketData.props = this.params.BASKET.PROPS; 817 } 818 if (!!this.params.BASKET.BASKET_URL) 819 { 820 this.basketData.basketUrl = this.params.BASKET.BASKET_URL; 821 } 822 if (3 === this.productType) 823 { 824 if (!!this.params.BASKET.SKU_PROPS) 825 { 826 this.basketData.sku_props = this.params.BASKET.SKU_PROPS; 827 } 828 } 829 if (!!this.params.BASKET.ADD_URL_TEMPLATE) 830 { 831 this.basketData.add_url = this.params.BASKET.ADD_URL_TEMPLATE; 832 } 833 if (!!this.params.BASKET.BUY_URL_TEMPLATE) 834 { 835 this.basketData.buy_url = this.params.BASKET.BUY_URL_TEMPLATE; 836 } 837 if (this.basketData.add_url === '' && this.basketData.buy_url === '') 838 { 839 this.errorCode = -1024; 840 } 841 } 842}; 843 844window.JCCatalogElement.prototype.initCompareData = function() 845{ 846 if (this.config.useCompare) 847 { 848 if (!!this.params.COMPARE && typeof(this.params.COMPARE) === 'object') 849 { 850 if (!!this.params.COMPARE.COMPARE_PATH) 851 { 852 this.compareData.comparePath = this.params.COMPARE.COMPARE_PATH; 853 } 854 if (!!this.params.COMPARE.COMPARE_URL_TEMPLATE) 855 { 856 this.compareData.compareUrl = this.params.COMPARE.COMPARE_URL_TEMPLATE; 857 } 858 else 859 {
860 this.config.useCompare = false; 861 } 862 } 863 else 864 { 865 this.config.useCompare = false; 866 } 867 } 868}; 869 870window.JCCatalogElement.prototype.setMainPictHandler = function() 871{ 872 switch (this.config.mainPictureMode) 873 { 874 case 'GALLERY': 875 break; 876 case 'MAGNIFIER': 877 this.magnify.obBigImg = BX(this.visual.BIG_IMG_CONT_ID); 878 this.magnify.obBigSlider = BX(this.visual.BIG_SLIDER_ID); 879 if (!!this.magnify.obBigImg && !!this.magnify.obBigSlider) 880 { 881 this.magnify.obMagnifyArea = this.obPictAligner.appendChild(BX.create( 882 'DIV', 883 { 884 props: { 885 id: this.visual.MAGNIFIER_AREA_ID, 886 className: 'bx_item_slider_lupe_small' 887 }, 888 style: { 889 display: 'none', 890 top: 0, 891 left: 0, 892 width: '100px', 893 height: '130px' 894 }, 895 events: { 896 mouseover: BX.delegate(this.onMagnifierArea, this), 897 mouseout: BX.delegate(function(){this.outMagnifierArea(); this.hideMagnifier(); }, this) 898 } 899 } 900 )); 901 902 this.magnify.obMagnifier = this.magnify.obBigSlider.appendChild(BX.create( 903 'DIV', 904 { 905 props: { 906 id: this.visual.MAGNIFIER_ID, 907 className: 'bx_item_slider_lupe' 908 }, 909 style: { 910 display: 'none' 911 } 912 } 913 )); 914 this.magnify.obMagnifyPict = this.magnify.obMagnifier.appendChild(BX.create( 915 'IMG', 916 { 917 props: { 918 src: this.currentImg.src 919 } 920 } 921 )); 922 BX.bind(this.obPict, 'mouseover', BX.delegate(this.showMagnifier, this)); 923 } 924 break; 925 case 'POPUP': 926 this.obPopupPict = new BX.PopupWindow('CatalogElementPopup_'+this.visual.ID, null, { 927 autoHide: false, 928 offsetLeft: 0, 929 offsetTop: 0, 930 overlay : false, 931 closeByEsc: true, 932 titleBar: true, 933 closeIcon: {top: '10px', right: '10px'} 934 }); 935 BX.bind(this.obPict, 'click', BX.delegate(this.showMainPictPopup, this)); 936 BX.adjust(this.obPict, { style: { cursor: 'pointer' } }); 937 BX.addCustomEvent(this.obPopupPict, "onAfterPopupShow", BX.proxy(this.onPopupWindowShow, this)); 938 BX.addCustomEvent(this.obPopupPict, "onPopupClose", BX.proxy(this.onPopupWindowClose, this)); 939 break; 940 default: 941 break; 942 } 943}; 944 945window.JCCatalogElement.prototype.setCurrentImg = function(img, showImage) 946{ 947 showImage = !!showImage; 948 this.currentImg.src = img.SRC; 949 this.currentImg.width = img.WIDTH; 950 this.currentImg.height = img.HEIGHT; 951 if (showImage && !!this.obPict) 952 { 953 BX.adjust(this.obPict, { props: { src: this.currentImg.src } }); 954 BX.adjust(this.obPictSub, { props: { src: this.currentImg.src } }); 955 } 956}; 957 958window.JCCatalogElement.prototype.scaleImg = function(src, dest) 959{ 960 var 961 scaleX, 962 scaleY, 963 scale, 964 result = {}; 965 966 if (dest.width >= src.width && dest.height >= src.height) 967 { 968 result.width = src.width; 969 result.height = src.height; 970 } 971 else 972 { 973 scaleX = dest.width/src.width; 974 scaleY = dest.height/src.height; 975 scale = Math.min(scaleX, scaleY); 976 result.width = Math.max(1, parseInt(scale*src.width , 10)); 977 result.height = Math.max(1, parseInt(scale*src.height , 10)); 978 } 979 return result; 980}; 981 982window.JCCatalogElement.prototype.showMagnifier = function(e) 983{ 984 if (!this.magnify.magnifyShow) 985 { 986 this.calcMagnifierParams(); 987 this.calcMagnifyAreaSize(); 988 this.calcMagnifyAreaPos(e); 989 this.calcMagnifyPictSize(); 990 this.calcMagnifyPictPos(); 991 this.setMagnifyAreaParams(true); 992 this.setMagnifyPictParams(true); 993 this.setMagnifierParams(true); 994 BX.bind(document, 'mousemove', BX.proxy(this.moveMagnifierArea, this)); 995 } 996}; 997 998window.JCCatalogElement.prototype.hideMagnifier = function() 999{ 1000 if (!this.magnify.magnifyShow) 1001 { 1002 if (!!this.magnify.obMagnifier) 1003 { 1004 BX.adjust(this.magnify.obMagnifier, { style: { display: 'none' } }); 1005 } 1006 if (!!this.magnify.obMagnifyArea) 1007 { 1008 BX.adjust(this.magnify.obMagnifyArea, { style: { display: 'none' } }); 1009 } 1010 BX.unbind(document, 'mousemove', BX.proxy(this.moveMagnifierArea, this)); 1011 } 1012}; 1013 1014window.JCCatalogElement.prototype.moveMagnifierArea = function(e) 1015{ 1016 var 1017 currentPos = { 1018 X: 0, 1019 Y: 0 1020 }, 1021 posBigImg = BX.pos(this.obPict), 1022 intersect = {}, 1023 params = {}, 1024 paramsPict = {}; 1025 1026 currentPos = this.inRect(e, posBigImg); 1027 if (this.inBound(posBigImg, currentPos)) 1028 { 1029 intersect = this.intersectArea(currentPos, posBigImg); 1030 switch (intersect.X) 1031 { 1032 case -1: 1033 this.magnify.areaParams.left = this.currentImg.screenOffsetX; 1034 break; 1035 case 0: 1036 this.magnify.areaParams.left = this.currentImg.screenOffsetX + currentPos.X - (this.magnify.areaParams.width >>> 1); 1037 break; 1038 case 1: 1039 this.magnify.areaParams.left = this.currentImg.screenOffsetX + posBigImg.width - this.magnify.areaParams.width; 1040 break; 1041 } 1042 switch (intersect.Y) 1043 { 1044 case -1: 1045 this.magnify.areaParams.top = 0; 1046 break; 1047 case 0: 1048 this.magnify.areaParams.top = currentPos.Y - (this.magnify.areaParams.height >>> 1); 1049 break; 1050 case 1: 1051 this.magnify.areaParams.top = posBigImg.height - this.magnify.areaParams.height; 1052 break; 1053 } 1054 this.magnify.magnifyPictParams.marginLeft = -parseInt(((this.magnify.areaParams.left-this.currentImg.screenOffsetX)*this.currentImg.scale), 10); 1055 this.magnify.magnifyPictParams.marginTop = -parseInt(((this.magnify.areaParams.top)*this.currentImg.scale), 10); 1056 params.left = this.magnify.areaParams.left+'px'; 1057 params.top = this.magnify.areaParams.top+'px'; 1058 BX.adjust(this.magnify.obMagnifyArea, { style: params }); 1059 paramsPict.marginLeft = this.magnify.magnifyPictParams.marginLeft+'px'; 1060 paramsPict.marginTop = this.magnify.magnifyPictParams.marginTop+'px'; 1061 BX.adjust(this.magnify.obMagnifyPict, { style: paramsPict }); 1062 } 1063 else 1064 { 1065 this.outMagnifierArea(); 1066 this.hideMagnifier(); 1067 } 1068}; 1069 1070window.JCCatalogElement.prototype.onMagnifierArea = function() 1071{ 1072 this.magnify.magnifyShow = true; 1073}; 1074 1075window.JCCatalogElement.prototype.outMagnifierArea = function() 1076{ 1077 this.magnify.magnifyShow = false;
1078}; 1079 1080window.JCCatalogElement.prototype.calcMagnifierParams = function() 1081{ 1082 if (!!this.magnify.obBigImg) 1083 { 1084 var pos = BX.pos(this.magnify.obBigImg, true); 1085 1086 this.magnify.magnifierParams.width = pos.width; 1087 this.magnify.magnifierParams.height = pos.height; 1088 this.magnify.magnifierParams.top = pos.top; 1089 this.magnify.magnifierParams.left = pos.left + pos.width + 2; 1090 } 1091}; 1092 1093window.JCCatalogElement.prototype.setMagnifierParams = function(show) 1094{ 1095 if (!!this.magnify.obMagnifier) 1096 { 1097 show = !!show; 1098 var params = { 1099 top: this.magnify.magnifierParams.top+'px', 1100 left: this.magnify.magnifierParams.left+'px', 1101 width: this.magnify.magnifierParams.width+'px', 1102 height: this.magnify.magnifierParams.height+'px' 1103 }; 1104 if (show) 1105 { 1106 params.display = ''; 1107 } 1108 BX.adjust(this.magnify.obMagnifier, { style: params }); 1109 } 1110}; 1111 1112window.JCCatalogElement.prototype.setMagnifyAreaParams = function(show) 1113{ 1114 if (!!this.magnify.obMagnifier) 1115 { 1116 show = !!show; 1117 var params = { 1118 top: this.magnify.areaParams.top+'px', 1119 left: this.magnify.areaParams.left+'px', 1120 width: this.magnify.areaParams.width+'px', 1121 height: this.magnify.areaParams.height+'px' 1122 }; 1123 if (show) 1124 { 1125 params.display = ''; 1126 } 1127 BX.adjust(this.magnify.obMagnifyArea, { style: params }); 1128 } 1129}; 1130 1131window.JCCatalogElement.prototype.calcMagnifyAreaPos = function(e) 1132{ 1133 var currentPos, 1134 posBigImg, 1135 intersect; 1136 1137 posBigImg = BX.pos(this.obPict); 1138 currentPos = this.inRect(e, posBigImg); 1139 if (this.inBound(posBigImg, currentPos)) 1140 { 1141 intersect = this.intersectArea(currentPos, posBigImg); 1142 switch (intersect.X) 1143 { 1144 case -1: 1145 this.magnify.areaParams.left = this.currentImg.screenOffsetX; 1146 break; 1147 case 0: 1148 this.magnify.areaParams.left = this.currentImg.screenOffsetX + currentPos.X - (this.magnify.areaParams.width >>> 1); 1149 break; 1150 case 1: 1151 this.magnify.areaParams.left = this.currentImg.screenOffsetX + posBigImg.width - this.magnify.areaParams.width; 1152 break; 1153 } 1154 switch (intersect.Y) 1155 { 1156 case -1: 1157 this.magnify.areaParams.top = 0; 1158 break; 1159 case 0: 1160 this.magnify.areaParams.top = currentPos.Y - (this.magnify.areaParams.height >>> 1); 1161 break; 1162 case 1: 1163 this.magnify.areaParams.top = posBigImg.height - this.magnify.areaParams.height; 1164 break; 1165 } 1166 } 1167}; 1168 1169window.JCCatalogElement.prototype.inBound = function(rect, point) 1170{ 1171 return ((0 <= point.Y && rect.height >= point.Y) && (0 <= point.X && rect.width >= point.X)); 1172}; 1173 1174window.JCCatalogElement.prototype.inRect = function(e, rect) 1175{ 1176 var wndSize = BX.GetWindowSize(), 1177 currentPos = { 1178 X: 0, 1179 Y: 0, 1180 globalX: 0, 1181 globalY: 0 1182 }; 1183 1184 currentPos.globalX = e.clientX + wndSize.scrollLeft; 1185 currentPos.X = currentPos.globalX - rect.left; 1186 currentPos.globalY = e.clientY + wndSize.scrollTop; 1187 currentPos.Y = currentPos.globalY - rect.top; 1188 return currentPos; 1189}; 1190 1191window.JCCatalogElement.prototype.intersectArea = function(currentPos, rect) 1192{ 1193 var intersect = { 1194 X: 0, 1195 Y: 0 1196 }, 1197 halfX = this.magnify.areaParams.width >>> 1, 1198 halfY = this.magnify.areaParams.height >>> 1; 1199 1200 if (currentPos.X <= halfX) 1201 { 1202 intersect.X = -1; 1203 } 1204 else if (currentPos.X >= (rect.width - halfX)) 1205 { 1206 intersect.X = 1; 1207 } 1208 else 1209 { 1210 intersect.X = 0; 1211 } 1212 if (currentPos.Y <= halfY) 1213 { 1214 intersect.Y = -1; 1215 } 1216 else if (currentPos.Y >= (rect.height - halfY)) 1217 { 1218 intersect.Y = 1; 1219 } 1220 else 1221 { 1222 intersect.Y = 0; 1223 } 1224 1225 return intersect; 1226}; 1227 1228window.JCCatalogElement.prototype.calcMagnifyAreaSize = function() 1229{ 1230 var scaleX, 1231 scaleY, 1232 scale; 1233 1234 if ( 1235 this.magnify.magnifierParams.width < this.currentImg.width && 1236 this.magnify.magnifierParams.height < this.currentImg.height 1237 ) 1238 { 1239 scaleX = this.magnify.obBigImg.offsetWidth/this.currentImg.width; 1240 scaleY = this.magnify.obBigImg.offsetHeight/this.currentImg.height; 1241 scale = Math.min(scaleX, scaleY); 1242 this.currentImg.scale = 1/scale; 1243 this.magnify.areaParams.width = Math.max(1, parseInt(scale*this.magnify.magnifierParams.width , 10)); 1244 this.magnify.areaParams.height = Math.max(1, parseInt(scale*this.magnify.magnifierParams.height , 10)); 1245 this.magnify.areaParams.scaleFactor = this.magnify.magnifierParams.defaultScale; 1246 } 1247 else 1248 { 1249 scaleX = this.obPict.offsetWidth/this.magnify.obBigImg.offsetWidth; 1250 scaleY = this.obPict.offsetHeight/this.magnify.obBigImg.offsetHeight; 1251 scale = Math.min(scaleX, scaleY); 1252 this.currentImg.scale = 1/scale; 1253 this.magnify.areaParams.width = Math.max(1, parseInt(scale*this.magnify.magnifierParams.width , 10)); 1254 this.magnify.areaParams.height = Math.max(1, parseInt(scale*this.magnify.magnifierParams.height , 10)); 1255 1256 scaleX = this.magnify.magnifierParams.width/this.currentImg.width; 1257 scaleY = this.magnify.magnifierParams.height/this.currentImg.height; 1258 scale = Math.max(scaleX, scaleY); 1259 this.magnify.areaParams.scaleFactor = scale; 1260 } 1261}; 1262 1263window.JCCatalogElement.prototype.calcMagnifyPictSize = function() 1264{ 1265 this.magnify.magnifyPictParams.width = this.currentImg.width*this.magnify.areaParams.scaleFactor; 1266 this.magnify.magnifyPictParams.height = this.currentImg.height*this.magnify.areaParams.scaleFactor; 1267}; 1268
1269window.JCCatalogElement.prototype.calcMagnifyPictPos = function() 1270{ 1271 this.magnify.magnifyPictParams.marginLeft = -parseInt(((this.magnify.areaParams.left-this.currentImg.screenOffsetX)*this.currentImg.scale), 10); 1272 this.magnify.magnifyPictParams.marginTop = -parseInt(((this.magnify.areaParams.top)*this.currentImg.scale), 10); 1273}; 1274 1275window.JCCatalogElement.prototype.setMagnifyPictParams = function(show) 1276{ 1277 if (!!this.magnify.obMagnifier) 1278 { 1279 show = !!show; 1280 var params = { 1281 width: this.magnify.magnifyPictParams.width+'px', 1282 height: this.magnify.magnifyPictParams.height+'px', 1283 marginTop: this.magnify.magnifyPictParams.marginTop+'px', 1284 marginLeft: this.magnify.magnifyPictParams.marginLeft+'px' 1285 }; 1286 if (show) 1287 { 1288 params.display = ''; 1289 } 1290 BX.adjust(this.magnify.obMagnifyPict, { style: params, props: { src: this.currentImg.src } }); 1291 } 1292}; 1293 1294window.JCCatalogElement.prototype.ProductSliderRowLeft = function() 1295{ 1296 var target = BX.proxy_context; 1297 if (!!target) 1298 { 1299 if (this.sliderRowShowSize < this.product.slider.COUNT) 1300 { 1301 if (0 > this.product.slider.START) 1302 { 1303 this.product.slider.START++; 1304 BX.adjust(this.product.slider.LIST, { style: { marginLeft: this.product.slider.START*20+'%' }}); 1305 BX.adjust(this.product.slider.RIGHT, { style: this.sliderEnableArrow }); 1306 } 1307 1308 if (0 <= this.product.slider.START) 1309 { 1310 BX.adjust(this.product.slider.LEFT, { style: this.sliderDisableArrow }); 1311 } 1312 } 1313 } 1314}; 1315 1316window.JCCatalogElement.prototype.ProductSliderRowRight = function() 1317{ 1318 var target = BX.proxy_context; 1319 if (!!target) 1320 { 1321 if (this.sliderRowShowSize < this.product.slider.COUNT) 1322 { 1323 if ((this.sliderRowShowSize - this.product.slider.START) < this.product.slider.COUNT) 1324 { 1325 this.product.slider.START--; 1326 BX.adjust(this.product.slider.LIST, { style: { marginLeft: this.product.slider.START*20+'%' }}); 1327 BX.adjust(this.product.slider.LEFT, { style: this.sliderEnableArrow } ); 1328 } 1329 1330 if ((this.sliderRowShowSize - this.product.slider.START) >= this.product.slider.COUNT) 1331 { 1332 BX.adjust(this.product.slider.RIGHT, { style: this.sliderDisableArrow } ); 1333 } 1334 } 1335 } 1336}; 1337 1338window.JCCatalogElement.prototype.ProductSelectSliderImg = function() 1339{ 1340 var strValue = '', 1341 target = BX.proxy_context; 1342 if (!!target && target.hasAttribute('data-value')) 1343 { 1344 strValue = target.getAttribute('data-value'); 1345 this.SetProductMainPict(strValue); 1346 } 1347}; 1348 1349window.JCCatalogElement.prototype.SetProductMainPict = function(intPict) 1350{ 1351 var indexPict = -1, 1352 i = 0, 1353 j = 0, 1354 value = '', 1355 strValue = '', 1356 RowItems = null; 1357 1358 if (0 < this.product.sliderCount) 1359 { 1360 for (j = 0; j < this.product.sliderPict.length; j++) 1361 { 1362 if (intPict === this.product.sliderPict[j].ID) 1363 { 1364 indexPict = j; 1365 break; 1366 } 1367 } 1368 if (-1 < indexPict) 1369 { 1370 if (!!this.product.sliderPict[indexPict]) 1371 { 1372 this.setCurrentImg(this.product.sliderPict[indexPict], true); 1373 } 1374 RowItems = BX.findChildren(this.product.slider.LIST, {tagName: 'div'}, false); 1375 if (!!RowItems && 0 < RowItems.length) 1376 { 1377 strValue = intPict; 1378 for (i = 0; i < RowItems.length; i++) 1379 { 1380 value = RowItems[i].getAttribute('data-value'); 1381 if (value === strValue) 1382 { 1383 BX.addClass(RowItems[i], 'bx_active'); 1384 } 1385 else 1386 { 1387 BX.removeClass(RowItems[i], 'bx_active'); 1388 } 1389 } 1390 } 1391 } 1392 } 1393}; 1394 1395window.JCCatalogElement.prototype.SliderRowLeft = function() 1396{ 1397 var strValue = '', 1398 index = -1, 1399 i, 1400 target = BX.proxy_context; 1401 if (!!target && target.hasAttribute('data-value')) 1402 { 1403 strValue = target.getAttribute('data-value'); 1404 for (i = 0; i < this.sliders.length; i++) 1405 { 1406 if (this.sliders[i].OFFER_ID === strValue) 1407 { 1408 index = i; 1409 break; 1410 } 1411 } 1412 if (-1 < index && this.sliderRowShowSize < this.sliders[index].COUNT) 1413 { 1414 if (0 > this.sliders[index].START) 1415 { 1416 this.sliders[index].START++; 1417 BX.adjust(this.sliders[index].LIST, { style: { marginLeft: this.sliders[index].START*20+'%' }}); 1418 BX.adjust(this.sliders[index].RIGHT, { style: this.sliderEnableArrow }); 1419 } 1420 1421 if (0 <= this.sliders[index].START) 1422 { 1423 BX.adjust(this.sliders[index].LEFT, { style: this.sliderDisableArrow }); 1424 } 1425 } 1426 } 1427}; 1428 1429window.JCCatalogElement.prototype.SliderRowRight = function() 1430{ 1431 var strValue = '', 1432 index = -1, 1433 i, 1434 target = BX.proxy_context; 1435 if (!!target && target.hasAttribute('data-value')) 1436 { 1437 strValue = target.getAttribute('data-value'); 1438 for (i = 0; i < this.sliders.length; i++) 1439 { 1440 if (this.sliders[i].OFFER_ID === strValue) 1441 { 1442 index = i; 1443 break; 1444 } 1445 } 1446 if (-1 < index && this.sliderRowShowSize < this.sliders[index].COUNT) 1447 { 1448 if ((this.sliderRowShowSize - this.sliders[index].START) < this.sliders[index].COUNT) 1449 { 1450 this.sliders[index].START--; 1451 BX.adjust(this.sliders[index].LIST, { style: { marginLeft: this.sliders[index].START*20+'%' }}); 1452 BX.adjust(this.sliders[index].LEFT, { style: this.sliderEnableArrow } ); 1453 } 1454 1455 if ((this.sliderRowShowSize - this.sliders[index].START) >= this.sliders[index].COUNT) 1456 { 1457 BX.adjust(this.sliders[index].RIGHT, { style: this.sliderDisableArrow } ); 1458 } 1459 } 1460 } 1461}; 1462 1463window.JCCatalogElement.prototype.SelectSliderImg = function() 1464{ 1465 var strValue = '', 1466 arItem = [], 1467 target = BX.proxy_context; 1468 if (!!target && target.hasAttribute('data-value')) 1469 { 1470 strValue = target.getAttribute('data-value'); 1471 arItem = strValue.split('_'); 1472 this.SetMainPict(arItem[0], arItem[1]); 1473 } 1474}; 1475 1476window.JCCatalogElement.prototype.SetMainPict = function(intSlider, intPict) 1477{ 1478 var index = -1, 1479 indexPict = -1, 1480 i, 1481 j, 1482 value = '', 1483 RowItems = null, 1484 strValue = ''; 1485 1486 for (i = 0; i < this.offers.length; i++) 1487 { 1488 if (intSlider === this.offers[i].ID) 1489 { 1490 index = i; 1491 break; 1492 } 1493 } 1494 if (-1 < index) 1495 { 1496 if (0 < this.offers[index].SLIDER_COUNT) 1497 { 1498 for (j = 0; j < this.offers[index].SLIDER.length; j++) 1499 { 1500 if (intPict === this.offers[index].SLIDER[j].ID) 1501 { 1502 indexPict = j; 1503 break; 1504 } 1505 } 1506 if (-1 < indexPict) 1507 { 1508 if (!!this.offers[index].SLIDER[indexPict]) 1509 { 1510 this.setCurrentImg(this.offers[index].SLIDER[indexPict], true); 1511 } 1512 RowItems = BX.findChildren(this.sliders[index].LIST, {tagName: 'div'}, false); 1513 if (!!RowItems && 0 < RowItems.length) 1514 { 1515 strValue = intSlider+'_'+intPict; 1516 for (i = 0; i < RowItems.length; i++) 1517 { 1518 value = RowItems[i].getAttribute('data-value'); 1519 if (value === strValue) 1520 { 1521 BX.addClass(RowItems[i], 'bx_active'); 1522 } 1523 else 1524 { 1525 BX.removeClass(RowItems[i], 'bx_active'); 1526 } 1527 } 1528 } 1529 } 1530 } 1531 } 1532}; 1533 1534window.JCCatalogElement.prototype.SetMainPictFromItem = function(index) 1535{ 1536 if (!!this.obPict) 1537 { 1538 var boolSet = false, 1539 obNewPict = {}; 1540 1541 if (!!this.offers[index]) 1542 { 1543 if (!!this.offers[index].DETAIL_PICTURE) 1544 { 1545 obNewPict = this.offers[index].DETAIL_PICTURE; 1546 boolSet = true; 1547 } 1548 else if (!!this.offers[index].PREVIEW_PICTURE) 1549 { 1550 obNewPict = this.offers[index].PREVIEW_PICTURE; 1551 boolSet = true; 1552 } 1553 } 1554 if (!boolSet) 1555 { 1556 if (!!this.defaultPict.detail) 1557 { 1558 obNewPict = this.defaultPict.detail; 1559 boolSet = true; 1560 } 1561 else if (!!this.defaultPict.preview) 1562 { 1563 obNewPict = this.defaultPict.preview; 1564 boolSet = true; 1565 } 1566 } 1567 if (boolSet) 1568 { 1569 this.setCurrentImg(obNewPict, true); 1570 } 1571 } 1572}; 1573 1574window.JCCatalogElement.prototype.showMainPictPopup = function(e) 1575{ 1576 var pictContent = ''; 1577 1578 pictContent = '<div style="text-align: center;"><img src="'+ 1579 this.currentImg.src+ 1580 '" width="'+this.currentImg.width+'" height="'+this.currentImg.height+'" name=""></div>'; 1581 this.obPopupPict.setContent(pictContent); 1582 this.obPopupPict.show(); 1583 return BX.PreventDefault(e); 1584}; 1585 1586window.JCCatalogElement.prototype.QuantityUp = function() 1587{ 1588 var curValue = 0, 1589 boolSet = true,
1590 calcPrice; 1591 1592 if (0 === this.errorCode && this.config.showQuantity && this.canBuy) 1593 { 1594 curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10)); 1595 if (!isNaN(curValue)) 1596 { 1597 curValue += this.stepQuantity; 1598 if (this.checkQuantity) 1599 { 1600 if (curValue > this.maxQuantity) 1601 { 1602 boolSet = false; 1603 } 1604 } 1605 1606 if (boolSet) 1607 { 1608 if (this.isDblQuantity) 1609 { 1610 curValue = Math.round(curValue*this.precisionFactor)/this.precisionFactor; 1611 } 1612 this.obQuantity.value = curValue; 1613 calcPrice = { 1614 ECONOMY: this.currentBasisPrice.ECONOMY * curValue, 1615 DISCOUNT_VALUE: this.currentBasisPrice.DISCOUNT_VALUE * curValue, 1616 VALUE: this.currentBasisPrice.VALUE * curValue, 1617 DISCOUNT_DIFF: this.currentBasisPrice.DISCOUNT_DIFF * curValue, 1618 DISCOUNT_DIFF_PERCENT: this.currentBasisPrice.DISCOUNT_DIFF_PERCENT, 1619 CURRENCY: this.currentBasisPrice.CURRENCY, 1620 PRICES: [], 1621 }; 1622 if (this.currentPrices != undefined && this.currentPrices.length > 1) { 1623 for (i = 0; i < this.currentPrices.length; i++) 1624 { 1625 calcPrice.PRICES[i] = { 1626 TITLE: this.currentPrices[i].TITLE, 1627 CURRENCY: this.currentPrices[i].CURRENCY, 1628 ECONOMY: this.currentPrices[i].ECONOMY * curValue, 1629 DISCOUNT_VALUE: this.currentPrices[i].DISCOUNT_VALUE * curValue, 1630 VALUE: this.currentPrices[i].VALUE * curValue 1631 }; 1632 } 1633 } 1634 this.setPrice(calcPrice); 1635 } 1636 } 1637 } 1638 //ÐÑогÑамма лоÑлÑноÑÑи 1639 if(window.ITRElementBonus){ 1640 bonusElemUp.UpdateBonus(curValue); // curvalue - колиÑеÑÑво ÑоваÑа 1641 } 1642}; 1643 1644window.JCCatalogElement.prototype.QuantityDown = function() 1645{ 1646 var curValue = 0, 1647 boolSet = true, 1648 calcPrice; 1649 1650 if (0 === this.errorCode && this.config.showQuantity && this.canBuy) 1651 { 1652 curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10)); 1653 if (!isNaN(curValue)) 1654 { 1655 curValue -= this.stepQuantity; 1656 if (curValue < this.stepQuantity) 1657 { 1658 boolSet = false; 1659 } 1660 if (boolSet) 1661 { 1662 if (this.isDblQuantity) 1663 { 1664 curValue = Math.round(curValue*this.precisionFactor)/this.precisionFactor; 1665 } 1666 this.obQuantity.value = curValue; 1667 calcPrice = { 1668 ECONOMY: this.currentBasisPrice.ECONOMY * curValue, 1669 DISCOUNT_VALUE: this.currentBasisPrice.DISCOUNT_VALUE * curValue, 1670 VALUE: this.currentBasisPrice.VALUE * curValue, 1671 DISCOUNT_DIFF: this.currentBasisPrice.DISCOUNT_DIFF * curValue, 1672 DISCOUNT_DIFF_PERCENT: this.currentBasisPrice.DISCOUNT_DIFF_PERCENT, 1673 CURRENCY: this.currentBasisPrice.CURRENCY, 1674 PRICES: [], 1675 }; 1676 if (this.currentPrices != undefined && this.currentPrices.length > 1) { 1677 for (i = 0; i < this.currentPrices.length; i++) 1678 { 1679 calcPrice.PRICES[i] = { 1680 TITLE: this.currentPrices[i].TITLE, 1681 CURRENCY: this.currentPrices[i].CURRENCY, 1682 ECONOMY: this.currentPrices[i].ECONOMY * curValue, 1683 DISCOUNT_VALUE: this.currentPrices[i].DISCOUNT_VALUE * curValue, 1684 VALUE: this.currentPrices[i].VALUE * curValue 1685 }; 1686 } 1687 } 1688 this.setPrice(calcPrice); 1689 } 1690 } 1691 } 1692 //ÐÑогÑамма лоÑлÑноÑÑи 1693 if(window.ITRElementBonus){ 1694 bonusElemUp.UpdateBonus(curValue); // curvalue - колиÑеÑÑво ÑоваÑа 1695 } 1696}; 1697 1698window.JCCatalogElement.prototype.QuantityChange = function() 1699{ 1700 var curValue = 0, 1701 calcPrice, 1702 intCount, 1703 count; 1704 1705 if (0 === this.errorCode && this.config.showQuantity) 1706 { 1707 if (this.canBuy) 1708 { 1709 curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10)); 1710 if (!isNaN(curValue)) 1711 { 1712 if (this.checkQuantity) 1713 { 1714 if (curValue > this.maxQuantity) 1715 { 1716 curValue = this.maxQuantity; 1717 } 1718 } 1719 if (curValue < this.stepQuantity) 1720 { 1721 curValue = this.stepQuantity; 1722 } 1723 else 1724 { 1725 count = Math.round((curValue*this.precisionFactor)/this.stepQuantity)/this.precisionFactor; 1726 intCount = parseInt(count, 10); 1727 if (isNaN(intCount)) 1728 { 1729 intCount = 1; 1730 count = 1.1; 1731 } 1732 if (count > intCount) 1733 { 1734 curValue = (intCount <= 1 ? this.stepQuantity : intCount*this.stepQuantity); 1735 curValue = Math.round(curValue*this.precisionFactor)/this.precisionFactor; 1736 } 1737 } 1738 this.obQuantity.value = curValue; 1739 } 1740 else 1741 {
1742 this.obQuantity.value = this.stepQuantity; 1743 } 1744 } 1745 else 1746 { 1747 this.obQuantity.value = this.stepQuantity; 1748 } 1749 calcPrice = { 1750 ECONOMY: this.currentBasisPrice.ECONOMY * this.obQuantity.value, 1751 DISCOUNT_VALUE: this.currentBasisPrice.DISCOUNT_VALUE * this.obQuantity.value, 1752 VALUE: this.currentBasisPrice.VALUE * this.obQuantity.value, 1753 DISCOUNT_DIFF: this.currentBasisPrice.DISCOUNT_DIFF * this.obQuantity.value, 1754 DISCOUNT_DIFF_PERCENT: this.currentBasisPrice.DISCOUNT_DIFF_PERCENT, 1755 CURRENCY: this.currentBasisPrice.CURRENCY, 1756 PRICES: [], 1757 }; 1758 if (this.currentPrices != undefined && this.currentPrices.length > 1) { 1759 for (i = 0; i < this.currentPrices.length; i++) 1760 { 1761 calcPrice.PRICES[i] = { 1762 TITLE: this.currentPrices[i].TITLE, 1763 CURRENCY: this.currentPrices[i].CURRENCY, 1764 ECONOMY: this.currentPrices[i].ECONOMY * this.obQuantity.value, 1765 DISCOUNT_VALUE: this.currentPrices[i].DISCOUNT_VALUE * this.obQuantity.value, 1766 VALUE: this.currentPrices[i].VALUE * this.obQuantity.value 1767 }; 1768 } 1769 } 1770 this.setPrice(calcPrice); 1771 } 1772 //ÐÑогÑамма лоÑлÑноÑÑи 1773 if(window.ITRElementBonus){ 1774 bonusElemUp.UpdateBonus(curValue); // curvalue - колиÑеÑÑво ÑоваÑа 1775 } 1776}; 1777 1778window.JCCatalogElement.prototype.QuantitySet = function(index) 1779{ 1780 var basisPrice = '', 1781 strLimit; 1782 if (this.errorCode === 0) 1783 { 1784 this.canBuy = this.offers[index].CAN_BUY; 1785 if (this.canBuy) 1786 { 1787 if (!!this.obBasketActions) 1788 { 1789 BX.style(this.obBasketActions, 'display', ''); 1790 } 1791 if (!!this.obNotAvail) 1792 { 1793 BX.style(this.obNotAvail, 'display', 'none'); 1794 } 1795 } 1796 else 1797 { 1798 if (!!this.obBasketActions) 1799 { 1800 BX.style(this.obBasketActions, 'display', 'none'); 1801 } 1802 if (!!this.obNotAvail) 1803 { 1804 BX.style(this.obNotAvail, 'display', ''); 1805 } 1806 } 1807 if (this.config.showQuantity) 1808 { 1809 this.isDblQuantity = this.offers[index].QUANTITY_FLOAT; 1810 this.checkQuantity = this.offers[index].CHECK_QUANTITY; 1811 if (this.isDblQuantity) 1812 { 1813 this.maxQuantity = parseFloat(this.offers[index].MAX_QUANTITY); 1814 this.stepQuantity = Math.round(parseFloat(this.offers[index].STEP_QUANTITY)*this.precisionFactor)/this.precisionFactor; 1815 } 1816 else 1817 { 1818 this.maxQuantity = parseInt(this.offers[index].MAX_QUANTITY, 10); 1819 this.stepQuantity = parseInt(this.offers[index].STEP_QUANTITY, 10); 1820 } 1821 this.obQuantity.value = this.stepQuantity; 1822 this.obQuantity.disabled = !this.canBuy; 1823 if (!!this.obMeasure) 1824 { 1825 if (!!this.offers[index].MEASURE) 1826 { 1827 BX.adjust(this.obMeasure, { html : this.offers[index].MEASURE}); 1828 } 1829 else 1830 { 1831 BX.adjust(this.obMeasure, { html : ''}); 1832 } 1833 } 1834 if (!!this.obQuantityLimit.all) 1835 { 1836 if (!this.checkQuantity) 1837 { 1838 BX.adjust(this.obQuantityLimit.value, { html: '' }); 1839 BX.adjust(this.obQuantityLimit.all, { style: {display: 'none'} }); 1840 } 1841 else 1842 { 1843 strLimit = this.offers[index].MAX_QUANTITY; 1844 if (!!this.offers[index].MEASURE) 1845 { 1846 strLimit += (' '+this.offers[index].MEASURE); 1847 } 1848 BX.adjust(this.obQuantityLimit.value, { html: strLimit}); 1849 BX.adjust(this.obQuantityLimit.all, { style: {display: ''} }); 1850 } 1851 } 1852 if (!!this.obBasisPrice) 1853 { 1854 if (!!this.offers[index].BASIS_PRICE) 1855 { 1856 basisPrice = BX.message('BASIS_PRICE_MESSAGE'); 1857 basisPrice = basisPrice.replace( 1858 '#PRICE#', 1859 BX.Currency.currencyFormat(this.offers[index].BASIS_PRICE.DISCOUNT_VALUE, this.offers[index].BASIS_PRICE.CURRENCY, true) 1860 ); 1861 basisPrice = basisPrice.replace('#MEASURE#', this.offers[index].MEASURE); 1862 BX.adjust(this.obBasisPrice, { style: { display: '' }, html: basisPrice }); 1863 } 1864 else 1865 { 1866 BX.adjust(this.obBasisPrice, { style: { display: 'none' }, html: '' }); 1867 } 1868 } 1869 } 1870 this.currentBasisPrice = this.offers[index].BASIS_PRICE; 1871 this.currentPrices = this.offers[index].PRICES; 1872 } 1873}; 1874 1875window.JCCatalogElement.prototype.SelectOfferProp = function() 1876{ 1877 var i = 0, 1878 strTreeValue = '', 1879 arTreeItem = [], 1880 RowItems = null, 1881 target = BX.proxy_context; 1882 1883 if (!!target && target.hasAttribute('data-treevalue')) 1884 { 1885 if (typeof(document.activeElement) === 'object') 1886 document.activeElement.blur(); 1887 strTreeValue = target.getAttribute('data-treevalue'); 1888 arTreeItem = strTreeValue.split('_'); 1889 this.SearchOfferPropIndex(arTreeItem[0], arTreeItem[1]); 1890 RowItems = BX.findChildren(target.parentNode, {tagName: 'div'}, false); 1891 if (!!RowItems && 0 < RowItems.length) 1892 { 1893 for (i = 0; i < RowItems.length; i++) 1894 { 1895 BX.removeClass(RowItems[i], 'bx_active'); 1896 } 1897 } 1898 BX.addClass(target, 'bx_active'); 1899 } 1900}; 1901 1902window.JCCatalogElement.prototype.SearchOfferPropIndex = function(strPropID, strPropValue) 1903{ 1904 var strName = '', 1905 arShowValues = false, 1906 arCanBuyValues = [], 1907 allValues = [], 1908 index = -1, 1909 i, j, 1910 arFilter = {}, 1911 tmpFilter = []; 1912 1913 for (i = 0; i < this.treeProps.length; i++) 1914 { 1915 if (this.treeProps[i].ID === strPropID) 1916 { 1917 index = i; 1918 break; 1919 } 1920 } 1921 1922 if (-1 < index) 1923 { 1924 for (i = 0; i < index; i++) 1925 { 1926 strName = 'PROP_'+this.treeProps[i].ID; 1927 arFilter[strName] = this.selectedValues[strName]; 1928 } 1929 strName = 'PROP_'+this.treeProps[index].ID; 1930 arFilter[strName] = strPropValue; 1931 for (i = index+1; i < this.treeProps.length; i++) 1932 { 1933 strName = 'PROP_'+this.treeProps[i].ID; 1934 arShowValues = this.GetRowValues(arFilter, strName); 1935 if (!arShowValues) 1936 { 1937 break; 1938 } 1939 allValues = []; 1940 if (this.config.showAbsent) 1941 { 1942 arCanBuyValues = []; 1943 tmpFilter = []; 1944 tmpFilter = BX.clone(arFilter, true); 1945 for (j = 0; j < arShowValues.length; j++) 1946 { 1947 tmpFilter[strName] = arShowValues[j]; 1948 allValues[allValues.length] = arShowValues[j]; 1949 if (this.GetCanBuy(tmpFilter)) 1950 arCanBuyValues[arCanBuyValues.length] = arShowValues[j]; 1951 } 1952 } 1953 else 1954 {
1955 arCanBuyValues = arShowValues; 1956 } 1957 if (!!this.selectedValues[strName] && BX.util.in_array(this.selectedValues[strName], arCanBuyValues)) 1958 { 1959 arFilter[strName] = this.selectedValues[strName]; 1960 } 1961 else 1962 { 1963 if (this.config.showAbsent) 1964 arFilter[strName] = (arCanBuyValues.length > 0 ? arCanBuyValues[0] : allValues[0]); 1965 else 1966 arFilter[strName] = arCanBuyValues[0]; 1967 } 1968 this.UpdateRow(i, arFilter[strName], arShowValues, arCanBuyValues); 1969 } 1970 this.selectedValues = arFilter; 1971 this.ChangeInfo(); 1972 } 1973}; 1974 1975window.JCCatalogElement.prototype.RowLeft = function() 1976{ 1977 var strTreeValue = '', 1978 index = -1, 1979 i, 1980 target = BX.proxy_context; 1981 if (!!target && target.hasAttribute('data-treevalue')) 1982 { 1983 strTreeValue = target.getAttribute('data-treevalue'); 1984 for (i = 0; i < this.treeProps.length; i++) 1985 { 1986 if (this.treeProps[i].ID === strTreeValue) 1987 { 1988 index = i; 1989 break; 1990 } 1991 } 1992 if (-1 < index && this.treeRowShowSize < this.showCount[index]) 1993 { 1994 if (0 > this.showStart[index]) 1995 { 1996 this.showStart[index]++; 1997 BX.adjust(this.obTreeRows[index].LIST, { style: { marginLeft: this.showStart[index]*20+'%' }}); 1998 BX.adjust(this.obTreeRows[index].RIGHT, { style: this.treeEnableArrow }); 1999 } 2000 2001 if (0 <= this.showStart[index]) 2002 { 2003 BX.adjust(this.obTreeRows[index].LEFT, { style: this.treeDisableArrow }); 2004 } 2005 } 2006 } 2007}; 2008 2009window.JCCatalogElement.prototype.RowRight = function() 2010{ 2011 var strTreeValue = '', 2012 index = -1, 2013 i, 2014 target = BX.proxy_context; 2015 if (!!target && target.hasAttribute('data-treevalue')) 2016 { 2017 strTreeValue = target.getAttribute('data-treevalue'); 2018 for (i = 0; i < this.treeProps.length; i++) 2019 { 2020 if (this.treeProps[i].ID === strTreeValue) 2021 { 2022 index = i; 2023 break; 2024 } 2025 } 2026 if (-1 < index && this.treeRowShowSize < this.showCount[index]) 2027 { 2028 if ((this.treeRowShowSize - this.showStart[index]) < this.showCount[index]) 2029 { 2030 this.showStart[index]--; 2031 BX.adjust(this.obTreeRows[index].LIST, { style: { marginLeft: this.showStart[index]*20+'%' }}); 2032 BX.adjust(this.obTreeRows[index].LEFT, { style: this.treeEnableArrow }); 2033 } 2034 2035 if ((this.treeRowShowSize - this.showStart[index]) >= this.showCount[index]) 2036 { 2037 BX.adjust(this.obTreeRows[index].RIGHT, { style: this.treeDisableArrow }); 2038 } 2039 } 2040 } 2041}; 2042 2043window.JCCatalogElement.prototype.UpdateRow = function(intNumber, activeID, showID, canBuyID) 2044{ 2045 var i = 0, 2046 showI = 0, 2047 value = '', 2048 dataTreeVal = '', 2049 countShow = 0, 2050 strNewLen = '', 2051 obData = {}, 2052 RowItems = null, 2053 pictMode = false, 2054 extShowMode = false, 2055 isCurrent = false, 2056 selectIndex = 0, 2057 obLeft = this.treeEnableArrow, 2058 obRight = this.treeEnableArrow, 2059 currentShowStart = 0; 2060 2061 if (-1 < intNumber && intNumber < this.obTreeRows.length) 2062 { 2063 RowItems = BX.findChildren(this.obTreeRows[intNumber].LIST, {tagName: 'div'}, false); 2064 if (!!RowItems && 0 < RowItems.length) 2065 { 2066 pictMode = ('PICT' === this.treeProps[intNumber].SHOW_MODE); 2067 countShow = showID.length; 2068 extShowMode = this.treeRowShowSize < countShow; 2069 strNewLen = 'auto'; 2070 obData = { 2071 props: { className: '' }, 2072 style: { 2073 width: strNewLen 2074 } 2075 }; 2076 if (pictMode) 2077 { 2078 obData.style.paddingTop = strNewLen; 2079 } 2080 obData.style.lineHeight = '0'; 2081 for (i = 0; i < RowItems.length; i++) 2082 { 2083 value = RowItems[i].getAttribute('data-onevalue'); 2084 dataTreeVal = RowItems[i].getAttribute('data-treevalue'); 2085 isCurrent = (value === activeID); 2086 if (BX.util.in_array(value, canBuyID)) 2087 { 2088 obData.props.className = (isCurrent ? 'inline-block-item bx_active' : 'inline-block-item'); 2089 if (isCurrent) { 2090 $('#id_' + this.visual.ID + '_' + dataTreeVal).attr('checked', 'checked'); 2091 } else { 2092 $('#id_' + this.visual.ID + '_' + dataTreeVal).removeAttr('checked'); 2093 } 2094 } 2095 else 2096 { 2097 obData.props.className = (isCurrent ? 'inline-block-item bx_active bx_missing' : 'inline-block-item bx_missing'); 2098 if (isCurrent) { 2099 $('#id_' + this.visual.ID + '_' + dataTreeVal).attr('checked', 'checked'); 2100 } else { 2101 $('#id_' + this.visual.ID + '_' + dataTreeVal).removeAttr('checked'); 2102 } 2103 } 2104 obData.style.display = 'none'; 2105 if (BX.util.in_array(value, showID)) 2106 { 2107 obData.style.display = ''; 2108 if (isCurrent) 2109 { 2110 selectIndex = showI; 2111 } 2112 showI++; 2113 } 2114 BX.adjust(RowItems[i], obData); 2115 } 2116 2117 obData = { 2118 style: { 2119 width: 'auto', 2120 } 2121 }; 2122 2123 /*if (pictMode) 2124 { 2125 BX.adjust(this.obTreeRows[intNumber].CONT, {props: {className: (extShowMode ? 'bx_item_detail_scu full' : 'bx_item_detail_scu')}}); 2126 } 2127 else 2128 {
2129 BX.adjust(this.obTreeRows[intNumber].CONT, {props: {className: (extShowMode < countShow ? 'bx_item_detail_size full' : 'bx_item_detail_size')}}); 2130 }*/ 2131 if (extShowMode) 2132 { 2133 if (selectIndex +1 === countShow) 2134 { 2135 obRight = this.treeDisableArrow; 2136 } 2137 if (this.treeRowShowSize <= selectIndex) 2138 { 2139 currentShowStart = this.treeRowShowSize - selectIndex - 1; 2140 } 2141 if (0 === currentShowStart) 2142 { 2143 obLeft = this.treeDisableArrow; 2144 } 2145 BX.adjust(this.obTreeRows[intNumber].LEFT, {style: obLeft }); 2146 BX.adjust(this.obTreeRows[intNumber].RIGHT, {style: obRight }); 2147 } 2148 else 2149 { 2150 BX.adjust(this.obTreeRows[intNumber].LEFT, {style: {display: 'none'}}); 2151 BX.adjust(this.obTreeRows[intNumber].RIGHT, {style: {display: 'none'}}); 2152 } 2153 BX.adjust(this.obTreeRows[intNumber].LIST, obData); 2154 this.showCount[intNumber] = countShow; 2155 this.showStart[intNumber] = currentShowStart; 2156 } 2157 } 2158}; 2159 2160window.JCCatalogElement.prototype.GetRowValues = function(arFilter, index) 2161{ 2162 var arValues = [], 2163 i = 0, 2164 j = 0, 2165 boolSearch = false, 2166 boolOneSearch = true; 2167 2168 if (0 === arFilter.length) 2169 { 2170 for (i = 0; i < this.offers.length; i++) 2171 { 2172 if (!BX.util.in_array(this.offers[i].TREE[index], arValues)) 2173 { 2174 arValues[arValues.length] = this.offers[i].TREE[index]; 2175 } 2176 } 2177 boolSearch = true; 2178 } 2179 else 2180 { 2181 for (i = 0; i < this.offers.length; i++) 2182 { 2183 boolOneSearch = true; 2184 for (j in arFilter) 2185 { 2186 if (arFilter[j] !== this.offers[i].TREE[j]) 2187 { 2188 boolOneSearch = false; 2189 break; 2190 } 2191 } 2192 if (boolOneSearch) 2193 { 2194 if (!BX.util.in_array(this.offers[i].TREE[index], arValues)) 2195 { 2196 arValues[arValues.length] = this.offers[i].TREE[index]; 2197 } 2198 boolSearch = true; 2199 } 2200 } 2201 } 2202 return (boolSearch ? arValues : false); 2203}; 2204 2205window.JCCatalogElement.prototype.GetCanBuy = function(arFilter) 2206{ 2207 var i = 0, 2208 j = 0, 2209 boolOneSearch = true, 2210 boolSearch = false; 2211 2212 for (i = 0; i < this.offers.length; i++) 2213 { 2214 boolOneSearch = true; 2215 for (j in arFilter) 2216 { 2217 if (arFilter[j] !== this.offers[i].TREE[j]) 2218 { 2219 boolOneSearch = false; 2220 break; 2221 } 2222 } 2223 if (boolOneSearch) 2224 { 2225 if (this.offers[i].CAN_BUY) 2226 { 2227 boolSearch = true; 2228 break; 2229 } 2230 } 2231 } 2232 return boolSearch; 2233}; 2234 2235window.JCCatalogElement.prototype.SetCurrent = function() 2236{ 2237 var i = 0, 2238 j = 0, 2239 strName = '', 2240 arShowValues = false, 2241 arCanBuyValues = [], 2242 arFilter = {}, 2243 tmpFilter = [], 2244 current = this.offers[this.offerNum].TREE; 2245 2246 for (i = 0; i < this.treeProps.length; i++) 2247 { 2248 strName = 'PROP_'+this.treeProps[i].ID; 2249 arShowValues = this.GetRowValues(arFilter, strName); 2250 if (!arShowValues) 2251 { 2252 break; 2253 } 2254 if (BX.util.in_array(current[strName], arShowValues)) 2255 { 2256 arFilter[strName] = current[strName]; 2257 } 2258 else 2259 { 2260 arFilter[strName] = arShowValues[0]; 2261 this.offerNum = 0; 2262 } 2263 if (this.config.showAbsent) 2264 { 2265 arCanBuyValues = []; 2266 tmpFilter = []; 2267 tmpFilter = BX.clone(arFilter, true); 2268 for (j = 0; j < arShowValues.length; j++) 2269 { 2270 tmpFilter[strName] = arShowValues[j]; 2271 if (this.GetCanBuy(tmpFilter)) 2272 { 2273 arCanBuyValues[arCanBuyValues.length] = arShowValues[j]; 2274 } 2275 } 2276 } 2277 else 2278 { 2279 arCanBuyValues = arShowValues; 2280 } 2281 this.UpdateRow(i, arFilter[strName], arShowValues, arCanBuyValues); 2282 } 2283 this.selectedValues = arFilter; 2284 this.ChangeInfo(); 2285}; 2286 2287window.JCCatalogElement.prototype.ChangeInfo = function() 2288{ 2289 var index = -1, 2290 i = 0, 2291 j = 0, 2292 boolOneSearch = true; 2293 2294 for (i = 0; i < this.offers.length; i++) 2295 { 2296 boolOneSearch = true; 2297 for (j in this.selectedValues) 2298 { 2299 if (this.selectedValues[j] !== this.offers[i].TREE[j]) 2300 { 2301 boolOneSearch = false; 2302 break; 2303 } 2304 } 2305 if (boolOneSearch) 2306 { 2307 index = i; 2308 break; 2309 } 2310 } 2311 if (-1 < index) 2312 { 2313 if (this.offers[index].PRICES != undefined && this.offers[index].PRICES.length > 1) { 2314 var currentPrices = this.offers[index].PRICES; 2315 this.offers[index].PRICE.PRICES = []; 2316 for (i = 0; i < currentPrices.length; i++) 2317 { 2318 this.offers[index].PRICE.PRICES[i] = { 2319 TITLE: currentPrices[i].TITLE, 2320 CURRENCY: currentPrices[i].CURRENCY, 2321 ECONOMY: currentPrices[i].ECONOMY, 2322 DISCOUNT_VALUE: currentPrices[i].DISCOUNT_VALUE, 2323 VALUE: currentPrices[i].VALUE 2324 }; 2325 } 2326 } 2327 this.setPrice(this.offers[index].PRICE); 2328 for (i = 0; i < this.offers.length; i++) 2329 { 2330 if (!!this.obBasketActions) { 2331 var buyButton = BX(this.visual.BUY_ID + this.offers[i].ID); 2332 if (i == index) { 2333 BX.adjust(buyButton, {style: {display: ''}}); 2334 } else { 2335 BX.adjust(buyButton, {style: {display: 'none'}}); 2336 } 2337 } 2338 if (this.config.showOfferGroup && this.offers[i].OFFER_GROUP) 2339 { 2340 if (i !== index) 2341 { 2342 BX.adjust(BX(this.visual.OFFER_GROUP+this.offers[i].ID), { style: {display: 'none'} }); 2343 } 2344 } 2345 if (!!this.sliders[i].ID) 2346 { 2347 if (i === index) 2348 { 2349 BX.adjust(this.sliders[i].CONT, {style: { display: ''}}); 2350 } 2351 else 2352 { 2353 BX.adjust(this.sliders[i].CONT, {style: { display: 'none'}}); 2354 } 2355 } 2356 this.obQuantityMax = BX(this.visual.QUANTITY_MAX + this.offers[i].ID); 2357 this.obArtnumber = BX(this.visual.ARTNUMBER_DIV + this.offers[i].ID); 2358 this.obPropTable = BX(this.visual.PROP_TABLE + this.offers[i].ID); 2359 this.obLikedCompare = BX(this.visual.LIKED_COMPARE_ID + this.offers[i].ID); 2360 this.obBuy1Click = BX(this.visual.BUY_1_CLICK_ID + this.offers[i].ID); 2361 this.obDescription = BX(this.visual.ARTNUMBER_DIV + this.offers[i].ID + '-detail'); 2362 2363 if (i === index) 2364 { 2365 if (!!this.obQuantityMax) { 2366 BX.adjust(this.obQuantityMax, {style: { display: ''}}); 2367 } 2368 if (!!this.obArtnumber) { 2369 BX.adjust(this.obArtnumber, {style: { display: ''}}); 2370 } 2371 if (this.config.showSkuProps && !!this.obPropTable) 2372 { 2373 BX.adjust(this.obPropTable, {style: { display: ''}}); 2374 } 2375 if (!!this.obLikedCompare) 2376 { 2377 BX.adjust(this.obLikedCompare, {style: { display: ''}}); 2378 } 2379 if (!!this.obBuy1Click) 2380 { 2381 BX.adjust(this.obBuy1Click, {style: { display: ''}}); 2382 } 2383 2384 if (!!this.obDescription) 2385 { 2386 BX.adjust(this.obDescription, {style: { display: ''}}); 2387 } 2388 } 2389 else 2390 { 2391 if (!!this.obQuantityMax) { 2392 BX.adjust(this.obQuantityMax, {style: { display: 'none'}}); 2393 } 2394 if (!!this.obArtnumber) { 2395 BX.adjust(this.obArtnumber, {style: { display: 'none'}}); 2396 } 2397 if (this.config.showSkuProps && !!this.obPropTable) 2398 { 2399 BX.adjust(this.obPropTable, {style: { display: 'none'}}); 2400 } 2401 if (!!this.obLikedCompare) 2402 { 2403 BX.adjust(this.obLikedCompare, {style: { display: 'none'}}); 2404 } 2405 if (!!this.obBuy1Click) 2406 { 2407 BX.adjust(this.obBuy1Click, {style: { display: 'none'}}); 2408 } 2409 if (!!this.obDescription) 2410 { 2411 BX.adjust(this.obDescription, {style: { display: 'none'}}); 2412 } 2413 } 2414 } 2415 if (this.config.showOfferGroup && this.offers[index].OFFER_GROUP) 2416 { 2417 BX.adjust(BX(this.visual.OFFER_GROUP+this.offers[index].ID), { style: {display: ''} }); 2418 } 2419 if (0 < this.offers[index].SLIDER_COUNT) 2420 { 2421 this.SetMainPict(this.offers[index].ID, this.offers[index].SLIDER[0].ID); 2422 } 2423 else 2424 { 2425 this.SetMainPictFromItem(index); 2426 } 2427 this.offerNum = index; 2428 this.QuantitySet(this.offerNum); 2429 2430 this.incViewedCounter(); 2431 if ($('#product_preview').length <= 0) { 2432 BX.onCustomEvent('onCatalogStoreProductChange', [this.offers[this.offerNum].ID]); 2433 } 2434 } 2435
2436 //ÐÑогÑамма лоÑлÑноÑÑи 2437 // if(window.ITRElementBonus){ 2438 // bonusElemUp.Update.params.PRODUCT_ID= this.offers[this.offerNum].ID; 2439 // где this.offers[this.offerNum].ID - ID вÑбÑанного ÑоÑгового пÑÐµÐ´Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ 2440 // bonusElemUp.UpdateBonus(1); 2441 // } 2442}; 2443 2444window.JCCatalogElement.prototype.setPrice = function(price) 2445{ 2446 var strPrice = ''; 2447 2448 if (!!this.obPrice.price) 2449 { 2450 var obActionEconomy = BX(this.visual.ACTION_ECONOMY_ID); 2451 if (price.PRICES != undefined && price.PRICES.length > 1) { 2452 for (i = 0; i < price.PRICES.length; i++) 2453 { 2454 strPrice += '<div class="product-price sale-price">'; 2455 strPrice += '<div class="product-info-caption">' + price.PRICES[i].TITLE + '</div>'; 2456 strPrice += '<div class="main">' + BX.Currency.currencyFormat(price.PRICES[i].DISCOUNT_VALUE, price.PRICES[i].CURRENCY, true) + '</div>'; 2457 if (this.config.showOldPrice && (price.PRICES[i].DISCOUNT_VALUE !== price.PRICES[i].VALUE)) 2458 { 2459 strPrice += '<div class="old">' + BX.Currency.currencyFormat(price.PRICES[i].VALUE, price.PRICES[i].CURRENCY, true) + '</div>'; 2460 strPrice += '<div class="economy">' + this.config.economyHtml.replace('#ECONOMY_PRICE#', BX.Currency.currencyFormat(price.PRICES[i].ECONOMY, price.PRICES[i].CURRENCY, true)) + '</div>'; 2461 } 2462 strPrice += '</div>'; 2463 } 2464 var j = price.PRICES.length - 1; 2465 if (!!obActionEconomy) { 2466 if (this.config.showOldPrice && (price.PRICES[j].DISCOUNT_VALUE !== price.PRICES[j].VALUE)) { 2467 BX.adjust(obActionEconomy, {html: BX.Currency.currencyFormat(price.PRICES[j].ECONOMY, price.PRICES[j].CURRENCY, true)}); 2468 } else { 2469 BX.adjust(obActionEconomy, {html: ''}); 2470 } 2471 } 2472 } else { 2473 strPrice += '<div class="product-price sale-price">'; 2474 strPrice += '<div class="main">' + BX.Currency.currencyFormat(price.DISCOUNT_VALUE, price.CURRENCY, true) + '</div>'; 2475 if (this.config.showOldPrice && (price.DISCOUNT_VALUE !== price.VALUE)) 2476 { 2477 strPrice += '<div class="old">' + BX.Currency.currencyFormat(price.VALUE, price.CURRENCY, true) + '</div>'; 2478 strPrice += '<div class="economy">' + this.config.economyHtml.replace('#ECONOMY_PRICE#', BX.Currency.currencyFormat(price.ECONOMY, price.CURRENCY, true)) + '</div>'; 2479 } 2480 strPrice += '</div>'; 2481 if (!!obActionEconomy) { 2482 if (this.config.showOldPrice && (price.DISCOUNT_VALUE !== price.VALUE)) { 2483 BX.adjust(obActionEconomy, {html: BX.Currency.currencyFormat(price.ECONOMY, price.CURRENCY, true)}); 2484 } else { 2485 BX.adjust(obActionEconomy, {html: ''}); 2486 } 2487 } 2488 } 2489 BX.adjust(this.obPrice.price, {html: strPrice}); 2490 } 2491}; 2492 2493window.JCCatalogElement.prototype.Compare = function() 2494{ 2495 var compareParams, compareLink; 2496 if (!!this.compareData.compareUrl) 2497 { 2498 switch (this.productType) 2499 { 2500 case 0://no catalog 2501 case 1://product 2502 case 2://set 2503 compareLink = this.compareData.compareUrl.replace('#ID#', this.product.id.toString()); 2504 break; 2505 case 3://sku 2506 compareLink = this.compareData.compareUrl.replace('#ID#', this.offers[this.offerNum].ID); 2507 break; 2508 } 2509 compareParams = { 2510 ajax_action: 'Y' 2511 }; 2512 BX.ajax.loadJSON( 2513 compareLink, 2514 compareParams, 2515 BX.proxy(this.CompareResult, this) 2516 ); 2517 } 2518}; 2519 2520window.JCCatalogElement.prototype.CompareResult = function(result) 2521{ 2522 var popupContent, popupButtons, popupTitle; 2523 if (!!this.obPopupWin) 2524 this.obPopupWin.close(); 2525 2526 if (typeof result !== 'object') 2527 return false; 2528 2529 if (result.STATUS === 'OK') 2530 { 2531 BX.onCustomEvent('OnCompareChange'); 2532 var compareUrl = (!!this.compareData.comparePath) ? this.compareData.comparePath : ''; 2533 switch (this.productType) 2534 { 2535 case 1:// 2536 case 2:// 2537 var productId = this.product.id; 2538 break; 2539 case 3: 2540 var productId = this.offers[this.offerNum].ID; 2541 break; 2542 } 2543 add2compare(productId, result.COUNT, BX.message('BTN_COMPARE_REDIRECT'), compareUrl); 2544 } 2545 return false;
2546}; 2547 2548window.JCCatalogElement.prototype.CompareRedirect = function() 2549{ 2550 if (!!this.compareData.comparePath) 2551 location.href = this.compareData.comparePath; 2552 else 2553 this.obPopupWin.close(); 2554}; 2555 2556window.JCCatalogElement.prototype.InitBasketUrl = function() 2557{ 2558 this.basketUrl = (this.basketMode === 'ADD' ? this.basketData.add_url : this.basketData.buy_url); 2559 switch (this.productType) 2560 { 2561 case 1://product 2562 case 2://set 2563 this.basketUrl = this.basketUrl.replace('#ID#', this.product.id.toString()); 2564 break; 2565 case 3://sku 2566 this.basketUrl = this.basketUrl.replace('#ID#', this.offers[this.offerNum].ID); 2567 break; 2568 } 2569 this.basketParams = { 2570 'ajax_basket': 'Y' 2571 }; 2572 if (this.config.showQuantity) 2573 { 2574 this.basketParams[this.basketData.quantity] = this.obQuantity.value; 2575 } 2576 if (!!this.basketData.sku_props) 2577 { 2578 this.basketParams[this.basketData.sku_props_var] = this.basketData.sku_props; 2579 } 2580}; 2581 2582window.JCCatalogElement.prototype.FillBasketProps = function() 2583{ 2584 if (!this.visual.BASKET_PROP_DIV) 2585 return; 2586 2587 var 2588 i = 0, 2589 propCollection = null, 2590 foundValues = false, 2591 obBasketProps = null; 2592 if (this.basketData.useProps && !this.basketData.emptyProps) 2593 { 2594 if (!!this.obPopupWin && !!this.obPopupWin.contentContainer) 2595 obBasketProps = this.obPopupWin.contentContainer; 2596 } 2597 else 2598 { 2599 obBasketProps = BX(this.visual.BASKET_PROP_DIV); 2600 } 2601 if (!!obBasketProps) 2602 { 2603 propCollection = obBasketProps.getElementsByTagName('select'); 2604 if (!!propCollection && !!propCollection.length) 2605 { 2606 for (i = 0; i < propCollection.length; i++) 2607 { 2608 if (!propCollection[i].disabled) 2609 { 2610 switch(propCollection[i].type.toLowerCase()) 2611 { 2612 case 'select-one': 2613 this.basketParams[propCollection[i].name] = propCollection[i].value; 2614 foundValues = true; 2615 break; 2616 default: 2617 break; 2618 } 2619 } 2620 } 2621 } 2622 propCollection = obBasketProps.getElementsByTagName('input'); 2623 if (!!propCollection && !!propCollection.length) 2624 { 2625 for (i = 0; i < propCollection.length; i++) 2626 { 2627 if (!propCollection[i].disabled) 2628 { 2629 switch(propCollection[i].type.toLowerCase()) 2630 { 2631 case 'hidden': 2632 this.basketParams[propCollection[i].name] = propCollection[i].value; 2633 foundValues = true; 2634 break; 2635 case 'radio': 2636 if (propCollection[i].checked) 2637 { 2638 this.basketParams[propCollection[i].name] = propCollection[i].value; 2639 foundValues = true; 2640 } 2641 break; 2642 default: 2643 break; 2644 } 2645 } 2646 } 2647 } 2648 } 2649 if (!foundValues) 2650 { 2651 this.basketParams[this.basketData.props] = []; 2652 this.basketParams[this.basketData.props][0] = 0; 2653 } 2654}; 2655 2656window.JCCatalogElement.prototype.SendToBasket = function() 2657{ 2658 if (!this.canBuy) 2659 return; 2660 2661 $.fancybox.helpers.overlay.open({ 2662 closeClick: false, 2663 parent: $('body'), 2664 }); 2665 $.fancybox.showLoading(); 2666 this.InitBasketUrl(); 2667 this.FillBasketProps(); 2668 BX.ajax.loadJSON( 2669 this.basketUrl, 2670 this.basketParams, 2671 BX.proxy(this.BasketResult, this) 2672 ); 2673}; 2674 2675window.JCCatalogElement.prototype.Add2Basket = function() 2676{ 2677 this.basketMode = 'ADD'; 2678 this.Basket(); 2679 console.log(this); 2680}; 2681 2682window.JCCatalogElement.prototype.BuyBasket = function() 2683{ 2684 this.basketMode = 'BUY'; 2685 this.Basket(); 2686}; 2687 2688window.JCCatalogElement.prototype.Basket = function() 2689{ 2690 var contentBasketProps = ''; 2691 if (!this.canBuy) 2692 return; 2693 2694 switch (this.productType) 2695 { 2696 case 1://product 2697 case 2://set 2698 var $self = $("#" + this.visual.BUY_ID); 2699 if (!$self.hasClass('in_basket')) { 2700 this.SendToBasket(); 2701 } 2702 break; 2703 case 3://sku 2704 var $self = $("#" + this.visual.BUY_ID + this.offers[this.offerNum].ID); 2705 if (!$self.hasClass('in_basket')) { 2706 this.SendToBasket(); 2707 } 2708 break; 2709 } 2710}; 2711 2712window.JCCatalogElement.prototype.BasketResult = function(arResult) 2713{ 2714 var popupContent, popupButtons, popupTitle, productPict; 2715 if (!!this.obPopupWin) 2716 this.obPopupWin.close(); 2717 2718 if (typeof arResult !== 'object') 2719 return false; 2720 2721 if (arResult.STATUS === 'OK' && this.basketMode === 'BUY') 2722 { 2723 this.BasketRedirect(); 2724 } 2725 else 2726 { 2727 var $self = null; 2728 if (arResult.STATUS === 'OK') 2729 { 2730 BX.onCustomEvent('OnBasketChange'); 2731 switch (this.productType) 2732 { 2733 case 1:// 2734 case 2:// 2735 productPict = this.product.pict.SRC; 2736 $self = $("#" + this.visual.BUY_ID); 2737 this.obBuyBtn.href = (!!this.basketData.basketUrl ? this.basketData.basketUrl : BX.message('BASKET_URL')); 2738 $("#" + this.visual.BUY_ID + " span").html(BX.message('ADD_TO_BASKET')); 2739 break; 2740 case 3: 2741 productPict = (!!this.offers[this.offerNum].PREVIEW_PICTURE ? 2742 this.offers[this.offerNum].PREVIEW_PICTURE.SRC : 2743 this.defaultPict.pict.SRC 2744 ); 2745 $self = $("#" + this.visual.BUY_ID + this.offers[this.offerNum].ID); 2746 var buyButton = BX(this.visual.BUY_ID + this.offers[this.offerNum].ID); 2747 buyButton.href = (!!this.basketData.basketUrl ? this.basketData.basketUrl : BX.message('BASKET_URL')); 2748 $("#" + this.visual.BUY_ID + this.offers[this.offerNum].ID + " span").html(BX.message('ADD_TO_BASKET')); 2749 break; 2750 } 2751 } 2752 preview2Basket($self); 2753 } 2754 $.fancybox.hideLoading(); 2755 if (!$self.parents('#product_preview').length) { 2756 $.fancybox.helpers.overlay.close(); 2757 } 2758 return false;
2759}; 2760 2761window.JCCatalogElement.prototype.BasketRedirect = function() 2762{ 2763 location.href = (!!this.basketData.basketUrl ? this.basketData.basketUrl : BX.message('BASKET_URL')); 2764}; 2765 2766window.JCCatalogElement.prototype.InitPopupWindow = function() 2767{ 2768 if (!!this.obPopupWin) 2769 return; 2770 2771 this.obPopupWin = BX.PopupWindowManager.create('CatalogElementBasket_'+this.visual.ID, null, { 2772 autoHide: false, 2773 offsetLeft: 0, 2774 offsetTop: 0, 2775 overlay : true, 2776 closeByEsc: true, 2777 titleBar: true, 2778 closeIcon: {top: '10px', right: '10px'} 2779 }); 2780}; 2781 2782window.JCCatalogElement.prototype.onPopupWindowShow = function(popup) 2783{ 2784 BX.bind(document, 'click', BX.proxy(this.popupWindowClick, this)); 2785}; 2786 2787window.JCCatalogElement.prototype.onPopupWindowClose = function(popup, event) 2788{ 2789 BX.unbind(document, 'click', BX.proxy(this.popupWindowClick, this)); 2790}; 2791 2792window.JCCatalogElement.prototype.popupWindowClick = function() 2793{ 2794 if (!!this.obPopupPict && typeof (this.obPopupPict) === 'object') 2795 { 2796 if (this.obPopupPict.isShown()) 2797 this.obPopupPict.close(); 2798 } 2799}; 2800 2801window.JCCatalogElement.prototype.incViewedCounter = function() 2802{ 2803 if (this.currentIsSet && !this.updateViewedCount) 2804 { 2805 switch (this.productType) 2806 { 2807 case 1: 2808 case 2: 2809 this.viewedCounter.params.PRODUCT_ID = this.product.id; 2810 this.viewedCounter.params.PARENT_ID = this.product.id; 2811 break; 2812 case 3: 2813 this.viewedCounter.params.PARENT_ID = this.product.id; 2814 this.viewedCounter.params.PRODUCT_ID = this.offers[this.offerNum].ID; 2815 break; 2816 default: 2817 return; 2818 } 2819 this.viewedCounter.params.SITE_ID = BX.message('SITE_ID'); 2820 this.updateViewedCount = true; 2821 BX.ajax.post( 2822 this.viewedCounter.path, 2823 this.viewedCounter.params, 2824 BX.delegate(function(){ this.updateViewedCount = false; }, this) 2825 ); 2826 } 2827}; 2828 2829window.JCCatalogElement.prototype.allowViewedCount = function(update) 2830{ 2831 update = !!update; 2832 this.currentIsSet = true; 2833 if (update) 2834 this.incViewedCounter(); 2835}; 2836window.JCCatalogStoreSKU = function(params) 2837{ 2838 var i; 2839 2840 if(!params) 2841 return; 2842 2843 this.config = { 2844 'id' : params.ID, 2845 'showEmptyStore' : params.SHOW_EMPTY_STORE, 2846 'useMinAmount' : params.USE_MIN_AMOUNT, 2847 'minAmount' : params.MIN_AMOUNT 2848 }; 2849 2850 this.messages = params.MESSAGES; 2851 this.sku = params.SKU; 2852 this.stores = params.STORES; 2853 this.obStores = {}; 2854 for (i in this.stores) 2855 this.obStores[this.stores[i]] = BX(this.config.id+"_"+this.stores[i]); 2856 if ($('#product_preview').length <= 0) { 2857 BX.addCustomEvent(window, "onCatalogStoreProductChange", BX.proxy(this.offerOnChange, this)); 2858 } 2859}; 2860 2861window.JCCatalogStoreSKU.prototype.offerOnChange = function(id) 2862{ 2863 var curSku = this.sku[id], 2864 k, 2865 message, 2866 parent; 2867 2868 for (k in this.obStores) 2869 { 2870 message = this.messages['ABSENT']; 2871 BX.adjust(this.obStores[k], {html: message}); 2872 if (!!curSku[k]) 2873 { 2874 message = curSku[k]; 2875 BX.adjust(this.obStores[k], {html: message}); 2876 } 2877 parent = BX.findParent(this.obStores[k], {tagName: 'li'}); 2878 if (!!this.config.showEmptyStore || curSku[k] > 0) 2879 BX.show(parent); 2880 else 2881 BX.hide(parent); 2882 } 2883}; 2884})(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.