mirror of
https://github.com/moparisthebest/www.moparscape.org
synced 2024-11-11 20:05:06 -05:00
34 lines
701 B
JavaScript
34 lines
701 B
JavaScript
|
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);
|
||
|
});
|
||
|
}
|