Created
September 24, 2016 13:19
-
-
Save tiagoduarte/425a17637ced534eb95c5c1bf5c02a1b to your computer and use it in GitHub Desktop.
make sharepoint ribbon reappear after being hidden from page customization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function showRibbonOnCustomizedPages() | |
{ | |
if(window.location.href.contains("/Forms/AllItems.aspx")) | |
{ | |
//console.log("library page"); | |
var listViews = $('.ms-listviewtable'); | |
if(listViews.length === 1) | |
{ | |
//console.log('only one view found'); | |
//misterious code - find in parents a match that starts by the specified string | |
var elem = document.getElementById($(listViews).parents('[id^="MSOZoneCell_WebPartWPQ"]').attr('id')); | |
if (elem != null) { | |
//console.log("showing ribbon"); | |
var dummyevent = new Array(); | |
dummyevent["target"] = elem; | |
dummyevent["srcElement"] = elem; | |
elem.parentNode.click(); | |
WpClick(dummyevent); | |
//set the Browse button as default | |
_ribbonStartInit("Ribbon.Browse", true); | |
} | |
} | |
} | |
else | |
{ | |
//console.log("non library page"); | |
} | |
} | |
jQuery(function ($) { | |
setTimeout(function(){ | |
showRibbonOnCustomizedPages(); | |
}, 1000); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment