2016-04-02 19:12:59 +02:00

5.1 KiB

Module: Alert

The alert module is one of the default modules of the MagicMirror. This module displays notifications from other modules.

Usage

To use this module, add it to the modules array in the config/config.js file:

modules: [
	{
		module: 'alert',
		config: {
			// The config property is optional.
			// See 'Configuration options' for more information. 
		}
	}
]

Configuration options

The following properties can be configured:

Option Description
style The style of the notifications.

Possible values: growl, attached & bar
Default value: growl
effect The animation effect of the notification style to use.

Possible values for growl style: scale, slide, genie & jelly
Possible values for attached style: flip & bouncyflip
Possible values for bar style: slidetop & exploader
Default value: slide
display_time Time a notification is displayed.

Possible values: any int
Default value: 3500
welcome_message Message shown at startup.

Possible values: any string & false
Default value: Welcome, start was successfull!

Developer notes

The message and the title parameters accept text as well as html.

Display notification

self.sendNotification("SHOW_NOTIFICATION", message); 

Display alert

self.sendNotification("SHOW_ALERT", {title: "Hello", message: "This is a test!", type: "success", imageUrl:"url", imageSize: "50x50", timer:1000}); 
Option Description
title The title of the alert.

Possible values: text or html as a string
message The message of the alert.

Possible values: text or html as a string
type (optional) The type of the alert.

Possible values: error, warning, info & success
Default value: none
imageUrl (optional) Image to show in the alert

Possible values: url as string
Default value: none
imageSize (optional even with imageUrl set) Size of the image

Possible values: "widthxheight" as string
Default value: none
timer (optional) How long the alert should stay visible.

Possible values: any int
Default value: none
Important: If you do not use the `timer`, it is your duty to hide the alert by using self.sendNotification("HIDE_ALERT");!

Open Source Licenses

###SweetAlert The MIT License (MIT)

Copyright (c) 2014 Tristan Edwards

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###NotificationStyles See ympanus.net for license.