1shop2.delivery.edost = function(attach_id) { 2 3 function find(name) { 4 var selector = '[name=' + name.replace(/([\[\]])/g, '\\$1') + ']'; 5 return $(selector); 6 } 7 8 var btn = $('#shop2-edost-calc'), 9 address = find(attach_id + '[address]'); 10 11 12 function setAddress(office) { 13 var text = $.trim(office.text()).replace(/\s*\n\s*/g, '\n').split('\n').splice(1).join('\n'); 14 address.val(text).prop('readonly', true); 15 } 16 17 find(attach_id + '[edost][office]').on('click', function() { 18 var $this = $(this), 19 wrap = $this.closest('.shop2-edost-office'); 20 21 setAddress(wrap); 22 $this.prop('checked', true); 23 }); 24 25 find(attach_id + '[edost][tarif]').on('click', function() { 26 var $this = $(this), 27 wrap = $this.closest('.shop2-edost-variant'), 28 siblings = wrap.siblings(), 29 office = wrap.find('.shop2-edost-office'), 30 checked; 31 32 siblings.find('.shop2-edost-office input, .shop2-edost-pickpointmap input').prop({ 33 disabled: true, 34 checked: false 35 }); 36 37 var radio = wrap.find('.shop2-edost-office input, .shop2-edost-pickpointmap input').prop({ 38 disabled: false 39 }).filter(':radio'); 40 41 checked = radio.filter(':checked'); 42 43 if (radio.get(0)) { 44 45 if (checked.get(0)) { 46 checked.trigger('click'); 47 } else { 48 radio.eq(0).trigger('click'); 49 } 50 51 } else { 52 53 if (office.length == 1) { 54 setAddress(office); 55 } else if (address.prop('readonly')) { 56 address.prop('readonly', false).val(''); 57 } 58 59 } 60 61 }).filter(':checked').trigger('click'); 62 63 64 $('.shop2-edost-pickpointmap a').on('click', function() { 65 var $this = $(this), 66 span = $this.children(), 67 city = $this.data('city'); 68 69 $this.closest('.shop2-edost-variant').find('> label input').trigger('click'); 70 71 function cb(data) { 72 var res = {}; 73 $.each(['name', 'address', 'id'], function(i, k) { 74 res[k] = data[k]; 75 }); 76 $this.next().val(JSON.stringify(res)); 77 span.html(': ' + res.name); 78 79 console.log(address); 80 address.val(res.name + ',\n' + res.address).prop('readonly', true); 81 } 82 83 PickPoint.open(cb, { 84 city: city, 85 ids: null 86 }); 87 88 return false; 89 }); 90 91}; 92 93shop2.delivery.calc = function(hash, ver_id, attach_id) { 94 95 96 var to = $('select[name=' + attach_id + '\\[to\\]]'); 97 var zip = $('input[name=' + attach_id + '\\[zip\\]]'); 98 99 to = to.length ? to.val() : ''; 100 zip = zip.length ? zip.val() : ''; 101 102 $.getJSON('/my/s3/api/shop2/?cmd=deliveryCalc', { 103 104 hash: hash, 105 ver_id: ver_id, 106 attach_id: attach_id, 107 params: 'to=' + to + '&zip=' + zip 108 109 }, function(d) { 110 111 if (!d.data && d.errstr) { 112 113 alert(d.errstr); 114 $('#delivery-' + attach_id + '-cost').html(0); 115 116 } else { 117 118 $('#delivery-' + attach_id + '-cost').html(d.data.cost); 119 120 if (d.data.html) { 121 122 $('#delivery-' + attach_id + '-html').html(d.data.html); 123 shop2.delivery.edost(attach_id); 124 125 } 126 127 } 128 129 }); 130 131 return false; 132}; 133 134 135 136(function() { 137 138 $.fn.s3center = function() { 139 140 return this.each( function() { 141 var $this = $(this), 142 isVisible = $this.is(':visible'); 143 144 if (!isVisible) { 145 $this.show(); 146 } 147 148 $this.css({ 149 marginLeft: -$this.outerWidth() / 2, 150 marginTop: -$this.outerHeight() / 2 151 }); 152 153 if (!isVisible) { 154 $this.hide(); 155 } 156 }); 157 }; 158 159 $.fn.caret = function(begin, end) { 160 var range; 161 162 if (this.length === 0 || this.is(":hidden")) { 163 return; 164 } 165 166 if (typeof begin == 'number') { 167 end = (typeof end === 'number') ? end : begin; 168 return this.each(function() { 169 if (this.setSelectionRange) { 170 this.setSelectionRange(begin, end); 171 } else if (this.createTextRange) { 172 range = this.createTextRange(); 173 range.collapse(true); 174 range.moveEnd('character', end); 175 range.moveStart('character', begin); 176 range.select(); 177 } 178 }); 179 } else { 180 if (this[0].setSelectionRange) { 181 begin = this[0].selectionStart; 182 end = this[0].selectionEnd; 183 } else if (document.selection && document.selection.createRange) { 184 range = document.selection.createRange(); 185 begin = 0 - range.duplicate().moveStart('character', -100000); 186 end = begin + range.text.length; 187 } 188 return { 189 begin: begin, 190 end: end 191 }; 192 } 193 } 194 195 $.fn.keyFilter = function(def, type, callback) { 196 return this.each(function() { 197 var obj = $(this); 198 obj.keypress(function(e) { 199 var caret = obj.caret(); 200 if (e.shiftKey || e.ctrlKey) return false;
201 if (e.which == 0) return true; 202 var isDigit = e.which >= 48 && e.which <= 57; 203 var isPoint = e.which == 46 || e.which == 44; 204 var isBack = e.which == 8; 205 if (type == 'int' && isPoint) return false; 206 if (!isDigit && !isPoint && !isBack) return false; 207 obj.val(obj.val().replace(',', '.')); 208 obj.caret(caret.begin, caret.end); 209 210 if (isPoint && obj.val().indexOf('.') != -1) return false; 211 }).keyup(function(e) { 212 var max = obj.attr('max'); 213 if (max) { 214 max = Number(max); 215 if (obj.val() > max) { 216 obj.val(max); 217 widgets.msg("РналиÑии ÑолÑко " + max, obj.get(0)); 218 } 219 } 220 if (callback) callback(obj); 221 }).blur(function() { 222 if (obj.val() == '' || obj.getVal() == 0) { 223 obj.val(def); 224 if (callback) callback(obj); 225 } 226 }); 227 }); 228 }; 229 230 $.fn.getVal = function() { 231 var v = $(this).val(); 232 v = parseFloat(v); 233 if (v) return v; 234 return 0; 235 }; 236 237 238 $.fn.s3tooltip = function(settings) { 239 240 settings = $.extend({ 241 data: function() { 242 return this.alt || ''; 243 }, 244 245 cls: 'tooltip-1', 246 slide: true, 247 dir: 'bottom' 248 249 }, settings); 250 251 var tooltip = $('#shop2-tooltip'); 252 253 if (!tooltip.get(0)) { 254 tooltip = $('<div id="shop2-tooltip"></div>'); 255 $('body').append(tooltip); 256 } 257 258 var selector = this.selector; 259 260 var win = { 261 $el: $(window) 262 }, 263 width, 264 height; 265 266 $(document).on({ 267 268 mouseenter: function(e) { 269 var html = settings.data.call(this); 270 271 if (!html) { 272 return; 273 } 274 275 win.width = win.$el.width(); 276 win.height = win.$el.height(); 277 278 tooltip.html(html); 279 tooltip.addClass(settings.cls); 280 tooltip.show(); 281 282 width = tooltip.outerWidth(true); 283 height = tooltip.outerHeight(true); 284 }, 285 286 mouseleave: function(e) { 287 tooltip.hide(); 288 tooltip.removeClass(settings.cls); 289 }, 290 291 mousemove: function(e) { 292 293 var left = e.pageX, 294 top = e.pageY, 295 scrollTop = $(document).scrollTop(); 296 297 if (left + width > win.width) { 298 left -= width; 299 } 300 301 if (settings.dir == 'top') { 302 top -= height; 303 304 if (top < scrollTop) { 305 306 if (settings.slide) { 307 308 top = scrollTop; 309 310 } else { 311 312 top += height; 313 } 314 315 } 316 317 } else { 318 319 if (top + height > win.height + scrollTop) { 320 321 if (settings.slide) { 322 323 top = win.height + scrollTop - height; 324 325 } else { 326 327 top -= height; 328 329 } 330 331 } 332 333 } 334 335 tooltip.css({ 336 left: left, 337 top: top 338 }); 339 340 } 341 }, selector); 342 343 }; 344 345})(jQuery); 346 347var p_reload = function(node, pageType, cb) { 348 349 // Read kind IDs encoded in node's data attr 350 var nodeData = this.getNodeData(node, /* decode */ true); 351 if (!nodeData) throw 'Node data is empty'; 352 353 var form = $(node).closest('form'); 354 if (!form.length) throw 'Failed getting form node'; 355 form = form.get(0); 356 357 form.submit.disabled = true; 358 359 var productId = Number(form.product_id.value); 360 // this.productRefs[productId] is a leverage array of custom fields 361 362 // Find the best matching kind ID 363 var refs = this.productRefs[productId]; 364 var kindId = 0, 365 matches = 0, 366 lastMatches = 0; 367 var i, d, p, v; 368 369 if (nodeData.length == 1) { 370 kindId = nodeData[0]; 371 } else { 372 for (i = 0; i < nodeData.length; ++i) { 373 // d - one of kind IDs having selected value 374 d = Number(nodeData[i]); 375 376 // Searching for kind ID with best matches 377 if (matches > lastMatches) { 378 kindId = d; 379 lastMatches = matches; 380 }; 381 matches = 0; 382 383 for (p in refs) { 384 // p - control name 385 for (v in refs[p]) { 386 // v - control value 387 if (refs[p][v].indexOf(d) == -1) { 388 continue; 389 } 390 ++matches; 391 } 392 } 393 } 394 } 395 396 shop2.showPreloader(node); 397 398 // Request the kind for rendering via AJAX 399 if (pageType == 'product') { 400 document.location = document.location.href.replace(/\/product\/(.+)/i, '/product/' + kindId); 401 } else { 402 var url = '/my/s3/api/shop2/?cmd=getProductListItem&hash=' + this.apiHash['getProductListItem'] + '&ver_id=' + this.verId; 403 if (pageType != undefined) { 404 url += '&page_type=' + pageType; 405 } 406 $.post(url, { 407 'kind_id': kindId, 408 'product_id': productId 409 }, function(d, textStatus) { 410 try { 411 if (textStatus == 'success') { 412 if (typeof d == 'string') { 413 d = jQuery.parseJSON(d); 414 } 415 416 if (typeof d.errstr != "undefined" && d.errstr) { 417 widgets.msg(window._s3Lang['JS_HTTP_ERROR'] + ': ' + d.errstr, node, 'msg-ajax-error'); 418 } 419 420 // Replace product element div 421 var $cont = $(node).closest('.shop2-product-item'); 422 $cont.hide(); 423 var $newCont = $(d.data.body).insertBefore($cont); 424 $cont.remove(); 425 shop2.product.disableUnusedFields($newCont, nodeData); 426 427 428 if (typeof d.data.params != "undefined") { 429 $('.shop2-product-item-params').html(d.data.params); 430 }; 431 } else { 432 // HTTP error code 433 widgets.msg(window._s3Lang['JS_HTTP_ERROR'] + ': ' + d.errstr, 'msg-ajax-error'); 434 } 435 436 shop2.hidePreloader(); 437 } catch (e) { 438 widgets.msg(e.message); 439 shop2.hidePreloader(); 440 } 441 if (typeof cb == "function") { 442 cb(d); 443 } 444 }); 445 } 446 447 form.submit.disabled = false;
448} 449 450var shopClient = { 451 reloadProduct: function(obj) { 452 shop2.product.reload = p_reload; 453 shop2.product.reloadProduct(obj); 454 }, 455 addItem: function(obj, hash, ver_id, kind_id, amount, submit_btn, type) { 456 createCookie("cart_opened", 1, 90); 457 amount = Number(amount); 458 if (!amount) amount = 1; 459 shop2.cart.addItem(obj, hash, ver_id, kind_id, amount, submit_btn, type); 460 } 461}; 462 463shopClient.callbacks = {}; 464 465shopClient.on = function(type, func) { 466 var _this = this; 467 468 $.each(type.split(','), function(index, type) { 469 type = $.trim(type); 470 471 if (!_this.callbacks[type]) { 472 _this.callbacks[type] = $.Callbacks(); 473 } 474 475 _this.callbacks[type].add(func); 476 }); 477}; 478 479shopClient.off = function(type, func) { 480 if (this.callbacks[type]) { 481 func ? this.callbacks[type].remove(func) : this.callbacks[type].empty(); 482 } 483}; 484 485shopClient.trigger = function(type) { 486 if (this.callbacks[type]) { 487 this.callbacks[type].fireWith(self, [].slice.call(arguments, 1)); 488 } 489}; 490 491shopClient.defaults = { 492 minAmount: 1, 493 unitType: 'int' 494}; 495 496shopClient.locale = { 497 inCard: 'Ð¢Ð¾Ð²Ð°Ñ Ð´Ð¾Ð±Ð°Ð²Ð»ÐµÐ½ в коÑзинÑ. <br /><a href="">ÐÑоÑмиÑÑ Ð·Ð°ÐºÐ°Ð·</a>', 498 hideParams: 'СкÑÑÑÑ Ð¿Ð°ÑамеÑÑÑ', 499 allParams: 'ÐÑе паÑамеÑÑÑ' 500}; 501 502shopClient.msg = { 503 win: null, 504 close: null, 505 content: null, 506 o: null, 507 init: function() { 508 var html = '<div id="shop2-msg">' + 509 '<div id="shop2-msg-close">x</div>' + 510 '<div id="shop2-msg-text"></div>' 511 '</div>'; 512 $('body').append(html); 513 this.win = $('#shop2-msg'); 514 this.close = $('#shop2-msg-close'); 515 this.content = $('#shop2-msg-text'); 516 517 $(window).resize(function() { 518 shopClient.msg.setPosition(); 519 }); 520 this.close.click(function() { 521 shopClient.msg.win.hide(); 522 }); 523 }, 524 show: function(text, obj) { 525 var ww, wh; 526 if (!this.win) { 527 this.init(); 528 } 529 530 text = shopClient.locale.inCard; 531 532 this.content.html(text); 533 this.o = $(obj); 534 this.win.show(); 535 this.setPosition(); 536 }, 537 setPosition: function() { 538 var ww, wh, mw, mh, ow, oh, pos, left, top, visible; 539 540 visible = this.win.is(':visible'); 541 if (!visible) return; 542 543 544 this.win.hide(); 545 546 ww = $(document).width() - 15; 547 wh = $(document).height(); 548 549 this.win.show(); 550 551 mw = this.win.outerWidth(true); 552 mh = this.win.outerHeight(true); 553 ow = this.o.width(); 554 oh = this.o.height(); 555 556 pos = this.o.offset(); 557 558 559 left = pos.left + ow + 15; 560 top = pos.top - (mh - oh) / 2; 561 562 if (left + mw > ww) { 563 left = pos.left - mw - 15; 564 } 565 566 if (top + mh > wh) { 567 top = wh - mh; 568 } 569 570 this.win.css({ 571 left: left, 572 top: top 573 }); 574 } 575}; 576 577$(function() { 578 if (document.location.search.indexOf('test') != -1) { 579 widgets.msg = function(text, obj) { 580 shopClient.msg.show(text, obj); 581 } 582 } 583}); 584 585//shop2.cart.addItem(this, '324eabfdc402491d8ab1d9f080f1d325', '26909', this.kind_id.value, this.amount.value,this.elements.submit, 'shop2-cart-preview'); return false; 586 587shopClient.Cart = { 588 check: function() { 589 var amount = $('#cart_total_amount'), 590 pre = $('#cart_pre_amount'), 591 cart = $('.shop-cart'), 592 empty = $('.shop-cart-in .shop-cart-empty'), 593 full = $('.shop-cart-in .shop-cart-full'); 594 595 if (amount.get(0) || pre.get(0)) { 596 if (parseFloat(amount.html()) > 0 || pre.html() > 0) { 597 cart.addClass('cart-added'); 598 empty.hide(); 599 full.show(); 600 } else { 601 cart.removeClass('cart-added'); 602 empty.show(); 603 full.hide(); 604 } 605 } 606 } 607}; 608 609shopClient.PriceList = { 610 addToCart: function(el, hash, ver_id, kind_id) { 611 var amount = $('#amount_' + kind_id).val(), 612 obj = $(el); 613 if (!obj.hasClass('shop2-button-disabled') && amount > 0) { 614 shopClient.addItem(el, hash, ver_id, kind_id, amount, el, 'shop2-cart-preview'); 615 } 616 return void(0); 617 } 618}; 619 620shopClient.Product = { 621 setBigImage: function(srcObj, imageUrl, thumbUrl) { 622 var e = document.getElementById('shop2-product-image'), 623 src = $(srcObj).attr('src'); 624 if (e && e.tagName == 'IMG') { 625 e.src = thumbUrl; 626 $('div.product-thumbnails-wrap li').removeClass('activ-img'); 627 $(srcObj).parent('li').addClass('activ-img'); 628 $(e).closest('a.highslide').attr('href', imageUrl); 629 } 630 } 631}; 632 633shopClient.Search = { 634 getFolderParams: function(self, hash, ver_id) { 635 var v = self.options[self.selectedIndex].value, 636 wrap = document.getElementById('shop2_search_custom_fields'), 637 url, 638 options = shopClient.Filter.getUrlParams(), 639 search = [], 640 i; 641 642 shopClient.trigger('beforeGetFolderCustomFields'); 643 644 if (wrap) { 645 646 647 if (v > 0) { 648 url = '/my/s3/api/shop2/?cmd=getFolderCustomFields' + '&hash=' + hash + '&ver_id=' + ver_id + '&folder_id=' + v; 649 650 for (i in options) { 651 if (options.hasOwnProperty(i) && options[i]) { 652 search.push(i + '=' + options[i]); 653 } 654 } 655 search = search.join('&'); 656 if (search) { 657 url = url + '&' + search; 658 } 659 660 jQuery.getJSON(url, function(d, status) { 661 662 shopClient.trigger('afterGetFolderCustomFields', d, status); 663 664 if (!d || d.error) { 665 widgets.msg(d.error, self); 666 return; 667 } 668 669 wrap.innerHTML = d.data; 670 }); 671 } else { 672 wrap.innerHTML = ''; 673 } 674 } 675 } 676}; 677 678 679shopClient.Filter = { 680 _get: null, 681 _sort: null, 682 _folder: "", 683 Folder: function(key, value) { 684 this._folder = '&' + key + '=' + value; 685 }, 686 getUrlParams: function() { 687 var search = window.decodeURIComponent(document.location.search), 688 params = {}, 689 param, 690 i, j, 691 parts; 692 if (this._get === null) { 693 search = search.slice(1).split('&'); 694 for (i = 0; i < search.length; i++) { 695 param = search[i].split('='); 696 if (param.length == 2) { 697 params[param[0]] = []; 698 parts = param[1].split('|'); 699 for (j = 0; j < parts.length; j++) { 700 if (parts[j] != '') { 701 params[param[0]].push(parts[j]); 702 } 703 } 704 } 705 } 706 this._get = params; 707 } 708 return this._get; 709 }, 710 findOption: function(array, value) { 711 var i; 712 for (i = 0; i < array.length; i++) { 713 if (array[i] == value) { 714 return i; 715 } 716 } 717 return -1; 718 }, 719 replaceParam: function(key, value) { 720 var params = this.getUrlParams(); 721 params[key] = [value]; 722 this._get = params; 723 this.getCount(); 724 }, 725 addParam: function(key, value, obj) { 726 var params = this.getUrlParams(), 727 i, position; 728 729 value = window.encodeURIComponent(value); 730 731 if (typeof params[key] === 'undefined') { 732 params[key] = [value]; 733 } else { 734 position = this.findOption(params[key], value); 735 if (position != -1) { 736 params[key].splice(position, 1); 737 } else { 738 params[key].push(value); 739 } 740 } 741 742 $(obj).toggleClass('shop-filter-param-val-active'); 743 744 this._get = params; 745 this.getCount(); 746 return void(0); 747 748 }, 749 getCount: function() { 750 var url = this.getUrl(true); 751 752 shopClient.trigger('beforeGetSearchMatches'); 753 754 $.get('/my/s3/api/shop2/?cmd=getSearchMatches&hash=' + shop2.product.apiHash.getSearchMatches + '&ver_id=' + shop2.product.verId + '&' + url + this._folder, function(d, textStatus) { 755 756 shopClient.trigger('afterGetSearchMatches', d, textStatus); 757 758 if (textStatus == 'success') { 759 if (typeof d == 'string') { 760 d = jQuery.parseJSON(d); 761 } 762 } 763 $('span.filter-result').removeClass('filter-result-hide'); 764 if (d.data.total_found == 0) { 765 $('span.filter-result').addClass('no-filter-result') 766 } else { 767 $('span.filter-result').removeClass('no-filter-result') 768 } 769 $('#filter-result').html(d.data.total_found); 770 }); 771 }, 772 getUrl: function(fromCount) { 773 var i, params = [], 774 j, options = this._get; 775 776 for (i in options) { 777 if (options.hasOwnProperty(i) && options[i]) { 778 if (options[i].length > 0) { 779 params.push(i + '=' + options[i].join('|')); 780 } 781 } 782 } 783 params = params.join('&'); 784 if (fromCount) { 785 return params; 786 } 787 if (params) { 788 params = '?' + params; 789 } 790 return document.location.pathname.replace(/\/p\/\d*/g, '') + params; 791 }, 792 goToUrl: function(key, value) { 793 if (key) { 794 this._get[key] = [value]; 795 } 796 document.location = this.getUrl() + '#shop2-filter'; 797 return void(0); 798 }, 799 getSortParams: function() { 800 var sort_by = this.getUrlParams()['s[sort_by]'], 801 options = {}, 802 option, 803 i; 804 if (this._sort === null) { 805 if ( sort_by && sort_by.length > 0 ) { 806 sort_by = sort_by[0].split(','); 807 for (i = 0; i < sort_by.length; i++) { 808 option = sort_by[i].split(' '); 809 if (option.length == 2) { 810 options[option[0]] = option[1]; 811 } 812 } 813 } 814 this._sort = options; 815 } 816 return this._sort; 817 }, 818 sortBy: function(name) {
819 var params = this.getSortParams(), 820 i, 821 sort_by = []; 822 if (typeof params[name] == 'undefined' || params[name] == '' || params[name] == 'asc') { 823 params[name] = 'desc'; 824 } else { 825 params[name] = 'asc'; 826 } 827 828 for (i in params) { 829 if (params.hasOwnProperty(i) && params[i]) { 830 sort_by.push(i + ' ' + params[i]); 831 } 832 } 833 834 sort_by = sort_by.join(','); 835 836 this._get['s[sort_by]'] = [sort_by]; 837 return this.goToUrl(); 838 }, 839 resetSort: function() { 840 this._get['s[sort_by]'] = []; 841 return this.goToUrl(); 842 }, 843 init: function() { 844 var params = this.getSortParams(), 845 i, j, value; 846 847 for (i in params) { 848 if (params.hasOwnProperty(i) && params[i]) { 849 $('#shop2-sorting-' + i).addClass('shop2-sorting-param-' + params[i]); 850 } 851 } 852 853 var timeout = {}; 854 $('form.shop2-filter input:text').keyup(function(i) { 855 var o = $(this), 856 name = o.attr('name'), 857 value = o.val(); 858 if (timeout[name]) { 859 window.clearTimeout(timeout[name]); 860 } 861 862 timeout[name] = window.setTimeout(function() { 863 shopClient.Filter.replaceParam(name, value); 864 }, 500); 865 866 }); 867 } 868}; 869 870 871shopClient.Compare = { 872 add: function(kind_id, callback) { 873 this.action('add', kind_id, callback); 874 }, 875 remove: function(kind_id, callback) { 876 this.action('del', kind_id, callback); 877 }, 878 clear: function(callback) { 879 this.action('clear', null, callback); 880 }, 881 action: function(action, kind_id, func) { 882 883 var eventName = $.camelCase('Compare-' + action); 884 885 shopClient.trigger('before' + eventName); 886 887 888 $.post( 889 '/my/s3/api/shop2/?cmd=compare', { 890 hash: shop2.product.apiHash.compare, 891 ver_id: shop2.product.verId, 892 kind_id: kind_id, 893 action: action 894 }, function(d, status) { 895 896 shopClient.trigger('after' + eventName, d, status); 897 898 if (func) func(d, status); 899 900 } 901 ); 902 } 903}; 904 905$(function() { 906 907 // ÐлÑÑ Ð¸ минÑÑ 908 909 $('span.p-plus, span.product-amount-button-add').on('click', function() { 910 var o = $(this), 911 product_amount, max 912 if (o.hasClass('disabled')) { 913 return false; 914 } 915 product_amount = o.parent().find('input:text'); 916 917 product_amount.val(product_amount.getVal() + 1); 918 max = product_amount.attr('max'); 919 if (max) { 920 max = Number(max); 921 if (product_amount.getVal() > max) { 922 product_amount.val(max); 923 widgets.msg(_s3Lang.JS_AVAILABLE_ONLY + ' ' + max, this); 924 } 925 } 926 }); 927 928 $('span.p-minus, span.product-amount-button-remove').on('click', function() { 929 var o = $(this), 930 product_amount; 931 if (o.hasClass('disabled')) { 932 return false; 933 } 934 product_amount = o.parent().find('input:text'); 935 936 if (product_amount.getVal() > shopClient.defaults.minAmount) { 937 product_amount.val(parseFloat(product_amount.getVal() - 1)); 938 } else { 939 product_amount.val(shopClient.defaults.minAmount); 940 } 941 }); 942 943 944 //ÐоÑзинка 945 (function() { 946 $('.shop-cart-title').on('click', function() { 947 var shop_cart_in = $('.shop-cart-in'), 948 shop_cart = $('.shop-cart'); 949 if (shop_cart_in.is(':hidden')) { 950 shop_cart_in.show(); 951 shop_cart.addClass('cart-opened'); 952 createCookie("cart_opened", 1, 90); 953 //$.cookie("full_cart", 1, {path : "/"}); 954 } else { 955 shop_cart_in.hide(); 956 shop_cart.removeClass('cart-opened'); 957 createCookie("cart_opened", 0, 90); 958 //$.cookie("full_cart", 0, {path : "/"}); 959 } 960 }); 961 })(); 962 963 964 //ÐоиÑк 965 (function() { 966 var shop_search_title = $('.shop-search-title'), 967 shop_search_wrap = $('.shop-search-wrap'), 968 ss = readCookie("search_state") /*$.cookie("search_state")*/ ; 969 970 shop_search_title.click(function() { 971 var o = $(this); 972 if (shop_search_wrap.is(':hidden')) { 973 shop_search_wrap.slideDown(500); 974 o.addClass('opened'); 975 createCookie("search_state", 1, 90); 976 //$.cookie("search_state", 1, {path: "/"}); 977 } else { 978 shop_search_wrap.slideUp(500); 979 o.removeClass('opened'); 980 createCookie("search_state", 0, 90); 981 //$.cookie("search_state", 0, {path: "/"}); 982 } 983 }); 984 985 if (ss == 1) { 986 shop_search_wrap.show(); 987 shop_search_title.addClass('opened'); 988 } 989 })(); 990 991 992 //ÐÐ°Ð±Ð¸Ð½ÐµÑ 993 (function() { 994 var cabinet = 0; 995 996 $('div.shop2-login-header').click(function() { 997 var o = $(this).parent(), 998 visible = 0; 999 1000 if ($('div.shop2-login-body').is(':hidden')) { 1001 visible = 1; 1002 } else { 1003 visible = 0; 1004 } 1005 o.toggleClass('shop2-login-close'); 1006 createCookie("cabinet", visible, 90); 1007 //$.cookie("cabinet", visible, {path : "/"}); 1008 }); 1009 1010 cabinet = readCookie("cabinet") /*$.cookie("cabinet")*/ ; 1011 if (cabinet == 1) { 1012 $('div.shop2-login').removeClass('shop2-login-close'); 1013 } 1014 })(); 1015 1016 1017 //Ð¢Ð°Ð±Ñ 1018 (function() { 1019 var active = 'shop-tab-active'; 1020 1021 $('.shop-tabs .shop-tabs-nav li a').on('click', function() { 1022 var o = $(this), 1023 current = o.attr('href'); 1024 1025 $('.shop-tabs .shop-tabs-nav li').removeClass(active); 1026 o.parent().addClass(active); 1027 $('.shop-tabs .shop-tab').hide().removeClass('shop-tabs-active'); 1028 $(current).show().addClass('shop-tabs-active'); 1029 return false;
1030 }); 1031 1032 $('.shop-tabs .shop-tab').hide().eq(0).show().addClass('shop-tabs-active'); 1033 $('.shop-tabs .shop-tabs-nav li').eq(0).addClass(active); 1034 })(); 1035 1036 //Скидки, подÑказки 1037 (function() { 1038 var info; 1039 $('#shop2-cart').append('<div id="discount-info"></div>'); 1040 info = $('#discount-info'); 1041 $('a.discount-info').hover(function() { 1042 var o = $(this), 1043 pos = o.position(), 1044 text = '', 1045 href = o.attr('href'); 1046 1047 if (o.attr('href') == '#') { 1048 text = o.attr('title'); 1049 } else { 1050 text = $(href).html(); 1051 } 1052 1053 info.html(text).show(); 1054 1055 info.css({ 1056 top: pos.top - info.outerHeight(true) - 5, 1057 left: pos.left + 20 1058 }); 1059 1060 }, function() { 1061 info.hide(); 1062 }); 1063 })(); 1064 1065 //ÐоÑÑавка 1066 (function() { 1067 var deliveries = $('div.delivery-type'); 1068 deliveries.click(function() { 1069 deliveries.removeClass('delivery-type-current'); 1070 $(this).addClass('delivery-type-current'); 1071 }); 1072 })(); 1073 1074 //ÐплаÑа 1075 (function() { 1076 var payments = $('div.payment-type'); 1077 payments.find('label').click(function() { 1078 payments.removeClass('payment-type-current'); 1079 $(this).parent().addClass('payment-type-current'); 1080 }); 1081 })(); 1082 1083 (function() { 1084 var btn = $('a.shop2-filter-show'), 1085 tr = $('tr.shop2-filter-custom-fields'); 1086 1087 var alt = btn.data('alt') || shopClient.locale.hideParams, 1088 text = btn.html() || shopClient.locale.allParams; 1089 1090 btn.click(function() { 1091 if (tr.is(':visible')) { 1092 tr.hide(); 1093 btn.html(text); 1094 createCookie('custom-fields', 0, 90); 1095 } else { 1096 tr.show(); 1097 btn.html(alt); 1098 createCookie('custom-fields', 1, 90); 1099 } 1100 return false; 1101 }); 1102 1103 var flag = readCookie('custom-fields'); 1104 if (flag == 1) { 1105 tr.show(); 1106 btn.html(alt); 1107 createCookie('custom-fields', 1, 90); 1108 } else { 1109 tr.hide(); 1110 btn.html(text); 1111 createCookie('custom-fields', 0, 90); 1112 } 1113 })(); 1114 1115 //ÐÑÑавнивание по вÑÑоÑе в ÑпиÑке 1116 (function() { 1117 1118 function getMaxHeight(group_heads, group_foots) { 1119 var max = 0; 1120 group_heads.each(function(i) { 1121 var o = $(this), 1122 height; 1123 o.css('min-height', 10); 1124 height = o.height() + group_foots.eq(i).outerHeight(true); 1125 if (height > max) { 1126 max = height; 1127 } 1128 }); 1129 return max; 1130 } 1131 1132 var setHeights = shop2._setHeights = function() { 1133 var wrap = $('div.tpl-product-list-v'); 1134 1135 wrap.each(function() { 1136 var wrap = $(this), 1137 items = wrap.find('div.product-item'), 1138 heads = wrap.find('div.product-top'), 1139 foots = wrap.find('div.product-bot'), 1140 inRow = 0, 1141 left, right, group_heads, group_foots, max = 0; 1142 1143 if (wrap.get(0) && items.get(0)) { 1144 var marginRight = parseInt(items.eq(0).css('margin-right')); 1145 var width = wrap.width(); 1146 var itemWidth = items.eq(0).outerWidth(true); 1147 inRow = Math.floor(width / itemWidth); 1148 1149 if (width % itemWidth >= itemWidth - marginRight) { 1150 inRow++; 1151 } 1152 1153 if (inRow > 1) { 1154 for (var i = 0; i < heads.length; i += inRow) { 1155 left = i; 1156 right = i + inRow; 1157 if (right > heads.length) { 1158 right = heads.length; 1159 } 1160 group_heads = heads.slice(left, right); 1161 group_foots = foots.slice(left, right); 1162 max = getMaxHeight(group_heads, group_foots); 1163 1164 group_heads.each(function(i) { 1165 $(this).css('min-height', max - group_foots.eq(i).outerHeight(true)); 1166 }); 1167 } 1168 } 1169 } 1170 }); 1171 }; 1172 1173 setHeights(); 1174 1175 $(window).resize(setHeights).load(setHeights); 1176 1177 if (shop2 && shop2.product && shop2.product.reload) { 1178 var reload = shop2.product.reload; 1179 1180 shop2.product.reload = function(node, pageType, cb) { 1181 if (pageType == 'product') { 1182 reload.call(this, node, 'product', cb); 1183 } else { 1184 if (!cb) { 1185 cb = setHeights; 1186 } 1187 reload.call(this, node, null, cb); 1188 } 1189 } 1190 } 1191 })(); 1192 1193 //ФилÑÑÑÑем ввод 1194 $('table.tpl-product-list-p input:text, input[name=amount]').keyFilter(shopClient.defaults.minAmount, shopClient.defaults.unitType); 1195 1196 $('td.shop2-cart-amount input:text').keyFilter(0, shopClient.defaults.unitType, function() { 1197 $('#recount-button').show(); 1198 }); 1199 1200 //ÐÑовеÑÑем коÑÐ·Ð¸Ð½ÐºÑ 1201 shopClient.Cart.check(); 1202 1203 //ÐниÑиализаÑÐ¸Ñ ÑилÑÑÑа 1204 shopClient.Filter.init(); 1205 1206 if (shopClient.defaults.minAmount != 1) { 1207 $('table.tpl-product-list-p input:text, input[name=amount]').val(shopClient.defaults.minAmount); 1208 } 1209 1210 $('form .tpl-stars').each(function() { 1211 var $this = $(this), 1212 selected = null, 1213 stars = $this.children('span'), 1214 input = $this.children('input'); 1215 1216 function choose(elem) { 1217 elem = $(elem); 1218 stars.removeClass('tpl-active'); 1219 elem.addClass('tpl-active').prevAll().addClass('tpl-active'); 1220 } 1221 1222 $this.on({ 1223 click: function(e) { 1224 selected = e.target; 1225 input.val($(selected).index() + 1); 1226 }, 1227 mousemove: function(e) { 1228 choose(e.target); 1229 }, 1230 mouseleave: function(e) { 1231 choose(selected); 1232 } 1233 }); 1234 1235 }); 1236 1237 1238 (function() { 1239 1240 var $document = $(document); 1241 1242 function update(el, res) { 1243 1244 // el.closest('.product-compare').replaceWith(res.data); 1245 $('input[type=checkbox][value=' + el.val() + ']').closest('.product-compare').replaceWith(res.data); 1246 1247 $('.product-compare-added a span').html('(' + res.count + ')'); 1248 1249 if (res.panel) { 1250 $('#shop2-panel').replaceWith(res.panel); 1251 } 1252 1253 } 1254 1255 $document.on('click', '.product-compare input:checkbox', function() { 1256 var $this = $(this), 1257 action = !($this.attr('checked') || $this.prop('checked')) ? 'del' : 'add'; 1258 1259 shopClient.Compare.action(action, $this.val(), function(res, status) { 1260 if (status == 'success') { 1261 1262 if (res.errstr) { 1263 alert(res.errstr); 1264 $this.prop('checked', false); 1265 } else { 1266 update($this, res); 1267 } 1268 } 1269 }); 1270 1271 return false;
1272 }); 1273 1274 })(); 1275 1276 1277 (function() { 1278 1279 var tpl = [ 1280 '<div id="shop2-alert">', 1281 '<div id="shop2-alert-body"></div>', 1282 '<a href="#" id="shop2-alert-ok" class="shop2-btn"></a>', 1283 '</div>', 1284 '<div id="shop2-alert-overlay"></div>' 1285 ].join('\n'), 1286 1287 win, 1288 overlay, 1289 body, 1290 ok, 1291 cls; 1292 1293 $(document.body).append(tpl); 1294 1295 win = $('#shop2-alert'); 1296 overlay = $('#shop2-alert-overlay'); 1297 body = $('#shop2-alert-body'); 1298 ok = $('#shop2-alert-ok'); 1299 1300 function hide() { 1301 overlay.hide(); 1302 win.hide(); 1303 win.removeAttr('class'); 1304 cls = ''; 1305 shopClient.trigger('alertHide', win); 1306 return false; 1307 } 1308 1309 function show() { 1310 overlay.show(); 1311 win.attr('class', cls); 1312 win.show().s3center(); 1313 shopClient.trigger('alertShow', win); 1314 } 1315 1316 overlay.on('click', hide); 1317 ok.on('click', hide); 1318 1319 shopClient.alert = function(msg, btn, c) { 1320 ok.html(btn || 'Ok'); 1321 body.html(msg); 1322 cls = c || ''; 1323 show(); 1324 }; 1325 1326 shopClient.alert.hide = hide; 1327 1328 })(); 1329 1330 1331 (function() { 1332 1333 var edost = $('[id^=delivery][id$=html]'); 1334 if (!edost.get(0)) return; 1335 var id = edost.attr('id'); 1336 if (!id) return; 1337 var attach_id = id.replace(/[^\d]/g, ''); 1338 if (!attach_id) return; 1339 1340 shop2.delivery.edost(attach_id); 1341 1342 })(); 1343 1344 (function() { 1345 1346 $('.shop2-color-ext-list li').s3tooltip({ 1347 1348 cls: 'shop2-color-ext-tooltip', 1349 dir: 'top', 1350 data: function() { 1351 return $(this).children('div').html(); 1352 } 1353 1354 }); 1355 1356 $('.shop2-color-ext-multi').s3tooltip({ 1357 1358 cls: 'shop2-color-ext-tooltip', 1359 dir: 'top', 1360 data: function() { 1361 var ul = this.getElementsByTagName('ul'); 1362 if (ul.length) { 1363 return ul[0].outerHTML; 1364 } 1365 } 1366 1367 }); 1368 1369 })(); 1370 1371 1372 (function() { 1373 1374 var popup = $('<div id="shop2-color-ext-popup"></div>'); 1375 var close = $('<div id="shop2-color-ext-close"></div>'); 1376 var list = $('<ul id="shop2-color-ext-list" class="shop2-color-ext-list"></ul>'); 1377 var colors = null; 1378 1379 popup.append(close); 1380 popup.append(list); 1381 $(document.body).append(popup); 1382 1383 $(document).on({ 1384 1385 click: function() { 1386 var caption = $(this); 1387 var wrap = caption.closest('.shop2-color-ext-popup'); 1388 var ul = wrap.find('.shop2-color-ext-list'); 1389 var offset = caption.offset(); 1390 1391 colors = ul.children('li'); 1392 list.html(ul.html()); 1393 1394 popup.css(offset).show(); 1395 1396 return false; 1397 } 1398 1399 }, '.shop2-color-ext-caption'); 1400 1401 $(document).on({ 1402 click: function() { 1403 var $this = $(this); 1404 var index = $this.index(); 1405 var data = $this.data(); 1406 1407 $this.toggleClass('shop2-color-ext-selected'); 1408 colors.eq(index).toggleClass('shop2-color-ext-selected'); 1409 1410 shopClient.Filter.addParam(data.name, data.value, this); 1411 shopClient.Filter.getCount(); 1412 } 1413 }, '#shop2-color-ext-list li'); 1414 1415 $(document).on('click', function(e) { 1416 var target = $(e.target); 1417 var wrap = target.closest('#shop2-color-ext-popup'); 1418 1419 if (!wrap.get(0) || e.target == close.get(0)) { 1420 popup.hide(); 1421 } 1422 }); 1423 1424 })(); 1425 1426 1427 (function() { 1428 1429 var select = $('<div id="shop2-color-ext-select"><ins></ins></div>'); 1430 var colors = null; 1431 var input = null; 1432 $(document.body).append(select); 1433 1434 function hide() { 1435 if (select.is(':visible')) { 1436 select.hide(); 1437 return true; 1438 } 1439 } 1440 1441 $(document).on('click', hide); 1442 1443 $(document).on({ 1444 1445 click: function() { 1446 1447 if (hide()) { 1448 return; 1449 } 1450 1451 var wrap = $(this); 1452 var ul = wrap.find('.shop2-color-ext-options'); 1453 var offset = wrap.offset(); 1454 1455 var html = 1456 '<div class="baron-wrapper">' + 1457 ' <div class="baron-scroller">' + 1458 ' <div class="baron-container">' + 1459 ' <div class="shop2-color-ext-options">' + 1460 ul.html() + 1461 ' </div>' + 1462 ' </div>' + 1463 ' <div class="baron-scroller-bar"></div>' + 1464 ' </div>' + 1465 '</div>'; 1466 1467 colors = ul.children('li'); 1468 input = wrap.find('input'); 1469 1470 select.html(html) 1471 select.show(); 1472 1473 var wrapWidth = wrap.width(); 1474 var selectWidth = select.data('width') || (function() { 1475 var width = select.width(); 1476 select.data('width', width); 1477 return width; 1478 })(); 1479 1480 if (wrapWidth > selectWidth) { 1481 select.css('width', wrapWidth); 1482 } else { 1483 select.css('width', selectWidth); 1484 } 1485 1486 baron(select, { 1487 scroller: '.baron-scroller', 1488 container: '.baron-container', 1489 bar: '.baron-scroller-bar' 1490 }); 1491 1492 select.css(offset); 1493 1494 return false;
1495 1496 } 1497 1498 }, '.shop2-color-ext-select'); 1499 1500 $(document).on({ 1501 1502 click: function() { 1503 var $this = $(this); 1504 var index = $this.index(); 1505 var data = $this.data(); 1506 var item = colors.eq(index); 1507 1508 $this.addClass('shop2-color-ext-selected').siblings().removeClass('shop2-color-ext-selected'); 1509 colors.removeClass('shop2-color-ext-selected'); 1510 item.addClass('shop2-color-ext-selected'); 1511 1512 if (data.kinds) { 1513 item.attr('data', data.kinds); 1514 shop2.product.reload(item.get(0), shopClient.mode); 1515 } else { 1516 input.val(data.value); 1517 } 1518 1519 } 1520 1521 }, '#shop2-color-ext-select li:not(.shop2-color-ext-selected)'); 1522 1523 })(); 1524 1525 1526 (function() { 1527 1528 var custom = $('#shop2_search_custom_fields'), 1529 global = $('#shop2_search_global_fields'), 1530 folders = $('#s\\[folder_id\\]'); 1531 1532 folders.change(function() { 1533 var folder_id = folders.val(); 1534 1535 if (!folder_id) { 1536 custom.html(''); 1537 global.find('input, select').prop('disabled', false); 1538 global.show(); 1539 } 1540 1541 }); 1542 1543 shopClient.on('afterGetFolderCustomFields', function(d) { 1544 var folder_id = folders.val(); 1545 1546 if (folder_id) { 1547 1548 custom.html(d.data); 1549 global.find('input, select').prop('disabled', true); 1550 global.hide(); 1551 1552 } 1553 1554 }); 1555 1556 folders.trigger('change'); 1557 1558 })(); 1559 1560 1561 1562});
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.