[Mapbender-commits] r1916 - trunk/mapbender/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Dec 12 11:37:54 EST 2007
Author: christoph
Date: 2007-12-12 11:37:54 -0500 (Wed, 12 Dec 2007)
New Revision: 1916
Modified:
trunk/mapbender/http/javascripts/map.js
Log:
added new (but backwards compatible) event management
Modified: trunk/mapbender/http/javascripts/map.js
===================================================================
--- trunk/mapbender/http/javascripts/map.js 2007-12-12 16:21:27 UTC (rev 1915)
+++ trunk/mapbender/http/javascripts/map.js 2007-12-12 16:37:54 UTC (rev 1916)
@@ -28,37 +28,52 @@
***************************************************************************************
*/
-var mb_MapRequestSubFunctions = [];
+//var mb_MapRequestSubFunctions = [];
+//var mb_MapRequestPreFunctions = [];
+//var mb_MapObjectSubFunctions = [];
+//var mb_GetScalePreFunctions = [];
+//var mb_FeatureInfoPreFunctions = [];
+//var mb_loadWmsSubFunctions = [];
+//var mb_InitFunctions = [];
var mb_WfsReadSubFunctions = [];
var mb_WfsWriteSubFunctions = [];
-var mb_MapRequestPreFunctions = [];
-var mb_FeatureInfoPreFunctions = [];
-var mb_InitFunctions = [];
-var mb_MapObjectSubFunctions = [];
-var mb_GetScalePreFunctions = [];
-var mb_loadWmsSubFunctions = [];
var mb_l10nFunctions = [];
+var eventAfterMapRequest = new MapbenderEvent();
+var eventBeforeMapRequest = new MapbenderEvent();
+var eventBeforeGetScale = new MapbenderEvent();
+var eventBeforeFeatureInfo = new MapbenderEvent();
+var eventAfterLoadWMS = new MapbenderEvent();
+var eventInit = new MapbenderEvent();
+var eventAfterMapObjectConstruction = new MapbenderEvent(); // possibly obsolete!
+
function mb_registerInitFunctions(stringFunction){
- mb_InitFunctions[mb_InitFunctions.length] = stringFunction;
+// mb_InitFunctions[mb_InitFunctions.length] = stringFunction;
+ eventInit.register(stringFunction);
}
function mb_registerPreFunctions(stringFunction){
- mb_MapRequestPreFunctions[mb_MapRequestPreFunctions.length] = stringFunction;
+// mb_MapRequestPreFunctions[mb_MapRequestPreFunctions.length] = stringFunction;
+ eventBeforeMapRequest.register(stringFunction);
}
function mb_registerFeatureInfoPreFunctions(stringFunction){
- mb_FeatureInfoPreFunctions[mb_FeatureInfoPreFunctions.length] = stringFunction;
+// mb_FeatureInfoPreFunctions[mb_FeatureInfoPreFunctions.length] = stringFunction;
+ eventBeforeFeatureInfo.register(stringFunction);
}
function mb_registerSubFunctions(stringFunction){
- mb_MapRequestSubFunctions[mb_MapRequestSubFunctions.length] = stringFunction;
+// mb_MapRequestSubFunctions[mb_MapRequestSubFunctions.length] = stringFunction;
+ eventAfterMapRequest.register(stringFunction);
}
function mb_registerMapObjectSubFunctions(stringFunction){
- mb_MapObjectSubFunctions[mb_MapObjectSubFunctions.length] = stringFunction;
+// mb_MapObjectSubFunctions[mb_MapObjectSubFunctions.length] = stringFunction;
+ eventAfterMapObjectConstruction.register(stringFunction);
}
function mb_registerGetScalePreFunctions(stringFunction){
- mb_GetScalePreFunctions[mb_GetScalePreFunctions.length] = stringFunction;
+// mb_GetScalePreFunctions[mb_GetScalePreFunctions.length] = stringFunction;
+ eventBeforeGetScale.register(stringFunction);
}
function mb_registerloadWmsSubFunctions(stringFunction){
- mb_loadWmsSubFunctions[mb_loadWmsSubFunctions.length] = stringFunction;
+// mb_loadWmsSubFunctions[mb_loadWmsSubFunctions.length] = stringFunction;
+ eventAfterLoadWMS.register(stringFunction);
}
function mb_registerWfsReadSubFunctions(stringFunction){
mb_WfsReadSubFunctions[mb_WfsReadSubFunctions.length] = stringFunction;
@@ -89,9 +104,12 @@
}
}
function mb_execloadWmsSubFunctions(){
+ eventAfterLoadWMS.trigger();
+/*
for(var i=0; i<mb_loadWmsSubFunctions.length; i++){
eval(mb_loadWmsSubFunctions[i]);
}
+*/
}
function mb_execWfsReadSubFunctions(geom) {
@@ -143,9 +161,13 @@
function init(){
+ eventInit.trigger();
+/*
for(var i=0; i<mb_InitFunctions.length; i++){
eval(mb_InitFunctions[i]);
}
+*/
+
for(var i=0; i<mb_mapObj.length; i++){
setMapRequest(mb_mapObj[i].frameName);
}
@@ -515,9 +537,7 @@
return true;
}
- for(var i=0; i<mb_MapObjectSubFunctions.length; i++){
- eval(mb_MapObjectSubFunctions[i]);
- }
+ eventAfterMapObjectConstruction.trigger();
}
/*
@@ -713,12 +733,19 @@
var functionName = 'setMapRequest';
var ts = mb_timestamp();
+
+ var ret = eventBeforeMapRequest.trigger("AND");
+ if (ret === false) {
+ return true;
+ }
+/*
for(var i=0; i<mb_MapRequestPreFunctions.length; i++){
var ret = eval(mb_MapRequestPreFunctions[i]);
if(ret == false){
return true;
}
}
+*/
for(var i=0; i<mb_mapObj.length; i++){
var newMapRequest = "";
if(mb_mapObj[i].frameName == frameName){
@@ -821,18 +848,24 @@
writeTag(mb_mapObj[i].frameName,mb_mapObj[i].elementName,newMapRequest);
}
}
+ eventAfterMapRequest.trigger({"frameName":frameName, "myMapId":myMapId});
+/*
for(var i=0; i<mb_MapRequestSubFunctions.length; i++){
eval(mb_MapRequestSubFunctions[i]);
}
+*/
}
function setSingleMapRequest(frameName,wms_id){
var functionName = 'setSingleMapRequest';
var ts = mb_timestamp();
-
+
+ eventBeforeMapRequest.trigger();
+/*
for(var i=0; i<mb_MapRequestPreFunctions.length; i++){
eval(mb_MapRequestPreFunctions[i]);
}
+*/
for(i=0; i<mb_mapObj.length; i++){
var newMapRequest = "";
if(mb_mapObj[i].frameName == frameName){
@@ -919,10 +952,12 @@
}
}
}
-
+ eventAfterMapRequest.trigger({"frameName":frameName, "myMapId":myMapId});
+/*
for(var i=0; i<mb_MapRequestSubFunctions.length; i++){
eval(mb_MapRequestSubFunctions[i]);
}
+*/
}
function mb_restateLayers(frameName,wms_id){
//alert(frameName + " / " + wms_id);
@@ -985,9 +1020,12 @@
function setFeatureInfoRequest(fName,x,y, path) {
var functionName = 'setFeatureInfoRequest';
var ts = mb_timestamp();
+ eventBeforeFeatureInfo.trigger({"fName":fName});
+/*
for(var i=0; i<mb_FeatureInfoPreFunctions.length; i++){
eval(mb_FeatureInfoPreFunctions[i]);
}
+*/
var cnt_fi = 0;
for(i=0; i<mb_mapObj.length; i++){
if(mb_mapObj[i].frameName == fName){
@@ -1348,10 +1386,16 @@
}
//scale
function mb_getScale(frameName) {
+
+ console.log("trigger scale: ");
+ var myScale = eventBeforeGetScale.trigger({"frameName":frameName});
+ console.log("myscale: %s", myScale);
+/*
for(var i=0; i<mb_GetScalePreFunctions.length; i++){
var myScale = eval(mb_GetScalePreFunctions[i]);
}
- if(myScale){
+*/
+ if(typeof(myScale) == "number"){
var Y_str = myScale;
}
else{
More information about the Mapbender_commits
mailing list