1. Some general styling improvements especially for syntax and navigation

2. JS line numbering now supports embedded gists
3. Added a favicon
This commit is contained in:
Brandon Mathis 2011-06-15 22:50:01 -04:00
parent ab29d45ae8
commit b0405cc3c2
7 changed files with 106 additions and 59 deletions

View file

@ -1,12 +1,11 @@
function getNav(){
var fieldset = $('body > nav fieldset[role=site-search]').after('<fieldset role="mobile-nav"></fieldset>').next();
var select = $(fieldset).append('<select></select>').children();
select.append('<option value="">Navigate&hellip;</option>');
$($('body > nav ul[role=main-nav] a').concat($('body > nav ul[role=subscription] a'))).each(function(link) {
select.append('<option value="'+link.href+'">&bull; '+link.text+'</option>')
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&hellip;</option>');
$($('body > nav ul[role=main-nav] a')).each(function(link) {
mobileNav.children('select').append('<option value="'+link.href+'">&bull; '+link.text+'</option>')
});
select.bind('change', function(event){
if (select.val()) window.location.href = select.val();
mobileNav.children('select').bind('change', function(event){
if (event.target.value) window.location.href = event.target.value;
});
}
function addSidebarToggler() {
@ -37,20 +36,10 @@ function testFeatures() {
}
}
function addDivLines(){
$('div.highlight pre code').each(function(el){
var content = bonzo(el).html();
var lines = content.replace(/\s*$/g, '').split('\n');
var count = lines.length;
bonzo(lines).each(function(line, index){
if(line == '') line = ' ';
lines[index] = '<div class="line">' + line + '</div>';
});
$(el).html(lines.join(''));
});
}
function preToTable(){
$('div.highlight').each(function(code){
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%">';
@ -63,6 +52,16 @@ function preToTable(){
$(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",
@ -102,10 +101,9 @@ function wrapFlashVideos(){
$.domReady(function(){
testFeatures();
addDivLines();
flashVideoFallback();
wrapFlashVideos();
preToTable();
addCodeLineNumbers();
getNav();
addSidebarToggler();
});
@ -144,3 +142,4 @@ b=j.userAgent.toLowerCase(),d=j.platform.toLowerCase(),g=d?/win/.test(d):/win/.t
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""}}}();