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