ucantblamem

MooTools 1.2 Plugin: Equalizer Update

16th Jun 2008

For those who may be trying to use the original MooTools Equalizer Plugin with MooTools 1.2, here is an updated version:

var Equalizer = new Class({

    Implements: [Options],

    options: {
        padding: 0
    },

    elements: [],
    height: 0,

    initialize: function(elements, options) {
        this.elements = $$(elements);
		this.setOptions(options);
        this.calculateHeight();

        if (this.height > 0) {
            this.resizeElements();
        }
    },

    calculateHeight: function() {
        $$(this.elements).each(function(el) {
            if (el.offsetHeight > this.height) {
                this.height = el.offsetHeight;
            }
        }, this);

		this.height = this.height + this.options.padding;
    },

    resizeElements: function() {
        $$(this.elements).each(function(el) {
            el.setStyles({
                'height': this.height + 'px'
            });
        }, this);
    }

});

Leave a Reply