home *** CD-ROM | disk | FTP | other *** search
- /* layermgr.js
-
- Copyright (c) 1997 Netscape Comunications Corporation,
- All Rights Reserved
-
- Handles layer management in an efficient way
-
- */
-
- function LayerLoadObject(layerObj, url, container, notifier, parameter, external)
- {
- this.layerObj = layerObj;
- this.layerURL = url;
- this.container = container;
- this.notifier = notifier;
- this.parameter = parameter
- this.nextLoad = null;
- this.external = external;
- }
-
-
- function LayerMgr_NewLayerAndLoad(layerObj, layerLoadObject) {
-
- layerLoadObject.layerObj = layerObj;
-
- window.layerManager.layerLoad(layerLoadObject);
-
- return;
- }
-
- function LayerMgr_LayerLoad(layerLoadObject)
- {
-
- if (this.mgrBusy == true) {
- setTimeout(this.layerLoad, 100, layerLoadObject);
- }
-
- this.mgrBusy = true;
-
- if ((!this.lastLoad) || (this.lastLoad == null)) {
-
- this.loading = layerLoadObject;
- this.lastLoad = layerLoadObject;
-
- this.mgrBusy = false;
-
- this.startLoad();
- } else {
-
- this.lastLoad.nextLoad = layerLoadObject;
- this.lastLoad = layerLoadObject;
- this.mgrBusy = false;
- }
-
- return;
- }
-
- function LayerMgr_StartNextLoad()
- {
- var loadObject = this.loading;
-
- if (loadObject && (loadObject != null)) {
- if (this.isLoading == true) {
- java.lang.System.out.println("Warning: another layer is already loading");
- }
-
- this.isLoading = true;
-
- if (loadObject.layerObj == null) {
- var newLayer = this.layerNew(200, loadObject.container);
-
- if (loadObject.layerURL != null) {
- window.layerManager.loading.layerObj = newLayer;;
- newLayer.visibility = "show";
- newLayer.src = loadObject.layerURL;
- if(loadObject.external == true) {
- newLayer.__parent__ = null;
- newLayer.initStandardObjects();
- newLayer.Event = Event;
- }
- }
- } else {
- loadObject.visibility = "show";
- loadObject.layerObj.src = loadObject.layerURL;
- if(loadObject.external == true) {
- loadObject.layerObj.__parent__ = null;
- loadObject.layerObj.initStandardObjects();
- loadObject.layerObj.Event = Event;
- }
- }
-
- this.isLoading = false;
- }
-
- }
-
-
- function LayerMgr_CaptureLoad(e)
- {
- var currentLoad = window.layerManager.loading;
-
- if (currentLoad && (currentLoad != null)) {
- if (currentLoad.layerObj != e.target) {
- if (e.target != window) {
- window.routeEvent(e);
- } else {
- if (window.onLoadHandler && (window.onLoadHandler != null)) {
- window.onLoadHandler(e);
- }
- }
- return;
- }
-
- if (currentLoad.notifier != null && currentLoad.notifier.layerLoaded) {
- currentLoad.notifier.layerLoaded(e.target, currentLoad.parameter);
- }
-
- window.layerManager.loading = window.layerManager.loading.nextLoad;
- if (window.layerManager.loading == null) {
- window.layerManager.lastLoad = null;
- }
- }
-
- if (e.target != window) {
- window.routeEvent(e);
-
- } else {
- if (window.onLoadHandler && (window.onLoadHandler != null)) {
- window.onLoadHandler(e);
- }
- }
-
- window.layerManager.startLoad();
-
-
- }
-
- function LayerMgr_NewLayer(width, parent)
- {
- var returnLayer;
- var count;
-
- count = this.layerCount--;
-
- if (count > 0) {
- returnLayer = this.layerArray[count];
- } else {
- this.layerCount++;
- returnLayer = new Layer(width, parent);
- }
-
- return returnLayer;
- }
-
- function LayerMgr_DeleteLayer(thisLayer)
- {
- if (thisLayer && thisLayer != null) {
- thisLayer.src="about:blank";
-
- var count = this.layerCount++;
-
- this.layerArray[count] = thisLayer;
- }
-
- return;
- }
-
- function LayerManager() {
- this.layerCount = 0;
- this.layerArray = new Array(5);
-
- this.layerDelete = LayerMgr_DeleteLayer;
- this.layerNew = LayerMgr_NewLayer;
-
- this.loading = null;
- this.lastLoad = null;
-
- this.layerLoad = LayerMgr_LayerLoad;
- this.startLoad = LayerMgr_StartNextLoad;
-
- this.mgrBusy = false;
- this.isLoading = false;
-
- netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
- window.enableExternalCapture();
-
- document.captureEvents(Event.LOAD);
- document.onload = LayerMgr_CaptureLoad;
-
- window.layerManager = this;
- }
-
- void(0);
-
-