Advertisement
Guest User

Untitled

a guest
Dec 4th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.34 KB | None | 0 0
  1. (function($, window){
  2. 'use strict';
  3.  
  4. var arrowWidth = 16;
  5.  
  6. $.fn.resizeselect = function(settings) {
  7.  
  8. return this.each( function() {
  9.  
  10. $(this).change( function(){
  11.  
  12. var $this = $(this);
  13.  
  14. // create test element
  15. var text = $this.find("option:selected").text();
  16. var $test = $("<span>").html(text);
  17.  
  18. // add to body, get width, and get out
  19. $test.appendTo('body');
  20. var width = $test.width();
  21. $test.remove();
  22.  
  23. // set select width
  24. $this.width(width + arrowWidth);
  25.  
  26. // run on start
  27. }).change();
  28.  
  29. });
  30. };
  31.  
  32. $.fn.arrangeObjects = function(wrapWith, maxCols) {
  33.  
  34. this.each(function() {
  35. if ($(this).parent(wrapWith).length) $(this).unwrap();
  36. });
  37.  
  38. this.parent().each(function () {
  39. var $subnodes = $(this).children();
  40.  
  41. // true will cause counter increment
  42. // false will cause counter decrement
  43. var inc = true;
  44. var cols = [];
  45.  
  46. for (var i = 0; i < maxCols; i++) {
  47. cols.push($('<ul></ul>'));
  48. cols[i].appendTo($(this));
  49. }
  50.  
  51. function sortByHeight(a, b) {
  52. return $(a).height() > $(b).height() ? 0 : 1;
  53. }
  54.  
  55. $subnodes = $subnodes.sort(sortByHeight);
  56.  
  57. var i = 0;
  58. $subnodes.each(function () {
  59. // logic for left and right boundry
  60. if (i < 0 || i === maxCols) {
  61. inc = !inc;
  62. // this will cause node to be added once again to the same column
  63. inc ? i++ : i--;
  64. }
  65.  
  66. cols[i].append($(this));
  67.  
  68. inc ? i++ : i--;
  69. });
  70. });
  71. };
  72.  
  73. })(jQuery, window);
  74.  
  75. (function($) {
  76. 'use strict';
  77.  
  78.  
  79. if( typeof $.blockUI !== "undefined" ) {
  80. $.blockUI.defaults.message = null;
  81. $.blockUI.defaults.overlayCSS.background = '#fff url(' + electro_options.ajax_loader_url + ') no-repeat center';
  82. $.blockUI.defaults.overlayCSS.backgroundSize = '16px 16px';
  83. $.blockUI.defaults.overlayCSS.opacity = 0.6;
  84. }
  85.  
  86. /**
  87. * Initialize all tooltips on the page
  88. */
  89. $( '[data-toggle="tooltip"]').tooltip();
  90.  
  91. /**
  92. * Once add to cart button is updated, add tooltip for view cart and remove the tooltip of add to cart
  93. */
  94. $( document ).on ( 'wc_cart_button_updated', function( event, button ) {
  95. $( button ).siblings( '.added_to_cart' ).tooltip();
  96. $( button ).parents( '.add-to-cart-wrap' ).addClass( 'added' ).tooltip( 'hide' ).tooltip( 'dispose' );
  97. } );
  98.  
  99. /*===================================================================================*/
  100. /* Visual Composer Row Behavior
  101. /*===================================================================================*/
  102.  
  103. var is_rtl = $('body,html').hasClass('rtl');
  104.  
  105. if ( is_rtl ) {
  106.  
  107. window.vc_rowBehaviour = function () {
  108. var $ = window.jQuery;
  109. var local_function = function () {
  110. var $elements = $( '[data-vc-full-width="true"]' );
  111. $.each( $elements, function ( key, item ) {
  112. var $el = $( this );
  113. var $el_full = $el.next( '.vc_row-full-width' );
  114. var $el_wrapper = $( '#page' );
  115. var el_margin_left = parseInt( $el.css( 'margin-left' ), 10 );
  116. var el_margin_right = parseInt( $el.css( 'margin-right' ), 10 );
  117. var offset = 0 - $el_full.offset().left - el_margin_left + $el_wrapper.offset().left;
  118. var width = $el_wrapper.width();
  119. if( is_rtl ){
  120. $el.css( {
  121. 'position': 'relative',
  122. 'right': offset,
  123. 'box-sizing': 'border-box',
  124. 'width': $el_wrapper.width()
  125. } );
  126. } else {
  127. $el.css( {
  128. 'position': 'relative',
  129. 'left': offset,
  130. 'box-sizing': 'border-box',
  131. 'width': $el_wrapper.width()
  132. } );
  133. }
  134.  
  135. if ( ! $el.data( 'vcStretchContent' ) ) {
  136. var padding = (- 1 * offset);
  137. if ( padding < 0 ) {
  138. padding = 0;
  139. }
  140. var paddingRight = width - padding - $el_full.width() + el_margin_left + el_margin_right;
  141. if ( paddingRight < 0 ) {
  142. paddingRight = 0;
  143. }
  144. $el.css( { 'padding-left': padding + 'px', 'padding-right': paddingRight + 'px' } );
  145. }
  146. $el.attr( "data-vc-full-width-init", "true" );
  147. } );
  148. };
  149. /**
  150. * @todo refactor as plugin.
  151. * @returns {*}
  152. */
  153. var parallaxRow = function () {
  154. var vcSkrollrOptions,
  155. callSkrollInit = false;
  156. if ( vcParallaxSkroll ) {
  157. vcParallaxSkroll.destroy();
  158. }
  159. $( '.vc_parallax-inner' ).remove();
  160. $( '[data-5p-top-bottom]' ).removeAttr( 'data-5p-top-bottom data-30p-top-bottom' );
  161. $( '[data-vc-parallax]' ).each( function () {
  162. var skrollrSpeed,
  163. skrollrSize,
  164. skrollrStart,
  165. skrollrEnd,
  166. $parallaxElement,
  167. parallaxImage;
  168. callSkrollInit = true; // Enable skrollinit;
  169. if ( $( this ).data( 'vcParallaxOFade' ) == 'on' ) {
  170. $( this ).children().attr( 'data-5p-top-bottom', 'opacity:0;' ).attr( 'data-30p-top-bottom',
  171. 'opacity:1;' );
  172. }
  173.  
  174. skrollrSize = $( this ).data( 'vcParallax' ) * 100;
  175. $parallaxElement = $( '<div />' ).addClass( 'vc_parallax-inner' ).appendTo( $( this ) );
  176. $parallaxElement.height( skrollrSize + '%' );
  177.  
  178. parallaxImage = $( this ).data( 'vcParallaxImage' );
  179.  
  180. if ( parallaxImage !== undefined ) {
  181. $parallaxElement.css( 'background-image', 'url(' + parallaxImage + ')' );
  182. }
  183.  
  184. skrollrSpeed = skrollrSize - 100;
  185. skrollrStart = - skrollrSpeed;
  186. skrollrEnd = 0;
  187.  
  188. $parallaxElement.attr( 'data-bottom-top', 'top: ' + skrollrStart + '%;' ).attr( 'data-top-bottom',
  189. 'top: ' + skrollrEnd + '%;' );
  190. } );
  191.  
  192. if ( callSkrollInit && window.skrollr ) {
  193. vcSkrollrOptions = {
  194. forceHeight: false,
  195. smoothScrolling: false,
  196. mobileCheck: function () {
  197. return false;
  198. }
  199. };
  200. vcParallaxSkroll = skrollr.init( vcSkrollrOptions );
  201. return vcParallaxSkroll;
  202. }
  203. return false;
  204. };
  205.  
  206. $( window ).unbind( 'resize.vcRowBehaviour' ).bind( 'resize.vcRowBehaviour', local_function );
  207.  
  208. local_function();
  209. parallaxRow();
  210. }
  211. }
  212.  
  213. /*===================================================================================*/
  214. /* Set Height of Products li
  215. /*===================================================================================*/
  216.  
  217. // these are (ruh-roh) globals. You could wrap in an
  218. // immediately-Invoked Function Expression (IIFE) if you wanted to...
  219. var currentTallest = 0,
  220. currentRowStart = 0,
  221. rowDivs = new Array();
  222.  
  223. function setConformingHeight(el, newHeight) {
  224. // set the height to something new, but remember the original height in case things change
  225. el.data("originalHeight", (el.data("originalHeight") == undefined) ? (el.height()) : (el.data("originalHeight")));
  226. el.height(newHeight);
  227. }
  228.  
  229. function getOriginalHeight(el) {
  230. // if the height has changed, send the originalHeight
  231. return (el.data("originalHeight") == undefined) ? (el.height()) : (el.data("originalHeight"));
  232. }
  233.  
  234. function columnConform() {
  235. if( $( window ).width() > 992 ) {
  236. $( '.columns-1:not(.exclude-auto-height) .product-outer' ).each( function() {
  237. var $this = $(this);
  238. if ( 0 != $this.height() ) {
  239. $this.height( $this.height() );
  240. }
  241. });
  242. }
  243. }
  244.  
  245. function columnConformV2() {
  246. if( $( window ).width() > 992 ) {
  247. $( 'li.product.first:last-child .product-outer' ).each( function() {
  248. var $this = $(this);
  249. var $wrap = '';
  250. var $shop_products = $this.parents( '[data-toggle="shop-products"]' );
  251. var $regular_products = $this.parents( '[data-toggle="regular-products"]' );
  252.  
  253. if( $shop_products.length > 0 && ! $shop_products.parents( '.exclude-auto-height' ).length > 0 ) {
  254. $wrap = $shop_products;
  255. } else if( $regular_products.length > 0 && ! $regular_products.parents( '.exclude-auto-height' ).length > 0 ) {
  256. $wrap = $regular_products;
  257. }
  258.  
  259. if ( $wrap.length > 0 ) {
  260. $this.height( 'auto' );
  261. if( $wrap.attr( 'data-view' ) == 'grid' || $wrap.attr( 'data-view' ) == 'grid-extended' ) {
  262. if ( 0 != $this.height() ) {
  263. $this.height( $this.height() );
  264. }
  265. }
  266. }
  267. });
  268. }
  269. }
  270.  
  271. $( window ).on( 'resize', function() {
  272. columnConform();
  273. columnConformV2();
  274. });
  275.  
  276. $( '.ec-tabs > li > a' ).on( 'click', function() {
  277. if ( location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname ) {
  278. var target = $(this.hash);
  279. target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
  280.  
  281. if ( target.length ) {
  282.  
  283. scrollTo = target.offset().top;
  284.  
  285. if ( $('.sticky-wrapper > .stuck' ).length > 0 ) {
  286. scrollTo = scrollTo - 40;
  287. }
  288.  
  289. $('html, body').animate({
  290. scrollTop: scrollTo
  291. }, 1000);
  292. }
  293. }
  294. });
  295.  
  296. $('a[data-toggle="tab"]').on( 'shown.bs.tab', function (e) {
  297.  
  298. if ( e.target == '#grid' || e.target == '#grid-extended' ) {
  299. columnConform();
  300. }
  301. });
  302.  
  303. $( window ).load( function() {
  304. columnConform();
  305. columnConformV2();
  306. });
  307.  
  308. // Bootstrap Multi level dropdown trigger
  309. $('li.dropdown-submenu > a').on('click', function(event) {
  310. event.preventDefault();
  311. event.stopPropagation();
  312. var $this = $(this);
  313. var $current_dd = $this.closest('li.dropdown-submenu');
  314. if ( $current_dd.hasClass('open') ) {
  315. $current_dd.removeClass('open').find('li.dropdown-submenu.open').removeClass('open');
  316. } else {
  317. $current_dd.removeClass('open');
  318. $current_dd.siblings('li.dropdown-submenu.open').removeClass('open').find('li.dropdown-submenu.open').removeClass('open');
  319. $current_dd.addClass('open');
  320. }
  321. });
  322.  
  323. // Bootstrap Multi level dropdown remove on outside click
  324. $( document ).on('hidden.bs.dropdown', function ( event ) {
  325. $(this).find('li.dropdown-submenu.open').removeClass('open');
  326. });
  327.  
  328. $(document).ready( function() {
  329.  
  330. // Set a cookie and hide the store notice when the dismiss button is clicked
  331. $( '.woocommerce-store-notice__dismiss-link' ).on( 'click', function() {
  332. $('body').addClass( 'woocommerce-store-notice-dismissed' );
  333. } );
  334.  
  335. // Check the value of that cookie and show/hide the notice accordingly
  336.  
  337. if ( typeof Cookies != 'undefined' ) {
  338. if ( 'hidden' === Cookies.get( 'store_notice' ) ) {
  339. $('body').addClass( 'woocommerce-store-notice-dismissed' );
  340. } else {
  341. $('body').removeClass( 'woocommerce-store-notice-dismissed' );
  342. }
  343. }
  344.  
  345. // Resize Select
  346.  
  347. $( "select.resizeselect" ).resizeselect();
  348.  
  349. /*===================================================================================*/
  350. /* YITH Wishlist
  351. /*===================================================================================*/
  352.  
  353. $( '.add_to_wishlist' ).on( 'click', function() {
  354. $( this ).closest( '.images-and-summary' ).block();
  355. $( this ).closest( '.product-inner' ).block();
  356. $( this ).closest( '.product-list-view-inner' ).block();
  357. $( this ).closest( '.product-item-inner' ).block();
  358. });
  359.  
  360. $( '.yith-wcwl-wishlistaddedbrowse > .feedback' ).on( 'click', function() {
  361. var browseWishlistURL = $( this ).next().attr( 'href' );
  362. window.location.href = browseWishlistURL;
  363. });
  364.  
  365. });
  366.  
  367. $( document ).on( 'added_to_wishlist', function() {
  368. $( '.images-and-summary' ).unblock();
  369. $( '.product-inner' ).unblock();
  370. $( '.product-list-view-inner' ).unblock();
  371. $( '.product-item-inner' ).unblock();
  372. });
  373.  
  374. /*===================================================================================*/
  375. /* WooCompare
  376. /*===================================================================================*/
  377.  
  378.  
  379. $( document ).on( 'click', '.add-to-compare-link:not(.added)', function(e) {
  380.  
  381. e.preventDefault();
  382.  
  383. var button = $(this),
  384. data = {
  385. _yitnonce_ajax: yith_woocompare.nonceadd,
  386. action: yith_woocompare.actionadd,
  387. id: button.data('product_id'),
  388. context: 'frontend'
  389. },
  390. widget_list = $('.yith-woocompare-widget ul.products-list');
  391.  
  392. // add ajax loader
  393. if( typeof woocommerce_params != 'undefined' ) {
  394. button.closest( '.images-and-summary' ).block();
  395. button.closest( '.product-inner' ).block();
  396. button.closest( '.product-list-view-inner' ).block();
  397. button.closest( '.product-item-inner' ).block();
  398. widget_list.block();
  399. }
  400.  
  401. $.ajax({
  402. type: 'post',
  403. url: yith_woocompare.ajaxurl.toString().replace( '%%endpoint%%', yith_woocompare.actionadd ),
  404. data: data,
  405. dataType: 'json',
  406. success: function(response){
  407.  
  408. if( typeof woocommerce_params != 'undefined' ) {
  409. $( '.images-and-summary' ).unblock();
  410. $( '.product-inner' ).unblock();
  411. $( '.product-list-view-inner' ).unblock();
  412. $( '.product-item-inner' ).unblock();
  413. widget_list.unblock()
  414. }
  415.  
  416. button.addClass('added')
  417. .attr( 'href', electro_options.compare_page_url )
  418. .text( yith_woocompare.added_label );
  419.  
  420. // add the product in the widget
  421. widget_list.html( response.widget_table );
  422. }
  423. });
  424. });
  425.  
  426. /*===================================================================================*/
  427. /* Add to Cart animation
  428. /*===================================================================================*/
  429.  
  430. $( 'body' ).on( 'adding_to_cart', function( e, $btn, data){
  431. $btn.closest( '.product' ).block();
  432. });
  433.  
  434. $( 'body' ).on( 'added_to_cart', function(){
  435. $( '.product' ).unblock();
  436. });
  437.  
  438. /*===================================================================================*/
  439. /* WC Variation Availability
  440. /*===================================================================================*/
  441.  
  442. $( 'body' ).on( 'woocommerce_variation_has_changed', function( e ) {
  443. var $singleVariationWrap = $( 'form.variations_form' ).find( '.single_variation_wrap' );
  444. var $availability = $singleVariationWrap.find( '.woocommerce-variation-availability' ).html();
  445. if ( typeof $availability !== "undefined" && $availability !== false ) {
  446. $( '.electro-stock-availability' ).html( $availability );
  447. }
  448. });
  449.  
  450. /*===================================================================================*/
  451. /* Deal Countdown timer
  452. /*===================================================================================*/
  453.  
  454. $( '.deal-countdown-timer' ).each( function() {
  455. var deal_countdown_text = electro_options.deal_countdown_text;
  456.  
  457. // set the date we're counting down to
  458. var deal_time_diff = $(this).children('.deal-time-diff').text();
  459. var countdown_output = $(this).children('.deal-countdown');
  460. var target_date = ( new Date().getTime() ) + ( deal_time_diff * 1000 );
  461.  
  462. // variables for time units
  463. var days, hours, minutes, seconds;
  464.  
  465. // update the tag with id "countdown" every 1 second
  466. setInterval( function () {
  467.  
  468. // find the amount of "seconds" between now and target
  469. var current_date = new Date().getTime();
  470. var seconds_left = (target_date - current_date) / 1000;
  471.  
  472. // do some time calculations
  473. days = parseInt(seconds_left / 86400);
  474. seconds_left = seconds_left % 86400;
  475.  
  476. hours = parseInt(seconds_left / 3600);
  477. seconds_left = seconds_left % 3600;
  478.  
  479. minutes = parseInt(seconds_left / 60);
  480. seconds = parseInt(seconds_left % 60);
  481.  
  482. // format countdown string + set tag value
  483. countdown_output.html( '<span data-value="' + days + '" class="days"><span class="value">' + days + '</span><b>' + deal_countdown_text.days_text + '</b></span><span class="hours"><span class="value">' + hours + '</span><b>' + deal_countdown_text.hours_text + '</b></span><span class="minutes"><span class="value">'
  484. + minutes + '</span><b>' + deal_countdown_text.mins_text + '</b></span><span class="seconds"><span class="value">' + seconds + '</span><b>' + deal_countdown_text.secs_text + '</b></span>' );
  485.  
  486. }, 1000 );
  487. });
  488.  
  489.  
  490. $( document ).ready( function() {
  491.  
  492. var is_rtl;
  493.  
  494. if( electro_options.rtl == '1' ) {
  495. is_rtl = true;
  496. } else {
  497. is_rtl = false;
  498. }
  499.  
  500. var hash_value = window.location.hash;
  501.  
  502. switch( hash_value ) {
  503. case '#grid-extended':
  504. case '#list-view':
  505. case '#list-view-small':
  506. case '#grid':
  507. $( '.shop-view-switcher a[href="' + hash_value +'"]' ).tab( 'show' );
  508. break;
  509. case '#tab-accessories': case '#tab-description':
  510. case '#tab-specification':
  511. case '#tab-reviews':
  512. $( '.wc-tabs a[href="' + hash_value + '"]' ).trigger( 'click' );
  513. break;
  514. }
  515.  
  516. // Set Home Page Sidebar margin-top
  517. var departments_menu_height = $( '.page-template-template-homepage-v2 .departments-menu > .dropdown > ul.dropdown-menu' ).height(),
  518. home_fullwidth_slider_height = $( '.page-template-template-homepage-v2 .home-v2-slider' ).height(),
  519. sidebar_margin_top = 0;
  520.  
  521. if ( departments_menu_height > home_fullwidth_slider_height ) {
  522. sidebar_margin_top = departments_menu_height + 24;
  523. } else {
  524. sidebar_margin_top = home_fullwidth_slider_height;
  525. }
  526.  
  527. sidebar_margin_top = sidebar_margin_top + 35;
  528. //$( '.page-template-template-homepage-v2 #sidebar').css( 'margin-top', sidebar_margin_top );
  529.  
  530. // Detect wrapping of price
  531. $( '.price-add-to-cart > .price' ).each( function() {
  532. var $this = $( this );
  533. if ( $this[0].scrollWidth > $this.innerWidth() ) {
  534. //Text has over-flowed
  535. $this.find( '.electro-price' ).css( 'position', 'relative' );
  536. if( is_rtl ){
  537. $this.find( 'del' ).attr( 'style', 'position:absolute;right:0;top:-14px;');
  538. }else {
  539. $this.find( 'del' ).attr( 'style', 'position:absolute;left:0;top:-14px;');
  540. }
  541. }
  542. });
  543.  
  544. $( '.shop-view-switcher' ).on( 'click', '.nav-link', function() {
  545. $( '[data-toggle="shop-products"]' ).attr( 'data-view', $(this).data( 'archiveClass' ) );
  546. columnConformV2();
  547. } );
  548.  
  549. if ( $( window ).width() > 768 ) {
  550. // Vertical Menu dropdown min-height
  551. var $vertical_menu = $( '.vertical-menu' ),
  552. vertical_menu_height = $vertical_menu.height(),
  553. vm_header_height = 52.25,
  554. dd_menu_min_height = vertical_menu_height - vm_header_height;
  555.  
  556. $vertical_menu.find( '.dropdown > .dropdown-menu, .dropdown-submenu > .dropdown-menu' ).each( function() {
  557. $(this).css( 'min-height', dd_menu_min_height );
  558. $(this).find( '.menu-item-object-static_block' ).css( 'min-height', dd_menu_min_height );
  559. });
  560.  
  561. var $list_group_dd = $( '.vertical-menu > .list-group-item > .dropdown-menu' ),
  562. list_group_dd_style = $list_group_dd.attr( 'style' ),
  563. list_group_dd_height = 0;
  564.  
  565. $list_group_dd.css({
  566. visibility: 'hidden',
  567. display: 'none'
  568. });
  569.  
  570. list_group_dd_height = $list_group_dd.height() + 15;
  571.  
  572. $list_group_dd.attr( 'style', list_group_dd_style ? list_group_dd_style : '' );
  573.  
  574. $list_group_dd.find( '.dropdown-menu' ).each( function() {
  575. $(this).css( 'min-height', list_group_dd_height );
  576. $(this).find( '.menu-item-object-static_block' ).css( 'min-height', list_group_dd_height );
  577. });
  578.  
  579. // Departments menu Height
  580. var $departments_menu_dropdown = $( '.departments-menu-dropdown' ),
  581. departments_menu_dropdown_height = $departments_menu_dropdown.height();
  582.  
  583. $departments_menu_dropdown.find( '.dropdown-submenu > .dropdown-menu' ).each( function() {
  584. $(this).find( '.menu-item-object-static_block' ).css( 'min-height', departments_menu_dropdown_height + 24 );
  585. $(this).css( 'min-height', departments_menu_dropdown_height + 28 );
  586. });
  587.  
  588. $( '.vertical-menu, .departments-menu-dropdown' ).on( 'mouseleave', function() {
  589. var $this = $(this);
  590. $this.removeClass( 'animated-dropdown' );
  591. });
  592.  
  593. $( '.vertical-menu .menu-item-has-children, .departments-menu-dropdown .menu-item-has-children' ).on({
  594. mouseenter: function() {
  595. var $this = $(this),
  596. $dropdown_menu = $this.find( '> .dropdown-menu' ),
  597. $vertical_menu = $this.parents( '.vertical-menu' ),
  598. $departments_menu = $this.parents( '.departments-menu-dropdown' ),
  599. css_properties = {
  600. width: 540,
  601. opacity: 1
  602. },
  603. animation_duration = 300,
  604. has_changed_width = true,
  605. animated_class = '',
  606. $container = '';
  607.  
  608. if ( $vertical_menu.length > 0 ) {
  609. $container = $vertical_menu;
  610. } else if ( $departments_menu.length > 0 ) {
  611. $container = $departments_menu;
  612. }
  613.  
  614. if ( $this.hasClass( 'yamm-tfw' ) ) {
  615. css_properties.width = 540;
  616.  
  617. if ( $departments_menu.length > 0 ) {
  618. css_properties.width = 600;
  619. }
  620. } else if ( $this.hasClass( 'yamm-fw' ) ) {
  621. css_properties.width = 900;
  622. } else if ( $this.hasClass( 'yamm-hw' ) ) {
  623. css_properties.width = 450;
  624. } else {
  625. css_properties.width = 277;
  626. }
  627.  
  628. $dropdown_menu.css( {
  629. visibility: 'visible',
  630. display: 'block'
  631. } );
  632.  
  633. if ( ! $container.hasClass( 'animated-dropdown' ) ) {
  634. $dropdown_menu.animate( css_properties, animation_duration, function() {
  635. $container.addClass( 'animated-dropdown' );
  636. });
  637. } else {
  638. $dropdown_menu.css( css_properties );
  639. }
  640. }, mouseleave: function() {
  641. $(this).find( '> .dropdown-menu' ).css({
  642. visibility: 'hidden',
  643. opacity: 0,
  644. width: 0,
  645. display: 'none'
  646. });
  647. }
  648. });
  649.  
  650. $( '.electro-animate-dropdown, .departments-menu-v2' ).on( 'mouseleave', function() {
  651. var $this = $(this);
  652. $this.removeClass( 'animated-dropdown' );
  653. });
  654.  
  655. $( '.electro-animate-dropdown .menu-item, .departments-menu-v2 .menu-item' ).on( 'mouseenter', function() {
  656. var $this = $(this),
  657. $departments_menu = $this.parents( '.departments-menu-v2' ),
  658. $container = $this.parents( '.electro-animate-dropdown' );
  659.  
  660. if ( $departments_menu.length > 0 ) {
  661. $container = $departments_menu;
  662. }
  663.  
  664. if ( $this.hasClass( 'menu-item-has-children' ) ) {
  665. if ( ! $container.hasClass( 'animated-dropdown' ) ) {
  666. setTimeout(function(){
  667. $container.addClass( 'animated-dropdown' );
  668. }, 200);
  669. }
  670. } else if ( $container.hasClass( 'animated-dropdown' ) ) {
  671. var $parent = $this.parents( '.menu-item-has-children' );
  672. if ( $parent.length <= 0 ) {
  673. $container.removeClass( 'animated-dropdown' );
  674. }
  675. }
  676. });
  677. }
  678.  
  679. // Handheld Footer Bottom Widgets Collapse
  680. $( '.handheld-footer.v1 .handheld-widget-menu .widget-title' ).on( 'click', function() {
  681. $( this ).siblings('div,ul').collapse( 'toggle' );
  682. });
  683. $( '.handheld-footer.v1 .handheld-widget-menu .widget-title' ).each( function() {
  684. $( this ).siblings('div,ul').addClass( 'collapse' );
  685. });
  686.  
  687. /*===================================================================================*/
  688. /* Handheld Sidebar
  689. /*===================================================================================*/
  690. // Hamburger Sidebar Toggler
  691. $( '.handheld-sidebar-toggle .sidebar-toggler' ).on( 'click', function() {
  692. $( this ).closest('.site-content').toggleClass( "active-hh-sidebar" );
  693. } );
  694.  
  695. // Hamburger Sidebar Close Trigger
  696. $( '.tmhh-sidebar-close' ).on( 'click', function() {
  697. $( this ).closest('.site-content').toggleClass( "active-hh-sidebar" );
  698. } );
  699.  
  700. // Hamburger Sidebar Close Trigger when click outside menu slide
  701. $( document ).on("click", function(event) {
  702. if ( $( '.site-content' ).hasClass( 'active-hh-sidebar' ) ) {
  703. if ( ! $( '.handheld-sidebar-toggle' ).is( event.target ) && 0 === $( '.handheld-sidebar-toggle' ).has( event.target ).length && ! $( '#sidebar' ).is( event.target ) && 0 === $( '#sidebar' ).has( event.target ).length ) {
  704. $( '.site-content' ).toggleClass( "active-hh-sidebar" );
  705. }
  706. }
  707. });
  708.  
  709. $( '.electro-handheld-footer-bar .search > a' ).on( 'click', function(e) {
  710. $( this ).parent().toggleClass( 'active' );
  711. e.preventDefault();
  712. });
  713.  
  714. $( '.handheld-header-links .search > a' ).on( 'click', function(e) {
  715. $( this ).closest('.search').toggleClass( 'active' );
  716. $('body').toggleClass( 'disableScroll' );
  717. e.preventDefault();
  718. });
  719.  
  720. $( document ).on("click", function(event) {
  721. if ( $( '.handheld-header-links .search' ).hasClass( 'active' ) ) {
  722. if ( ! $( '.handheld-header-links .search' ).is( event.target ) && 0 === $( '.handheld-header-links .search' ).has( event.target ).length ) {
  723. $( 'body' ).removeClass( 'disableScroll' );
  724. $( '.handheld-header-links .search' ).removeClass( "active" );
  725. }
  726. }
  727. });
  728.  
  729. // Hamburger Menu Toggler
  730. $( '.handheld-navigation-wrapper .navbar-toggler' ).on( 'click', function() {
  731. $( this ).closest('.handheld-navigation-wrapper').toggleClass( "toggled" );
  732. } );
  733.  
  734. // Hamburger Menu Close Trigger
  735. $( '.ehm-close' ).on( 'click', function() {
  736. $( this ).closest('.handheld-navigation-wrapper').toggleClass( "toggled" );
  737. } );
  738.  
  739. // Hamburger Menu Close Trigger when click outside menu slide
  740. $( document ).on("click", function(event) {
  741. if ( $( '.handheld-navigation-wrapper' ).hasClass( 'toggled' ) ) {
  742. if ( ! $( '.handheld-navigation-wrapper' ).is( event.target ) && 0 === $( '.handheld-navigation-wrapper' ).has( event.target ).length ) {
  743. $( '.handheld-navigation-wrapper' ).toggleClass( "toggled" );
  744. }
  745. }
  746. });
  747.  
  748. $( '.off-canvas-navigation-wrapper .navbar-toggle-hamburger' ).on( 'click', function() {
  749. var css_properties = {
  750. transform: 'translateX(250px)',
  751. transition: 'all .5s'
  752. };
  753. if( is_rtl ) {
  754. css_properties.transform = 'translateX(-250px)';
  755. }
  756.  
  757. if ( $( this ).parents( '.stuck' ).length > 0 ) {
  758. $('html, body').animate({
  759. scrollTop: $('body')
  760. }, 0);
  761. }
  762.  
  763. $( this ).closest('.off-canvas-navigation-wrapper').toggleClass( "toggled" );
  764. $('#page').toggleClass( "off-canvas-bg-opacity" ).css( css_properties );
  765. } );
  766.  
  767. $( '.off-canvas-navigation-wrapper .navbar-toggle-close' ).on( 'click', function() {
  768. $( this ).closest('.off-canvas-navigation-wrapper').removeClass( "toggled" );
  769. $('#page').css({'transform': 'none','transition': 'all .5s'}).removeClass( "off-canvas-bg-opacity" );
  770. } );
  771.  
  772. $( document ).on("click", function(event) {
  773. if ( $( '.off-canvas-navigation-wrapper' ).hasClass( 'toggled' ) ) {
  774. if ( ! $( '.off-canvas-navigation-wrapper' ).is( event.target ) && 0 === $( '.off-canvas-navigation-wrapper' ).has( event.target ).length ) {
  775. $( '.off-canvas-navigation-wrapper' ).removeClass( "toggled" );
  776. $('#page').css({'transform': 'none','transition': 'all .5s'}).removeClass( "off-canvas-bg-opacity" );
  777. }
  778. }
  779. });
  780.  
  781. // Animate on scroll into view
  782. $( '.animate-in-view' ).each( function() {
  783. var $this = $(this), animation = $this.data( 'animation' );
  784. var waypoint_animate = new Waypoint({
  785. element: $this,
  786. handler: function(e) {
  787. $this.addClass( $this.data( 'animation' ) + ' animated' );
  788. },
  789. offset: '90%'
  790. });
  791. });
  792.  
  793. /*===================================================================================*/
  794. /* STICKY NAVIGATION
  795. /*===================================================================================*/
  796.  
  797. // If we're in desktop orientation...
  798. if ( $( window ).width() > 768 ) {
  799. if( electro_options.enable_sticky_header == '1' && $( "#page" ).find( '.stick-this' ).length > 0 ) {
  800. var sticky_header = new Waypoint.Sticky({
  801. element: $('.stick-this')[0],
  802. stuckClass: 'stuck animated fadeInDown faster'
  803. });
  804. }
  805. }
  806.  
  807. // If we're in hand-held navigation...
  808. if( electro_options.enable_sticky_header == '1' && $( "#page" ).find( '.handheld-navbar-toggle-buttons' ).length > 0 ) {
  809. var sticky_hh_nav = new Waypoint.Sticky({
  810. element: $('.handheld-navbar-toggle-buttons')[0],
  811. stuckClass: 'stuck animated fadeInDown faster'
  812. });
  813. }
  814.  
  815. // Owl Carousel
  816. $( '.slider-next' ).on( 'click', function() {
  817. var owl = $( $( this ).data( 'target' ) + ' .owl-carousel' );
  818. owl.trigger( 'next.owl.carousel' );
  819. return false;
  820. });
  821.  
  822. $( '.slider-prev' ).on( 'click', function() {
  823. var owl = $( $( this ).data( 'target' ) + ' .owl-carousel' );
  824. owl.trigger( 'prev.owl.carousel' );
  825. return false;
  826. });
  827.  
  828. /*===================================================================================*/
  829. /* Electro Product Gallery Carousel
  830. /*===================================================================================*/
  831.  
  832. $( 'body' ).on( 'woocommerce_variation_has_changed', function( event ) {
  833. var $product_img = $(this).find( '.product div.electro-gallery img:eq(0)' );
  834. var $product_link = $(this).find( '.product div.electro-gallery a.zoom:eq(0)' );
  835. var image_url = $product_link.attr('href');
  836.  
  837. if ( typeof variation !== "undefined" && variation ) {
  838. $(this).wc_variations_image_update( variation );
  839. } else {
  840. $(this).wc_variations_image_update( false );
  841. }
  842.  
  843. $('.single-product .electro-gallery > .thumbnails-single .owl-item').each( function() {
  844. if( $(this).find('a').attr( 'href' ) == image_url ) {
  845. $( '.single-product .electro-gallery .thumbnails-single' ).trigger('to.owl.carousel', [$(this).index(), 300, true]);
  846. }
  847. });
  848. });
  849.  
  850. $( '[data-ride="owl-carousel"]').each( function() {
  851. var $this = $( this ), carouselDiv = $this.data( 'carouselSelector' ), carouselOptions = $this.data( 'carouselOptions' ),
  852. shouldReplaceActiveClass = $this.data( 'replaceActiveClass' ), $carousel_elem;
  853.  
  854. if ( 'self' === carouselDiv ) {
  855. $carousel_elem = $this.owlCarousel( carouselOptions );
  856. } else {
  857. $carousel_elem = $this.find( carouselDiv );
  858. }
  859.  
  860. if ( true === shouldReplaceActiveClass ) {
  861. $carousel_elem.on( 'initialized.owl.carousel translated.owl.carousel', function() {
  862. var $this = $(this);
  863.  
  864. $this.find( '.owl-item.last-active' ).each( function() {
  865. $(this).removeClass( 'last-active' );
  866. });
  867.  
  868. $(this).find( '.owl-item.active' ).last().addClass( 'last-active' );
  869. });
  870. }
  871.  
  872. $carousel_elem.owlCarousel( carouselOptions );
  873. });
  874.  
  875. $( '.single-product .electro-gallery' ).each( function() {
  876. var $sync1 = $(this).children('.thumbnails-single');
  877. var $sync2 = $(this).children('.thumbnails-all');
  878. var flag = false;
  879. var duration = 300;
  880.  
  881. $sync1.owlCarousel( {
  882. items: 1,
  883. margin: 0,
  884. dots: false,
  885. nav: false,
  886. rtl: is_rtl,
  887. responsive:{
  888. 0:{
  889. items:1
  890. },
  891. 480:{
  892. items:1
  893. },
  894. 768:{
  895. items:1
  896. },
  897. }
  898. });
  899.  
  900. $sync1.on('changed.owl.carousel', function (e) {
  901. if (!flag) {
  902. flag = true;
  903. $sync2.trigger('to.owl.carousel', [e.item.index, duration, true]);
  904. flag = false;
  905. }
  906. $sync2.find(".owl-item").removeClass("synced").eq(e.item.index).addClass("synced");
  907. });
  908.  
  909. $sync2.on('initialized.owl.carousel',function (e) {
  910. $sync2.find(".owl-item").eq(0).addClass("synced");
  911. });
  912.  
  913. var thumbnail_column_class = $sync2.attr( 'class' );
  914. var cols = 4;
  915. if( typeof thumbnail_column_class !== 'undefined' ) {
  916. cols = parseInt( thumbnail_column_class.replace( 'thumbnails-all columns-', '' ) );
  917. }
  918.  
  919. $sync2.owlCarousel( {
  920. items: cols,
  921. margin: 8,
  922. dots: true,
  923. nav: false,
  924. rtl: is_rtl,
  925. responsive:{
  926. 0:{
  927. items:1
  928. },
  929. 480:{
  930. items:3
  931. },
  932. 768:{
  933. items:cols
  934. },
  935. }
  936. });
  937.  
  938. $sync2.on('click', 'a', function (e) {
  939. e.preventDefault();
  940. });
  941.  
  942. $sync2.on('click', '.owl-item', function () {
  943. $sync1.trigger('to.owl.carousel', [$(this).index(), duration, true]);
  944. });
  945.  
  946. $sync2.on('changed.owl.carousel', function (e) {
  947. if (!flag) {
  948. flag = true;
  949. $sync1.trigger('to.owl.carousel', [e.item.index, duration, true]);
  950. flag = false;
  951. }
  952. });
  953. });
  954.  
  955. $(".electro-store-directory .product-categories > li").arrangeObjects('ul', 4);
  956.  
  957. /*===================================================================================*/
  958. /* Products LIVE Search
  959. /*===================================================================================*/
  960.  
  961. if( electro_options.enable_live_search == '1' ) {
  962.  
  963. if ( electro_options.ajax_url.indexOf( '?' ) > 1 ) {
  964. var prefetch_url = electro_options.ajax_url + '&action=products_live_search&fn=get_ajax_search';
  965. var remote_url = electro_options.ajax_url + '&action=products_live_search&fn=get_ajax_search&terms=%QUERY';
  966. } else {
  967. var prefetch_url = electro_options.ajax_url + '?action=products_live_search&fn=get_ajax_search';
  968. var remote_url = electro_options.ajax_url + '?action=products_live_search&fn=get_ajax_search&terms=%QUERY';
  969. }
  970.  
  971. var searchProducts = new Bloodhound({
  972. datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
  973. queryTokenizer: Bloodhound.tokenizers.whitespace,
  974. prefetch: prefetch_url,
  975. remote: {
  976. url: remote_url,
  977. wildcard: '%QUERY',
  978. },
  979. identify: function(obj) {
  980. return obj.id;
  981. }
  982. });
  983.  
  984. searchProducts.initialize();
  985.  
  986. $( '.navbar-search .product-search-field' ).typeahead( electro_options.typeahead_options,
  987. {
  988. name: 'search',
  989. source: searchProducts.ttAdapter(),
  990. displayKey: 'value',
  991. limit: electro_options.live_search_limit,
  992. templates: {
  993. empty : [
  994. '<div class="empty-message">',
  995. electro_options.live_search_empty_msg,
  996. '</div>'
  997. ].join('\n'),
  998. suggestion: Handlebars.compile( electro_options.live_search_template )
  999. }
  1000. }
  1001. );
  1002. }
  1003.  
  1004. /*===================================================================================*/
  1005. /* PRODUCT CATEGORIES TOGGLE
  1006. /*===================================================================================*/
  1007.  
  1008. $('.product-categories .show-all-cat-dropdown').each(function(){
  1009. if( $(this).siblings('ul').length > 0 ) {
  1010. var $childIndicator = $('<span class="child-indicator"><i class="fa fa-angle-right"></i></span>');
  1011.  
  1012. $(this).siblings('ul').hide();
  1013. if($(this).siblings('ul').is(':visible')){
  1014. $childIndicator.addClass( 'open' );
  1015. $childIndicator.html('<i class="fa fa-angle-up"></i>');
  1016. }
  1017.  
  1018. $(this).on( 'click', function(){
  1019. $(this).siblings('ul').toggle( 'fast', function(){
  1020. if($(this).is(':visible')){
  1021. $childIndicator.addClass( 'open' );
  1022. $childIndicator.html('<i class="fa fa-angle-up"></i>');
  1023. }else{
  1024. $childIndicator.removeClass( 'open' );
  1025. $childIndicator.html('<i class="fa fa-angle-right"></i>');
  1026. }
  1027. });
  1028. return false;
  1029. });
  1030. $(this).append($childIndicator);
  1031. }
  1032. });
  1033.  
  1034. $('.product-categories .cat-item > a').each(function(){
  1035. if( $(this).siblings('ul.children').length > 0 ) {
  1036. var $childIndicator = $('<span class="child-indicator"><i class="fa fa-angle-right"></i></span>');
  1037.  
  1038. $(this).siblings('.children').hide();
  1039. $('.current-cat > .children').show();
  1040. $('.current-cat-parent > .children').show();
  1041. if($(this).siblings('.children').is(':visible')){
  1042. $childIndicator.addClass( 'open' );
  1043. $childIndicator.html('<i class="fa fa-angle-up"></i>');
  1044. }
  1045.  
  1046. $childIndicator.on( 'click', function(){
  1047. $(this).parent().siblings('.children').toggle( 'fast', function(){
  1048. if($(this).is(':visible')){
  1049. $childIndicator.addClass( 'open' );
  1050. $childIndicator.html('<i class="fa fa-angle-up"></i>');
  1051. }else{
  1052. $childIndicator.removeClass( 'open' );
  1053. $childIndicator.html('<i class="fa fa-angle-right"></i>');
  1054. }
  1055. });
  1056. return false;
  1057. });
  1058. $(this).prepend($childIndicator);
  1059. } else {
  1060. $(this).prepend('<span class="no-child"></span>');
  1061. }
  1062. });
  1063. });
  1064.  
  1065. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement