themes/admin/js/menu.js
author Dan
Sun, 25 Nov 2007 21:40:42 -0500
changeset 240 ee1fc84f12a8
parent 86 c162ca39db8f
permissions -rw-r--r--
SECURITY: Tighten default allowed file types; make sure search index rebuild is performed on upgrade
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
86
c162ca39db8f Finished pagination code (was incomplete in previous revision) and added a few hacks for an upcoming theme
Dan
parents: 81
diff changeset
     1
/*
c162ca39db8f Finished pagination code (was incomplete in previous revision) and added a few hacks for an upcoming theme
Dan
parents: 81
diff changeset
     2
 * IE doesn't like display: table.
c162ca39db8f Finished pagination code (was incomplete in previous revision) and added a few hacks for an upcoming theme
Dan
parents: 81
diff changeset
     3
 */
c162ca39db8f Finished pagination code (was incomplete in previous revision) and added a few hacks for an upcoming theme
Dan
parents: 81
diff changeset
     4
80
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 79
diff changeset
     5
var TBL_SHOW = ( IE ) ? 'block' : 'table';
86
c162ca39db8f Finished pagination code (was incomplete in previous revision) and added a few hacks for an upcoming theme
Dan
parents: 81
diff changeset
     6
79
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
     7
function admin_expand()
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
     8
{
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
     9
  var expander = document.getElementById('sidebar-hide');
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    10
  var content  = document.getElementById('sidebar-show');
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    11
  var holder  = document.getElementById('td-sidebar');
80
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 79
diff changeset
    12
  if ( content.style.display == TBL_SHOW )
79
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    13
  {
80
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 79
diff changeset
    14
    admin_collapse_real(expander, content, holder);
79
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    15
    createCookie('theme_admin_sidebar', 'collapsed', 3650);
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    16
  }
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    17
  else
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    18
  {
80
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 79
diff changeset
    19
    admin_expand_real(expander, content, holder);
79
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    20
    createCookie('theme_admin_sidebar', 'expanded', 3650);
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    21
  }
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    22
}
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    23
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    24
function admin_collapse_real(expander, content, holder)
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    25
{
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    26
  expander.className = 'collapsed';
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    27
  content.style.display = 'none';
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    28
  holder.style.width = '0px';
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    29
  holder.style.paddingRight = '12px';
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    30
  holder.style.paddingLeft = '0px';
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    31
}
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    32
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    33
function admin_expand_real(expander, content, holder)
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    34
{
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    35
  expander.className = 'expanded';
80
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 79
diff changeset
    36
  content.style.display = TBL_SHOW;
79
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    37
  holder.style.width = '230px';
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    38
  holder.style.paddingLeft = '12px';
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    39
  holder.style.paddingRight = '0px';
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    40
}
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    41
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    42
function expander_set_height()
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    43
{
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    44
  var expander = document.getElementById('sidebar-hide');
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    45
  var magic = $('header').Height() + $('pagebar_main').Height();
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    46
  var height = getHeight();
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    47
  var exheight = height - magic;
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    48
  expander.style.height = exheight + 'px';
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    49
  expander.style.top = magic + 'px';
81
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
    50
  expander_set_pos();
79
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    51
}
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    52
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    53
function expander_onload()
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    54
{
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    55
  var expander = document.getElementById('sidebar-hide');
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    56
  var content  = document.getElementById('sidebar-show');
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    57
  var holder  = document.getElementById('td-sidebar');
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    58
  if ( readCookie('theme_admin_sidebar') == 'collapsed' )
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    59
  {
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    60
    admin_collapse_real(expander, content, holder);
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    61
  }
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    62
  else if ( readCookie('theme_admin_sidebar') == 'expanded' )
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    63
  {
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    64
    admin_expand_real(expander, content, holder);
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    65
  }
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    66
}
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    67
81
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
    68
function expander_set_pos()
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
    69
{
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
    70
  var winheight = getHeight();
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
    71
  var magic = $('header').Height() + $('pagebar_main').Height();
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
    72
  var top = getScrollOffset();
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
    73
  if ( typeof(top) != 'number' )
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
    74
  {
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
    75
    return null;
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
    76
  }
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
    77
  magic = magic - top;
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
    78
  if ( magic < 0 )
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
    79
    magic = 0;
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
    80
  var bartop = magic + top;
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
    81
  var barheight = winheight - magic;
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
    82
  var expander = document.getElementById('sidebar-hide');
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
    83
  expander.style.top = bartop + 'px';
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
    84
  expander.style.height = barheight + 'px';
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
    85
}
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
    86
79
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    87
addOnloadHook(expander_set_height);
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    88
addOnloadHook(expander_onload);
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    89
window.onresize = expander_set_height;
81
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
    90
window.onscroll = expander_set_pos;