themes/admin/js/menu.js
author Dan
Mon, 30 Jul 2007 10:46:17 -0400
changeset 79 5faff33a6580
parent 0 902822492a68
child 80 cb7dde69c301
permissions -rw-r--r--
Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
79
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
     1
/*
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     2
var menuClicked = false;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     3
var menuID = false;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     4
var menuParent = false;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     5
function adminOpenMenu(menu, parent)
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     6
{
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     7
  menuParent = parent;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     8
  if ( typeof(menu) == 'string' )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     9
  {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    10
    menu = document.getElementById(menu);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    11
  }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    12
  if(!menu)
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    13
  {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    14
    alert('Menu object is invalid');
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    15
    return false;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    16
  }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    17
  var off = fetch_offset(parent);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    18
  var dim = fetch_dimensions(parent);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    19
  var w = 200;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    20
  var top = off['top'] + dim['h'];
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    21
  var left = off['left'] + dim['w'] - w;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    22
  menu.style.top = top + 'px';
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    23
  menu.style.left = left + 'px';
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    24
  menu.style.display = 'block';
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    25
  menuID = menu.id;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    26
  setTimeout('setMenuoffEvents();', 500);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    27
  //if(!IE)
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    28
  //  parent.onclick = eval('(function() { this.onclick = function() { adminOpenMenu(\'' + menu.id + '\', this); return false; }; return false; } )');
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    29
}
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    30
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    31
function adminMenuOff()
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    32
{
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    33
  if ( menuID )
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    34
  {
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    35
    menu = document.getElementById(menuID);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    36
    menu.style.display = 'none';
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    37
    menu.onmousedown = false;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    38
    menu.onmouseup = false;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    39
    menuID = false;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    40
    document.onclick = false;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    41
    //menuParent.onclick();
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    42
    //menuParent = false;
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    43
  }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    44
}
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    45
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    46
function setMenuoffEvents()
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    47
{
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    48
  menu = document.getElementById(menuID);
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    49
  menu.onmousedown = function() { menuClicked = true; }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    50
  menu.onmouseup   = function() { setTimeout('menuClicked = false;', 100); }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    51
  document.onclick = function() { if ( menuClicked ) return false; adminMenuOff(); }
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    52
}
79
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    53
*/
0
902822492a68 Initial population
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    54
79
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    55
function admin_expand()
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    56
{
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    57
  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
    58
  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
    59
  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
    60
  if ( content.style.display == 'table' )
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
    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
    63
    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
    64
  }
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    65
  else
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
    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
    68
    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
    69
  }
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    70
}
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    71
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    72
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
    73
{
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    74
  expander.className = 'collapsed';
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    75
  content.style.display = 'none';
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    76
  holder.style.width = '0px';
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    77
  holder.style.paddingRight = '12px';
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    78
  holder.style.paddingLeft = '0px';
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    79
}
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    80
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    81
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
    82
{
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    83
  expander.className = 'expanded';
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    84
  content.style.display = 'table';
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    85
  holder.style.width = '230px';
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    86
  holder.style.paddingLeft = '12px';
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    87
  holder.style.paddingRight = '0px';
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    88
}
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    89
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    90
function expander_set_height()
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    91
{
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    92
  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
    93
  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
    94
  var height = getHeight();
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    95
  var exheight = height - magic;
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    96
  expander.style.height = exheight + 'px';
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    97
  expander.style.top = magic + 'px';
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    98
}
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
    99
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
   100
function expander_onload()
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
   101
{
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
   102
  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
   103
  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
   104
  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
   105
  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
   106
  {
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
   107
    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
   108
  }
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
   109
  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
   110
  {
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
   111
    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
   112
  }
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
   113
}
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
   114
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
   115
addOnloadHook(expander_set_height);
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
   116
addOnloadHook(expander_onload);
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
   117
window.onresize = expander_set_height;
5faff33a6580 Admin theme now uses a collapsable sidebar instead of that ugly menu (WiP)
Dan
parents: 0
diff changeset
   118