$(document).ready(function(){
// Resize the header logo to match the height of the header nav (if over 120px)
var headerLogoHeight = $('#header-logo a span').first().outerHeight();
var headerNavHeight = $('#header nav').first().outerHeight();
if (headerNavHeight >= 120) {
$('#header-logo a span').height(headerNavHeight); // Adjust the header logo
$('#header-title').css('marginTop',headerNavHeight-90); // Adjust the header title (if it exists)
}
// Initialize jQuery Uniform
$("input, textarea, select, button.button").uniform();
// Work > Index code
if($('#work-index').length != 0) {
var pageTitle = document.title; // Store the initial page title, since it will change as the user interacts with the page
$('head').append(''); // As the page loads, add Facebook meta tags
$('a.iframe').fancybox({
centerOnScroll: true,
height: 355, // 535:355
overlayColor: '#fcfcfa',
overlayOpacity: '0.94',
padding: 0,
speedIn: 300,
speedOut: 100,
width: 630, // 950:630
// When a Fancybox is opened, we need to store a bunch of vars, insert "share this" code above the video, and add new meta data to the page.
onComplete: function( links, index ){
var self = $(links[index]); // Store the currently active video's link
var title = self.find('.title').first().text(); // Get the video's title
var urlTitle = self.attr('rel'); // Get the video's URL title
var image = self.find('img').first().attr('src'); // Get the URL of the video's image placeholder
var block = $('#fancybox-wrap'); // Find the Fancybox element that we need to add "share this" code to.
var permalinkCode = '
Permalink'; // Permanent link to this video
var tweetButtonCode = ''; // Twitter "Tweet" button
var likeButtonCode = ''; // Facebook "Like" button
document.title = title+' - '+pageTitle; // Prepend the page title with the current video's title
block.outerHeight(block.outerHeight()+30); // Adjust the Fancybox's height to make room for the new code
block.css('top',block.position().top-50); // Adjust the Fancybox's vertical position to make room for the new code
block.prepend(''+permalinkCode+tweetButtonCode+likeButtonCode)+'
'; // Insert the new code
$.getScript("http://platform.twitter.com/widgets.js"); // Load Twitter's widjet JS file
// Add a bunch of meta tag data for Facebook
$('meta[property=og:title]').attr('content',title);
$('meta[property=og:type]').attr('content','article');
$('meta[property=og:image]').attr('content',image);
$('meta[property=og:url]').attr('content','http://creoproductions.com/work/'+urlTitle+'/');
$('meta[property=og:site_name]').attr('content','Creo Productions');
return false;
},
// Return the work page to its default state when the user closes Fancybox
onClosed: function(){
document.title = pageTitle; // Revert to the initial page title
$('#share-page').empty(); // Dump all HTML from the "share this" container
$('meta[property=og:title],meta[property=og:type],meta[property=og:image],meta[property=og:url],meta[property=og:site_name]').attr('content',''); // Clear out all values for the Facebook meta tags.
return false;
}
});
// If the Work page has a value in the second URL segment, open that video on page load.
var workIndexWrapper = $('#work-index');
var isPermalinkPage = workIndexWrapper.hasClass('permalink');
if(isPermalinkPage){
var targetRel = workIndexWrapper.attr('rel');
$('#work-list a[rel='+targetRel+']').trigger('click');
}
}
// Hack pasted content and old Blogger text so that all blog posts use our typographic styles
$('.content [style]').removeAttr('style');
});