/ Published in: JavaScript
Trying out head.js - available at http://headjs.com/
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// load scripts by assigning a label for them head.js( {jquery: "http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"}, {custom: "<?php echo get_bloginfo(template_url); ?>/include/js/main.js"} ); //call this function as soon as jquery is ready head.ready("jquery", function(){ //fade in the background jQuery('#pageBackground').fadeIn('1500'); jQuery('section').delay('900').fadeIn('1500'); //resize background script from example at http://css-tricks.com/perfect-full-page-background-image/ var theWindow = $(window), $bg = $("#pageBackground"), aspectRatio = $bg.width() / $bg.height(); function resizeBg() { if ( (theWindow.width() / theWindow.height()) < aspectRatio ) { $bg .removeClass() .addClass('bgheight'); } else { $bg .removeClass() .addClass('bgwidth'); } } theWindow.resize(function() { resizeBg(); }).trigger("resize"); }); //google stats head.js("http://www.google-analytics.com/ga.js", function() { var tracker = _gat._getTracker("UA-XXXXXX-X"); tracker._trackPageview(); });