// ------------------------------------------------------------------------- /** * Global Initializer * Site-wide initializers for elements */ var objGlobals = { init : function() { objGlobals.init_supersized(); objGlobals.init_page_view(); objGlobals.init_navigation(); objGlobals.init_modal_box(); objGlobals.init_scroll(); objGlobals.init_content_control(); objGlobals.init_sec_content_control(); objGlobals.hide_content(); objGlobals.init_thumb_list(); objGlobals.init_tooltips(); objGlobals.init_thumbs_mouse_scroll(); objGlobals.init_video_player(); $(window).resize(function(){ objGlobals.hide_content(); objGlobals.init_thumbs_mouse_scroll(); }); var bodyID = $('body').attr('id'); switch(bodyID) { case 'projects-page': objProjectsPage.init(); break; case 'project-detail-page': objProjectDetailPage.init(); break; case 'contact-page': objContactPage.init(); break; case 'awards-page': objProjectsPage.init(); break; case 'press-page': objProjectsPage.init(); break; case 'how_we_think-page': objProjectsPage.init(); break; default: break; } }, // ------------------------------------------------------------------------- /** * Supersized Initializer * Supersized is used for fullscreen background slideshow * Further information : http://buildinternet.com/project/supersized/docs.html */ init_supersized : function() { var array = [ {image : 'http://www.avciarchitects.com/cdn/media/pages/Home1.jpg', title : 'image_1'},{image : 'http://www.avciarchitects.com/cdn/media/pages/Home2.jpg', title : 'image_2'},{image : 'http://www.avciarchitects.com/cdn/media/pages/Home3a.jpg', title : 'image_3'},{image : 'http://www.avciarchitects.com/cdn/media/pages/Home4.jpg', title : 'image_4'},{image : 'http://www.avciarchitects.com/cdn/media/pages/CNN.jpg', title : 'video_5'},{image : 'http://www.avciarchitects.com/cdn/media/pages/Home5.jpg', title : 'image_6'},{image : 'http://www.avciarchitects.com/cdn/media/pages/Home6.jpg', title : 'image_7'},{image : '', title : 'image_8'},{image : 'http://www.avciarchitects.com/cdn/media/pages/Home12.jpg', title : 'image_9'},{image : 'http://www.avciarchitects.com/cdn/media/pages/Home14.jpg', title : 'image_10'},{image : 'http://www.avciarchitects.com/cdn/media/pages/Home15.jpg', title : 'image_11'},{image : 'http://www.avciarchitects.com/cdn/media/pages/Home16.jpg', title : 'image_12'} ]; jQuery(function($){ $.supersized({ //Functionality keyboard_nav : 1, //Keyboard navigation on/off image_protect : 1, //Disables image dragging and right click with Javascript image_path : 'img/', //Default image path slide_interval :3500, min_width : 1024, //Min width allowed (in pixels) min_height : 768, //Min height allowed (in pixels) horizontal_center : 1, thumbnail_navigation : 0, slides : array }); }); }, // --------------------------------------------------------------------- /** * Will set the minimum size of the wrapper */ init_page_view : function() { $(window).load(function() { $('#loading').fadeOut(450); var $nav = $('#nav'); var $primary = $('#nav .primary>ul'); var $secondary = $('#nav .secondary>ul'); $nav.css({ position: "absolute", visibility: "hidden", display: "block" }); var $wrapWidth = $primary.outerWidth(true) + $secondary.outerWidth(true); $nav.css({ position: "", visibility: "", display: ""}); $('#wrap').css({minWidth: $wrapWidth + 1}); var offsetTop = ($('#content-wrap').length) ? $('#content-wrap').offset().top : 0; var contentHeight = ($('#content-wrap').length) ? $('#content-wrap').outerHeight() : 0; var secContentHeight = ($('#sec-content-wrap').length) ? $('#sec-content-wrap').outerHeight() : 0; var footerHeight = ($('#footer').length) ? $('#footer').outerHeight() : 0; var totalHeight = Math.round(offsetTop + contentHeight + secContentHeight + footerHeight); var minHeight = $('#wrap').css('minHeight').split('px')[0]; if(totalHeight > minHeight) { $('#wrap').css({minHeight: totalHeight}); } if($('#content-wrap').hasClass('delayed')) { $('#content-wrap').hide().removeClass('delayed'); setTimeout('$("#content-wrap").fadeIn(500)' , 800); } if($('#sec-content-wrap').hasClass('delayed')) { $('#sec-content-wrap').hide().removeClass('delayed'); setTimeout('$("#sec-content-wrap").fadeIn(500)' , 800); } objGlobals.show_content(); }); }, // --------------------------------------------------------------------- /** * Initializes click effects of the navigation and the menu button */ init_navigation : function() { $('#nav .primary>ul>li>a').click(function(e){ var $this = $(this); var $show = $this.parent('li').find('.sub-nav'); var $visible = $('#nav .sub-nav:visible'); if(!$inAnimation){ $inAnimation = true; if($show.length){ e.preventDefault(); if($visible.length){ if($show[0] == $visible[0]) { $this.removeClass('visible'); $show.animate({ opacity: 0 },200,function(){ $show.hide(450,function(){ $inAnimation = false; }); }); //$this.animate({ // backgroundPosition: '0 0' //},650); } else { $show.show(450, function(){ $visible.animate({ opacity: 0 },200,function(){ $('.visible').removeClass('visible'); $this.addClass('visible'); $show.animate({ opacity: 1 },200); $visible.hide(450,function(){ $inAnimation = false; }); }); //$('.visible').animate({ // backgroundPosition: '0 0' //},650); //$this.animate({ // backgroundPosition: '0 -200px' //},650); }); } } else { $show.show(450, function(){ $show.animate({ opacity: 1 },200,function(){ $this.addClass('visible'); $inAnimation = false; }); }); //$this.animate({ // backgroundPosition: '0 -200px' //},650); } } } }); $('#menu-button').click(function(e){ if(!$inAnimation){ $inAnimation = true; e.preventDefault(); var $this = $('.visible'); var $visible = $('#nav .sub-nav:visible'); var $nav = $('#nav'); var $menubutton = $('#menu-line a'); if($visible.length) { $visible.animate({ opacity: 0 },200,function(){ $this.removeClass('visible'); $visible.hide(450,function(){ $inAnimation = false; }); }); $this.animate({ backgroundPosition: '0 0' },650); } else { if($('#nav:visible').length) { $nav.slideUp(450,function(){ $inAnimation = false; $menubutton.removeClass('up'); }); } else{ $nav.slideDown(450,function(){ $inAnimation = false; $menubutton.addClass('up'); }); } } } }); }, // --------------------------------------------------------------------- /** * Shows the content if #content-wrap has class .short-content */ show_content : function() { if($('#content-wrap').hasClass('short-content')) { var width = $('#content').outerWidth(); if($('#content-wrap').hasClass('hidden')){ $('#content-wrap').animate({ left: 0 }, { duration: 600, speicalEasing: { left: 'easeOutCubic' }, complete: function() {$('#content-wrap').removeClass('hidden');} }); } else { $('#content-wrap').addClass('hidden'); $('#content-wrap').animate({ left: -width }, { duration: 600, specialEasing: { left: 'easeOutCubic' } }); } } }, // --------------------------------------------------------------------- /** * Hides the content. Actually it keeps the content hidden. Only to use on window resize. */ hide_content : function() { if($('#content-wrap').hasClass('hidden')){ var width = $('#content').outerWidth(); $('#content-wrap').css({ left: -width }); } }, // --------------------------------------------------------------------- /** * Initializes modal box */ init_modal_box : function() { // Modal Box - Functionality $('.has-modal').click(function(e){ e.stopPropagation(); e.preventDefault(); $(this).siblings('.modal-box').slideToggle(250); $(this).toggleClass('active'); }); // Modal Box - Close $(document).click(function(){ if($('.modal-box:visible').length){ $visible = $('.modal-box:visible'); $visible.slideUp(250); $visible.siblings('.has-modal').removeClass('active'); } }); }, // --------------------------------------------------------------------- /** * Initializes scroll for the content. Scrollable div should have class .scroll */ init_scroll : function() { $('.scroll').each( function() { $(this).jScrollPane( { showArrows: $(this).is('.arrow') } ); var scroll_api = $(this).data('jsp'); var throttleTimeout; $(window).bind( 'resize', function() { if ($.browser.msie) { // IE fires multiple resize events while you are dragging the browser window which // causes it to crash if you try to update the scrollpane on every one. So we need // to throttle it to fire a maximum of once every 50 milliseconds... if (!throttleTimeout) { throttleTimeout = setTimeout( function() { scroll_api.reinitialise(); throttleTimeout = null; }, 50 ); } } else {scroll_api.reinitialise();} } ); } ); }, // --------------------------------------------------------------------- /** * Initializes content control button. Only short content has this button. */ init_content_control : function() { $('#content-control a').click(function(e){ e.preventDefault(); objGlobals.show_content(); }); }, // --------------------------------------------------------------------- /** * Initializes secondary content control button. */ init_sec_content_control : function() { $('#sec-content-control a').click(function(e){ e.preventDefault(); $inAnimation = true; $(this).toggleClass('up'); $('#sec-content').slideToggle(500,function(){ $inAnimation = false; }); }); }, // --------------------------------------------------------------------- /** * Initializes thumbnails on secondary content */ init_thumb_list : function() { var thumbsWidth = 0; $('#sec-content').height($('.thumb-list').outerHeight()); $('.thumb-list').find('li').each(function(){ thumbsWidth += $(this).outerWidth(true); }); $('.thumb-list').width(thumbsWidth); $('.thumb-list a') .mouseover(function(){ $(this).children('img').stop().animate( {opacity: 1}, {duration: 450}) }) .mouseout(function(){ $(this).children('img').stop().animate( {opacity: 0.6}, {duration: 450}) }); }, // --------------------------------------------------------------------- /** * Initializes thumbnails mouse scroll. */ init_thumbs_mouse_scroll : function() {$('.thumb-list').mousescroll();}, // --------------------------------------------------------------------- /** * Initializes tooltips. * Takes its content from the title images. */ init_tooltips : function() { $('.tooltip').each(function(){ var title = $(this).children('img').attr('title'); var html = ''; $(this).append(html); $popup = $(this).children('.popup'); $popup.css({ right: -$popup.outerWidth() + 10 }) }).mouseover(function(){$(this).children('.popup').show();}).mouseout(function(){$(this).children('.popup').hide();}); }, // --------------------------------------------------------------------- /** * Initializes video player. * Play, Pause and Mute functions */ init_video_player : function() { $('#pause-button').click(function(e){ e.preventDefault(); background.pause(); $(this).fadeOut(200); $('#play-button').fadeIn(200); }); $('#play-button').click(function(e){ e.preventDefault(); background.resume(); $(this).fadeOut(200); $('#pause-button').fadeIn(200); }); $('#mute-button').click(function(e){ e.preventDefault(); if($(this).hasClass('mute')) { background.muteCurrentVideo(false); $(this).removeClass('mute'); } else { background.muteCurrentVideo(true); $(this).addClass('mute'); } }); } }; // ------------------------------------------------------------------------- /** * Projects Page Initializers * Handles the functions to be used in projcets-page */ var objProjectsPage = { init : function() { objProjectsPage.init_projects_thumbs(); objProjectsPage.init_table_sorter(); objProjectsPage.init_icons_mouse_scroll(); objProjectsPage.init_mouse_highlight(); $(window).resize(function(){objProjectsPage.init_icons_mouse_scroll();}); }, // --------------------------------------------------------------------- /** * Takes care of the thumbsnails in the projects page */ init_projects_thumbs : function() { var tableLength = ($('.project-thumb').length * 2) - 1; var n = Math.floor(tableLength / 3); n = n + (tableLength % 3); /* How many empty cells to add */ var e = ((n * 3) - tableLength) - 1; $('.project-thumb').each(function(){ /* Create tooltips from the 'title' attribute of the images */ var projectTitle = $(this).find('img').attr('title'); var html = '

