function getNav(){
var mobileNav = $('body > nav fieldset[role=site-search]').after('<fieldset role="mobile-nav"></fieldset>').next().append('<select></select>');
mobileNav.children('select').append('<option value="">Navigate…</option>');
$($('body > nav ul[role=main-nav] a')).each(function(link) {
mobileNav.children('select').append('<option value="'+link.href+'">• '+link.text+'</option>')
});
mobileNav.children('select').bind('change', function(event){
if (event.target.value) window.location.href = event.target.value;
});
}
function addSidebarToggler() {
$('#articles').before('<a href="#" class="toggle-sidebar">»</a>').previous().bind('click', function(e){
e.preventDefault();
if($('body').hasClass('collapse-sidebar')){
$('body').removeClass('collapse-sidebar');
e.target.innerHTML = '»';
} else {
$('body').addClass('collapse-sidebar');
e.target.innerHTML = '«';
}
});
}
function testFeatures() {
var features = ['maskImage'];
$(features).map(function(feature){
if (Modernizr.testAllProps(feature)) {
$('html').addClass(feature);
} else {
$('html').addClass('no-'+feature);
}
});
if ("placeholder" in document.createElement("input")) {
$('html').addClass('placeholder');
} else {
$('html').addClass('no-placeholder');
}
}
function addCodeLineNumbers(){
if (navigator.appName == 'Microsoft Internet Explorer') { return }
$('div.highlight pre code').each(function(el){ addDivLines(el); });
$('div.highlight, div.gist-highlight').each(function(code){
var tableStart = '<table cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter">';
var lineNumbers = '<pre class="line-numbers">';
var tableMiddle = '</pre></td><td class="code" width="100%">';
var tableEnd = '</td></tr></tbody></table>';
var count = $('div.line', code).length;
for (i=1;i<=count; i++){
lineNumbers += '<span class="line">'+i+'</span>\n';
}
table = tableStart + lineNumbers + tableMiddle + '<pre>'+$('pre', code).html()+'</pre>' + tableEnd;
$(code).html(table);
});
}
function addDivLines(el){
var content = $(el).html();
var lines = content.replace(/\s*$/g, '').split(/\n/);
var count = lines.length;
$(lines).each(function(line, index){
if(line == '') line = ' ';
lines[index] = '<div class="line">' + line + '</div>';
});
$(el).html(lines.join(''));
}
function flashVideoFallback(){
var flashplayerlocation = "/assets/jwplayer/player.swf",
flashplayerskin = "/assets/jwplayer/glow/glow.xml";
$('video').each(function(video){
video = $(video);
if(!Modernizr.video.h264 && swfobject.getFlashPlayerVersion() || window.location.hash.indexOf("flash-test") != -1){
video.children('source[src$=mp4]').first().map(function(source){;
var src = $(source).attr('src'),
id = 'video_'+Math.round(1 + Math.random()*(100000)),
width = video.attr('width'),
height = parseInt(video.attr('height')) + 30;
video.after('<div class="flash-video"><div><div id='+id+'>');
swfobject.embedSWF(flashplayerlocation, id, width, height + 30, "9.0.0",
{ file : src, image : video.attr('poster'), skin : flashplayerskin } ,
{ movie : src, wmode : "opaque", allowfullscreen : "true" });
});
video.remove();
}
});
}
function wrapFlashVideos(){
$('object').each(function(object){
object = $(object);
if(object.children('param[name=movie]')){
var wrapper = object.before('<div class="flash-video"><div>').previous();
$(wrapper).children().append(object);
}
});
$('iframe[src*=vimeo],iframe[src*=youtube]').each(function(iframe){
iframe = $(iframe);
var wrapper = iframe.before('<div class="flash-video"><div>').previous();
$(wrapper).children().append(iframe);
});
}
$.domReady(function(){
testFeatures();