script.js (776B)
1 // Global object for shared functions and data. 2 window.rwmb = window.rwmb || {}; 3 4 ( function( $, document, rwmb ) { 5 'use strict'; 6 7 // Selectors for all plugin inputs. 8 rwmb.inputSelectors = 'input[class*="rwmb"], textarea[class*="rwmb"], select[class*="rwmb"], button[class*="rwmb"]'; 9 10 // Detect Gutenberg. 11 rwmb.isGutenberg = document.body.classList.contains( 'block-editor-page' ); 12 13 // Generate unique ID. 14 rwmb.uniqid = function uniqid() { 15 return Math.random().toString( 36 ).substr( 2 ); 16 } 17 18 // Trigger a custom ready event for all scripts to hook to. 19 // Used for static DOM and dynamic DOM (loaded in MB Blocks extension for Gutenberg). 20 rwmb.$document = $( document ); 21 $( function() { 22 rwmb.$document.trigger( 'mb_ready' ); 23 } ); 24 } )( jQuery, document, rwmb );