diff options
author | Vinicius Coque <vcoque@gmail.com> | 2012-01-15 12:51:33 -0200 |
---|---|---|
committer | Vinicius Coque <vcoque@gmail.com> | 2012-01-15 12:51:33 -0200 |
commit | ea0d4171c0f0c9e68f26ed052aba0fa078aba120 (patch) | |
tree | e4a98226c63730ce78880fdc60bf399ddc5bbee5 | |
parent | 584183558e2aafcd2d7dce6e5aaff34e96cb6e56 (diff) | |
download | pfsense-ea0d4171c0f0c9e68f26ed052aba0fa078aba120.zip pfsense-ea0d4171c0f0c9e68f26ed052aba0fa078aba120.tar.gz |
Converting headjs javascript code from prototype to jQuery
-rw-r--r-- | usr/local/www/headjs.php | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/usr/local/www/headjs.php b/usr/local/www/headjs.php index eacaa23..4cf1ab2 100644 --- a/usr/local/www/headjs.php +++ b/usr/local/www/headjs.php @@ -46,7 +46,7 @@ function getHeadJS() { $headjs = " var input_errors = ''; - Event.observe(window, 'load', init, false); + jQuery(document).ready(init); "; $_SESSION['NO_AJAX'] == "True" ? $noajax = "var noAjaxOnSubmit = true;" : $noajax = "var noAjaxOnSubmit = false;"; @@ -54,35 +54,35 @@ function getHeadJS() { {$noajax} function init() { - if($('submit') && ! noAjaxOnSubmit) { + if(jQuery('#submit') && ! noAjaxOnSubmit) { // debugging helper //alert('adding observe event for submit button'); - Event.observe(\"submit\", \"click\", submit_form, false); - $('submit').onclick = function() {return false;}; + jQuery(\"#submit\").click(submit_form); + jQuery('#submit').click(function() {return false;}); var to_insert = \"<div style='visibility:hidden' id='loading' name='loading'><img src='{$loader_gif}' \/><\/div>\"; - new Insertion.Before('submit', to_insert); + jQuery('#submit').before(to_insert); } } function submit_form(e){ // debugging helper //alert(Form.serialize($('iform'))); - - if($('inputerrors')) - $('inputerrors').innerHTML = '<center><b><i>Loading...</i></b></center>'; + + if(jQuery('#inputerrors')) + jQuery('#inputerrors').html('<center><b><i>Loading...</i></b></center>'); /* dsh: Introduced because pkg_edit tries to set some hidden fields * if executing submit's onclick event. The click gets deleted * by Ajax. Hence using onkeydown instead. */ - if($('submit') && $('submit').onkeydown) - $('submit').onkeydown(); - if($('submit')) - $('submit').style.visibility = 'hidden'; - if($('cancelbutton')) - $('cancelbutton').style.visibility = 'hidden'; - $('loading').style.visibility = 'visible'; + if(jQuery('#submit').prop('keydown')) { + jQuery('#submit').keydown(); + jQuery('#submit').css('visibility','hidden'); + } + if(jQuery('#cancelbutton')) + jQuery('#cancelbutton').css('visibility','hidden'); + jQuery('#loading').css('visibility','visible'); // submit the form using Ajax } @@ -104,12 +104,12 @@ function getHeadJS() { /* this function will be called if an HTTP error will be triggered */ function formFailure(resp) { showajaxmessage(resp.responseText); - if($('submit')) - $('submit').style.visibility = 'visible'; - if($('cancelbutton')) - $('cancelbutton').style.visibility = 'visible'; - if($('loading')) - $('loading').style.visibility = 'hidden'; + if(jQuery('#submit')) + jQuery('#submit').css('visibility','visible'); + if(jQuery('#cancelbutton')) + jQuery('#cancelbutton').css('visibility','visible'); + if(jQuery('#loading')) + jQuery('#loading').css('visibility','hidden'); } @@ -121,12 +121,12 @@ function getHeadJS() { Rounded(\"div#redbox\",\"all\",\"#FFF\",\"#990000\",\"smooth\"); Rounded(\"td#blackbox\",\"all\",\"#FFF\",\"#000000\",\"smooth\"); - if($('submit')) - $('submit').style.visibility = 'visible'; - if($('cancelbutton')) - $('cancelbutton').style.visibility = 'visible'; - if($('loading')) - $('loading').style.visibility = 'hidden'; + if(jQuery('#submit')) + jQuery('#submit').css('visibility','visible'); + if(jQuery('#cancelbutton')) + jQuery('#cancelbutton').css('visibility','visible'); + if(jQuery('#loading')) + jQuery('#loading').css('visibility','hidden'); return; } @@ -145,19 +145,19 @@ function getHeadJS() { } message_html += '<\/tr><\/table><\/div><\/td><\/table><br \/>'; - $('inputerrors').innerHTML = message_html; + jQuery('#inputerrors').html(message_html); NiftyCheck(); Rounded(\"div#redbox\",\"all\",\"#FFF\",\"#990000\",\"smooth\"); Rounded(\"td#blackbox\",\"all\",\"#FFF\",\"#000000\",\"smooth\"); - if($('submit')) - $('submit').style.visibility = 'visible'; - if($('cancelbutton')) - $('cancelbutton').style.visibility = 'visible'; - if($('loading')) - $('loading').style.visibility = 'hidden'; - if($('inputerrors')) + if(jQuery('#submit')) + jQuery('#submit').css('visibility','visible'); + if(jQuery('#cancelbutton')) + jQuery('#cancelbutton').css('visibility','visible'); + if(jQuery('#loading')) + jQuery('#loading').css('visibility','hidden'); + if(jQuery('#inputerrors')) window.scrollTo(0, 0); } "; |