ExpandButton.js

Summary

No overview generated for 'ExpandButton.js'


/**
 * Expand/collapse button (v/^)
 * @constructor
 * @param {Function} f  Function to be fired by the onclick event
 */
var ExpandButton = Class.create();
ExpandButton.prototype.initialize = function(f)
{
	this.img = document.createElement('IMG');
	this.img.onclick = f;
	this.img.style.cursor = 'pointer';
	this.img.alt = '+/-';
};

/**
 * Get Element
 * @method
 * @return {Element}  The expand button
 */
ExpandButton.prototype.getButton = function()
{
	return this.img;
};

/**
 * Set the expand button graphic
 * @method
 * @param {boolean} isExpanded  New state
 * @param {boolean} isNode  Item is a node (can't be expanded)
 */
ExpandButton.prototype.set = function(isExpanded, isNode)
{
	var _this = this;
	var icon = isExpanded ? JSWMImages.collapse : JSWMImages.expand;
	var iconHover = isExpanded ? JSWMImagesHover.collapse : JSWMImagesHover.expand;

	this.img.src = icon;
	this.img.onmouseover = function() {
		_this.img.src = iconHover;
	};
	this.img.onmouseout = function() {
		_this.img.src = icon;
	};
};


Documentation generated by JSDoc on Sun May 6 13:35:11 2007