I am trying to hide the ribbon by default, but display the ribbon when a user gives focus (clicking) on any web part on a page. There are several sites I have tried to emulate, however, have run into a snag during the implementation. The sites I have found helpful, include:
- http://marcellotonarelli.wordpress.com/2011/09/05/hide-the-sharepoint-2010-ribbon/#comment-3989
- http://www.blogger.com/comment.g?blogID=7599218781305366419&postID=2879781993148375516&page=1&token=1350398347147
- http://www.thelineberrys.com/default-category/option-to-show-the-sharepoint-2010-ribbon-when-hidden-by-default-2.html
Here is the current code to register the CTRL-G keys
// Registering 'ctrl' + 'G' button press $.ctrl('G', function (s) { var ribbonElement = $(CtrlGControlsToHide); var displayPropValue = (ribbonElement.css('display') == 'none' ? 'block' : 'none'); ribbonElement.css('display', displayPropValue); // Set display state for the following hour var date = new Date(); date.setTime(date.getTime() + (60 * 60 * 1000)); $.cookie(RibbonDisplayCookieName, displayPropValue, { expires: date }); }, ["Control G pressed"]); // Loading cookie value of ribbon display if ($.cookie(RibbonDisplayCookieName) == 'block') document.write("<style> " + CtrlGControlsToHide + " { display:block; } </style>");
Here is my attempt to show/hide the ribbon when a web part is clicked. Something is wrong with my code below.
function OnRibbonMinimizedChanged(ribbonMinimized) {ULSxSy:; var ribbonElement=GetCachedElement("s4-ribbonrow"); if (ribbonElement) { if (ribbonMinimized) { ribbonElement.style.display = "none"; //alert('None'); //$(".mysidenav").animate({ 'margin-top': '15px' }, 0); } else { ribbonElement.style.display = "block"; //alert('Block'); } } }