Index

Classes

Class

Methods

Class Banana.Control


Extends Class.


Defined in: Control.js.

Class Detail
Banana.Control()

Base control class for component controls in Banana. Provides needed methods to function well in the Banana Hierarchy. This control is suitable to use in your render hierarchy. Note that this control won't be rendered. Possible child controls can have visually different parent controls than the internal control collection would suggest.

Method Detail
addControl(String)

Adds a plaintext or a control to the control hierargy. Adding control after render requires call to invalidateDisplay in order to get the new control rendered visible

Parameters:
{mixed} String
or Banana.Control
applyToChildren(fn)
Parameters:
{Function} fn
function to apply to all children in control collection
{this} bind(name, func, data)

Binds an eventname to a method There are 2 types of events: Dom events: Events mostly fired from user actions like mouse click, keyup etc. Custom events: These events are manually triggered by Banana components.

Important is that dom events are available after the control is rendered. Custom events are registered instantly and available at all time.

Parameters:
{String} name
of the event
{Function} func
callback function
{mixed} data
userdata
Returns:
{this} ;
clear()

removes all child controls in this control

createComponents()

This method is called by the page during creation of the control. This is the place to define your control hierarchy. Unlike the constructor (init) you have also access to properties

  1. this.page - Reference to the page control
  2. this.parent - Reference to the parent control
  3. this.id - internal id
  4. this.clientId - client id of the dom node

Except for these properties there is no difference. It doesn't really matters if you create child controls in the init or in the createComponents methods. Only if you need access to the parent or page control. Or when you need to know what the id or client is. You will find out that in most cases createComponents is the right place to do things. Note: that createComponents is called only once. Rerendering doesn't result into a call to createComponents Another important note is that both init and createComponents methods are executed before even one thing is rendered on your screen.The clientId is already known, but you cannot access the dom node. To get access to the dom you need the updateDisplay() method.

findControl(id)

Recursively finds control

Parameters:
{String} id
of the control
Returns:
Banana.Control
generateUniqueId()

generated unique id used for dom elements

{String} getClientId()
Returns:
{String}
{Array} getControls()
Returns:
{Array} of collection of mixed types
{Array} getDomEventTypes()
Returns:
{Array} of dom event types compatible with jquery
{Banana.Control} getFirstUiControl()

fetches the first parent control which is an instance of Banana.UiControl

Returns:
{Banana.Control}
{String} getHtml(markAsRendered)

returns html string of all child controls Note that Banana.Control type classes on it self won't get rendered.

note Banana.control itself wont be rendered, but it chould contain child controls which are from Banana.UiControl type

Parameters:
{boolean} markAsRendered
Returns:
{String}
{String} getId()
Returns:
{String} id of control
{Banana.Page} getPage()
Returns:
{Banana.Page}
{Banana.Control} getParent()
Returns:
{Banana.Control} parent control
{Function} getProxy(fn)

This method is most useful for attaching event handlers to an element where the context is pointing back to a different object.

Parameters:
fn
Returns:
{Function} fn
{boolean} hasBind(name, func)

Check wether a bind to a specific function in a control exists

Parameters:
{String} name
of event
{Function} func
Returns:
{boolean}
invalidateDisplay()

invalidates display. triggers the page to re-render node tree beginning from this control.

onPreInvalidateContents()

called after invalidating control with invalidateDisplay method

onWindowResize()

called on every display size change

remove()

If control is part of a collection belonging to a page it has a page defined. we let the page handle the removement of the control. If it is a standalone control, we just unregister the events TODO: should maybe also remove dom in the situation where control is not part of a collection

render(control)

forces control to be rendered. Only this function to bypass the page logic i.e you want to render a control which is not part of a control hierarchy

Parameters:
{Banana.Control} control
setClientId(string)

sets client id used for reference to dom node

Parameters:
string
{this} setId(id)

sets internal id

Parameters:
{String} id
of control
Returns:
{this}
setPage(page)

sets reference to the page control

Parameters:
{Banana.Page} page
setParent(parent)

Sets reference to parent control. This method is automatically invoked during page construction

Parameters:
{Banana.Control} parent
triggerEvent(name, params)

Triggers an event so all listeners are getting notified.

To start listening use the bind method. example:

someControl.bind('test',function(){});

To Trigger an event. example

someControl.triggerEvent('test',{data:'foo'});

Parameters:
{String} name
of the event
params
unbind(name, func)

Unbinds an eventname If funcion is given we unbind only when the bind matches the given function. Otherwise we unbind all binds with the specified name regardless how many.

Parameters:
{String} name
of event
{Function} func
optionaly
unload()

called just before destroying object Use this method to manualy destroy other objects i.e to prevent memory leaks

updateDisplay()

The method is called by the page after the dom element is rendered. If you want to add controls to the collection don't forget to invalidate by calling invalidateDisplay()


Documentation generated by JsDoc Toolkit 2.4.0 on Wed Dec 05 2012 22:01:28 GMT+0100 (CET)