Instantly share code, notes, and snippets.

View sp.tableOfContentsReferences.html
<link href="/SiteAssets/TableOfContents/sp.tableOfContents.css" type="text/css" rel="stylesheet">
<script src="/SiteAssets/TableOfContents/jquery.min.js" type="text/javascript"></script>
<script src="/SiteAssets/TableOfContents/sp.tableOfContentsSticky.js" type="text/javascript"></script>
<script src="/SiteAssets/TableOfContents/sp.tableOfContents.js" type="text/javascript"></script>
<script src="/SiteAssets/TableOfContents/TableOfContents.conf.js" type="text/javascript"></script>
View TableOfContents.conf.js
$(document).ready(function() {
// Change this options to your need
var options = {
orderedlist: false,
customStyle : "no-bullets",
prepend : true
};
// Initialize table of contents for the rich text editor
$(".ms-rtestate-field").tocMenu(options);
View sp.tableOfContents.js
"use strict";
(function($){
$.fn.tocMenu = function(options)
{
// Helpder Methodes
String.prototype.repeat = function( num )
{
return new Array( num + 1 ).join( this );
};
View sp.tableOfContentsSticky.js
// Author: Fabian Neve / http://fneve.blogspot.ch/
// Date: 18.09.2017
// With input from https://blog.sharepointexperience.com/2014/10/sticky-stuff-in-sharepoint/
//
// Top alignment of ToC has to be defined in sp.tableOfContents.css under #s4-workspace.scroll .right-wp-zone-col
var wrap = $("#s4-workspace");
wrap.on("scroll", function(e) {
View sp.tableOfContents.css
.tocMain {
border-bottom: 1px #333 dashed;
}
.tocMain a:active {
}
.tocMain a:hover {
}
.tocMain a:visited {
color: #0072c6;
}
View TableOfContent.html
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
function hideTOC() {
document.getElementById("theTOC").style.display = 'none';
document.getElementById("show").style.display = 'block';
document.getElementById("hide").style.display = 'none';
}
function showTOC() {
View SP_SkipUpdateFormAfterImageUpload_sample.js
<script type="text/javascript">
window.onload = function() {
if (!PreSaveItem()) return false;if (SPClientForms.ClientFormManager.SubmitClientForm('WPQ2')) return false;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ctl39$g_31aae83b_4f8e_4609_a4ee_d5f9cde46fe4$ctl00$ctl02$ctl00$toolBarTbl$RightRptControls$ctl00$ctl00$diidIOSaveItem", "", true, "", "", false, true))
}
</script>
View SP_clearShortTermFileLockImpersonation.ps1
$web = get-spweb "https://domain/sitecollection/site"
$list = $web.Lists["Documents"]
$item = $list.Items.GetItemById(123)
$userId = $item.File.LockedByUser.ID
$user = $web.AllUsers.GetById($userId)
$impSite = New-Object Microsoft.SharePoint.SPSite($web.Url, $user.UserToken);
$impWeb = $impSite.OpenWeb();
$impList = $impWeb.Lists[$list.Title];
View SP_clearShortTermFileLock.ps1
$web = get-spweb "https://domain/sitecollection/site"
$list = $web.Lists["Documents"]
$item = $list.Items.GetItemById(123)
$item.File.ReleaseLock($item.File.LockId)
$web.Dispose()
View changeDiscussionLabel.js
//self-executing anonymous function
(function () {
// String overrides
function DiscussionListViewStringOverride() {
Strings.STS.L_SPDiscHeroLinkAltText = "New Label"; //change "New Label" into your desired one, eg. "Create News"
Strings.STS.L_SPDiscHeroLinkFormat = "New Label"; //change "New Label" into your desired one, eg. "Create News"
}
DiscussionListViewStringOverride();
ExecuteOrDelayUntilScriptLoaded(DiscussionListViewStringOverride, "strings.js");