Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/02/2007, 21:02
Avatar de merolhack
merolhack
 
Fecha de Ingreso: junio-2006
Ubicación: México
Mensajes: 1.242
Antigüedad: 17 años, 10 meses
Puntos: 16
Sonrisa Mover elementos

Hola, en un componente de Joomla(Facileforms) utilizan para mover los elementos de el formulario un javascipt:

Código:
function moveElements(direction)
			{
				var f = document.adminForm;
				var step = parseInt(f.id_movepixels.value);
				if (step==0) return;
				var fd = ff_prevframe.document;
				var i;
				for (i = 0; i < 6; i++) {
					var cb = eval('f.cb'+i);
					if (cb.checked && ff_coords[i][0]) {
						var el = fd.getElementById('ff_div'+cb.value).style;
						var x,y,u;
						switch (direction) {
							case 'left':
								x = ff_coords[i][2];
								if (ff_coords[i][3]) u = '%'; else u = 'px';
								if (x >= 0) {
									if (x > step)
										x -= step;
									else
										x = 0;
									el.left = x+u;
								} else {
									x -= step;
									el.right = (-x)+u;
								} // if
								ff_coords[i][2] = x;
								break;
							case 'right':
								x = ff_coords[i][2];
								if (ff_coords[i][3]) u = '%'; else u = 'px';
								if (x >= 0) {
									x += step;
									el.left = x+u;
								} else {
									if ((-x) > step)
										x += step;
									else
										x = -1;
									el.right = (-y)+u;
								} // if
								ff_coords[i][2] = x;
								break;
							case 'up':
								y = ff_coords[i][5];
								if (ff_coords[i][6]) u = '%'; else u = 'px';
								if (y >= 0) {
									if (y > step)
										y -= step;
									else
										y = 0;
									el.top = y+u;
								} else {
									y -= step;
									el.bottom = (-y)+u;
								} // if
								ff_coords[i][5] = y;
								break;
							case 'down':
								y = ff_coords[i][5];
								if (ff_coords[i][6]) u = '%'; else u = 'px';
								if (y >= 0) {
									y += step;
									el.top = y+u;
								} else {
									if ((-y) > step)
										y += step;
									else
										y = -1;
									el.bottom = (-y)+u;
								} // if
								ff_coords[i][5] = y;
								break;
							default:;
						} // switch
					} // if
				} // for
				var disabled = true;
				for (i = 0; i < 6; i++)
					if (ff_coords[i][1]!=ff_coords[i][2] || ff_coords[i][4]!=ff_coords[i][5]) {
						disabled = false;
						break;
					} // if
				f.savepos.disabled = disabled;
				f.restpos.disabled = disabled;
			} // moveElements
Pero quisiera saber si alguien sabe de algun manual o tutorial, para usar algun Javascript similar, es que se me haria más fácil, que viendo el mundo de codigo con el que esta hecho el componente :S

A ver si alguien conoce otro Javascript más sencillito que realize la misma funcion