1"use strict"; 2/** 3 * General Custom JS Functions 4 * 5 * @author Themovation <[email protected]> 6 * @copyright 2014 Themovation INC. 7 * @license http://themeforest.net/licenses/regular 8 * @version 1.5 9 */ 10 11/* 12 # Helper Functions 13 # On Window Resize 14 # On Window Load 15 */ 16 17//====================================================================== 18// Helper Functions 19//====================================================================== 20 21function UpdateQueryString(key, value, url) { 22 if (!url) url = window.location.href; 23 var re = new RegExp("([?&])" + key + "=.*?(&|#|$)(.*)", "gi"), 24 hash; 25 26 if (re.test(url)) { 27 if (typeof value !== 'undefined' && value !== null) 28 return url.replace(re, '$1' + key + "=" + value + '$2$3'); 29 else { 30 hash = url.split('#'); 31 url = hash[0].replace(re, '$1$3').replace(/(&|\?)$/, ''); 32 if (typeof hash[1] !== 'undefined' && hash[1] !== null) 33 url += '#' + hash[1]; 34 return url; 35 } 36 } 37 else { 38 if (typeof value !== 'undefined' && value !== null) { 39 var separator = url.indexOf('?') !== -1 ? '&' : '?'; 40 hash = url.split('#'); 41 url = hash[0] + separator + key + '=' + value; 42 if (typeof hash[1] !== 'undefined' && hash[1] !== null) 43 url += '#' + hash[1]; 44 return url; 45 } 46 else 47 return url; 48 } 49} 50 51//----------------------------------------------------- 52// NAVIGATION - Adds support for Mobile Navigation 53// Detect screen size, add / subtract data-toggle 54// for mobile dropdown menu. 55//----------------------------------------------------- 56function themo_support_mobile_navigation(){ 57 58 // If mobile navigation is active, add data attributes for mobile touch / toggle 59 if (Modernizr.mq('(max-width: 767px)')) { 60 //console.log('Adding data-toggle, data-target'); 61 jQuery("li.dropdown .dropdown-toggle").attr("data-toggle", "dropdown"); 62 jQuery("li.dropdown .dropdown-toggle").attr("data-target", "#"); 63 } 64 65 // If mobile navigation is NOT active, remove data attributes for mobile touch / toggle 66 if (Modernizr.mq('(min-width:768px)')) { 67 //console.log('Removing data-toggle, data-target'); 68 jQuery("li.dropdown .dropdown-toggle").removeAttr("data-toggle", "dropdown"); 69 jQuery("li.dropdown .dropdown-toggle").removeAttr("data-target", "#"); 70 } 71} 72 73 74//----------------------------------------------------- 75// Detect if touch device via modernizr, return true 76//----------------------------------------------------- 77function themo_is_touch_device(checkScreenSize){ 78 79 if (typeof checkScreenSize === "undefined" || checkScreenSize === null) { 80 checkScreenSize = true; 81 } 82 83 var deviceAgent = navigator.userAgent.toLowerCase(); 84 85 86 var isTouch = (deviceAgent.match(/(iphone|ipod|ipad)/) || 87 deviceAgent.match(/(android)/) || 88 deviceAgent.match(/iphone/i) || 89 deviceAgent.match(/ipad/i) || 90 deviceAgent.match(/ipod/i) || 91 deviceAgent.match(/blackberry/i)); 92 93 if(checkScreenSize){ 94 var isMobileSize = Modernizr.mq('(max-width:767px)'); 95 }else{ 96 var isMobileSize = false; 97 } 98 99 if(isTouch || isMobileSize ){ 100 return true; 101 } 102 103 return false; 104} 105 106 107//----------------------------------------------------- 108// Disable Transparent Header for Mobile 109//----------------------------------------------------- 110function themo_no_transparent_header_for_mobile(isTouch){ 111 112 if (jQuery(".navbar[data-transparent-header]").length) { 113 if(isTouch){ 114 jQuery('.navbar').attr("data-transparent-header", "false"); 115 } 116 else{ 117 jQuery('.navbar').attr("data-transparent-header", "true"); 118 } 119 } 120} 121 122 123 124 125 126//----------------------------------------------------- 127// Scroll Up 128//----------------------------------------------------- 129function themo_start_scrollup() { 130 131 jQuery.scrollUp({ 132 animationSpeed: 200, 133 animation: 'fade', 134 scrollSpeed: 500, 135 scrollImg: { active: true, type: 'background', src: '../../images/top.png' } 136 }); 137} 138 139 140 141var nice = false; 142 143/** 144 * Protect window.console method calls, e.g. console is not defined on IE 145 * unless dev tools are open, and IE doesn't define console.debug 146 */ 147(function() { 148 149 if (!window.console) { 150 window.console = {}; 151 } 152 // union of Chrome, FF, IE, and Safari console methods 153 var m = [ 154 "log", "info", "warn", "error", "debug", "trace", "dir", "group", 155 "groupCollapsed", "groupEnd", "time", "timeEnd", "profile", "profileEnd", 156 "dirxml", "assert", "count", "markTimeline", "timeStamp", "clear" 157 ]; 158 // define undefined methods as noops to prevent errors 159 for (var i = 0; i < m.length; i++) { 160 if (!window.console[m[i]]) { 161 window.console[m[i]] = function() {}; 162 } 163 } 164})(); 165 166//====================================================================== 167// Executes when HTML-Document is loaded and DOM is ready 168//====================================================================== 169jQuery(document).ready(function($) { 170 "use strict"; 171 172 173 if (jQuery(".datepick").length) 174 { 175 //console.log('TEST '+jQuery(".datepick").width()); 176 //var th_current_width = jQuery(".datepick").width(); 177 //var the_new_witdh = th_current_width + 200; 178 //jQuery(".datepick-month-row").width(the_new_witdh); 179 //.datepick-nav 180 } 181 182 183 184 // Preloader : Is really only used for the flexslider but is added to the body tag. 185 // If flex is detected, we put a timeout on it (5s( so it does not get stuck spinning. 186 // If no flex, then disable. 187 if (jQuery("#main-flex-slider")[0]){
188 // Do nothing / flex will figure it out. 189 setTimeout(function(){ 190 jQuery('body').addClass('loaded'); 191 }, 10000); 192 }else{ 193 jQuery('body').addClass('loaded'); 194 } 195 196 // add body class for touch devices. 197 if (themo_is_touch_device()) { 198 jQuery('body').addClass('th-touch'); 199 } 200 201 // Add support for mobile navigation 202 themo_support_mobile_navigation($); 203 204 // Support for sub menu navigation / also works with sticky header. 205 206 jQuery("body").on("click", "ul.dropdown-menu .dropdown-submenu > a[data-toggle='dropdown']", function(event){ 207 //console.log($(this).text()); 208 event.preventDefault(); 209 event.stopPropagation(); 210 jQuery(this).parents('ul.dropdown-menu .dropdown-submenu').toggleClass('open'); 211 }); 212 213 // Sticky Header - Set options 214 var options = { 215 // Scroll offset. Accepts Number or "String" (for class/ID) 216 offset: 125, // OR â offset: '.classToActivateAt', 217 218 classes: { 219 clone: 'headhesive--clone', 220 stick: 'headhesive--stick', 221 unstick: 'headhesive--unstick' 222 }, 223 224 // If the top nav bar menu is open, close it. 225 onStick: function () { 226 227 //jQuery( "header:not('.headhesive--stick') .navbar-toggle").not( ".collapsed" ).trigger( "click" ); 228 jQuery('.navbar-collapse').css('height', '0'); 229 jQuery('.navbar-collapse').removeClass('in'); 230 }, 231 // If the top nav bar menu is open, close it. 232 onUnstick: function () { 233 234 //jQuery( "header:not('.headhesive--stick') .navbar-toggle").not( ".collapsed" ).trigger( "click" ); 235 jQuery('.navbar-collapse').css('height', '0'); 236 jQuery('.navbar-collapse').removeClass('in'); 237 }, 238 // Throttle scroll event to fire every 250ms to improve performace 239 throttle: 250, 240 }; 241 242 243 try 244 { 245 // Initialise with options 246 var banner = new Headhesive('body.th-sticky-header .banner, body.ehf-header.th-sticky-header header#masthead', options); 247 jQuery('body.th-sticky-header').addClass('headhesive'); 248 } 249 catch (err) { 250 console.log('Sticky header deactivated. WP Dash / Appearance / Customize / Theme Options / Menu & Header'); 251 } 252 253 // Close sticky header on menu item click. 254 jQuery('.navbar-collapse').on( "click", 'a:not(.dropdown-toggle)', function() { 255 //jQuery( ".navbar-toggle").not( ".collapsed" ).trigger( "click" ); 256 jQuery('.navbar-collapse').css('height', '0'); 257 jQuery('.navbar-collapse').removeClass('in'); 258 }); 259 260 /** 261 * Check a href for an anchor. If exists, and in document, scroll to it. 262 * If href argument ommited, assumes context (this) is HTML Element, 263 * which will be the case when invoked by jQuery after an event 264 */ 265 function scroll_if_anchor(href) { 266 href = typeof(href) == "string" ? href : jQuery(this).attr("href"); 267 268 var fromTop = 0; 269 if (jQuery("header").hasClass("headhesive--clone")) { 270 fromTop = jQuery(".headhesive--clone").height() ; 271 } 272 273 // You could easily calculate this dynamically if you prefer 274 //var fromTop = 50; 275 276 // If our Href points to a valid, non-empty anchor, and is on the same page (e.g. #foo) 277 // Legacy jQuery and IE7 may have issues: http://stackoverflow.com/q/1593174 278 if(href.indexOf("#") == 0) { 279 var $target = jQuery(href); 280 281 // Older browser without pushState might flicker here, as they momentarily 282 // jump to the wrong position (IE < 10) 283 if($target.length) { 284 285 jQuery('html, body').animate({ scrollTop: $target.offset().top - fromTop }, 500, 'linear', function() { 286 //alert("Finished animating"); 287 }); 288 if(history && "pushState" in history) { 289 history.pushState({}, document.title, window.location.pathname + href); 290 return false; 291 } 292 } 293 } 294 } 295 296 // When our page loads, check to see if it contains and anchor 297 scroll_if_anchor(window.location.hash); 298 299 300 // Detect and set isTouch for touch screens 301 // var isTouch = themo_is_touch_device(); 302
303 // Set off set for waypoints 304 //if(!isTouch){ 305 //Setup waypoints plugin 306 307 var th_offset = 0; 308 if (jQuery("header").hasClass("headhesive--clone")) { 309 th_offset = jQuery(".headhesive--clone").height() ; 310 } 311 312 // Add space for Elementor Menu Anchor link 313 jQuery( window ).on( 'elementor/frontend/init', function() { 314 elementorFrontend.hooks.addFilter( 'frontend/handlers/menu_anchor/scroll_top_distance', function( scrollTop ) { 315 //console.log('ELEM HOOK - Scroll offset ' + th_offset); 316 return scrollTop - th_offset; 317 } ); 318 } ); 319 //} 320 321 322 if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) { 323 //console.log('Smooth Scroll Off (Safari).'); 324 }else{ 325 try 326 { 327 // Initialise with options 328 nice = jQuery("html").niceScroll({ 329 zindex:20000, 330 scrollspeed:60, 331 mousescrollstep:60, 332 cursorborderradius: '10px', // Scroll cursor radius 333 cursorborder: '1px solid rgba(255, 255, 255, 0.4)', 334 cursorcolor: 'rgba(0, 0, 0, 0.6)', // Scroll cursor color 335 //autohidemode: 'true', // Do not hide scrollbar when mouse out 336 cursorwidth: '10px', // Scroll cursor width 337 autohidemode: false, 338 339 }); 340 } 341 catch (err) { 342 //console.log('Smooth Scroll Off.'); 343 } 344 } 345 346}); 347 348 349//====================================================================== 350// On Window Load - executes when complete page is fully loaded, including all frames, objects and images 351//====================================================================== 352jQuery(window).on('load',function ($) { 353 "use strict"; 354 355 // Detect and set isTouch for touch screens 356 var isTouch = themo_is_touch_device(); 357 358 // Disable Transparent Header for Mobile / touch 359 themo_no_transparent_header_for_mobile(isTouch); 360 361 // Start Scroll Up 362 themo_start_scrollup(); 363 364 365 jQuery('a[data-filter="*"]').trigger( "click" ); 366 367 368 369}); 370 371//====================================================================== 372// On Window Resize 373//====================================================================== 374 jQuery(window).resize(function($){ 375 "use strict"; 376 // Detect and set isTouch for touch screens 377 var isTouch = themo_is_touch_device(); 378 379 // Add support for mobile navigation 380 themo_support_mobile_navigation(); 381 382 // Disable Transparent Header for Mobile / touch 383 themo_no_transparent_header_for_mobile(isTouch); 384}); 385 386
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.