[Mapbender-commits] r5802 - trunk/mapbender/http/plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Mar 17 09:00:41 EDT 2010


Author: verenadiewald
Date: 2010-03-17 09:00:37 -0400 (Wed, 17 Mar 2010)
New Revision: 5802

Modified:
   trunk/mapbender/http/plugins/mb_initWmc.php
Log:
defined a done event for initWmc

Modified: trunk/mapbender/http/plugins/mb_initWmc.php
===================================================================
--- trunk/mapbender/http/plugins/mb_initWmc.php	2010-03-17 10:53:53 UTC (rev 5801)
+++ trunk/mapbender/http/plugins/mb_initWmc.php	2010-03-17 13:00:37 UTC (rev 5802)
@@ -41,37 +41,46 @@
 var myTarget = options.target ? options.target[0] : "mapframe1";
 var myId = options ? options.id : "initWmc";
 
-var initWmc = function () {
+var InitWmcApi = function () {
 
 	var that = this;
-	
-	<?php 
-	function initWmcById ($wmcId,$wmcAction) {
-		
-	    
-	    $wmc = new wmc();
-	     
-	    $wmc->createFromDb($wmcId);
-	    
-	    $updatedWMC = $wmc->updateUrlsFromDb();
-	    $wmc->createFromXml($updatedWMC);
-	    
-	    $jsArray = $wmc->toJavaScript();
-	    
-		if ($jsArray) {
-			$jsString = implode("", $jsArray);
-			echo $jsString;
+	this.events = {
+		done: new Mapbender.Event()
+	};
+	this.init = function () {
+		<?php 
+		function initWmcById ($wmcId,$wmcAction) {
+			$wmc = new wmc();
+		     
+		    $wmc->createFromDb($wmcId);
+		    
+		    $updatedWMC = $wmc->updateUrlsFromDb();
+		    $wmc->createFromXml($updatedWMC);
+		    
+		    $jsArray = $wmc->toJavaScript();
+		    
+			if ($jsArray) {
+				$jsString = implode("", $jsArray);
+				echo $jsString;
+			}
+			else {
+				$e = new mb_exception("WMC could not be loaded.");
+			}
 		}
-		else {
-			$e = new mb_exception("WMC could not be loaded.");
+		if($wmcId != "") {
+			initWmcById($wmcId,$wmcAction);
 		}
-	}
-	if($wmcId != "") {
-		initWmcById($wmcId,$wmcAction);
-	}
-	?>
+		?>
+		Mapbender.events.init.register(function () {
+			that.events.done.trigger({
+				id: parseInt("<?php echo $wmcId;?>", 10)
+			});
+		});
+		
+	};
+	Mapbender.events.beforeInit.register(function () {
+		that.init();
+	});
 };
+$("#" + myId).mapbender(new InitWmcApi());
 
-Mapbender.events.beforeInit.register(function () {
-	initWmc();
-});



More information about the Mapbender_commits mailing list