/** * HTML ID for modal DOM node * * @private * @constant modalId * * @type {string} */ const modalId = 'user-alert-modal'; /** * Displays a general purpose user alert modal with a title, body text, and confirmation button. * * @function showUserAlertModal * @param {string} title The title/heading text to be displayed * @param {string} text The body text to be displayed * @param {string} confirm_text Text of the confirmation button * * @example * showUserAlertModal('Warning', 'You must wait', 'OK', '/faq/why-must-i-wait', 'Why must I wait?'); */ function showUserAlertModal(title, text, confirm_text) { buildModalDiv(text, confirm_text); window.Forem.showModal({ title, contentSelector: `#${modalId}`, overlay: true, }); } /** * Displays a user rate limit alert modal letting the user know what they did that exceeded a rate limit, * and gives them links to explain why they must wait * * @function showUserAlertModal * @param {string} action_text Description of the action taken by the user * @param {string} next_action_text Description of the next action that can be taken * * @example * showRateLimitModal('Made a comment', 'comment again') */ function showRateLimitModal(action_text, next_action_text) { let rateLimitText = buildRateLimitText(action_text, next_action_text); let rateLimitLink = '/faq'; showUserAlertModal( 'Wait a moment...', rateLimitText, 'Got it', rateLimitLink, 'Why do I have to wait?', ); } /** * HTML template for modal * * @private * @function getModalHtml * * @param {string} text The body text to be displayed * @param {string} confirm_text Text of the confirmation button * * @returns {string} HTML for the modal */ const getModalHtml = (text, confirm_text) => `
${text}