includes/clientside/static/fadefilter.js
author Dan
Thu, 02 Jul 2009 08:58:54 -0400
changeset 1030 23959360dcfd
parent 907 44851d7e9bda
child 1053 bdbb49cf6f1b
permissions -rw-r--r--
SHA256: Fixed broken hashes on 64-bit PHP
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;
869
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 694
diff changeset
    17
  if(document.getElementById(layerid) && !document.getElementById(layerid).destroying)
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    18
  {
694
43367c66d869 Couple of fixes (hacks) for Opera and the aftermath of that z-index change to darken() and enlighten() fadefilters; added ajaxOpenDirectACLRule() to placeholder list
Dan
parents: 677
diff changeset
    19
    document.getElementById(layerid).style.zIndex = getHighestZ() + 1;
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    20
    if(nofade)
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    21
    {
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
    22
      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
    23
      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
    24
      document.getElementById(layerid).myOpacVal = opacVal;
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    25
    }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    26
    else
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    27
    {
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
    28
      if ( document.getElementById(layerid).style.display != 'none' )
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    29
      {
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
    30
        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
    31
        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
    32
        document.getElementById(layerid).myOpacVal = opacVal;
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    33
      }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    34
      else
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    35
      {
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
    36
        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
    37
        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
    38
        opacity(layerid, 0, opacVal, 1000);
582
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
    }
869
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 694
diff changeset
    41
  }
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 694
diff changeset
    42
  else if(document.getElementById(layerid) && document.getElementById(layerid).destroying)
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 694
diff changeset
    43
  {
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 694
diff changeset
    44
    // fade in progress - abort
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 694
diff changeset
    45
    console.warn('Aborting fade');
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 694
diff changeset
    46
    abortFades();
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 694
diff changeset
    47
    changeOpac(opacVal, layerid);
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 694
diff changeset
    48
    document.getElementById(layerid).destroying = false;
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 694
diff changeset
    49
    return document.getElementById(layerid);
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 694
diff changeset
    50
  }
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 694
diff changeset
    51
  else
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 694
diff changeset
    52
  {
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    53
    w = getWidth();
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    54
    h = getHeight();
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    55
    var thediv = document.createElement('div');
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    56
    if(IE)
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    57
      thediv.style.position = 'absolute';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    58
    else
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    59
      thediv.style.position = 'fixed';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    60
    if ( IE )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    61
    {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    62
      var top = getScrollOffset();
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    63
      thediv.style.top = String(top) + 'px';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    64
    }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    65
    else
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    66
    {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    67
      thediv.style.top = '0px';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    68
    }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    69
    thediv.style.left = '0px';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    70
    thediv.style.opacity = '0';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    71
    thediv.style.filter = 'alpha(opacity=0)';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    72
    thediv.style.backgroundColor = '#000000';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    73
    thediv.style.width =  '100%';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    74
    thediv.style.height = '100%';
694
43367c66d869 Couple of fixes (hacks) for Opera and the aftermath of that z-index change to darken() and enlighten() fadefilters; added ajaxOpenDirectACLRule() to placeholder list
Dan
parents: 677
diff changeset
    75
    thediv.style.zIndex = getHighestZ() + 1;
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
    76
    thediv.id = layerid;
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    77
    thediv.myOpacVal = opacVal;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    78
    if(nofade)
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    79
    {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    80
      thediv.style.opacity = ( parseFloat(opacVal) / 100 );
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    81
      thediv.style.filter = 'alpha(opacity=' + opacVal + ')';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    82
      body = document.getElementsByTagName('body');
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    83
      body = body[0];
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    84
      body.appendChild(thediv);
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    85
    } else {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    86
      body = document.getElementsByTagName('body');
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    87
      body = body[0];
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    88
      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
    89
      opacity(layerid, 0, opacVal, 1000);
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    90
    }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    91
  }
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
    92
  return document.getElementById(layerid);
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    93
}
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    94
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    95
/**
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    96
 * 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
    97
 * @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
    98
 */
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    99
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
   100
function enlighten(nofade, layerid)
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
   101
{
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
   102
  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
   103
  
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
   104
  if(IE)
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
   105
    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
   106
  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
   107
  if ( darkener_index[layerid] > 0 )
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
   108
    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
   109
  if(document.getElementById(layerid))
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
   110
  {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
   111
    if(nofade)
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
   112
    {
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
   113
      document.getElementById(layerid).style.display = 'none';
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
   114
    }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
   115
    else
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
   116
    {
869
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 694
diff changeset
   117
      document.getElementById(layerid).destroying = 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
   118
      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
   119
      opacity(layerid, from, 0, 1000);
907
44851d7e9bda Live Re-Auth is now required for deleting pages, editing ACLs, protecting pages, and clearing logs. Committing in a hurry as a storm is coming in, hope everything is in there.
Dan
parents: 869
diff changeset
   120
      setTimeout("var l = document.getElementById('" + layerid + "'); var b = document.getElementsByTagName('body')[0]; b.removeChild(l);", 1000);
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
   121
    }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
   122
  }
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
   123
  return document.getElementById(layerid);
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
   124
}