2012-02-16 12:27:47 +01:00
|
|
|
// Shortcut-function (until we update to Prototye v1.5)
|
|
|
|
if(typeof $$ != "Function") $$ = document.getElementsBySelector;
|
|
|
|
|
2007-10-22 01:05:46 +02:00
|
|
|
var ToggleField = Class.create();
|
|
|
|
ToggleField.prototype = {
|
|
|
|
initialize: function() {
|
|
|
|
var rules = {};
|
|
|
|
rules['#' + this.id + ' .triggerMore'] = {
|
|
|
|
onclick: function(e) {
|
2007-11-10 06:15:28 +01:00
|
|
|
Element.toggle(this);
|
2007-10-22 01:05:46 +02:00
|
|
|
Event.stop(e); return false;
|
|
|
|
}.bind(this)
|
|
|
|
};
|
|
|
|
rules['#' + this.id + ' .triggerLess'] = {
|
|
|
|
onclick: function(e) {
|
2007-11-10 06:15:28 +01:00
|
|
|
Element.toggle(this);
|
2007-10-22 01:05:46 +02:00
|
|
|
Event.stop(e); return false;
|
|
|
|
}.bind(this)
|
|
|
|
};
|
|
|
|
Behaviour.register(rules);
|
|
|
|
|
|
|
|
if(Element.hasClassName(this, 'startClosed')) {
|
2007-11-10 06:15:28 +01:00
|
|
|
Element.toggle(this);
|
2007-10-22 01:05:46 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
toggle: function() {
|
2007-11-10 06:15:28 +01:00
|
|
|
var lessDivs = $$('#' + this.id + ' .contentLess');
|
|
|
|
if(lessDivs) Element.toggle(lessDivs[0]);
|
|
|
|
|
|
|
|
var moreDivs = $$('#' + this.id + ' .contentMore');
|
|
|
|
if(moreDivs) Element.toggle(moreDivs[0]);
|
2007-10-22 01:05:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ToggleField.applyTo('div.toggleField');
|