(add-initfn! f)
Executes a function once the window load event is fired.
Executes a function once the window load event is fired.
Updates and returns the document's body
element in place.
Updates and returns the document's `body` element in place.
(case-tpl expr & clauses)
Template. Accepts an expr
cell and a number of clauses
and returns a
cell with the value produced by the matching clause:
(case-tpl expr :a (span "A") :b (span "B") (span "Default"))
Template. Accepts an `expr` cell and a number of `clauses` and returns a cell with the value produced by the matching clause: (case-tpl expr :a (span "A") :b (span "B") (span "Default"))
(cond-tpl & clauses)
Template. Accepts a number of clauses
cell-template pairs and returns a
cell with the value produced by the matching clause:
(cond-tpl clause-a (span "A") clause-b (span "B") :else (span "Default"))
Template. Accepts a number of `clauses` cell-template pairs and returns a cell with the value produced by the matching clause: (cond-tpl clause-a (span "A") clause-b (span "B") :else (span "Default"))
(defattr name & forms)
Defines an attribute function.
An element attribute is a function given three arguments:
elem
- the target DOM Element containing the attributekey
- the attribute keyword or symbolvalue
- the attribute valueThe attribute function is called whenever the value argument changes.
Defines an attribute function. An element attribute is a function given three arguments: * `elem` - the target DOM Element containing the attribute * `key` - the attribute keyword or symbol * `value` - the attribute value The attribute function is called whenever the value argument changes.
(defelem name & forms)
Defines an element function.
An element function creates a DOM Element (parent) given two arguments:
attrs
- a number of key-value pairs for attributes and their valueskids
- a sequence of DOM Elements to be appended/used insideThe returned DOM Element is itself a function which can accept more attributes and child elements.
Defines an element function. An element function creates a DOM Element (parent) given two arguments: * `attrs` - a number of key-value pairs for attributes and their values * `kids` - a sequence of DOM Elements to be appended/used inside The returned DOM Element is itself a function which can accept more attributes and child elements.
(do-watch ref f)
(do-watch ref init f)
Adds f as a watcher to ref and evaluates (f init @ref) once. The watcher f is a function of two arguments: the previous and next values. If init is not provided the default (nil) will be used.
Adds f as a watcher to ref and evaluates (f init @ref) once. The watcher f is a function of two arguments: the previous and next values. If init is not provided the default (nil) will be used.
(elem bind & body)
Create an anonymous custom element.
Create an anonymous custom element.
(element? this)
Returns true if elem is a managed element. Managed elements have their children managed by Hoplon and implement the IHoplonElement protocol.
Returns true if elem is a managed element. Managed elements have their children managed by Hoplon and implement the IHoplonElement protocol.
(for-tpl [bindings items] body)
Template. Accepts a cell-binding and returns a cell containing a sequence of elements:
(for-tpl [x xs] (span x))
Template. Accepts a cell-binding and returns a cell containing a sequence of elements: (for-tpl [x xs] (span x))
Updates and returns the document's head
element in place.
Updates and returns the document's `head` element in place.
(if-tpl predicate consequent & [alternative])
Template. Accepts a predicate
cell and returns a cell containing either
the element produced by consequent
or alternative
, depending on the value
of the predicate:
(if-tpl predicate (span "True") (span "False"))
Template. Accepts a `predicate` cell and returns a cell containing either the element produced by `consequent` or `alternative`, depending on the value of the predicate: (if-tpl predicate (span "True") (span "False"))
(-append-child! this child)
Appends child
to this
for the case of this
being a managed element.
Appends `child` to `this` for the case of `this` being a managed element.
(-hoplon-kids this)
Returns the hoplon managed kids atom, or creates it if missing.
Returns the hoplon managed kids atom, or creates it if missing.
(-insert-before! this new existing)
Inserts existing
before new
in this
for the case of this
being a managed element.
Inserts `existing` before `new` in `this` for the case of `this` being a managed element.
(-remove-child! this child)
Removes child
from this
for the case of this
being a managed element.
Removes `child` from `this` for the case of `this` being a managed element.
(-replace-child! this new existing)
Replaces existing
with new
in this
for the case of this
being a managed element.
Replaces `existing` with `new` in `this` for the case of `this` being a managed element.
(-set-attributes! this kvs)
Sets attributes on a managed element using native functionality.
Sets attributes on a managed element using native functionality.
(-set-styles! this kvs)
Sets styles on a managed element using native functionality.
Sets styles on a managed element using native functionality.
(kw-dispatcher elem key value)
A multi-method dispatch function.
Will dispatch against three arguments:
elem
- the target DOM Element containing the attributekey
- the attribute keywordvalue
- the attribute valueThe kw-dispatcher will attempt to dispatch agains the key argument.
ex. when key is :namespace/key
will dispatch on :namespace/key
A multi-method dispatch function. Will dispatch against three arguments: * `elem` - the target DOM Element containing the attribute * `key` - the attribute keyword * `value` - the attribute value The kw-dispatcher will attempt to dispatch agains the key argument. ex. when key is `:namespace/key` will dispatch on `:namespace/key`
(loop-tpl & args)
Template. Works identically to for-tpl
, only expects a :bindings
attribute to accomodate the HTML HLisp representation:
(loop-tpl :bindings [x xs] ...)
Template. Works identically to `for-tpl`, only expects a `:bindings` attribute to accomodate the HTML HLisp representation: (loop-tpl :bindings [x xs] ...)
(loop-tpl* items tpl)
Given a cell items containing a seqable collection, constructs a cell that
works like a fill vector. The template tpl
is a function of one argument: the
formula cell containing the ith item in items. The tpl function is called
once (and only once) for each index in items. When the items collection
shrinks the DOM element created by the template is not destroyed--it is only
removed from the DOM and cached. When the items collection grows again those
cached elements will be reinserted into the DOM at their original index.
Given a cell items containing a seqable collection, constructs a cell that works like a fill vector. The template `tpl` is a function of one argument: the formula cell containing the ith item in items. The tpl function is called once (and only once) for each index in items. When the items collection shrinks the DOM element created by the template is not destroyed--it is only removed from the DOM and cached. When the items collection grows again those cached elements will be reinserted into the DOM at their original index.
(native? elem)
Returns true if elem is a native element. Native elements' children are not managed by Hoplon, and have not been extended with IHoplonElement.
Returns true if elem is a native element. Native elements' children are not managed by Hoplon, and have not been extended with IHoplonElement.
(normalize-class kvs)
Class normalization for attribute providers. Converts from strings and sequences to hashmaps.
Class normalization for attribute providers. Converts from strings and sequences to hashmaps.
(ns-dispatcher elem key value)
A multi-method dispatch function.
Will dispatch against three arguments:
elem
- the target DOM Element containing the attributekey
- the attribute keywordvalue
- the attribute valueThe ns-dispatcher will attempt to dispatch agains the key namespace or key.
ex. when key is :namespace/key
will dispatch on :namespace/default
otherwise :namespace/key
A multi-method dispatch function. Will dispatch against three arguments: * `elem` - the target DOM Element containing the attribute * `key` - the attribute keyword * `value` - the attribute value The ns-dispatcher will attempt to dispatch agains the key namespace or key. ex. when key is `:namespace/key` will dispatch on `:namespace/default` otherwise `:namespace/key`
(parse-args args)
Parses a sequence of element arguments into attributes and children.
Parses a sequence of element arguments into attributes and children.
Is the application running in a prerendering container (eg. PhantomJS via the prerender task)?
Is the application running in a prerendering container (eg. PhantomJS via the prerender task)?
(text form)
Creates a DOM Text node and binds its text content to a formula created via string interpolation, so the Text node updates with the formula.
Creates a DOM Text node and binds its text content to a formula created via string interpolation, so the Text node updates with the formula.
(timeout f)
(timeout f t)
Executes a fuction after a delay, if no delay is passed, 0 is used as a default.
Executes a fuction after a delay, if no delay is passed, 0 is used as a default.
(when-dom this f)
Executes a function once an element has been attached to the DOM.
Executes a function once an element has been attached to the DOM.
(when-tpl predicate & body)
Template. Accepts a predicate
cell and returns a cell containing either
the element produced by consequent
or nothing, depending on the value of
the predicate:
(when-tpl predicate (span "Value"))
Template. Accepts a `predicate` cell and returns a cell containing either the element produced by `consequent` or nothing, depending on the value of the predicate: (when-tpl predicate (span "Value"))
(with-animation-frame & body)
Evaluates the body before the next browser repaint as requestAnimationFrame.
Evaluates the body before the next browser repaint as requestAnimationFrame.
(with-dom elem & body)
Evaluates the body after elem has been inserted into the DOM.
Evaluates the body after elem has been inserted into the DOM.
(with-init! & body)
Evaluates the body after Hoplon has completed constructing the page.
Evaluates the body after Hoplon has completed constructing the page.
(with-interval msec & body)
Evaluates the body every msec milliseconds, asynchronously. Returns the interval ID which can be used to cancel the operation (see js/clearInterval).
Evaluates the body every msec milliseconds, asynchronously. Returns the interval ID which can be used to cancel the operation (see js/clearInterval).
(with-timeout msec & body)
Evaluates the body after msec milliseconds, asynchronously. Returns the timeout ID which can be used to cancel the operation (see js/clearTimeout).
Evaluates the body after msec milliseconds, asynchronously. Returns the timeout ID which can be used to cancel the operation (see js/clearTimeout).
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close