diff options
Diffstat (limited to '')
-rw-r--r-- | source/javascripts/octopress.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/source/javascripts/octopress.js b/source/javascripts/octopress.js new file mode 100644 index 00000000..300d9c6a --- /dev/null +++ b/source/javascripts/octopress.js @@ -0,0 +1,34 @@ +window.addEvent('domready', function() { + addPreExpanders(); +}); + +function addPreExpanders(){ + $$('div.highlight').each(function(div){ + addExpander(div); + }); +} +function addExpander(div){ + new Element('span',{ + html: 'expand »', + 'class': 'pre_expander', + 'styles': { + 'display': 'block' + }, + 'events': { + 'click': function(){ + toggleExpander(); + } + } + }).inject(div, 'top'); +} +function toggleExpander(){ + var html = ''; + if($('main').toggleClass('expanded').hasClass('expanded')){ + html = '« contract'; + } else { + html = 'expand »'; + } + $$('div.highlight span.pre_expander').each(function(span){ + span.set('html',html); + }); +}
\ No newline at end of file |