gruss Kai,
...
Mir ist gerade ein unschönes Problem aufgefallen: Wenn mehrere Popups
geöffnet sind, kann ich die einzelnen Popups nicht gezielt in den
Vordergrund bringen. ......
...Also müßte die Funktion irgendwie ihre erzeugten Objekt-Instanzen
verwalten. Nun könnte ich diese jeweils in ein globales Array pushen,
aber das ist bestimmt nicht der richtige Ansatz.
var Popup = (function () { // legt einen weiteren funktionsstack an, ...
var popupList = []; // ... der diese liste von popup-referenzen kapselt, ...
var defragment = (function () {
for (var obj, i=0, len=popupList.length; i<len; ++i) {
obj = popupList[i];
if ((obj && !obj.pop_container) || !obj) {
delete obj;
//popupList.splice(i--, 1);
popupList.splice(i, 1);
--len;
--i;
}
}
});
var Popup = (function (def) { // [1]... den konstruktor initialisiert, ...
/* http://www.kaichen.in/code/popup.js */ /*
code*/
var oNewpop = this;/*
code*/
/* ----- public ----- */
oNewpop.pop_container = oContainer;
oNewpop.pop_titlebar = oTitlebar;
oNewpop.pop_closeme = oClImg;
oNewpop.pop_content = oContent;
oNewpop.pop_iframe = oIframe;
popupList.push(oNewpop);
return oNewpop;
});
Popup.prototype.show = (function (w) {/*
code*/
defragment();
popupList.forEach(function (obj/*, idx, arr*/) {
obj.pop_container.style.zIndex = 0;
});
this.pop_container.style.zIndex = 99;
});
Popup.prototype.initQMDrag = (function () {/*
code*/
});
return Popup; // ... und genau den in [1] genannten zurueckgibt.
})();/*
[popupList] und [defragment] lassen sich jetzt nur noch ueber den
konstruktor einer jeden [[Popup]]-instanz adressieren.
fuer die generische/prototypische array-methode [forEach] siehe auch:
[link:http://developer.mozilla.org/en/docs/New_in_JavaScript_1.6#Array_extras]
[link:http://forum.de.selfhtml.org/archiv/2007/3/t149403/#m970590]
*/
so long - peterS. - pseliger@gmx.net
--
»Because objects in JavaScript are so flexible, you will want to think differently about class hierarchies.
Deep hierarchies are inappropriate. Shallow hierarchies are efficient and expressive.« - Douglas Crockford
ie:( fl:) br:> va:( ls:& fo:) rl:) n3;} n4:} ss:} de:µ js:} mo:? zu:]
»Because objects in JavaScript are so flexible, you will want to think differently about class hierarchies.
Deep hierarchies are inappropriate. Shallow hierarchies are efficient and expressive.« - Douglas Crockford
ie:( fl:) br:> va:( ls:& fo:) rl:) n3;} n4:} ss:} de:µ js:} mo:? zu:]