SharePoint Core JavaScript Library

SharePoint contains many core javascript files that can be used to customize the experience for the user, while keeping things native to SharePoint. Refer to this blog post for additional details.

Documentation

Code Reference

// JavaScript
var $REST = require("gd-sprest");
$REST.Helper.SP.ModalDialog

// TypeScript
import { Helper } from "gd-sprest";
Helper.SP.ModalDialog

Dialog Options

Property Type Description
allowMaximize boolean A Boolean value that specifies whether the dialog can be maximized. true if the Maximize button is shown; otherwise, false.
args any An object that contains data that are passed to the dialog.
autoSize boolean A Boolean value that specifies whether the dialog platform handles dialog sizing.
dialogReturnValueCallback (dialogResult: number, returnVal: any) => void A function pointer that specifies the return callback function. The function takes two parameters, a dialogResult of type SP.UI.DialogResult Enumeration and a returnValue of type object that contains any data returned by the dialog.
height number An integer value that specifies the height of the dialog. If height is not specified, the height of the dialog is autosized by default. If autosize is false, the dialog height is set to 576 pixels.
html HtmlElement An html element to appear in the dialog. If both html and url are specified, url takes precedence. Either url or html must be specified. The html element is removed from the DOM after the dialog closes.
showClose boolean A Boolean value that specifies whether the Close button appears on the dialog.
showMaximized boolean A Boolean value that specifies whether the dialog opens in a maximized state. true the dialog opens maximized. Otherwise, the dialog is opened at the requested sized if specified; otherwise, the default size, if specified; otherwise, the autosized size.
title string A string that contains the title of the dialog.
url string A string that contains the URL of the page that appears in the dialog. If both url and html are specified, url takes precedence. Either url or html must be specified.
width number An integer value that specifies the width of the dialog. If width is not specified, the width of the dialog is autosized by default. If autosize is false, the width of the dialog is set to 768 pixels.
x number An integer value that specifies the x-offset of the dialog. This value works like the CSS left value.
y number An integer value that specifies the y-offset of the dialog. This value works like the CSS top value.

Methods

Name Parameters Description
close (dialogResult?: number) Closes the most recently opened modal dialog with the specified dialog result.
commonModalDialogClose (dialogResult?: number, returnVal?: any) Closes the most recently opened modal dialog with the specified dialog result and return value.
commonModalDialogOpen (url: string, options?: IDialogOptions, callback?: (dialogResult?: number, returnVal?: any) => void, args?: any) Displays a modal dialog with the specified URL, options, callback function, and arguments.
load   Method to ensure the core script is loaded.
OpenPopUpPage (url: string, callback?: (dialogResult?: number, returnVal?: any) => void, width?: number, height?: number) Displays a modal dialog with the specified URL, callback function, width, and height.
RefreshPage (dialogResult?: number) Refreshes the parent page of the modal dialog when the dialog is closed by clicking OK.
showModalDialog (options: IDialogOptions) Displays a modal dialog with specified dialog options.
ShowPopupDialog (url: string) Displays a modal dialog using the page at the specified URL.
showWaitScreenSize (title: string, message: string, callback: () => void, height: number, width: number) Displays a wait screen dialog that has a Cancel button using the specified parameters.
showWaitScreenWithNoClose (title: string, message: string, height: number, width: number) Displays a wait screen dialog that does not have a Cancel button using the specified parameters.

Notify

Documentation

Code Reference

// JavaScript
var $REST = require("gd-sprest");
$REST.Helper.SP.Notify

// TypeScript
import { Helper } from "gd-sprest";
Helper.SP.Notify

Methods

Name Parameters Description
addNotification (html: string, sticky?: boolean) Adds a notification to the page. By default, notifications appear for five seconds.
load   Method to ensure the core script is loaded.
removeNotification (id: string) Removes the specified notification from the page.

Status

Documentation

Code Reference

// JavaScript
var $REST = require("gd-sprest");
$REST.Helper.SP.Status

// TypeScript
import { Helper } from "gd-sprest";
Helper.SP.Status

Methods

Name Parameters Description
addStatus (title: string, html?: string, prepend?: boolean) Adds a status message to the page.
appendStatus (id: string, title: string, html: string) Appends text to an existing status message.
load   Method to ensure the core script is loaded.
removeAllStatus (hide?: boolean) Removes all status messages from the page.
removeStatus (id: string) Removes the specified status message.
setStatusPriColor (id: string, color: string) Sets the priority color of the specified status message.
updateStatus (id: string, html: string) Updates the specified status message.