From b0405cc3c2f901e20d8aa0bc1ed8c499065f0c8b Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Wed, 15 Jun 2011 22:50:01 -0400 Subject: 1. Some general styling improvements especially for syntax and navigation 2. JS line numbering now supports embedded gists 3. Added a favicon --- themes/classic/source/javascripts/octopress.js | 45 +++++++++++++------------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'themes/classic/source/javascripts') diff --git a/themes/classic/source/javascripts/octopress.js b/themes/classic/source/javascripts/octopress.js index 591a0ecd..611357a9 100644 --- a/themes/classic/source/javascripts/octopress.js +++ b/themes/classic/source/javascripts/octopress.js @@ -1,12 +1,11 @@ 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('') + var mobileNav = $('body > nav fieldset[role=site-search]').after('
').next().append(''); + mobileNav.children('select').append(''); + $($('body > nav ul[role=main-nav] a')).each(function(link) { + mobileNav.children('select').append('') }); - 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] = '
' + line + '
'; - }); - $(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 = '
'; var lineNumbers = '
';
     var tableMiddle = '
'; @@ -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] = '
' + line + '
'; + }); + $(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