1$(document).ready(function() { 2 initPlaceholders(); 3 initTopPanel(); 4 initMainMenu(); 5 initPopovers(); 6// initRadiosCheckboxes(); 7 initSelects(); 8 initSteppers(); 9 initTabs(); 10 initFancyBox(); 11 initRating(); 12 initTipsy(); 13 initSidebar(); 14 fixIE7Links(); 15}); 16$(window).on('load', function(){ 17 // insert code here 18 initMainBannersCarousel(); 19 initHomeCategories(); 20 initProductsCarousel('slider'); 21 initProductsCarousel('bestsellers'); 22 initProductsCarousel('newest'); 23 initProductsCarousel('featured'); 24 initProductsCarousel('recommended'); 25 initProductsCarousel('related'); 26 initProductGalleries(); 27 initComparison(); 28 initProductsCarouselCompare('comparison'); 29 initHashChange(true); 30 31}); 32 33$.fn.hasAttr = function(name) { 34 var attr = this.attr(name); 35 return attr !== undefined && attr !== false; 36}; 37 38$.fn.parentsOrSelf = function(selector) { 39 if (this.is(selector)) { 40 return this; 41 } 42 if (this.parents(selector).length) { 43 } 44 return this.parents(selector); 45}; 46 47$.fn.parseIntCss = function(property) { 48 return parseInt(this.css(property), 10); 49}; 50 51// ÐозвÑаÑÐ°ÐµÑ Ð¼Ð°ÐºÑималÑное знаÑение ÑÑеди ÑезÑлÑÑаÑов обÑабоÑки колбÑков Ð´Ð»Ñ ÐºÐ°Ð¶Ð´Ð¾Ð³Ð¾ ÑлеменÑа маÑÑива 52$.fn.getCallbackMaxValue = function(callback) { 53 var result = -1; 54 this.each(function() { 55 result = Math.max(result, callback($(this))) 56 }); 57 return result; 58}; 59 60/** 61 * In IE7 the window.resize event is fired when any element on the page is resized. 62 * This workaround call callback only if window size was really changed since last event firing 63 */ 64$.windowResize = function(callback) { 65 if (!callback) { 66 return; 67 } 68 var $window = $(window); 69 var lastHeight = $window.height(); 70 var lastWidth = $window.width(); 71 $window.resize(function(e) { 72 if (!Modernizr.touch && $window.height() != lastHeight || 73 $window.width()!=lastWidth){ 74 lastHeight = $window.height(); 75 lastWidth =$window.width(); 76 callback(e); 77 } 78 }); 79}; 80 81/** 82 * Fix non-clickable links inside hasLayout elements in IE7 83 */ 84function fixIE7Links() { 85 var $body = $('.lt-ie8'); 86 $('a > *', $body).css('cursor', 'hand'); 87 $body.on('click', 'a > *', function() { 88 var $link = $(this).parents('a'); 89 if ($link.length) { 90 location.href = $link.attr('href'); 91 } 92 }); 93} 94 95function initPlaceholders() { 96 $('input[placeholder],textarea[placeholder]').placeholder(); 97} 98 99function closeMainMenu() { 100 var $mainMenu = $('.main-menu'); 101 $mainMenu.find('li').removeClass('active'); 102} 103 104function closePopovers() { 105 $('.popover').removeClass('active'); 106} 107 108function initTopPanel() { 109 var $topPanel = $('.top-panel'); 110 111 if ($('.left-panel').width() + $('.right-panel').width() > $('.top-panel .container').width() && $topPanel.css('position') == 'fixed') { 112 $topPanel.css('position', 'static'); 113 $('.main-menu').css('margin-top', '0'); 114 } 115} 116 117function initMainMenu() { 118 var $mainMenu = $('.main-menu'); 119 if (!$mainMenu.length) { 120 return; 121 } 122 123 $mainMenu.find('a').click(function() { 124 var $link = $(this); 125 var $menuItem = $link.parent(); 126 var $subMenu = $menuItem.find('ul'); 127 if ($subMenu.length > 0) { 128 if ($menuItem.hasClass('active')) { 129 $menuItem.removeClass('active'); 130 } else { 131 closeMainMenu(); 132 133 var $liWidthSum = $menuItem.width(); 134 $menuItem.siblings().each(function(){ 135 $liWidthSum += $(this).width(); 136 }); 137 138 var subMenuLeft = ($mainMenu.width() <= 1007 || ($menuItem.is(':last-child') && ($(window).width() <= 1280 || $liWidthSum - $mainMenu.width() > 50))) 139 ? $link.width() / 2 - $subMenu.width() / 2 140 : $link.width() - $subMenu.width() / 2 + 5; 141 142 $subMenu.css('left', subMenuLeft + 'px'); 143 $menuItem.addClass('active'); 144 } 145 return false; 146 } 147 return true; 148 }); 149 $('html').click(function() { 150 closeMainMenu(); 151 }); 152 $.windowResize(function() { 153 closeMainMenu(); 154 }); 155} 156//========================== 157function getOffset(elem){ 158 if (elem.getBoundingClientRect) { 159 // "пÑавилÑнÑй" ваÑÐ¸Ð°Ð½Ñ 160 return getOffsetRect(elem) 161 } else { 162 // пÑÑÑÑ ÑабоÑÐ°ÐµÑ Ñ Ð¾ÑÑ ÐºÐ°Ðº-Ñо 163 return getOffsetSum(elem) 164 } 165} 166 167function getOffsetSum(elem) { 168 var top=0, left=0 169 while(elem) { 170 top = top + parseInt(elem.offsetTop) 171 left = left + parseInt(elem.offsetLeft) 172 elem = elem.offsetParent 173 } 174//alert(top); 175 return {top: top, left: left} 176} 177 178function getOffsetRect(elem) { 179 // (1) 180 var box = elem.getBoundingClientRect() 181 182 // (2) 183 var body = document.body 184 var docElem = document.documentElement 185 186 // (3) 187 var scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop 188 var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft 189 190 // (4) 191 var clientTop = docElem.clientTop || body.clientTop || 0 192 var clientLeft = docElem.clientLeft || body.clientLeft || 0 193 194 // (5) 195 var top = Math.round(box.top + scrollTop - clientTop) 196 var left = Math.round(box.left + scrollLeft - clientLeft) 197 198 return { top: top, left: left } 199} 200//====================== 201function initPopovers() { 202 $('.popover-trigger').click(function() { 203 if ($('.popover').hasClass('active')) { 204 closePopovers(); 205 return false;
206 } 207 closePopovers(); 208 var scrollTop = window.pageYOffset || document.documentElement.scrollTop; 209 var $wind_top = $("#izmer").offset().top + $(".sticky-2").outerHeight(); 210 var $wind_left = $("#izmer").offset().left; 211 var $wind_width = $(window).width(); 212 var $wind_height = $(window).height(); 213 var $link = $(this); 214 var $popover = $($link.data('popover')); 215 var $popover_id = "#"+$popover.attr("id"); 216 var $parent_popover = $($popover_id).offsetParent(); 217 var $parent_popover_top = $parent_popover.offset().top; 218 var $parent_popover_left = $parent_popover.offset().left; 219 var $popover_width = $popover.outerWidth(); 220 var $popover_height = $popover.outerHeight(); 221 setTimeout(function() { 222 if($popover_height > $wind_height){ 223 if($parent_popover_top){ 224 $tops = (($wind_top - $parent_popover_top) + 30); 225 }else{ 226 $tops = ($wind_top + 30); 227 } 228 }else{ 229 if($parent_popover_top){ 230 $tops = (($wind_top - $parent_popover_top)+70); 231 }else{ 232 $tops = ($wind_top + 30); 233 } 234 } 235 //---------------------------- 236 if($wind_width > $popover_width){ 237 if($parent_popover_left){ 238 $lefts = (($wind_width - ($parent_popover_left*2) - $popover_width) / 2); 239 }else{ 240 $lefts = (($wind_width - $popover_width) / 2); 241 } 242 }else{ 243 $lefts = 0; 244 } 245 246 $popover.addClass('active').removeClass('hidden'); 247 //------------------------- 248 249 var linkOffset=$link.offset(); 250 var popoverTop=linkOffset.top+$link.outerHeight(); 251 var popoverLeft=linkOffset.left+$link.outerWidth()/2-$popover.outerWidth()/2; 252 if((popoverLeft<($(document).width()*0.05))||(popoverLeft+$popover.outerWidth()>($(document).width()*0.95))){ 253 popoverLeft=$(document).width()/2-$popover.outerWidth()/2; 254 } 255 256 $popover.css({ 257 left: $lefts, 258 top: $tops 259 }); 260 }, 0); 261//------------------------------- 262 return false; 263 }); 264 265 266 267 $('.popover-close').click(function() { 268 closePopovers(); 269 return false; 270 }); 271 272 $('html').click(function(e) { 273 var $target = $(e.srcElement || e.target); 274 // Ðлик вне поповеÑа 275 if (!$target.parentsOrSelf('.popover').length && !$target.hasClass('fancybox-close')) { 276 closePopovers(); 277 } 278 }); 279 280 var $window = $(window); 281 var lastWidth = $window.width(); 282 $window.resize(function(e) { 283 if ($window.width() != lastWidth) { 284 lastWidth = $window.width(); 285 closePopovers(); 286 } 287 }); 288} 289 290/** 291 * @see http://caroufredsel.dev7studios.com/ 292 */ 293function initMainBannersCarousel() { 294 var $carousel = $('#home-slides-carousel'); 295 if (!$carousel.length) { 296 return; 297 } 298 299 $carousel.carouFredSel({ 300 circular: true, 301 responsive: true, 302 transition: true, 303 width: "100%", 304 auto: { 305 timeoutDuration: 'auto', 306 pauseOnHover: true 307 }, 308 items: { 309 height: "auto" 310 }, 311/* scroll: { 312 fx: 'scroll', 313 easing: 'linear', 314 duration : 1500, 315 pauseOnHover : true 316 }, 317*/ 318 scroll: { 319 items: 'page', 320 fx: 'directscroll', 321 easing: 'swing', 322 duration : 700, 323 pauseOnHover : true 324 }, 325 swipe: { 326 onMouse: false, 327 onTouch: true 328 }, 329 pagination: '#home-slides-carousel-pager' 330 }); 331 setTimeout(function() { 332 $carousel.trigger('updateSizes'); // IE7/8 hack 333 }, 500); 334} 335 336/** 337 * @see http://caroufredsel.dev7studios.com/ 338 */ 339function initHomeCategories() { 340 341 function _attachNavigationToItem($item, $prev, $next) { 342 var $container = $item.find('.category-wrapper'); 343 $container.append($prev); 344 $container.append($next); 345 $prev.removeClass('hidden'); 346 $next.removeClass('hidden'); 347 } 348 349 var $categoriesStatic = $('.categories-static-wrapper .categories-static'); 350 var $categoriesCarousel = $('.categories-carousel-wrapper .categories-carousel'); 351 if (!$categoriesCarousel.length) { 352 return; 353 } 354 355 randomRotateElements($categoriesStatic.find('.category')); 356 357 var $prev = $('#categories-carousel-prev'); 358 var $next = $('#categories-carousel-next'); 359 $categoriesCarousel.carouFredSel({ 360 circular: true, 361 responsive: true, 362 transition: true, 363 prev: $prev, 364 next: $next, 365 auto: { 366 play: false 367 }, 368 items: { 369 visible: 1 370 }, 371 width: '100%', 372 scroll: { 373 fx: 'fade', 374 onBefore: function(e) { 375 _attachNavigationToItem(e.items.visible, $prev, $next); 376 } 377 } 378 }); 379 $categoriesStatic.children('span').each(function() {
380 $categoriesCarousel.trigger("insertItem", $(this).clone(true)); 381 }); 382 $categoriesCarousel.trigger('currentVisible', function($current) { 383 _attachNavigationToItem($current, $prev, $next); 384 }); 385 setTimeout(function() { 386 $categoriesCarousel.trigger('updateSizes'); // IE7/8 hack 387 }, 500); 388} 389 390/** 391 * @see http://caroufredsel.dev7studios.com/ 392 */ 393function initProductsCarousel(what) { 394 function _updateNavigationPos($productsCarousel, $prev, $next) { 395 $productsCarousel.trigger("currentVisible", function($visibleItems) { 396 var $firstItem = $visibleItems.first(); 397 var $lastItem = $visibleItems.last(); 398 var $carousel = $firstItem.parent(); 399 var carouselLeft = $carousel.position().left; 400 var real_margin = ($carousel.parent().parent().width() - $carousel.parent().width())/2; 401 $prev.css('margin-left', real_margin-$prev.width() +'px'); 402 $next.css('margin-right', real_margin-$next.width() +'px'); 403 }); 404 } 405/* 406$('#carousel').carouFredSel({ 407 circular: true, // ÐпÑеделÑеÑ, должен ли бÑÑÑ ÑÐ»Ð°Ð¹Ð´ÐµÑ ÐºÑÑговÑм 408 // (ÑеÑÑно говоÑÑ, мне не ÑдалоÑÑ Ð´Ð¾Ð±Ð¸ÑÑÑÑ ÐµÐ³Ð¾ коÑÑекÑной 409 // ÑабоÑÑ Ñ Ð²ÐºÐ»ÑÑÑнной ÑÑой опÑией) 410 infinite: true, // ÐпÑеделÑеÑ, должен ли бÑÑÑ ÑÐ»Ð°Ð¹Ð´ÐµÑ (каÑÑÑелÑ) беÑконеÑнÑм. 411 // ÐÑли true поÑле поÑледнего ÑлеменÑа ÑÐ»Ð°Ð¹Ð´ÐµÑ Ð±ÑÐ´ÐµÑ Ð¿ÐµÑÐµÑ Ð¾Ð´Ð¸ÑÑ Ð½Ð° пеÑвÑй 412 responsive: false, // ÐпÑеделÑеÑ, бÑдÑÑ Ð»Ð¸ ÑлеменÑÑ ÐºÐ°ÑÑÑели ÑаÑÑÑнÑÑÑ Ð¸Ð»Ð¸ ÑжаÑÑ Ð¿Ð¾Ð´ ÐµÑ ÑазмеÑÑ 413 direction: "left", // ÐапÑÐ°Ð²Ð»ÐµÐ½Ð¸Ñ Ð¿ÑокÑÑÑки: "right", "left", "up" or "down". 414 width: null, // ШиÑина каÑÑÑели. ÐÐ¾Ð¶ÐµÑ Ð±ÑÑÑ null (ÑиÑина бÑÐ´ÐµÑ ÑаÑÑиÑана), ÑиÑлом, 415 // "variable" (ÑазмеÑÑ ÐºÐ°ÑÑÑели бÑдÑÑ Ð°Ð²ÑомаÑиÑеÑки изменÑÑÑÑÑ Ð¿Ñи пÑокÑÑÑке ÑлеменÑов Ñ Ð¿ÐµÑеменной ÑиÑиной), 416 // "auto" (ÑиÑина бÑÐ´ÐµÑ ÐºÐ°Ðº Ñ Ñамого ÑиÑокого ÑлеменÑа) или в пÑоÑенÑÐ°Ñ , напÑÐ¸Ð¼ÐµÑ "100%" (ÑолÑко Ð´Ð»Ñ Ð³Ð¾ÑизонÑалÑнÑÑ ÐºÐ°ÑÑÑелей) 417 height: null, // ÐÑÑоÑа (аналогиÑно паÑамеÑÑÑ width, ÑолÑко Ð´Ð»Ñ Ð²ÐµÑÑикалÑного измеÑениÑ) 418 align: "center", // Ðак бÑдÑÑ Ð²ÑÑавниваÑÑÑÑ ÑлеменÑÑ Ð²Ð½ÑÑÑи ÑикÑиÑованной ÑиÑинÑ/вÑÑоÑÑ: "center", "left", "right" or false. 419 padding: null, // ÐÑÑÑÑÐ²Ñ ÐºÐ°ÑÑÑели (веÑÑ Ð½Ð¸Ð¹, пÑавÑй, нижний и левÑй). ÐапÑимеÑ: [10, 20, 30, 40] 420 synchronise: null, // ÐозволÑÐµÑ Ð½ÐµÑколÑким каÑÑÑелÑм ÑабоÑаÑÑ ÑÐ¸Ð½Ñ Ñонно: 421 // [string selector, boolean inheritOptions, boolean sameDirection, number deviation] For example: ["#foo2", true, true, 0] 422 cookie: false, // ÐозволÑÐµÑ Ð·Ð°Ð¿Ð¾Ð¼Ð¸Ð½Ð°ÑÑ ÑекÑÑее положение каÑÑÑели в кÑÐºÐ°Ñ . Ðожно задаÑÑ Ð¸Ð¼Ñ Ð¿ÐµÑеменной cookie 423 onCreate: null // ФÑнÑиÑ, вÑзÑÐ²Ð°ÐµÐ¼Ð°Ñ Ð¿Ð¾Ñле ÑÐ¾Ð·Ð´Ð°Ð½Ð¸Ñ Ð¾Ð±ÑекÑа каÑÑÑели 424}); 425*/ 426 var $productsCarousel = $('.products-carousel-wrapper .products-carousel-' + what); 427 if (!$productsCarousel.length) { 428 return; 429 } 430 431 var $prev = $('#products-carousel-' + what + '-prev'); 432 var $next = $('#products-carousel-' + what + '-next'); 433 $productsCarousel.carouFredSel({ 434 cookie:false, 435 align: 'center', 436 padding: [0,50,0,150], 437 circular: true, 438 infinite: false, 439 transition: true, 440 responsive: false, 441 prev: $prev, 442 next: $next, 443 auto: { 444 play: false, 445// items: 2, 446// fx: 'scroll', 447// easing: 'swing', 448// duration : 1000, 449 }, 450 scroll: { 451 items: 3, 452 fx: 'directscroll', 453 easing: 'swing', 454 duration : 1500, 455 pauseOnHover : true 456 }, 457 458 swipe: { 459 onMouse: true, 460 onTouch: true 461 }, 462 width: 'variable' 463 464 }); 465 $productsCarousel.bind('updateSizes', function() { 466 _updateNavigationPos($productsCarousel, $prev, $next); 467 }); 468 469 $productsCarousel.trigger('updateSizes'); 470 setTimeout(function() { 471 $productsCarousel.trigger('updateSizes'); // IE7/8 hack 472 }, 500); 473 474 $.windowResize(function() { 475 _updateNavigationPos($productsCarousel, $prev, $next); 476 }); 477} 478 479 480function initProductsCarouselCompare(what) { 481 482 function _updateNavigationPos($productsCarousel, $prev, $next) { 483 $productsCarousel.trigger("currentVisible", function($visibleItems) { 484 var $firstItem = $visibleItems.first();
485 var $lastItem = $visibleItems.last(); 486 var $carousel = $firstItem.parent(); 487 var carouselLeft = $carousel.position().left; 488 var offset_right = 20; 489 $prev.css('margin-left', carouselLeft + 'px'); 490 $next.css('margin-right', 491 -carouselLeft - offset_right + 492 $carousel.parent().width() - 493 ($lastItem.position().left + $lastItem.width()) + 'px'); 494 }); 495 } 496 497 var $productsCarousel = $('.products-carousel-wrapper .products-carousel-' + what); 498 if (!$productsCarousel.length) { 499 return; 500 } 501 502 var $prev = $('#products-carousel-' + what + '-prev'); 503 var $next = $('#products-carousel-' + what + '-next'); 504 505 $productsCarousel.carouFredSel({ 506// items: auto, 507 align: 'center', 508// padding: [0,50,0,150], 509 circular: false, 510// infinite: true, 511 transition: true, 512 responsive: false, 513 prev: $prev, 514 next: $next, 515 auto: { 516 play: false 517 }, 518 scroll: { 519 items: 3, 520 fx: 'directscroll', 521 easing: 'swing', 522 duration : 1500, 523 pauseOnHover : true 524 }, 525 swipe: { 526 onMouse: false, 527 onTouch: true 528 }, 529 width: '100%', 530 }); 531 $productsCarousel.bind('updateSizes', function() { 532 _updateNavigationPos($productsCarousel, $prev, $next); 533 }); 534 535 $productsCarousel.trigger('updateSizes'); 536 setTimeout(function() { 537 $productsCarousel.trigger('updateSizes'); // IE7/8 hack 538 }, 500); 539 540 $.windowResize(function() { 541 _updateNavigationPos($productsCarousel, $prev, $next); 542 }); 543} 544 545/** 546 * @see http://cherne.net/brian/resources/jquery.hoverIntent.html 547 */ 548function initProductsHover() { 549 return false; 550} 551 552/** 553 * @see https://github.com/itsalif/ezMark 554 **/ 555/* 556function initRadiosCheckboxes($context) { 557 $('input:checkbox,input:radio:not(.star, .star_total, .star_discuss)', $context).ezMark(); 558 $('input:checkbox:disabled', $context).closest('.ez-checkbox').addClass('ez-disabled'); 559 $('input:radio:disabled', $context).closest('.ez-radio').addClass('ez-disabled'); 560} 561*/ 562/** 563 * @see http://ivaynberg.github.com/select2/ 564 */ 565function initSelects($context, doInit) { 566 if (doInit === undefined) { 567 doInit = true; 568 } 569 570 var $selects = $('select.stylish', $context); 571 if (doInit) { 572 $selects.select2({ 573 minimumResultsForSearch: 1000 574 }); 575 $selects.each(function() { 576 var $styledSelect = $(this).prev('.select2-container'); 577 $styledSelect.attr('class', $styledSelect.attr('class') + ' ' + $(this).data('class')); 578 }) 579 } else { 580 $selects.select2('destroy'); 581 } 582} 583 584function initSteppers($context) { 585 $('input.numeric', $context).attr('type', 'text').stepper(); 586} 587 588function initTabs() { 589 $('.tabs-wrapper').each(function() { 590 var $tabsWrapper = $(this); 591 var $tabsContent = $('.tabs-content', $tabsWrapper); 592 $('.tabs a', $tabsWrapper).click(function() { 593 var $link = $(this); 594 $link.siblings().removeClass('active'); 595 $link.addClass('active'); 596 $('.tab', $tabsContent).removeClass('active'); 597 $($link.attr('href'), $tabsContent).addClass('active'); 598 return false; 599 }); 600 }); 601} 602 603function initFancyBox() { 604 var isTouch = Modernizr.touch; 605 $(".fancybox:visible, .sv-fancy:visible").fancybox({ 606 helpers: { 607 title: { 608 type: 'inside' 609 }, 610 overlay: { 611 speedOut: isTouch ? 0 : 200 612 } 613 }, 614 scrolling : 'visible', 615 padding: 5, 616 mouseWheel: false, 617 openEffect:isTouch?'none':'elastic', 618 closeEffect:isTouch?'none':'elastic', 619// openEffect: 'elastic', 620// closeEffect: 'elastic', 621 minWidth: 300, 622 maxWidth: '90%', 623 nextEffect: 'fade', 624 prevEffect: 'fade', 625 626 beforeShow : function() { 627 $('.top-panel').addClass('hidden'); 628 var needCounter = this.element.attr('rel') == 'group'; 629 var hasTitle = !!this.title; 630 var counterHtml = (this.index + 1) + ' / ' + this.group.length; 631 if (hasTitle) { 632 counterHtml = '(' + counterHtml + ')'; 633 } 634 counterHtml = '<span class="counter">' + counterHtml + '</span>'; 635 var titleHtml = hasTitle 636 ? '<span>' + this.title + '</span>' 637 : ''; 638 if (needCounter) { 639 titleHtml += ' ' + counterHtml; 640 } 641 var description = this.element.data('description'); 642 if (titleHtml) { 643 titleHtml = '<div class="section-title' + (!description ? ' no-border' : '') + '">' + titleHtml + '</div>'; 644 } 645 646 if (description) { 647 titleHtml += '<div class="description">' + description + '</div>'; 648 } 649 650 this.title = titleHtml; 651 }, 652 653 afterClose : function() { 654 $('.top-panel').removeClass('hidden'); 655 } 656 }); 657 658} 659 660function initRating($context) { 661 $('input[type=radio].star', $context).rating({ 662 split: 4, 663 readOnly: true 664 }); 665 $('.rating-bar').removeClass('hidden'); 666} 667 668function initTipsy($context) { 669 if (Modernizr.touch) { 670 $('.tipsy-control', $context).tipsy({gravity: $.fn.tipsy.autoBounds(100, 'n'), trigger: 'manual'}); 671 $('.tipsy-control', $context).css('cursor', 'pointer').click(function() { 672 if ($(this).hasClass('sv-tipsy-visible')) { 673 $(this).tipsy('hide'); 674 } else { 675 $('.tipsy').remove(); 676 $('.sv-tipsy-visible').removeClass('sv-tipsy-visible'); 677 $(this).tipsy('show'); 678 } 679 $(this).toggleClass('sv-tipsy-visible'); 680 }); 681 682 if (!$context) { 683 $('body').click(function(e){ 684 if (!$(e.target).hasClass('tipsy-control') && $(e.target).parents('.tipsy-control').length == 0) { 685 $('.tipsy').remove(); 686 $('.sv-tipsy-visible').removeClass('sv-tipsy-visible'); 687 } 688 }); 689 } 690 } else { 691 $('.tipsy-control', $context).tipsy({gravity: $.fn.tipsy.autoBounds(100, 'n')}); 692 } 693} 694 695function initSidebar() { 696 var main = $('.main'); 697 var content = $('.main > .content'); 698 var sidebar = $('.main > .sidebar').last(); 699 700 if (sidebar.length == 0) { 701 return; 702 } 703 704 var categories = sidebar.children('.categories').first(); 705 var by_price = sidebar.children('.filter-by-price').first(); 706 707 function _sidebarMove() { 708 if (sidebar.css('float') == 'none' && !sidebar.hasClass('bottom')) { 709 sidebar.addClass('bottom'); 710 sidebar.insertAfter(content); 711 712 if (categories.length > 0 || by_price.length > 0) { 713 var top_sidebar = main.prepend('<div class="sidebar"></div>').children('.sidebar').first(); 714 715 if (categories.length > 0) { 716 top_sidebar.append(categories.clone()); 717 categories.addClass('hidden'); 718 } 719 720 if (by_price.length > 0) { 721 top_sidebar.append(by_price.clone()); 722 by_price.addClass('hidden'); 723 } 724 } 725 } else if (sidebar.css('float') != 'none' && sidebar.hasClass('bottom')) { 726 var sidebar_count = main.children('.sidebar').length; 727 728 if (sidebar_count > 1) { 729 main.children('.sidebar').first().remove(); 730 } 731 732 if (categories.length > 0) { 733 categories.removeClass('hidden'); 734 } 735 736 if (by_price.length > 0) { 737 by_price.removeClass('hidden'); 738 } 739 740 sidebar.removeClass('bottom'); 741 sidebar.insertBefore(content); 742 } 743 } 744 745 _sidebarMove(); 746 747 $.windowResize(function() { 748 _sidebarMove(); 749 }); 750} 751 752function initHashChange(bind) { 753 var hashCount = (location.hash.split('#').length - 1); 754 755 if (hashCount == 1) { 756 var id = location.hash.substr(1); 757 var anchor = $('a[name="' + id + '"]'); 758 759 if (anchor.length == 0) { 760 anchor = $('[rel="' + id + '"]'); 761 } 762 763 if (anchor.length == 1) { 764 var o = anchor.offset(); 765 766 $.scrollTo(o.top - 100 + 'px', bind ? 0 : 500); 767 } 768 } 769 770 if (bind) { 771 $(window).bind('hashchange', function() { 772 initHashChange(false); 773 }); 774 } 775} 776 777function initComparison() { 778 779 function _updateCarouselWidth($comparisonWrapper, $comparisonHeader, $comparisonCarousel) { 780 var availableWidth = $comparisonWrapper.width(); 781 var headerWidth = $comparisonHeader.is(':visible') ? $comparisonHeader.width() : 0; 782 var itemWidth = $comparisonCarousel.find('.product-comparison').width(); 783 784 if (headerWidth > 0) { 785 var itemCount = $comparisonCarousel.find('.product-comparison').length; 786 787 for (var n = 1;
787 n <= itemCount; n++) { 788 if (itemWidth * n + headerWidth > availableWidth) { 789 itemCount = n - 1; 790 break; 791 } 792 } 793 794 headerWidth = Math.floor(availableWidth - itemWidth * itemCount); 795 } 796 797 var newWidth = Math.floor((availableWidth - headerWidth) / itemWidth) * itemWidth; 798 $comparisonCarousel.trigger('configuration', ['width', newWidth]); 799 } 800 801 var $comparisonWrapper = $('.products-comparison-wrapper'); 802 if (!$comparisonWrapper.length) { 803 return; 804 } 805 806 // ÐÑÑавниваем вÑÑоÑÑ Ð·Ð°Ð³Ð¾Ð»Ð¾Ð²ÐºÐ¾Ð² 807 var $titleContainers = $comparisonWrapper.find('.title-container'); 808 var titleHeight = $titleContainers.getCallbackMaxValue(function ($obj) { 809 return $obj.outerHeight(); 810 }); 811 $titleContainers.css('height', titleHeight + 'px'); 812 813 // ÐÑÑавниваем вÑÑоÑÑ ÑÑÑок Ñ Ð´Ð°Ð½Ð½Ñми 814 var $comparisonHeader = $comparisonWrapper.find('.product-comparison-header'); 815 var $headerParams = $comparisonHeader.find('.comparison-params'); 816 var $params = $comparisonWrapper.find('.comparison-params'); 817 for (var i = 0; i < $headerParams.children().length; i++) { 818 var $row = $params.find(':eq(' + i + ')'); 819 var rowHeight = $row.getCallbackMaxValue(function ($obj) { 820 return $obj.outerHeight(); 821 }); 822 $row.css('height', rowHeight + 'px'); 823 } 824 825 // ÐавоÑаÑиваем даннÑе в каÑÑÑÐµÐ»Ñ 826 var $comparisonCarouselWrapper = $comparisonWrapper.find('.products-comparison-carousel-wrapper'); 827 var $comparisonCarousel = $comparisonCarouselWrapper.find('.products-comparison-carousel'); 828 var $prev = $('#products-comparison-carousel-prev'); 829 var $next = $('#products-comparison-carousel-next'); 830 $comparisonCarousel.carouFredSel({ 831 circular: false, 832 transition: true, 833 prev: $prev, 834 next: $next, 835 auto: { 836 play: false 837 }, 838 scroll: { 839 fx: 'crossfade', 840 'duration' : 700 841 } 842 }); 843 _updateCarouselWidth($comparisonWrapper, $comparisonHeader, $comparisonCarousel); 844 845 $.windowResize(function() { 846 _updateCarouselWidth($comparisonWrapper, $comparisonHeader, $comparisonCarousel); 847 }); 848 849 $comparisonWrapper.removeClass('invisible'); 850} 851 852// ------------------------------ GALLERY START 853function initProductGallery($gallery,syncGalleries,$target,orientation){ 854 855 // РаÑÑÑавлÑÐµÑ z-index'Ñ Ð² поÑÑдке Ð¸Ñ ÑазмеÑÐµÐ½Ð¸Ñ Ð² конÑейнеÑе 856 function _initSlidesZIndex($slides){ 857 var $slides=$('li',$gallery); 858 var index=0; 859 $slides.each(function(){ 860 $(this).css('z-index',$slides.length-index); 861 index++; 862 }); 863 } 864 // ÐбновлÑÐµÑ Ð¿Ð°ÑамеÑÑÑ Ñлайдов 865 function _updateSlidesGeometry(){ 866 var $slides=$('li',$gallery); 867 var $lastSlide=$('li:last-child',$gallery); 868 var maxSlideSize,lastSlideSize,containerSize,offsetProperty; 869 if(orientation=='vertical'){ 870 maxSlideSize=$slides.getCallbackMaxValue(function($obj){ 871 return $obj.outerWidth(); 872 }); 873 lastSlideSize=$lastSlide.outerHeight(); 874 containerSize=$target.outerHeight(); 875 offsetProperty='top'; 876 }else if(orientation=='horizontal'){ 877 maxSlideSize=$slides.getCallbackMaxValue(function($obj){ 878 return $obj.outerHeight(); 879 }); 880 lastSlideSize=$lastSlide.outerWidth(); 881 containerSize=$target.outerWidth(); 882 offsetProperty='left'; 883 } 884 var margin=parseInt($gallery.css('margin-left'),10); 885 var increment=(containerSize-lastSlideSize-2*margin)/($slides.length-1); 886 var startOffset=margin; 887 if($slides.length==1){ 888 startOffset+=(containerSize-lastSlideSize)/2; 889 } 890 if(orientation=='vertical'){ 891 $gallery.width(maxSlideSize).height(containerSize); 892 var offset=startOffset; 893 }else if(orientation=='horizontal'){ 894 $gallery.width(containerSize).height(maxSlideSize); 895 var offset=startOffset-10; 896 } 897 898 $slides.each(function(){ 899 $(this).css(offsetProperty,offset+'px'); 900 offset+=increment; 901 }); 902 } 903 904 function _activateSlide($slides,$newSlide){ 905 var maxZIndex=$slides.getCallbackMaxValue(function($slide){ 906 return $slide.css('z-index'); 907 }); 908 if($newSlide.css('z-index')==maxZIndex){ 909 return; 910 } 911 var $newSlideClone=$newSlide.clone(); 912 $newSlideClone.css({'opacity':0,'z-index':maxZIndex+1}); 913 $newSlideClone.insertAfter($newSlide); 914 $.when($newSlide.animate({'opacity':0},500), 915 $newSlideClone.animate({'opacity':1},500)).then(function(){ 916 $newSlide.css({'opacity':1,'z-index':maxZIndex+1}); 917 $newSlideClone.remove(); 918 }); 919 } 920 if(orientation!='horizontal'&&orientation!='vertical'){ 921 return false;
922 } 923 var $slides=$('li',$gallery); 924 if(!$slides.length){ 925 return false; 926 } 927 randomRotateElements($slides); 928 _updateSlidesGeometry(); 929 _initSlidesZIndex(); 930 931 $slides.click(function(){ 932 var $currentSlide=$(this); 933 var $link=$currentSlide.find('a'); 934 $currentSlide.siblings().each(function(){ 935 var $sibling=$(this); 936 var $siblingLink=$sibling.find('a'); 937 $siblingLink.attr('rel','gal_pics'); 938 $siblingLink.addClass('sv-fancy'); 939 var $siblingImg=$siblingLink.find('img'); 940 //var img_alt = $siblingImg.attr('alt'); 941 //alert(img_alt); 942 //$('#sv-prod-thumb').attr('alt',img_alt); 943 }); 944 $link.attr('rel',''); 945 $link.removeClass('sv-fancy'); 946 _activateSlide($slides,$currentSlide); 947 var fullImage=$link.data('fullImage'); 948 var largeImage=$link.data('largeImage'); 949 var link_img = $link.find('img'); 950 var img_alt = link_img.attr('alt'); 951 var $targetLink=$($gallery.data('for')); 952 var $targetImage=$targetLink.find('img'); 953 $targetLink.attr('href',fullImage); 954 $targetImage.attr('src',largeImage); 955 if (img_alt != '') { 956 $targetLink.attr('title',img_alt); 957 $targetImage.attr('alt',img_alt); 958 }else if($link.attr('title') != ''){ 959 $targetLink.attr('title',$link.attr('title')); 960 $targetImage.attr('alt',$link.attr('title')); 961 }else{ 962 // 963 } 964 965 $.each(syncGalleries,function(index){ 966 var $syncSlides=syncGalleries[index].find('li'); 967 var $syncCurrentSlide=$syncSlides.eq($currentSlide.index()); 968 _activateSlide($syncSlides,$syncCurrentSlide); 969 }); 970 return false; 971 }); 972 $.windowResize(function(){ 973 _updateSlidesGeometry(); 974 }); 975 return true; 976} 977// ------------------------------ GALLERY STOP 978 979//------------------ Init Gallerys product start 980function initProductGalleries(){ 981 var $target=$('#gallery-target'); 982 if(!$target.length){ 983 return; 984 } 985 var $verticalGallery=$('.gallery-vertical'); 986 var $horizontalGallery=$('.gallery-horizontal'); 987 initProductGallery($verticalGallery,[$horizontalGallery],$target,'vertical'); 988 initProductGallery($horizontalGallery,[$verticalGallery],$target,'horizontal'); 989} 990//------------------ Init Gallery product stop 991 992function randomRotateElements($objs,duration,spread,min){ 993 function _generateAngle(spreadAngle,minAngle){ 994 if(spreadAngle==undefined){ 995 spreadAngle=9; 996 } 997 if(minAngle==undefined){ 998 minAngle=3; 999 } 1000 var angle=Math.round(Math.random()*2*spreadAngle-spreadAngle); 1001 if(Math.abs(angle)<minAngle){ 1002 angle=_generateAngle(spreadAngle,minAngle); 1003 } 1004 return angle; 1005 } 1006 1007 if(duration===undefined){ 1008 duration=500; 1009 } 1010 $objs.each(function(){ 1011 $(this).transition({ 1012 rotate:_generateAngle(spread,min)+'deg' 1013 }, 1014 duration); 1015 }); 1016} 1017 1018/* ======================================================== */ 1019stopex = false; 1020var CartBox = (function() { 1021 var cart = {}; 1022 var cartFlyBoxType = ''; 1023 1024 cart.addProduct = function(prod_id, cat_id, product_form_id, variant_id=0, callback) { 1025 1026 var options = { 1027 url: BASE_URL + 'modules/cart/cart_js.php?act=add&prod_id=' + prod_id + '&cat_id=' + cat_id + '&tpl_cart_path=cart/box/box.html&tpl_products_path=cart/box/products.html', 1028 dataType: 'json', 1029 success: function(obj) { 1030 $('.sv-cart-box').html($.base64Decode(obj.html)); 1031 $('.sv-cart-box-fly').html($.base64Decode(obj.html)); 1032 $('.sv-cart-box-products').html($.base64Decode(obj.arg5)); 1033 1034 if (obj.err) { 1035 ProcessMsgs('', obj.err); 1036 stopex = true; 1037 } else if (obj.msg) { 1038 stopex = false; 1039 if (callback) { 1040 callback.call(); 1041 } 1042 $('#p_cart_empty').addClass('hidden'); 1043 $('#a_cart_empty').removeClass('hidden'); 1044 if (!$('#flyer').is(':visible') && !$('#sv-cart-box-fly').is(':visible')) { 1045 CartBox.flyOn(); 1046 $('#flyer').removeClass('hidden'); 1047 } 1048 $('#magnet_button').removeClass('hidden'); 1049 ProcessMsgs(obj.msg, ''); 1050 } 1051 }, 1052 resetForm: false 1053 }; 1054 1055 $('#' + product_form_id).ajaxSubmit(options); 1056 }; 1057 1058 cart.delProduct = function(cart_id, prod_id) { 1059 $.getJSON(BASE_URL + 'modules/cart/cart_js.php?act=delete&cart_id=' + cart_id + '&tpl_cart_path=cart/box/box.html&tpl_products_path=cart/box/products.html', 1060 function(obj) { 1061 $('.sv-cart-box').html($.base64Decode(obj.html)); 1062 $('.sv-cart-box-fly').html($.base64Decode(obj.html)); 1063// $('.sv-cart-box span.head-price').remove(); 1064 1065 $('.sv-cart-box-products').html($.base64Decode(obj.arg5)); 1066 if (obj.arg4 == 0) { 1067 $('#flyer').addClass('hidden'); 1068 CartBox.flyOff(); 1069 closePopovers(); 1070 $('#p_cart_empty').removeClass('hidden'); 1071 $('#a_cart_empty').addClass('hidden'); 1072 $('#magnet_button').addClass('hidden'); 1073 } 1074 if (window.ProductOptionChanged) { 1075 ProductOptionChanged(prod_id); 1076 } 1077 1078 ProcessMsgs(obj.msg, obj.err); 1079 } 1080 ); 1081 }; 1082 1083 cart.productsHide = function() { 1084 $('.sv-cart-box-products').addClass('hidden'); 1085 }; 1086 1087 cart.flyOn = function() { 1088 if ($('#sv-cart-box-fly').is(':hidden')) { 1089 $('#sv-cart-box-fly').removeClass('hidden'); 1090 $.post(BASE_URL + 'modules/cart/cart_js.php?act=fly-cart-show'); 1091 $('.bottom-line').css('padding', '10px 10px 50px 10px'); 1092 $('#Go_Top').css('bottom', '40px'); 1093 } else { 1094 cart.flyOff(); 1095 } 1096 }; 1097 1098 cart.flyOff = function() { 1099 $('#sv-cart-box-fly').addClass('hidden'); 1100 $.post(BASE_URL + 'modules/cart/cart_js.php?act=fly-cart-hide'); 1101 $('.bottom-line').css('padding', '10px'); 1102 $('#Go_Top').css('bottom', '5px'); 1103 }; 1104 1105 return cart; 1106})(); 1107 1108/* ======================================================== */ 1109 1110function BlockUI(title, message) { 1111 $.fancybox({ 1112 helpers: { 1113 title: { 1114 type: 'inside' 1115 }, 1116 overlay: { 1117 speedOut: 0,
1118 locked: false 1119 } 1120 }, 1121 scrolling : 'visible', 1122 openEffect: 'none', 1123 closeEffect: 'none', 1124 maxWidth: 800, 1125 modal: true, 1126 content: '<div class="section-title">' + title + '</div><div class="description">' + message + '</div>', 1127 afterLoad: function() { 1128 this.wrap.addClass('fancybox-modal-message'); 1129 } 1130 }); 1131} 1132 1133function UnblockUI() { 1134 $.fancybox.close(); 1135} 1136 1137function ConfirmDialog(title, text, on_yes_button, on_no_button) { 1138 var isTouch = Modernizr.touch; 1139 1140 if (title) { 1141 $('#sv-confirm-dialog-title').html(title); 1142 $('#sv-confirm-dialog-title').parent().removeClass('hidden'); 1143 } else { 1144 $('#sv-confirm-dialog-title').parent().addClass('hidden'); 1145 } 1146 1147 $('#sv-confirm-dialog-text').html(text); 1148 1149 $.fancybox({ 1150 helpers: { 1151 title: { 1152 type: 'inside' 1153 }, 1154 overlay: { 1155 speedOut: isTouch ? 0 : 200, 1156 locked: false 1157 } 1158 }, 1159 scrolling : 'visible', 1160 openEffect: isTouch ? 'none' : 'fade', 1161 closeEffect: isTouch ? 'none' : 'fade', 1162 maxWidth: 800, 1163 modal: true, 1164 content: $('#sv-confirm-dialog-inner'), 1165 afterLoad: function() { 1166 this.wrap.addClass('fancybox-confirm-dialog'); 1167 } 1168 }); 1169 1170 $('#sv-confirm-dialog-yes-button').unbind('click').click(function(){ 1171 on_yes_button.call(); 1172 }); 1173 1174 $('#sv-confirm-dialog-no-button').unbind('click').click(function(){ 1175 on_no_button.call(); 1176 $.fancybox.close(); 1177 }); 1178} 1179 1180var processMsgsTimeoutId = -1; 1181 1182function ProcessMsgs(msg_txt, err_txt, callback) { 1183 $.fancybox.close(); 1184 1185 if (processMsgsTimeoutId != -1) { 1186 clearTimeout(processMsgsTimeoutId); 1187 processMsgsTimeoutId = -1; 1188 } 1189 1190 if (msg_txt !== '' || err_txt !== '') { 1191 $.getJSON(BASE_URL + 'messages.php', {msg: $.base64Decode(msg_txt), err: $.base64Decode(err_txt), tpl_path_error: '_system_/msgs_error_block.html', tpl_path_info: '_system_/msgs_info_block.html'}, 1192 function(obj) { 1193 if (obj && obj.html) { 1194 var isTouch = Modernizr.touch; 1195 1196 $.fancybox({ 1197 helpers: { 1198 title: { 1199 type: 'inside' 1200 }, 1201 overlay: null, 1202 locked: false 1203 }, 1204 scrolling : 'visible', 1205 openEffect: isTouch ? 'none' : 'fade', 1206 closeEffect: isTouch ? 'none' : 'fade', 1207 openSpeed: 100, 1208 closeSpeed: 0, 1209 maxWidth: isTouch ? $(window).width() - 70 : 800, 1210 topRatio: 1, 1211 fitToView: !isTouch, 1212 content: $.base64Decode(obj.html), 1213 afterLoad: function() { 1214 if (err_txt !== '') { 1215 this.wrap.addClass('fancybox-error-message'); 1216 } else { 1217 this.wrap.addClass('fancybox-info-message'); 1218 } 1219 }, 1220 afterShow: function() { 1221 var titleDiv = this.inner.find('.section-title'); 1222 1223 var i = 0; 1224 var blinkCount = obj.arg4; 1225 var timeToShow = obj.arg5; 1226 1227 fadeItOut = function() { 1228 titleDiv.fadeTo(300, 0.1, function() { 1229 fadeItIn(); 1230 }); 1231 i++; 1232 }; 1233 1234 fadeItIn = function() { 1235 titleDiv.fadeTo(300, 1, function() { 1236 if (i < blinkCount) { 1237 fadeItOut(); 1238 } else { 1239 if (msg_txt != '' && timeToShow > 0) { 1240 processMsgsTimeoutId = setTimeout(function() { 1241 $.fancybox.close(); 1242 }, timeToShow * 200); 1243 } 1244 } 1245 }); 1246 }; 1247 1248 if (blinkCount > 0) { 1249 setTimeout(function() { 1250 fadeItOut(); 1251 }, 100); 1252 } else { 1253 fadeItIn(); 1254 } 1255 } 1256 }); 1257 1258 if (callback) { 1259 callback.call(); 1260 } 1261 } 1262 } 1263 ); 1264 } 1265 1266 return false; 1267} 1268 1269function HighlightInvalidFields(invalid_fields, bound) { 1270 if (!bound) { 1271 var bound = document; 1272 } 1273 1274 $(bound).find('.has-errors').removeClass('has-errors'); 1275 1276 if (invalid_fields && invalid_fields.length) { 1277 for (var i = 0; i < invalid_fields.length; i++) { 1278 var field_name = invalid_fields[i]; 1279 1280 field_name = field_name.replace('[', '\\['); 1281 field_name = field_name.replace(']', '\\]'); 1282 1283 $(bound).find('.sv-field-' + field_name).addClass('has-errors'); 1284 } 1285 } 1286} 1287 1288function ReloadCaptcha() { 1289 $.getJSON(BASE_URL + 'captcha.php', 1290 function(data) { 1291 $('.sv-captcha').attr('src', BASE_URL + data.html); 1292 } 1293 ); 1294} 1295 1296function BannerClicked(id, href) { 1297 $.post( 1298 BASE_URL + 'modules/banners/banners_js.php', 1299 {act: 'click', id: id, page: location.href}, 1300 function() { 1301 if (href) { 1302 location.href = href; 1303 } 1304 } 1305 ); 1306} 1307 1308function OrderStatusShow(order_id) { 1309 $.getJSON(BASE_URL + 'modules/order_status/order_status_js.php', 1310 {order_id: order_id}, 1311 function(obj) { 1312 ProcessMsgs(obj.msg, obj.err); 1313 } 1314 ); 1315 1316 return false;
1317} 1318 1319function ProductsKupiVKreditOnClick(prod_id, payment_id, cart_href) { 1320 $('#sv-button-cart-' + prod_id).click(); 1321 1322 window.setTimeout(function() { 1323 if(stopex != true){ 1324 $.getJSON( 1325 BASE_URL + 'modules/cart/cart_js.php?act=set_payment_id&payment_id=' + payment_id, 1326 function() { 1327 location.href = cart_href; 1328 } 1329 ); 1330 }else{ 1331 return false; 1332 } 1333 }, 2000); 1334} 1335 1336function ShowLoading(id, alt, label, centered) { 1337 if (!centered) { 1338 centered = false; 1339 } 1340 1341 var html = '<img src="' + BASE_URL + 'templates/customer/lb_ultra/images/1x1.gif" class="ajax-loader" alt="' + alt + '" />'; 1342 1343 if (label) { 1344 html += ' ' + label; 1345 } 1346 1347 if (centered) { 1348 html = '<div align="center">' + html + '</div>'; 1349 } 1350 1351 $('#' + id).html(html); 1352} 1353 1354function AccountShowAcquiredProducts() { 1355 if ($('#tab-2').html() == '') { 1356 ShowLoading('tab-2', '{$LABEL.lbl_please_wait}', '{$LABEL.lbl_please_wait}'); 1357 } else { 1358 $('#tab-2').css('opacity', 0.5); 1359 } 1360// alert($device+' - '+$style); 1361 if ($style == 'block') { 1362 $tpl_path = 'account/registered/orders/acquired_products_computer_block.html' 1363 }else{ 1364 $tpl_path = 'account/registered/orders/acquired_products_computer_row.html' 1365 } 1366 $('#tab-2').load( 1367 BASE_URL + 'modules/account/orders_js.php', 1368 {act: 'acquired_products', tpl_path: $tpl_path}, 1369 function() { 1370 $('#tab-2').css('opacity', 1); 1371 1372 var context = $('#tab-2'); 1373 1374 initSteppers(context); 1375 initRating(context); 1376 initRadiosCheckboxes(context); 1377 initTipsy(context); 1378 } 1379 ); 1380} 1381 1382function WishlistProductAdd(prod_id, user_id) { 1383 $.getJSON(BASE_URL + 'modules/products/wishlist_js.php', 1384 {act: 'add', 1385 prod_id: prod_id, 1386 user_id: user_id}, 1387 function(obj) { 1388 ProcessMsgs(obj.msg, obj.err); 1389 } 1390 ); 1391 return false; 1392} 1393 1394function WishlistProductDelete(user_id, prod_id, where_to_go) { 1395 $.getJSON(BASE_URL + 'modules/account/wishlist_js.php', 1396 {act: 'del', 1397 user_id: user_id, 1398 prod_id: prod_id}, 1399 function(obj) { 1400 ProcessMsgs(obj.msg, obj.err); 1401 location.href = where_to_go; 1402 } 1403 ); 1404 return false; 1405} 1406 1407function CompareProductsToggle(product_id, checkbox) { 1408 if (checkbox.checked) { 1409 var action = 'add'; 1410 } else { 1411 var action = 'delete'; 1412 } 1413 1414 $.ajax({ 1415 url: BASE_URL + 'modules/products_compare/products_compare_js.php', 1416 data: {act: action, prod_id: product_id, tpl_path: 'products_compare/box.html'}, 1417 dataType: 'html', 1418 success: function(html) { 1419 if (html != '') { 1420 $('#sv-compare-button-disabled').addClass('hidden'); 1421 $('#sv-compare-button-enabled').removeClass('hidden'); 1422 } else { 1423 $('#sv-compare-button-enabled').addClass('hidden'); 1424 $('#sv-compare-button-disabled').removeClass('hidden'); 1425 } 1426 1427 $('#sv-compare-block').html(html); 1428 } 1429 }); 1430 1431 return false; 1432} 1433 1434function isCookieEnabled() { 1435 var cookieEnabled = (navigator.cookieEnabled) ? true : false; 1436 1437 if (!cookieEnabled) { 1438 document.cookie = "testcookie"; 1439 var cookies = document.cookie.split(';'); 1440 1441 for (var i = 0; i < cookies.length; i++) { 1442 if (cookies[i] == 'testcookie') { 1443 cookieEnabled = true; 1444 break; 1445 } 1446 } 1447 1448 document.cookie = ""; 1449 } 1450 1451 return cookieEnabled; 1452} 1453 1454function checkCookie(err) { 1455 if (!isCookieEnabled()) { 1456 ProcessMsgs('', $.base64Encode(err)); 1457 } 1458} 1459 1460function visitorUpdateActTime() { 1461 $.get(BASE_URL + 'modules/account/account_js.php?act=update_act_time'); 1462} 1463var te_id = 0; 1464function ShowInfo(id){ 1465 $('#descr-'+id).slideToggle({ 1466 duration: 300, 1467 easing: 'swing', 1468 complete: false 1469 }); 1470 $('#te-'+id).toggleClass('activ'); 1471 1472 if ($('#descr-'+te_id).css('display') == 'block' && te_id != id) { 1473 $('#descr-'+te_id).slideToggle({ 1474 duration: 300, 1475 easing: 'swing', 1476 complete: false 1477 }); 1478 $('#te-'+te_id).toggleClass('activ'); 1479 te_id = 0; 1480 } 1481 te_id = id; 1482} 1483 1484function ShowMenu(){ 1485 if ($('.sticky-2').css('position') == 'relative') { 1486 var menu_top = $(".sticky-2").offset().top; 1487 var scrollTop = window.pageYOffset || document.documentElement.scrollTop; 1488 1489 if (scrollTop<$menu_top_pos) {return false;} 1490 $('.sticky-2').css('top', +$nav_top_h+'px'); 1491 $('.sticky-2').css('z-index', '1000'); 1492 $('.sticky-2').css('position', 'sticky'); 1493 $('#bars').addClass('current'); 1494 }else{ 1495 $('.sticky-2').css('top', '0'); 1496 $('.sticky-2').css('z-index', '500'); 1497 $('.sticky-2').css('position', 'relative'); 1498 $('#bars').removeClass('current'); 1499 } 1500} 1501$(document).ready(function() { 1502/* 1503 $(window).scroll(function() { 1504 //$('.sticky-2').css('top', +$nav_top_h+'px'); 1505 var scrollTop = window.pageYOffset || document.documentElement.scrollTop; 1506 var wind_top = $("#izmer").offset().top; 1507 var menu_top = $(".sticky-2").offset().top; 1508 var menu_height = $(".sticky-2").outerHeight(); 1509 var scroll1 = scrollTop + menu_height; 1510 var scroll2 = scrollTop + menu_height +10; 1511 1512 if (menu_top>$menu_top_pos+1 && $('.sticky-2').css('position') == 'sticky') { 1513 $('.sticky-2').css('top', '0'); 1514 $('.sticky-2').css('z-index', '0'); 1515 $('.sticky-2').css('position', 'relative'); 1516 } 1517 }); 1518*/ 1519 $(window).on('resize', function(){ 1520 setTimeout(function() { 1521 initProductsCarouselCompare('comparison'); 1522 }, 1000); 1523 var pos_left=$('.sub-body').offset().left; 1524 var pos_width=$('.sub-body').width(); 1525 $('#sv-cart-box-fly').innerWidth(pos_width); 1526 $('#sv-cart-box-fly').offset({bottom: 0, left: pos_left}); 1527
1528 var $nav_top_h = $('.sticky-0').height(); 1529 $('.sub-body').css('margin-top', $nav_top_h); 1530 $('.sticky-2').css('top', +$nav_top_h+'px'); 1531 1532 function autoReload(){ 1533 var goal = self.location; 1534 location.href = goal; 1535 } 1536 1537 if (user_device == 'computer' && $(window).width() <= 768) { 1538 autoReload(); 1539 } 1540 1541 }); 1542 1543 $('input[type="text"], input[type="password"]').keypress(function(e){ 1544 if (e.which == 13 && this.form.action != '') { 1545 this.form.submit(); 1546 } 1547 }); 1548 1549 visitorUpdateActTime(); 1550 1551 $(document).on('click', 'a.cat-but', function(e) { 1552 e.preventDefault(); 1553 var punkt_id = $(this).parent().parent().attr('id'); 1554 var menu_scroll_top_0 = $('#'+punkt_id).offset().top; 1555 var delta_scroll = menu_scroll_top_0 - $(window).scrollTop(); 1556 1557 if($(this).parent().parent().siblings().hasClass("opened")){ 1558 $(this).parent().parent().siblings().removeClass("opened"); 1559 $(this).parent().parent().siblings().addClass("closed"); 1560 $('a.cat-but i').removeClass('fas fa-chevron-up'); 1561 $('a.cat-but i').addClass('fas fa-chevron-down'); 1562 } 1563 1564 $(this).parent().parent().toggleClass("closed opened"); 1565 if ($(this).parent().parent().hasClass("closed")) { 1566 $(this).children().removeClass("fas fa-chevron-up"); 1567 $(this).children().addClass("fas fa-chevron-down"); 1568 }else{ 1569 $(this).children().removeClass("fas fa-chevron-down"); 1570 $(this).children().addClass("fas fa-chevron-up"); 1571 } 1572 1573 var menu_scroll_top_1 = $('#'+punkt_id).offset().top; 1574 //$(window).scrollTop(menu_scroll_top_1 - delta_scroll); 1575 1576 return false; 1577 }); 1578 1579// ------------------------ ÐонÑÑÐ¾Ð»Ñ Ð¾ÑобÑÐ°Ð¶ÐµÐ½Ð¸Ñ Ð¿Ð»Ð°Ð²Ð°ÑÑей коÑÐ·Ð¸Ð½Ñ ÑÑаÑÑ 1580 if ($('#sv-cart-box-fly').get(0) && window.location.toString().indexOf('cart.htm')<=0 && $('#flyer').hasClass('hidden') == false){ 1581 $.ajax({ 1582 url: BASE_URL + 'modules/cart/cart_js.php?act=fly-cart-visibility-get', 1583 dataType: 'json', 1584 success: function(data) { 1585 if (data.arg4 > 0) { 1586 var pos_left=$('.sub-body').offset().left; 1587 var pos_width=$('.sub-body').width(); 1588 $('#sv-cart-box-fly').innerWidth(pos_width); 1589 $('#sv-cart-box-fly').offset({bottom: 0, left: pos_left}); 1590 $('#sv-cart-box-fly').removeClass('hidden'); 1591 $('.bottom-line').css('padding', '10px 10px 50px 10px'); 1592 $('#Go_Top').css('bottom', '40px'); 1593 } 1594 } 1595 }); 1596 }; 1597// ------------------------ ÐонÑÑÐ¾Ð»Ñ Ð¾ÑобÑÐ°Ð¶ÐµÐ½Ð¸Ñ Ð¿Ð»Ð°Ð²Ð°ÑÑей коÑÐ·Ð¸Ð½Ñ ÑÑоп 1598 1599 // ------------------------ Yamm3 menu start 1600 $(document).on('click', '.yamm .dropdown-menu', function(e) { 1601 e.stopPropagation(); 1602 }); 1603 // ------------------------ Yamm3 menu end 1604 1605 $('.tab-knobs').click(function (e) { 1606 e.preventDefault() 1607 $('.tab-knobs').removeClass('active'); 1608 $(this).addClass('active') 1609 }); 1610 1611 1612 1613}); 1614 1615/* setup vars for our trigger, form, text input and result elements */ 1616var $voiceTrigger = $("#voice-trigger"); 1617var $searchForm = $("#search"); 1618var $searchInput = $("#inp-find"); 1619var $result = $("#result"); 1620 1621/* set Web Speech API for Chrome or Firefox */ 1622window.SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition; 1623/* 1624if(window.SpeechRecognition || window.webkitSpeechRecognition || window.mozSpeechRecognition || window.msSpeechRecognition){ 1625 alert('ÐÑаÑÐ·ÐµÑ Ð¿Ð¾Ð´Ð´ÐµÑÐ¶Ð¸Ð²Ð°ÐµÑ Ð´Ð°Ð½Ð½ÑÑ ÑÐµÑ Ð½Ð¾Ð»Ð¾Ð³Ð¸Ñ'); 1626}else{ 1627 alert('Ðе поддеÑживаеÑÑÑ Ð´Ð°Ð½Ð½Ñм бÑаÑзеÑом'); 1628} 1629*/ 1630/* Check if browser support Web Speech API, remove the voice trigger if not supported */ 1631if (window.SpeechRecognition) { 1632 1633 /* setup Speech Recognition */ 1634 var recognition = new SpeechRecognition(); 1635 recognition.interimResults = true; 1636 recognition.lang = 'ru-RU'; 1637 recognition.addEventListener('result', _transcriptHandler); 1638 1639 recognition.onerror = function(event) { 1640 console.log(event.error); 1641 1642 /* Revert input and icon CSS if no speech is detected */ 1643 if(event.error == 'no-speech'){ 1644 $voiceTrigger.removeClass('active'); 1645 $searchInput.attr("placeholder", "ÐоиÑк..."); 1646 } 1647 } 1648} else { 1649 $voiceTrigger.remove(); 1650} 1651 1652jQuery(document).ready(function(){ 1653 1654 /* Trigger listen event when our trigger is clicked */ 1655 $voiceTrigger.on('click touch', listenStart); 1656}); 1657 1658/* Our listen event */ 1659function listenStart(e){ 1660 e.preventDefault();
1661 /* Update input and icon CSS to show that the browser is listening */ 1662 $searchInput.attr("placeholder", "ÐовоÑиÑе..."); 1663 $voiceTrigger.addClass('active'); 1664 /* Start voice recognition */ 1665 recognition.start(); 1666} 1667 1668/* Parse voice input */ 1669function _parseTranscript(e) { 1670 return Array.from(e.results).map(function (result) { return result[0] }).map(function (result) { return result.transcript }).join('') 1671} 1672 1673/* Convert our voice input into text and submit the form */ 1674function _transcriptHandler(e) { 1675 var speechOutput = _parseTranscript(e) 1676 $searchInput.val(speechOutput); 1677 //$result.html(speechOutput); 1678 if (e.results[0].isFinal) { 1679 $searchForm.submit(); 1680 } 1681}
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.