2011-09-18 11:50:23 +00:00
|
|
|
function getNav() {
|
2011-09-21 12:48:38 +00:00
|
|
|
var mobileNav = $('nav[role=navigation] fieldset[role=search]').after('<fieldset class="mobile-nav"></fieldset>').next().append('<select></select>');
|
2011-06-16 02:50:01 +00:00
|
|
|
mobileNav.children('select').append('<option value="">Navigate…</option>');
|
2011-09-25 14:14:50 +00:00
|
|
|
$('ul[role=main-navigation]').addClass('main-navigation');
|
2011-09-21 12:48:38 +00:00
|
|
|
$('ul.main-navigation a').each(function(link) {
|
2011-12-10 18:45:03 +00:00
|
|
|
mobileNav.children('select').append('<option value="'+link.href+'">» '+link.text+'</option>');
|
|
|
|
});
|
|
|
|
$('ul.subscription a').each(function(link) {
|
|
|
|
mobileNav.children('select').append('<option value="'+link.href+'">» '+link.text+'</option>');
|
2011-06-07 20:12:46 +00:00
|
|
|
});
|
2011-09-18 11:50:23 +00:00
|
|
|
mobileNav.children('select').bind('change', function(event) {
|
2011-09-26 12:41:39 +00:00
|
|
|
if (event.target.value) { window.location.href = event.target.value; }
|
2011-06-07 20:12:46 +00:00
|
|
|
});
|
|
|
|
}
|
2011-09-18 11:50:23 +00:00
|
|
|
|
2011-06-07 20:12:46 +00:00
|
|
|
function addSidebarToggler() {
|
2011-09-26 02:30:55 +00:00
|
|
|
if(!$('body').hasClass('sidebar-footer')) {
|
|
|
|
$('#content').append('<span class="toggle-sidebar"></span>');
|
|
|
|
$('.toggle-sidebar').bind('click', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
if ($('body').hasClass('collapse-sidebar')) {
|
|
|
|
$('body').removeClass('collapse-sidebar');
|
|
|
|
} else {
|
|
|
|
$('body').addClass('collapse-sidebar');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2011-09-21 12:48:38 +00:00
|
|
|
var sections = $('aside.sidebar > section');
|
2011-09-18 11:50:23 +00:00
|
|
|
if (sections.length > 1) {
|
2011-07-13 15:57:44 +00:00
|
|
|
sections.each(function(section, index){
|
2011-09-18 11:50:23 +00:00
|
|
|
if ((sections.length >= 3) && index % 3 === 0) {
|
2011-07-13 15:57:44 +00:00
|
|
|
$(section).addClass("first");
|
|
|
|
}
|
2011-09-18 11:50:23 +00:00
|
|
|
var count = ((index +1) % 2) ? "odd" : "even";
|
2011-07-13 15:57:44 +00:00
|
|
|
$(section).addClass(count);
|
|
|
|
});
|
|
|
|
}
|
2011-09-21 12:48:38 +00:00
|
|
|
if (sections.length >= 3){ $('aside.sidebar').addClass('thirds'); }
|
2011-06-07 20:12:46 +00:00
|
|
|
}
|
2011-09-18 11:50:23 +00:00
|
|
|
|
2011-06-07 20:12:46 +00:00
|
|
|
function testFeatures() {
|
|
|
|
var features = ['maskImage'];
|
2011-09-18 11:50:23 +00:00
|
|
|
$(features).map(function(feature) {
|
2011-06-08 22:58:00 +00:00
|
|
|
if (Modernizr.testAllProps(feature)) {
|
2011-06-07 20:12:46 +00:00
|
|
|
$('html').addClass(feature);
|
|
|
|
} else {
|
|
|
|
$('html').addClass('no-'+feature);
|
|
|
|
}
|
|
|
|
});
|
2011-06-08 22:58:00 +00:00
|
|
|
if ("placeholder" in document.createElement("input")) {
|
|
|
|
$('html').addClass('placeholder');
|
|
|
|
} else {
|
|
|
|
$('html').addClass('no-placeholder');
|
|
|
|
}
|
2011-06-07 20:12:46 +00:00
|
|
|
}
|
|
|
|
|
2011-09-18 11:50:23 +00:00
|
|
|
function addCodeLineNumbers() {
|
2011-09-26 12:41:39 +00:00
|
|
|
if (navigator.appName === 'Microsoft Internet Explorer') { return; }
|
2011-09-18 11:50:23 +00:00
|
|
|
$('div.gist-highlight').each(function(code) {
|
|
|
|
var tableStart = '<table><tbody><tr><td class="gutter">',
|
|
|
|
lineNumbers = '<pre class="line-numbers">',
|
|
|
|
tableMiddle = '</pre></td><td class="code">',
|
|
|
|
tableEnd = '</td></tr></tbody></table>',
|
2011-09-27 05:57:45 +00:00
|
|
|
count = $('.line', code).length;
|
2011-09-18 11:50:23 +00:00
|
|
|
for (var i=1;i<=count; i++) {
|
|
|
|
lineNumbers += '<span class="line-number">'+i+'</span>\n';
|
2011-06-07 20:12:46 +00:00
|
|
|
}
|
2011-09-18 11:50:23 +00:00
|
|
|
var table = tableStart + lineNumbers + tableMiddle + '<pre>'+$('pre', code).html()+'</pre>' + tableEnd;
|
2011-06-07 20:12:46 +00:00
|
|
|
$(code).html(table);
|
|
|
|
});
|
|
|
|
}
|
2011-06-13 20:41:03 +00:00
|
|
|
|
|
|
|
function flashVideoFallback(){
|
|
|
|
var flashplayerlocation = "/assets/jwplayer/player.swf",
|
2011-09-18 11:50:23 +00:00
|
|
|
flashplayerskin = "/assets/jwplayer/glow/glow.xml";
|
2011-06-13 20:41:03 +00:00
|
|
|
$('video').each(function(video){
|
|
|
|
video = $(video);
|
2011-09-26 12:41:39 +00:00
|
|
|
if (!Modernizr.video.h264 && swfobject.getFlashPlayerVersion() || window.location.hash.indexOf("flash-test") !== -1){
|
2011-09-18 11:50:23 +00:00
|
|
|
video.children('source[src$=mp4]').first().map(function(source){
|
2011-06-13 20:41:03 +00:00
|
|
|
var src = $(source).attr('src'),
|
2011-09-18 11:50:23 +00:00
|
|
|
id = 'video_'+Math.round(1 + Math.random()*(100000)),
|
|
|
|
width = video.attr('width'),
|
|
|
|
height = parseInt(video.attr('height'), 10) + 30;
|
|
|
|
video.after('<div class="flash-video"><div><div id='+id+'>');
|
2011-06-13 20:41:03 +00:00
|
|
|
swfobject.embedSWF(flashplayerlocation, id, width, height + 30, "9.0.0",
|
|
|
|
{ file : src, image : video.attr('poster'), skin : flashplayerskin } ,
|
2011-09-18 11:50:23 +00:00
|
|
|
{ movie : src, wmode : "opaque", allowfullscreen : "true" }
|
|
|
|
);
|
2011-06-13 20:41:03 +00:00
|
|
|
});
|
|
|
|
video.remove();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2011-09-18 11:50:23 +00:00
|
|
|
function wrapFlashVideos() {
|
|
|
|
$('object').each(function(object) {
|
2011-06-13 20:41:03 +00:00
|
|
|
object = $(object);
|
2011-09-24 10:43:44 +00:00
|
|
|
if ( $('param[name=movie]', object).length ) {
|
2011-06-13 20:41:03 +00:00
|
|
|
var wrapper = object.before('<div class="flash-video"><div>').previous();
|
|
|
|
$(wrapper).children().append(object);
|
|
|
|
}
|
|
|
|
});
|
2011-09-18 11:50:23 +00:00
|
|
|
$('iframe[src*=vimeo],iframe[src*=youtube]').each(function(iframe) {
|
2011-06-13 20:41:03 +00:00
|
|
|
iframe = $(iframe);
|
|
|
|
var wrapper = iframe.before('<div class="flash-video"><div>').previous();
|
|
|
|
$(wrapper).children().append(iframe);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2011-09-26 12:19:47 +00:00
|
|
|
function renderDeliciousLinks(items) {
|
|
|
|
var output = "<ul>";
|
|
|
|
for (var i=0,l=items.length; i<l; i++) {
|
|
|
|
output += '<li><a href="' + items[i].u + '" title="Tags: ' + items[i].t.join(', ') + '">' + items[i].d + '</a></li>';
|
|
|
|
}
|
|
|
|
output += "</ul>";
|
|
|
|
$('#delicious').html(output);
|
|
|
|
}
|
|
|
|
|
2011-09-18 11:50:23 +00:00
|
|
|
$.domReady(function() {
|
2011-06-07 20:12:46 +00:00
|
|
|
testFeatures();
|
2011-06-13 20:41:03 +00:00
|
|
|
wrapFlashVideos();
|
2011-06-24 21:17:35 +00:00
|
|
|
flashVideoFallback();
|
2011-06-16 02:50:01 +00:00
|
|
|
addCodeLineNumbers();
|
2011-06-07 20:12:46 +00:00
|
|
|
getNav();
|
|
|
|
addSidebarToggler();
|
|
|
|
});
|
|
|
|
|
|
|
|
// iOS scaling bug fix
|
|
|
|
// Rewritten version
|
|
|
|
// By @mathias, @cheeaun and @jdalton
|
|
|
|
// Source url: https://gist.github.com/901295
|
|
|
|
(function(doc) {
|
|
|
|
var addEvent = 'addEventListener',
|
2011-09-18 11:50:23 +00:00
|
|
|
type = 'gesturestart',
|
|
|
|
qsa = 'querySelectorAll',
|
|
|
|
scales = [1, 1],
|
|
|
|
meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : [];
|
2011-06-07 20:12:46 +00:00
|
|
|
function fix() {
|
|
|
|
meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1];
|
|
|
|
doc.removeEventListener(type, fix, true);
|
|
|
|
}
|
|
|
|
if ((meta = meta[meta.length - 1]) && addEvent in doc) {
|
|
|
|
fix();
|
2011-09-18 11:50:23 +00:00
|
|
|
scales = [0.25, 1.6];
|
2011-06-07 20:12:46 +00:00
|
|
|
doc[addEvent](type, fix, true);
|
|
|
|
}
|
|
|
|
}(document));
|
2011-06-13 20:41:03 +00:00
|
|
|
|
|
|
|
/*! SWFObject v2.2 modified by Brandon Mathis to contain only what is necessary to dynamically embed flash objects
|
|
|
|
* Uncompressed source in javascripts/libs/swfobject-dynamic.js
|
|
|
|
* <http://code.google.com/p/swfobject/>
|
|
|
|
released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
|
|
|
|
*/
|
|
|
|
var swfobject=function(){function s(a,b,d){var q,k=n(d);if(g.wk&&g.wk<312)return q;if(k){if(typeof a.id==l)a.id=d;if(g.ie&&g.win){var e="",c;for(c in a)if(a[c]!=Object.prototype[c])c.toLowerCase()=="data"?b.movie=a[c]:c.toLowerCase()=="styleclass"?e+=' class="'+a[c]+'"':c.toLowerCase()!="classid"&&(e+=" "+c+'="'+a[c]+'"');c="";for(var f in b)b[f]!=Object.prototype[f]&&(c+='<param name="'+f+'" value="'+b[f]+'" />');k.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+e+">"+c+
|
|
|
|
"</object>";q=n(a.id)}else{f=i.createElement(o);f.setAttribute("type",m);for(var h in a)a[h]!=Object.prototype[h]&&(h.toLowerCase()=="styleclass"?f.setAttribute("class",a[h]):h.toLowerCase()!="classid"&&f.setAttribute(h,a[h]));for(e in b)b[e]!=Object.prototype[e]&&e.toLowerCase()!="movie"&&(a=f,c=e,h=b[e],d=i.createElement("param"),d.setAttribute("name",c),d.setAttribute("value",h),a.appendChild(d));k.parentNode.replaceChild(f,k);q=f}}return q}function n(a){var b=null;try{b=i.getElementById(a)}catch(d){}return b}
|
|
|
|
function t(a){var b=g.pv,a=a.split(".");a[0]=parseInt(a[0],10);a[1]=parseInt(a[1],10)||0;a[2]=parseInt(a[2],10)||0;return b[0]>a[0]||b[0]==a[0]&&b[1]>a[1]||b[0]==a[0]&&b[1]==a[1]&&b[2]>=a[2]?!0:!1}function u(a){return/[\\\"<>\.;]/.exec(a)!=null&&typeof encodeURIComponent!=l?encodeURIComponent(a):a}var l="undefined",o="object",m="application/x-shockwave-flash",v=window,i=document,j=navigator,g=function(){var a=typeof i.getElementById!=l&&typeof i.getElementsByTagName!=l&&typeof i.createElement!=l,
|
|
|
|
b=j.userAgent.toLowerCase(),d=j.platform.toLowerCase(),g=d?/win/.test(d):/win/.test(b),d=d?/mac/.test(d):/mac/.test(b),b=/webkit/.test(b)?parseFloat(b.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):!1,k=!+"\u000b1",e=[0,0,0],c=null;if(typeof j.plugins!=l&&typeof j.plugins["Shockwave Flash"]==o){if((c=j.plugins["Shockwave Flash"].description)&&!(typeof j.mimeTypes!=l&&j.mimeTypes[m]&&!j.mimeTypes[m].enabledPlugin))k=!1,c=c.replace(/^.*\s+(\S+\s+\S+$)/,"$1"),e[0]=parseInt(c.replace(/^(.*)\..*$/,"$1"),
|
|
|
|
10),e[1]=parseInt(c.replace(/^.*\.(.*)\s.*$/,"$1"),10),e[2]=/[a-zA-Z]/.test(c)?parseInt(c.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}else if(typeof v.ActiveXObject!=l)try{var f=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if(f&&(c=f.GetVariable("$version")))k=!0,c=c.split(" ")[1].split(","),e=[parseInt(c[0],10),parseInt(c[1],10),parseInt(c[2],10)]}catch(h){}return{w3:a,pv:e,wk:b,ie:k,win:g,mac:d}}();return{embedSWF:function(a,b,d,i,k,e,c,f,h){var j={success:!1,id:b};if(g.w3&&!(g.wk&&g.wk<312)&&
|
|
|
|
a&&b&&d&&i&&k){d+="";i+="";var p={};if(f&&typeof f===o)for(var m in f)p[m]=f[m];p.data=a;p.width=d;p.height=i;a={};if(c&&typeof c===o)for(var n in c)a[n]=c[n];if(e&&typeof e===o)for(var r in e)typeof a.flashvars!=l?a.flashvars+="&"+r+"="+e[r]:a.flashvars=r+"="+e[r];if(t(k))b=s(p,a,b),j.success=!0,j.ref=b}h&&h(j)},ua:g,getFlashPlayerVersion:function(){return{major:g.pv[0],minor:g.pv[1],release:g.pv[2]}},hasFlashPlayerVersion:t,createSWF:function(a,b,d){if(g.w3)return s(a,b,d)},getQueryParamValue:function(a){var b=
|
|
|
|
i.location.search||i.location.hash;if(b){/\?/.test(b)&&(b=b.split("?")[1]);if(a==null)return u(b);for(var b=b.split("&"),d=0;d<b.length;d++)if(b[d].substring(0,b[d].indexOf("="))==a)return u(b[d].substring(b[d].indexOf("=")+1))}return""}}}();
|
2011-12-10 18:45:03 +00:00
|
|
|
|