1(function($, window) { 2 "use strict"; 3 var arrowWidth = 16; 4 5 $.fn.resizeselect = function(settings) { 6 return this.each(function() { 7 $(this) 8 .change(function() { 9 var $this = $(this); 10 11 // create test element 12 var text = $this.find("option:selected").text(); 13 var $test = $("<span>").html(text); 14 15 // add to body, get width, and get out 16 $test.appendTo("body"); 17 var width = $test.width(); 18 $test.remove(); 19 20 // set select width 21 $this.width(width + arrowWidth); 22 23 // run on start 24 }) 25 .change(); 26 }); 27 }; 28 29 $.fn.arrangeObjects = function(wrapWith, maxCols) { 30 this.each(function() { 31 if ($(this).parent(wrapWith).length) $(this).unwrap(); 32 }); 33 34 this.parent().each(function() { 35 var $subnodes = $(this).children(); 36 37 // true will cause counter increment 38 // false will cause counter decrement 39 var inc = true; 40 var cols = []; 41 42 for (var i = 0; i < maxCols; i++) { 43 cols.push($("<ul></ul>")); 44 cols[i].appendTo($(this)); 45 } 46 47 function sortByHeight(a, b) { 48 return $(a).height() > $(b).height() ? 0 : 1; 49 } 50 51 $subnodes = $subnodes.sort(sortByHeight); 52 53 var i = 0; 54 $subnodes.each(function() { 55 // logic for left and right boundry 56 if (i < 0 || i === maxCols) { 57 inc = !inc; 58 // this will cause node to be added once again to the same column 59 inc ? i++ : i--; 60 } 61 62 cols[i].append($(this)); 63 64 inc ? i++ : i--; 65 }); 66 }); 67 }; 68 69 // run by default 70 $("select.resizeselect").resizeselect(); 71})(jQuery, window); 72 73(function($) { 74 "use strict"; 75 76 /*===================================================================================*/ 77 /* WOW 78 /*===================================================================================*/ 79 80 $(document).ready(function() { 81 new WOW().init(); 82 }); 83 84 /*===================================================================================*/ 85 86 /*===================================================================================*/ 87 /* Accessories Product Check 88 /*===================================================================================*/ 89 90 jQuery(document).ready(function($) { 91 function accessory_checked_count() { 92 var product_count = 0; 93 $(".accessory-checkbox .product-check").each(function() { 94 if ($(this).is(":checked")) { 95 product_count++; 96 } 97 }); 98 return product_count; 99 } 100 101 function accessory_checked_total_price() { 102 var total_price = 0; 103 $(".accessory-checkbox .product-check").each(function() { 104 if ($(this).is(":checked")) { 105 total_price += parseFloat($(this).data("price")); 106 } 107 }); 108 return total_price; 109 } 110 111 function accessory_checked_product_ids() { 112 var product_ids = []; 113 $(".accessory-checkbox .product-check").each(function() { 114 if ($(this).is(":checked")) { 115 product_ids.push($(this).data("product-id")); 116 } 117 }); 118 return product_ids; 119 } 120 121 function accessory_unchecked_product_ids() { 122 var product_ids = []; 123 $(".accessory-checkbox .product-check").each(function() { 124 if (!$(this).is(":checked")) { 125 product_ids.push($(this).data("product-id")); 126 } 127 }); 128 return product_ids; 129 } 130 131 function accessory_checked_variable_product_ids() { 132 var variable_product_ids = []; 133 $(".accessory-checkbox .product-check").each(function() { 134 if ($(this).is(":checked") && $(this).data("product-type") == "variable") { 135 variable_product_ids.push($(this).data("product-id")); 136 } 137 }); 138 return variable_product_ids; 139 } 140 141 function accessory_is_variation_selected() { 142 if ($(".single_add_to_cart_button").is(":disabled")) { 143 return false; 144 } 145 return true; 146 } 147 148 function accessory_refresh_fragments(response) { 149 var this_page = window.location.toString(); 150 var fragments = response.fragments; 151 var cart_hash = response.cart_hash; 152 153 // Block fragments class 154 if (fragments) { 155 $.each(fragments, function(key) { 156 $(key).addClass("updating"); 157 }); 158 } 159 160 // Replace fragments 161 if (fragments) { 162 $.each(fragments, function(key, value) { 163 $(key).replaceWith(value); 164 }); 165 } 166 167 // Cart page elements 168 $(".shop_table.cart").load(this_page + " .shop_table.cart:eq(0) > *", function() { 169 $(".shop_table.cart") 170 .stop(true) 171 .css("opacity", "1") 172 .unblock(); 173 174 $(document.body).trigger("cart_page_refreshed"); 175 }); 176 177 $(".cart_totals").load(this_page + " .cart_totals:eq(0) > *", function() { 178 $(".cart_totals") 179 .stop(true) 180 .css("opacity", "1") 181 .unblock(); 182 }); 183 } 184 185 $(".accessory-checkbox .product-check").on("click", function() { 186 $.ajax({
187 cache: false, 188 url: "http://demo2.transvelo.in/electro/wp-admin/admin-ajax.php", 189 success: function(result) { 190 var previous_price = $("span.total-price-html .amount") 191 .text() 192 .replace(/\.|\,/g, ""); 193 var current_price = accessory_checked_total_price() 194 .toFixed(2) 195 .replace(/./g, function(c, i, a) { 196 return i && c !== "." && (a.length - i) % 3 === 0 ? "," + c : c; 197 }); 198 total_price = previous_price.replace(/\d+/g, current_price); 199 $("span.total-price-html .amount").html(total_price); 200 $("span.total-products").html(accessory_checked_count()); 201 202 var unchecked_product_ids = accessory_unchecked_product_ids(); 203 $(".accessories ul.products > li").each(function() { 204 $(this).show(); 205 for (var i = 0; i < unchecked_product_ids.length; i++) { 206 if ($(this).hasClass("post-" + unchecked_product_ids[i])) { 207 $(this).hide(); 208 } 209 } 210 }); 211 } 212 }); 213 }); 214 215 $(".accessories-add-all-to-cart .add-all-to-cart").on("click", function() { 216 var accerories_all_product_ids = accessory_checked_product_ids(); 217 var accerories_variable_product_ids = accessory_checked_variable_product_ids(); 218 if (accerories_all_product_ids.length === 0) { 219 var accerories_alert_msg = '<div class="woocommerce-error">No Products selected.</div>'; 220 } else if (accerories_variable_product_ids.length > 0 && accessory_is_variation_selected() === false) { 221 var accerories_alert_msg = '<div class="woocommerce-error">Product Variation does not selected.</div>'; 222 } else { 223 for (var i = 0; i < accerories_all_product_ids.length; i++) { 224 if (!$.inArray(accerories_all_product_ids[i], accerories_variable_product_ids)) { 225 var variation_id = $(".variations_form .variations_button") 226 .find("input[name^=variation_id]") 227 .val(); 228 var variation = {}; 229 if ($(".variations_form").find("select[name^=attribute]").length) { 230 $(".variations_form") 231 .find("select[name^=attribute]") 232 .each(function() { 233 var attribute = $(this).attr("name"); 234 var attributevalue = $(this).val(); 235 variation[attribute] = attributevalue; 236 }); 237 } else { 238 $(".variations_form") 239 .find(".select") 240 .each(function() { 241 var attribute = $(this).attr("data-attribute-name"); 242 var attributevalue = $(this) 243 .find(".selected") 244 .attr("data-name"); 245 variation[attribute] = attributevalue; 246 }); 247 } 248 $.ajax({
249 type: "POST", 250 async: false, 251 url: "http://demo2.transvelo.in/electro/wp-admin/admin-ajax.php", 252 data: { action: "electro_variable_add_to_cart", product_id: accerories_all_product_ids[i], variation_id: variation_id, variation: variation }, 253 success: function(response) { 254 accessory_refresh_fragments(response); 255 } 256 }); 257 } else { 258 $.ajax({ 259 type: "POST", 260 async: false, 261 url: "http://demo2.transvelo.in/electro/wp-admin/admin-ajax.php", 262 data: { action: "woocommerce_add_to_cart", product_id: accerories_all_product_ids[i] }, 263 success: function(response) { 264 accessory_refresh_fragments(response); 265 } 266 }); 267 } 268 } 269 var accerories_alert_msg = 270 '<div class="woocommerce-message">Products was successfully added to your cart. <a class="button wc-forward" href="http://demo2.transvelo.in/electro/cart/">View Cart</a></div>'; 271 } 272 $(".electro-wc-message").html(accerories_alert_msg); 273 }); 274 }); 275 276 /*===================================================================================*/ 277 /* Set Height of Products li 278 /*===================================================================================*/ 279 280 // these are (ruh-roh) globals. You could wrap in an 281 // immediately-Invoked Function Expression (IIFE) if you wanted to... 282 var currentTallest = 0, 283 currentRowStart = 0, 284 rowDivs = new Array(); 285 286 function setConformingHeight(el, newHeight) { 287 // set the height to something new, but remember the original height in case things change 288 el.data("originalHeight", el.data("originalHeight") == undefined ? el.height() : el.data("originalHeight")); 289 el.height(newHeight); 290 } 291 292 function getOriginalHeight(el) { 293 // if the height has changed, send the originalHeight 294 return el.data("originalHeight") == undefined ? el.height() : el.data("originalHeight"); 295 } 296 297 function columnConform() { 298 $(".product-outer").each(function() { 299 var $this = $(this); 300 if (0 != $this.height()) { 301 $this.height($this.height()); 302 } 303 }); 304 } 305 306 $(window).on("resize", function() { 307 columnConform(); 308 }); 309 310 $(".ec-tabs > li > a").on("click", function() { 311 if (location.pathname.replace(/^\//, "") == this.pathname.replace(/^\//, "") && location.hostname == this.hostname) { 312 var target = $(this.hash); 313 target = target.length ? target : $("[name=" + this.hash.slice(1) + "]"); 314 315 if (target.length) { 316 $("html, body").animate( 317 { 318 scrollTop: target.offset().top 319 }, 320 1000 321 ); 322 //return false; 323 } 324 } 325 }); 326 327 $('a[data-toggle="tab"]').on("shown.bs.tab", function(e) { 328 if (e.target == "#grid" || e.target == "#grid-extended") { 329 columnConform(); 330 } 331 }); 332 333 /*===================================================================================*/ 334 /* YITH Wishlist 335 /*===================================================================================*/ 336 337 $(document).ready(function() { 338 $(".add_to_wishlist").on("click", function() { 339 $(this) 340 .closest(".images-and-summary") 341 .block(); 342 $(this) 343 .closest(".product-inner") 344 .block(); 345 $(this) 346 .closest(".product-list-view-inner") 347 .block(); 348 $(this) 349 .closest(".product-item-inner") 350 .block(); 351 }); 352 353 $(".yith-wcwl-wishlistaddedbrowse > .feedback").on("click", function() { 354 var browseWishlistURL = $(this) 355 .next() 356 .attr("href"); 357 window.location.href = browseWishlistURL; 358 }); 359 }); 360 361 $(document).on("added_to_wishlist", function() { 362 $(".images-and-summary").unblock(); 363 $(".product-inner").unblock(); 364 $(".product-list-view-inner").unblock(); 365 $(".product-item-inner").unblock(); 366 }); 367 368 /*===================================================================================*/ 369 /* LAZY LOAD IMAGES USING ECHO 370 /*===================================================================================*/ 371 372 echo.init({ 373 offset: 100, 374 throttle: 250, 375 unload: false 376 }); 377 378 /*===================================================================================*/ 379 /* WooCompare 380 /*===================================================================================*/ 381 382 $(document).on("click", ".add-to-compare-link:not(.added)", function(e) { 383 e.preventDefault(); 384 385 var button = $(this), 386 data = { 387 _yitnonce_ajax: yith_woocompare.nonceadd, 388 action: yith_woocompare.actionadd, 389 id: button.data("product_id"), 390 context: "frontend" 391 }, 392 widget_list = $(".yith-woocompare-widget ul.products-list"); 393 394 // add ajax loader
395 if (typeof woocommerce_params != "undefined") { 396 button.closest(".images-and-summary").block(); 397 button.closest(".product-inner").block(); 398 button.closest(".product-list-view-inner").block(); 399 button.closest(".product-item-inner").block(); 400 widget_list.block(); 401 } 402 403 $.ajax({ 404 type: "post", 405 url: yith_woocompare.ajaxurl.toString().replace("%%endpoint%%", yith_woocompare.actionadd), 406 data: data, 407 dataType: "json", 408 success: function(response) { 409 if (typeof woocommerce_params != "undefined") { 410 $(".images-and-summary").unblock(); 411 $(".product-inner").unblock(); 412 $(".product-list-view-inner").unblock(); 413 $(".product-item-inner").unblock(); 414 widget_list.unblock(); 415 } 416 417 button 418 .addClass("added") 419 .attr("href", mc_options.compare_page_url) 420 .text(yith_woocompare.added_label); 421 422 // add the product in the widget 423 widget_list.html(response.widget_table); 424 } 425 }); 426 }); 427 428 /*===================================================================================*/ 429 /* Add to Cart animation 430 /*===================================================================================*/ 431 432 $("body").on("adding_to_cart", function(e, $btn, data) { 433 $btn.closest("li.product").block(); 434 }); 435 436 $("body").on("added_to_cart", function() { 437 $("li.product").unblock(); 438 return false; 439 }); 440 441 $(document).ready(function() { 442 var is_rtl = false; 443 444 var hash_value = window.location.hash; 445 446 switch (hash_value) { 447 case "#grid-extended": 448 case "#list-view": 449 case "#list-view-small": 450 case "#grid": 451 $('.shop-view-switcher a[href="' + hash_value + '"]').tab("show"); 452 break; 453 case "#tab-accessories": 454 case "#tab-description": 455 case "#tab-specification": 456 case "#tab-reviews": 457 $('.wc-tabs a[href="' + hash_value + '"]').trigger("click"); 458 break; 459 } 460 461 // Adjust Product Item heights 462 columnConform(); 463 464 // Set Home Page Sidebar margin-top 465 var departments_menu_height = $(".page-template-template-homepage-v2 .departments-menu > li > ul.dropdown-menu").height(), 466 home_fullwidth_slider_height = $(".page-template-template-homepage-v2 .home-v2-slider").height(), 467 sidebar_margin_top = 0; 468 469 if (departments_menu_height > home_fullwidth_slider_height) { 470 sidebar_margin_top = departments_menu_height + 24; 471 } else { 472 sidebar_margin_top = home_fullwidth_slider_height; 473 } 474 475 sidebar_margin_top = sidebar_margin_top + 35; 476 $(".page-template-template-homepage-v2 #sidebar").css("margin-top", sidebar_margin_top); 477 478 // Detect wrapping of price 479 $(".price-add-to-cart > .price").each(function() { 480 var $this = $(this); 481 if ($this[0].scrollWidth > $this.innerWidth()) { 482 //Text has over-flowed 483 $this.find(".electro-price").css("position", "relative"); 484 if (is_rtl) { 485 $this.find("del").attr("style", "position:absolute;right:0;top:-14px;"); 486 } else { 487 $this.find("del").attr("style", "position:absolute;left:0;top:-14px;"); 488 } 489 } 490 }); 491 492 // Vertical Menu dropdown min-height 493 var $vertical_menu = $(".vertical-menu"), 494 vertical_menu_height = $vertical_menu.height(), 495 vm_header_height = 52.25, 496 dd_menu_min_height = vertical_menu_height - vm_header_height; 497 498 $vertical_menu.find(".dropdown > .dropdown-menu").each(function() { 499 $(this).css("min-height", dd_menu_min_height); 500 $(this) 501 .find(".menu-item-object-static_block") 502 .css("min-height", dd_menu_min_height); 503 }); 504 505 var $list_group_dd = $(".vertical-menu > .list-group-item > .dropdown-menu"), 506 list_group_dd_style = $list_group_dd.attr("style"), 507 list_group_dd_height = 0; 508 509 $list_group_dd.css({ 510 visibility: "hidden", 511 display: "none" 512 }); 513 514 list_group_dd_height = $list_group_dd.height() + 15; 515 516 $list_group_dd.attr("style", list_group_dd_style ? list_group_dd_style : ""); 517 518 $list_group_dd.find(".dropdown-menu").each(function() { 519 $(this).css("min-height", list_group_dd_height); 520 $(this) 521 .find(".menu-item-object-static_block") 522 .css("min-height", list_group_dd_height); 523 });
524 525 // Departments menu Height 526 var $departments_menu_dropdown = $(".departments-menu-dropdown"), 527 departments_menu_dropdown_height = $departments_menu_dropdown.height(); 528 529 $departments_menu_dropdown.find(".dropdown > .dropdown-menu").each(function() { 530 $(this) 531 .find(".menu-item-object-static_block") 532 .css("min-height", departments_menu_dropdown_height + 24); 533 $(this).css("min-height", departments_menu_dropdown_height + 28); 534 }); 535 536 $(".vertical-menu, .departments-menu-dropdown").on("mouseleave", function() { 537 var $this = $(this); 538 $this.removeClass("animated-dropdown"); 539 }); 540 541 $(".vertical-menu .menu-item-has-children, .departments-menu-dropdown .menu-item-has-children").on({ 542 mouseenter: function() { 543 var $this = $(this), 544 $dropdown_menu = $this.find(".dropdown-menu"), 545 $vertical_menu = $this.parents(".vertical-menu"), 546 $departments_menu = $this.parents(".departments-menu-dropdown"), 547 css_properties = { 548 width: 540, 549 opacity: 1 550 }, 551 animation_duration = 300, 552 has_changed_width = true, 553 animated_class = "", 554 $container = ""; 555 556 if ($vertical_menu.length > 0) { 557 $container = $vertical_menu; 558 } else if ($departments_menu.length > 0) { 559 $container = $departments_menu; 560 } 561 562 if ($this.hasClass("yamm-tfw")) { 563 css_properties.width = 540; 564 565 if ($departments_menu.length > 0) { 566 css_properties.width = 600; 567 } 568 } else if ($this.hasClass("yamm-fw")) { 569 css_properties.width = 900; 570 } else if ($this.hasClass("yamm-hw")) { 571 css_properties.width = 450; 572 } else { 573 css_properties.width = 277; 574 } 575 576 $dropdown_menu.css({ 577 visibility: "visible", 578 display: "block" 579 }); 580 581 if (!$container.hasClass("animated-dropdown")) { 582 $dropdown_menu.animate(css_properties, animation_duration, function() { 583 $container.addClass("animated-dropdown"); 584 }); 585 } else { 586 $dropdown_menu.css(css_properties); 587 } 588 }, 589 mouseleave: function() { 590 $(this) 591 .find(".dropdown-menu") 592 .css({ 593 visibility: "hidden", 594 opacity: 0, 595 width: 0, 596 display: "none" 597 }); 598 } 599 }); 600 601 // Owl Carousel 602 $(".slider-next").on("click", function() { 603 var owl = $($(this).data("target") + " .owl-carousel"); 604 owl.trigger("next.owl.carousel"); 605 return false; 606 }); 607 608 $(".slider-prev").on("click", function() { 609 var owl = $($(this).data("target") + " .owl-carousel"); 610 owl.trigger("prev.owl.carousel"); 611 return false; 612 }); 613 614 // Animate on scroll into view 615 $(".animate-in-view").each(function() { 616 var $this = $(this), 617 animation = $this.data("animation"); 618 if (typeof $this !== "undefined") { 619 $this.waypoint( 620 function(e) { 621 $(this).addClass(animation + " animated"); 622 }, 623 { 624 triggerOnce: true, 625 offset: "90%" 626 } 627 ); 628 } 629 }); 630 631 /*===================================================================================*/ 632 /* Electro Product Gallery Carousel 633 /*===================================================================================*/ 634 635 $(".single-product .electro-gallery").each(function() { 636 var $sync1 = $(this).children(".thumbnails-single"); 637 var $sync2 = $(this).children(".thumbnails-all"); 638 var flag = false; 639 var duration = 300; 640 641 $sync1.owlCarousel({ 642 items: 1, 643 margin: 0, 644 dots: false, 645 nav: false, 646 rtl: is_rtl, 647 responsive: { 648 0: { 649 items: 1 650 }, 651 480: { 652 items: 1 653 }, 654 768: { 655 items: 1 656 } 657 } 658 }); 659 660 $sync1.on("changed.owl.carousel", function(e) { 661 if (!flag) { 662 flag = true; 663 $sync2.trigger("to.owl.carousel", [e.item.index, duration, true]); 664 flag = false; 665 } 666 $sync2 667 .find(".owl-item") 668 .removeClass("synced") 669 .eq(e.item.index) 670 .addClass("synced"); 671 }); 672 673 $sync2.on("initialized.owl.carousel", function(e) { 674 $sync2 675 .find(".owl-item") 676 .eq(0) 677 .addClass("synced"); 678 }); 679 680 var thumbnail_column_class = $sync2.attr("class"); 681 var cols = parseInt(thumbnail_column_class.replace("thumbnails-all columns-", "")); 682 683 $sync2.owlCarousel({ 684 items: cols, 685 margin: 8, 686 dots: true, 687 nav: false, 688 rtl: is_rtl, 689 responsive: { 690 0: { 691 items: 1 692 }, 693 480: { 694 items: 3 695 }, 696 768: { 697 items: cols 698 } 699 } 700 }); 701 702 $sync2.on("click", "a", function(e) { 703 e.preventDefault(); 704 }); 705 706 $sync2.on("click", ".owl-item", function() { 707 $sync1.trigger("to.owl.carousel", [$(this).index(), duration, true]); 708 }); 709 710 $sync2.on("changed.owl.carousel", function(e) { 711 if (!flag) { 712 flag = true; 713 $sync1.trigger("to.owl.carousel", [e.item.index, duration, true]); 714 flag = false; 715 } 716 }); 717 });
718 719 $(".electro-store-directory .product-categories > li").arrangeObjects("ul", 4); 720 721 /*===================================================================================*/ 722 /* PRODUCT CATEGORIES TOGGLE 723 /*===================================================================================*/ 724 725 $(".product-categories .show-all-cat-dropdown").each(function() { 726 if ($(this).siblings("ul").length > 0) { 727 var $childIndicator = $('<span class="child-indicator"><i class="fa fa-angle-right"></i></span>'); 728 729 $(this) 730 .siblings("ul") 731 .hide(); 732 if ( 733 $(this) 734 .siblings("ul") 735 .is(":visible") 736 ) { 737 $childIndicator.addClass("open"); 738 $childIndicator.html('<i class="fa fa-angle-up"></i>'); 739 } 740 741 $(this).on("click", function() { 742 $(this) 743 .siblings("ul") 744 .toggle("fast", function() { 745 if ($(this).is(":visible")) { 746 $childIndicator.addClass("open"); 747 $childIndicator.html('<i class="fa fa-angle-up"></i>'); 748 } else { 749 $childIndicator.removeClass("open"); 750 $childIndicator.html('<i class="fa fa-angle-right"></i>'); 751 } 752 }); 753 return false; 754 }); 755 $(this).append($childIndicator); 756 } 757 }); 758 759 $(".cat-item > a").each(function() { 760 if ($(this).siblings("ul.children").length > 0) { 761 var $childIndicator = $('<span class="child-indicator"><i class="fa fa-angle-right"></i></span>'); 762 763 $(this) 764 .siblings(".children") 765 .hide(); 766 $(".current-cat > .children").show(); 767 $(".current-cat-parent > .children").show(); 768 if ( 769 $(this) 770 .siblings(".children") 771 .is(":visible") 772 ) { 773 $childIndicator.addClass("open"); 774 $childIndicator.html('<i class="fa fa-angle-up"></i>'); 775 } 776 777 $childIndicator.on("click", function() { 778 $(this) 779 .parent() 780 .siblings(".children") 781 .toggle("fast", function() { 782 if ($(this).is(":visible")) { 783 $childIndicator.addClass("open"); 784 $childIndicator.html('<i class="fa fa-angle-up"></i>'); 785 } else { 786 $childIndicator.removeClass("open"); 787 $childIndicator.html('<i class="fa fa-angle-right"></i>'); 788 } 789 }); 790 return false; 791 }); 792 $(this).prepend($childIndicator); 793 } else { 794 $(this).prepend('<span class="no-child"></span>'); 795 } 796 }); 797 }); 798})(jQuery);
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.