Class Index | Minimal

Classes


Class jabberwerx.ui.JWView


Extends jabberwerx.JWModel.

Abstract base class for views.

Subclasses MUST override the following:

Subclasses SHOULD override the following:

This class provides the following events:

Class Summary
Constructor Attributes Constructor Name and Description
 

Creates a new jabberwerx.ui.JWView instance.

Field Summary
Field Attributes Field Name and Description
 
jq

The jQuery-wrapped content element for this jabberwerx.ui.JWView.

<static> <constant>  
jabberwerx.ui.JWView.persist_html
Base class automatically saves and loads the innerHTML of the view's current #jq
<static> <constant>  
jabberwerx.ui.JWView.persist_none
No automatic persistence by base class
Method Summary
Method Attributes Method Name and Description
 
createDOM(doc)

Called by #render to generate the content for this View.

 

Destroys this view.

 

Called by #remove to destroy the DOM content of this view.

 

Retrieves or changes the dimensions of this view.

 
height(h, noupdate)

Retrieves or changes the height of this view.

 
hide()

Hides the view if visible in the document.

 

Retreives the parent jabberwerx.ui.JWView for this instance.

 

Set or retrieve built in persistence flags.

 

Removes this jabberwerx.ui.JWView's contents.

 
render(doc)

Renders this jabberwerx.ui.JWView.

 

Called by #restoreRender to generate the content for this View from previously persisted state data.

 

Renders this jabberwerx.ui.JWView the first time after rehydration.

 

Called by #restoreRender when the view's jq member has been assigned.

 

Determines if this view should be saved in object graphs.

 
show()

Shows the view if hidden in the document.

 

Updates this view.

 

Called when this instance has been rehydrated.

 
width(w, noupdate)

Retrieves or changes the width of this view.

 

Check #persistOptions and save the current JQ's xml as needed.

Methods borrowed from class jabberwerx.JWModel:
applyEvent, event
Methods borrowed from class jabberwerx.JWBase:
getClassName, graphUnserialized, init, invocation, shouldBeSerializedInline, toString
Class Detail
jabberwerx.ui.JWView()

Creates a new jabberwerx.ui.JWView instance.

Field Detail
{jQuery} jq

The jQuery-wrapped content element for this jabberwerx.ui.JWView.

NOTE: Do not modify this value directly; instead it is created via #render and deleted via #remove.


<static> <constant> jabberwerx.ui.JWView.persist_html
Base class automatically saves and loads the innerHTML of the view's current #jq
See:
#persistOptions

<static> <constant> jabberwerx.ui.JWView.persist_none
No automatic persistence by base class
See:
#persistOptions
Method Detail
{Element|jQuery} createDOM(doc)

Called by #render to generate the content for this View. Subclasses MUST override this method, returning the DOM element that is to be this view's content.

NOTE: This method should not be called directly; instead it is called by #render when necessary.

Parameters:
{Document} doc
The Document to use for creating content
Returns:
{Element|jQuery} The content element (either as a DOM element or the jQuery-wrapped DOM element)
See:
#render

destroy()

Destroys this view. This implementation calls #remove before calling the superclass' implementation.


destroyDOM()

Called by #remove to destroy the DOM content of this view. The current implementation does nothing.

Subclasses MAY override this method to perform any necessary cleanup. The value of #jq has not yet been deleted.

NOTE: This method should not be called directly; instead it is called by #remove when necessary.


{Object|jabberwerx.ui.JWView} dimensions(dim)

Retrieves or changes the dimensions of this view. This method is a convenience for calling #width and #height within a single method call, although #update is only called once.

If this method is called without any arguments, the current dimensions are returned. Otherwise, the dimensions are changed and this jabberwerx.ui.JWView is returned.

The return value (or value of {dim}) is an object with the following properties:

{
  width: {Number|String},    //the pixel width (if Number), or CSS
                             //value (if String)
  height: {Number|String},   //the pixel height (if Number), or CSS
                             //value (if String)
}
Parameters:
{Object} dim Optional
The new dimensions, or undefined to retrieve the current dimensions
Returns:
{Object|jabberwerx.ui.JWView} The current dimensions (if {dim} is undefined); or this jabberwerx.ui.JWView if the dimensions were changed

{Number|jabberwerx.ui.JWView} height(h, noupdate)

Retrieves or changes the height of this view.

If {h} is not defined, this method returns the current height of this view, in pixels. Otherwise the height is changed to the value of {h} in pixels (if a Number) or the CSS value (if a String), #update is called (unless {noupdate} is true), and this jabberwerx.ui.JWView is returned.

If this view is not currently rendered, this method returns 0 for retrieval, and ignores {h} for changes.

Parameters:
{Number|String} h Optional
The new height (or undefined to retrieve the current height)
{Boolean} noupdate Optional
true if the view should NOT be updated
Returns:
{Number|jabberwerx.ui.JWView} The current height (if retrieving); or this jabberwerx.ui.JWView (if changing)
See:
#dimensions

{jabberwerx.ui.JWView} hide()

Hides the view if visible in the document. View state is kept in #jq so this method does nothing if called before #render .

Returns:
{jabberwerx.ui.JWView} self refernce

{jabberwerx.ui.JWView} parent()

Retreives the parent jabberwerx.ui.JWView for this instance. This method locates the parent by recursing through the parent DOM elments until a jabberwerx.ui.JWView instance is found.

Returns:
{jabberwerx.ui.JWView} The parent view, or null if not found

