W3C home > Mailing lists > Public > www-validator-cvs@w3.org > September 2009

2006/unicorn/WebContent/scripts w3c_unicorn_index.js,1.7,1.8

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Thu, 10 Sep 2009 09:29:43 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1MlfyJ-0001UL-NF@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/WebContent/scripts
In directory hutz:/tmp/cvs-serv5707/WebContent/scripts

Modified Files:
	w3c_unicorn_index.js 
Log Message:
added FormValidator objects on form to keep the selected tab and task in case of an error
+ prepared for form validation

Index: w3c_unicorn_index.js
===================================================================
RCS file: /sources/public/2006/unicorn/WebContent/scripts/w3c_unicorn_index.js,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- w3c_unicorn_index.js	3 Sep 2009 14:04:12 -0000	1.7
+++ w3c_unicorn_index.js	10 Sep 2009 09:29:41 -0000	1.8
@@ -80,6 +80,30 @@
 				this.setProperty('href', this.getProperty('href') +  window.location.hash);
 			});
 		});
+		
+		W3C.Forms.filter('form[method=get]').each(function (form) {
+			new FormValidator(form, {
+				onFormValidate: function(passed, form, event) {
+					if (passed) {
+						event.preventDefault();	
+						var queryString = form.toQueryString().replace('uri=http%3A%2F%2F', 'uri=') + "#" + W3C.getHash();
+						queryString = queryString + "#" + W3C.getHash();
+						window.location = "./observe?" + queryString;
+					}
+				}
+			});
+		});
+		
+		W3C.Forms.filter('form[method=post]').each(function (form) {
+			new FormValidator(form, {
+				onFormValidate: function(passed, form, event) {
+					if (passed) {
+						form.setProperty('action', form.getProperty('action') + '#' + W3C.getHash());
+					}
+				}
+			});
+		});
+
 	},
 	
 	addOptionEvents: function () {
@@ -286,6 +310,14 @@
 		W3C.setHash(tab + task + withOptions);
 	},
 	
+	getHash: function() {
+		var tab = W3C.Forms[W3C.SelectedTab].getProperty('id');
+		var task = '+task_' + W3C.TaskOptions[W3C.SelectedTask].getProperty('value');
+		var withOptions = W3C.WithOptions ? '+with_options' : '';
+		
+		return tab + task + withOptions;
+	},
+	
 	setHash: function(hash){
 		if (window.webkit419){
 			W3C.FakeForm = W3C.FakeForm || new Element('form', {'method': 'get'}).injectInside(document.body);
@@ -293,10 +325,6 @@
 		} else {
 			window.location.hash = hash;
 		}
-	},
-	
-	isUrl: function(url){
-		return	url.test(".*");
 	}
 	
 };
Received on Thursday, 10 September 2009 09:29:56 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:55:14 GMT