Skip to content
Snippets Groups Projects
Select Git revision
  • 8c75f98216614808aed44638437664e816ebc2f0
  • main default protected
  • renovate/lock-file-maintenance
  • demo protected
  • person-select-custom
  • dbp-translation-component
  • icon-set-mapping
  • port-i18next-parser
  • remove-sentry
  • favorites-and-recent-files
  • revert-6c632dc6
  • lit2
  • advertisement
  • wc-part
  • automagic
  • publish
  • wip-cleanup
  • demo-file-handling
18 results

notification.js

Blame
  • notification.js 776 B
    /**
     * Sends a notification via the event
     *
     * Type can be info/success/warning/danger
     *
     * example options:
     *
     * {
     *   "summary": "Item deleted",
     *   "body": "Item foo was deleted!",
     *   "type": "info",
     *   "timeout": 5,
     * }
     *
     * @param options
     */
    function send(options) {
        const event = new CustomEvent("dbp-notification-send", {
            bubbles: true,
            cancelable: true,
            detail: options,
        });
    
        const result = window.dispatchEvent(event);
    
        // true means the event was not handled
        if (result) {
            alert((options.summary !== undefined && options.summary !== "" ? options.summary + ": " : "") + options.body);
            console.log("Use the web component dbp-notification to show fancy notifications.");
        }
    }
    
    export { send };