UNPKG

next-dialog

Version:

A lightweight dialog plugin based on vanilla js

86 lines (71 loc) 1.14 kB
const ClassPrefix = "next-dialog"; export default class NextDialog { constructor(options) { this.key = this._guid(); this.options = options; this.init(); } /** * Helpers */ /** * Globally Unique Identifier * @returns {string} */ _guid() { return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace( /[xy]/g, function (c) { const r = (Math.random() * 16) | 0; const v = c === "x" ? r : (r & 0x3) | 0x8; return v.toString(16); } ); } /** * Init */ init() { // } /** * Event */ _bindEvents() { // } /** * Constructors */ // Open dropdown open() { // } // Close dropdown close() { // } /** * Callback methods */ _onOpen() { if (this.options.onOpen) { this.options.onOpen(); } } _onClose() { if (this.options.onClose) { this.options.onClose(); } } _beforeOpen() { if (this.options.beforeOpen) { this.options.beforeOpen(); } } _beforeClose() { if (this.options.beforeClose) { this.options.beforeClose(); } } }