1/* 2 Name: Photographer 3 Description: Responsive HTML5 Template 4 Version: 1.0 5 Author: pixelwars 6*/ 7 8(function($) { "use strict"; 9 10 11 /* DOCUMENT READY */ 12 $(function() { 13 14 // ------------------------------ 15 // MASONRY GALLERY 16 var gallery = $('.gallery'); 17 if(gallery.length) { 18 gallery.each(function(index, element) { 19 //wait for images 20 $(element).imagesLoaded( function() { 21 22 $(element).masonry(); 23 24 }); 25 }); 26 } 27 // ------------------------------ 28 29 30 31 // ------------------------------ 32 // KEN SLIDER 33 var ken = $('.ken-slider'); 34 if(ken.length) { 35 ken.slippry({ 36 adaptiveHeight: false, 37 captions: false, 38 pager: false, 39 controls: false, 40 autoHover: false, 41 transition: ken.data('animation'), // fade, horizontal, kenburns, false 42 kenZoom: 120, 43 speed: ken.data('speed') // time the transition takes (ms) 44 }); 45 } 46 // ------------------------------ 47 48 49 // ------------------------------ 50 // PHOTOWALL 51 photowall(); 52 // ------------------------------ 53 54 55 // ------------------------------ 56 // GALLERY COLLAGE LAYOUT 57 var resizeTimer = null; 58 $(window).bind('resize', function() { 59 // hide all the images until we resize them 60 // set the element you are scaling i.e. the first child nodes of ```.Collage``` to opacity 0 61 $('.pw-collage > a').css("opacity", 0); 62 // set a timer to re-apply the plugin 63 if (resizeTimer) { 64 clearTimeout(resizeTimer); 65 } 66 resizeTimer = setTimeout(collage(), 200); 67 }); 68 // ------------------------------ 69 70 71 // ------------------------------ 72 // FADE SLIDER 73 var fadeSlider = $('.fade-slider'); 74 if(fadeSlider.length) { 75 fadeSlider.find('.fs-slide').each(function() { 76 $(this).css('background-image', 'url(' + $(this).find('img').attr('src') + ')'); 77 }); 78 fadeSlider.imagesLoaded( { background: true }, function() { 79 80 fadeSlider.addClass('loaded'); 81 var firstSlide = fadeSlider.find('.fs-slide').first(); 82 fadeImage(firstSlide); 83 //console.log('.fadeSlider background image loaded'); 84 85 }); 86 } 87 88 // fn : FADE IMAGE 89 function fadeImage(slide) { 90 91 var animationTime = (0.85 / (slide.index()+2)) + 0.1 + 's'; 92 93 slide.css({ 94 'animation-duration': animationTime, 95 '-webkit-animation-duration': animationTime 96 }); 97 98 slide.addClass('fade-in'); 99 slide.on('animationend webkitAnimationEnd oAnimationEnd MSAnimationEnd', 100 function(e) { 101 if(slide.is(':last-child')) { 102 fadeSlider.addClass('finito'); 103 } else { 104 // recursive call : happy developer :P 105 fadeImage(slide.next()); 106 slide.removeClass('fade-in'); 107 slide.hide(); 108 } 109 }); 110 } 111 // ------------------------------ 112 113 114 // ------------------------------ 115 // OWL-CAROUSEL 116 var owl = $('.owl-carousel'); 117 if(owl.length) { 118 owl.each(function(index, element) { 119 //wait for images 120 $(element).imagesLoaded( function() { 121 122 //remove loading 123 $(element).find('.loading').remove(); 124 125 var items = $(element).data('items'); 126 $(element).owlCarousel({ 127 loop: $(element).data('loop'), 128 center : $(element).data('center'), 129 mouseDrag : $(element).data('mouse-drag'), 130 dots : $(element).data('dots'), 131 nav : $(element).data('nav'), 132 autoplay : $(element).data('autoplay'), 133 autoplaySpeed : $(element).data('autoplay-speed'), 134 autoplayTimeout : $(element).data('autoplay-timeout'), 135 autoWidth : $(element).data('auto-width'), 136 autoplayHoverPause :$(element).hasClass('fs-slider') ? false : true, 137 navText : [$(element).data('nav-text-prev'),$(element).data('nav-text-next')], 138 animateOut: $(element).hasClass('fs-slider') ? 'fadeOut' : '', 139 //autoHeight: true, 140 responsive:{ 141 0: { items: 1 }, 142 768: { items: items <= 2 ? items : 2 }, 143 1200: { items: items <= 3 ? items : 3 }, 144 1600: { items: items } 145 } 146 });
147 148 149 }); 150 }); 151 } 152 // ------------------------------ 153 154 155 // ------------------------------ 156 // MAGNIFIC POPUP 157 var mfp = $('.mfp-gallery'); 158 if(mfp.length) { 159 mfp.each(function(index, element) { 160 $(element).magnificPopup({ 161 delegate: 'a', 162 type: 'image', 163 image: { 164 markup: '<div class="mfp-figure">'+ 165 '<div class="mfp-close"></div>'+ 166 '<div class="mfp-img"></div>'+ 167 '</div>' + 168 '<div class="mfp-bottom-bar">'+ 169 '<div class="mfp-title"></div>'+ 170 '<div class="mfp-counter"></div>'+ 171 '</div>', // Popup HTML markup. `.mfp-img` div will be replaced with img tag, `.mfp-close` by close button 172 173 cursor: 'mfp-zoom-out-cur', // Class that adds zoom cursor, will be added to body. Set to null to disable zoom out cursor. 174 175 titleSrc: 'title', // Attribute of the target element that contains caption for the slide. 176 // Or the function that should return the title. For example: 177 // titleSrc: function(item) { 178 // return item.el.attr('title') + '<small>by Marsel Van Oosten</small>'; 179 // } 180 181 verticalFit: true, // Fits image in area vertically 182 183 tError: '<a href="%url%">The image</a> could not be loaded.' // Error message 184 }, 185 gallery: { 186 enabled:true, 187 tCounter: '<span class="mfp-counter">%curr% / %total%</span>' // markup of counter 188 }, 189 mainClass: 'mfp-zoom-in', 190 tLoading: '', 191 removalDelay: 300, //delay removal by X to allow out-animation 192 callbacks: { 193 imageLoadComplete: function() { 194 var self = this; 195 setTimeout(function() { 196 self.wrap.addClass('mfp-image-loaded'); 197 }, 16); 198 }, 199 close: function() { 200 this.wrap.removeClass('mfp-image-loaded'); 201 } 202 }, 203 closeBtnInside: false, 204 closeOnContentClick: true, 205 midClick: true 206 }); 207 }); 208 } 209 // ------------------------------ 210 211 212 // ------------------------------ 213 // HEADER MENU TOGGLE 214 $('.menu-toggle').on( "click", function() { 215 $('html').toggleClass('is-menu-toggled-on'); 216 }); 217 // ------------------------------ 218 219 220 // ------------------------------ 221 /* SOCIAL FEED WIDGET */ 222 // see plugin github page for documentation : https://github.com/pixel-industry/Social-Photo-Stream-jQuery-Plugin 223 var socialFeed = $('.social-feed'); 224 if(socialFeed.length) { 225 socialFeed.each(function() { 226 $(this).socialstream({ 227 socialnetwork: $(this).data("social-network"), 228 limit: $(this).data("limit"), 229 username: $(this).data("username"), 230 accessToken: $(this).data("access-token") /* for instagram or dribbble */ 231 //picasaAlbumId: $(this).data("picasa-album-id"), /* for picassa only */ 232 //apikey: $(this).data("api-key") /* for youtube only */ 233 }); 234 }); 235 } 236 // ------------------------------ 237 238 239 // ------------------------------ 240 // FluidBox : Zoomable Images 241 $('.fluidbox-gallery a').fluidbox(); 242 $('.entry-content > p a, .wp-caption a').each(function(index, element) { 243 if($(this).attr('href').match(/\.(jpeg|jpg|gif|png)$/) != null) { 244 $(this).fluidbox(); 245 } 246 }); 247 if(!($('html').hasClass('no-fluidbox'))) { 248 $('.gallery a').fluidbox(); 249 } 250 // ------------------------------ 251 252 253 // ------------------------------ 254 // remove click delay on touch devices 255 FastClick.attach(document.body); 256 // ------------------------------ 257 258 259 // ------------------------------ 260 // TABS 261 $('.tabs').each(function() { 262 if(!$(this).find('.tab-titles li a.active').length) { 263 $(this).find('.tab-titles li:first-child a').addClass('active'); 264 $(this).find('.tab-content > div:first-child').show(); 265 } else { 266 $(this).find('.tab-content > div').eq($(this).find('.tab-titles li a.active').parent().index()).show(); 267 } 268 }); 269 270 $('.tabs .tab-titles li a').on( "click", function() { 271 if($(this).hasClass('active')) { return; } 272 $(this).parent().siblings().find('a').removeClass('active'); 273 $(this).addClass('active'); 274 $(this).parents('.tabs').find('.tab-content > div').hide().eq($(this).parent().index()).show(); 275 return false; 276 }); 277 // ------------------------------ 278 279 280 // ------------------------------ 281 // TOGGLES 282 var toggleSpeed = 300; 283 $('.toggle h4.active + .toggle-content').show(); 284 285 $('.toggle h4').on("click", function() { 286 if($(this).hasClass('active')) { 287 $(this).removeClass('active');
288 $(this).next('.toggle-content').stop(true,true).slideUp(toggleSpeed); 289 } else { 290 291 $(this).addClass('active'); 292 $(this).next('.toggle-content').stop(true,true).slideDown(toggleSpeed); 293 294 //accordion 295 if($(this).parents('.toggle-group').hasClass('accordion')) { 296 $(this).parent().siblings().find('h4').removeClass('active'); 297 $(this).parent().siblings().find('.toggle-content').stop(true,true).slideUp(toggleSpeed); 298 } 299 300 } 301 return false; 302 }); 303 // ------------------------------ 304 305 306 307 // ------------------------------ 308 // Fitvids.js : fluid width video embeds 309 $("body").fitVids(); 310 // ------------------------------ 311 312 313 314 // ------------------------------ 315 // UNIFORM 316 $("input:checkbox, input:radio, input:file").uniform(); 317 var ua = navigator.userAgent.toLowerCase(); 318 var isAndroid = ua.indexOf("android") > -1; 319 if(isAndroid) { 320 $('html').addClass('android'); 321 } 322 // ------------------------------ 323 324 325 326 // ------------------------------ 327 // FORM VALIDATION 328 // comment form validation fix 329 $('#commentform').addClass('validate-form'); 330 $('#commentform').find('input,textarea').each(function(index, element) { 331 if($(this).attr('aria-required') == "true") { 332 $(this).addClass('required'); 333 } 334 if($(this).attr('name') == "email") { 335 $(this).addClass('email'); 336 } 337 }); 338 339 // validate form 340 if($('.validate-form').length) { 341 $('.validate-form').each(function() { 342 $(this).validate(); 343 }); 344 } 345 // ------------------------------ 346 347 348 349 // ------------------------------ 350 // GOOGLE MAP 351 /* 352 custom map with google api 353 check out the link below for more information about api usage 354 https://developers.google.com/maps/documentation/javascript/examples/marker-simple 355 */ 356 function initializeMap() { 357 if($('.map').length) { 358 var styles = [{"featureType":"landscape","stylers":[{"saturation":-100},{"lightness":65},{"visibility":"on"}]},{"featureType":"poi","stylers":[{"saturation":-100},{"lightness":51},{"visibility":"simplified"}]},{"featureType":"road.highway","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"road.arterial","stylers":[{"saturation":-100},{"lightness":30},{"visibility":"on"}]},{"featureType":"road.local","stylers":[{"saturation":-100},{"lightness":40},{"visibility":"on"}]},{"featureType":"transit","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"administrative.province","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"labels","stylers":[{"visibility":"on"},{"lightness":-25},{"saturation":-100}]},{"featureType":"water","elementType":"geometry","stylers":[{"hue":"#ffff00"},{"lightness":-25},{"saturation":-97}]}]; 359 var mapCanvas = $('#map-canvas'); 360 var myLatlng = new google.maps.LatLng(mapCanvas.data("latitude"),mapCanvas.data("longitude")); 361 var mapOptions = { 362 zoom: mapCanvas.data("zoom"), 363 center: myLatlng, 364 disableDefaultUI: true, 365 styles: styles 366 } 367 var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); 368 369 var marker = new google.maps.Marker({ 370 position: myLatlng, 371 map: map 372 }); 373 } 374 375 } 376 if($('.map').length) { 377 google.maps.event.addDomListener(window, 'load', initializeMap); 378 } 379 // ------------------------------ 380 381 382 383 // ------------------------------ 384 /* jQuery Ajax Mail Send Script */ 385 var contactForm = $( '#contact-form' ); 386 var $submit = contactForm.find('.submit'); 387 388 contactForm.submit(function() 389 { 390 if (contactForm.valid()) 391 { 392 $submit.addClass("active loading"); 393 var formValues = contactForm.serialize(); 394 395 $.post(contactForm.attr('action'), formValues, function(data) 396 { 397 if ( data == 'success' ) 398 { 399 setTimeout(function() { 400 $submit.removeClass("loading").addClass("success"); 401 contactForm.clearForm(); 402 },2000); 403 } 404 else 405 { 406 $submit.removeClass("loading").addClass("error"); 407 } 408 }); 409 } 410 411 return false 412 }); 413 414 $.fn.clearForm = function() { 415 Â return this.each(function() { 416 Â Â var type = this.type, tag = this.tagName.toLowerCase(); 417 Â Â if (tag == 'form') 418 Â Â Â return $(':input',this).clearForm(); 419 Â Â if (type == 'text' || type == 'password' || tag == 'textarea') 420 Â Â Â this.value = ''; 421 Â Â else if (type == 'checkbox' || type == 'radio') 422 Â Â Â this.checked = false; 423 Â Â else if (tag == 'select') 424 Â Â Â this.selectedIndex = -1; 425 Â }); 426 }; 427 // ------------------------------ 428 429 430 431 // ------------------------------ 432 // GALLERY LOAD ONE BY ONE 433 var lazy_gallery = $('.pw-collage.load-one-by-one'); 434 if(lazy_gallery.length) { 435 //lazy_gallery.find('img').addClass('no-auto-height');
436 collage(); 437 } 438 // 439 // ------------------------------ 440 441 442 443 // ------------------------------ 444 // HOME LANDING FULLSCREEN VIDEO 445 var fs_video = $('.home-wrap .fluid-width-video-wrapper'); 446 if(fs_video.length) { 447 fs_video.wrap( "<div class='fs-video'></div>" ); 448 fs_video = $('.fs-video'); 449 bgVideo(fs_video); 450 $( window ).resize(function() { 451 bgVideo(fs_video); 452 //setTimeout(bgVideo(fs_video), 1500); 453 }); 454 } 455 456 var resizeTimer = null; 457 $(window).bind('resize', function() { 458 if (resizeTimer) clearTimeout(resizeTimer); 459 resizeTimer = setTimeout(bgVideo(fs_video), 200); 460 }); 461 // ------------------------------ 462 463 464 465 466 }); 467 // DOCUMENT READY 468 469 470 471 // ------------------------------ 472 // FULL SCREEN BG VIDEO 473 function bgVideo(fs_video) { 474 475 var videoW = fs_video.find('iframe').width(), 476 videoH = fs_video.find('iframe').height(), 477 screenW = $(window).width(), 478 screenH = $(window).height(); 479 480 var video_ratio = videoW / videoH; 481 var screen_ratio = screenW / screenH; 482 483 if(video_ratio > screen_ratio) { 484 var diffW = screenH / videoH; 485 var newWidth = videoW * diffW; 486 fs_video.css( {'width' : newWidth, 'margin-left' : -((newWidth-screenW)/2), 'margin-top' : 0 }); 487 } else { 488 var diffH = screenH / videoH; 489 var newHeight = screenH * diffH; 490 fs_video.css( {'width' : "100%", 'margin-left' : 0, 'margin-top' : -((videoH-screenH)/2) }); 491 } 492 } 493 // ------------------------------ 494 495 496 497 // WINDOW ONLOAD 498 window.onload = function() { 499 500 // html addclass : loaded 501 $('html').addClass('loaded'); 502 503 // GALLERY COLLAGE LAYOUT 504 collage(); 505 506 507 // ------------------------------ 508 // FULL WIDTH IMAGES 509 fullWidthImages(); 510 // ------------------------------ 511 512 513 // ------------------------------ 514 // Rotating Words 515 var rotate_words = $('.rotate-words'), 516 interval = 3000; 517 if(rotate_words.length) { 518 519 var next_word_index = 0; 520 interval = rotate_words.data("interval"); 521 522 if(Modernizr.csstransforms3d) { 523 524 rotate_words.each(function(index, element) { 525 $(element).find('span').eq(0).addClass('active'); 526 setInterval(function(){ 527 next_word_index = $(element).find('.active').next().length ? $(element).find('.active').next().index() : 0; 528 $(element).find('.active').addClass('rotate-out').removeClass('rotate-in active'); 529 $(element).find('span').eq(next_word_index).addClass('rotate-in active').removeClass('rotate-out'); 530 },interval); 531 }); 532 533 } 534 else { 535 536 rotate_words.each(function(index, element) { 537 $(element).find('span').eq(0).addClass('active').show(); 538 setInterval(function(){ 539 next_word_index = $(element).find('.active').next().length ? $(element).find('.active').next().index() : 0; 540 $(element).find('.active').removeClass('active').slideUp(500); 541 $(element).find('span').eq(next_word_index).addClass('active').slideDown(500); 542 },interval); 543 }); 544 } 545 } 546 // ------------------------------ 547 548 }; 549 // WINDOW ONLOAD 550 551 552 553 554 // ------------------------------------------------------------ 555 // ------------------------------------------------------------ 556 // FUNCTIONS 557 // ------------------------------------------------------------ 558 // ------------------------------------------------------------ 559 560 561 562 // ------------------------------ 563 // FULL WIDTH IMAGES 564 function fullWidthImages() { 565 $('.full-width-image').each(function(index, element) { 566 $(element).css("min-height", $(element).find('img').height()); 567 $( window ).resize(function() { 568 $(element).css("min-height", $(element).find('img').height()); 569 }); 570 }); 571 } 572 // ------------------------------ 573 574 575 // ------------------------------ 576 // GALLERY COLLAGE LAYOUT 577 function collage() { 578 var collage = $('.pw-collage'); 579 var mobile = $(window).width() < 768; 580 var row_height = mobile ? collage.data('mobile-row-height') : collage.data('row-height'); 581 if(collage.length) { 582 collage.removeClass('pw-collage-loading');
583 collage.collagePlus({ 584 585 'targetHeight' : row_height, 586 'effect' : collage.data('effect'), 587 'allowPartialLastRow' : true 588 589 }); 590 } 591 } 592 // ------------------------------ 593 594 595 // ------------------------------ 596 // PHOTOWALL - ri-grid 597 function photowall() { 598 var riGrid = $('.ri-grid'); 599 if(riGrid.length) { 600 601 if($('html').hasClass('home-landing')) { 602 603 riGrid.gridrotator( { 604 rows : 5, 605 columns : 9, 606 maxStep : riGrid.data('max-step'), // 1 to 3 607 interval : riGrid.data('interval'), // in ms 608 609 // animation type 610 // showHide || fadeInOut || slideLeft || 611 // slideRight || slideTop || slideBottom || 612 // rotateLeft || rotateRight || rotateTop || 613 // rotateBottom || scale || rotate3d || 614 // rotateLeftScale || rotateRightScale || 615 // rotateTopScale || rotateBottomScale || random 616 animType : riGrid.data('animation'), 617 618 w1500 : { 619 rows : 5, 620 columns : 8 621 }, 622 w1200 : { 623 rows : 6, 624 columns : 7 625 }, 626 w1024 : { 627 rows : 7, 628 columns : 5 629 }, 630 w768 : { 631 rows : 7, 632 columns : 4 633 }, 634 w480 : { 635 rows : 7, 636 columns : 3 637 }, 638 w320 : { 639 rows : 6, 640 columns : 3 641 } 642 }); 643 644 645 } else { 646 647 riGrid.gridrotator( { 648 rows : 3, 649 columns : 12, 650 maxStep : riGrid.data('max-step'), // 1 to 3 651 interval : riGrid.data('interval'), // in ms 652 653 // animation type 654 // showHide || fadeInOut || slideLeft || 655 // slideRight || slideTop || slideBottom || 656 // rotateLeft || rotateRight || rotateTop || 657 // rotateBottom || scale || rotate3d || 658 // rotateLeftScale || rotateRightScale || 659 // rotateTopScale || rotateBottomScale || random 660 animType : riGrid.data('animation'), 661 662 w1500 : { 663 rows : 3, 664 columns : 12 665 }, 666 w1200 : { 667 rows : 3, 668 columns : 13 669 }, 670 w1024 : { 671 rows : 3, 672 columns : 12 673 }, 674 w768 : { 675 rows : 3, 676 columns : 8 677 }, 678 w480 : { 679 rows : 3, 680 columns : 7 681 }, 682 w320 : { 683 rows : 2, 684 columns : 4 685 } 686 }); 687 }// else 688 } 689 } 690 // ------------------------------ 691 692 693})(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.