function detectIOS() { var t = window.navigator.userAgent, e = /iPad|iPhone|iPod/; return e.test(t) }
/* * Get Viewport Dimensions * returns object with viewport dimensions to match css in width and height properties * ( source: http://andylangton.co.uk/blog/development/get-viewport-size-width-and-height-javascript ) */ function updateViewportDimensions() { var w=window,d=document,e=d.documentElement,g=d.getElementsByTagName('body')[0],x=w.innerWidth||e.clientWidth||g.clientWidth,y=w.innerHeight||e.clientHeight||g.clientHeight; return { width:x,height:y } } // setting the viewport width var viewport = updateViewportDimensions();
//adding fullscreen icon if we're embedded if (window!=window.top) { jQuery( "#fullscreen").addClass('framed'); }
jQuery(document).ready(function() {
// check for iOS if ( detectIOS() ) { jQuery('body').addClass('is-ios'); }
jQuery( "#description" ).click(function(e) { e.preventDefault(); jQuery( "#description-overlay" ).addClass("show"); jQuery( "body").addClass("overlaid"); });
jQuery( "#share" ).click(function(e) { e.preventDefault(); jQuery( "#share-overlay" ).addClass("show"); jQuery( "body").addClass("overlaid"); });
jQuery( "#connect" ).click(function(e) { e.preventDefault(); jQuery( "#connect-overlay" ).addClass("show"); jQuery( "body").addClass("overlaid"); });
jQuery( "#agents" ).click(function(e) { e.preventDefault(); jQuery( "#agents-overlay" ).addClass("show"); jQuery( "body").addClass("overlaid"); });
jQuery( ".close-overlay" ).click(function(e) { e.preventDefault(); jQuery(".overlay iframe").attr('src', ''); jQuery( ".overlay" ).removeClass("show"); jQuery( "body").removeClass("overlaid"); });
jQuery(document).keyup(function(e) { if (e.keyCode === 27) { jQuery('.close-overlay').click(); } // esc });
/* Preload Functionality */ var preloadModel = jQuery( "#mp-iframe").data('preload'); if (preloadModel === true ) { console.log('preload'); if( viewport.width >= 768 ) { // do the preload var mp_iframe_preload_src = jQuery( "#mp-iframe").data('src'); // get the iframe src // do the preload if (mp_iframe_preload_src !== '') { jQuery( "#mp-iframe").attr("src", mp_iframe_preload_src); } } } else { preloadModel = false; }
jQuery( "#wp3d-intro a.no-iframe" ).click(function(e) { e.preventDefault(); });
jQuery( "#wp3d-intro a.load-iframe" ).click(function(e) { e.preventDefault(); window.scrollTo(0,0); if (preloadModel === false || viewport.width < 768) { // only swap out the src if we are not preloading OR on mobile var mp_iframe_src = jQuery( "#mp-iframe").data('src'); jQuery( "#mp-iframe").attr("src",mp_iframe_src); } jQuery( "#wp3d-intro" ).fadeOut("slow"); jQuery('#wp3d-iframe-wrap').removeClass('wp3d-sold wp3d-pending'); // if it exists, remove the sold/pending when actually viewing the model if( viewport.width < 768 ) { // fade out overlay on small screens jQuery('.iframe-logo-overlay').delay(3000).fadeOut(); } }); // Remove is-loading intro class window.setTimeout(function() { jQuery('#wp3d-intro').removeClass('is-loading'); }, 500); jQuery(window).load(function() { jQuery('body').addClass('loaded'); jQuery('body').delay( 800 ).addClass('loaded-delay'); /* If the #start hash is present in the skinned URL, jump right in */ if (window.location.hash){ var hash = window.location.hash.substring(1); if (hash == "start"){ console.log ("WP3D Starting!"); jQuery( "#wp3d-intro a" ).click(); } } }) });