UI.Widget - common widget services

Description

This module contains the base and common widget methods.

The most used method defined here is w$(), an alias of UI.Widget.get().

Dependencies

MochiKit.

Overview

What's a Widget?

A Widget is a GUI component that interacts with users, such as a Table, a TreeView or a Form.

Widget Registration

UI.Widget class manages the widget registry. This registry is a mapping between DOM elements and the associated widget, if any. Widget registration also ensures that a DOM element wrapped by a widget has the CSS class associated with it.

Once a widget instance is registed you can use the UI.Widget.get(element) to obtain a reference to the widget associated to the specified DOM element.

Widget registration is made by the constructor of the classes that inherits UI.Widget. If you extend UI.Widget, put something like this on the constructor:

My.PrettyWidget = function(...) {
    bindMethods(this)
    //Initialization stuff
    this.element = ...
    this.cssClass = ...
    this.register()
}

API Reference

Class UI.Widget

Properties

UI.Widget.prototype.element:

The DOM element wrapped by the widget. (Read-Only).

UI.Widget.prototype.cssClass:

The CSS class that the element wrapped by the widget must have. This property should have the same value on the same class instances, but should differ between UI.Widget derived classes.

Static methods

UI.Widget.get(element):
Returns the widget wrapped by $(element). As element is passed to $(), it can be a DOM element or a string.
w$(element):
A convenience alias for UI.Widget.get(`element). Note that it is exported to the global scope, so you don't need to prefix it with UI.Widget

Methods

UI.Widget.prototype.register():

Registers the widget. This should be called only from the derived classes constructors and after the element and cssClass propeties has been set.

UI.Widget.prototype.hide():

Hides the widget.

UI.Widget.prototype.show(display="block"):

Shows the widget, using the CSS display property value specified by display.

UI.Widget.prototype.toDOM(parentElement), UI.Widget.prototype.__dom__(parentElement):

Implements the MochiKit's DOM coercion protocol <http://mochikit.com/doc/html/MochiKit/DOM.html#dom-coercion-rules>`_.

Authors

Copyright

Copyright 2005-2006 Leonardo Soto M. <leo.soto@gmail.com> and Imagemaker IT <http://www.imagemaker.cl>.

This program is licensed under the CDDL v1.0 license, see http://www.sun.com/cddl/cddl.html.