Class module.exports
This plugin links dom nodes to a model
Defined in: Bind.plugin.js.
Constructor Attributes | Constructor Name and Description |
---|---|
module.exports($model, $bindings)
|
Field Attributes | Field Name and Description |
---|---|
This will hold the dom nodes built from the template.
|
|
The UI's Store
It has set/get/del/has/watch/unwatch methods
|
|
The module that will manage the plugins for this UI
|
|
Describes the template, can either be like "<p></p>" or HTMLElements
|
Method Attributes | Method Name and Description |
---|---|
add(name, plugin)
Add a plugin
Note that once added, the function adds a "plugins" property to the plugin.
|
|
addAll(list)
Add multiple plugins at once
|
|
addBinding(name, binding)
Add a new way to handle a binding
|
|
addBindings(list)
Add multiple binding at once
|
|
alive(node)
Transforms dom nodes into a UI.
|
|
apply(dom)
Apply the plugins to a NodeList
|
|
bind(node, name, name)
Both ways binding between a dom node attributes and the model
|
|
count()
Count the number of elements in a stack
|
|
del(name)
Delete a plugin from the list
|
|
delegate(node, selector, name, listener, useCapture)
Delegate the event handling to a parent DOM element
|
|
down(dom)
Move an element down in the stack
|
|
foreach(node, idItemRenderer, start, nb)
Expands the inner dom nodes of a given dom node, filling it with model's values
|
|
form(DOMfrom)
Prevents the submit and set the model with all form's inputs
|
|
get(name)
Get a previously added plugin
|
|
<static> |
module.exports.getDataset(dom)
Get a domNode's dataset attribute.
|
Get the last dom element that the stack transitted to
|
|
<static> |
module.exports.getNodes(dom, query)
Returns a NodeList including the given dom node,
its childNodes and its siblingNodes
|
Get the parent object.
|
|
getPosition(dom)
Get the position of an element in the stack
|
|
has(dom)
Tells if a DOM element is in the stack
|
|
hide(dom)
Hide a dom element that was previously added to the stack
It will be taken out of the dom until displayed again
|
|
hideAll()
Helper function for hiding all the dom elements
|
|
insert(dom, position)
Insert a new element at a specific position in the stack
|
|
<static> |
module.exports.isAcceptedType(type)
Olives can manipulate HTMLElement and SVGElements
This function tells if an element is one of them
|
listen(node, name, listener, useCapture)
Listen to DOM events.
|
|
map(event's)
Get event mapping.
|
|
<static> |
module.exports.matches(the, CSS, the, true)
Determine if an element matches a certain CSS selector.
|
move(dom, position)
Move an element that is already in the stack to a new position
|
|
place(node, beforeNode)
Place the UI in a given dom node
|
|
refresh(id)
Refresh a foreach after having modified its limits
|
|
remove(dom)
Remove a DOM element from the stack.
|
|
render()
Renders the template to dom nodes and applies the plugins on it
It requires the template to be set first
|
|
<static> |
module.exports.setAttribute(node, property, value)
Assign a new value to an Element's property.
|
setMap(event's, event's)
Set event mapping.
|
|
setModel(model)
Define the model to watch for
|
|
setParent(the)
Set the parent object.
|
|
setTemplateFromDom(dom)
Set the UI's template from a DOM element
|
|
show(dom)
Show a dom element that was previously hidden
It will be added back to the dom
|
|
showAll()
Helper function for showing all the dom elements
|
|
transit(dom)
Transit between views, will show the new one and hide the previous
element that the stack transitted to, if any.
|
|
up(dom)
Move an element up in the stack
|
|
updateNb(id, nb)
Update the number of item to display in a foreach
|
|
updateStart(id, start)
Update the lower boundary of a foreach
|
Class Detail
module.exports($model, $bindings)
- Parameters:
- $model
- $bindings
- Requires:
- Store, Observable, Tools, DomUtils
Field Detail
dom
This will hold the dom nodes built from the template.
Defined in: OObject.js.
Defined in: OObject.js.
model
The UI's Store
It has set/get/del/has/watch/unwatch methods
Defined in: OObject.js.
Defined in: OObject.js.
- See:
- Emily's doc for more info on how it works.
plugins
The module that will manage the plugins for this UI
Defined in: OObject.js.
Defined in: OObject.js.
- See:
- Olives/Plugins' doc for more info on how it works.
{string or HTMLElement|SVGElement}
template
Describes the template, can either be like "<p></p>" or HTMLElements
Defined in: OObject.js.
Defined in: OObject.js.
Method Detail
add(name, plugin)
Add a plugin
Note that once added, the function adds a "plugins" property to the plugin.
It's an object that holds a name property, with the registered name of the plugin
and an apply function, to use on new nodes that the plugin would generate
Defined in: Plugins.js.
Defined in: Plugins.js.
- Parameters:
- {String} name
- the name of the data that the plugin should look for
- {Object} plugin
- the plugin that has the functions to execute
- Returns:
- true if plugin successfully added.
addAll(list)
Add multiple plugins at once
Defined in: Plugins.js.
Defined in: Plugins.js.
- Parameters:
- {Object} list
- key is the plugin name and value is the plugin
- Returns:
- true if correct param
addBinding(name, binding)
Add a new way to handle a binding
- Parameters:
- {String} name
- of the binding
- {Function} binding
- the function to handle the binding
- Returns:
addBindings(list)
Add multiple binding at once
- Parameters:
- {Object} list
- the list of bindings to add
- Returns:
alive(node)
Transforms dom nodes into a UI.
It basically does a setTemplateFromDOM, then a place
It's a helper function
Defined in: OObject.js.
Defined in: OObject.js.
- Parameters:
- {HTMLElement|SVGElement} node
- the dom to transform to a UI
- Returns:
- true if dom is an HTMLElement|SVGElement
{Boolean}
apply(dom)
Apply the plugins to a NodeList
Defined in: Plugins.js.
Defined in: Plugins.js.
- Parameters:
- {HTMLElement|SVGElement} dom
- the dom nodes on which to apply the plugins
- Returns:
- {Boolean} true if the param is a dom node
bind(node, name, name)
Both ways binding between a dom node attributes and the model
- Parameters:
- {HTMLElement|SVGElement} node
- the dom node to apply the plugin to
- {String} name
- the name of the property to look for in the model's value
- name
- Returns:
{Number}
count()
Count the number of elements in a stack
Defined in: Stack.js.
Defined in: Stack.js.
- Returns:
- {Number} the number of items
{Boolean}
del(name)
Delete a plugin from the list
Defined in: Plugins.js.
Defined in: Plugins.js.
- Parameters:
- {String} name
- the name of the plugin
- Returns:
- {Boolean} true if success
delegate(node, selector, name, listener, useCapture)
Delegate the event handling to a parent DOM element
Defined in: Event.plugin.js.
Defined in: Event.plugin.js.
- Parameters:
- {Object} node
- DOM node
- {String} selector
- CSS3 selector to the element that listens to the event
- {String} name
- event's name
- {String} listener
- callback's name
- {String} useCapture
- string
{HTMLElement}
down(dom)
Move an element down in the stack
Defined in: Stack.js.
Defined in: Stack.js.
- Parameters:
- {HTMLElement} dom
- the dom element to move down
- Returns:
- {HTMLElement} dom
foreach(node, idItemRenderer, start, nb)
Expands the inner dom nodes of a given dom node, filling it with model's values
- Parameters:
- {HTMLElement|SVGElement} node
- the dom node to apply foreach to
- idItemRenderer
- start
- nb
form(DOMfrom)
Prevents the submit and set the model with all form's inputs
- Parameters:
- {HTMLFormElement} DOMfrom
- Returns:
- true if valid form
{Object}
get(name)
Get a previously added plugin
Defined in: Plugins.js.
Defined in: Plugins.js.
- Parameters:
- {String} name
- the name of the plugin
- Returns:
- {Object} the plugin
<static>
{Object}
module.exports.getDataset(dom)
Get a domNode's dataset attribute. If dataset doesn't exist (IE)
then the domNode is looped through to collect them.
Defined in: DomUtils.js.
Defined in: DomUtils.js.
- Parameters:
- {HTMLElement|SVGElement} dom
- Returns:
- {Object} dataset
{HTMLElement}
getLastTransit()
Get the last dom element that the stack transitted to
Defined in: Stack.js.
Defined in: Stack.js.
- Returns:
- {HTMLElement} the last dom element
<static>
module.exports.getNodes(dom, query)
Returns a NodeList including the given dom node,
its childNodes and its siblingNodes
Defined in: DomUtils.js.
Defined in: DomUtils.js.
- Parameters:
- {HTMLElement|SVGElement} dom
- the dom node to start with
- {String} query
- an optional CSS selector to narrow down the query
- Returns:
- the list of nodes
{Object}
getParent()
Get the parent object.
Defined in: Event.plugin.js.
Defined in: Event.plugin.js.
- Returns:
- {Object} the parent object
{HTMLElement}
getPosition(dom)
Get the position of an element in the stack
Defined in: Stack.js.
Defined in: Stack.js.
- Parameters:
- {HTMLElement} dom
- the dom to get the position from
- Returns:
- {HTMLElement} dom
{HTMLElement}
has(dom)
Tells if a DOM element is in the stack
Defined in: Stack.js.
Defined in: Stack.js.
- Parameters:
- {HTMLElement} dom
- the dom to tell if its in the stack
- Returns:
- {HTMLElement} dom
{boolean}
hide(dom)
Hide a dom element that was previously added to the stack
It will be taken out of the dom until displayed again
Defined in: Stack.js.
Defined in: Stack.js.
- Parameters:
- {HTMLElement} dom
- the dom to hide
- Returns:
- {boolean} if dom element is in the stack
hideAll()
Helper function for hiding all the dom elements
Defined in: Stack.js.
Defined in: Stack.js.
{HTMLElement}
insert(dom, position)
Insert a new element at a specific position in the stack
Defined in: Stack.js.
Defined in: Stack.js.
- Parameters:
- {HTMLElement} dom
- the dom element to insert
- {Number} position
- the position to which to insert the DOM element
- Returns:
- {HTMLElement} dom
<static>
module.exports.isAcceptedType(type)
Olives can manipulate HTMLElement and SVGElements
This function tells if an element is one of them
Defined in: DomUtils.js.
Defined in: DomUtils.js.
- Parameters:
- {Element} type
- Returns:
- true if HTMLElement or SVGElement
listen(node, name, listener, useCapture)
Listen to DOM events.
Defined in: Event.plugin.js.
Defined in: Event.plugin.js.
- Parameters:
- {Object} node
- DOM node
- {String} name
- event's name
- {String} listener
- callback's name
- {String} useCapture
- string
map(event's)
Get event mapping.
Defined in: Event.plugin.js.
Defined in: Event.plugin.js.
- Parameters:
- {String} event's
- name
- Returns:
- the mapped event's name
<static>
module.exports.matches(the, CSS, the, true)
Determine if an element matches a certain CSS selector.
Defined in: DomUtils.js.
Defined in: DomUtils.js.
- Parameters:
- {Element} the
- parent node
- {String} CSS
- selector
- {Element} the
- node to check out
- true
- if matches
{HTMLElement}
move(dom, position)
Move an element that is already in the stack to a new position
Defined in: Stack.js.
Defined in: Stack.js.
- Parameters:
- {HTMLElement} dom
- the dom element to move
- {Number} position
- the position to which to move the DOM element
- Returns:
- {HTMLElement} dom
place(node, beforeNode)
Place the UI in a given dom node
Defined in: OObject.js.
Defined in: OObject.js.
- Parameters:
- node
- the node on which to append the UI
- beforeNode
- the dom before which to append the UI
refresh(id)
Refresh a foreach after having modified its limits
- Parameters:
- {String} id
- the id of the foreach to refresh
- Returns:
- true if the foreach exists
{HTMLElement}
remove(dom)
Remove a DOM element from the stack.
Defined in: Stack.js.
Defined in: Stack.js.
- Parameters:
- {HTMLElement} dom
- the DOM element to remove
- Returns:
- {HTMLElement} dom
render()
Renders the template to dom nodes and applies the plugins on it
It requires the template to be set first
Defined in: OObject.js.
Defined in: OObject.js.
<static>
module.exports.setAttribute(node, property, value)
Assign a new value to an Element's property. Works with HTMLElement and SVGElement.
Defined in: DomUtils.js.
Defined in: DomUtils.js.
- Parameters:
- {HTMLElement|SVGElement} node
- the node which property should be changed
- {String} property
- the name of the property
- {any} value
- the value to set
- Returns:
- true if assigned
setMap(event's, event's)
Set event mapping.
Defined in: Event.plugin.js.
Defined in: Event.plugin.js.
- Parameters:
- {String} event's
- name
- {String} event's
- value
- Returns:
- true if mapped
{Boolean}
setModel(model)
Define the model to watch for
- Parameters:
- {Store} model
- the model to watch for changes
- Returns:
- {Boolean} true if the model was set
setParent(the)
Set the parent object.
The parent object is an object which the functions are called by node listeners.
Defined in: Event.plugin.js.
Defined in: Event.plugin.js.
- Parameters:
- {Object} the
- parent object
- Returns:
- true if object has been set
setTemplateFromDom(dom)
Set the UI's template from a DOM element
Defined in: OObject.js.
Defined in: OObject.js.
- Parameters:
- {HTMLElement|SVGElement} dom
- the dom element that'll become the template of the UI
- Returns:
- true if dom is an HTMLElement|SVGElement
{boolean}
show(dom)
Show a dom element that was previously hidden
It will be added back to the dom
Defined in: Stack.js.
Defined in: Stack.js.
- Parameters:
- {HTMLElement} dom
- the dom to show
- Returns:
- {boolean} if dom element is current hidden
showAll()
Helper function for showing all the dom elements
Defined in: Stack.js.
Defined in: Stack.js.
{Boolean}
transit(dom)
Transit between views, will show the new one and hide the previous
element that the stack transitted to, if any.
Defined in: Stack.js.
Defined in: Stack.js.
- Parameters:
- {HTMLElement} dom
- the element to transit to
- Returns:
- {Boolean} false if the element can't be shown
{HTMLElement}
up(dom)
Move an element up in the stack
Defined in: Stack.js.
Defined in: Stack.js.
- Parameters:
- {HTMLElement} dom
- the dom element to move up
- Returns:
- {HTMLElement} dom
updateNb(id, nb)
Update the number of item to display in a foreach
- Parameters:
- {String} id
- the id of the foreach to update
- {Number} nb
- the number of items to display
- Returns:
- true if the foreach exists
updateStart(id, start)
Update the lower boundary of a foreach
- Parameters:
- {String} id
- the id of the foreach to update
- {Number} start
- the new value
- Returns:
- true if the foreach exists