1/* 2 * Fineliner - Responsive Portfolio HTML Template 3 * By UXbarn 4 * Themeforest Profile: http://themeforest.net/user/UXbarn?ref=UXbarn 5 * Demo URL: http://themes.uxbarn.com/redirect.php?theme=fineliner_html 6 * Created: September 19, 2013 7 */ 8 9jQuery(document).ready(function($) { 10 11 // --------------------------------------------------------- // 12 // Configuration Options 13 // --------------------------------------------------------- // 14 var homeSliderAutoAnimated = true; 15 var homeSliderAutoAnimatedDelay = 6000; 16 var homeSliderAnimation = 'fade'; // only "fade" or "slide" 17 var homeSliderAnimationSpeed = 800; 18 var homeSliderCaptionAnimated = true; 19 20 var portfolioImageSliderAutoAnimated = false; 21 var portfolioImageSliderAutoAnimatedDelay = 5000; 22 var portfolioImageSliderAnimation = 'fade'; // only "fade" or "slide" 23 var portfolioImageSliderAnimationSpeed = 600; 24 25 var imageSliderAutoAnimated = true; 26 var imageSliderAutoAnimatedDelay = 4000; 27 var imageSliderAnimation = 'fade'; // only "fade" or "slide" 28 var imageSliderAnimationSpeed = 1500; 29 30 var testimonialSliderAutoAnimated = false; 31 var testimonialSliderAutoAnimatedDelay = 10000; 32 // ---------------------------------------------- // 33 34 35 36 // ---------------------------------------------- // 37 // Global Read-Only Variables (DO NOT CHANGE!) 38 // ---------------------------------------------- // 39 40 41 var isHomeSliderLoaded = false; 42 var isHomeSliderFirstTimeHovered = false; 43 44 45 var isPortfolioSliderLoaded = false; 46 var isPortfolioSliderFirstTimeHovered = false; 47 48 var ua = navigator.userAgent.toLowerCase(); 49 var isAndroid = ua.indexOf("android") > -1; 50 var androidversion = parseFloat(ua.slice(ua.indexOf("android")+8)); 51 52 var width = parseInt($('.content-width').css('width').replace('px', ''), 10); 53 // ---------------------------------------------- // 54 55 // ---------------------------------------------- // 56 // Core Scripts 57 // ---------------------------------------------- // 58 59 // Initialize custom functions 60 renderGoogleMaps(); 61 initMobileMenu(); 62 63 64 // Initialize Foundation framework 65 $(document).foundation(); 66 $(".no-result-text").hide(); 67 68 // Force displaying tabs element after JS has been loaded 69 $('#content-container .section-container').addClass('display-block'); 70 71 72 73 /***** Home Slider *****/ 74 if($('#home-slider-container').length > 0) { 75 76 if( ! homeSliderCaptionAnimated) { 77 $('.slider-caption h2, .slider-caption p').css('opacity', 1); 78 } 79 80 $('#home-slider-container').flexslider({ 81 animation: homeSliderAnimation, 82 directionNav: false, 83 controlNav: false, 84 pauseOnAction: true, 85 pauseOnHover: true, 86 slideshow: homeSliderAutoAnimated, 87 slideshowSpeed: homeSliderAutoAnimatedDelay, 88 animationSpeed: homeSliderAnimationSpeed, 89 selector: '.home-slider-slides > li', 90 initDelay: 2000, 91 smoothHeight: true, 92 animationLoop: true, 93 start: function(slider) { 94 95 var initFadingSpeed = 500; 96 var initDelay = 0; 97 // "slide" effect has some different transition to re-define 98 if(homeSliderAnimation == 'slide') { 99 initFadingSpeed = 1; 100 initDelay = 800; 101 } 102 103 $('#home-slider-container .home-slider-slides, #home-slider-container .flex-viewport').stop().animate({ // "fade" and "slide" effect container 104 opacity: 1 105 }, initFadingSpeed, function() { 106 107 if(homeSliderCaptionAnimated) { 108 $(slider.slides[slider.currentSlide]).find('.slider-caption h2').delay(initDelay).stop().animate({ 109 opacity: 1 110 }, 500, function() { 111 $(slider.slides[slider.currentSlide]).find('.slider-caption p').stop().animate({ 112 opacity: 1 113 }, 800); 114 115 }); 116 } 117 }); 118 119 isHomeSliderLoaded = true; 120 121 // Hide loading gif 122 $(slider).closest('#home-slider-container').css({ 123 background: 'none', 124 // reset init height fix for Safari (also working on other browsers). this will also set the inline height based on the first slide's image 125 height: $(slider).closest('#home-slider-container').find('.home-slider-slides li.flex-active-slide img').height() + 'px', 126 }).addClass('auto-height'); 127 128 /*$('#home-slider-container').css({ 129 background: 'none', 130 height: 'auto', 131 });*/ 132 }, 133 before: function(slider) { 134 if(homeSliderCaptionAnimated) { 135 $('.slider-caption h2, .slider-caption p').stop().animate({ 'opacity' : 0 }, 1); 136 } 137 }, 138 after: function(slider) { 139 140 $(slider).closest('#home-slider-container').css('height','inherit'); 141 142 if(homeSliderCaptionAnimated) { 143 144 $(slider.slides[slider.currentSlide]).find('.slider-caption h2').stop().animate({ 145 opacity: 1 146 }, 500, function() { 147 $(slider.slides[slider.currentSlide]).find('.slider-caption p').stop().animate({ 148 opacity: 1 149 }, 800); 150 151 }); 152 } 153 } 154 }); 155 $('#home-slider-container .slider-prev').on('click', function(){ 156 $(this).closest('.slider-set').flexslider('prev'); 157 return false;
158 }); 159 $('#home-slider-container .slider-next').on('click', function(){ 160 $(this).closest('.slider-set').flexslider('next'); 161 return false; 162 }); 163 164 // Set the position of home slider's border 165 //alert($('.home-slider-item:first-child').height()); 166 var $homeSliderBorder = $('.home-slider-item-border'); 167 $homeSliderBorder.css({ 168 height: '89%', 169 top: '5.5%', 170 width: '94.35897435897436%', 171 left: '2.820512820512821%' 172 }); 173 174 // Display slider controller on hovered 175 $('#home-slider-container').hover(function() { 176 if($(this).find('.home-slider-item').length > 1) { 177 if(isHomeSliderLoaded) { // works only when the slider is loaded 178 isHomeSliderFirstTimeHovered = true; // this is used to prevent the "mousemove" event below continuously firing the handler 179 $(this).find('.slider-controller').css('display', 'block').stop().animate({ 'opacity' : 1 }); 180 } 181 } 182 }, function() { 183 $(this).find('.slider-controller').stop().animate({ 'opacity' : 0 }); 184 }); 185 // If the mouse cursor is moving on the slider when it is just loaded, display the controller 186 $('#home-slider-container').mousemove(function() { 187 if($(this).find('.home-slider-item').length > 1) { 188 if( ! isHomeSliderFirstTimeHovered && isHomeSliderLoaded) { 189 $(this).find('.slider-controller').css('display', 'block').stop().animate({ 'opacity' : 1 }); 190 } 191 } 192 }); 193 194 } 195 196 197 198 199 /***** Menu *****/ 200 $('.sf-menu').superfish({ 201 animation: { 202 height: 'show' // slide-down effect without fade-in 203 }, 204 speed: 'normal', 205 speedOut: 'normal', 206 delay: 400 // 0.4 second delay on mouseout 207 }); 208 209 // Set marker for active menu 210 var menuParent = $('.main-menu .active').closest('li'); 211 menuParent.append('<span class="menu-marker"></span>'); 212 $('.menu-marker').stop().animate({ 'opacity' : 1 }); 213 214 // Menu on hovered 215 $('.main-menu > li').mouseover(function() { 216 $('.main-menu > li > a, .menu-marker').not($(this).children('a')).stop().animate({ 'opacity' : 0.2 }); 217 }).mouseout(function() { 218 $('.main-menu > li > a, .menu-marker').not($(this).children('a')).stop().animate({ 'opacity' : 1 }, 600); 219 }); 220 221 // Header Search Button 222 $('#header-search-button').click(function() { 223 if(!isSearchDisplayed) { 224 // $("#header-search-input").attr('placeholder','Inserisci la tua mail...'); 225 // Hide menu 226 $('.menu-column').stop().animate({ 227 opacity : 0 228 }, 300, function() { 229 $(this).css('display', 'none'); 230 }); 231 232 //$('#mobile-menu > ul').css('visibility', 'hidden'); 233 $('#mobile-menu > ul').stop().animate({'opacity': 0}); 234 235 // Display search input 236 $('#header-search-input-wrapper').css('display', 'block').stop().animate({ 237 opacity : 1 238 }, 300); 239 240 $('#header-search-button').addClass('cancel').find('i').removeClass().addClass('icon-chevron-right'); 241 $('#header-search-button').removeClass('cancel').find('span').html(''); 242 $('#header-closed-button').removeClass("hide").addClass('show'); 243 $('#header-search-input').focus(); 244 245 isSearchDisplayed = true; 246 } else { 247 UTILS.handle_subscribe(); 248 } 249 250 }); 251 $('#header-closed-button').click(function() { 252 if(window.location.href.indexOf('sign=Y') > -1){ 253 window.location.href = "http://www.lemeravigliedellarte.it" 254 }else { 255 $('.menu-column').css('display', '').stop().animate({ 256 opacity: 1 257 }, 300); 258 //$('#mobile-menu > ul').css('visibility', 'visible'); 259 $('#mobile-menu > ul').stop().animate({'opacity': 1}, 400); 260 261 // Hide search input 262 $('#header-search-input-wrapper').stop().animate({ 263 opacity: 0 264 }, 200, function () { 265 $(this).css('display', 'none'); 266 }); 267 268 $('#header-search-button').removeClass('cancel').find('i').removeClass().addClass('icon-envelope'); 269 $('#header-search-button').removeClass('cancel').find('span').html('Iscriviti'); 270 $('#header-closed-button').removeClass("show").addClass('hide'); 271 isSearchDisplayed = false;
272 } 273 }); 274 275 $("#subscribe_button").click(function(){ 276 if(!isSearchDisplayed){ 277 jQuery('html,body').animate({scrollTop: 0}, 'slow'); 278 $('#header-search-button').trigger("click"); 279 } 280 }); 281 /***** Portfolio *****/ 282 283 // Run Isotope for portfolio list 284 var container = $('.portfolio-wrapper'); 285 286 $(container).each(function() { 287 var container = $(this); 288 var rootContainer = $(this).closest(".portfolio-root-wrapper"); 289 var qsRegex; 290 $(container).imagesLoaded(function() { 291 292 /* alert(title); 293 alert(place); 294 alert(date);*/ 295 /* var title=$(this).find('h3.title').html(); 296 var place=$(this).find('span.place').html(); 297 var date=$(this).find('span.date').html();*/ 298 $(container).isotope({ 299 itemSelector : '.portfolio-item', 300 filter : function() { 301 302 var title=($(this).find('h3.title').html()== undefined || $(this).find('h3.title').html()== '')?'': $(this).find('h3.title').html(); 303 var place=($(this).find('span.place').html()== undefined || $(this).find('span.place').html()== '')?'': $(this).find('span.place').html(); 304 var date= ($(this).find('span.date').html()== undefined || $(this).find('span.date').html()== '')?'': $(this).find('span.date').html(); 305 306 var is_present= (title.toLowerCase().match( qsRegex )|| date.toLowerCase().match( qsRegex) || place.toLowerCase().match( qsRegex)); 307 return (qsRegex && qsRegex.toString().indexOf($('#search_text').attr('placeholder'))<0) ? is_present : true; 308 } 309 }); 310 311 $(rootContainer).find(".loading-text").css('display', 'none'); 312 313 // Display loaded wrapper 314 $(container).closest(".portfolio-loaded-wrapper").css({ 315 'opacity': 1, 316 'height': 'auto', 317 'visibility': 'visible' 318 }); 319 320 // Display the items one after another 321 $(container).find('.portfolio-item').each(function(index) { 322 $(this).css('visibility', 'visible').delay(110*index).animate({ 323 "opacity" : 1 324 }, 1); 325 }); 326 }); 327 328 var $quicksearch = $('#search_text').keyup( debounce( function() { 329 330 qsRegex = new RegExp($quicksearch.val(), 'gi'); 331 $(container).isotope(); 332 if ($(container).data('isotope').$filteredAtoms.length == 0) { 333 $('.no-result-text').fadeIn('slow'); 334 } else { 335 $('.no-result-text').fadeOut('fast'); 336 } 337 }, 200 ) ); 338 339 340 /*RIFATTO DA RUBEN*/ 341 /*var filters = $(container).closest(".portfolio-loaded-wrapper").find('.portfolio-filters a'); 342 $(filters).click(function(){ 343 var selector = $(this).attr('data-filter'); 344 $(container).isotope({filter : function() { 345 return qsRegex ? $(selector).text().match( qsRegex ) : true; 346 } }); 347 348 $(filters).removeClass('active'); 349 $(this).addClass('active'); 350 351 return false; 352 });*/ 353 354 $(window).smartresize(function(){ 355 $(container).isotope(); 356 }); 357 358 }); 359 360 function debounce( fn, threshold ) { 361 var timeout; 362 return function debounced() { 363 if ( timeout ) { 364 clearTimeout( timeout ); 365 } 366 function delayed() { 367 fn(); 368 timeout = null; 369 } 370 timeout = setTimeout( delayed, threshold || 100 ); 371 } 372 } 373 374 $('.portfolio-item-hover-info').each(function() { 375 var infoHeight = $(this).height(); 376 var parentHeight = $(this).parent('.portfolio-item').height(); 377 $(this).css({ 378 height : infoHeight, 379 top : '50%', 380 marginTop : ((infoHeight/2) * -1) + 'px', // add negative margin to centering the element 381 }); 382 }); 383 384 // Portfolio slider on single page 385 if($('#single-portfolio-images-container').length > 0) { 386 $('#single-portfolio-images-container').flexslider({ 387 animation: portfolioImageSliderAnimation, 388 directionNav: false, 389 contolNav: false, 390 pauseOnAction: false, 391 pauseOnHover: true, 392 slideshow: portfolioImageSliderAutoAnimated, 393 slideshowSpeed: portfolioImageSliderAutoAnimatedDelay, 394 animationSpeed: portfolioImageSliderAnimationSpeed, 395 selector: '.single-portfolio-slides > li', 396 initDelay: 2000,
397 smoothHeight: true, 398 start: function(slider) { 399 400 var initFadingSpeed = 800; 401 var initDelay = 0; 402 // "slide" effect has some different transition to re-define 403 if(portfolioImageSliderAnimation == 'slide') { 404 initFadingSpeed = 1; 405 initDelay = 800; 406 } 407 408 $('#single-portfolio-images-container .single-portfolio-slides, #single-portfolio-images-container .flex-viewport') 409 .css('visibility', 'visible').stop().animate({ 410 opacity: 1, 411 }, initFadingSpeed); 412 413 isPortfolioSliderLoaded = true; 414 415 // Hide loading gif 416 $('#single-portfolio-images-container').css({ 417 background: 'none', 418 // reset init height fix for Safari (also working on other browsers). this will also set the inline height based on the first slide's image 419 height: $('#single-portfolio-images-container .single-portfolio-slides li.flex-active-slide img').height() + 16 + 'px', 420 }).addClass('auto-height'); 421 422 423 }, 424 before: function(slider) { 425 }, 426 after: function(slider) { 427 // set a new height based on the next slide 428 $('#single-portfolio-images-container, #single-portfolio-images-container.portrait-view').css('height','inherit'); 429 } 430 }); 431 $('#single-portfolio-images-container .slider-prev').on('click', function(){ 432 $(this).closest('.slider-set').flexslider('prev'); 433 return false; 434 }); 435 $('#single-portfolio-images-container .slider-next').on('click', function(){ 436 $(this).closest('.slider-set').flexslider('next'); 437 return false; 438 }); 439 440 // Display slider controller on hovered 441 $('#single-portfolio-images-container').hover(function() { 442 if($(this).find('.single-portfolio-image').length > 1) { 443 if(isPortfolioSliderLoaded) { // works only when the slider is loaded 444 isPortfolioSliderFirstTimeHovered = true; // this is used to prevent the "mousemove" event below continuously firing the handler 445 $(this).find('.slider-controller').css('display', 'block').stop().animate({ 'opacity' : 1 }); 446 } 447 } 448 }, function() { 449 $(this).find('.slider-controller').stop().animate({ 'opacity' : 0 }); 450 }); 451 // If the mouse cursor is moving on the slider when it is just loaded, display the controller 452 $('#single-portfolio-images-container').mousemove(function() { 453 if($(this).find('.single-portfolio-image').length > 1) { 454 if( ! isPortfolioSliderFirstTimeHovered && isPortfolioSliderLoaded) { 455 $(this).find('.slider-controller').css('display', 'block').stop().animate({ 'opacity' : 1 }); 456 } 457 } 458 }); 459 460 } 461 462 463 464 465 466 /***** Image Slider *****/ 467 $('.image-slider-wrapper').flexslider({ 468 animation: imageSliderAnimation, 469 directionNav: false, 470 contolNav: false, 471 pauseOnAction: true, 472 pauseOnHover: true, 473 slideshow: imageSliderAutoAnimated, 474 slideshowSpeed: imageSliderAutoAnimatedDelay, 475 animationSpeed: imageSliderAnimationSpeed, 476 selector: '.image-slider > li', 477 initDelay: 2000, 478 smoothHeight: true, 479 start: function(slider) { 480 481 var initFadingSpeed = 800; 482 var initDelay = 0; 483 // "slide" effect has some different transition to re-define 484 if(imageSliderAnimation == 'slide') { 485 initFadingSpeed = 1; 486 initDelay = 800; 487 } 488 489 $(slider).find('.image-slider, .flex-viewport') 490 .css('visibility', 'visible').stop().animate({ 491 opacity: 1 492 }, initFadingSpeed); 493 494 495 // Hide loading gif 496 $(slider).closest('.image-slider-wrapper').css({ 497 background: 'none', 498 // reset init height fix for Safari (also working on other browsers). this will also set the inline height based on the first slide's image 499 height: $(slider).closest('.image-slider-wrapper').find('.image-slider li.flex-active-slide img').height() + 16 + 'px', 500 }).addClass('auto-height'); 501 502 $(slider).closest('.image-slider-root-container').attr('data-loaded', 'true'); 503 504 }, 505 before: function(slider) { 506 }, 507 after: function(slider) { 508 // set a new height based on the next slide 509 $(slider).closest('.image-slider-wrapper').css('height','inherit'); 510 }, 511 }); 512 $('.image-slider-root-container .slider-prev').on('click', function(){ 513 $(this).closest('.image-slider-root-container').find('.slider-set').flexslider('prev'); 514 return false;
515 }); 516 $('.image-slider-root-container .slider-next').on('click', function(){ 517 $(this).closest('.image-slider-root-container').find('.slider-set').flexslider('next'); 518 return false; 519 }); 520 521 // Display slider controller on hovered 522 $('.image-slider, .slider-controller').hover(function() { 523 var root = $(this).closest('.image-slider-root-container'); 524 if($(root).find('.image-slider-item').length > 1) { 525 if($(root).attr('data-loaded') == 'true') { // works only when the slider is loaded 526 $(root).attr('data-first-hover', 'true'); // this is used to prevent the "mousemove" event below continuously firing the handler 527 $(root).find('.slider-controller').css('display', 'block').stop().animate({ 'opacity' : 1 }); 528 } 529 } 530 }, function() { 531 var root = $(this).closest('.image-slider-root-container'); 532 $(root).find('.slider-controller').stop().animate({ 'opacity' : 0 }); 533 }); 534 // If the mouse cursor is moving on the slider when it is just loaded, display the controller 535 $('.image-slider, .slider-controller').mousemove(function() { 536 var root = $(this).closest('.image-slider-root-container'); 537 if($(root).find('.image-slider-item').length > 1) { 538 if($(root).attr('data-first-hover') != 'true' && $(root).attr('data-loaded') == 'true') { 539 $(root).find('.slider-controller').css('display', 'block').stop().animate({ 'opacity' : 1 }); 540 } 541 } 542 }); 543 544 545 546 /***** Testimonial Slider *****/ 547 if($('.testimonial-list').length > 0) { 548 549 var testimonialAnimation = 'crossfade'; 550 var testimonialAnimationDuration = 500; 551 if($('html').hasClass('touch')) { 552 testimonialAnimation = 'fade'; 553 testimonialAnimationDuration = 300; 554 } 555 556 var testimonialList = $('.testimonial-list'); 557 testimonialList.each(function() { 558 559 var parent = $(this).closest('.testimonial-wrapper'); 560 561 $(this).carouFredSel({ 562 responsive: true, 563 swipe: true, 564 onCreate: function(data) { 565 // Display the element 566 $(parent).css({ 567 overflow : 'inherit', 568 height : 'auto', 569 }).stop().animate({ 'opacity' : 1 }); 570 571 // Apply custom z-index to make the first item's image on top 572 var zIndex = 50; 573 $(this).find('.testimonial-item .testimonial-thumbnail').each(function() { 574 $(this).css('z-index', zIndex); 575 zIndex -= 1; 576 }); 577 578 }, 579 pagination: { 580 container: $(parent).find('.testimonial-bullets'), 581 anchorBuilder: function(nr, item) { 582 return '<a href="#'+nr+'"></a>'; 583 } 584 }, 585 scroll: { 586 fx: testimonialAnimation, 587 duration: testimonialAnimationDuration, 588 onBefore: function(data) { 589 // Reset custom z-index 590 $(this).find('.testimonial-item .testimonial-thumbnail').each(function() { 591 592 if($('html').hasClass('touch')) { 593 $(this).stop().animate({ 'opacity': 0 }); 594 } else { 595 $(this).css({ 596 zIndex: '', 597 display: 'none', 598 }); 599 } 600 601 }); 602 603 // Apply a new custom z-index to the next item's image that will be displayed 604 var nextItem = data.items.visible; 605 606 if($('html').hasClass('touch')) { 607 $(nextItem).find('.testimonial-thumbnail').stop().animate({ 'opacity': 1 }); 608 } else { 609 $(nextItem).find('.testimonial-thumbnail').css({ 610 zIndex: 50, 611 display: 'block', 612 }); 613 } 614 615 //console.debug($(data.items.visible).find('p').html()); 616 }, 617 onAfter: function(data) { 618 619 } 620 }, 621 auto: { 622 play: testimonialSliderAutoAnimated, 623 pauseOnHover: 'resume', 624 timeoutDuration: testimonialSliderAutoAnimatedDelay, 625 } 626 }, 627 { 628 transition: !(isAndroid), // if running on Android, set it to "fal
628se" for this CSS3 transition, otherwise "true" 629 }); 630 631 }); 632 } 633 634 635 // Validation Engine 636 if ($('form.validate').length > 0) { 637 $('form.validate').validationEngine('attach', { 638 autoHidePrompt : 'false', 639 autoHideDelay : '7000', 640 fixed : true, 641 scroll : false, 642 binded : false, 643 promptPosition : 'centerRight' 644 }); 645 } 646 // Always initialize contact form "after" Validation Engine plugin 647 initContactForm(); 648 649 /***** Contact Form *****/ 650 function initContactForm() { 651 652 // Submitting contact form 653 if ($('form#contact-form').length > 0) { 654 655 var contactForm = $('form#contact-form'); 656 contactForm.submit(function() { 657 658 $('#success').css('display', 'none'); 659 $('#error').css('display', 'none'); 660 661 if (contactForm.validationEngine('validate')) { 662 663 $submitButton = $(this).find('input[type="submit"]'); 664 $submitButton.removeClass().addClass('gray button disabled'); 665 $submitButton.attr('value', 'Submitting...'); 666 $submitButton.attr('disabled', 'disabled'); 667 668 $.ajax({ 669 type : 'POST', 670 url : 'send_mail/send_contact_mail', 671 data : contactForm.serialize(), 672 success : function(result) { 673 674 if (result == 'true') { 675 contactForm.stop().animate({ 676 opacity : '0' 677 }, 400, function() { 678 contactForm.css('display', 'none'); 679 $('#success').css('display', 'block'); 680 $('#success').stop().animate({ 681 opacity : '1' 682 }, 900); 683 }); 684 685 } else { 686 $('#error').css('display', 'block'); 687 $('#error').stop().animate({ 688 opacity : '1' 689 }, 1000); 690 691 alert('Error Message: ' + result); 692 } 693 694 }, 695 error : function(xmlHttpRequest, textStatus, errorThrown) { 696 $('#error').css('display', 'block'); 697 $('#error').stop().animate({ 698 opacity : '1' 699 }, 1000); 700 701 alert(errorThrown); 702 } 703 }); 704 return false; 705 } 706 }); 707 708 } 709 } 710 711 // ---------------------------------------------- // 712 // Elements / Misc. 713 // ---------------------------------------------- // 714 715 /***** Google Maps *****/ 716 function renderGoogleMaps() { 717 718 if(typeof google !== 'undefined' && typeof google.maps.MapTypeId !== 'undefined') { 719 720 var elements = $('.google-map'); 721 722 elements.each(function() { 723 724 var rawlatlng = $(this).attr('data-latlng').split(','); 725 var lat = jQuery.trim(rawlatlng[0]); 726 var lng = jQuery.trim(rawlatlng[1]); 727 var address = $(this).attr('data-address'); 728 var displayType = $(this).attr('data-display-type'); 729 var zoomLevel = parseInt($(this).attr('data-zoom-level'), 10); 730 $(this).css('height', $(this).attr('data-height')); 731 732 switch(displayType.toUpperCase()) { 733 case 'ROADMAP' : displayType = google.maps.MapTypeId.ROADMAP; break; 734 case 'SATELLITE' : displayType = google.maps.MapTypeId.SATELLITE; break; 735 case 'HYBRID' : displayType = google.maps.MapTypeId.HYBRID; break; 736 case 'TERRAIN' : displayType = google.maps.MapTypeId.TERRAIN; break; 737 default : displayType = google.maps.MapTypeId.ROADMAP; break; 738 } 739 740 var geocoder = new google.maps.Geocoder(); 741 var latlng = new google.maps.LatLng(lat, lng); 742 var myOptions = { 743 scrollwheel : false, 744 zoom : zoomLevel, 745 center : latlng, 746 mapTypeId : displayType 747 }; 748 749 var map = new google.maps.Map($(this)[0], myOptions); 750 751 geocoder.geocode({ 752 'address' : address, 753 'latLng' : latlng, 754 }, function(results, status) { 755 if (status === google.maps.GeocoderStatus.OK) { 756 var marker; 757 if(jQuery.trim(address).length > 0) { 758 marker = new google.maps.Marker({ 759 map : map, 760 position : results[0].geometry.location 761 }); 762 763 map.setCenter(results[0].geometry.location); 764 765 } else { 766 marker = new google.maps.Marker({ 767 map : map, 768 position : latlng 769 }); 770 771 marker.setPosition(latlng); map.setCenter(latlng); 772 773 } 774 775 } else { 776 window.alert("Geocode was not successful for the following reason: " + status); 777 } 778 }); 779 780 }); 781 } 782 783 } 784 785 786 787 /***** Fancybox *****/ 788 789 if(isAndroid && androidversion <= 4.0) { 790 $('.image-box').fancybox(); // Fancybox's thumbnail helper is not working on older Android, so disable it. 791 } else { 792 $('.image-box').fancybox({ 793 helpers: { 794 thumbs : { 795 width: 50, 796 height: 50 797 } 798 } 799 }); 800 } 801 802 803 /***** Accordion/Toggle *****/ 804 var icons = { 805 header: 'ui-accordion-header-icon', 806 activeHeader: 'ui-accordion-header-icon-active' 807 }; 808 var animateObj = { 809 animate: 'easeOutQuint', 810 duration: 600,
811 }; 812 813 if ($('.accordion').length > 0) { 814 815 $('.accordion').each(function() { 816 $(this).accordion({ 817 autoHeight: false, 818 heightStyle: 'content', // jQuery UI 1.10.x 819 collapsible: false, 820 //icons: icons, 821 animate: animateObj, 822 active: parseInt($(this).attr('data-active-index')), 823 create: function( event, ui ) { 824 $(this).css({ 825 height: 'auto', 826 visibility: 'visible', 827 }).animate({ 'opacity' : 1 }); 828 }, 829 }); 830 }); 831 832 } 833 834 if ($('.toggle').length > 0) { 835 836 $('.toggle').accordion({ 837 autoHeight: false, 838 heightStyle: 'content', // jQuery UI 1.10.x 839 //icons: icons, 840 collapsible: true, 841 animate: animateObj, 842 active: false, 843 create: function( event, ui ) { 844 $(this).css({ 845 height: 'auto', 846 visibility: 'visible', 847 }).animate({ 'opacity' : 1 }); 848 } 849 }); 850 851 if($('.toggle').hasClass('active')) { 852 $('.toggle.active').accordion({ 853 heightStyle: 'content', 854 autoHeight: false, 855 //icons: icons, 856 collapsible: true, 857 animate: animateObj, 858 active: 0, 859 create: function( event, ui ) { 860 $(this).css({ 861 height: 'auto', 862 visibility: 'visible', 863 }).animate({ 'opacity' : 1 }); 864 }, 865 }); 866 867 $('body').scrollTop(0); 868 } 869 870 } 871 872 /***** Tabs *****/ 873 if($('html').hasClass('lt-ie9')) { 874 $('.auto').addClass('tabs').removeClass('auto').attr('data-section', 'tabs'); 875 } 876 var tabs = $('.vertical-tabs p.title > a, .tabs p.title > a, .auto p.title > a'); 877 tabs.click(function() { 878 879 // Force hiding any content that contains Google Map 880 $(this).parents('.section-container').find('.content').each(function() { 881 if($(this).find('.google-map').length > 0) { 882 $(this).css('display', 'none'); 883 } 884 }); 885 886 var map = $(this).parents('section').find('.content').find('.google-map'); 887 if(map.length > 0) { 888 // Re-render Google Map for tab content and display the content 889 $(this).parents('section').find('.content').css({'display': 'block', 'width': '100%'}); 890 renderGoogleMaps(); 891 } 892 }); 893 894 895 /***** Progress Bar *****/ 896 if(isAndroid) { 897 if (androidversion >= 4.0) { 898 animateProgressBar(); 899 } else { 900 901 $('.progress-bar .bar-meter').each(function() { 902 $(this).css('width', $(this).attr('data-meter') + '%'); 903 }); 904 905 } 906 } else { 907 animateProgressBar(); 908 } 909 function animateProgressBar() { 910 $('.progress-bar').waypoint(function() { 911 912 var meter = $(this).find('.bar-meter'); 913 $(meter).css('width', 0); 914 $(meter).delay(250).animate({ 915 width: $(meter).attr('data-meter') + '%', 916 }, 1400, 'easeOutQuint'); 917 918 }, { offset: '85%', triggerOnce: true }); 919 } 920 921 922 // "placeholder" attribute fix for all browsers 923 $('[placeholder]').focus(function() { 924 var input = $(this); 925 if (input.val() == input.attr('placeholder')) { 926 input.val(''); 927 input.removeClass('placeholder'); 928 } 929 }).blur(function() { 930 var input = $(this); 931 if (input.val() == '' || input.val() == input.attr('placeholder')) { 932 input.addClass('placeholder'); 933 input.val(input.attr('placeholder')); 934 } 935 }).blur(); 936 $('[placeholder]').parents('form').submit(function() { 937 $(this).find('[placeholder]').each(function() { 938 var input = $(this); 939 if (input.val() == input.attr('placeholder')) { 940 input.val(''); 941 } 942 }); 943 }); 944 945 946 /***** Mobile Menu *****/ 947 function initMobileMenu() { 948 //var defaultMenuList = $('#root-menu'); 949 var mobileMenuList = $('<ul />').appendTo($('#mobile-menu .top-bar-section')); 950 951 var clonedList = $('#menu-wrapper .main-menu > li').clone(); 952 clonedList = getGeneratedSubmenu(clonedList); 953 clonedList.appendTo(mobileMenuList); 954 955 } 956 957 // Recursive function for generating submenus 958 function getGeneratedSubmenu(list) { 959 //console.debug($('#menu-wrapper .main-menu > li')); 960 $(list).each(function() { 961 //$(this).append('<li class="divider"></li>'); 962 963 if($(this).find('ul').length > 0) { 964 var submenu = $(this).find('ul'); 965 966 $(this).addClass('has-dropdown'); 967 submenu.addClass('dropdown'); 968 969 getGeneratedSubmenu(submenu.find('li')); 970 } 971 }); 972 973 return list; 974 } 975 976});
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.