Gadgets.MiniMessage (v0.9)

NeedsExamples

gadgets.MiniMessage

MiniMessage class, used to create messages that will appear to the user within the gadget. Typical use cases: Status messages: loading, saving, etc. Promotional messages: new features, new gadget, etc. Debug/error messages: bad input, failed connection to server, etc.

Methods

gadgets.MiniMessage.createDismissibleMessage

;HTMLElement createDismissibleMessage(message, opt_callback)

Parameters
NameTypeDescription|

string

ECMAScipt string

number

ECMAScipt number

boolean

ECMAScipt boolean

array

ECMAScipt array, e.g. 1, 1, 2, 3, 5, 8. The element type/s are not specified when the generic "array" type is used.

object *

ECMAScipt object, e.g. { foo: "bar", baz: "boo" }. The specifics of the object are not specified when the generic "object" type is used.

null *

ECMAScipt null

length *

Any CSS length value

color *

Any CSS color value

id

ID value - probably not useful for OpenSocial Gadgets, but might as well keep the two specs in sync

class *

zero of more CSS class names, separated by spaces

style *

a string that could be used as value for a 'style' attribute

url

A URL

html

A fragment of HTML markup.

countrycode *

A string that represents an A3 ISO 3166 country code.

languagecode *

A string that represents an ISO 639-2 language code.

email

A string that represents an e-mail address.

person

A string that holds a person's name.

postalcode

A string that represents a postal code.

phone

A string that represents a phone number.

date *

A string that represents a date. MUST be expressed using the "Date Time String Format" defined in the ECMAScript5 specification using one of the date-only forms. For example: "2009-12-15"

time *

A string that represents a time of day. MUST be expressed using the "Date Time String Format" defined in the ECMAScript5 specification using one of the time-only forms. For example: "18:45:00Z" or "10:26:24-05:00"

timestamp *

A string that represents a date and time of day. MUST be expressed using the "Date Time String Format" defined in the ECMAScript5 specification. For example: "2009-12-15:18:45.000Z"

duration *

A string that represents a duration. MUST have format "PYYYY-DDDThh:mm:ss.fff". For example, "P0400-152T20:45:33.123" means "400 years, 152 days, 20 hours, 45 minutes, 33.123 seconds, while "P0003-000T01:56:22.000" means "3 years, 1 hour, 56 minutes and 22.000 seconds." (Must use this one variant defined in the ISO 8601 standard).

Asterisk, or missing type attribute, means "any datatype"

...

 

 

 

message

String

Object

The message as an HTML string or DOM element

opt_callback

Function

Optional callback function to be called when the message is dismissed. The callback function will not be called until after the existing callstack has completed execution.

Returns
TypeDescription |

HTMLElement

HTML element of the created message

Description
Creates a dismissible message with an ()x icon that allows users to dismiss the message. When the message is dismissed, it is removed from the DOM and the optional callback function, if defined, is called.

gadgets.MiniMessage.createStaticMessage

;HTMLElement createStaticMessage(message)

Parameters
NameTypeDescription |

message

String

Object

The message as an HTML string or DOM element

Returns
TypeDescription |

HTMLElement

HTML element of the created message

Description
Creates a static message that can only be dismissed programmatically (by calling dismissMessage()).

gadgets.MiniMessage.createTimerMessage

;HTMLElement createTimerMessage(message, seconds, opt_callback)

Parameters
NameTypeDescription |

message

String

Object

The message as an HTML string or DOM element

seconds

number

Number of seconds to wait before dismissing the message

opt_callback

Function

Optional callback function to be called when the message is dismissed. The callback function will not be called until after the existing callstack has completed execution.

Returns
TypeDescription |

HTMLElement

HTML element of the created message

Description
Creates a message that displays for the specified number of seconds. When the timer expires, the message is dismissed and the optional callback function is executed.

gadgets.MiniMessage.dismissMessage

;dismissMessage(message)

Parameters
NameTypeDescription |

message

HTMLElement

HTML element of the message to remove

Description
Dismisses the specified message.

{{ JsApiAlphaList_(v0.9) }}