aboutsummaryrefslogtreecommitdiff
path: root/source/javascripts
diff options
context:
space:
mode:
authorB Mathis <brandon@imathis.com>2009-11-12 11:57:01 -0600
committerB Mathis <brandon@imathis.com>2009-11-12 11:57:01 -0600
commita55a55156638efd574b7d78f57da0955f355ba40 (patch)
tree12e86b9f507e319a6fd29a2232573ed24b8e10c7 /source/javascripts
parent0b744bae5e8379531939942670d87b46bb9d0e1a (diff)
downloadmy_new_personal_website-a55a55156638efd574b7d78f57da0955f355ba40.tar.xz
my_new_personal_website-a55a55156638efd574b7d78f57da0955f355ba40.zip
added ability to collapse layout
Diffstat (limited to 'source/javascripts')
-rw-r--r--source/javascripts/octopress.js27
1 files changed, 20 insertions, 7 deletions
diff --git a/source/javascripts/octopress.js b/source/javascripts/octopress.js
index a91d30e8..23716351 100644
--- a/source/javascripts/octopress.js
+++ b/source/javascripts/octopress.js
@@ -1,14 +1,13 @@
window.addEvent('domready', function() {
- $$('div.highlight').each(addExpander);
+ codeblocks = $$('div.highlight');
+ codeblocks.each(addExpander);
+ enableCompressedLayout(codeblocks);
});
function addExpander(div){
new Element('span',{
html: 'expand &raquo;',
'class': 'pre_expander',
- 'styles': {
- 'display': 'block'
- },
'events': {
'click': function(){
toggleExpander();
@@ -18,12 +17,26 @@ function addExpander(div){
}
function toggleExpander(){
var html = '';
- if($('main').toggleClass('expanded').hasClass('expanded')){
+ if($('main').toggleClass('expanded').hasClass('expanded'))
html = '&laquo; contract';
- } else {
+ else
html = 'expand &raquo;';
- }
$$('div.highlight span.pre_expander').each(function(span){
span.set('html',html);
});
+}
+function enableCompressedLayout(codeblocks){
+ if(!codeblocks.length) return;
+ new Element('span',{
+ html: 'Collapse layout',
+ 'id': 'collapser',
+ 'events': {
+ 'click': function(){
+ if($('page').toggleClass('collapsed').hasClass('collapsed'))
+ this.set('html','Expand layout');
+ else
+ this.set('html','Collapse layout');
+ }
+ }
+ }).inject($('main'), 'top');
} \ No newline at end of file