Xojo web control for simple notifications.
ToastrIJ is a Xojo Web SDK Control that wraps the most excellent toastr JavaScript library.
You can create simple notifications that fade away after an interval.
You can also create sticky notifications that need to be closed, and optionally can add a title.
Custom WebStyles can also be applied programatically.
Open the ToastrIJ project and copy the ToastrIJ
folder, or just the ToastrIJ
control from inside it into your project.
Drag the ToastrIJ
control onto your page and give it a useful name such as Toastr
. It'll sit in the page's tray as it can not be positioned on the page.
In the inspector you can change some default Notification Options, Notification Icons and the Notification Position settings. All of these options can also be set programatically.
Whether or not every notification should have a close button, regardless of whether it is a sticky notification or not. Sticky notifications always have a close button.
How long does rolling the mouse over a notification extend how long it takes before it fades away. Default is 1 second (1,000 miliseconds).
Should new notifications appear at the top of the stack (default) or bottom.
How long until a non-sticky notification fades away. Default is 5 seconds (5,000 miliseconds).
Specify a Picture
to be used in place of the default icon for the respective notification type. For best results icons should be no greater than 24x24px.
Can be Left
, Center
, Right
or Full Width
. Default is Right
.
Can be Top
or Bottom
. Default is Top
.
It's as simple as...
Toastr.Display("This is a message")
That'll get you the default Info type message.
For an Error message...
Toastr.Display("Does not compute!", ToastrIJ.Type.Error)
There are four types:
ToastrIJ.Type.Info
ToastrIJ.Type.Success
ToastrIJ.Type.Warning
ToastrIJ.Type.Error
There are three signatures for the Display
method:
Public Sub Display(Message As String, Type As ToastrIJ.Type = ToastrIJ.Type.Info, Sticky As Boolean = False)
Public Sub Display(Message As String, Type As ToastrIJ.Type = ToastrIJ.Type.Info, Icon As Picture)
Public Sub Display(Message As String, Type As ToastrIJ.Type = ToastrIJ.Type.Info, Title As String = "", Sticky As Boolean = False, Icon As Picture = Nil)
If you need to clear all notifications in one fell swoop, use:
Toastr.Clear
To turn off the fade animation:
Toastr.Clear(False)
The included demo app can be run to see some of the features.
Download, clone or fork from GitHub
git clone https://github.com/ianmjones/ToastrIJ.git
Ian M. Jones
https://www.ianmjones.com
mailto:ian@ianmjones.com
Standard MIT license (a.k.a. do what you like with it except claim it as your own)...
Copyright (c) 2017 Ian M. Jones, Byte Pixie Ltd
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.
1.1 2017-04-07
- Added
InfoIcon
,SuccessIcon
,WarningIcon
andErrorIcon
properties that can be used to set custom icons. - Added
Icon
parameter toToastr.Display
method to allow a custom icon to be set. - Added
NewestOnTop
boolean property to enable showing new notifications either at the top of the stack (default) or bottom.
1.0 2017-03-02
- Initial public release.
--- EOF ---