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
{ | |
"properties": { | |
"name": { | |
"description": "The slug name of your site.", | |
"type": "string", | |
"minLength": 1 | |
}, | |
"production": { | |
"description": "The production URL of your site.", | |
"type": "object", |
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
const { select, subscribe } = wp.data; | |
const closeListener = subscribe( () => { | |
const isReady = select( 'core/editor' ).__unstableIsEditorReady(); | |
if ( ! isReady ) { | |
// Editor not ready. | |
return; | |
} | |
// Close the listener as soon as we know we are ready to avoid an infinite loop. | |
closeListener(); |
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
const $ = jQuery | |
class AbstractDomElement { | |
constructor(element, options) { | |
let oldInstance | |
// provide an explicit spaceName to prevent conflict after minification | |
// MaClass.nameSpace = 'MaClass' | |
this.constructor.nameSpace = this.constructor.nameSpace || this.constructor.name | |
const nameSpace = this.constructor.nameSpace |
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
const $ = jQuery | |
class AbstractDomElement { | |
constructor(element, options) { | |
let oldInstance | |
// provide an explicit spaceName to prevent conflict after minification | |
// MaClass.nameSpace = 'MaClass' | |
this.constructor.nameSpace = this.constructor.nameSpace || this.constructor.name | |
const nameSpace = this.constructor.nameSpace |
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
/** | |
* Escape Regex if string has any symbols | |
* @param {String} input input string to escape | |
*/ | |
const escapeRegExp = input => { | |
if (/\W|[_]/g.test(input)) { | |
return input.replace(/\W|_/g, '[$&]') | |
} | |
return input |
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
/** | |
* Scroll to animation | |
* @param {(HTMLElement|Number)} destination Scroll to an specific element or a numerical value | |
* @param {Number} duration Duration of the animation | |
* @param {String} easing Easing of the animation | |
* @param {Number} offset Offset of the scroll | |
* @param {Function} callback Callback function | |
*/ | |
const smoothScroll = (destination, duration = 300, easing = 'linear', offset = 0, callback) => { | |
const easings = { |
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
export const getSiblings = element => { | |
// Setup siblings array and get the first sibling | |
const siblings = [] | |
let sibling = element.parentNode.firstChild | |
// Loop through each sibling and push to the array | |
while (sibling) { | |
if (sibling.nodeType === 1 && sibling !== element) { | |
siblings.push(sibling) | |
} |
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
export const prevAll = element => { | |
const prevElements = [] | |
let prevElement = element.parentNode.firstElementChild | |
while(prevElement !== element) { | |
prevElements.push(prevElement) | |
prevElement = prevElement.nextElementSibling | |
} | |
return prevElements |
NewerOlder