1/************************** 2* 3* http://modx-shopkeeper.ru/ 4* Shopkeeper 2.3.6 - shopping cart for MODX 2.x Revolution 5* 6**************************/ 7 8if(typeof(site_base_url)=='undefined'){ 9 var site_base_url = jQuery('base').size()>0 10 ? jQuery('base:first').attr('href') 11 : window.location.protocol+'//'+window.location.host+'/'; 12} 13 14var shk_timer; 15 16//ÐаÑÑÑойки по ÑмолÑÐ°Ð½Ð¸Ñ 17var shkOptDefault = { 18 'prop_name': 'default', 19 'prodCont': 'div.shk-item', 20 'lang': 'ru', 21 'style':'default', 22 'cartTpl': ['@FILE shopCart.tpl','',''], 23 'flyToCart': 'helper', 24 'currency': 'ÑÑб.', 25 'orderFormPage': '0', 26 'orderFormPageUrl': '/', 27 'goToOrderFormPage': false, 28 'priceTV': 'price', 29 'noCounter': false, 30 'changePrice': false, 31 'counterField': false, 32 'counterFieldCart': false, 33 'tocartImage_width': 70, 34 'tocartImage_height': 70, 35 'noLoader': false, 36 'animCart': true, 37 'allowFloatCount': false, 38 'debug': false, 39 'psn': '', 40 'shkHelper': '<div id="shk_prodHelper"><div><b id="shk_prodHelperName"></b></div>' 41 +"\n"+'<div class="shs-count" id="shk_prodCount">'+langTxt['count']+' <input type="text" size="2" name="count" value="1" maxlength="3" />' 42 +'</div><div><button class="shk-but" id="shk_confirmButton">'+langTxt['continue']+'</button> ' 43 +"\n"+'<button class="shk-but" id="shk_cancelButton">'+langTxt['cancel']+'</button></div></div>' 44 +"\n" 45}; 46 47jQuery.fn.setCounterToField = function(opt){ 48 var opt = jQuery.extend({img_path:'assets/components/shopkeeper/css/web/default/img/', wrapdiv:false, allowFloatCount:false, callback:function(){}}, opt); 49 var imgpath = site_base_url+opt.img_path; 50 function shk_checkKey(e){ 51 var key_code = e.which ? e.which : e.keyCode; 52 var allowed = [8]; 53 if(opt.allowFloatCount) allowed.push(44,46); 54 return (key_code>47&&key_code<58)||jQuery.inArray(key_code, allowed)>-1 ? true : false; 55 } 56 var countButs = '<img class="field-arr-up" src="'+imgpath+'arr_up.gif" width="17" height="9" alt="" />' 57 + '<img class="field-arr-down" src="'+imgpath+'arr_down.gif" width="17" height="9" alt="" />'+"\n"; 58 59 if(opt.wrapdiv) jQuery(this).wrap('<div></div>'); 60 61 jQuery(this) 62 //.css({'border':'1px solid #888','vertical-align':'bottom','text-align':'center'}) 63 .after(countButs) 64 .keypress(function(e){return shk_checkKey(e);}); 65 66 jQuery(this).each(function(){ 67 var field = this; 68 jQuery(this).next('img').click(function(){ 69 var count = parseInt(jQuery(field).val()); 70 if((count+1)>=1) jQuery(field).val(count+1); 71 opt.callback(); 72 }) 73 .css({'cursor':'pointer','margin':'0 0 11px 1px','vertical-align':'bottom'}) 74 .next('img').click(function(){ 75 var count = parseInt(jQuery(field).val()); 76 if((count-1)>=1) jQuery(field).val(count-1); 77 opt.callback(); 78 }) 79 .css({'cursor':'pointer','margin':'0 0 1px -17px','vertical-align':'bottom'}); 80 }); 81 82 return this; 83} 84 85jQuery.fn.reverse = function() { 86 return this.pushStack(this.get().reverse(), arguments); 87}; 88 89jQuery.each(['prev', 'next'], function(unusedIndex, name) { 90 jQuery.fn[name + 'AllElem'] = function(parentSelector,matchExpr) { 91 var $all = jQuery(parentSelector).find('*').andSelf(); 92 $all = (name == 'prev') ? $all.slice(0, $all.index(this)).reverse() : $all.slice($all.index(this) + 1); 93 if (matchExpr) $all = $all.filter(matchExpr); 94 return $all; 95 }; 96}); 97 98jQuery.fn.shopkeeper = function(){ 99 100 // jQuery 1.7+ 101 if(shkOpt.debug && parseFloat(jQuery.fn.jquery)<1.07) alert(langTxt['error_jqVersion']+jQuery.fn.jquery); 102 103 //ÑÑнкÑÐ¸Ñ Ð½Ð° ÑобÑÑие оÑпÑавки (submit) ÑоÑÐ¼Ñ ÑоваÑа 104 jQuery(document).on('submit', this.selector+' form', function(){ 105 SHK.toCart(this); 106 return false; 107 }); 108 //ÑÑнкÑÐ¸Ñ Ð½Ð° ÑобÑÑие клик по ÑÑÑлке "ÐÑиÑÑиÑÑ ÐºÐ¾Ñзин
108Ñ" 109 jQuery(document).on('click', '#shk_butEmptyCart', function(){ 110 SHK.deleteItem('all',this); 111 return false; 112 }); 113 //ÑÑнкÑÐ¸Ñ Ð½Ð° ÑобÑÑие клик по ÐºÐ½Ð¾Ð¿ÐºÑ "УдалиÑÑ ÑÐ¾Ð²Ð°Ñ Ð¸Ð· коÑзинÑ" 114 jQuery(document).on('click', '#shopCart a.shk-del', function(){ 115 var index = jQuery(this).prevAllElem('#shopCart','a.shk-del').size(); 116 SHK.deleteItem(index,this); 117 return false; 118 }); 119 //ÑÑнкÑÐ¸Ñ Ð½Ð° ÑобÑÑие focus в поле Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ñ ÐºÐ¾Ð»-ва ÑоваÑа в коÑзине 120 if(!shkOpt.counterFieldCart){ 121 jQuery(document).on('focus', '#shopCart input.shk-count', function(){ 122 var index = jQuery(this).prevAllElem('#shopCart','input.shk-count').size(); 123 SHK.recountItem(index,this); 124 return false; 125 }); 126 //Ðбновление коÑÐ·Ð¸Ð½Ñ Ð¿Ñи изменении ÑиÑла в поле кол-ва ÑоваÑов в коÑзине 127 }else{ 128 jQuery(document).on('keyup', '#shopCart input.shk-count', function(){ 129 SHK.changeCartItemsCount(); 130 }); 131 } 132 //пÑименÑеÑÑÑ Ð¿Ð»Ð°Ð³Ð¸Ð½ setCounterToField Ð´Ð»Ñ Ð²ÑÐµÑ Ð¿Ð¾Ð»ÐµÐ¹ кол-ва ÑоваÑов на ÑÑÑаниÑе (ÑÑÑелки болÑÑ/менÑÑе) 133 if(shkOpt.counterField){ 134 jQuery("input[name='shk-count']",jQuery(this)).not(':hidden').setCounterToField(shkOpt); 135 } 136 //вÑзов иниÑиализаÑии Ð´Ð¾Ð±Ð°Ð²Ð»ÐµÐ½Ð¸Ñ ÐºÐ½Ð¾Ð¿Ð¾Ðº "болÑÑе/менÑÑе" к полÑм кол-ва в коÑзине 137 if(shkOpt.counterFieldCart) SHK.counterFieldCartInit(); 138 return this; 139} 140 141/** 142 * Shopkeeper 143 */ 144var SHK = { 145 146 settings_qs: '', 147 148 data: {price_total:0, items_total:0, items_unique_total:0}, 149 150 round: function round (value, precision, mode) { 151 var m, f, isHalf, sgn; 152 precision |= 0; 153 m = Math.pow(10, precision); 154 value *= m; 155 sgn = (value > 0) | -(value < 0); 156 isHalf = value % 1 === 0.5 * sgn; 157 f = Math.floor(value); 158 159 if (isHalf) { 160 switch (mode) { 161 case 'PHP_ROUND_HALF_DOWN': 162 value = f + (sgn < 0); 163 break; 164 case 'PHP_ROUND_HALF_EVEN': 165 value = f + (f % 2 * sgn); 166 break; 167 case 'PHP_ROUND_HALF_ODD': 168 value = f + !(f % 2); 169 break; 170 default: 171 value = f + (sgn > 0); 172 } 173 } 174 175 return (isHalf ? value : Math.round(value)) / m; 176 }, 177 178 number_format: function(number, decimals, dec_point, thousands_sep) { 179 number = (number + '').replace(/[^0-9+\-Ee.]/g, ''); 180 var n = !isFinite(+number) ? 0 : +number, 181 prec = !isFinite(+decimals) ? 0 : Math.abs(decimals), 182 sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep, 183 dec = (typeof dec_point === 'undefined') ? '.' : dec_point, 184 s = '', 185 toFixedFix = function (n, prec) { 186 var k = Math.pow(10, prec); 187 return '' + Math.round(n * k) / k; 188 }; 189 // Fix for IE parseFloat(0.55).toFixed(0) = 0; 190 s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.'); 191 if (s[0].length > 3) { 192 s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep); 193 } 194 if ((s[1] || '').length < prec) { 195 s[1] = s[1] || ''; 196 s[1] += new Array(prec - s[1].length + 1).join('0'); 197 } 198 var out = s.join(dec); 199 return out; 200 }, 201 202 numFormat: function(n){ 203 return this.number_format(n, (Math.floor(n)===n ? 0 : 2), '.', ' '); 204 }, 205 206 /** 207 * ÐоказÑÐ²Ð°ÐµÑ Ð±Ð»Ð¾Ðº Ñ Ð¿Ð¾Ð´ÑвеÑждением дейÑÑвий 208 */ 209 showHelper: function(elem,name,noCounter,func){ 210 if(typeof(jQuery(elem).get(0))=='undefined') return; 211 if(typeof(func)=='undefined') var func = function(){}; 212 jQuery('#shk_prodHelper').remove(); 213 jQuery('body').append(shkOpt.shkHelper); 214 jQuery('#shk_cancelButton').click(function(){ 215 jQuery('#shk_prodHelper').fadeOut(300,function(){jQuery(this).remove()}); 216 return false; 217 }); 218 jQuery('#shk_confirmButton').click(function(){ 219 func(); 220 return false; 221 }); 222 if(noCounter){ 223 jQuery('#shk_prodCount').remove(); 224 }else{
225 jQuery('input:text','#shk_prodCount').setCounterToField(shkOpt); 226 } 227 var elHelper = jQuery('#shk_prodHelper'); 228 var btPos = this.getCenterPos(elHelper,elem); 229 if(name){ 230 jQuery('#shk_prodHelperName').html(name); 231 }else{ 232 jQuery('#shk_prodHelperName').remove(); 233 } 234 jQuery('#shk_prodHelper').css({'top':btPos.y+'px','left':btPos.x+'px'}).fadeIn(500); 235 }, 236 237 /** 238 * ÐоказÑÐ²Ð°ÐµÑ Ð¿ÑÐµÐ»Ð¾Ð°Ð´ÐµÑ 239 */ 240 showLoading: function(show){ 241 if(!shkOpt.noLoader){ 242 if(show==true){ 243 jQuery('body').append('<div id="shk_Loading"></div>'); 244 var loader = jQuery('#shk_Loading'); 245 var shopCart = jQuery('#shopCart'); 246 var btPos = this.getCenterPos(loader,shopCart); 247 jQuery('#shk_Loading').css({'top':btPos.y+'px','left':btPos.x+'px'}).fadeIn(300); 248 }else{ 249 jQuery('#shk_Loading').fadeOut(300,function(){ 250 jQuery(this).remove(); 251 }); 252 } 253 } 254 }, 255 256 /** 257 * ÐпÑеделение кооÑÐ´Ð¸Ð½Ð°Ñ (позиÑии) ÑлеменÑа 258 */ 259 getPosition: function(elem){ 260 var el = jQuery(elem).get(0); 261 var p = {x: el.offsetLeft, y: el.offsetTop} 262 while (el.offsetParent){ 263 el = el.offsetParent; 264 p.x += el.offsetLeft; 265 p.y += el.offsetTop; 266 if (el != document.body && el != document.documentElement){ 267 p.x -= el.scrollLeft; 268 p.y -= el.scrollTop; 269 } 270 } 271 return p; 272 }, 273 274 /** 275 * ÐпÑеделÑÐµÑ Ð¿Ð¾Ð·Ð¸ÑÐ¸Ñ Ð´Ð»Ñ Ð±Ð»Ð¾ÐºÐ° оÑноÑÑиÑелÑно ÑенÑÑа дÑÑгого блока 276 */ 277 getCenterPos: function(elA,elB,Awidth,Aheight){ 278 if(typeof(Awidth)=='undefined') Awidth = jQuery(elA).outerWidth(); 279 if(typeof(Aheight)=='undefined') Aheight = jQuery(elA).outerHeight(); 280 posB = new Object(); 281 cntPos = new Object(); 282 posB = this.getPosition(elB); 283 cntPos.x = Math.round((jQuery(elB).outerWidth()-Awidth)/2)+posB.x; 284 cntPos.y = Math.round((jQuery(elB).outerHeight()-Aheight)/2)+posB.y; 285 if(cntPos.x+Awidth>jQuery(window).width()){ 286 cntPos.x = Math.round(jQuery(window).width()-jQuery(elA).outerWidth())-2; 287 } 288 if(cntPos.x<0){ 289 cntPos.x = 2; 290 } 291 return cntPos; 292 }, 293 294 /** 295 * ÐÑкÑ-запÑÐ¾Ñ Ð´Ð»Ñ Ð¾ÑпÑавки даннÑÑ Ð¸ полÑÑÐµÐ½Ð¸Ñ HTML-кода обновленной коÑÐ·Ð¸Ð½Ñ 296 */ 297 ajaxRequest: function(params,refresh){ 298 if(typeof(refresh)=='undefined') var refresh = true; 299 jQuery.ajax({ 300 type: "POST", 301 cache: false, 302 dataType: 'json', 303 url: site_base_url+'assets/components/shopkeeper/connector_fe.php', 304 data: params+SHK.settings_qs+'&psn='+encodeURIComponent(shkOpt.psn),//jQuery.extend({},{psn:shkOpt.psn}) 305 success: function(data){ 306 SHK.showLoading(false); 307 if(typeof(data.price_total)!='undefined') SHK.data.price_total = data.price_total; 308 if(typeof(data.items_total)!='undefined') SHK.data.items_total = data.items_total; 309 if(typeof(data.items_unique_total)!='undefined') SHK.data.items_unique_total = data.items_unique_total; 310 if(typeof(data.ids)!='undefined') SHK.data.ids = data.ids; 311 if(shkOpt.goToOrderFormPage && window.location.href.indexOf(shkOpt.orderFormPageUrl)==-1 && data.items_total>0){ 312 window.location.href = shkOpt.orderFormPageUrl; 313 return; 314 } 315 if(refresh){ 316 if(window.location.href.indexOf('/'+shkOpt.orderFormPageUrl)>-1){ 317 jQuery('#shk_butOrder').hide(); 318 } 319 var cartHeight = jQuery('#shopCart').height(); 320 if(typeof(data.html)!='undefined') jQuery('#shopCart').replaceWith(data.html);
321 if(window.location.href.indexOf('/'+shkOpt.orderFormPageUrl)>-1){ 322 jQuery('#shk_butOrder').hide(); 323 } 324 var cartheightNew = jQuery('#shopCart').height(); 325 if(shkOpt.animCart) SHK.animCartHeight(cartHeight,cartheightNew); 326 } 327 if(typeof(SHKloadCartCallback)=='function') SHKloadCartCallback(); 328 if(shkOpt.counterFieldCart) SHK.counterFieldCartInit(); 329 } 330 ,error: function(jqXHR, textStatus, errorThrown){ 331 if(typeof(console)!='undefined') console.log(textStatus+' '+errorThrown); 332 } 333 }); 334 }, 335 336 /** 337 * Удаление ÑоваÑа из коÑÐ·Ð¸Ð½Ñ 338 */ 339 deleteItem: function(num,el,refresh){ 340 if(typeof(refresh)=='undefined') var refresh = true; 341 var thisAction = function(){ 342 if(num!='all'){ 343 SHK.showLoading(true); 344 var getParams = '&action=delete&index='+num; 345 SHK.ajaxRequest(getParams,refresh); 346 }else{ 347 SHK.emptyCart(); 348 } 349 jQuery('#shk_prodHelper').fadeOut(500,function(){ 350 jQuery(this).remove(); 351 }); 352 } 353 if(el!=null){ 354 this.showHelper(el,langTxt['confirm'],true,thisAction); 355 jQuery('#shk_confirmButton').text(langTxt['yes']); 356 }else{ 357 thisAction(); 358 } 359 }, 360 361 /** 362 * ÐеÑеÑÑÐµÑ ÐºÐ¾Ð»-ва ÑоваÑа в коÑзине 363 */ 364 recountItem: function(num,el){ 365 var thisAction = function(){ 366 var count = jQuery('input:text','#shk_prodCount').val(); 367 jQuery('#shk_prodHelper').fadeOut(500,function(){ 368 jQuery(this).remove(); 369 }); 370 if(typeof(SHKrecountItemCallback)=='function'){ 371 if(!SHKrecountItemCallback(count,el)) return; 372 } 373 SHK.showLoading(true); 374 var getParams = '&action=recount&index='+num+'&count='+count; 375 SHK.ajaxRequest(getParams); 376 } 377 this.showHelper(el,false,false,thisAction); 378 el.blur(); 379 var thisCount = parseFloat(jQuery(el).val().replace(',','.')); 380 jQuery('input:text','#shk_prodCount').val(thisCount); 381 }, 382 383 /** 384 * ÐеÑеÑÑÐµÑ Ð²ÑÐµÑ ÑоваÑов в коÑзине 385 */ 386 recountItemAll: function(){ 387 var cartData = jQuery("#shopCart input[name='count[]']").serialize(); 388 if(typeof(SHKrecountItemCallback)=='function'){ 389 if(!SHKrecountItemCallback(count,el)) return; 390 } 391 var getParams = '&action=recount_all'; 392 if(cartData.length>0) getParams += '&'+cartData; 393 SHK.showLoading(true); 394 SHK.ajaxRequest(getParams); 395 }, 396 397 /** 398 * ÐниÑиализаÑÐ¸Ñ Ð´Ð¾Ð±Ð°Ð²Ð»ÐµÐ½Ð¸Ñ ÐºÐ½Ð¾Ð¿Ð¾Ðº "болÑÑе/менÑÑе" к полÑм кол-ва в коÑзине 399 */ 400 counterFieldCartInit: function(){ 401 jQuery("#shopCart input.shk-count").setCounterToField(jQuery.extend({'callback':SHK.changeCartItemsCount}, shkOpt)); 402 }, 403 404 /** 405 * ÐÑзов ÑÑнкÑии пеÑеÑÑÑÑа обÑей ÑÐµÐ½Ñ ÑоваÑов в коÑзине пÑи изменении кол-ва 406 */ 407 changeCartItemsCount: function(){ 408 clearTimeout(shk_timer); 409 shk_timer = setTimeout(function(){ 410 SHK.recountItemAll(); 411 },1000); 412 }, 413 414 /** 415 * Ðобавление ÑоваÑа в коÑÐ·Ð¸Ð½Ñ 416 */ 417 fillCart: function(thisForm,count,refresh){ 418 if(typeof(refresh)=='undefined') var refresh = true; 419 var shopCart = jQuery('#shopCart'); 420 this.showLoading(true); 421 var prodCount = typeof(count)!='undefined' && count!='' ? '&count='+count : ''; 422 var getParams = '&action=fill_cart'+SHK.settings_qs+prodCount; 423 var formData = typeof(thisForm)=='object' ? jQuery(thisForm).serialize() : 'shk-id='+thisForm; 424 if(typeof(SHKfillCartCallback)=='function') SHKfillCartCallback(thisForm); 425 this.ajaxRequest(getParams+'&'+formData,refresh); 426 }, 427 428 /** 429 * ÐизÑалÑнÑй ÑÑÑÐµÐºÑ Ð¿ÐµÑед добавлением ÑоваÑа в коÑзин
429Ñ 430 */ 431 toCart: function(thisForm){ 432 var el = jQuery(':submit,input[type="image"]',thisForm).eq(0);//jQuery('input[type="submit"],input[type="image"],button[type="submit"]',thisForm).eq(0); 433 var name = ''; 434 if(jQuery('input[name="shk-name"]',thisForm).size()>0){ 435 name = jQuery("input[name='shk-name']",thisForm).val(); 436 }else if(jQuery("h3",thisForm).size()>0){ 437 name = jQuery("h3",thisForm).text(); 438 } 439 switch(shkOpt.flyToCart){ 440 //////////////////////////////////////////// 441 //&flyToCart=`helper` 442 case 'helper': 443 var thisAction = function(){ 444 if(typeof(SHKtoCartCallback)=='function'){ 445 if(!SHKtoCartCallback(thisForm)) return false; 446 } 447 var count = jQuery('#shk_prodCount').is('*') && jQuery('input:text','#shk_prodCount').val().length>0 ? parseFloat(jQuery('input:text','#shk_prodCount').val().replace(',','.')) : ''; 448 jQuery('#shk_prodHelper').animate({ 449 top: cartPos.y+'px', 450 left: cartPos.x+'px' 451 },700).fadeOut(500,function(){ 452 jQuery(this).remove(); 453 SHK.fillCart(thisForm,count); 454 }); 455 } 456 this.showHelper(el,name,shkOpt.noCounter,thisAction); 457 var cartPos = this.getCenterPos(jQuery('#shk_prodHelper'),jQuery('#shopCart')); 458 break;
459 //////////////////////////////////////////// 460 //&flyToCart=`image` 461 case 'image': 462 if(typeof(SHKtoCartCallback)=='function'){ 463 if(!SHKtoCartCallback(thisForm)) return false; 464 } 465 var parent = jQuery(thisForm).parents(shkOpt.prodCont); 466 var image = jQuery('img.shk-image:first',parent); 467 if(jQuery(image).size()>0){ 468 var cart = jQuery('#shopCart'); 469 var btPos = this.getPosition(image); 470 var cartPos = this.getCenterPos(image,cart,shkOpt.tocartImage_width,shkOpt.tocartImage_height); 471 jQuery('img.shk-image:first',parent) 472 .clone(false) 473 .appendTo('body') 474 .css({'top':btPos.y+'px','position':'absolute','left':btPos.x+'px','opacity':0.75}) 475 .animate({ 476 top: cartPos.y+'px', 477 left: cartPos.x+'px', 478 width: shkOpt.tocartImage_width+'px', 479 height: shkOpt.tocartImage_height+'px' 480 },700).fadeOut(500,function(){ 481 jQuery(this).remove(); 482 SHK.fillCart(thisForm,0); 483 }); 484 }else{ 485 this.fillCart(thisForm,0); 486 } 487 this.showHelper(el,langTxt['addedToCart'],true); 488 jQuery('#shk_confirmButton,#shk_cancelButton').hide(); 489 clearTimeout(shk_timer); 490 shk_timer = setTimeout(function(){ 491 jQuery('#shk_prodHelper').fadeOut(500,function(){ 492 jQuery('#shk_prodHelper').remove(); 493 }); 494 },1000); 495 break;
496 //////////////////////////////////////////// 497 //&flyToCart=`scrollimage` 498 case 'scrollimage': 499 if(typeof(SHKtoCartCallback)=='function'){ 500 if(!SHKtoCartCallback(thisForm)) return false; 501 } 502 var parent = jQuery(thisForm).parents(shkOpt.prodCont); 503 var image = jQuery('img.shk-image:first',parent); 504 if(jQuery(image).size()>0){ 505 var yScroll = $.browser.msie ? document.documentElement.scrollTop : self.pageYOffset; 506 var cart = jQuery('#shopCart'); 507 var btPos = this.getPosition(image); 508 var cartPos = this.getCenterPos(image,cart,shkOpt.tocartImage_width,shkOpt.tocartImage_height); 509 var cartPosTop = cart.position().top; 510 if(yScroll < cartPosTop){ 511 cartPosTop -= (jQuery(window).height()-cart.height()); 512 if(cartPosTop < yScroll) cartPosTop = yScroll; 513 } 514 var baseDuration = 400; 515 var flyDuration = baseDuration + Math.round((Math.abs(btPos.y - cartPosTop)/baseDuration)*100); 516 var docBody = jQuery('html');//jQuery('html').scrollTop()>0 ? jQuery('html') : jQuery('body'); 517 docBody.animate({ 518 scrollTop: cartPosTop 519 }, 520 flyDuration, 521 function(){ 522 image 523 .clone(false) 524 .appendTo('body') 525 .css({'top':btPos.y+'px','position':'absolute','left':btPos.x+'px','opacity':0.75,'z-index':500}) 526 .animate({ 527 top: cartPos.y+'px', 528 left: cartPos.x+'px', 529 width: 60+'px', 530 height: 60+'px' 531 },flyDuration) 532 .fadeOut(500,function(){ 533 jQuery(this).remove(); 534 SHK.fillCart(thisForm,0); 535 docBody.animate({scrollTop:yScroll},flyDuration); 536 }); 537 } 538 ); 539 }else{ 540 this.fillCart(thisForm,0); 541 } 542 this.showHelper(el,langTxt['addedToCart'],true); 543 jQuery('#shk_confirmButton,#shk_cancelButton').hide(); 544 clearTimeout(shk_timer); 545 shk_timer = setTimeout(function(){ 546 jQuery('#shk_prodHelper').fadeOut(500,function(){ 547 jQuery('#shk_prodHelper').remove(); 548 }); 549 },1000); 550 break;
551 //////////////////////////////////////////// 552 //&flyToCart=`nofly` 553 case 'nofly': 554 if(typeof(SHKtoCartCallback)=='function'){ 555 if(!SHKtoCartCallback(thisForm)) return false; 556 } 557 this.fillCart(thisForm,0); 558 this.showHelper(el,langTxt['addedToCart'],true); 559 jQuery('#shk_confirmButton,#shk_cancelButton').hide(); 560 clearTimeout(shk_timer); 561 shk_timer = setTimeout(function(){ 562 jQuery('#shk_prodHelper').fadeOut(500,function(){ 563 jQuery('#shk_prodHelper').remove(); 564 }); 565 },1000); 566 break; 567 //////////////////////////////////////////// 568 default: 569 this.fillCart(thisForm,0); 570 break; 571 } 572 }, 573 574 /** 575 * ÐндикаÑÐ¸Ñ Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ñ Ð¿Ð°ÑамеÑÑа ÑоваÑа 576 */ 577 additOpt: function(elem){ 578 var thisName = jQuery(elem).attr('name'); 579 var thisNameArr = thisName.split('__'); 580 jQuery('#add_'+thisNameArr[1]).remove(); 581 var additPriceSum = 0; 582 var multiplication = new Array; 583 var parent = jQuery(elem).parents('form'); 584 var params_elems = jQuery('select.shk_param,input.shk_param:checked,input.shk_param:hidden',parent).not('*[name="'+thisName+'"]'); 585 if(!jQuery(elem).is('[type="checkbox"]') || (jQuery(elem).is(':checked'))) params_elems = params_elems.add(elem); 586 params_elems.each(function(i){ 587 var value = jQuery(this).val(); 588 var valArr = value.split('__'); 589 var price = valArr[1]!='' && !isNaN(valArr[1]) ? parseFloat(valArr[1]) : 0; 590 if(valArr[1]!='' && isNaN(valArr[1]) && valArr[1].indexOf('*')==0){ 591 multiplication[multiplication.length] = parseFloat(valArr[1].replace('*','')); 592 } 593 additPriceSum += price; 594 }); 595 if(additPriceSum!='' && !isNaN(additPriceSum) && !shkOpt.changePrice){ 596 additPriceSum = this.round(additPriceSum,2); 597 jQuery('.shk-price:first',parent).after('<sup id="add_'+thisNameArr[1]+'" class="price-add">+'+additPriceSum+'</sup>'); 598 }else if(!isNaN(additPriceSum) && shkOpt.changePrice!=false){ 599 var priceTxt = jQuery('.shk-price:first',parent); 600 var curPrice = jQuery(priceTxt).is(":has('span')") ? jQuery('span',priceTxt).text() : jQuery(priceTxt).text(); 601 var formated = curPrice.indexOf(' ') > 0; 602 if(shkOpt.changePrice=='replace'){ 603 var newPrice = additPriceSum>0 ? additPriceSum : parseFloat(curPrice.replace(/\D* /,'')); 604 }else{ 605 var newPrice = parseFloat(curPrice.replace(/\D* /,''))+additPriceSum; 606 for(var i=0;i<multiplication.length;i++){ 607 newPrice = newPrice*multiplication[i]; 608 } 609 } 610 newPrice = this.round(newPrice,2); 611 if(formated){ 612 newPrice = this.numFormat(newPrice); 613 } 614 jQuery(priceTxt).empty().append('<span style="display:none;">'+curPrice+'</span>'+newPrice); 615 } 616 }, 617 618 /** 619 * Ðобавление ÑоваÑов в коÑÐ·Ð¸Ð½Ñ Ð¿Ð¾ маÑÑÐ¸Ð²Ñ ID 620 */ 621 toCartFromArray: function(ids_arr,count_arr,shk_catalog,refresh){ 622 if(typeof(ids_arr)!='object') return; 623 if(typeof(count_arr)=='undefined') var count_arr = []; 624 if(typeof(shk_catalog)=='undefined') var shk_catalog = 1; 625 if(typeof(refresh)=='undefined') var refresh = true; 626 if(typeof(SHKfillCartCallback)=='function') SHKfillCartCallback(); 627 this.ajaxRequest('&action=add_from_array&ids='+ids_arr.join(',')+'&count='+count_arr.join(',')+'&shk-catalog='+shk_catalog,refresh); 628 }, 629 630 /** 631 * ÐÑиÑение коÑÐ·Ð¸Ð½Ñ 632 */ 633 emptyCart: function(refresh){ 634 if(typeof(refresh)=='undefined') var refresh = true; 635 this.showLoading(true); 636 if(typeof(SHKemptyCartCallback)=='function') SHKemptyCartCallback(); 637 this.ajaxRequest('&action=empty',refresh);//&cart_tpl='+shkOpt.cartTpl[0] 638 }, 639 640 /**
641 * Ðбновление коÑÐ·Ð¸Ð½Ñ 642 */ 643 refreshCart: function(loader){ 644 if(typeof(loader)=='undefined') loader = true; 645 if(loader) this.showLoading(true); 646 var getParams = '&action=refresh_cart'; 647 this.ajaxRequest(getParams); 648 }, 649 650 /** 651 * ÐÑименение ÑпоÑоба доÑÑавки Ð´Ð»Ñ Ð¾Ð±Ð½Ð¾Ð²Ð»ÐµÐ½Ð¸Ñ Ð¾Ð±Ñей ÑÐµÐ½Ñ Ð² коÑзине 652 */ 653 selectDelivery: function(value){ 654 var getParams = '&action=refresh_cart&shk_delivery='+value; 655 this.ajaxRequest(getParams); 656 }, 657 658 /** 659 * ÐнимаÑÐ¸Ñ Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ñ ÑазмеÑа коÑÐ·Ð¸Ð½Ñ 660 */ 661 animCartHeight: function(curH,newH){ 662 jQuery('#shopCart') 663 .css({'height':curH+'px','overflow':'hidden'}) 664 .animate({height:newH+'px'},500,function(){ 665 jQuery(this).css({'overflow':'visible','height':'auto'}); 666 }); 667 } 668 669 670} 671 672jQuery(document).bind('ready',function(){ 673 //ÐÑли Ð½Ð°Ñ Ð¾Ð´Ð¸Ð¼ÑÑ Ð½Ð° ÑÑÑаниÑе оÑоÑÐ¼Ð»ÐµÐ½Ð¸Ñ Ð·Ð°ÐºÐ°Ð·Ð°, ÑкÑÑваем ÑÑÑÐ»ÐºÑ Ð½Ð° ÑÑÑ ÑÑÑаниÑÑ 674 if(window.location.href.indexOf('/'+shkOpt.orderFormPageUrl)>-1){ 675 jQuery('#shk_butOrder').hide(); 676 } 677 //ÐниÑиализаÑÐ¸Ñ Ð´Ð¾Ð¿Ð¾Ð»Ð½Ð¸ÑелнÑÑ Ð¿Ð°ÑамеÑÑов 678 jQuery('select.shk_param,input.shk_param:checked',shkOpt.prodCont).each(function(){ 679 SHK.additOpt(this); 680 }); 681 if(typeof(SHKloadCartCallback)=='function') SHKloadCartCallback(true); 682});
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.