1/* ----------------------------------------------------------------------------- 2 3 TABLE OF CONTENTS 4 5 1.) General 6 2.) Components 7 3.) Header 8 4.) Widgets 9 5.) Sidebar 10 6.) Other 11 12----------------------------------------------------------------------------- */ 13 14(function($){ "use strict"; 15$(document).ready(function(){ 16 17/* ----------------------------------------------------------------------------- 18 19 1.) GENERAL 20 21----------------------------------------------------------------------------- */ 22 23 /* ------------------------------------------------------------------------- 24 CHECK FOR TOUCH DISPLAY 25 ------------------------------------------------------------------------- */ 26 27 $( 'body' ).one( 'touchstart', function(){ 28 $(this).addClass( 'm-touch' ); 29 }); 30 31 /* ------------------------------------------------------------------------- 32 INIT PAGE 33 ------------------------------------------------------------------------- */ 34 35 if ( ! $.fn.lsvrInitPage ) { 36 $.fn.lsvrInitPage = function( element ){ 37 38 var $element = $( element ); 39 40 // FLUID MEDIA 41 if ( $.fn.lsvrFluidEmbedMedia ){ 42 $element.lsvrFluidEmbedMedia(); 43 } 44 45 // LIGHTBOXES 46 if ( $.fn.lsvrInitLightboxes ) { 47 $element.lsvrInitLightboxes(); 48 } 49 50 // LOAD HIRES IMAGES FOR HiDPI SCREENS 51 if ( $.fn.lsvrLoadHiresImages ) { 52 $element.lsvrLoadHiresImages(); 53 } 54 55 // AJAX FORMS 56 if ( $.fn.lsvrAjaxForm ) { 57 $element.find( 'form.m-ajax-form' ).each(function(){ 58 $(this).lsvrAjaxForm(); 59 }); 60 } 61 62 }; 63 } 64 $.fn.lsvrInitPage( 'body' ); 65 66 /* ------------------------------------------------------------------------- 67 MEDIA QUERY BREAKPOINT 68 ------------------------------------------------------------------------- */ 69 70 var mediaQueryBreakpoint; 71 if ( $.fn.lsvrGetMediaQueryBreakpoint ) { 72 mediaQueryBreakpoint = $.fn.lsvrGetMediaQueryBreakpoint(); 73 $( document ).on( 'screenTransition', function(){ 74 mediaQueryBreakpoint = $.fn.lsvrGetMediaQueryBreakpoint(); 75 }); 76 } 77 else { 78 mediaQueryBreakpoint = $(window).width(); 79 } 80 81 82/* ----------------------------------------------------------------------------- 83 84 2.) COMPONENTS 85 86----------------------------------------------------------------------------- */ 87 88 if ( ! $.fn.lsvrInitComponents ) { 89 $.fn.lsvrInitComponents = function( element ){ 90 91 var $element = $( element ); 92 93 /* ------------------------------------------------------------------------- 94 ACCORDION 95 ------------------------------------------------------------------------- */ 96 97 if ( $.fn.lsvrAccordion ) { 98 $element.find( '.c-accordion' ).each(function(){ 99 $(this).lsvrAccordion(); 100 }); 101 } 102 103 /* ------------------------------------------------------------------------- 104 ALERT MESSAGE 105 ------------------------------------------------------------------------- */ 106 107 if ( $.fn.lsvrAlertMessage ) { 108 $element.find( '.c-alert-message' ).each(function(){ 109 $(this).lsvrAlertMessage(); 110 }); 111 } 112 113 /* ------------------------------------------------------------------------- 114 GALLERY 115 ------------------------------------------------------------------------- */ 116 117 if ( $.fn.masonry && $.fn.lsvrImagesLoaded ) { 118 $( '.c-gallery .gallery-images.m-layout-masonry' ).each(function(){ 119 var $this = $(this); 120 $this.lsvrImagesLoaded(function(){ 121 $this.masonry(); 122 $this.removeClass( 'm-loading' ); 123 }); 124 }); 125 } 126 else { 127 $( '.c-gallery .gallery-images.m-layout-masonry.m-loading' ).each(function(){ 128 $(this).removeClass( 'm-loading' ); 129 }); 130 } 131 132 /* ------------------------------------------------------------------------- 133 GOOGLE MAP 134 ------------------------------------------------------------------------- */ 135 136 if ( $.fn.lsvrLoadGoogleMaps && $element.find( '.gmap-canvas' ).length > 0 ) { 137 $.fn.lsvrLoadGoogleMaps(); 138 } 139 140 /* ------------------------------------------------------------------------- 141 SLIDER 142 ------------------------------------------------------------------------- */ 143 144 if ( $.fn.lsvrSlider ) { 145 $element.find( '.c-slider' ).each(function(){ 146 $(this).lsvrSlider(); 147 }); 148 } 149 150 /* ------------------------------------------------------------------------- 151 TABS 152 ------------------------------------------------------------------------- */ 153 154 if ( $.fn.lsvrTabs ) { 155 $element.find( '.c-tabs' ).each(function(){ 156 $(this).lsvrTabs();
157 }); 158 } 159 160 }; 161 } 162 $.fn.lsvrInitComponents( 'body' ); 163 164 165/* ----------------------------------------------------------------------------- 166 167 3.) HEADER 168 169----------------------------------------------------------------------------- */ 170 171 /* ------------------------------------------------------------------------- 172 GMAP SWITCHER 173 ------------------------------------------------------------------------- */ 174 175 $( '.header-gmap-switcher' ).each(function(){ 176 177 var $this = $(this); 178 $this.click(function(){ 179 180 // OPEN MAP 181 if ( ! $this.hasClass( 'm-active' ) ) { 182 183 $( '.header-gmap-switcher' ).addClass( 'm-active' ); 184 $( 'body' ).addClass( 'm-header-map-active' ); 185 $.event.trigger({ 186 type: 'headerMapOpened', 187 message: 'Header map opened.', 188 time: new Date() 189 }); 190 191 // HIDE LOGO ON MOBILE 192 if ( mediaQueryBreakpoint <= 991 ) { 193 $( '.header-branding' ).slideUp(300); 194 } 195 196 } 197 198 // CLOSE MAP 199 else { 200 201 $( '.header-gmap-switcher' ).removeClass( 'm-active' ); 202 $( 'body' ).removeClass( 'm-header-map-active' ); 203 $.event.trigger({ 204 type: 'headerMapClosed', 205 message: 'Header map closed.', 206 time: new Date() 207 }); 208 209 // SHOW LOGO ON MOBILE 210 if ( mediaQueryBreakpoint <= 991 ) { 211 $( '.header-branding' ).slideDown(300); 212 } 213 214 } 215 216 }); 217 218 // RESET ON SCREEN TRANSITION 219 $( document ).on( 'screenTransition', function(){ 220 $( '.header-gmap-switcher' ).removeClass( 'm-active' ); 221 $( 'body' ).removeClass( 'm-header-map-active' ); 222 $( '.header-branding' ).removeAttr( 'style' ); 223 }); 224 225 }); 226 227 /* ------------------------------------------------------------------------- 228 IMAGE SLIDESHOW 229 ------------------------------------------------------------------------- */ 230 231 $( '.header-image' ).each(function(){ 232 if ( mediaQueryBreakpoint > 991 && $.timer && $(this).data( 'autoplay' ) && $(this).find( '.image-layer' ).length > 1 ) { 233 234 var $this = $(this), 235 layers = $this.find( '.image-layer' ), 236 interval = parseInt( $this.data( 'autoplay' ) ), 237 timer; 238 239 layers.filter( ':eq(0)' ).addClass( 'm-active' ); 240 layers.filter( ':eq(1)' ).addClass( 'm-next' ); 241 242 interval = interval < 1 ? 0 : interval * 1000; 243 244 if ( interval > 0 ) { 245 246 // START SLIDESHOW 247 timer = $.timer( interval, function(){ 248 layers.filter( '.m-active' ).fadeOut( 900, function(){ 249 $(this).removeClass( 'm-active' ).css( 'display', '' ); 250 layers.filter( '.m-next' ).addClass( 'm-active' ).removeClass( 'm-next' ); 251 if ( layers.filter( '.m-active' ).is( ':last-child' ) ) { 252 layers.filter( ':eq(0)' ).addClass( 'm-next' ); 253 } 254 else { 255 layers.filter( '.m-active' ).next().addClass( 'm-next' ); 256 } 257 }); 258 }); 259 260 // PAUSE WHEN MAP IS OPENED 261 $( document ).on( 'headerMapOpened', function(){ 262 timer.pause(); 263 }); 264 265 // RESUME WHEN MAP IS CLOSED 266 $( document ).on( 'headerMapClosed', function(){ 267 timer.resume(); 268 }); 269 270 } 271 272 } 273 }); 274 275 /* ------------------------------------------------------------------------- 276 HEADER TOGGLE 277 ------------------------------------------------------------------------- */ 278 279 $( '.header-toggle' ).each(function(){ 280 281 var $this = $(this); 282 $this.click( function(){ 283 284 // HIDE 285 if ( $( '.header-tools' ).is( ':visible') ) { 286 $this.removeClass( 'm-active' ); 287 $( '.header-menu, .header-tools' ).slideUp(300); 288 } 289 // SHOW 290 else { 291 $this.addClass( 'm-active' ); 292 $( '.header-menu, .header-tools' ).slideDown(300); 293 } 294 295 }); 296 297 // RESET ON SCREEN TRANSITION 298 $( document ).on( 'screenTransition', function(){ 299 $this.removeClass( 'm-active' ); 300 $( '.header-menu, .header-tools' ).removeAttr( 'style' ); 301 }); 302 303 }); 304 305 /* ------------------------------------------------------------------------- 306 HEADER MENU 307 ------------------------------------------------------------------------- */ 308 309 $( '.header-menu ul > li:last-child' ).prev().addClass( 'm-penultimate' ); 310 $( '.header-menu ul > li:last-child' ).addClass( 'm-last' ); 311 312 if ( ! $.fn.lsvrHeaderMenuSubmenu ) { 313 $.fn.lsvrHeaderMenuSubmenu = function(){ 314 315 var $this = $(this), 316 $parent = $this.parent(); 317 318 $parent.addClass( 'm-has-submenu' ); 319 320 // HOVER 321 $parent.hover(function(){ 322 if ( mediaQueryBreakpoint > 991 && ! $( 'body' ).hasClass( 'm-touch' ) ) { 323 $parent.addClass( 'm-hover' ); 324 $this.show().addClass( 'animated fadeInDown' ); 325 } 326 }, function(){ 327 if ( mediaQueryBreakpoint > 991 && ! $( 'body' ).hasClass( 'm-touch' ) ) { 328 $parent.removeClass( 'm-hover' ); 329 $this.hide().removeClass( 'animated fadeInDown' ); 330 } 331 }); 332 333 // CLICK ON TOUCH DISPLAY 334 $parent.find( '> a' ).click(function(){ 335 if ( mediaQueryBreakpoint > 991 && ! $parent.hasClass( 'm-hover' ) ) { 336 337 if ( $(this).parents( 'ul' ).length < 2 ) { 338 $( '.header-menu li.m-hover' ).each(function(){ 339 $(this).removeClass( 'm-hover' ); 340 $(this).find( '> ul' ).hide(); 341 });
342 } 343 344 $parent.addClass( 'm-hover' ); 345 $this.show().addClass( 'animated fadeInDown' ); 346 347 $( 'html' ).on( 'touchstart', function(e) { 348 $parent.removeClass( 'm-hover' ); 349 $this.hide().removeClass( 'animated fadeInDown' ); 350 }); 351 352 $parent.on( 'touchstart' ,function(e) { 353 e.stopPropagation(); 354 }); 355 356 return false; 357 358 } 359 }); 360 361 // CREATE TOGGLES 362 if ( $parent.find( '> .toggle' ).length < 1 ) { 363 $parent.append( '<button class="submenu-toggle" type="button"><i class="fa"></i></button>' ); 364 } 365 var $toggle = $parent.find( '> .submenu-toggle' ); 366 367 // TOGGLE 368 $toggle.click( function(){ 369 370 // close 371 if ( $(this).hasClass( 'm-active' ) ) { 372 $toggle.removeClass( 'm-active' ); 373 $this.slideUp( 300 ); 374 } 375 376 // open 377 else { 378 379 // deactivate others 380 if ( $(this).parents( 'ul' ).length < 2 ) { 381 $( '.header-menu > ul > li > .submenu-toggle.m-active' ).each(function(){ 382 $(this).removeClass( 'm-active' ); 383 $(this).parent().find( '> ul' ).slideUp( 300 ); 384 }); 385 } 386 387 // activate this 388 $toggle.addClass( 'm-active' ); 389 $this.slideDown( 300 ); 390 391 } 392 393 }); 394 395 // HIDE ON SCREEN TRANSITION 396 $( document ).on( 'screenTransition', function(){ 397 $toggle.removeClass( 'm-active' ); 398 $this.removeAttr( 'style' ); 399 }); 400 401 }; 402 403 $( '.header-menu ul > li > ul' ).each(function(){ 404 if ( ! $(this).is( ':visible' ) ) { 405 $(this).lsvrHeaderMenuSubmenu(); 406 } 407 }); 408 409 } 410 411 412/* ----------------------------------------------------------------------------- 413 414 4.) WIDGETS 415 416----------------------------------------------------------------------------- */ 417 418 /* ------------------------------------------------------------------------- 419 MAILCHIMP SUBSCRIBE WIDGET 420 ------------------------------------------------------------------------- */ 421 422 if ( $.fn.lsvrMailchimpSubscribeForm ) { 423 $( '.mailchimp-subscribe-widget' ).each(function(){ 424 $(this).lsvrMailchimpSubscribeForm(); 425 }); 426 } 427 428 429/* ----------------------------------------------------------------------------- 430 431 5.) SIDEBAR 432 433----------------------------------------------------------------------------- */ 434 435 /* ------------------------------------------------------------------------- 436 SIDE MENU 437 ------------------------------------------------------------------------- */ 438 439 // SUB MENU 440 if ( ! $.fn.lsvrSideMenuSubmenu ) { 441 $.fn.lsvrSideMenuSubmenu = function(){ 442 443 var $this = $(this), 444 $parent = $this.parent(); 445 446 $parent.addClass( 'm-has-submenu' ); 447 448 // HOVER 449 $parent.hover(function(){ 450 if ( mediaQueryBreakpoint > 991 && ! $( 'body' ).hasClass( 'm-touch' ) ) { 451 $parent.addClass( 'm-hover' ); 452 $this.show().addClass( 'animated fadeInDown' ); 453 } 454 }, function(){ 455 if ( mediaQueryBreakpoint > 991 && ! $( 'body' ).hasClass( 'm-touch' ) ) { 456 $parent.removeClass( 'm-hover' ); 457 $this.hide().removeClass( 'animated fadeInDown' ); 458 } 459 }); 460 461 // CLICK ON TOUCH DISPLAY 462 $parent.find( '> a' ).click(function(){ 463 if ( mediaQueryBreakpoint > 991 && ! $parent.hasClass( 'm-hover' ) ) { 464 465 if ( $(this).parents( 'ul' ).length < 2 ) { 466 $( '.side-menu li.m-hover' ).each(function(){ 467 $(this).removeClass( 'm-hover' ); 468 $(this).find( '> ul' ).hide(); 469 }); 470 } 471 472 $parent.addClass( 'm-hover' ); 473 $this.show().addClass( 'animated fadeInDown' ); 474 475 $( 'html' ).on( 'touchstart', function(e) { 476 $parent.removeClass( 'm-hover' ); 477 $this.hide().removeClass( 'animated fadeInDown' ); 478 }); 479 480 $parent.on( 'touchstart' ,function(e) { 481 e.stopPropagation(); 482 }); 483 484 return false; 485 486 } 487 }); 488 489 }; 490 491 // SHOWING SUBMENUS 492 if ( $( '.side-menu' ).first().hasClass( 'm-show-submenu' ) ) { 493 $( '.side-menu ul > li' ).not( '.m-active' ).find( ' > ul' ).each(function(){ 494 $(this).lsvrSideMenuSubmenu(); 495 }); 496 } 497 498 // NOT SHOWING SUBMENUS 499 else { 500 $( '.side-menu ul > li > ul' ).each(function(){ 501 $(this).lsvrSideMenuSubmenu(); 502 }); 503 } 504 505 } 506 507 508/* ----------------------------------------------------------------------------- 509 510 6.) OTHER 511 512----------------------------------------------------------------------------- */ 513 514 /* ------------------------------------------------------------------------- 515 SCROLL ANIMATION 516 ------------------------------------------------------------------------- */ 517 518 $( 'a[href^="#"]' ).each(function(){ 519 520 var $this = $(this), 521 element = $this.attr( 'href' ); 522 523 if ( $( element ).length > 0 ) { 524 $this.click(function(e){
525 $( 'html, body' ).animate({ 526 'scrollTop' : $( element ).offset().top - 95 527 }, 500); 528 return false; 529 }); 530 } 531 532 }); 533 534 /* ------------------------------------------------------------------------- 535 STYLE SWITCHER 536 ------------------------------------------------------------------------- */ 537 538 var enableStyleSwitcher = false; 539 540 if ( enableStyleSwitcher ) { 541 542 // CREATE STYLE SWITCHER 543 var styleSwitcherHtml = '<div id="style-switcher"><button class="style-switcher-toggle"><i class="ico fa fa-tint"></i></button>'; 544 styleSwitcherHtml += '<div class="style-switcher-content"><ul class="skin-list">'; 545 styleSwitcherHtml += '<li><button class="skin-1 m-active" data-skin="red"></button></li>'; 546 styleSwitcherHtml += '<li><button class="skin-2" data-skin="blue"></button></li>'; 547 styleSwitcherHtml += '<li><button class="skin-3" data-skin="green"></button></li>'; 548 styleSwitcherHtml += '<li><button class="skin-4" data-skin="orange"></button></li>'; 549 styleSwitcherHtml += '<li><button class="skin-5" data-skin="bluegrey"></button></li>'; 550 styleSwitcherHtml += '</ul></div></div>'; 551 $( 'body' ).append( styleSwitcherHtml ); 552 553 // INIT SWITCHER 554 $( '#style-switcher' ).each(function(){ 555 556 var switcher = $(this), 557 toggle = switcher.find( '.style-switcher-toggle' ), 558 skins = switcher.find( '.skin-list button' ), 559 switches = switcher.find( '.switch-list button' ); 560 561 // TOGGLE SWITCHER 562 toggle.click(function(){ 563 switcher.toggleClass( 'm-active' ); 564 }); 565 566 // SET SKIN 567 skins.click(function(){ 568 skins.filter( '.m-active' ).removeClass( 'm-active' ); 569 $(this).toggleClass( 'm-active' ); 570 if ( $( 'head #skin-temp' ).length < 1 ) { 571 $( 'head' ).append( '<link id="skin-temp" rel="stylesheet" type="text/css" href="library/css/skin/' + $(this).data( 'skin' ) + '.css">' ); 572 } 573 else { 574 $( '#skin-temp' ).attr( 'href', 'library/css/skin/' + $(this).data( 'skin' ) + '.css' ); 575 } 576 }); 577 578 }); 579 580 } 581 582}); 583})(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.