1function getNav() { 2 var mobileNav = $('nav[role=navigation] fieldset[role=search]').after('<fieldset class="mobile-nav"></fieldset>').next().append('<select></select>'); 3 mobileNav.children('select').append('<option value="">Navigate…</option>'); 4 $('ul[role=main-navigation]').addClass('main-navigation'); 5 $('ul.main-navigation a').each(function(link) { 6 mobileNav.children('select').append('<option value="'+link.href+'">» '+link.text+'</option>'); 7 }); 8 $('ul.subscription a').each(function(link) { 9 mobileNav.children('select').append('<option value="'+link.href+'">» '+link.text+'</option>'); 10 }); 11 mobileNav.children('select').bind('change', function(event) { 12 if (event.target.value) { window.location.href = event.target.value; } 13 }); 14} 15 16function addSidebarToggler() { 17 if(!$('body').hasClass('sidebar-footer')) { 18 $('#content').append('<span class="toggle-sidebar"></span>'); 19 $('.toggle-sidebar').bind('click', function(e) { 20 e.preventDefault(); 21 if ($('body').hasClass('collapse-sidebar')) { 22 $('body').removeClass('collapse-sidebar'); 23 } else { 24 $('body').addClass('collapse-sidebar'); 25 } 26 }); 27 } 28 var sections = $('aside.sidebar > section'); 29 if (sections.length > 1) { 30 sections.each(function(section, index){ 31 if ((sections.length >= 3) && index % 3 === 0) { 32 $(section).addClass("first"); 33 } 34 var count = ((index +1) % 2) ? "odd" : "even"; 35 $(section).addClass(count); 36 }); 37 } 38 if (sections.length >= 3){ $('aside.sidebar').addClass('thirds'); } 39} 40 41function testFeatures() { 42 var features = ['maskImage']; 43 $(features).map(function(feature) { 44 if (Modernizr.testAllProps(feature)) { 45 $('html').addClass(feature); 46 } else { 47 $('html').addClass('no-'+feature); 48 } 49 }); 50 if ("placeholder" in document.createElement("input")) { 51 $('html').addClass('placeholder'); 52 } else { 53 $('html').addClass('no-placeholder'); 54 } 55} 56 57function addCodeLineNumbers() { 58 if (navigator.appName === 'Microsoft Internet Explorer') { return; } 59 $('div.gist-highlight').each(function(code) { 60 var tableStart = '<table><tbody><tr><td class="gutter">', 61 lineNumbers = '<pre class="line-numbers">', 62 tableMiddle = '</pre></td><td class="code">', 63 tableEnd = '</td></tr></tbody></table>', 64 count = $('.line', code).length; 65 for (var i=1;i<=count; i++) { 66 lineNumbers += '<span class="line-number">'+i+'</span>\n'; 67 } 68 var table = tableStart + lineNumbers + tableMiddle + '<pre>'+$('pre', code).html()+'</pre>' + tableEnd; 69 $(code).html(table); 70 }); 71} 72 73function flashVideoFallback(){ 74 var flashplayerlocation = "/assets/jwplayer/player.swf", 75 flashplayerskin = "/assets/jwplayer/glow/glow.xml"; 76 $('video').each(function(video){ 77 video = $(video); 78 if (!Modernizr.video.h264 && swfobject.getFlashPlayerVersion() || window.location.hash.indexOf("flash-test") !== -1){ 79 video.children('source[src$=mp4]').first().map(function(source){ 80 var src = $(source).attr('src'), 81 id = 'video_'+Math.round(1 + Math.random()*(100000)), 82 width = video.attr('width'), 83 height = parseInt(video.attr('height'), 10) + 30; 84 video.after('<div class="flash-video"><div><div id='+id+'>'); 85 swfobject.embedSWF(flashplayerlocation, id, width, height + 30, "9.0.0", 86 { file : src, image : video.attr('poster'), skin : flashplayerskin } , 87 { movie : src, wmode : "opaque", allowfullscreen : "true" } 88 ); 89 }); 90 video.remove(); 91 } 92 }); 93} 94 95function wrapFlashVideos() { 96 $('object').each(function(object) { 97 object = $(object); 98 if ( $('param[name=movie]', object).length ) { 99 var wrapper = object.before('<div class="flash-video"><div>').previous(); 100 $(wrapper).children().append(object); 101 } 102 }); 103 $('iframe[src*=vimeo],iframe[src*=youtube]').each(function(iframe) { 104 iframe = $(iframe); 105 var wrapper = iframe.before('<div class="flash-video"><div>').previous(); 106 $(wrapper).children().append(iframe); 107 }); 108} 109 110function renderDeliciousLinks(items) { 111 var output = "<ul>"; 112 for (var i=0,l=items.length; i<l; i++) { 113 output += '<li><a href="' + items[i].u + '" title="Tags: ' + (items[i].t == "" ? "" : items[i].t.join(', ')) + '">' + items[i].d + '</a></li>'; 114 } 115 output += "</ul>"; 116 $('#delicious').html(output); 117} 118 119$.domReady(function() { 120 testFeatures(); 121 wrapFlashVideos(); 122 flashVideoFallback(); 123 addCodeLineNumbers(); 124 getNav(); 125 addSidebarToggler(); 126}); 127 128// iOS scaling bug fix 129// Rewritten version 130// By @mathias, @cheeaun and @jdalton 131// Source url: https://gist.github.com/901295 132(function(doc) { 133 var addEvent = 'addEventListener', 134 type = 'gesturestart', 135 qsa = 'querySelectorAll', 136 scales = [1, 1], 137 meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : []; 138 function fix() { 139 meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1]; 140 doc.removeEventListener(type, fix, true); 141 } 142 if ((meta = meta[meta.length - 1]) && addEvent in doc) { 143 fix(); 144 scales = [0.25, 1.6]; 145 doc[addEvent](type, fix, true); 146 } 147}(document)); 148 149/*! SWFObject v2.2 modified by Brandon Mathis to contain only what is necessary to dynamically embed flash objects 150 * Uncompressed source in javascripts/libs/swfobject-dynamic.js 151 * <http://code.google.com/p/swfobject/> 152 released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 153*/ 154var 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+ 155"</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} 156function 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]>
156a[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, 157b=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"), 15810),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)&& 159a&&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= 160i.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""}}}(); 161
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.