function getNav(){ var fieldset = $('body > nav fieldset[role=site-search]').after('
').next(); var select = $(fieldset).append('').children(); select.append(''); $($('body > nav ul[role=main-nav] a').concat($('body > nav ul[role=subscription] a'))).each(function(link) { select.append('') }); select.bind('change', function(event){ if (select.val()) window.location.href = select.val(); }); } function addSidebarToggler() { $('#articles').before('»').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); } }); } function addDivLines(){ $('div.highlight pre code').each(function(el){ var content = bonzo(el).html(); var lines = content.split('\n'); var count = lines.length; bonzo(lines).each(function(line, index){ if(line == '') line = ' '; lines[index] = '
' + line + '
'; }); $(el).html(lines.join('')); }); } function preToTable(){ $('div.highlight').each(function(code){ var tableStart = '
'; var lineNumbers = '
';
    var tableMiddle = '
'; var tableEnd = '
'; var count = $('div.line', code).length; for (i=1;i<=count; i++){ lineNumbers += ''+i+'\n'; } table = tableStart + lineNumbers + tableMiddle + '
'+$('pre', code).html()+'
' + tableEnd; $(code).html(table); }); } $.domReady(function(){ testFeatures(); addDivLines(); preToTable(); 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', type = 'gesturestart', qsa = 'querySelectorAll', scales = [1, 1], meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : []; 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(); scales = [.25, 1.6]; doc[addEvent](type, fix, true); } }(document));