' + projectTitle + '

'; $(this).append(html); $(this).parent().after(''); }); $('#projects-icons-list td:last-child').remove(); // add empty cells for(var i = 0; i <= e; i++) { $('#projects-icons-list tr').append(''); } $('#projects-icons-list td').unwrap(); $('#projects-icons-list td').slice(0, n).wrapAll(''); $('#projects-icons-list td').slice(n, n * 2).wrapAll('') $('#projects-icons-list td').slice(n * 2).wrapAll('') $('.project-thumb').hover(function(){ /* var thumbOver = $(this).find('img').attr('src'); //Set a background image on the tag $(this).css({ 'background' : 'url(' + thumbOver + ') no-repeat center bottom' }); $(this).find("span").stop().fadeTo(500, 0 , function() { $(this).hide() //Hide the image after fade }); */ $(this).find('.project-title').stop().fadeTo(500, 1); }, function(){ /* $(this).find("span").stop().fadeTo(500, 1).show(); */ $(this).find('.project-title').stop().fadeTo(500, 0); }); $('#projects-icons').height($('#projects-icons-list').outerHeight()); }, // --------------------------------------------------------------------- /** * Initializes table sorter */ init_table_sorter :function() { $("#projects-table").tablesorter({ sortList: [[1,0]], headers: { 0: { sorter: false }, 1: { sorter: false }, 2: { sorter: false }, 3: { sorter: false }, 4: { sorter: false }, 5: { sorter: false }, 6: { sorter: false } } }); updateColumn(); $(".sort-up").click(function(e){ e.preventDefault(); var index = $('#projects-table-sorter th').index($(this).parents('th')); var sorting = [[index , 0]]; $("#projects-table").trigger("sorton",[sorting]); updateColumn(); }); $(".sort-down").click(function(e){ e.preventDefault(); var index = $('#projects-table-sorter th').index($(this).parents('th')); var sorting = [[index , 1]]; $("#projects-table").trigger("sorton",[sorting]); updateColumn(); }); function updateColumn() { var index; if($('.headerSortDown').length) { index = $('#projects-table th').index($('.headerSortDown')) + 1; } else if($('.headerSortUp').length) { index = $('#projects-table th').index($('.headerSortUp')) + 1; } $('#projects-table td.bold').removeClass('bold'); $('#projects-table td:nth-child(' + index + ')').addClass('bold'); } $('#projects-table').mousescroll({ direction: 'vertical', speed: 10 }); }, // --------------------------------------------------------------------- /** * Initializes the mouseover highlights for the projects list */ init_mouse_highlight :function() { $('#projects-table tbody tr').mouseover(function(){$(this).addClass('highlight');}).mouseout(function(){$(this).removeClass('highlight');}); }, // --------------------------------------------------------------------- /** * Initializes the mousescroll for the projects icons */ init_icons_mouse_scroll :function() {$('#projects-icons-list').mousescroll();} }; // ------------------------------------------------------------------------- /** * Contact Page Initializers * Handles the functions to be used in contact-page */ var objContactPage = { init : function() {objContactPage.init_newsletter_form_validation();}, init_newsletter_form_validation :function() { var form = $('#newsletter-form'); $('#newsletter-form').validate({ rules: { "newsletter-name": {required: true}, "newsletter-surname": {required: true}, "newsletter-email": {required: true, email:true} }, messages: { "newsletter-name": "This field is required.", "newsletter-surname": "This field is required.", "newsletter-email": {required: "This field is required.", email: "Please enter a valid e-mail address."} }, submitHandler: function(form){ //on click - message waiting $('#submit-wrapper .ajax-loader').fadeIn(); $.ajax({ url: "http://www.avciarchitects.com/newsletter_add", type:"POST", data: "newsletter-name="+$("#newsletter-name").val()+"&newsletter-surname="+$("#newsletter-surname").val()+"&newsletter-email="+$("#newsletter-email").val()+"&tmpstmp="+$("#tmpstmp").val(), cache: false, success: function(html){ if(html == 'success'){ //on success $('#submit-wrapper').html('Thanks for sucscribing to our newsletter!'); } else{ $('#submit-wrapper .ajax-loader').fadeOut(); $('#submit-wrapper').append('Sorry, there was an unknown error. Please try again.'); } } }); } }); $('#newsletter-submit').click(function(e){ e.preventDefault(); $('#newsletter-form').submit(); }); } }; // ------------------------------------------------------------------------- /** * Project DetailPage Initializers * Handles the functions to be used in project-detail-page */ var objProjectDetailPage = { init : function() {objProjectDetailPage.init_content_auto_close();}, // --------------------------------------------------------------------- /** * Initializes the autoclose of content after 8 seconds */ init_content_auto_close :function() { setTimeout(close_content, 8000 ); function close_content(){ if(!$("#project-detail-page .short-content").hasClass("hidden")) {objGlobals.show_content();} } } }; // ------------------------------------- // Ready JS // ------------------------------------- $(document).ready(function() {objGlobals.init();}); // ------------------------------------- // Global Variables // ------------------------------------- $inAnimation = false;