APIs

Show:
Module: awa.mvc The StructuredView is the overall view you see in a tab. It should contain a header, context section/menu, control bar, sidebar, and contents view. You do have the freedom to not use this view but doing so will allow easier refractoring. This also provides a structured way to handle different platforms (varying screen size, mobile, touchscreens, etc.) Provided below is some boilerplate code for creating a new StructuredView. var NewView = awa.mvc.StructuredView.extend({ constructor: function (options) { var o = { headerTpl: //header template here }; NewView.__super__.constructor.call(this, _.extend(o, options || {})); }, }); The StructuredView also supports multiple content views with section and state variables. var NewView = awa.mvc.StructuredView.extend({ initialize: function () { //return either the class or the instanced view. self.addSection({section: "section1", callback: function(sectionConfig){ return new View(); }); self.addSection({section: "section2", callback: function(sectionConfig){ return View; }); self.addSection({section: "section3", callback: function(sectionConfig){ //do not return anything if you need to build the view async. //Use sectionConfig.callback to provide the view. sectionConfig.callback(new View); }); //if the classpath is incorrect, your section will not load //This approach is no longer recommended self.addSection({section: "section2", classPath: 'viewpath/View'}); self.addSection({section: "section2", viewClass: View}); }, }); Whatever controls the StructuredView can use the updateSection method to change the section in the contents of the structured view structuredView.updateSection({ //required property section: section, //optional properties state: arg2 || arg1, id: arg1 //callback property is reserved }); structuredView.refresh();

Methods

addSection

(
  • section
)
Undefined deprecated

For multi section structured views (i.e. patients record or settings area)

Parameters:

  • section Object

    Section config

    • name Object

      Displayable name

    • group Object

      Used for grouping on sidebars

    • icon Object

      recommended icon

    • section Object

      Key/id for section

    • callback Function

      Called when view is requested

Returns:

Undefined:

addSections

(
  • sections
)
Undefined

For multi section structured views (i.e. patients record or settings area)

Parameters:

  • sections Array

    array of section args

Returns:

Undefined:

getContents

() jQuery.Element

returns the contents element

Returns:

jQuery.Element:

View Jquery selector element for contents

getContext

() jQuery.Element

overrides backbone.view's render method. Sets the rendered property to rendered and renders any provided templates. This also binds any buttons in the view to it's action IF it has an actions attribute. The actione attribute value should match the name of the function in the view class.

Returns:

jQuery.Element:

View Jquery selector element for contents

getCurrentContentsView

() awa.mvc.View

Returns:

awa.mvc.View:

returns the current active contents view

getSection

() Object

override this method to return views based on the parameters provided.

Returns:

Object:

Configuration object

getSection

(
  • sectionConfig
)
Mixed

Search for a section using a partial sectionConfig to match against.

Parameters:

  • sectionConfig Object

    sectionConfig to match against

Returns:

Mixed:

A section that matches the sectionConfig. If none are found, undefined is returned

getViewFromSection

(
  • sectionConfig
)
Mixed

override this method to return views based on the parameters provided.

Parameters:

  • sectionConfig Object

    Section config to match against

    • section Object

      key/id for section

Returns:

Mixed:

varies depending on if config provides a callback If the section has no classpath, but has a callback, the result from that callback will be returned with sectionConfig passed as the argument If the section has a classpath, but no callback, an attempt is made to require and instantiate the view at the classpath. If this succeeds, the new instance is returned. If the section has a classpath and a callback, an attempt is made to require and instantiate the view at the classpath. If this succeeds, that view is passed as the arg to the callback. Otherwise undefined is returned.

hideControls

(
  • $el
)
Undefined

Adds a child View. Added children automatically get cleaned up after (destroy is called, events are unbound). Be sure to always add child view AND large ui element (like autoselect)

Parameters:

  • $el String | jQuery.Element

    This can be either the constructor method or an already constructed view. I'd suggest you construct your view first as it's easier to track any issues.

Returns:

Undefined:

hideSidebar

() awa.mvc.StructuredView chainable

Adds a child View. Added children automatically get cleaned up after (destroy is called, events are unbound). Be sure to always add child view AND large ui element (like autoselect)

Returns:

popup

(
  • [createArgs]
)
Object

Parameters:

  • [createArgs] Object optional

    arguments used on creation of popup

    • [controlsOnTop] Boolean optional

      defaults to false

    • [x] Integer optional

      defaults to false

    • [y] Integer optional

      defaults to false

    • [onRender] Function optional

      defaults to false

Returns:

Object:

popup

render

() awa.mvc.StructuredView chainable

overrides backbone.view's render method. Sets the rendered property to rendered and renders any provided templates. This also binds any buttons in the view to it's action IF it has an actions attribute. The actione attribute value should match the name of the function in the view class.

Returns:

setContents

(
  • $el
)
Undefined

Adds a child View. Added children automatically get cleaned up after (destroy is called, events are unbound). Be sure to always add child view AND large ui element (like autoselect)

Parameters:

  • $el String | jQuery.Element

    This can be either the constructor method or an already constructed view. I'd suggest you construct your view first as it's easier to track any issues.

Returns:

Undefined:

setContextText

(
  • text
)
Undefined

Sets a subtitle for the structured view

Parameters:

  • text String

    Context text

Returns:

Undefined:

setControls

(
  • $el
)
Undefined

Adds a child View. Added children automatically get cleaned up after (destroy is called, events are unbound). Be sure to always add child view AND large ui element (like autoselect)

Parameters:

  • $el String | jQuery.Element

    This can be either the constructor method or an already constructed view. I'd suggest you construct your view first as it's easier to track any issues.

Returns:

Undefined:

setControls

(
  • $el
)
Undefined

Adds a child View. Added children automatically get cleaned up after (destroy is called, events are unbound). Be sure to always add child view AND large ui element (like autoselect)

Parameters:

  • $el String | jQuery.Element

    This can be either the constructor method or an already constructed view. I'd suggest you construct your view first as it's easier to track any issues.

Returns:

Undefined:

setCurrentControlsView

(
  • view
)
awa.mvc.StructuredView

Sets an internal pointer for the current controls view. Also replaces the existing controls view on the dom but keeps the current element alive.

Parameters:

Returns:

setHeader

(
  • $el
)
Undefined

Adds a child View. Added children automatically get cleaned up after (destroy is called, events are unbound). Be sure to always add child view AND large ui element (like autoselect)

Parameters:

  • $el String | jQuery.Element

    This can be either the constructor method or an already constructed view. I'd suggest you construct your view first as it's easier to track any issues.

Returns:

Undefined:

setHeader

(
  • $el
)
Undefined

Adds a child View. Added children automatically get cleaned up after (destroy is called, events are unbound). Be sure to always add child view AND large ui element (like autoselect)

Parameters:

  • $el String | jQuery.Element

    This can be either the constructor method or an already constructed view. I'd suggest you construct your view first as it's easier to track any issues.

Returns:

Undefined:

setHeader

(
  • $el
)
jQuery.Element

Adds a child View. Added children automatically get cleaned up after (destroy is called, events are unbound). Be sure to always add child view AND large ui element (like autoselect)

Parameters:

  • $el String | jQuery.Element

    This can be either the constructor method or an already constructed view. I'd suggest you construct your view first as it's easier to track any issues.

Returns:

jQuery.Element:

View Jquery selector element for contents

setHeaderText

(
  • text
)
Undefined

Sets a title in the very top bar of the structured view

Parameters:

  • text String

    Header text I'd suggest you construct your view first as it's easier to track any issues.

Returns:

Undefined:

setSidebar

(
  • $el
)
Undefined

Adds a child View. Added children automatically get cleaned up after (destroy is called, events are unbound). Be sure to always add child view AND large ui element (like autoselect)

Parameters:

  • $el String | jQuery.Element

    This can be either the constructor method or an already constructed view. I'd suggest you construct your view first as it's easier to track any issues.

Returns:

Undefined:

showControls

(
  • $el
)
Undefined

Adds a child View. Added children automatically get cleaned up after (destroy is called, events are unbound). Be sure to always add child view AND large ui element (like autoselect)

Parameters:

  • $el String | jQuery.Element

    This can be either the constructor method or an already constructed view. I'd suggest you construct your view first as it's easier to track any issues.

Returns:

Undefined:

showSidebar

(
  • show
)
awa.mvc.StructuredView chainable

Parameters:

  • show Boolean

    if undefined, defaults to true

Returns:

toggleSidebar

() Undefined

overrides backbone.view's render method. Sets the rendered property to rendered and renders any provided templates. This also binds any buttons in the view to it's action IF it has an actions attribute. The actione attribute value should match the name of the function in the view class.

Returns:

Undefined: