[Mapbender-commits] r6435 - trunk/mapbender/lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Jun 29 05:55:02 EDT 2010


Author: christoph
Date: 2010-06-29 09:55:02 +0000 (Tue, 29 Jun 2010)
New Revision: 6435

Modified:
   trunk/mapbender/lib/wizard.js
Log:


Modified: trunk/mapbender/lib/wizard.js
===================================================================
--- trunk/mapbender/lib/wizard.js	2010-06-29 09:36:45 UTC (rev 6434)
+++ trunk/mapbender/lib/wizard.js	2010-06-29 09:55:02 UTC (rev 6435)
@@ -3,87 +3,94 @@
  * Link between various interfaces, imagine a wizard
  */
 $.widget("mb.wizard", {
-	_create: function () {
-		var options = this.options;
-		var args = arguments;
-		var getPath = function ($t) {
-			var m = $t.metadata({
-				type: "attr",
-				name: "data"
+	options: {
+		fade: false,
+		onClickLink: function () {
+			return true;
+		},
+		onBeforeClickLink: function () {
+			return true;
+		}		
+	},
+	_navigate: function ($t) {
+		if (o.fade) {
+			$t.siblings("div").fadeOut(function () {
+				$t.fadeIn();
 			});
-			var p = [];
-			if (m && m.path) {
-				p = m.path.split("/");
-			}
-			o.onClickLink(p);			
-		};
-		
-		var navigate = function ($t) {
-			if (o.fade) {
-				$t.siblings("div").fadeOut(function () {
-					$t.fadeIn();
-				});
-			}		
-			else {
-				$t.siblings("div").hide();
-				$t.show();
-			}
-		};
-
-		var clickHandler = function (e, $t) {
-			getPath($t);
-			navigate($t);
-			if (e) {
-				e.preventDefault();
-			}
-		};
-	
-		var to = function () {
-			if (arguments.length === 2) {
-				var $target = arguments[1];
-				var href = "#" + $target.attr("id");
-				var me = null;
-				var e = null;
-			}
-			else {
-				var href = $(this).attr("href");
-				var $target = $(href);
-				var me = this;
-				var e = arguments[0];
-			}
-			var found = false;
-			var abort = false;
-			$target.parents().each(function () {
-				if (abort || found) {
-					return;
-				}
-				var $currentElement = $(this);
-				// not this target's wizard
-				if ($(this).data("isWizard") && this !== wizardInstance) {
-					abort = true;
-					return;
-				}				
-				// this target's wizard
-				if ($(this).data("isWizard") && this === wizardInstance) {
-					found = true;
-					return;
-				}				
-			});
-			if (abort || !found) {
-				new Mapbender.Warning("not this target's wizard, or not found, aborting");
+		}		
+		else {
+			$t.siblings("div").hide();
+			$t.show();
+		}
+	},
+	_getPath: function ($t) {
+		var m = $t.metadata({
+			type: "attr",
+			name: "data"
+		});
+		var p = [];
+		if (m && m.path) {
+			p = m.path.split("/");
+		}
+		o.onClickLink(p);			
+	},
+	_clickHandler: function (e, $t) {
+		this._getPath($t);
+		this._navigate($t);
+		if (e) {
+			e.preventDefault();
+		}
+	},
+	to: function () {
+		if (arguments.length === 2) {
+			var $target = arguments[1];
+			var href = "#" + $target.attr("id");
+			var me = null;
+			var e = null;
+		}
+		else {
+			var href = $(this).attr("href");
+			var $target = $(href);
+			var me = this;
+			var e = arguments[0];
+		}
+		var found = false;
+		var abort = false;
+		$target.parents().each(function () {
+			if (abort || found) {
 				return;
 			}
-
-			var proceed = me === null ? true : o.onBeforeClickLink(e, $(me));
-			if (proceed === false) {
-				new Mapbender.Warning("Clicked link " + href + " in wizard " + wizardInstance.id + " aborted!");
+			var $currentElement = $(this);
+			// not this target's wizard
+			if ($currentElement.data("isWizard") && this !== wizardInstance) {
+				abort = true;
 				return;
-			}
-			
-			new Mapbender.Warning("Clicked link " + href + " in wizard " + wizardInstance.id);
-			clickHandler(e, $target);
-		};
+			}				
+			// this target's wizard
+			if ($currentElement.data("isWizard") && this === wizardInstance) {
+				found = true;
+				return;
+			}				
+		});
+		if (abort || !found) {
+			new Mapbender.Warning("not this target's wizard, or not found, aborting");
+			return;
+		}
 
+		var proceed = me === null ? true : o.onBeforeClickLink(e, $(me));
+		if (proceed === false) {
+			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);
+	},
+	_create: function () {
+/*
+		var options = this.options;
+		var args = arguments;
+
 		if (typeof options === "string") {
 			if (!$(this).data("isWizard")) {
 				return;
@@ -95,29 +102,17 @@
 			}
 			return;
 		}
-
+*/
 		var wizardInstance = this;
 		var $wiz = $(wizardInstance);
 		$wiz.data("isWizard", true);
 
-		var o = $.extend({
-			fade: false,
-			onClickLink: function () {
-				return true;
-			},
-			onBeforeClickLink: function () {
-				return true;
-			}
-		}, options || {});
-		$wiz.data("wizardOptions", o);
-
-		
 		if (o.startWith) {
 			getPath(o.startWith);
 		}
 
 		$("a.wizard").live("click", function (e) {
-			to.apply($(this), [e]);
+			this.to.apply($(this), [e]);
 		});
 	}
 });



More information about the Mapbender_commits mailing list