1var AW_AjaxCartProConfig = { 2 actionsObservers: {}, 3 targetsToUpdate: {}, 4 data: {}, 5 addUpdater: function(a) { 6 this.targetsToUpdate[a.name] = a 7 }, 8 addObserver: function(a) { 9 this.actionsObservers[a.name] = a 10 }, 11 addSystemData: function(a) { 12 Object.extend(this.data, a) 13 } 14}; 15var AW_AjaxCartPro = { 16 config: AW_AjaxCartProConfig, 17 init: function(a) { 18 this.connector = AW_AjaxCartProConnector; 19 this.ui = AW_AjaxCartProUI; 20 this.config.addSystemData(a); 21 this.startObservers() 22 }, 23 registerUpdater: function(a) { 24 this.config.addUpdater(a) 25 }, 26 registerObserver: function(a) { 27 this.config.addObserver(a) 28 }, 29 startObservers: function(b) { 30 var c = this; 31 if (Object.isString(b)) { 32 var a = this.config.actionsObservers[b]; 33 if (a) { 34 a.run() 35 } 36 } else { 37 if (typeof(this.config.actionsObservers) == "object") { 38 Object.keys(this.config.actionsObservers).each(function(d) { 39 c.config.actionsObservers[d].run() 40 }) 41 } 42 } 43 }, 44 stopObservers: function(b) { 45 var c = this; 46 if (Object.isString(b)) { 47 var a = this.config.actionsObservers[b]; 48 if (a) { 49 a.stop() 50 } 51 } else { 52 if (typeof(this.config.actionsObservers) == "object") { 53 Object.keys(this.config.actionsObservers).each(function(d) { 54 c.config.actionsObservers[d].stop() 55 }) 56 } 57 } 58 }, 59 callUpdaters: function(c) { 60 var a = this; 61 var c = c || {}; 62 var b = true; 63 this.ui.beforeUpdate(a.msg); 64 Object.keys(c).each(function(f) { 65 if (!b || c[f] === null) { 66 return 67 } 68 var d = true; 69 try { 70 d = a.config.targetsToUpdate[f].update(c[f]) 71 } catch (g) { 72 d = false; 73 if (window.console) { 74 console.log(g.name) 75 } 76 } 77 b = b && d 78 }); 79 this.ui.afterUpdate(a.msg); 80 delete a.msg; 81 return b 82 }, 83 fire: function(b, d, a) { 84 if (b.indexOf("?") != -1) { 85 this.stopObservers(); 86 window.location = b; 87 return 88 } 89 if ($("shopping-cart-table") != null) { 90 if (a.name == "clickOnAddToCartInCategoryList") { 91 this.stopObservers(); 92 var e = $$("button.btn-continue").first(); 93 e.click(); 94 return 95 } 96 } 97 if ($("out-of-stock-sub") != null) { 98 if ($("out-of-stock-sub").visible()) { 99 this.stopObservers(); 100 document.getElementById("product_addtocart_form").submit(); 101 return 102 } 103 } 104 var c = this; 105 this.ui.observer = a; 106 this.ui.beforeFire(); 107 var d = d || {}; 108 d["block[]"] = []; 109 Object.keys(c.config.targetsToUpdate).each(function(f) { 110 if (c.config.targetsToUpdate[f].updateOnActionRequest) { 111 d["block[]"].push(f) 112 } 113 }); 114 this.connector.sendRequest(b, d, function(g) { 115 if (g.has_optional_selection === true) { 116 a.fireOriginal(b, d); 117 return; 118 } 119 var f = Object.values(g.block).without(null).length > 0; 120 if (f) { 121 var h = c.callUpdaters(g.block); 122 if (!h) { 123 document.location.reload(); 124 return; 125 } 126 c.stopObservers(); 127 c.startObservers(); 128 if (g.has_optional_selection == false ) { 129 c.ui.blocks.options._addToCartBtnOnClick(a); 130 } 131 return; 132 } 133 if (g.redirect_to) { 134 c.msg = g.msg; 135 c.fire(g.redirect_to, d, a); 136 return; 137 } 138 c.update(function(i) { 139 document.location.reload() 140 }, { 141 actionData: Object.toJSON(g.action_data) 142 }) 143 }, function(f) { 144 a.fireOriginal(b, d) 145 }) 146 }, 147 update: function(c, a) { 148 var e = this; 149 c = c || function() {}; 150 var b = document.location.href; 151 var d = a; 152 d["block[]"] = []; 153 Object.keys(e.config.targetsToUpdate).each(function(f) { 154 if (e.config.targetsToUpdate[f].updateOnUpdateRequest) { 155 d["block[]"].push(f) 156 } 157 }); 158 this.connector.sendRequest(b, d, function(f) { 159 var g = e.callUpdaters(f.block); 160 if (!g) { 161 c(f); 162 return 163 } 164 e.stopObservers(); 165 e.startObservers(); 166 e.ui.afterFire(d) 167 }, c) 168 } 169}; 170var AW_AjaxCartProConnector = { 171 defaultParameters: { 172 awacp: 1 173 }, 174 sendRequest: function(c, e, f, b) { 175 var d = this; 176 var e = e || {}; 177 var b = b || function() {}; 178 var f = f || function() {}; 179 Object.extend(e, this.defaultParameters); 180 var a = { 181 parameters: e, 182 onSuccess: this.onSuccessFn(f, b), 183 onFailure: this.onFailureFn(f, b) 184 }; 185 c = c.replace(/http[^:]*:/, document.location.protocol); 186 new Ajax.Request(c, a) 187 }, 188 onSuccessFn: function(success, failure) { 189 return function(transport) { 190 try { 191 eval("var json = " + transport.responseText + " || {}") 192 } catch (e) { 193 failure({}); 194 return 195 } 196 if (!json.success) { 197 failure(json); 198 return 199 } 200 success(json) 201 } 202 }, 203 onFailureFn: function(b, a) { 204 return function(c) { 205 a(json) 206 } 207 } 208}; 209var AW_AjaxCartProUI = { 210 observer: null, 211 blocks: {}, 212 config: AW_AjaxCartProConfig.data, 213 hideCls: "ajaxcartpro-box-hide", 214 showCls: "ajaxcartpro-box-show", 215 overlayCssSelector: "#acp-overlay", 216 beforeFire: function() { 217 return this._call("beforeFire", arguments) 218 }, 219 afterFire: function() { 220 return this._call("afterFire", arguments) 221 }, 222 beforeUpdate: function(a) { 223 return this._call("beforeUpdate", arguments) 224 }, 225 afterUpdate: function() { 226 return this._call("afterUpdate", arguments) 227 }, 228 registerBlock: function(a) { 229 var a = a || {}; 230 if (!a.name) { 231 return 232 } 233 this.blocks[a.name] = a 234 }, 235 showBlock: function(b) { 236 b = this._initEl(b); 237 if (!b) { 238 return false 239 } 240 var c = this._collectPos(b, "center", this.config.dialogsVAlign); 241 if (c[0] < 50) { 242 c[0] = 50; 243 b.setStyle({ 244 width: (document.viewport.getWidth() - 100) + "px" 245 }) 246 } 247 if (c[1] < 50) { 248 c[1] = 50; 249 b.setStyle({ 250 height: (document.viewport.getHeight() - 100) + "px" 251 }) 252 } 253 b.setStyle({ 254 left: c[0] + "px", 255 top: c[1] + "px" 256 }); 257 this._show(b); 258 var a = $$(this.overlayCssSelector)[0]; 259 this._show(a); 260 return true 261 }, 262 updatePosition: function(a) { 263 a = this._initEl(a); 264 if (!a) { 265 return false 266 } 267 var b = this._collectPos(a, "center", this.config.dialogsVAlign); 268 if (b[0] < 50) { 269 b[0] = 50; 270 a.setStyle({ 271 width: (document.viewport.getWidth() - 100) + "px" 272 }) 273 } 274 if (b[1] < 50) { 275 b[1] = 50; 276 a.setStyle({ 277 height: (document.viewport.getHeight() - 100) + "px" 278 }) 279 } 280 a.setStyle({ 281 left: b[0] + "px", 282 top: b[1] + "px" 283 }); 284 return true 285 }, 286 hideBlock: function(b) { 287 b = this._initEl(b); 288 if (!b) { 289 return false 290 } 291 b.setStyle({ 292 height: "auto", 293 width: "auto" 294 }); 295 var c = this; 296 var d = 0; 297 Object.keys(c.blocks).each(function(e) { 298 var f = c.blocks[e]; 299 if (f.enabled === true) { 300 d++ 301 } 302 }); 303 if (d === 0) { 304 var a = $$(this.overlayCssSelector)[0]; 305 this._hide(a) 306 } 307 this._hide(b); 308 return true 309 }, 310 _call: function(d, b) { 311 var c = this; 312 Object.keys(c.blocks).each(function(e) { 313 if (c.observer.uiBlocks.indexOf(e) === -1) { 314 return 315 } 316 var f = c.blocks[e]; 317 if (typeof(f[d]) == "function") { 318 f[d](b) 319 } 320 }); 321 var a = true; 322 Object.keys(c.blocks).each(function(e) { 323 if (!a) { 324 return 325 } 326 var f = c.blocks[e]; 327 if (f.enabled === true) { 328 a = a && c.showBlock(f.cssSelector) 329 } else { 330 a = a && c.hideBlock(f.cssSelector) 331 } 332 }); 333 return a 334 }, 335 _show: function(a) { 336 a.removeClassName(this.hideCls); 337 a.addClassName(this.showCls) 338 }, 339 _hide: function(a) { 340 if (a.className == 'grouped-items-table-wrapper') { 341 debugger; 342 } 343 a.removeClassName(this.showCls); 344 a.addClassName(this.hideCls) 345 }, 346 _initEl: function(a) { 347 if (Object.isString(a)) { 348 a = $$(a); 349 if (a.length > 0) { 350 a = a[0] 351 } else { 352 return false 353 } 354 } 355 a = $(a); 356 if (!a) { 357 return false 358 } 359 return a 360 }, 361 _collectPos: function(a, b, c) { 362 var g, f; 363 var h = a.getWidth(); 364 var e = document.viewport.getWidth(); 365 switch (b) { 366 case "center": 367 g = e / 2 - h / 2; 368 break;
369 case "left": 370 g = 50; 371 break; 372 case "right": 373 g = e - h; 374 break; 375 default: 376 } 377 var d = a.getHeight(); 378 var i = document.viewport.getHeight(); 379 switch (c) { 380 case "top": 381 f = 50; 382 break; 383 case "center": 384 f = i / 2 - d / 2; 385 break; 386 case "bottom": 387 f = i - d; 388 break; 389 default: 390 } 391 return [g, f] 392 } 393}; 394var AW_AjaxCartProObserver = Class.create(); 395AW_AjaxCartProObserver.prototype = { 396 name: null, 397 uiBlocks: [], 398 initialize: function(a) { 399 this.name = a 400 }, 401 run: function() { 402 return 403 }, 404 stop: function() { 405 return 406 }, 407 fireOriginal: function(a, b) { 408 document.location.href = a; 409 return 410 }, 411 fireCustom: function(a, b) { 412 var b = b || {}; 413 AW_AjaxCartPro.fire(a, b, this) 414 } 415}; 416var AW_AjaxCartProUpdater = Class.create(); 417AW_AjaxCartProUpdater.prototype = { 418 config: AW_AjaxCartProConfig.data, 419 selectors: null, 420 parentSelector: null, 421 name: null, 422 initialize: function(a, b, c) { 423 this.name = a; 424 this.selectors = b || null; 425 this.parentSelector = c || null 426 }, 427 beforeUpdate: function(a) { 428 return 429 }, 430 afterUpdate: function(a) { 431 return 432 }, 433 update: function(b) { 434 this.beforeUpdate(b); 435 var c = this; 436 var a = this.selectors; 437 if (a === null) { 438 a = this._getRootSelectors(b) 439 } 440 var d = new Element("div"); 441 d.innerHTML = b; 442 if (d.childElements().length != a.length && d.childElements().length > 0) { 443 return false 444 } 445 if (!this._checkSelectorsOnUnique(a)) { 446 return false 447 } 448 a.each(function(f) { 449 var e = d.select(f)[0]; 450 var g = null; 451 c._getSelectorsToTarget(f).each(function(h) { 452 if (g !== null) { 453 return 454 } 455 if ($$(h).length > 0) { 456 g = $$(h)[0] 457 } 458 }); 459 if (!g) { 460 return 461 } 462 if (!e) { 463 g.parentNode.removeChild(g); 464 return 465 } 466 g.parentNode.replaceChild(e, g) 467 }); 468 delete d; 469 this._evalScripts(b); 470 this.afterUpdate(b, a); 471 return true 472 }, 473 _getRootSelectors: function(b) { 474 var c = new Element("div"); 475 c.innerHTML = b; 476 var a = []; 477 c.childElements().each(function(d) { 478 a.push(this._getCssSelectorsByElement(d)) 479 }, this); 480 delete c; 481 return a 482 }, 483 _checkSelectorsOnUnique: function(a) { 484 var b = true; 485 a.each(function(e) { 486 var d = this._getSelectorsToTarget(e); 487 var c = null; 488 d.each(function(f) { 489 if (c !== null) { 490 return 491 } 492 if ($$(f) > 0) { 493 c = $$(f)[0] 494 } 495 }); 496 if ($$(c).length > 1) { 497 b = false 498 } 499 }, this); 500 return b 501 }, 502 _getSelectorsToTarget: function(a) { 503 var b = []; 504 if (this.parentSelector !== null) { 505 this.parentSelector.each(function(d) { 506 var c = d + " " + a; 507 b.push(c) 508 }) 509 } else { 510 b.push(a) 511 } 512 return b 513 }, 514 _getCssSelectorsByElement: function(b) { 515 b = $(b); 516 var a = b.tagName.toLowerCase(); 517 var c = a; 518 $H({ 519 id: "id", 520 className: "class" 521 }).each(function(g) { 522 var f = g.first(), 523 d = g.last(), 524 e = (b[f] || "").toString(); 525 if (e) { 526 if (d === "id") { 527 c += "#" + e 528 } else { 529 e = e.split(" ").join("."); 530 c += "." + e 531 } 532 } 533 }); 534 return c 535 }, 536 _evalScripts: function(html) { 537 var scripts = html.extractScripts(); 538 scripts.each(function(script) { 539 try { 540 script = script.replace("//<![CDATA[", "").replace("//]]>", ""); 541 script = script.replace("/*<![CDATA[*/", "").replace("/*]]>*/", ""); 542 eval(script.replace(/var /gi, "")) 543 } catch (e) { 544 if (window.console) { 545 console.log(e.message) 546 } 547 } 548 }) 549 } 550}; 551var AW_AjaxCartProUIBlocks = [{ 552 cssSelector: "#ajaxcartpro-progress", 553 name: "progress", 554 enabled: false, 555 beforeFire: function(a) { 556 if (!AW_AjaxCartPro.config.data.useProgress) { 557 return 558 } 559 this.enabled = true 560 }, 561 afterFire: function(a) {}, 562 beforeUpdate: function(a) {}, 563 afterUpdate: function(a) { 564 this.enabled = false 565 } 566}, { 567 name: "add_confirmation", 568 cssSelector: "#ajaxcartpro-add-confirm", 569 enabled: false, 570 beforeFire: function(a) { 571 this.enabled = false 572 }, 573 afterFire: function(a) { 574 if (!AW_AjaxCartPro.config.data.addProductConfirmationEnabled) { 575 return 576 } 577 this.enabled = true;
578 this._cntBtnInit() 579 }, 580 beforeUpdate: function(a) {}, 581 afterUpdate: function(a) {}, 582 _cntBtnInit: function() { 583 var a = $$(this.cssSelector)[0].select(".aw-acp-continue")[0]; 584 if (!a) { 585 return 586 } 587 a.stopObserving("click", this._cntBtnOnClick.bind(this)); 588 a.observe("click", this._cntBtnOnClick.bind(this)); 589 if (AW_AjaxCartPro.config.data.addProductCounterBeginFrom > 0) { 590 this._initCounterForBtn(a, AW_AjaxCartPro.config.data.addProductCounterBeginFrom) 591 } 592 }, 593 _cntBtnOnClick: function(a) { 594 this.enabled = false; 595 AW_AjaxCartProUI.hideBlock(this.cssSelector); 596 a.stop() 597 }, 598 _initCounterForBtn: function(e, a) { 599 var d = e.innerHTML; 600 e.innerHTML = d + " (" + a + ")"; 601 var c = setInterval(function() { 602 a--; 603 if (a === 0) { 604 e.click() 605 } 606 e.innerHTML = d + " (" + a + ")" 607 }, 1000); 608 var b = function(f) { 609 clearInterval(c); 610 e.stopObserving("click", this.bind(this)) 611 }; 612 e.observe("click", b.bind(b)) 613 } 614}, { 615 name: "remove_confirmation", 616 cssSelector: "#ajaxcartpro-remove-confirm", 617 enabled: false, 618 beforeFire: function(a) { 619 this.enabled = false 620 }, 621 afterFire: function(a) { 622 if (!AW_AjaxCartPro.config.data.removeProductConfirmationEnabled) { 623 return 624 } 625 this.enabled = true; 626 this._cntBtnInit() 627 }, 628 beforeUpdate: function(a) {}, 629 afterUpdate: function(a) {}, 630 _cntBtnInit: function() { 631 var a = $$(this.cssSelector)[0].select(".aw-acp-continue")[0]; 632 if (!a) { 633 return 634 } 635 a.stopObserving("click", this._cntBtnOnClick.bind(this)); 636 a.observe("click", this._cntBtnOnClick.bind(this)); 637 if (AW_AjaxCartPro.config.data.removeProductCounterBeginFrom > 0) { 638 this._initCounterForBtn(a, AW_AjaxCartPro.config.data.removeProductCounterBeginFrom) 639 } 640 }, 641 _cntBtnOnClick: function(a) { 642 this.enabled = false; 643 AW_AjaxCartProUI.hideBlock(this.cssSelector); 644 a.stop() 645 }, 646 _initCounterForBtn: function(e, a) { 647 var d = e.innerHTML; 648 e.innerHTML = d + " (" + a + ")"; 649 var c = setInterval(function() { 650 a--; 651 if (a === 0) { 652 e.click() 653 } 654 e.innerHTML = d + " (" + a + ")" 655 }, 1000); 656 var b = function(f) { 657 clearInterval(c); 658 e.stopObserving("click", this.bind(this)) 659 }; 660 e.observe("click", b.bind(b)) 661 } 662}, { 663 name: "options", 664 rootCssSelector: "#acp-configurable-block", 665 cssSelector: "#acp-product-options", 666 enabled: false, 667 beforeFire: function(a) {}, 668 afterFire: function(a) {}, 669 beforeUpdate: function(a) {}, 670 afterUpdate: function(a) { 671 var b = $$(this.cssSelector); 672 if (b.length === 1) { 673 this.enabled = true; 674 var c = a[0]; 675 this._addMsgBlock(c); 676 this._appearGroupedBlock(); 677 this._appearGiftBlock(); 678 this._cancelBtnInit(); 679 this._addToCartBtnInit() 680 } 681 }, 682 _addMsgBlock: function(b) { 683 if (!b || !b.length || b.length < 1) { 684 return 685 } 686 var a = $$(".acp-msg-block")[0]; 687 a.innerHTML = ""; 688 AW_AjaxCartProUI._show(a); 689 b.each(function(d) { 690 var c = new Element("li"); 691 c.innerHTML = d; 692 a.appendChild(c) 693 }) 694 }, 695 _appearGroupedBlock: function() { 696 var a = ["div.grouped-items-table-wrapper", "table.grouped-items-table", "table#super-product-table"]; 697 var b = null; 698 a.each(function(c) { 699 if (b !== null) { 700 return 701 } 702 b = $("acp-product-type-data").select(c); 703 if (b.length === 0) { 704 b = null; 705 return 706 } 707 b = b[0] 708 }); 709 AW_AjaxCartProUI._show($("acp-product-type-data")); 710 $("acp-product-type-data").childElements().each(function(c) { 711 if (c === b || c.tagName.toLocaleLowerCase() === "script") { 712 return 713 } 714 AW_AjaxCartProUI._hide(c) 715 }); 716 return 717 }, 718 _appearGiftBlock: function() { 719 var a = $("acp-product-type-data").select(".giftcard-send-form"); 720 if (a.length === 0) { 721 return 722 } 723 a = a[0]; 724 AW_AjaxCartProUI._show($("acp-product-type-data")); 725 AW_AjaxCartProUI._show(a.up()); 726 a.up().childElements().each(function(b) { 727 if (b === a || b.tagName.toLocaleLowerCase() === "script") { 728 return 729 } 730 AW_AjaxCartProUI._hide(b) 731 }); 732 return 733 }, 734 _cancelBtnInit: function() { 735 var a = $$(this.cssSelector)[0].select(".aw-acp-continue")[0]; 736 a.stopObserving("click", this._cancelBtnOnClick.bind(this)); 737 a.observe("click", this._cancelBtnOnClick.bind(this)) 738 }, 739 _cancelBtnOnClick: function(a) { 740 this._hideBlock(); 741 a.stop() 742 }, 743 _addToCartBtnInit: function() { 744 var a = $$(this.cssSelector)[0].select(".aw-acp-checkout")[0]; 745 a.stopObserving("click", this._addToCartBtnOnClick.bind(this)); 746 a.observe("click", this._addToCartBtnOnClick.bind(this)) 747 }, 748 _addToCartBtnOnClick: function(a) { 749 if (productAddToCartFormAcp.validator && productAddToCartFormAcp.validator.validate()) { 750 productAddToCartFormAcp.form.submit(); 751 this._hideBlock() 752 } 753 a.stop() 754 }, 755 _hideBlock: function() { 756 this.enabled = false;
757 AW_AjaxCartProUI.hideBlock(this.cssSelector); 758 $$(this.rootCssSelector)[0].down().remove() 759 } 760}]; 761AW_AjaxCartProUIBlocks.each(function(a) { 762 AW_AjaxCartProUI.registerBlock(a) 763});
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.