themes/admin/js/menu.js
changeset 80 cb7dde69c301
parent 79 5faff33a6580
child 81 d7fc25acd3f3
equal deleted inserted replaced
79:5faff33a6580 80:cb7dde69c301
     1 /*
     1 var TBL_SHOW = ( IE ) ? 'block' : 'table';
     2 var menuClicked = false;
       
     3 var menuID = false;
       
     4 var menuParent = false;
       
     5 function adminOpenMenu(menu, parent)
       
     6 {
       
     7   menuParent = parent;
       
     8   if ( typeof(menu) == 'string' )
       
     9   {
       
    10     menu = document.getElementById(menu);
       
    11   }
       
    12   if(!menu)
       
    13   {
       
    14     alert('Menu object is invalid');
       
    15     return false;
       
    16   }
       
    17   var off = fetch_offset(parent);
       
    18   var dim = fetch_dimensions(parent);
       
    19   var w = 200;
       
    20   var top = off['top'] + dim['h'];
       
    21   var left = off['left'] + dim['w'] - w;
       
    22   menu.style.top = top + 'px';
       
    23   menu.style.left = left + 'px';
       
    24   menu.style.display = 'block';
       
    25   menuID = menu.id;
       
    26   setTimeout('setMenuoffEvents();', 500);
       
    27   //if(!IE)
       
    28   //  parent.onclick = eval('(function() { this.onclick = function() { adminOpenMenu(\'' + menu.id + '\', this); return false; }; return false; } )');
       
    29 }
       
    30 
       
    31 function adminMenuOff()
       
    32 {
       
    33   if ( menuID )
       
    34   {
       
    35     menu = document.getElementById(menuID);
       
    36     menu.style.display = 'none';
       
    37     menu.onmousedown = false;
       
    38     menu.onmouseup = false;
       
    39     menuID = false;
       
    40     document.onclick = false;
       
    41     //menuParent.onclick();
       
    42     //menuParent = false;
       
    43   }
       
    44 }
       
    45 
       
    46 function setMenuoffEvents()
       
    47 {
       
    48   menu = document.getElementById(menuID);
       
    49   menu.onmousedown = function() { menuClicked = true; }
       
    50   menu.onmouseup   = function() { setTimeout('menuClicked = false;', 100); }
       
    51   document.onclick = function() { if ( menuClicked ) return false; adminMenuOff(); }
       
    52 }
       
    53 */
       
    54 
       
    55 function admin_expand()
     2 function admin_expand()
    56 {
     3 {
    57   var expander = document.getElementById('sidebar-hide');
     4   var expander = document.getElementById('sidebar-hide');
    58   var content  = document.getElementById('sidebar-show');
     5   var content  = document.getElementById('sidebar-show');
    59   var holder  = document.getElementById('td-sidebar');
     6   var holder  = document.getElementById('td-sidebar');
    60   if ( content.style.display == 'table' )
     7   if ( content.style.display == TBL_SHOW )
    61   {
     8   {
       
     9     admin_collapse_real(expander, content, holder);
    62     createCookie('theme_admin_sidebar', 'collapsed', 3650);
    10     createCookie('theme_admin_sidebar', 'collapsed', 3650);
    63     admin_collapse_real(expander, content, holder);
       
    64   }
    11   }
    65   else
    12   else
    66   {
    13   {
       
    14     admin_expand_real(expander, content, holder);
    67     createCookie('theme_admin_sidebar', 'expanded', 3650);
    15     createCookie('theme_admin_sidebar', 'expanded', 3650);
    68     admin_expand_real(expander, content, holder);
       
    69   }
    16   }
    70 }
    17 }
    71 
    18 
    72 function admin_collapse_real(expander, content, holder)
    19 function admin_collapse_real(expander, content, holder)
    73 {
    20 {
    79 }
    26 }
    80 
    27 
    81 function admin_expand_real(expander, content, holder)
    28 function admin_expand_real(expander, content, holder)
    82 {
    29 {
    83   expander.className = 'expanded';
    30   expander.className = 'expanded';
    84   content.style.display = 'table';
    31   content.style.display = TBL_SHOW;
    85   holder.style.width = '230px';
    32   holder.style.width = '230px';
    86   holder.style.paddingLeft = '12px';
    33   holder.style.paddingLeft = '12px';
    87   holder.style.paddingRight = '0px';
    34   holder.style.paddingRight = '0px';
    88 }
    35 }
    89 
    36