/*-----------------------------------------------------------------------------------*/
/* Preloader & Initialize Masonry Script
/*-----------------------------------------------------------------------------------*/
jQuery.noConflict();
jQuery('.ajaxloading').fadeIn(500);
jQuery(window).load(function(){
jQuery('.ajaxloading').fadeOut(500);
});
jQuery(window).load(function(){
jQuery(".slideshowpreload").fadeOut('slow');
});
/*-----------------------------------------------------------------------------------*/
/* Superfish Initialization
/*-----------------------------------------------------------------------------------*/
jQuery(function() {
jQuery('ul.sf-menu').superfish({
autoArrows: true
});
});
/*-----------------------------------------------------------------------------------*/
/* Tabs
/*-----------------------------------------------------------------------------------*/
if(jQuery() .tabs) {
jQuery( "#tabs" ).tabs().addClass( "ui-tabs-vertical ui-helper-clearfix" );
jQuery( "#tabs li" ).removeClass( "ui-corner-top" ).addClass( "ui-corner-left" );
jQuery( "#tabs" ).tabs({ fx: { opacity: 'toggle' } });
};
/*-----------------------------------------------------------------------------------*/
/* Pretty Photo
/*-----------------------------------------------------------------------------------*/
jQuery(function(){
jQuery("a[rel^='prettyPhoto']").prettyPhoto({
animation_speed: 'fast', /* fast/slow/normal */
slideshow: 5000, /* false OR interval time in ms */
autoplay_slideshow: false, /* true/false */
opacity: 0.80, /* Value between 0 and 1 */
show_title: false, /* true/false */
allow_resize: true, /* Resize the photos bigger than viewport. true/false */
default_width: 500,
default_height: 344,
counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
theme: 'pp_default', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
horizontal_padding: 20, /* The padding on each side of the picture */
hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
wmode: 'opaque', /* Set the flash wmode attribute */
autoplay: true, /* Automatically start videos: True/False */
modal: false, /* If set to true, only the close button will close the window */
deeplinking: true, /* Allow prettyPhoto to update the url to enable deeplinking. */
overlay_gallery: true, /* If set to true, a gallery will overlay the fullscreen image on mouse over */
keyboard_shortcuts: true, /* Set to false if you open forms inside prettyPhoto */
changepicturecallback: function(){}, /* Called everytime an item is shown/changed */
callback: function(){}, /* Called when prettyPhoto is closed */
ie6_fallback: true
});
});
/*-----------------------------------------------------------------------------------*/
/* Hover Effects
/*-----------------------------------------------------------------------------------*/
function hover_overlay() {
jQuery('.flexslider .slides').each(function() {
var $this = jQuery(this);
$this.hover( function() {
jQuery($this).stop().animate({opacity : 0.1}, 500);
}, function() {
jQuery($this).stop().animate({opacity : 1}, 500);
});
});
}
hover_overlay();
function hover_overlay_slide() {
jQuery('.video').hover( function() {
jQuery(this).stop().animate({opacity : 1}, 100);
}, function() {
jQuery(this).stop().animate({opacity : .9}, 100);
});
}
hover_overlay_slide();
function hover_overlay_images() {
jQuery('a img').hover( function() {
jQuery(this).stop().animate({opacity : 0.7}, 500);
}, function() {
jQuery(this).stop().animate({opacity : 1}, 500);
});
}
hover_overlay_images();
/*-----------------------------------------------------------------------------------*/
/* Portfolio Mini Flexible Slideshow
/*-----------------------------------------------------------------------------------*/
jQuery(document).ready(function() {
jQuery('.flexslider').each(function() {
var $this = jQuery(this);
$this.flexslider({
animation: "fade", //String: Select your animation type, "fade" or "slide"
slideDirection: "vertical", //String: Select the sliding direction, "horizontal" or "vertical"
slideshow: false, //Boolean: Animate slider automatically
slideshowSpeed: Math.floor(Math.random()*10001) + 3000, //Integer: Set the speed of the slideshow cycling, in milliseconds
animationDuration: 2000, //Integer: Set the speed of animations, in milliseconds
directionNav: false, //Boolean: Create navigation for previous/next navigation? (true/false)
controlNav: false, //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage
keyboardNav: false, //Boolean: Allow slider navigating via keyboard left/right keys
mousewheel: false, //Boolean: Allow slider navigating via mousewheel
prevText: "Previous", //String: Set the text for the "previous" directionNav item
nextText: "Next", //String: Set the text for the "next" directionNav item
pausePlay: false, //Boolean: Create pause/play dynamic element
pauseText: 'Pause', //String: Set the text for the "pause" pausePlay item
playText: 'Play', //String: Set the text for the "play" pausePlay item
randomize: false, //Boolean: Randomize slide order
slideToStart: 0, //Integer: The slide that the slider should start on. Array notation (0 = first slide)
animationLoop: true, //Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end
pauseOnAction: true, //Boolean: Pause the slideshow when interacting with control elements, highly recommended.
pauseOnHover: true, //Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering
controlsContainer: "", //Selector: Declare which container the navigation elements should be appended too. Default container is the flexSlider element. Example use would be ".flexslider-container", "#container", etc. If the given element is not found, the default action will be taken.
manualControls: "", //Selector: Declare custom control navigation. Example would be ".flex-control-nav li" or "#tabs-nav li img", etc. The number of elements in your controlNav should match the number of slides/tabs.
start: function(){}, //Callback: function(slider) - Fires when the slider loads the first slide
before: function(){}, //Callback: function(slider) - Fires asynchronously with each slider animation
after: function(){}, //Callback: function(slider) - Fires after each slider animation completes
end: function(){} //Callback: function(slider) - Fires when the slider reaches the last slide (asynchronous)
});
});
});
/*-----------------------------------------------------------------------------------*/
/* Scroll to Top by Andre Gagnon
/*-----------------------------------------------------------------------------------*/
jQuery(document).ready(function() {
jQuery(window).scroll(function () {
var y_scroll_pos = window.pageYOffset;
var scroll_pos_test = 50; // set to whatever you want it to be
if(y_scroll_pos > scroll_pos_test) {
jQuery('.top').fadeIn(1000);
jQuery('.iphone').children('.top').css('display', 'none !important');
} else { jQuery('.top').fadeOut(500);
}
});
jQuery('.top').click(function(){
jQuery('html, body').animate({scrollTop:0}, 500, 'easeOutCubic');
return false;
});
});
/*-----------------------------------------------------------------------------------*/
/* Top Widgets Drawer by Andre Gagnon
/*-----------------------------------------------------------------------------------*/
jQuery(function($) {
var height = $('#top_panel_content').height();
$('#top_panel_button').click(function() {
var docHeight = $(document).height();
var windowHeight = $(window).height();
var scrollPos = docHeight - windowHeight + height;
$('#top_panel_content').animate({ height: "toggle"}, 500, 'easeOutCubic');
$('#toggle_button').toggleClass("downarrow");
jQuery('#top_panel').removeClass('active');
jQuery(this).addClass('active');
});
});
/*-----------------------------------------------------------------------------------*/
/* Ajax Load Post
/*-----------------------------------------------------------------------------------*/
jQuery(document).ready(function($){
$.ajaxSetup({cache:false});
/* Declare Variables */
var ajaxouter = jQuery('#ajaxouter'); /* Outer Container (with data id = post id) */
var url = jQuery('#ajaxinner').attr('data-url'); /* Set the post ID from the outer container */
var $postId = null;
var $nextitem = null;
var $nextId = null;
var $prevId = null;
var $this = null;
var $state = 'closed';
$(".flexslider ul.slides li a").live('click', function(e){ e.preventDefault();
/*Set Function Variables */
$this = $(this);
$postId = $($this).attr('data-url');
$nextitem = $($this).closest('.portfolioitem').next('.portfolioitem').find('a');
$previtem = $($this).closest('.portfolioitem').prev('.portfolioitem').find('a');
$prevId = $($this).closest('.portfolioitem').prev('.portfolioitem').find('a').attr('data-url');
$nextId = $($this).closest('.portfolioitem').next('.portfolioitem').find('a').attr('data-url');
$('.ajaxloading').fadeIn(500);
if ( $.browser.msie && $.browser.version == '7.0') {
$('html,body').parent().animate({scrollTop: $('#loadingcontainer').offset().top}, 2000, 'easeOutCubic');
} else {
$('html,body').animate({scrollTop: $('#loadingcontainer').offset().top}, 2000, 'easeOutCubic');
}
if ($state !== 'closed'){
$('#ajaxcontainer').animate({ height: "toggle"}, 500, 'easeOutCubic');
}
ajaxouter.load(url, {
id: $postId
},
function() {
if ($state == 'closed'){
$('#ajaxcontainer').animate({ height: "toggle"}, 500, 'easeOutCubic');
/* If there's a previous */
if(typeof $prevId == 'string') {
$('a#prev-port').css('display', 'block');
} else {
$('a#prev-port').css('display', 'none');
}
/* If there's a Next*/
if(typeof $nextId == 'string') {
$('a#next-port').css('display', 'block');
} else {
$('a#next-port').css('display', 'none');
}
$state = 'open';
} else {
$('#ajaxcontainer').animate({ height: "toggle"}, 500, 'easeOutCubic');
/* If there's a previous */
if(typeof $prevId == 'string') {
$('a#prev-port').css('display', 'block');
} else {
$('a#prev-port').css('display', 'none');
}
/* If there's a Next*/
if(typeof $nextId == 'string') {
$('a#next-port').css('display', 'block');
} else {
$('a#next-port').css('display', 'none');
}
}
$('.ajaxloading').fadeOut(500);
}
);
return false;
});
jQuery('a#next-port').live('click', function(e){ e.preventDefault();
if(typeof $nextId == 'string') {
jQuery('.ajaxloading').fadeIn(500);
jQuery('#ajaxcontainer').animate({ height: "toggle"}, 500, 'easeOutCubic');
ajaxouter.load(url, { id: $nextId },
function() {
$this = $nextitem;
$previtem = jQuery($this).closest('.portfolioitem').prev('.portfolioitem').find('a');
$nextitem = jQuery($this).closest('.portfolioitem').next('.portfolioitem').find('a');
$prevId = jQuery($this).closest('.portfolioitem').prev('.portfolioitem').find('a').attr('data-url');
$nextId = jQuery($this).closest('.portfolioitem').next('.portfolioitem').find('a').attr('data-url');
/* If there's a Next*/
if(typeof $nextId == 'string') {
jQuery('a#next-port').css('display', 'block');
} else {
jQuery('a#next-port').css('display', 'none');
}
jQuery('#ajaxcontainer').animate({ height: "toggle"}, 500, 'easeOutCubic');
jQuery('.ajaxloading').fadeOut(500);
});
}
});
jQuery('a#prev-port').live('click', function(e){ e.preventDefault();
if(typeof $prevId == 'string') {
jQuery('.ajaxloading').fadeIn(500);
jQuery('#ajaxcontainer').animate({ height: "toggle"}, 500, 'easeOutCubic');
ajaxouter.load(url, { id: $prevId },
function() {
$this = $previtem;
$previtem = jQuery($this).closest('.portfolioitem').prev('.portfolioitem').find('a');
$nextitem = jQuery($this).closest('.portfolioitem').next('.portfolioitem').find('a');
$prevId = jQuery($this).closest('.portfolioitem').prev('.portfolioitem').find('a').attr('data-url');
$nextId = jQuery($this).closest('.portfolioitem').next('.portfolioitem').find('a').attr('data-url');
/* If there's a previous */
if(typeof $prevId == 'string') {
jQuery('a#prev-port').css('display', 'block');
} else {
jQuery('a#prev-port').css('display', 'none');
}
jQuery('#ajaxcontainer').animate({ height: "toggle"}, 500, 'easeOutCubic');
jQuery('.ajaxloading').fadeOut(500);
});
}
});
jQuery('a.portfolio-close').live('click', function(e){
e.preventDefault();
$state = 'closed';
if ( jQuery.browser.msie && jQuery.browser.version == '7.0' ) {
jQuery('html,body').parent().animate({scrollTop: jQuery('body').offset().top}, 2000, 'easeOutCubic');
} else {
jQuery('html,body').animate({scrollTop: jQuery('body').offset().top}, 2000, 'easeOutCubic');
}
jQuery('#ajaxcontainer').animate({ height: "toggle"}, 500, 'easeOutCubic', function(){
jQuery('.ajaxslider').remove(); // so videos stop playing
});
});
});
/*-----------------------------------------------------------------------------------*/
/* Filter Portfolio
/*-----------------------------------------------------------------------------------*/
jQuery(document).ready(function() {
jQuery('ul.filter a').click(function() {
jQuery(this).css('outline','none');
jQuery('ul.filter .active').removeClass('active');
jQuery(this).parent().addClass('active');
var filterVal = jQuery(this).text().toLowerCase().replace(' ','-').replace(' ','-').replace(' ','-').replace(' ','-').replace(' ','-').replace(' ','-');
if(jQuery(this).hasClass('filterall')) {
jQuery('.portfolioitem .disable').stop().animate({opacity: 0}, 500, function(){
jQuery(this).css('display', 'none');
});
} else {
jQuery('.portfolioitem .disable').each(function() {
if(!jQuery(this).hasClass(filterVal)) {
jQuery(this).css('display', 'block');
jQuery(this).stop().animate({opacity: .95}, 500);
} else {
jQuery(this).stop().animate({opacity: 0}, 500, function(){jQuery(this).css('display', 'none');});
}
});
}
return false;
});
});
/*-----------------------------------------------------------------------------------*/
/* Portfolio Flexible Slider
/*-----------------------------------------------------------------------------------*/
jQuery('.projectslideshow').wmuSlider({
animation: 'fade',
animationDuration: 600,
slideshow: true,
slideshowSpeed: 7000,
slideToStart: 0,
navigationControl: true,
paginationControl: true,
previousText: 'Previous',
nextText: 'Next',
touch: true,
slide: 'span'
});
/*-----------------------------------------------------------------------------------*/
/* FitVid Fluid Video
/*-----------------------------------------------------------------------------------*/
jQuery(document).ready(function(){
jQuery(".videocontainer").fitVids();
});
/*-----------------------------------------------------------------------------------*/
/* Coda Slider
/*-----------------------------------------------------------------------------------*/
if(jQuery() .codaSlider){
jQuery('#coda-slider-1').codaSlider({
dynamicArrows: false,
dynamicTabs: false
});
};
// ---------------------------------------------
// wire up the contact me link to bring down the top drawer
// ---------------------------------------------
var lis = document.getElementsByTagName('li');
for (var i = 0; i < lis.length; i++) {
if (jQuery(lis[i]).text() == "Contact Me") {
lis[i].style.cursor = "pointer";
var height = jQuery('#top_panel_content').height();
lis[i].addEventListener("click", function () {
var docHeight = jQuery(document).height();
var windowHeight = jQuery(window).height();
var scrollPos = docHeight - windowHeight + height;
jQuery('#top_panel_content').animate({ height: "toggle"}, 500, 'easeOutCubic');
jQuery('#toggle_button').toggleClass("downarrow");
jQuery('#top_panel').removeClass('active');
jQuery(this).addClass('active');
}, false);
}
}
// a convenience function for parsing string namespaces and
// automatically generating nested namespaces
function Namespace( ns, ns_string ) {
var parts = ns_string.split('.'),
parent = ns,
pl, i;
if (parts[0] == "myApp") {
parts = parts.slice(1);
}
pl = parts.length;
for (i = 0; i < pl; i++) {
//create a property if it doesnt exist
if (typeof parent[parts[i]] == 'undefined') {
parent[parts[i]] = {};
}
parent = parent[parts[i]];
}
return parent;
}
backChannelIFrame = document.getElementById("backchannel");
// -------------------------------------------------------
// JSFoundation class for responding to web service updates via an iframe
// -------------------------------------------------------
var JSFoundation = JSFoundation || {};
Namespace(JSFoundation, 'WebServiceClient');
JSFoundation.WebServiceClient = function(/* function */ callback) {
backChannelIFrame.addEventListener("load", function () {
var retStatus;
if (this.contentDocument.body.innerText != undefined) {
try {
retStatus = JSON.parse(this.contentDocument.body.innerText);
}
catch (e) {
console.log(e.message);
}
}
if (this.contentDocument.body.textContent != undefined) {
try {
retStatus = JSON.parse(this.contentDocument.body.textContent);
}
catch (e) {
console.log(e.message);
}
}
else {
// Error condition.
}
callback.call(null, retStatus);
}, false);
};
// ---------------------------------------------------------------------
// a web service client to respond to the contact me form on the homepage
// ---------------------------------------------------------------------
var wsc = new JSFoundation.WebServiceClient(function(retStatus) {
if (retStatus.operation == "ContactMeEmail") {
// update the "waiting for response" message
var coverDiv = document.getElementById("coverdiv");
var message = document.createElement("div");
message.style.top = "0px";
message.style.left = "50%";
message.style.width = "300px";
message.style.height = "300px";
message.style.marginLeft = "-150px";
message.style.position = "absolute";
message.style.color = "#ffffff";
message.style.padding = "10px";
var button = document.createElement("button");
if (retStatus.status == "OK") {
message.innerHTML = "Your request was successfully processed.
";
button.innerText = "Ok";
button.addEventListener("click", function() {
var docHeight = jQuery(document).height();
var windowHeight = jQuery(window).height();
var scrollPos = docHeight - windowHeight + height;
jQuery('#top_panel_content').animate({ height: "toggle"}, 500, 'easeOutCubic');
jQuery('#toggle_button').toggleClass("downarrow");
jQuery('#top_panel').removeClass('active');
jQuery(this).addClass('active');
var commentfield = document.getElementById("contactcomment");
commentfield.value = "";
var parentDiv = document.getElementById("top_panel");
parentDiv.removeChild(coverDiv);
}, false);
}
if (retStatus.status == "ERROR") {
message.innerHTML = "Error: " + retStatus.errortext + "
";
button.innerText = "Retry";
button.addEventListener("click", function() {
/*var docHeight = jQuery(document).height();
var windowHeight = jQuery(window).height();
var scrollPos = docHeight - windowHeight + height;
jQuery('#top_panel_content').animate({ height: "toggle"}, 500, 'easeOutCubic');
jQuery('#toggle_button').toggleClass("downarrow");
jQuery('#top_panel').removeClass('active');
jQuery(this).addClass('active');*/
document.body.removeChild(coverDiv);
}, false);
}
message.appendChild(button);
coverDiv.removeChild(coverDiv.firstChild);
coverDiv.appendChild(message);
}
});
// A web service for getting the twitter feeds
var twitterclient = new JSFoundation.WebServiceClient(function (retStatus) {
if (retStatus.operation == "TwitterUserTimeline") {
BlakesTwitterCallback(retStatus.results.tweets);
BlakesTwitterCallback_Light(retStatus.results.tweets);
}
});
backChannelIFrame.src = "http://blakesblog.com/twitter_timeline.php";
// -------------------------------------------------------------------------
// animation function for waiting for response from contact me web service
// -------------------------------------------------------------------------
function processEmailUI() {
var parentDiv = document.getElementById("top_panel"),
topPanelButton = document.getElementById("top_panel_button"),
coverDiv = document.createElement("div"),
newHeight = parentDiv.scrollHeight + topPanelButton.scrollHeight;
coverDiv.className = "coverDiv";
coverDiv.style.top = "0px";
coverDiv.style.left = "0px";
coverDiv.style.width = parentDiv.scrollWidth + "px";
coverDiv.style.height = newHeight + "px";
coverDiv.style.opacity = ".75";
coverDiv.style.background = "#000000";
coverDiv.style.position = "absolute";
coverDiv.id = "coverdiv";
var spinner = document.createElement("img");
spinner.src = 'http://blakesblog.com/wp-content/themes/blakesblog_v90_1/images/loading-dark.gif';
spinner.style.top = "50%";
spinner.style.left = "50%";
spinner.style.marginTop = "-12px";
spinner.style.marginLeft = "-12px";
spinner.style.position = "absolute";
coverDiv.appendChild(spinner);
var divs = document.getElementsByTagName("div");
parentDiv.appendChild(coverDiv);
}
/*-----------------------------------------------------------------------------------*/
/* Form Validation
/*-----------------------------------------------------------------------------------*/
jQuery(document).ready(function(){
jQuery("#contactform").validate();
jQuery("#quoteform").validate();
jQuery("#quickform").validate({
submitHandler: function(form) {
form.submit();
processEmailUI();
},
errorPlacement: function(error, element) {
var elementid = element.attr('id');
var divid = elementid + "label";
var label = document.getElementById(divid);
if (label !== null) {
label.style.color = "#ff0000";
}
},
errorElement: "span"
});
jQuery("#commentsubmit").validate();
var shadowify = function (e) {
var color = jQuery(e).css('color'),
size = jQuery(e).css('font-size');
// Got Hex color? Modify with: http://stackoverflow.com/questions/1740700/get-hex-value-rather-than-rgb-value-using-jquery
if ( color.search('rgb') == -1 )
return;
var rgba = color.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))?\)$/);
//jQuery(e).css('text-shadow', '0 0 1px rgba(0,0,0,1)');
jQuery(e).css('-webkit-font-smoothing: antialiased');
// To use calculated shadow of say, 1/15th of the font height
//var fsize = size.match(/(\d+)px/);
//jQuery(e).css('text-shadow', '0 0 '+(fsize[1]/24)+'px rgba('+rgba[1]+','+rgba[2]+','+rgba[3]+',1)')
}
if(navigator.platform.indexOf('Win') != -1) {
jQuery('.darkbubble, h1, h3, h2').each(function(){
shadowify(this);
});
}
//^ Your appropriately targeted list of elements here ^
});
// truncating text to fit layout.
jQuery('.small-blog-excerpt').dotdotdot();
jQuery('.top-post-excerpt').dotdotdot({
height: 80
});
jQuery('.small-blog-title').dotdotdot({
height: 50
});
jQuery('.top-post-title').dotdotdot();
jQuery('.aboutme_excerpt').dotdotdot();