O'Reilly logo

Programming Social Applications by Jonathan LeBlanc

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Displaying Messages to Your Users

The minimessage library enables the developer to display a message window to a user. This is a valuable feature when you’re trying to obtain user input or display status messages to a user that autodismiss after a short interval.

To integrate this feature, take the following steps:

  1. Within the ModulePrefs node of the gadget spec file, add a Require element to enable the minimessage JavaScript library.

    • Include: <Require feature="minimessage"/>

  2. Within the gadget JavaScript layer, insert an initialization function for the mini-message features.

    • Method call: var message = new gadgets.MiniMessage(__MODULE_ID__);

  3. When you wish to create a new message window, call one of three message window request methods.

    • Dismissible message: message.createDismissibleMessage("My Message", callback);

    • Static message: message.createStaticMessage("My Message");

    • Timer message: message.createTimerMessage("My Message", 3, callback);

As noted in step 3, there are three different message types that a gadget implementer may specify:

Dismissible message

Remains visible until the user manually closes the window.

Static message

Remains visible until the code-specified event occurs. This message may be dismissed only via the gadget code.

Timer message

Remains visible until a predefined timeout occurs. These messages will autoclose when the allotted time expires.

Moving from basic concepts into functional examples, next we’ll explore how to build and customize message windows using the available JavaScript library methods.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required