www.moparisthebest.com/source/javascripts/octopress.js

41 lines
1005 B
JavaScript
Raw Normal View History

window.addEvent('domready', function() {
2009-11-12 12:57:01 -05:00
codeblocks = $$('div.highlight');
codeblocks.each(addExpander);
});
function addExpander(div){
new Element('span',{
html: 'expand »',
'class': 'pre_expander',
'events': {
'click': function(){
toggleExpander();
}
}
}).inject(div, 'top');
}
function toggleExpander(){
var html = '';
2009-11-12 12:57:01 -05:00
if($('main').toggleClass('expanded').hasClass('expanded'))
html = '« contract';
2009-11-12 12:57:01 -05:00
else
html = 'expand »';
$$('div.highlight span.pre_expander').each(function(span){
2009-11-12 11:28:30 -05:00
span.set('html',html);
});
2009-11-12 12:57:01 -05:00
}
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');
}