1;(function($) { 2 "use strict"; 3 4 var themesFlat = { 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 24 // Run on document ready 25 self.config.$document.on( 'ready', function() { 26 27 // Header Fixed 28 self.headerFixed(); 29 30 // Cart Icon 31 self.cartIcon(); 32 33 // Mobile Navigation 34 self.mobileNav(); 35 36 // Retina Logos 37 self.retinaLogo(); 38 39 // Responsive Videos 40 self.responsiveVideos(); 41 42 // Spacer 43 self.widgetSpacer(); 44 45 // Mega menu 46 self.megaMenu(); 47 48 // Scroll to Top 49 self.scrollToTop(); 50 51 // PreLoader 52 self.preLoader(); 53 } ); 54 55 // Run on Window Load 56 self.config.$window.on( 'load', function() { 57 58 } ); 59 }, 60 61 // Mega Menu 62 megaMenu: function() { 63 $(window).on('load resize', function() { 64 var 65 du = $('#main-nav .megamenu > ul'), 66 siteNav = $('#main-nav'), 67 siteHeader = $( '#site-header' ); 68 69 if ( du.length ) { 70 var 71 o = siteHeader.find(".themesflat-container").outerWidth(), 72 a = siteNav.outerWidth(), 73 n = siteNav.css("right"), 74 n = parseInt(n,10), 75 d = o-a-n; 76 if ( $('.site-navigation-wrap').length ) d = 0; 77 du.css({ width: o, "margin-left": -d }) 78 } 79 }); 80 }, 81 82 // PreLoader 83 preLoader: function() { 84 if ( $().animsition ) { 85 $('.animsition').animsition({ 86 inClass: 'fade-in', 87 outClass: 'fade-out', 88 inDuration: 1500, 89 outDuration: 800, 90 loading: true, 91 loadingParentElement: 'body', 92 loadingClass: 'animsition-loading', 93 timeout: false, 94 timeoutCountdown: 5000, 95 onLoadEvent: true, 96 browser: [ 97 '-webkit-animation-duration', 98 '-moz-animation-duration', 99 'animation-duration' 100 ], 101 overlay: false, 102 overlayClass: 'animsition-overlay-slide', 103 overlayParentElement: 'body', 104 transition: function(url){ window.location.href = url; } 105 }); 106 } 107 }, 108 109 // Menu Cart Icon 110 cartIcon: function() { 111 $( document ).on( 'woocommerce-cart-changed', function( e, data ) { 112 if ( parseInt(data.items_count,10) > 0 ) { 113 $('.shopping-cart-items-count') 114 .text( data.items_count ) 115 } 116 } ); 117 }, 118 119 // Mobile Navigation 120 mobileNav: function() { 121 var menuType = 'desktop'; 122 123 $(window).on('load resize', function() { 124 var mode = 'desktop'; 125 var wrapMenu = $('#site-header-inner .wrap-inner'); 126 var navExtw = $('.nav-extend.active'); 127 var navExt = $('.nav-extend.active').children(); 128 129 if ( matchMedia( 'only screen and (max-width: 991px)' ).matches ) 130 mode = 'mobile'; 131 132 if ( mode != menuType ) { 133 menuType = mode; 134 135 if ( mode === 'mobile' ) { 136 $('#main-nav').attr('id', 'main-nav-mobi') 137 .appendTo('#site-header') 138 .hide().children('.menu').append(navExt) 139 .find('li:has(ul)') 140 .children('ul') 141 .removeAttr('style') 142 .hide() 143 .before('<span class="arrow"></span>'); 144 } else { 145 if ( $('body').is('.header-style-3') ) 146 wrapMenu = $('.site-navigation-wrap .inner'); 147 148 $('#main-nav-mobi').attr('id', 'main-nav') 149 .removeAttr('style') 150 .prependTo(wrapMenu) 151 .find('.ext').appendTo(navExtw) 152 .parent().siblings('#main-nav') 153 .find('.sub-menu') 154 .removeAttr('style') 155 .prev().remove(); 156 157 $('.mobile-button').removeClass('active'); 158 } 159 } 160 }); 161 162 $(document).on('click', '.mobile-button', function() { 163 $(this).toggleClass('active'); 164 $('#main-nav-mobi').slideToggle(); 165 }) 166 167 $(document).on('click', '#main-nav-mobi .arrow', function() { 168 $(this).toggleClass('active').next().slideToggle(); 169 }) 170 }, 171 172 // Retina Logos 173 retinaLogo: function() { 174 var retina = window.devicePixelRatio > 1 ? true : false;
175 var $logo = $('#site-logo img'); 176 var $logo_retina = $logo.data('retina'); 177 178 if ( retina && $logo_retina ) { 179 $logo.attr({ 180 src: $logo.data('retina'), 181 width: $logo.data('width'), 182 height: $logo.data('height') 183 }); 184 } 185 }, 186 187 // Responsive Videos 188 responsiveVideos: function() { 189 if ( $().fitVids ) { 190 $('.themesflat-container').fitVids(); 191 } 192 }, 193 194 // Header Fixed 195 headerFixed: function() { 196 if ( $('body').hasClass('header-fixed') ) { 197 var nav = $('#site-header'); 198 199 if ( $('body').is('.header-style-8') ) { 200 var nav = $('.site-navigation-wrap'); 201 } 202 203 if ( nav.length ) { 204 var offsetTop = nav.offset().top, 205 headerHeight = nav.height(), 206 injectSpace = $('<div />', { 207 height: headerHeight 208 }).insertAfter(nav); 209 210 $(window).on('load scroll', function(){ 211 if ( $(window).scrollTop() > offsetTop ) { 212 nav.addClass('is-fixed'); 213 injectSpace.show(); 214 } else { 215 nav.removeClass('is-fixed'); 216 injectSpace.hide(); 217 } 218 219 if ( $(window).scrollTop() > 300 ) { 220 nav.addClass('is-small'); 221 } else { 222 nav.removeClass('is-small'); 223 } 224 }) 225 } 226 } 227 }, 228 229 // Scroll to Top 230 scrollToTop: function() { 231 $(window).scroll(function() { 232 if ( $(this).scrollTop() > 800 ) { 233 $('#scroll-top').addClass('show'); 234 } else { 235 $('#scroll-top').removeClass('show'); 236 } 237 }); 238 239 $('#scroll-top').on('click', function() { 240 $('html, body').animate({ scrollTop: 0 }, 1000 , 'easeInOutExpo'); 241 return false; 242 }); 243 244 $('.btn-anchor').on('click',function() { 245 var anchor = $(this).attr('href').split('#')[1]; 246 247 $(this).parent() 248 .addClass('current-menu-item') 249 .siblings() 250 .removeClass('current-menu-item'); 251 252 if ( anchor ) { 253 if ( $('#'+anchor).length > 0 ) { 254 var headerHeight = 0; 255 256 if ( $('body').hasClass('header_sticky')){ 257 headerHeight = $('#site-header').height(); 258 var target = $('#' + anchor).offset().top + 39 - headerHeight; 259 if ( matchMedia( 'only screen and (max-width: 991px)' ).matches ){ 260 var target = $('#' + anchor).offset().top + 10 - headerHeight; 261 console.log(target); 262 } 263 264 $('html,body').animate({scrollTop: target}, 2000, 'easeInOutExpo'); 265 } 266 } 267 } 268 return false; 269 }); 270 }, 271 272 // Widget Spacer 273 widgetSpacer: function() { 274 $(window).on('load resize', function() { 275 var mode = 'desktop'; 276 277 if ( matchMedia( 'only screen and (max-width: 991px)' ).matches ) 278 mode = 'mobile'; 279 280 $('.spacer').each(function(){ 281 if ( mode === 'mobile' ) { 282 $(this).attr('style', 'height:' + $(this).data('mobi') + 'px') 283 } else { 284 $(this).attr('style', 'height:' + $(this).data('desktop') + 'px') 285 } 286 }) 287 }); 288 }, 289 290 }; // end themesFlat 291 292 // Start things up
293 themesFlat.init(); 294 295})(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.