Nuestro conocimiento compartido. Nuestro tesoro compartido. Wikipedia.
ShareCode
Permalink: http://www.treeweb.es/u/974/ 01/02/2011

ShareCode

1 2 var PicVi = function(parent) {3  4  this.dom = document.createElement('div');5  this.dom.className = 'PicVi';6  this.dom.setAttribute('status', 'rest'); 7  this.canvas = [];8  this.selected_id = -1;9  10  parent.appendChild(this.dom);11  return;12 };13 14 PicVi.prototype.getSelectedId = function() {15  return this.selected_id;16 };17 18 PicVi.prototype.add = function(url) {19  var c = document.createElement('div');20  c.innerHTML = url+' ('+this.canvas.length+')';21  this.canvas.push(c);22  c.className = 'canvas';23  c.setAttribute('position', 'hidden');24  this.dom.appendChild(c);25 };26 27 PicVi.prototype.exists = function(id) {28  return typeof (this.canvas[id]) != 'undefined';29 };30 31 PicVi.prototype.select = function(id) {32  if (this.exists(id)) {33  this.selected_id = id;34  var l = this.canvas.length;35  for (var i=0; i<l; i++) {36  var position = 'hidden';37  if (i == id) {38  position = 'center';39  } else if (id == i+1) {40  position = 'left';41  } else if (id == i-1) {42  position = 'right';43  } else if (id == i+2) {44  position = 'left-far';45  } else if (id == i-2) {46  position = 'right-far';47  } else {48  position = 'hidden';49  }50  this.canvas[i].setAttribute('position', position);51  }52  }53 };54 55 56 57 


Este ShareCode tiene versiones:
  1. Image viewer    &nb... (26/04/2013)
Enlace
El enlace para compartir es: