es este:
http://www.dhtmlgoodies.com/index.ht...slide_out_menu
lo implemente para q pudiera coger los valores de la base de datos y hasta ahi bien. Pero mi problema es k en la misma pagina compongo 2 menus: uno publico y otro privado. Pongo aki la modificación q le echo al script de la pagina (se q es un poco largo y un coñazo):
archivo.php (para cargar la funcion)
Código:
function cargar() { var privado=<? if ($sess_member_id){echo "1";}else{echo"0";}?>; if (privado==1) { initLeftMenu1(); } initLeftMenu(); window.onresize = resetPosition; }
archivo.js
Código:
var timeBeforeAutoHide = 700; // Microseconds to wait before auto hiding menu(1000 = 1 second) var slideSpeed_out = 10; // Steps to move sub menu at a time ( higher = faster) var slideSpeed_in = 10; var slideTimeout_out = 25; // Microseconds between slide steps ( lower = faster) var slideTimeout_in = 10; // Microseconds between slide steps ( lower = faster) var showSubOnMouseOver = true; // false = show sub menu on click, true = show sub menu on mouse over var fixedSubMenuWidth = false; // Width of sub menu items - A number(width in pixels) or false when width should be dynamic var fixedSubMenuWidth_Public = false; // Width of sub menu items - A number(width in pixels) or false when width should be dynamic var showSubOnMouseOver_Public = true; // false = show sub menu on click, true = show sub menu on mouse over var xOffsetSubMenu = 0; // Offset x-position of sub menu items - use negative value if you want the sub menu to overlap main menu var slideDirection = 'right'; // Slide to left or right ? var activeSubMenuId = false; var activeSubMenuId_Public = false; var activeMainMenuItem = false; var activeMainMenuItem_Public = false; var currentZIndex = 1000; var autoHideTimer = 0; var submenuObjArray = new Array(); var submenuObjArray_Public = new Array(); var okToSlideInSub = new Array(); var okToSlideInSub_Public = new Array(); var subPositioned = new Array(); var subPositioned_Public = new Array(); function stopAutoHide() { autoHideTimer = -1; } function stopAutoHide_Public() { autoHideTimer = -1; } function initAutoHide() { autoHideTimer = 0; if(autoHideTimer>=0)autoHide(); } function autoHide() { if(autoHideTimer>timeBeforeAutoHide) { if(activeMainMenuItem){ activeMainMenuItem.className=''; activeMainMenuItem = false; } if(activeSubMenuId){ var obj = document.getElementById('subMenuDiv' + activeSubMenuId); showSub(); } }else{ if(autoHideTimer>=0){ autoHideTimer+=50; setTimeout('autoHide()',50); } } } //.... function initAutoHide_Public() { autoHideTimer = 0; if(autoHideTimer>=0)autoHide_Public(); } function autoHide_Public() { if(autoHideTimer>timeBeforeAutoHide) { if(activeMainMenuItem_Public){ activeMainMenuItem_Public.className=''; activeMainMenuItem_Public = false; } if(activeSubMenuId_Public){ var obj = document.getElementById('subMenuDiv' + activeSubMenuId_Public); showSub_Public(); } }else{ if(autoHideTimer>=0){ autoHideTimer+=50; setTimeout('autoHide_Public()',50); } } } //..... function getTopPos(inputObj) { var returnValue = inputObj.offsetTop; while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetTop; return returnValue; } function getLeftPos(inputObj) { var returnValue = inputObj.offsetLeft; while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft; return returnValue; } function showSub() { var subObj = false; if(this && this.tagName){ var numericId = this.parentNode.id.replace(/[^0-9]/g,''); okToSlideInSub[numericId] = false; var subObj = document.getElementById('subMenuDiv' + numericId); if(activeMainMenuItem)activeMainMenuItem.className=''; if(subObj){ if(!subPositioned[numericId]){ if(slideDirection=='right'){ subObj.style.left = getLeftPos(submenuObjArray[numericId]['parentDiv']) + submenuObjArray[numericId]['parentDiv'].offsetWidth + xOffsetSubMenu + 'px'; }else{ subObj.style.left = getLeftPos(submenuObjArray[numericId]['parentDiv']) + xOffsetSubMenu + 'px'; } submenuObjArray[numericId]['left'] = subObj.style.left.replace(/[^0-9]/g,''); subObj.style.top = getTopPos(submenuObjArray[numericId]['parentDiv']) + 'px'; subPositioned[numericId] = true; } subObj.style.visibility = 'visible'; subObj.style.zIndex = currentZIndex; currentZIndex++; this.className='activeMainMenuItem'; activeMainMenuItem = this; } }else{ var numericId = activeSubMenuId; } if(activeSubMenuId && (numericId!=activeSubMenuId || !subObj))slideMenu(activeSubMenuId,(slideSpeed_in*-1)); if(numericId!=activeSubMenuId && this && subObj){ subObj.style.width = '0px'; slideMenu(numericId,slideSpeed_out); activeSubMenuId = numericId; }else{ if(numericId!=activeSubMenuId)activeSubMenuId = false; } if(showSubOnMouseOver)stopAutoHide(); } //.... function showSub_Public() { var subObj = false; if(this && this.tagName){ var numericId = this.parentNode.id.replace(/[^0-9]/g,''); okToSlideInSub_Public[numericId] = false; var subObj = document.getElementById('subMenuDiv' + numericId); if(activeMainMenuItem_Public)activeMainMenuItem_Public.className=''; if(subObj){ if(!subPositioned_Public[numericId]){ if(slideDirection=='right'){ subObj.style.left = getLeftPos(submenuObjArray_Public[numericId]['parentDiv']) + submenuObjArray_Public[numericId]['parentDiv'].offsetWidth + xOffsetSubMenu + 'px'; }else{ subObj.style.left = getLeftPos(submenuObjArray_Public[numericId]['parentDiv']) + xOffsetSubMenu + 'px'; } submenuObjArray_Public[numericId]['left'] = subObj.style.left.replace(/[^0-9]/g,''); subObj.style.top = getTopPos(submenuObjArray_Public[numericId]['parentDiv']) + 'px'; subPositioned_Public[numericId] = true; } subObj.style.visibility = 'visible'; subObj.style.zIndex = currentZIndex; currentZIndex++; this.className='activeMainMenuItem_Public'; activeMainMenuItem_Public = this; } }else{ var numericId = activeSubMenuId_Public; } if(activeSubMenuId_Public && (numericId!=activeSubMenuId_Public || !subObj))slideMenu_Public(activeSubMenuId_Public,(slideSpeed_in*-1)); if(numericId!=activeSubMenuId_Public && this && subObj){ subObj.style.width = '0px'; slideMenu_Public(numericId,slideSpeed_out); activeSubMenuId_Public = numericId; }else{ if(numericId!=activeSubMenuId_Public)activeSubMenuId_Public = false; } if(showSubOnMouseOver_Public)stopAutoHide_Public(); } function slideMenu(menuIndex,speed){ var obj = submenuObjArray[menuIndex]['divObj']; var obj2 = submenuObjArray[menuIndex]['ulObj']; var width = obj.offsetWidth + speed; if(speed<0){ if(width<0)width = 0; obj.style.width = width + 'px'; if(slideDirection=='left'){ obj.style.left = submenuObjArray[menuIndex]['left'] - width + 'px'; obj2.style.left = '0px'; }else{ obj2.style.left = width - submenuObjArray[menuIndex]['width'] + 'px' } if(width>0 && okToSlideInSub[menuIndex])setTimeout('slideMenu(' + menuIndex + ',' + speed + ')',slideTimeout_in); else{ obj.style.visibility = 'hidden'; obj.style.width = '0px'; if(activeSubMenuId==menuIndex)activeSubMenuId=false; } }else{ if(width>submenuObjArray[menuIndex]['width'])width = submenuObjArray[menuIndex]['width']; if(slideDirection=='left'){ obj.style.left = submenuObjArray[menuIndex]['left'] - width + 'px'; obj2.style.left = '0px'; }else{ obj2.style.left = width - submenuObjArray[menuIndex]['width'] + 'px' } obj.style.width = width + 'px'; if(width<submenuObjArray[menuIndex]['width']){ setTimeout('slideMenu(' + menuIndex + ',' + speed + ')',slideTimeout_out); }else{ okToSlideInSub[menuIndex] = true; } } } // .... function slideMenu_Public(menuIndex,speed){ var obj = submenuObjArray_Public[menuIndex]['divObj']; var obj2 = submenuObjArray_Public[menuIndex]['ulObj']; var width = obj.offsetWidth + speed; if(speed<0){ if(width<0)width = 0; obj.style.width = width + 'px'; if(slideDirection=='left'){ obj.style.left = submenuObjArray_Public[menuIndex]['left'] - width + 'px'; obj2.style.left = '0px'; }else{ obj2.style.left = width - submenuObjArray_Public[menuIndex]['width'] + 'px' } if(width>0 && okToSlideInSub_Public[menuIndex])setTimeout('slideMenu_Public(' + menuIndex + ',' + speed + ')',slideTimeout_in); else{ obj.style.visibility = 'hidden'; obj.style.width = '0px'; if(activeSubMenuId_Public==menuIndex)activeSubMenuId_Public=false; } }else{ if(width>submenuObjArray_Public[menuIndex]['width'])width = submenuObjArray_Public[menuIndex]['width']; if(slideDirection=='left'){ obj.style.left = submenuObjArray_Public[menuIndex]['left'] - width + 'px'; obj2.style.left = '0px'; }else{ obj2.style.left = width - submenuObjArray_Public[menuIndex]['width'] + 'px' } obj.style.width = width + 'px'; if(width<submenuObjArray_Public[menuIndex]['width']){ setTimeout('slideMenu_Public(' + menuIndex + ',' + speed + ')',slideTimeout_out); }else{ okToSlideInSub_Public[menuIndex] = true; } } }