1;(function($) { 2 'use strict'; 3 4 var agriosTheme = { 5 6 // Main init function 7 init : function() { 8 this.config(); 9 this.events(); 10 }, 11 12 // Define vars for caching 13 config : function() { 14 this.config = { 15 $window : $( window ), 16 $document : $( document ), 17 }; 18 }, 19 20 // Events 21 events : function() { 22 var self = this; 23 // Run on document ready 24 25 // PreLoader 26 self.preLoader(); 27 28 // Menu Search Icon 29 self.searchIcon(); 30 31 // Cart Icon 32 self.cartIcon(); 33 34 // One Page 35 self.onePage(); 36 37 // Responsive Videos 38 self.responsiveVideos(); 39 40 // Header Fixed 41 self.headerFixed(); 42 43 //Scroll to Top 44 self.scrollToTop(); 45 46 // Quantity Button 47 self.quantityButton(); 48 49 // Hamburger Menu 50 self.hamburgerMenu(); 51 52 // Comment no Reply 53 self.noReply(); 54 55 // Custom Widget 56 self.customWidget(); 57
58 // Wishlist 59 self.wishlist(); 60 }, 61 62 // PreLoader 63 preLoader: function() { 64 if ( $().animsition ) { 65 if ( $('.animsition.image').length ) { 66 var $url = $('.animsition.image').data('preloader'); 67 $('.animsition').animsition({ 68 inClass: 'fade-in', 69 outClass: 'fade-out', 70 inDuration: 500, 71 outDuration: 300, 72 loading: true, 73 loadingParentElement: 'body', 74 loadingClass: 'animsition-image', 75 loadingInner: '<img src="' + $url + '" alt="Image" />', 76 timeout: true, 77 timeoutCountdown: 5000, 78 onLoadEvent: true, 79 browser: [ 80 '-webkit-animation-duration', 81 '-moz-animation-duration', 82 'animation-duration' 83 ], 84 overlay: false, 85 overlayClass: 'animsition-overlay-slide', 86 overlayParentElement: 'body', 87 transition: function(url){ window.location.href = url; } 88 }); 89 } else { 90 $('.animsition').animsition({ 91 inClass: 'fade-in', 92 outClass: 'fade-out', 93 inDuration: 500, 94 outDuration: 300, 95 loading: true, 96 loadingParentElement: 'body', 97 loadingClass: 'animsition-loading', 98 timeout: true, 99 timeoutCountdown: 5000, 100 onLoadEvent: true, 101 browser: [ 102 '-webkit-animation-duration', 103 '-moz-animation-duration', 104 'animation-duration' 105 ], 106 overlay: false, 107 overlayClass: 'animsition-overlay-slide', 108 overlayParentElement: 'body', 109 transition: function(url){ window.location.href = url; } 110 }); 111 } 112 } 113 }, 114 115 // Menu Search Icon 116 searchIcon: function() { 117 var search_wrap = $('.search-style-fullscreen'); 118 var search_trigger = $('.search-trigger'); 119 var search_field = search_wrap.find('.search-field'); 120 121 search_trigger.on('click', function(e) { 122 if ( ! search_wrap.hasClass('search-opened') ) { 123 search_wrap.addClass('search-opened'); 124 search_field.get(0).focus(); 125 126 } else if (search_field.val() === '') { 127 if ( search_wrap.hasClass('search-opened') ) 128 search_wrap.removeClass('search-opened'); 129 else search_field.get(0).focus(); 130 131 } else { 132 search_wrap.find('form').get(0).submit(); 133 } 134 135 $('html').addClass( 'disable-scroll' ); 136 e.preventDefault(); 137 return false; 138 }); 139 140 search_wrap.find('.search-close').on('click', function(e) { 141 search_wrap.removeClass('search-opened'); 142 $('html').removeClass( 'disable-scroll' ); 143 e.preventDefault(); 144 return false; 145 }); 146 }, 147 148 // Menu Cart Icon 149 cartIcon: function() { 150 $( document ).on( 'woocommerce-cart-changed', function( e, data ) { 151 if ( parseInt(data.items_count,10) >= 0 ) { 152 $('.shopping-cart-items-count') 153 .text( data.items_count ) 154 } 155 } ); 156 }, 157 158 159 // One Page 160 onePage: function() { 161 if ( $('#menu-one-page').length ) { 162 $('#menu-one-page li').filter(':first').addClass('current-menu-item'); 163 164 $('#menu-one-page li a').on('click',function() { 165 var anchor = $(this).attr('href').split('#')[1]; 166 167 if ( anchor ) { 168 if ( $('#'+anchor).length > 0 ) { 169 var headerHeight = 0; 170 171 var target = $('#' + anchor).offset().top - headerHeight; 172 173 $('html,body').animate({scrollTop: target}, 1000, 'easeInOutExpo'); 174 } 175 } 176 return false;
177 }); 178 179 $(window).on("scroll", function() { 180 var scrollPos = $(window).scrollTop(); 181 182 if ( $('body').hasClass('header-fixed') ) { 183 var headerHeight = $('#site-header').height(); 184 scrollPos = scrollPos + headerHeight; 185 } 186 187 $('#menu-one-page .menu-item a').each(function () { 188 var link = $(this); 189 var block = $( link.attr("href") ); 190 191 if ( block.offset().top <= scrollPos 192 && block.offset().top + block.height() > scrollPos ) { 193 $('#menu-one-page li').removeClass("current-menu-item"); 194 link.parent().addClass("current-menu-item"); 195 } else { 196 link.parent().removeClass("current-menu-item"); 197 } 198 }); 199 }); 200 } 201 }, 202 203 // Responsive Videos 204 responsiveVideos: function() { 205 if ( $().fitVids ) { 206 $('.agrios-container').fitVids(); 207 } 208 }, 209 210 // Header Fixed 211 headerFixed: function() { 212 var nav = $('.agrios-header-fixed'); 213 var sp = 0; 214 215 var showHeader = function() { 216 var np = $('body')[0].getBoundingClientRect().top; 217 var st = $(window).scrollTop(); 218 219 if (np > sp) { 220 if (st > 500) { 221 nav.addClass('fixed-show'); 222 } 223 if (st < 300) { 224 nav.removeClass('fixed-show'); 225 } 226 } else { 227 nav.removeClass('fixed-show'); 228 } 229 230 sp = np 231 } 232 233 $(window).on('scroll', showHeader); 234 }, 235 236 // Scroll to Top 237 scrollToTop: function() { 238 $(window).scroll(function() { 239 if ( $(this).scrollTop() > 800 ) { 240 $('#scroll-top').addClass('show'); 241 } else { 242 $('#scroll-top').removeClass('show'); 243 } 244 }); 245 246 $('#scroll-top').on('click', function() { 247 var rocket = $(this); 248 setTimeout(function(){ $('html, body').animate({ scrollTop: 0 }, 1000 , 'easeInOutExpo'); }, 250); 249 }); 250 }, 251 252 // Featured Media 253 featuredMedia: function() { 254 $('.blog-gallery').each(function () { 255 const gallery = new Swiper( $(this), { 256 direction: 'horizontal', 257 pagination: { 258 el: $(this).find('.swiper-pagination'), 259 clickable: true 260 }, 261 navigation: { 262 nextEl: $(this).find('.swiper-button-next'), 263 prevEl: $(this).find('.swiper-button-prev'), 264 }, 265 autoplay: { 266 delay: 5000, 267 }, 268 }); 269 }) 270 }, 271 272 // Quantity Button 273 quantityButton: function() { 274 if ( ! String.prototype.getDecimals ) { 275 String.prototype.getDecimals = function() { 276 var num = this, 277 match = ('' + num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/); 278 if ( ! match ) { 279 return 0; 280 } 281 return Math.max( 0, ( match[1] ? match[1].length : 0 ) - ( match[2] ? +match[2] : 0 ) ); 282 } 283 } 284 // Quantity "plus" and "minus" buttons 285 $( document.body ).on( 'click', '.plus, .minus', function() { 286 var $qty = $( this ).closest( '.quantity' ).find( '.qty'), 287 currentVal = parseFloat( $qty.val() ), 288 max = parseFloat( $qty.attr( 'max' ) ), 289 min = parseFloat( $qty.attr( 'min' ) ), 290 step = $qty.attr( 'step' ); 291 292 // Format values 293 if ( ! currentVal || currentVal === '' || currentVal === 'NaN' ) currentVal = 0; 294 if ( max === '' || max === 'NaN' ) max = ''; 295 if ( min === '' || min === 'NaN' ) min = 0; 296 if ( step === 'any' || step === '' || step === undefined || parseFloat( step )
296=== 'NaN' ) step = 1; 297 298 // Change the value 299 if ( $( this ).is( '.plus' ) ) { 300 if ( max && ( currentVal >= max ) ) { 301 $qty.val( max ); 302 } else { 303 $qty.val( ( currentVal + parseFloat( step )).toFixed( step.getDecimals() ) ); 304 } 305 } else { 306 if ( min && ( currentVal <= min ) ) { 307 $qty.val( min ); 308 } else if ( currentVal > 0 ) { 309 $qty.val( ( currentVal - parseFloat( step )).toFixed( step.getDecimals() ) ); 310 } 311 } 312 313 // Trigger change event 314 $qty.trigger( 'change' ); 315 }); 316 }, 317 318 // Hamburger Menu 319 hamburgerMenu: function() { 320 $('.agrios-menu-panel').each(function () { 321 var 322 t = $(this), 323 btn = t.siblings('.agrios-hamburger-icon'), 324 c = t.find('.close-menu'), 325 o = t.find('.menu-panel-overlay'), 326 w = t.find('.menu-panel-wrap'); 327 328 t.find('.menu-item-has-children').children('ul').before('<span class="arrow"></span>'); 329 330 t.find('.menu-item-has-children > .arrow').on('click', function() { 331 $(this).parent().toggleClass("active").siblings().removeClass("active"); 332 $(this).next("ul").slideToggle(); 333 $(this).parent().siblings().find("ul").slideUp(); 334 }) 335 336 o.on('click', function() { 337 btn.removeClass('hide'); 338 o.removeClass('show'); 339 w.animate({ right: "-100%" }, 300, 'easeInOutExpo') 340 $('html').removeClass( 'disable-scroll' ); 341 } ); 342 343 c.on('click', function() { 344 btn.removeClass('hide'); 345 o.removeClass('show'); 346 w.animate({ right: "-100%" }, 300, 'easeInOutExpo') 347 $('html').removeClass( 'disable-scroll' ); 348 } ); 349 350 btn.on('click', function() { 351 btn.addClass('hide'); 352 o.addClass('show'); 353 $('html').addClass( 'disable-scroll' ); 354 w.animate({ right: "0"}, 300, 'easeInOutExpo'); 355 }) 356 }) 357 }, 358 359 // Comment no Reply 360 noReply: function() { 361 $('#comments .comment-list .comment').each(function (idx, el) { 362 var btn = $(el).find('.comment-reply-link'); 363 if ( btn.length === 0 ) { 364 $(el).addClass('comment-no-reply'); 365 } 366 }) 367 }, 368 369 // Custom Widget 370 customWidget: function () { 371 if ( $('.custom-widget').length ) { 372 $('.custom-widget').each(function(idx, el) { 373 $(el).parent('.widget').addClass('widget-custom'); 374 }) 375 } 376 }, 377 378 // Wishlist 379 wishlist: function () { 380 if ( $('.shopengine_add_to_list_action.shopengine-wishlist').length ) { 381 $('.shopengine_add_to_list_action.shopengine-wishlist').each(function(idx, el) { 382 if ( $(el).is('.active') ) { 383 $(el).find('.text').text('Remove wishlist'); 384 } 385 386 $(el).on('click', function() { 387 if ( $(el).is('.active') ) { 388 $(el).find('.text').text('Add to wishlist'); 389 } else { 390 $(el).find('.text').text('Remove wishlist'); 391 } 392 }) 393 }) 394 } 395 }, 396 397 }; // end agriosTheme 398 399 // Start things up 400 agriosTheme.init(); 401 402})(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.