Mojo.View

Namespace Detail

All User Interface (UI) layout files are located in the views folder of your application. Much of the user interface in Mojo is assembled out of text files containing fragments of HTML and special tags indicating locations to insert dynamic data.

A scene assistant has one main HTML view file, which provides the static structure and content of its presentation page. It also includes zero or more HTML template view files that may be used to display dynamic data, such as JavaScript object properties from a scene assistant.

Developers can use templates directly by calling Mojo.View.render, but more often they will pass names of templates as part of widget setup or use them implicitly in scene creation.

Method Summary


Method Detail

Mojo.View.addTemplateLocation(basePath, localizedPath, viewFolderName)

Adds a pair of locations to be used for loading localized templates. If a template is specified by full path and the base path is a prefix of the full path, the localized path for the correct locale will be searched first for the template.

Parameters


Mojo.View.addTouchFeedback(targetElement)

Adds touch feedback to a new element and always removes touch feedback from the existing highlighted element.

Parameters


Mojo.View.advanceFocus(containingElement, optionalSelection)

Advances the current text focus to the next focusable element in the containing element, or sets it to the first focusable element in the container if nothing in the container is currently focused.

Parameters


Mojo.View.clearTouchFeedback(root)

Parameters


Mojo.View.convertToNode(htmlContent, targetDocument)

Converts the given HTML content into nodes, and returns the first element node at the top level of the content.

Parameters


Mojo.View.convertToNodeList(htmlContent, targetDocument)

Returns a nodelist resulting from converting the given html content into nodes. A shared rendering div is used for this conversion, so the caller should not keep a reference to the nodelist, and needs to remove the nodes from their parent (the shared div).

Parameters


{String|Object|Array|Boolean|Number} Mojo.View.getFocusableList(containingElement)

Returns a list of DOM elements that are considered focusable.

Parameters


Mojo.View.getFocusedElement(containingElement)

Returns the currently focused element inside the passed-in container, or null if there is no such element.

Parameters


Mojo.View.getScrollerForElement(targetElement)

Searches from targetElement up the DOM looking for a Scroller widget that contains the targetElement.

Parameters


Mojo.View.makeFocusable(targetElement)

Marks an element as being one that can be focused. Currently implemented by adding a tabindex attribute of value "0".

Parameters


Mojo.View.makeNotFocusable(targetElement)

Marks an element as being one that can not be focused. Currently implemented by removing the tab index value

Parameters


Mojo.View.removeTouchFeedback(targetElement)

Removes touch feedback from an element.

Parameters


Mojo.View.render(renderParams)

Use a partial and one or more objects to create HTML markup.

The first example shows how we would bind a single object to a template:

var content = Mojo.View.render({object: contact, template: 'detail/header'});
headerElement.innerHTML = content; 

This shows how we render a list of objects with a template and a separator:

var content = Mojo.View.render({collection: songs, template: 'list/song',
  separator: 'list/separator''});
listElement.innerHTML = content; 

Parameters


Mojo.View.requiresProperties(element, target, one)

Given a DOM element and a target object, hide the element if the value of any of the named properties are undefined or have a false value in the target.

Parameters


{Boolean} Mojo.View.visible(element)

Returns true if the element and all of its ancestors are visible.

Parameters