Ver Mensaje Individual
  #5 (permalink)  
Antiguo 03/07/2008, 00:11
mariano_donati
 
Fecha de Ingreso: marzo-2005
Mensajes: 1.418
Antigüedad: 20 años
Puntos: 9
Respuesta: Acceder a una propiedad publica desde un metodo privado

No me puedo hacer cargo en la totalidad de ese código. Puse mi duda en otro foro y allí me dieron esta opción. Tenía un par de cosas que no me convencían del todo, y las modifiqué.
Por si a alguien le interesa, este es el código que originalmente me abrió la cabeza:

Código:
function Button_constructor ( objid , img_normal , img_mouseover , title )
{
	var sel;
	var obj = null;
	
	this.objid = objid;
	this.root = "Includes/Scripts/TextEditor/Images/";
	this.img_normal = img_normal;
	this.img_mouseover = img_mouseover;
	this.innerObj = obj;
	this.selected = true;
	
	obj = document.getElementById(objid);
	obj.title = title;
	obj.src   = this.root + this.img_normal;
	obj.onmouseover = this.get_event('mouseover', this);
	obj.onmouseout  = this.get_event('mouseout', this);
	
}

Button_constructor.prototype = {
	
	change_cursor : function(obj)
	{
		try
		{
			obj.style.cursor = "pointer";		//MOZILLA
		}
		catch (ex)
		{
			obj.style.cursor = "hand";			//IEX
		}
	},
	
	get_event : function(type, instance)
	{
		var fn = function() {};
		switch (type)
		{
			case 'mouseover':
				fn = function() {
					instance.change_cursor(this);
					if ( !instance.selected )
						this.src = instance.root + instance.img_mouseover;
				};
				break;
			case 'mouseout':
				fn = function() {
					if ( !instance.selected )
						this.src = instance.root + instance.img_normal;
				};
				break;
		}
		return fn;
	}
	
};
Saludos.
__________________
Add, never Remove