|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Defined in widgets.js
Widget is the base class that XBLinJS is built on. It is too complicated to explain here; see the documentation .
Field Summary | |
Object |
content
Contains the content of the widget. |
Constructor Summary | |
Widget
()
Widget is the base class that implements all of the features of the framework. |
Method Summary | |
void
|
appendChild(element, target)
Appends a DOM node, text fragment, or widget to the specified append target. |
void
|
appendTo(parent)
Appends this widget to some DOM node. |
void
|
checkObjectDef(def)
A function to issue various warnings with the object specs as they occur. |
Object
|
create(tagName, attDict, childText)
A convenience function for creating DOM elements, drawing on the XBLinJS flavor for the creation of the base widget. |
void
|
createObjectCustom(objDef, child)
This method should be overridden to perform any custom object creation. |
void
|
finishReplacementChildrenAdding()
This method will be called when replaceElementWithWidget has finished adding any children there are for the tag. |
Object
|
getGlobals()
Returns the relevant global storage for this widget. |
void
|
hide()
Hides the widget. |
void
|
init(atts)
|
void
|
initDOM(atts)
This initializes the data storage and DOM nodes of the widget. |
void
|
initWidget(atts)
This should do any final initialization of the widget now that we have all the DOM nodes, such as setting up the value of those nodes and such. |
void
|
prependChild(element, target)
Prepends a DOM node, text fragment, or Widget to the specified append target. |
Object
|
registerEventHandler(eventType, handleMethod, target, context)
Registers an event handler. |
void
|
show()
Shows the widget. |
Object
|
toString()
Returns a string identifying the type of the widget, and how to retrieve it: [type WidgetGlobals.Widgets[id]]. |
Field Detail |
Object content
The default is a single span tag, but you should always override this; if you don't override it, that's a sign that class probably isn't really a Widget.
Constructor Detail |
Widget()
atts
- The attribute object, if constructing a widget for actual use.
prototypeOnly
- If true, this object is only being used for its prototype, so don't initialize it as if it is going to be on the screen.
Method Detail |
void appendChild(element, target)
element
- The DOM node, text fragment (as string) or widget to be appended.
target
- The append target to add the element to. Defaults to the append target named "default".
void appendTo(parent)
parent
- The DOM node (or Widget) to append this Widget to.
void checkObjectDef(def)
For any given children specification, the output of this function will be constant, so you can leave this in while deploying.
This checks for the following common problems:
Object create(tagName, attDict, childText)
This condenses five or more frequently-recurring lines down to a small handful, often just one, with much less redundancy.
tagName
- The name of the tag to create.
attDict
- A Javascript object that will be used to initialize the tag by calling .setAttribute(key, value) on every key and value in the given object.
childText
- A convenience parameter that, if defined, will add the given childText to the node.
void createObjectCustom(objDef, child)
The default method throws an error on all input.
void finishReplacementChildrenAdding()
This is only useful in the case where you are creating a widget that will primarily be invoked by tag. By default, it does nothing.
Object getGlobals()
This should be used in preference to directly accessing WidgetGlobals, so the widget is more likely to work in cross-frame situations.
void hide()
Equivalent to this.domNode.style.display = "none".
void init(atts)
void initDOM(atts)
This is generally only overridden if you want to affect the DOM before setting values and stuff.
atts
- The atts object containing the parameters, processed to include the defaults as needed.
void initWidget(atts)
The default implementation does nothing, just a stub to prevent this.initWidget is not a function errors.
void prependChild(element, target)
element
- The DOM node, text fragment (as string), or Widget to be prepended.
target
- The append target to add the element to, defaulting to "default".
Object registerEventHandler(eventType, handleMethod, target, context)
Normally you should define the specially named methods to pick up events, but you can call this manually. This is necessary to attach to a foreign widget.
eventType
- The type of the event to catch, stripped of the "on" prefix. e.g., "blur", "focus", "keypress".
handleMethod
- The name of the method to be called as the handler. Will be passed a single parameter, the event object from Javascript. Note the word "method"; only Widgets can handle events. (This may change later if there is call for it.)
target
- The name of the DOM node or widget to recieve the event from, as seen from the widget you are calling registerEventHandler from. For example, if you are trying to pick up a click on a button, pass in the name corresponding to that button. This, if false, defaults to the domNode of the widget; this will often be the case when calling it manually unless you are tightly binding the two Widgets together (generally bad). This must be a string, not a reference, which implies events can only be registered on things with names.
void show()
Equivalent to this.domNode.style.display = "". Widgets default to displaying just like anything else, of course, unless you do something.
Object toString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |