source/javascripts/octopress.js
1eddd60a
 window.addEvent('domready', function() {
a55a5515
   codeblocks = $$('div.highlight');
   codeblocks.each(addExpander);
1eddd60a
 });
 
 function addExpander(div){
   new Element('span',{
 		html: 'expand »',
 		'class': 'pre_expander',
     'events': {
       'click': function(){
0ac4eca1
         toggleExpander(this);
1eddd60a
       }
     }
 	}).inject(div, 'top');
 }
0ac4eca1
 function toggleExpander(expander){
1eddd60a
   var html = '';
0ac4eca1
   var expanderPos = expander.getPosition().y;
a55a5515
   if($('main').toggleClass('expanded').hasClass('expanded'))
1eddd60a
     html = '« contract';
a55a5515
   else
1eddd60a
     html = 'expand »';
   $$('div.highlight span.pre_expander').each(function(span){
0b744bae
       span.set('html',html);
1eddd60a
   });
0ac4eca1
   fixScroll(expander, expanderPos);
 }
 function fixScroll(el, position){
   pos = el.getPosition().y - position;
   window.scrollTo(window.getScroll().x ,window.getScroll().y + pos);
a55a5515
 }
 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');
1eddd60a
 }