1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
/*
* $Id: layers.js,v 1.7.2.4 2010/04/06 16:46:12 source Exp $
*
* This file is part of the OpenLink Software Ajax Toolkit (OAT) project.
*
* Copyright (C) 2005-2010 OpenLink Software
*
* See LICENSE file for details.
*/
/*
var l = new OAT.Layers(baseOffset);
l.addLayer(something,activationEvent)
l.removeLayer(something)
*/
OAT.Layers = function(baseOffset) {
var self = this;
this.baseOffset = baseOffset;
this.layers = [];
this.currentIndex = 0;
this.raise = function(elm) {
var index = self.layers.find(elm);
if (index == -1) { return; }
var curr = elm.style.zIndex;
for (var i=0;i<self.layers.length;i++) {
var e = self.layers[i];
if (e.style.zIndex > curr) { e.style.zIndex--; }
}
elm.style.zIndex = self.currentIndex;
}
this.addLayer = function(something,activationEvent) {
var elm = $(something);
if (!elm) { return; }
self.currentIndex++;
elm.style.zIndex = self.currentIndex;
self.layers.push(elm);
var event = (activationEvent ? activationEvent : "mousedown");
OAT.Event.attach(elm,event,function(){self.raise(elm);});
}
this.removeLayer = function(something) {
var elm = $(something);
var index = self.layers.find(elm);
if (index == -1) { return; }
self.layers.splice(index,1);
}
self.currentIndex = self.baseOffset;
}
|