{jabberwerx.ui.JWView} persistOptions(opts)

Set or retrieve built in persistence flags. The jabberwerx.ui.JWView base class can serialize its JQ reference by storing the JQ's innerHTML. The default is #persist_none. If #persist_html is set the base class will store and reload the JQ's html. /p>

Parameters:
{Integer} opts
Serialization options implemented implemented in the base class. #persist_html.
Returns:
{jabberwerx.ui.JWView} self reference

{jabberwerx.ui.JWView} remove()

Removes this jabberwerx.ui.JWView's contents. This method performs the following:

  1. Calls #destroyDOM.
  2. Removes #jq from its parent
  3. Deletes #jq.
  4. Triggers the "viewRemoved" event with the previous value of #jq as the data.

If #jq is not valid when this method is called, no actions are taken.

Returns:
{jabberwerx.ui.JWView} This jabberwerx.ui.JWView instance

{jQuery} render(doc)

Renders this jabberwerx.ui.JWView. This method performs the following:

  1. Calls #createDOM to generate the content to render
  2. Stores the content as a jQuery-wrapped object in #jq.
  3. Triggers the "viewRendered" event with the jQuery-wrapped object as data.
  4. Calls #update.
  5. Returns #jq.

If this view has already been rendered, then #update is called and #jq is returned.

Parameters:
{Document} doc Optional
The document to use for rendering; defaults to the global document object is not defined.
Throws:
{TypeError}
if {doc} is not a valid Document.
{ReferenceError}
if the generated DOM is not valid
Returns:
{jQuery} The jQuery-wrapped content to be inserted

{Element|jQuery} restoreDOM(doc)

Called by #restoreRender to generate the content for this View from previously persisted state data. Subclasses may override this method, returning the DOM element that is to be this view's content. Default behavior is to return the result of a #createDOM call if #persist_html was not in #persistOptions. If HTML was persisted this base class returns the DOM element built from it. .

NOTE: This method should not be called directly; instead it is called by #restoreRender when necessary.

Parameters:
{Document} doc
The Document to use for creating content
Returns:
{Element|jQuery} The content element (either as a DOM element or the jQuery-wrapped DOM element)
See:
#restoreRender

{jQuery} restoreRender(doc)

Renders this jabberwerx.ui.JWView the first time after rehydration.

  • Calls #restoreDOM to generate the content to render
  • Stores the content as a jQuery-wrapped object in #jq.
  • Calls #restoreUpdate to allow special handling after rehydration
  • Reassigns #render to original method so future calls invoke that method.
  • Returns #jq.
  • This method is called the first time the view is rendered after rehydration. Unlike #render this method invokes restoreDOM, restoreUpdate and does not trigger any events.

    Parameters:
    {Document} doc Optional
    The document to use for rendering; defaults to the global document object is not defined.
    Throws:
    {TypeError}
    if {doc} is not a valid Document.
    {ReferenceError}
    if the generated DOM is not valid
    Returns:
    {jQuery} The jQuery-wrapped content to be inserted

    {jabberwerx.ui.JWView} restoreUpdate()

    Called by #restoreRender when the view's jq member has been assigned. Gives subclasses a way of initializing the DOM, above and beyond #update. Update is used to refresh the view from its current state (redraw) *or* from associated models, a behavior undeeded and unwanted when rehydrating.

    NOTE: This method should not be called directly; instead it is called by #restoreRender when necessary.

    Returns:
    {jabberwerx.ui.JWView} self reference
    See:
    #restoreRender

    {Boolean} shouldBeSavedWithGraph()

    Determines if this view should be saved in object graphs. Default behavior is to include the view

    Returns:
    {Boolean} Always true

    {jabberwerx.ui.JWView} show()

    Shows the view if hidden in the document. View state is kept in #jq so this method does nothing if called before #render .

    Returns:
    {jabberwerx.ui.JWView} self refernce

    {Boolean} update()

    Updates this view. This method is called by #dimensions, #height, and #width automatically, but may also be called directly to force an update of the view.

    Subclasses SHOULD override this method to perform any necessary changes, but SHOULD call the super-classes implementation.

    Returns:
    {Boolean} true if the view is updatable (e.g. if #jq is valid).

    {Boolean} wasUnserialized()

    Called when this instance has been rehydrated. Subclass changes #render to a #restoreRender reference. This allows special handling of the first render after a rehydration.

    Returns:
    {Boolean} Always true

    {Number|jabberwerx.ui.JWView} width(w, noupdate)

    Retrieves or changes the width of this view.

    If {w} is not defined, this method returns the current width of this view, in pixels. Otherwise the width is changed to the value of {w} in pixels (if a Number) or the CSS value (if a String), #update is called (unless {noupdate} is true), and this jabberwerx.ui.JWView is returned.

    If this view is not currently rendered, this method returns 0 for retrieval, and ignores {w} for changes.

    Parameters:
    {Number|String} w Optional
    The new width (or undefined to retrieve the current width)
    {Boolean} noupdate Optional
    true if the view should NOT be updated
    Returns:
    {Number|jabberwerx.ui.JWView} The current width (if retrieving); or this jabberwerx.ui.JWView (if changing)
    See:
    #dimensions

    {Boolean} willBeSerialized()

    Check #persistOptions and save the current JQ's xml as needed. Sets JQ to null to prevent any further serialization of that object.

    Returns:
    {Boolean} Always true

    Documentation generated by JsDoc Toolkit 2.4.0 on Wed Apr 02 2014 13:23:43 GMT-0600 (MDT)