1var originalContainer; 2var currentGalleryPage = 0; 3var iOS = ( navigator.userAgent.match(/(iPad|iPhone|iPod)/g) ? true : false ); 4var otheriOS = (navigator.userAgent.match(/(iPhone|iPod)/g) ? true : false ); 5var isiPad = navigator.userAgent.match(/iPad/i) != null; 6 7$(document).ready(function () { 8 9 var iOS = ( navigator.userAgent.match(/(iPad|iPhone|iPod)/g) ? true : false ); 10 if(iOS) { 11 $("html").addClass('ios'); 12 } 13 if($(window).width() < 768) 14 { 15 $("html").addClass('phone'); 16 } 17 18 if($("section#work").length){ 19 $("body").addClass('work'); 20 } 21 22 if(Modernizr.cssanimations){ 23 $("header").addClass("active"); 24 $("header").on('webkitAnimationEnd msAnimationEnd animationend', initPage); 25 }else{ 26 $("header").css("top", "0px"); 27 initPage(); 28 } 29 30 //work slider stuff 31 jQuery("#main #work article.row .column.thumbs .arrow").click(nextThumbPage); 32 jQuery("#main #work article.row .column.thumbs ul li a, #main #work article.row .column .video").click(swapWorkVideo); 33 34}); 35 36function setupVideos(){ 37 if($("#main #work article.row .column.thumbs").length){ 38 $("#main #work article.row .column.thumbs ul li a, #main #work article.row .column .video").each(function(index, value){ 39 var video_id = 'videoCont_' + index; 40 $(this).append('<div id="' + video_id + '" class="jw-video" />'); 41 }); 42 } 43 else { 44 $("#main #work article.row .column .video").each(function(index, value){ 45 var video_id = 'videoCont_' + index; 46 $(this).append('<div id="' + video_id + '" class="jw-video" />'); 47 }); 48 } 49} 50 51function pauseWorkVideos(){ 52 $(".column .video, .column.thumbs ul li a").each(function(index, value){ 53 if(jwplayer(index) != undefined){ 54 jwplayer(index).pause(); 55 } 56 }); 57} 58 59function swapWorkVideo(e){ 60 e.preventDefault(); 61 if($(this).hasClass('setup')) return; 62 if(!$(this).hasClass("video") && !$(this).parents('.column.thumbs.internal')) return; 63 64 var videoURL = $(this).attr("href"); 65 //keeps the div dimensions so the video maintains aspect ratio 66 67 if($(this).parents('.column.thumbs').length){ 68 $(this).parents('.column.thumbs').find('li.on').removeClass('on'); 69 $(this).parent().addClass('on'); 70 } 71 72 var video_index = $(".column .video, .column.thumbs ul li a").index(this), 73 video_id = 'videoCont_' + video_index, 74 $video = $("#" + video_id), 75 vid_width = $(this).parent().find('img').width(), 76 vid_height = $(this).parent().find('img').height(); 77 78 if($(this).parent().hasClass('checkHeight')) 79 { 80 vid_width = $(this).width(); 81 vid_height = $(this).height(); 82 } 83 84 if($(this).parents('.column.thumbs').length && !$(this).parents('.column.thumbs').hasClass('internal')) 85 { 86 video_id = $(this).parents('article.row').prev().find('.jw-video').attr('id'); 87 $video = $("#" + video_id); 88 vid_width = $(this).parents('article.row').prev().find('img').width(); 89 vid_height = $(this).parents('article.row').prev().find('img').height(); 90 } 91 92 //pauseWorkVideos(); 93 94 $video.parent().find("img").hide(); 95 //$("#" + video_id).parent().find("img").css("opacity", "0"); 96 97 var playerInstance = jwplayer(video_id).setup({ 98 flashplayer: applicationURL + '/assets/jwplayer/player.swf', 99 file: videoURL, 100 width: vid_width, 101 height: vid_height, 102 autostart: 'true', 103 controlbar: 'over', 104 skin: applicationURL + '/assets/jwplayer/bekle.zip' 105 }); 106 107 $(this).addClass('setup'); 108 playerInstance.onPlay(function(event){ 109 if(event.newstate == 'PLAYING') 110 { 111 jwPlay(this.id); 112 } 113 }); 114} 115 116function jwPlay(id) 117{ 118 var jw_index = parseInt(id.replace('videoCont_','')); 119 120 $("object").not("#" + id).each(function(index, value){ 121 if(jwplayer(index) != undefined){ 122 if(jwplayer($(this).attr('id')).getState() == 'PLAYING') 123 { 124 jwplayer($(this).attr('id')).pause(); 125 } 126 } 127 }); 128} 129 130function nextThumbPage(e){ 131 var thumbsPerPage = 4; 132 var maxGalleryPages = Math.floor(jQuery("#main #work article.row .column.thumbs ul li").length/thumbsPerPage); 133 134 if(jQuery("#main #work article.row .column.thumbs ul li").length == thumbsPerPage) return; 135 if(currentGalleryPage >= maxGalleryPages && jQuery(this).hasClass("next")) return; 136 if(currentGalleryPage <= 0 && jQuery(this).hasClass("prev")) return; 137 138 var navWidth = jQuery("#main #work article.row .column.thumbs").width()+14; 139 var startLeft = jQuery("#main #work article.row .column.thumbs ul").css("left"); 140 startLeft = startLeft.split("px"); 141 var newLeft = 0; 142 143 if(jQuery(this).hasClass("next")){ 144 newLeft = parseInt(startLeft[0])-navWidth; 145 currentGalleryPage++; 146 }else if(jQuery(this).hasClass("prev")){ 147 newLeft = parseInt(startLeft[0])+navWidth; 148 currentGalleryPage--; 149 } 150 jQuery("#main #work article.row .column.thumbs ul").css("left", newLeft+"px"); 151} 152 153function createResponsiveMenu(){ 154 155 var $nav = $("header nav"), 156 navMenu = $nav.find('.mainNav').html(), 157 markup = '<nav class="respond"><ul>' + navMenu + '</ul><div class="clearFloat"></div></nav>'; 158
159 var workSub = $nav.find('ul.sortMenu').html(); 160 161 $("header > .contain").append(markup); 162 163 if($nav.find('ul.sortMenu').length){ 164 $("header .respond > ul li:eq(0)").append('<ul>' + workSub + '</ul>'); 165 } 166 167 $("header .respond > ul > li > ul > li > a").on('click', function(){ 168 169 $("header .respond > ul > li > ul > li").removeClass('active'); 170 $(this).parent().addClass('active'); 171 172 return false; 173 }); 174 175 $("header .drawer").on('click', function(){ 176 $("header .respond").slideToggle(); 177 return false; 178 }); 179} 180 181function initPage(){ 182 $("header").off("webkitAnimationEnd msAnimationEnd animationend"); 183 184 function checkResponse(init){ 185 if(parseInt($(window).height()) <= 480) 186 { 187 $("nav.respond").css({ 188 height: ($(window).height() - $("header").height()) + "px", 189 'overflow-y': 'scroll' 190 }); 191 } 192 } 193 194 $(window).on('resize', checkResponse); 195 checkResponse(true); 196 197 function headerFlex() 198 { 199 200 var startY = 0; 201 202 $("#container").on('touchstart', function(event){ 203 if($(window).scrollTop() > $("header").outerHeight()) 204 { 205 var touchobj = event.originalEvent.changedTouches[0]; 206 startY = parseInt(touchobj.clientY); 207 } 208 }); 209 $("#container").on('touchend', function(event){ 210 //startY = 0; 211 }); 212 213 $("#container").on('touchmove', function(event){ 214 if($(window).scrollTop() > $("header").outerHeight()) 215 { 216 var touchobj = event.originalEvent.changedTouches[0], 217 dist = touchobj.clientY - startY; 218 219 var threshold = 10; 220 if(dist > threshold) 221 { 222 $("header").addClass('active').removeClass('out'); 223 } 224 else if(dist < 0 && (dist * -1) > threshold) 225 { 226 $("header").removeClass('active').addClass('out'); 227 } 228 } 229 }); 230 231 } 232 headerFlex(); 233 234 //if portfolio template 235 if($('section#portfolio').length > 0){ 236 originalContainer = $('section#portfolio').clone(); 237 var work = new workContainer($('section#portfolio'), 250); 238 239 if($("section#portfolio .column").hasClass('career') || $("section#portfolio .column").hasClass('news')){ 240 241 } 242 else { 243 //work.addEventListener("scrolledOut", duplicateSection); 244 } 245 246 work.checkInitialScroll(); 247 } 248 if($(".column.work").length){ 249 $(".column.work .imageCont, .column.work h1").on('click', function(){ 250 251 if($(this).parents('.column').find('.videoCont').length == 0){ 252 window.location = $(this).parent().find('.info .copy h2 a').attr('href'); 253 return false; 254 } 255 256 }); 257 $(".column.work .info .copy h2 a").on('click', function(){ 258 259 if($(this).parents('.column').find('.videoCont').length) 260 { 261 $(this).parents('.column').find('.background').trigger('click'); 262 return false; 263 } 264 265 }); 266 } 267 if($(".column.news").length){ 268 $(".column.news").on('click', function(){ 269 270 window.location = $(this).find('a').attr('href'); 271 return false; 272 273 }); 274 } 275 if($("#contact").length){ 276 277 if(!iOS) 278 { 279 $maps = []; 280 $("li.location").each(function(){ 281 282 var $this = $(this); 283 var $map = $this.find('.gmap').get(0); 284 var coords = $this.data('coords').split(','); 285 var lat_lng = new google.maps.LatLng(coords[0],coords[1]); 286 287 var mapOptions = { 288 zoom: 15, 289 center: lat_lng, 290 mapTypeId: google.maps.MapTypeId.ROADMAP, 291 disableDoubleClickZoom: true, 292 draggable: false, 293 scrollwheel: false, 294 panControl: false, 295 mapTypeControl: false 296 }; 297 298 var map = new google.maps.Map( $map, mapOptions); 299 var marker = new google.maps.Marker({ 300 position: lat_lng, 301 map: map, 302 icon: $this.data('icon') 303 }); 304 $maps.push(map); 305 306 }); 307 } 308 else 309 { 310 $("li.location").each(function(){ 311 $(this).find('.overlay').hide(); 312 $(this).find('.pin').show(); 313 }); 314 315 function moveMarker(init){ 316 if($(window).width() < 1600) 317 { 318 var move = (1600 - $(window).width()) / 2; 319 $(".location .pin").each(function(index, value){ 320 if(init == true){ 321 $(this).data('left',$(this).css('left')) 322 } 323 $(this).css('left', ((parseInt($(this).data('left')) - move)) + "px" ); 324 });
325 } 326 } 327 328 moveMarker(true); 329 $(window).on('resize', moveMarker); 330 } 331 332 $.fn.toggleOverlay = function(){ 333 334 if(!this.length){return this;} 335 336 this.each(function(){ 337 var $this = $(this); 338 339 var index = $("#contact .location").index($this.parent()); 340 341 $.each($maps, function(){ 342 $this.draggable = false; 343 $this.panControl = false; 344 $this.zoomControl = false; 345 $this.streetViewControl = false; 346 $this.disableDoubleClickZoom = true; 347 }); 348 349 if(!$this.parent().hasClass("active")) 350 { 351 352 $maps[index].draggable = true; 353 $maps[index].panControl = true; 354 $maps[index].zoomControl = true; 355 $maps[index].streetViewControl = true; 356 $maps[index].disableDoubleClickZoom = false; 357 358 $(".gmnoprint").css('opacity',0); 359 $this 360 .parent() 361 .find('.gmap') 362 .find('.gmnoprint') 363 .css('opacity',1); 364 365 $("#contact .location.active").removeClass('active'); 366 $this.parent().addClass('active'); 367 368 $("#contact .location .overlay").fadeIn(); 369 $this.fadeOut(); 370 } 371 else { 372 $this.find('.gmnoprint').css('opacity',0); 373 $this.parent().find('.overlay').fadeIn(); 374 $this.parent().removeClass('active'); 375 } 376 377 }); 378 379 return this; 380 } 381 382 $("#contact .location .overlay").on('click', function(){ 383 $(this).toggleOverlay(); 384 return false; 385 }); 386 387 388 $(".location .overlay").on('click', function(){ 389 390 if(otheriOS || $(window).width <= 768) 391 { 392 393 $(".location .info").animate({ 394 left: 0 395 }, 396 250, function() { 397 /* stuff to do after animation is complete */ 398 }); 399 400 $(this).parent().find('.info').animate({ 401 left: -1.2 * $(window).width() + "px", 402 }, 403 250, function() { 404 /* stuff to do after animation is complete */ 405 }); 406 407 } 408 }); 409 410 $(document).on('keyup', function(event){ 411 if(event.keyCode == 27){ 412 $(".location.active .overlay").toggleOverlay(); 413 } 414 }); 415 416 } 417 createResponsiveMenu(); 418 setupVideos(); 419 420 //if about template 421 if($("section#about").length > 0) 422 { 423 if($(window).width > 480 || otheriOS == false){ 424 $(".top-yellow h1").fitText(1.5, { 425 maxFontSize: '95px' 426 }); 427 428 $(".top-yellow h2").fitText(.5, { 429 minFontSize: '16px', 430 maxFontSize: '21px' 431 }); 432 433 $(".top-blue blockquote").fitText(.50, { 434 minFontSize: '85px', 435 maxFontSize: '185px' 436 }); 437 438 $(".top-blue cite").fitText(2, { 439 //minFontSize: '85px', 440 maxFontSize: '30px' 441 }); 442 443 $(".wave-bottom > p").fitText(2, { 444 maxFontSize: '72px' 445 }); 446 } 447 448 449 function circle_animations(event){ 450 var scroll_pos = parseInt($(window).scrollTop()); 451 452 if(scroll_pos >= ($(".bottom-blue .circle").offset().top - ($(window).height() * .6))){ 453 454 $(".bottom-blue .circle").addClass('animated'); 455 456 } 457 if(scroll_pos >= ($(".wave-bottom .circle").offset().top - ($(window).height() * .6))){ 458 459 $(".wave-bottom .circle").addClass('animated'); 460 461 } 462 } 463 464 if(otheriOS == false) 465 { 466 $(window).on('scroll', circle_animations ); 467 circle_animations('load'); 468 469 $(window).on('resize load', function(){ 470 471 var w_width = parseInt($(window).width()); 472 473 if(w_width < 1600){ 474 var $yellow_icon = $(".top-yellow .icon"), 475 yellow_icon_width = (.12 * w_width), 476 yellow_icon_bg_size = "" + yellow_icon_width + " " + yellow_icon_width + ""; 477 478 $yellow_icon.css({ 479 width: yellow_icon_width, 480 height: yellow_icon_width 481 }); 482 483 $(".web").css({ 484 left: ($(".bottom-blue .circle").offset().left - (.63 * (w_
484width))) + "px" 485 }); 486 } 487 488 }); 489 490 } 491 } 492 493 //if people template 494 if($('section#people').length > 0) var thePeople = new PeopleContainer($('section#people ul')); 495 496 //if contact template 497 if($('section#contact').length > 0){ 498 $('section#contact .location').each(function(){ 499 var tempLocation = new Location($(this)); 500 }); 501 } 502 503 //if work template 504 if($('section#work').length > 0){ 505 loadWorkVideos(); 506 } 507 508 //change contact dropdown info 509 $("header nav .mainNav li .subMenu .locationLinks li a").mouseover(function(){ 510 $("header nav .mainNav li .subMenu .contactInfo").html( $(this).parent().find(".info").html() ).show(); 511 }); 512} 513 514//////////////////////////////////////////////////////////// 515// [Portfolio Scroll] 516//////////////////////////////////////////////////////////// 517function duplicateSection(){ 518 var newContainer = originalContainer.clone(); 519 newContainer.appendTo("#main"); 520 var work = new workContainer(newContainer, 250); 521 work.addEventListener("scrolledOut", duplicateSection); 522} 523 524//////////////////////////////////////////////////////////// 525// [Work Video] 526//////////////////////////////////////////////////////////// 527function loadWorkVideos(){ 528 $('section#work .videoCont').each(function(){ 529 var videoEle = $(this).children(".video"); 530 jwplayer(videoEle.attr("id")).setup({ 531 flashplayer: applicationURL+'/assets/jwplayer/player.swf', 532 image: videoEle.attr("data-image"), 533 file: videoEle.attr("data-src"), 534 width: videoEle.attr("data-width"), 535 height: videoEle.attr("data-height"), 536 autostart:'false', 537 controlbar:'over', 538 skin:applicationURL+'/assets/jwplayer/bekle.zip' 539 }); 540 }); 541} 542 543 544//////////////////////////////////////////////////////////// 545// [Location Class] 546//////////////////////////////////////////////////////////// 547function Location(_div){ 548 var div = _div; 549 var events = {}; 550 551 function init(){ 552 var image = new Image(); 553 image.src = div.attr("data-src"); 554 $(image).load(function(){ 555 div.addClass("loaded"); 556 557 558 div.find('.gmap').css({ 559 "background":"transparent url('"+div.attr("data-src")+"') no-repeat", 560 //"background-size": "cover", 561 "background-position": "50% 50%" 562 }); 563 564 if(!Modernizr.backgroundsize) div.css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+div.attr("data-src")+"', sizingMethod='scale');"); 565 }); 566 } 567 568 this.getElement = function(){ 569 return div; 570 }; 571 572 this.addEventListener = function(the_event, the_action){ 573 events[the_event] = the_action; 574 }; 575 576 function dispatchEvent(the_event){ 577 if (events.hasOwnProperty(the_event)) events[the_event](); 578 } 579 580 init(); 581} 582//////////////////////////////////////////////////////////// 583// [People Container Class] 584//////////////////////////////////////////////////////////// 585function PeopleContainer(_div){ 586 var div = _div; 587 var people = new Array(); 588 var events = {}; 589 590 function init(){ 591 loadPerson(); 592 } 593 594 function loadPerson(){ 595 var firstPerson = div.children(".person:not(.loaded):first"); 596 if(firstPerson.length > 0){ 597 var tempPerson = new Extender(firstPerson); 598 tempPerson.addEventListener("loaded", loadPerson); 599 tempPerson.addEventListener("click", function(){ 600 showPeopleDetails(tempPerson); 601 }); 602 people.push(tempPerson); 603 } 604 } 605 606 function elementInViewport(el, perc){ 607 608 if(!perc){ 609 perc = 1; 610 } 611 612 var top = el.offsetTop; 613 var left = el.offsetLeft; 614 var width = el.offsetWidth; 615 var height = (el.offsetHeight * perc); 616 617 while(el.offsetParent) { 618 el = el.offsetParent; 619 top += el.offsetTop; 620 left += el.offsetLeft; 621 } 622 623 return ( 624 top < (window.pageYOffset + window.innerHeight) && 625 (top + height) > window.pageYOffset 626 ); 627 } 628 629 function showPeopleDetails(tempPerson){ 630 if(tempPerson.isOpen()){ 631 tempPerson.close(true); 632 var $el = $("#people .person.open .details"); 633 634 /* 635 $el 636 .parent() 637 .css({ 638 'padding-bottom': '' 639 }); 640 */ 641 642 }else{ 643 var foundOpenOnRow = false; 644 for(var i=0; i<people.length; i++){ 645 if(people[i].isOpen()){ 646 if(people[i].getRow() == tempPerson.getRow()){ 647 people[i].close(false); 648 foundOpenOnRow = true; 649 }else{ 650 people[i].close(true); 651 } 652 break; 653 } 654 } 655 656 if(!foundOpenOnRow){ 657 tempPerson.open(true); 658 }else{ 659 tempPerson.open(false); 660 } 661 662 var $el = $("#people .person.open .details"); 663 var view = elementInViewport($el.get(0), 1); 664 665 /* 666 $el 667 .parent() 668 .css({ 669 'padding-bottom': $el.outerHeight() 670 }); 671 */ 672 673 $el.on('transitionend webkitTransitionEnd oTransitionEnd msTransitionEnd', function(){ 674 if( (window.pageYOffset + window.innerHeight) < ($el.offset().top + $el.height()) ){ 675 $('body,html').animate({ scrollTop: ($el.offset().top - $("header.active").height()) + "px" }); 676 } 677 }); 678 } 679 } 680 681 this.getElement = function(){ 682 return div; 683 }; 684 685 this.addEventListener = function(the_event, the_action){ 686 events[the_event] = the_action; 687 }; 688 689 function dispatchEvent(the_event){ 690 if (events.hasOwnProperty(the_event)) events[the_event](); 691 } 692 693 init(); 694} 695 696//////////////////////////////////////////////////////////// 697// [Extender Class]
698//////////////////////////////////////////////////////////// 699function Extender(_div){ 700 var div = _div; 701 var imageCont = null; 702 var detailsEle = null; 703 var index; 704 var row = 0; 705 var events = {}; 706 707 function init(){ 708 index = div.index(); 709 imageCont = div.children(".imageCont"); 710 detailsEle = div.children(".details"); 711 712 loadImage(); 713 714 $(window).resize(checkRow); 715 checkRow(); 716 } 717 718 function loadImage(){ 719 if(imageCont.attr("data-src") != "" && imageCont.attr("data-src") != undefined){ 720 var image = new Image(); 721 image.src = imageCont.attr("data-src"); 722 $(image).load(function(){ 723 if(imageCont.children("img").length <= 0) imageCont.prepend(image); 724 725 div.addClass("loaded"); 726 if(Modernizr.cssanimations) div.bind('transitionend webkitTransitionEnd oTransitionEnd msTransitionEnd', loaded); 727 else loaded(); 728 }); 729 }else{ 730 loaded(); 731 } 732 } 733 734 function loaded(){ 735 div.unbind('transitionend webkitTransitionEnd oTransitionEnd msTransitionEnd'); 736 dispatchEvent("loaded"); 737 738 div.find(".details .closeBtn").click(function(){dispatchEvent("click")}); 739 740 imageCont.click(function(){dispatchEvent("click");}); 741 } 742 743 function checkRow(){ 744 var ratio = Math.round(div.parent().width()/div.width()); 745 row = Math.floor((index/ratio)); 746 } 747 748 function animate(callback){ 749 div.addClass("animate"); 750 div.bind('transitionend webkitTransitionEnd oTransitionEnd msTransitionEnd', function(){ 751 div.unbind('transitionend webkitTransitionEnd oTransitionEnd msTransitionEnd'); 752 div.removeClass("animate"); 753 if(typeof callback == 'function'){ 754 callback(); 755 } 756 }); 757 } 758 759 this.open = function(doAnimation){ 760 761 dispatchEvent("open"); 762 div.addClass("open"); 763 764 var $el = div.find('.details'); 765 766 $el 767 .parent() 768 .css({ 769 'padding-bottom': $el.outerHeight() 770 }); 771 772 if(doAnimation){ 773 animate(function(){ 774 775 if( (window.pageYOffset + window.innerHeight) < ($el.offset().top + $el.height()) ){ 776 $('body,html').animate({ scrollTop: ($el.offset().top - $("header.active").height()) + "px" }); 777 } 778 779 }); 780 } 781 782 if(detailsEle.css("background-image") == "none" && imageCont.attr("data-src") != "" && imageCont.attr("data-src") != undefined) detailsEle.css("background", "#000 url('"+detailsEle.attr("data-src")+"') top center no-repeat"); 783 }; 784 785 this.close = function(doAnimation){ 786 if(doAnimation) animate(); 787 788 dispatchEvent("close"); 789 790 var $el = div.find('.details'); 791 $el.parent().css('padding-bottom','0'); 792 div.removeClass("open"); 793 }; 794 795 this.isOpen = function(){ 796 if (div.hasClass("open")) return true; 797 else return false; 798 }; 799 800 this.getRow = function(){ 801 return row; 802 }; 803 804 this.getElement = function(){ 805 return div; 806 }; 807 808 this.addEventListener = function(the_event, the_action){ 809 events[the_event] = the_action; 810 }; 811 812 function dispatchEvent(the_event){ 813 if (events.hasOwnProperty(the_event)) events[the_event](); 814 } 815 816 init(); 817} 818 819//////////////////////////////////////////////////////////// 820// [Work Container Class] 821//////////////////////////////////////////////////////////// 822function workContainer(_div, _scrollPadding){ 823 var div = _div; 824 var scrollPadding = _scrollPadding; 825 var imageQueue = new Array(); 826 var imageQueueTimer; 827 var topPosition; 828 var events = {}; 829 var currentItemStarted = 0; 830 var nextItemStarter; 831 var expanders = new Array(); 832 833 function init(){ 834 imageQueue["images"] = new Array(); 835 imageQueue["arrows"] = new Array(); 836 837 /*div.find('.imageCont').each(function(){ 838 loadImage($(this)); 839 });*/ 840 loadImage(); 841 842 this.topPosition = div.position().top; 843 $(window).scroll(checkScroll); 844 $(window).on('resize', resizeDivs); 845 resizeDivs(); 846 } 847 848 function loadImage(){ 849 if (nextItemStarter) window.clearInterval(nextItemStarter); 850 851 var imageCont = div.find('.column').eq(currentItemStarted).find(".imageCont"); 852 853 //not the best solution, just designed to work with the framework already in place 854 var arrowContainer = new ArrowContainer(imageCont); 855 //arrowContainer.generateArrows(imageCont.width(), imageCont.height()); 856 857 //imageCont.append(arrowContainer.getElement()); 858 859 if(imageCont.attr("data-src") != ""){ 860 var image = new Image(); 861 image.src = imageCont.attr("data-src"); 862 $(image).load(function(){ 863 imageCont.addClass("loaded"); 864 }); 865 }else{ 866 imageCont.addClass("loaded"); 867 } 868 869 var addImage = function(){ 870 if(imageCont.attr("data-src") != ""){ 871 imageCont.parent().addClass("exit"); 872 imageCont.css({ 873 "background":"transparent url('"+imageCont.attr("data-src")+"') no-repeat", 874 "background-size": "cover" 875 }); 876 877 if(imageCont.hasClass('left')) imageCont.css('background-repeat', ''); 878 else if(imageCont.hasClass('right')) imageCont.css('background-repeat', ''); 879 880 if(!Modernizr.backgroundsize) imageCont.css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+imageCont.attr("data-src")+"', sizingMethod='scale');"); 881 882 if(imageCont.hasClass("center")) imageCont.css("background-position", "50% 50%"); 883 else if(imageCont.hasClass("top")) imageCont.css("background-position", "50% 0%"); 884 else if(imageCont.hasClass("bottom")) imageCont.css("background-position", "50% 100%"); 885 else if(imageCont.hasClass("left")) imageCont.css("background-position", "left center"); 886 else if(imageCont.hasClass("right")) imageCont.css("background-position", "right center"); 887 }else{ 888 imageCont.addClass("solid"); 889 } 890 } 891 892 addImageToQueue(imageCont, arrowContainer); 893 894 arrowContainer.addEventListener("complete", function(){imageCont.addClass("complete"); div.find('.column').eq(currentItemStarted).find(".loader").hide();}); 895 arrowContainer.addEventListener("exitStart", addImage); 896 arrowContainer.addEventListener("exitEnd", function(){exitEnd(imageCont);}); 897 arrowContainer.complete(); 898 //arrowContainer.unfoldArrows(); 899 900 currentItemStarted++; 901 if(currentItemStarted < div.find('.column').length){ 902 //var queueAmount = (div.find('.column').eq(currentItemStarted-1).hasClass("wide"))? 1600 : 800; 903 var queueAmount = 150; 904 nextItemStarter = window.setInterval(loadImage, queueAmount); 905 } 906 } 907 908 function exitEnd(imageCont){ 909 imageCont.removeClass("complete").removeClass("loaded"); 910 imageCont.children(".origami").remove(); 911 imageCont.parent().removeClass("exit").addClass("ready"); 912 913 if(imageCont.parent().hasClass('news')) 914 { 915 imageCont.parent().children("article").css("top", 0+"px"); 916 imageCont.parent().children('h1').css({ 917 'opacity': 1, 918 top: 0 919 }); 920 imageCont.parent().children('.excerpt').css({ 921 'opacity': 1, 922 top: 0 923 }); 924 } 925 else 926 { 927 imageCont.parent().children("article").css("top", (imageCont.parent().children("h1").height())+20+"px"); 928 } 929 930 var videoCont = imageCont.parent().children(".videoCont"); 931 videoCont.click(function(){playVideo(videoCont);}); 932 933 var item = imageCont.parent(); 934 if(item.find(".details").length > 0){ 935 var tempExtender = new Extender(item);
936 tempExtender.addEventListener("click", function(){showDetails(tempExtender);}); 937 expanders.push(tempExtender); 938 } 939 } 940 941 function resizeDivs(){ 942 943 var $_height = 0; 944 945 div.find(".column").each(function(){ 946 var baseWidth = 800; 947 var baseHeight = 900; 948 var perc = 1; 949 950 if($(this).hasClass("wide")) baseWidth = 1600; 951 else if($(this).hasClass("short")) baseHeight = 450; 952 953 /* 954 @todo 955 if($(this).width() <= 480) 956 { 957 if($(this).hasClass('career')) 958 { 959 perc = .1; 960 } 961 962 baseWidth = baseWidth * perc; 963 baseHeight = baseHeight * perc; 964 } 965 */ 966 967 var ratio = $(this).width() / baseWidth; 968 var newHeight = ( baseHeight * ratio ); 969 970 if( Math.floor(newHeight) > $_height ){ 971 $_height = Math.floor(newHeight); 972 973 if($(this).hasClass('career')) 974 { 975 //$_height = 180; 976 } 977 978 //$(this).css('height', $_height + "px"); 979 } 980 }); 981 982 $(".column").css("height", Math.floor($_height)+"px"); 983 } 984 985 function playVideo(videoCont){ 986 videoCont.parent().find("h1.initial").hide(); 987 videoCont.parent().removeClass("ready"); 988 videoCont.addClass("play"); 989 videoCont.unbind("click"); 990 991 var baseWidth = 992; 992 var baseHeight = 558; 993 var id = videoCont.children(".videoPlayer").attr("id"); 994 var width = videoCont.width(); 995 var ratio = width/baseWidth; 996 var height = baseHeight*ratio; 997 998 jwplayer(id).setup({ 999 flashplayer: applicationURL+'/assets/jwplayer/player.swf', 1000 file: videoCont.attr("data-src"), 1001 width: width, 1002 height: height, 1003 autostart:'true', 1004 controlbar:'none' 1005 //skin:applicationURL+'/assets/jwplayer/bekle.zip' 1006 }); 1007 1008 $(window).resize(function(){ 1009 var resize = true; 1010 var newWidth = $("#main").width(); 1011 ratio = newWidth/baseWidth; 1012 var newHeight = (baseHeight*ratio); 1013 if(newHeight < baseHeight) resize = false; 1014 1015 if(resize){ 1016 $("#"+id+"_wrapper").css("width", newWidth+"px"); 1017 $("#"+id+"_wrapper").css("height", (baseHeight*ratio)+"px"); 1018 } 1019 }); 1020 } 1021 1022 function showDetails(tempExtender){ 1023 if(tempExtender.isOpen()){ 1024 tempExtender.close(true); 1025 }else{ 1026 var foundOpenOnRow = false; 1027 for(var i=0; i<expanders.length; i++){ 1028 var curExtender = expanders[i]; 1029 if(curExtender.isOpen()){ 1030 if(curExtender.getRow() == tempExtender.getRow()){ 1031 curExtender.close(false); 1032 foundOpenOnRow = true; 1033 }else{ 1034 curExtender.close(true); 1035 } 1036 break; 1037 } 1038 } 1039 if(!foundOpenOnRow){ 1040 tempExtender.open(true); 1041 }else{ 1042 tempExtender.open(false); 1043 } 1044 } 1045 } 1046 1047 function addImageToQueue(imageCont, arrowContainer){ 1048 if(imageQueueTimer == null) imageQueueTimer = window.setInterval(checkQueue, 250); 1049 1050 imageQueue["images"].push(imageCont); 1051 imageQueue["arrows"].push(arrowContainer); 1052 } 1053 1054 function checkQueue(){ 1055 for(var i = 0; i < imageQueue.images.length; i++){ 1056 var imageCont = imageQueue.images[i]; 1057 var arrowContainer = imageQueue.arrows[i]; 1058 if(imageCont.hasClass("complete") && imageCont.hasClass("loaded")){ 1059 arrowContainer.exit(); 1060 imageQueue.images.splice(i, 1); 1061 imageQueue.arrows.splice(i, 1); 1062 i--; 1063 } 1064 } 1065 1066 if(imageQueue.images.length == 0){ 1067 window.clearInterval(imageQueueTimer); 1068 imageQueueTimer = null; 1069 } 1070 } 1071 1072 this.checkInitialScroll = function(){ 1073 checkScroll(); 1074 }; 1075 1076 function checkScroll(){ 1077 if (($(window).scrollTop()+$(window).height()+scrollPadding) >= (this.topPosition + div.height())){ 1078 $(window).unbind('scroll', checkScroll); 1079 dispatchEvent("scrolledOut"); 1080 } 1081 } 1082 1083 this.getElement = function(){ 1084 return div; 1085 }; 1086 1087 this.addEventListener = function(the_event, the_action){ 1088 events[the_event] = the_action; 1089 }; 1090 1091 function dispatchEvent(the_event){ 1092 if (events.hasOwnProperty(the_event)) events[the_event](); 1093 } 1094 1095 init(); 1096} 1097 1098//////////////////////////////////////////////////////////// 1099// [Arrow Container Class] 1100//////////////////////////////////////////////////////////// 1101var arrowWidth = 165; 1102var arrowHeight = 190; 1103function ArrowContainer(_imageCont){ 1104 var imageCont = _imageCont; 1105 var div; 1106 var arrows = new Array(); 1107 var rows; 1108 var cols; 1109 var totalTiles; 1110 var completeTimer; 1111 var events = {}; 1112
1113 function init(){ 1114 //div = document.createElement("div"); 1115 //div.className = "origami"; 1116 1117 div = imageCont.children(".origami"); 1118 } 1119 1120 this.generateArrows = function(containerWidth, containerHeight){ 1121 rows = Math.ceil(containerHeight / arrowHeight)+1; 1122 cols = (Math.ceil(containerWidth / arrowWidth))*2; 1123 totalTiles = rows*cols; 1124 1125 for(var i=0; i<rows;i++){ 1126 for(var j=0; j<cols;j++){ 1127 var topOffset = (j % 2 == 0)? -(arrowHeight/2) : 0; 1128 1129 var tempArrow = new Arrow(); 1130 tempArrow.getElement().style.top=(((arrowHeight*i)+topOffset)-i)+"px"; 1131 tempArrow.getElement().style.left=((arrowWidth*Math.floor(j/2))-j)+"px"; 1132 1133 if (j/cols >= 0.5 && i/rows >= 0.5) tempArrow.slowDown(); 1134 1135 div.appendChild(tempArrow.getElement()); 1136 1137 arrows.push(tempArrow); 1138 } 1139 } 1140 }; 1141 1142 this.unfoldArrows = function(){ 1143 var arrowsQueued = new Array(); 1144 1145 arrows[0].setOrientation("right"); 1146 arrowsQueued.push(arrows[0]); 1147 for (var i=0; i < arrows.length; i++) { 1148 //get next column 1149 1150 var newIndex = i+1; 1151 if((arrows[i].getOrientation() == "right" || arrows[i].getOrientation() == "left" || arrows[i].getOrientation() == "down") && arrows[newIndex] && arrowsQueued.indexOf(arrows[newIndex]) == -1){ 1152 var newOrientation = (arrows[i].getOrientation() == "down") ? "right" : "down"; 1153 arrows[newIndex].setOrientation(newOrientation); 1154 arrows[newIndex].setAnimationDelay((arrows[i].animationDelay()+(arrows[i].animationDuration()*0.8))+"s"); 1155 arrowsQueued.push(arrows[newIndex]); 1156 } 1157 1158 //get next row 1159 newIndex = i+(cols-1); 1160 if(arrows[i].getOrientation() == "down" && arrows[newIndex] && arrowsQueued.indexOf(arrows[newIndex]) == -1){ 1161 arrows[newIndex].setOrientation("left"); 1162 arrows[newIndex].setAnimationDelay((arrows[i].animationDelay()+(arrows[i].animationDuration()*0.8))+"s"); 1163 arrowsQueued.push(arrows[newIndex]); 1164 } 1165 } 1166 1167 for (var i=0; i < arrows.length; i++) { 1168 arrows[i].unfold(); 1169 if (i == arrows.length-1) this.startTimer((arrows[i].animationDelay()+(arrows[i].animationDuration()*0.8))); 1170 } 1171 }; 1172 1173 this.startTimer = function(time){ 1174 completeTimer = window.setInterval(this.complete, (time*1000)); 1175 }; 1176 1177 this.complete = function(){ 1178 window.clearInterval(completeTimer); 1179 div.addClass("complete"); 1180 div.innerHTML = ""; 1181 dispatchEvent("complete"); 1182 }; 1183 1184 this.exit = function(){ 1185 dispatchEvent("exitStart"); 1186 if(Modernizr.cssanimations) $(div).bind('transitionend webkitTransitionEnd oTransitionEnd msTransitionEnd', exitEnd); 1187 else exitEnd(); 1188 $(div).addClass("exit"); 1189 } 1190 1191 function exitEnd(){ 1192 $(div).unbind('transitionend webkitTransitionEnd oTransitionEnd msTransitionEnd'); 1193 dispatchEvent("exitEnd"); 1194 } 1195 1196 this.getElement = function(){ 1197 return div; 1198 }; 1199 1200 this.addEventListener = function(the_event, the_action){ 1201 events[the_event] = the_action; 1202 }; 1203 1204 function dispatchEvent(the_event){ 1205 if (events.hasOwnProperty(the_event)) events[the_event](); 1206 } 1207 1208 init(); 1209} 1210 1211 1212//////////////////////////////////////////////////////////// 1213// [Arrow Class] 1214//////////////////////////////////////////////////////////// 1215function Arrow(){ 1216 var div; 1217 var animationDelay = null; 1218 var animationDuration = null; 1219 var orientation; 1220 1221 function init(){ 1222 div = document.createElement("div"); 1223 div.className = "arrow"; 1224 } 1225 1226 this.getElement = function(){ 1227 return div; 1228 } 1229 1230 this.animationDuration = function(){ 1231 if(animationDuration == null) animationDuration = parseFloat(new String($(div).css("animation-duration")).replace("s", "")); 1232 return animationDuration; 1233 } 1234 1235 this.animationDelay = function(){ 1236 if(animationDelay == null) animationDelay = parseFloat(new String($(div).css("animation-delay")).replace("s", "")); 1237 return animationDelay; 1238 } 1239 1240 this.setAnimationDelay = function(delay){ 1241 animationDelay = parseFloat(new String(delay).replace("s", "")); 1242 $(div).css("animation-delay",delay); 1243 } 1244 1245 this.setOrientation = function(_orientation){ 1246 orientation = _orientation; 1247 div.classList.add(_orientation); 1248 } 1249 1250 this.getOrientation = function(){ 1251 return orientation; 1252 } 1253 1254 this.slowDown = function(){ 1255 div.classList.add("slow"); 1256 } 1257 1258 this.unfold = function(){ 1259 div.classList.add("active"); 1260 if(Modernizr.cssanimations) $(div).bind('webkitAnimationEnd msAnimationEnd animationend', this.complete); 1261 else this.complete; 1262 1263 //webkit blink bug fix 1264 $(div).bind('webkitAnimationStart', function(){$(div).css("opacity", 1);}); 1265 } 1266 1267 this.complete = function(){ 1268 $(div).unbind('webkitAnimationEnd msAnimationEnd animationend'); 1269 div.classList.remove("active"); 1270 div.classList.add("complete"); 1271 } 1272 1273 init(); 1274}
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.