includes/clientside/static/fadefilter.js
author Dan
Wed, 13 Aug 2008 08:48:03 -0400
changeset 691 dab7850c098d
parent 677 2a263b598a2b
child 694 43367c66d869
permissions -rw-r--r--
Made login forms that use $session->aes_javascript() use new whiteOutForm() function
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
     1
/**
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
     2
 * Darkens the browser screen. This will make the entire page un-clickable except for any floating divs created after this is called. Restore with enlighten().
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
     3
 * @param bool Controls whether the fade should be disabled or not. aclDisableTransitionFX will override this if set to true, and fades are never fired on IE.
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
     4
 * @param int When specified, represents the numeric opacity value to set the fade layer to. 1-100.
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
     5
 */
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
     6
677
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
     7
var darkener_index = [];
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
     8
677
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
     9
function darken(nofade, opacVal, layerid)
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    10
{
677
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    11
  layerid = ( layerid ) ? layerid : 'specialLayer_darkener';
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    12
  if(IE)
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    13
    nofade = true;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    14
  if ( !opacVal )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    15
    opacVal = 70;
677
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    16
  darkener_index[layerid] = ( typeof(darkener_index[layerid]) == 'number' ) ? darkener_index[layerid] + 1 : 1;
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    17
  if(document.getElementById(layerid))
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    18
  {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    19
    if(nofade)
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    20
    {
677
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    21
      changeOpac(opacVal, layerid);
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    22
      document.getElementById(layerid).style.display = 'block';
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    23
      document.getElementById(layerid).myOpacVal = opacVal;
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    24
    }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    25
    else
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    26
    {
677
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    27
      if ( document.getElementById(layerid).style.display != 'none' )
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    28
      {
677
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    29
        var currentOpac = document.getElementById(layerid).myOpacVal;
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    30
        opacity(layerid, currentOpac, opacVal, 1000);
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    31
        document.getElementById(layerid).myOpacVal = opacVal;
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    32
      }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    33
      else
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    34
      {
677
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    35
        document.getElementById(layerid).style.display = 'block';
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    36
        document.getElementById(layerid).myOpacVal = opacVal;
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    37
        opacity(layerid, 0, opacVal, 1000);
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    38
      }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    39
    }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    40
  } else {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    41
    w = getWidth();
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    42
    h = getHeight();
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    43
    var thediv = document.createElement('div');
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    44
    if(IE)
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    45
      thediv.style.position = 'absolute';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    46
    else
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    47
      thediv.style.position = 'fixed';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    48
    if ( IE )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    49
    {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    50
      var top = getScrollOffset();
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    51
      thediv.style.top = String(top) + 'px';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    52
    }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    53
    else
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    54
    {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    55
      thediv.style.top = '0px';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    56
    }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    57
    thediv.style.left = '0px';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    58
    thediv.style.opacity = '0';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    59
    thediv.style.filter = 'alpha(opacity=0)';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    60
    thediv.style.backgroundColor = '#000000';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    61
    thediv.style.width =  '100%';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    62
    thediv.style.height = '100%';
677
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    63
    thediv.style.zIndex = getHighestZ() + 5;
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    64
    thediv.id = layerid;
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    65
    thediv.myOpacVal = opacVal;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    66
    if(nofade)
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    67
    {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    68
      thediv.style.opacity = ( parseFloat(opacVal) / 100 );
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    69
      thediv.style.filter = 'alpha(opacity=' + opacVal + ')';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    70
      body = document.getElementsByTagName('body');
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    71
      body = body[0];
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    72
      body.appendChild(thediv);
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    73
    } else {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    74
      body = document.getElementsByTagName('body');
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    75
      body = body[0];
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    76
      body.appendChild(thediv);
677
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    77
      opacity(layerid, 0, opacVal, 1000);
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    78
    }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    79
  }
677
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    80
  return document.getElementById(layerid);
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    81
}
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    82
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    83
/**
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    84
 * Un-darkens the screen and re-enables clicking of on-screen controls.
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    85
 * @param bool If true, disables the fade effect. Fades are always disabled if aclDisableTransitionFX is true and on IE.
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    86
 */
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    87
677
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    88
function enlighten(nofade, layerid)
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    89
{
677
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    90
  layerid = ( layerid ) ? layerid : 'specialLayer_darkener';
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    91
  
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    92
  if(IE)
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    93
    nofade = true;
677
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    94
  darkener_index[layerid] -= 1;
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    95
  if ( darkener_index[layerid] > 0 )
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    96
    return false;
677
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
    97
  if(document.getElementById(layerid))
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    98
  {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    99
    if(nofade)
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
   100
    {
677
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
   101
      document.getElementById(layerid).style.display = 'none';
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
   102
    }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
   103
    else
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
   104
    {
677
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
   105
      var from = document.getElementById(layerid).myOpacVal;
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
   106
      opacity(layerid, from, 0, 1000);
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
   107
      setTimeout("document.getElementById('" + layerid + "').style.display = 'none';", 1000);
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
   108
    }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
   109
  }
677
2a263b598a2b Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
parents: 582
diff changeset
   110
  return document.getElementById(layerid);
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
   111
}