[Mapbender-commits] r6375 - in trunk/mapbender: http/plugins lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Jun 22 05:56:39 EDT 2010


Author: christoph
Date: 2010-06-22 09:56:39 +0000 (Tue, 22 Jun 2010)
New Revision: 6375

Modified:
   trunk/mapbender/http/plugins/mb_wizard.js
   trunk/mapbender/lib/wizard.js
Log:


Modified: trunk/mapbender/http/plugins/mb_wizard.js
===================================================================
--- trunk/mapbender/http/plugins/mb_wizard.js	2010-06-21 01:20:23 UTC (rev 6374)
+++ trunk/mapbender/http/plugins/mb_wizard.js	2010-06-22 09:56:39 UTC (rev 6375)
@@ -13,9 +13,9 @@
 				fade: true,
 				startWith: o.$target.eq(0),
 				onClickLink: function ($targets) {
-					that.events.onClickLink.trigger({
+					return that.events.onClickLink.trigger({
 						path: $targets
-					});
+					}, "AND");
 				}
 			});
 		}

Modified: trunk/mapbender/lib/wizard.js
===================================================================
--- trunk/mapbender/lib/wizard.js	2010-06-21 01:20:23 UTC (rev 6374)
+++ trunk/mapbender/lib/wizard.js	2010-06-22 09:56:39 UTC (rev 6375)
@@ -12,7 +12,10 @@
 		var o = $.extend({
 			fade: false,
 			onClickLink: function () {
-				
+				return true;
+			},
+			onBeforeClickLink: function () {
+				return true;
 			}
 		}, options || {});
 		
@@ -25,26 +28,30 @@
 			if (m && m.path) {
 				p = m.path.split("/");
 			}
-			o.onClickLink(p);			
+			return o.onClickLink(p);			
 		};
 		
+		var navigate = function ($t) {
+			if (o.fade) {
+				$t.siblings("div:visible").fadeOut(function () {
+					$t.fadeIn();
+				});
+			}		
+			else {
+				$t.siblings("div").hide();
+			}
+		};
+
 		var clickHandler = function (e, $t) {
-			$t.siblings("div").hide();
+			var proceed = getPath($t);
+			if (!proceed) {
+				return;
+			}
+			navigate($t);
 			$t.show();
-			getPath($t);
 			e.preventDefault();
 		};
 	
-		if (o.fade) {
-			clickHandler = function (e, $t) {
-				$t.siblings("div:visible").fadeOut(function () {
-					$t.fadeIn();
-				});
-				getPath($t);
-				e.preventDefault();
-			};
-		}
-		
 		if (o.startWith) {
 			getPath(o.startWith);
 		}
@@ -74,8 +81,14 @@
 				return;
 			}
 			
+			if (typeof o.onBeforeClickLink === "function") {
+				var proceed = o.onBeforeClickLink($target);
+				if (!proceed) {
+					new Mapbender.Warning("Clicked link " + href + " in wizard " + wizardInstance.id + " aborted!");
+					return;
+				}
+			}
 			new Mapbender.Warning("Clicked link " + href + " in wizard " + wizardInstance.id);
-
 			clickHandler(e, $target);
 		});
 	});



More information about the Mapbender_commits mailing list