diff options
author | Brandon Mathis <brandon@imathis.com> | 2011-06-15 22:50:01 -0400 |
---|---|---|
committer | Brandon Mathis <brandon@imathis.com> | 2011-06-15 22:50:01 -0400 |
commit | b0405cc3c2f901e20d8aa0bc1ed8c499065f0c8b (patch) | |
tree | df8800a6a4dd045faa5ab99e1919e5bda8442b22 /themes/classic/source/javascripts | |
parent | ab29d45ae81760e82a6715a41674f58c3f51683a (diff) | |
download | my_new_personal_website-b0405cc3c2f901e20d8aa0bc1ed8c499065f0c8b.tar.xz my_new_personal_website-b0405cc3c2f901e20d8aa0bc1ed8c499065f0c8b.zip |
1. Some general styling improvements especially for syntax and navigation
2. JS line numbering now supports embedded gists
3. Added a favicon
Diffstat (limited to 'themes/classic/source/javascripts')
-rw-r--r-- | themes/classic/source/javascripts/octopress.js | 45 |
1 files changed, 22 insertions, 23 deletions
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('<fieldset role="mobile-nav"></fieldset>').next(); - var select = $(fieldset).append('<select></select>').children(); - select.append('<option value="">Navigate…</option>'); - $($('body > nav ul[role=main-nav] a').concat($('body > nav ul[role=subscription] a'))).each(function(link) { - select.append('<option value="'+link.href+'">• '+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…</option>'); + $($('body > nav ul[role=main-nav] a')).each(function(link) { + mobileNav.children('select').append('<option value="'+link.href+'">• '+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""}}}(); + |