Changeset 334:6994b09c7991
- Timestamp:
- 09/10/09 09:29:41 (4 years ago)
- Author:
- tgambet
- Branch:
- default
- convert_revision:
- svn:cdcfb263-7567-472c-a848-e2c2df3466e7/trunk@335
- Message:
-
added FormValidator? objects on form to keep the selected tab and task in case of an error
+ prepared for form validation
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r265
|
r334
|
|
| 81 | 81 | }); |
| 82 | 82 | }); |
| | 83 | |
| | 84 | W3C.Forms.filter('form[method=get]').each(function (form) { |
| | 85 | new FormValidator(form, { |
| | 86 | onFormValidate: function(passed, form, event) { |
| | 87 | if (passed) { |
| | 88 | event.preventDefault(); |
| | 89 | var queryString = form.toQueryString().replace('uri=http%3A%2F%2F', 'uri=') + "#" + W3C.getHash(); |
| | 90 | queryString = queryString + "#" + W3C.getHash(); |
| | 91 | window.location = "./observe?" + queryString; |
| | 92 | } |
| | 93 | } |
| | 94 | }); |
| | 95 | }); |
| | 96 | |
| | 97 | W3C.Forms.filter('form[method=post]').each(function (form) { |
| | 98 | new FormValidator(form, { |
| | 99 | onFormValidate: function(passed, form, event) { |
| | 100 | if (passed) { |
| | 101 | form.setProperty('action', form.getProperty('action') + '#' + W3C.getHash()); |
| | 102 | } |
| | 103 | } |
| | 104 | }); |
| | 105 | }); |
| | 106 | |
| 83 | 107 | }, |
| 84 | 108 | |
| … |
… |
|
| 287 | 311 | }, |
| 288 | 312 | |
| | 313 | getHash: function() { |
| | 314 | var tab = W3C.Forms[W3C.SelectedTab].getProperty('id'); |
| | 315 | var task = '+task_' + W3C.TaskOptions[W3C.SelectedTask].getProperty('value'); |
| | 316 | var withOptions = W3C.WithOptions ? '+with_options' : ''; |
| | 317 | |
| | 318 | return tab + task + withOptions; |
| | 319 | }, |
| | 320 | |
| 289 | 321 | setHash: function(hash){ |
| 290 | 322 | if (window.webkit419){ |
| … |
… |
|
| 294 | 326 | window.location.hash = hash; |
| 295 | 327 | } |
| 296 | | }, |
| 297 | | |
| 298 | | isUrl: function(url){ |
| 299 | | return url.test(".*"); |
| 300 | 328 | } |
| 301 | 329 | |