Changeset 334:6994b09c7991

Show
Ignore:
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:
1 modified

Legend:

Unmodified
Added
Removed
  • WebContent/scripts/w3c_unicorn_index.js

    r265 r334  
    8181                        }); 
    8282                }); 
     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 
    83107        }, 
    84108         
     
    287311        }, 
    288312         
     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         
    289321        setHash: function(hash){ 
    290322                if (window.webkit419){ 
     
    294326                        window.location.hash = hash; 
    295327                } 
    296         }, 
    297          
    298         isUrl: function(url){ 
    299                 return  url.test(".*"); 
    300328        } 
    301329