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

Creating a Message

As we just discussed, there are three different message types that we can create within a gadget, each of which has its own specific expiration criteria. Let’s go over them in more depth.

Dismissible messages

The dismissible message window is a standard alert that, if it’s not programmatically set to close, requires the user to interact with the window dismiss controls (generally an “x” in the top-right corner) to close it. These messages are generally developed to alert the user of changes within the gadget—such as new messages for her, or profile detail changes requesting an accept or cancel action from her.

We can create a dismissible mini-message simply by following the requirements described previously:

<Module title="Gadget to display a mini-message">
   <ModulePrefs>
      <Require feature="minimessage" />
   </ModulePrefs>
   <Content view="canvas">
      <![CDATA[
      <div id="msgDisplay"></div>

      <script type="text/javascript">
      //message dismissal callback
      function msgCallback(){
         document.getElementById("msgDisplay").innerHTML = "Message window closed";
      }

      //create new dismissible mini-message
      var message = new gadgets.MiniMessage(__MODULE_ID__);
      message.createDismissibleMessage("My dismissible mini-message", msgCallback);
      </script>
      ]]>
   </Content>
</Module>

We add in our Require element to enable the minimessage JavaScript ...

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