YeahToast - WinJS Toast Library

Posted by on

Javascript

Windows 8 Toast notifications with WinJS isnt the easiest thing to do. First you have to figure out what template you want, then get the XML from the template manager, then modifying the XML with the image url, title and description. Then finally creating a toast notifier to parse the XML into a toast notification.

I wanted an easier solution to add Toasts to WinJS apps, something closer to the javascript alert function: alert("Message does here!"); So we started the YeahToast library, a WinJS library for easily adding toast notifications to Windows 8 applications.

YeahToast can automatically determine the template to use if you dont specifically set one, it does this based on the other options you give it. If there is an image set it will use a template with an image. If you set both text contents it will use a template with a 2 content lines. If you just set the title it will use the template with just the title.

Basic usage:

YeahToast.show({ title: "YEAHTOAST!" });
YeahToast.show({ title: "YEAHTOAST!", textContent: "message does here" });
YeahToast.show({ title: "YEAHTOAST!", textContent: "message does here", textContent2: "message line 2" });
YeahToast.show({ imgsrc: "images/placeholder.png", title: "This one has an image!", textContent: "something something" });

Options:

{
	template: , //Windows.UI.Notifications.ToastTemplateType to define the toast template if not set YeahToast will guess based on other parameters
	imgsrc: , //Image url to appear on toast
	title: , //The toasts header text
	textContent: , //Toast description line 1
	textContent2: , //Toast description line 2
}

Where to get it

PM> Install-Package YeahToast

Or download the js file directly from Github (https://github.com/Tboda/YeahToast/blob/master/lib/YeahToast.js)

What they look like:


The source for YeahToast is available on github to add the your project. There is also an example project to show basic usage.

Fork