Gracias, 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  c.style.backgroundImage = 'url(\''+url+'\')';22  this.canvas.push(c);23  c.className = 'canvas';24  c.setAttribute('position', 'hidden');25  this.dom.appendChild(c);26 };27 28 PicVi.prototype.exists = function(id) {29  return typeof (this.canvas[id]) != 'undefined';30 };31 32 PicVi.prototype.select = function(id) {33  if (this.exists(id)) {34  this.selected_id = id;35  var l = this.canvas.length;36  for (var i=0; i<l; i++) {37  var position = 'hidden';38  if (i == id) {39  position = 'center';40  } else if (id == i+1) {41  position = 'left';42  } else if (id == i-1) {43  position = 'right';44  } else if (id == i+2) {45  position = 'left-far';46  } else if (id == i-2) {47  position = 'right-far';48  } else {49  position = 'hidden';50  }51  this.canvas[i].setAttribute('position', position);52  }53  }54 };55 56 57 58 


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