themes/admin/js/menu.js
changeset 0 902822492a68
child 79 5faff33a6580
equal deleted inserted replaced
-1:000000000000 0:902822492a68
       
     1 var menuClicked = false;
       
     2 var menuID = false;
       
     3 var menuParent = false;
       
     4 function adminOpenMenu(menu, parent)
       
     5 {
       
     6   menuParent = parent;
       
     7   if ( typeof(menu) == 'string' )
       
     8   {
       
     9     menu = document.getElementById(menu);
       
    10   }
       
    11   if(!menu)
       
    12   {
       
    13     alert('Menu object is invalid');
       
    14     return false;
       
    15   }
       
    16   var off = fetch_offset(parent);
       
    17   var dim = fetch_dimensions(parent);
       
    18   var w = 200;
       
    19   var top = off['top'] + dim['h'];
       
    20   var left = off['left'] + dim['w'] - w;
       
    21   menu.style.top = top + 'px';
       
    22   menu.style.left = left + 'px';
       
    23   menu.style.display = 'block';
       
    24   menuID = menu.id;
       
    25   setTimeout('setMenuoffEvents();', 500);
       
    26   //if(!IE)
       
    27   //  parent.onclick = eval('(function() { this.onclick = function() { adminOpenMenu(\'' + menu.id + '\', this); return false; }; return false; } )');
       
    28 }
       
    29 
       
    30 function adminMenuOff()
       
    31 {
       
    32   if ( menuID )
       
    33   {
       
    34     menu = document.getElementById(menuID);
       
    35     menu.style.display = 'none';
       
    36     menu.onmousedown = false;
       
    37     menu.onmouseup = false;
       
    38     menuID = false;
       
    39     document.onclick = false;
       
    40     //menuParent.onclick();
       
    41     //menuParent = false;
       
    42   }
       
    43 }
       
    44 
       
    45 function setMenuoffEvents()
       
    46 {
       
    47   menu = document.getElementById(menuID);
       
    48   menu.onmousedown = function() { menuClicked = true; }
       
    49   menu.onmouseup   = function() { setTimeout('menuClicked = false;', 100); }
       
    50   document.onclick = function() { if ( menuClicked ) return false; adminMenuOff(); }
       
    51 }
       
    52