brixxbox Wiki
Ask or search…
K

showMessage

Displays a message to the user.

Parameters

  1. 1.
    messageOptions- This is a json object with the message parameters:
    • content - this is the message Text
    • title - (optional) id of the record to load in the new app
    • timeout - (optional) a timeout in milliseconds. The message will disappear after this timeout. No timeout by default.
    • "mode" - (optional) will start in a modal overlay window (default),
      • "big" - (default) a small box in the lowerright corner of the page
      • "small" - a small box in the upper right corner of the page
    • icon - (optional) a icon class string (default: "fa fa-bell swing animated")
    • sound - (optional) play a sound (true) or no (false = default)
    • type - (optional) PReset color scheme. You can use all the button types (danger, success, warning...)
    • buttons - (optional, only for mode "big") You can add buttons to the message. Just provide a list with each button in square brackets (e.g. "[Yes][No][Cancel]"). For more details please check the examples.
    • callback - (optional, only for mode "big") If u provide more than one button the callback option is needed to distinguish which action needs to be taken for a button. For more details please check the examples.

Example Usages

Most simple message
brixxApi.showMessage({content: "Message Text" });
using additional options
brixxApi.showMessage({
title: "My Title",
content: "My Text",
type: "danger",
sound: true,
timeout: 2000,
icon: "fa fa-bell swing animated"
});
message with buttons
//If u provide more then one button the callback option is needed to distinguish wich action needs to be taken for a button.
function msgCallBack (reasonForCallBack){
// possible values for reason:
// "click" : the message was closed with the X-button
// "timeout" : the timeout elapsed
// "btn1", "btn2", ... : each button gets an id number (starting from 1). e.g. if the second button was pressed -> "btn2"
console.log("reasonForCallBack:" + reasonForCallBack);
}
brixxApi.showMessage({
title: "My Title",
content: "My Text",
type: "info",
sound: true,
icon: "fa fa-bell swing animated",
buttons: "[Yes][No][Cancel]",
callback: msgCallBack,
});
message with buttons, timeout and changing the layout of the message after it was created
function msgCallBack (reasonForCallBack){
console.log("reasonForCallBack:" + reasonForCallBack);
}
let msgId = brixxApi.showMessage({
title: "My Title",
content: "My Text",
type: "info",
sound: true,
timeout: 20000,
icon: "fa fa-bell swing animated",
//when using the timeout option the running timer value can be shown on one button. This
//will visualize the default action taken after the timeout elapsed. Just add "{timer}" to a button text.
buttons: "[ <i class='fas fa-check'></i> Yes {timer}][ <i class='fas fa-do-not-enter'></i> No]",
callback: msgCallBack,
});
//each message will get an unique id number. This can be used to add/change the message layout further.
document.getElementById('bigBoxBtn1-Msg' + msgId).classList.add("btn-success");
document.getElementById('bigBoxBtn2-Msg' + msgId).classList.add("btn-danger");