Made login forms that use $session->aes_javascript() use new whiteOutForm() function
authorDan
Wed, 13 Aug 2008 08:48:03 -0400
changeset 691 dab7850c098d
parent 690 aeac05b5b7ca
child 692 78473351a6c9
Made login forms that use $session->aes_javascript() use new whiteOutForm() function
includes/clientside/static/functions.js
includes/sessions.php
--- a/includes/clientside/static/functions.js	Wed Aug 13 08:47:20 2008 -0400
+++ b/includes/clientside/static/functions.js	Wed Aug 13 08:48:03 2008 -0400
@@ -583,7 +583,8 @@
   var height = $(el).Height();
   
   var blackout = document.createElement('div');
-  blackout.style.position = 'absolute';
+  // using fixed here allows modal windows to be blacked out
+  blackout.style.position = ( el.style.position == 'fixed' ) ? 'fixed' : 'absolute';
   blackout.style.top = top + 'px';
   blackout.style.left = left + 'px';
   blackout.style.width = width + 'px';
@@ -630,6 +631,54 @@
     }, 1250);
 }
 
+/**
+ * Whites out a form and disables all buttons under it. Useful for onsubmit functions.
+ * @example
+ <code>
+ <form action="foo" onsubmit="whiteOutForm(this);">
+ </code>
+ * @param object Form object
+ * @return object Whiteout div
+ */
+
+function whiteOutForm(form)
+{
+  if ( !form.getElementsByTagName )
+    return false;
+  
+  // disable all buttons
+  var buttons = form.getElementsByTagName('input');
+  for ( var i = 0; i < buttons.length; i++ )
+  {
+    if ( buttons[i].type == 'button' || buttons[i].type == 'submit' || buttons[i].type == 'image' )
+    {
+      buttons[i].disabled = 'disabled';
+      // ... but also make a hidden element to preserve any flags
+      var clone = buttons[i].cloneNode(true);
+      clone.type = 'hidden';
+      clone.disabled = false;
+      console.debug(clone);
+      form.appendChild(clone);
+    }
+  }
+  var buttons = form.getElementsByTagName('button');
+  for ( var i = 0; i < buttons.length; i++ )
+  {
+    buttons[i].disabled = 'disabled';
+    // ... but also make a hidden element to preserve any flags
+    if ( buttons[i].name )
+    {
+      var clone = document.createElement('input');
+      clone.type = 'hidden';
+      clone.name = buttons[i].name;
+      clone.value = ( buttons[i].value ) ? buttons[i].value : '';
+      form.appendChild(clone);
+    }
+  }
+  
+  return whiteOutElement(form);
+}
+
 // other DHTML functions
 
 function fetch_offset(obj)
--- a/includes/sessions.php	Wed Aug 13 08:47:20 2008 -0400
+++ b/includes/sessions.php	Wed Aug 13 08:48:03 2008 -0400
@@ -3275,9 +3275,11 @@
           
           function runEncryption()
           {
+            var frm = document.forms.'.$form_name.';
+            whiteOutForm(frm);
+            
             load_component(\'crypto\');
             var testpassed = ' . ( ( isset($_GET['use_crypt']) && $_GET['use_crypt']=='0') ? 'false; // CRYPTO-AUTH DISABLED ON USER REQUEST // ' : '' ) . '( aes_self_test() && md5_vm_test() );
-            var frm = document.forms.'.$form_name.';
             var use_diffiehellman = false;' . "\n";
     if ( $dh_supported && $dh_pubkey )
     {
@@ -3301,10 +3303,12 @@
               {
                 el = el.parentNode;
               }
+              /*
               if ( el.tagName == "TABLE" )
               {
                 whiteOutElement(el);
               }
+              */
               
               frm.'.$use_crypt.'.value = \'yes_dh\';