Class: Notifier

notifier~Notifier()

Main class. It contains all functions and manages paper-dialog and paper-toast elements currently on the page. You don't have to worry about multiple instances

Constructor

new Notifier()

Source:

Members

dialog

Get dialog element or create one if needed

Source:

(constant) MATERIAL_DIALOG_ANIMATION

Source:

toast

Get toast element or create one if needed

Source:

Methods

askDialog(msgopt, optionsopt) → {Promise}

Predefined dialog with a yes/no question

Parameters:
Name Type Attributes Default Description
msg String <optional>
'Are you sure?'

Header text

options Object <optional>
Properties
Name Type Attributes Default Description
innerMsg String <optional>

Massage in dialog body

cancelText String <optional>
'No'

Text to show in cancel button

acceptText String <optional>
'Yes'

Text to show in accept button

attributes object <optional>

Attributes to be passed down to the dialog, { attr: value }

noBackdrop boolean <optional>

Don't show backdrop behind dialog

formatted boolean <optional>
false

If true,content will be put directly into element, otherwise put inside <paper-scrollable-dialog>

target Element <optional>
window

Target element on which dialog will be appended

beforeClose function <optional>

Function to be run after accepting but before removing the dialog, if set returned promise will resolve with it's results

animationConfig object <optional>

animationConfig on dialog element, if unset will default to Material animation

Source:
Returns:

A promise that will resolve if dialog was accepted or reject with error: false when cancelled

Type
Promise

showDialog(header, content, optionsopt) → {Promise}

Opens a dialog

Parameters:
Name Type Attributes Description
header string

Header of the dialog

content string

Content of the dialog, must be a string with all tags, including bottom buttons

options object <optional>
Properties
Name Type Attributes Default Description
attributes object <optional>

Attributes to be passed down to the dialog, { attr: value }

noBackdrop boolean <optional>

Don't show backdrop behind dialog

formatted boolean <optional>
false

If true,content will be put directly into element, otherwise put inside <paper-scrollable-dialog>

target Element <optional>
window

Target element on which dialog will be appended

beforeClose function <optional>

Function to be run after accepting but before removing the dialog, if set promise will resolve with it's resoluts

animationConfig object <optional>

animationConfig on dialog element, if unset will default to Material animation

Source:
Returns:

A promise that will resolve if dialog was accepted or reject with error: false when cancelled

Type
Promise

(async) showToast(msg, optionsopt)

Opens a toast with provided message

Parameters:
Name Type Attributes Description
msg string

Message to be shown

options object <optional>
Properties
Name Type Attributes Default Description
btnText string <optional>

Text on paper button, leave empty to not show

btnFunction EventListener <optional>

Function to be called when button is pressed

duration number <optional>
3000

Time in milliseconds before dialog will close, set to 0 to only allow manual close

attributes object <optional>

Attributes to be passed down to the dialog, { attr: value }

Source:
Throws:

This will throw if msg is empty