A utility library for working with the Sitecore CMS.
THIS REPOSITORY IS NO LONGER MAINTAINED
sitecoreUtils is an ES6 module. Consequently, you'll need an ES6 transpiler (Babel is a nice one) and a module loader (SystemJS will do the job) as part of your Javascript workflow.
If you're already using the JSPM package manager for your project, you can install sitecoreUtils with the following command:
$ jspm install github:DEGJS/sitecoreUtils
import { isSitecoreEditMode } from "DEGJS/sitecoreUtils";
let editModeCheck = isSitecoreEditMode();import * as sitecoreUtils from "DEGJS/sitecoreUtils";
let editModeCheck = sitecoreUtils.isSitecoreEditMode();Returns a boolean value depending on whether the site is currently in Sitecore's logged-in Experience Editor mode, based on a class set on a DOM element.
Type: String
Default: sc--edit-mode
The class name that's tested for on a given element
Type: DOM element
Default: document.body
The element that's checked for the given class
sitecoreUtils depends on the following browser APIs:
- classList: Documentation | Polyfill
To support legacy browsers, you'll need to include polyfills for the above API.