CrossClj

0.2.3 docs

SourceDocs



RECENT
    VARS
    add-class!
    ancestor-nodes
    ancestors
    append!
    attr
    bounding-client-rect
    children
    class
    clear!
    closest
    create-element
    create-text-node
    descendant?
    elem-and-selector
    event-listeners
    has-class?
    hidden?
    hide!
    html
    insert-after!
    insert-before!
    listen!
    listen-once!
    live-listener
    matches-pred
    parent
    prepend!
    px
    remove!
    remove-attr!
    remove-class!
    replace!
    replace-contents!
    scroll-into-view
    selector
    set-attr!
    set-class!
    set-html!
    set-px!
    set-style!
    set-text!
    set-value!
    show!
    special-listener-makers
    style
    text
    toggle!
    toggle-attr!
    toggle-class!
    unlisten!
    update-event-listeners!
    value

    « Index of all namespaces of this project

    Core DOM manipulation functions
    
    (add-class! elem classes)(add-class! elem classes & more-classes)
    Add classes to elem, trying to use Element::classList, and
    falling back to fast string parsing/manipulation
    (ancestors elem)
    Lazy seq of the ancestors of elem
    
    (append! parent child)(append! parent child & more-children)
    Append child to parent
    
    (attr elem k)
    (bounding-client-rect elem)
    Returns a map of the bounding client rect of elem
    as a map with [:top :left :right :bottom :width :height]
    (children elem)
    (class elem)
    (clear! elem)
    Clears all children from elem
    
    (closest base elem selector)(closest elem selector)
    Closest ancestor of elem (up to base, if provided)
    that matches selector
    (create-element tag)(create-element tag-ns tag)
    (create-text-node text)
    (descendant? descendant ancestor)
    Is descendant a descendant of ancestor?
    (http://goo.gl/T8pgCX)
    Private
    (elem-and-selector elem-sel)
    Private
    (event-listeners elem)
    Returns a nested map of event listeners on elem
    
    (has-class? elem c)
    Does elem contain c in its class list
    
    (hidden? elem)
    Is elem hidden (as associated with hide!/show!/toggle!, using display: none)
    
    (hide! elem)
    (html elem)
    (insert-after! elem other)
    Insert elem after other, other must have a parent
    
    (insert-before! elem other)
    Insert elem before other, other must have a parent
    
    (listen! elem-sel & type-fs)
    Adds f as a listener for events of type event-type on
    elem-sel, which must either be a DOM node, or a sequence
    whose first item is a DOM node.
    
    In other words, the call to listen! can take two forms:
    
    If elem-sel is a DOM node, i.e., you're doing something like:
    
        (listen! elem :click click-handler)
    
    then click-handler will be set as a listener for click events
    on the elem.
    
    If elem-sel is a sequence:
    
        (listen! [elem :.selector.for :.some.descendants] :click click-handler)
    
    then click-handler will be set as a listener for click events
    on descendants of elem that match the selector
    
    Also accepts any number of event-type and handler pairs for setting
    multiple listeners at once:
    
        (listen! some-elem :click click-handler :hover hover-handler)
    (listen-once! elem-sel & type-fs)
    Behaves like listen!, but removes the listener after the first event occurs.
    
    (live-listener elem selector f)
    fires f if event.target is found with selector
    
    (matches-pred base selector)(matches-pred selector)
    Returns a predicate on nodes that match selector at the
    time of this matches-pred call (may return outdated results
    if you fuck with the DOM)
    (parent elem)
    (prepend! parent child)(prepend! parent child & more-children)
    Prepend child to parent
    
    (px elem k)
    (remove! elem)(remove! p elem)
    Remove elem from parent, return parent
    
    (remove-attr! elem k)(remove-attr! elem k & ks)
    Removes dom attributes on and returns elem.
    class and classes are special cases which clear
    out the class name on removal.
    (remove-class! elem c)(remove-class! elem class & classes)
    Remove c from elem class list
    
    (replace! elem new)
    Replace elem with new, return new
    
    (replace-contents! p child)
    Replace children of elem with child
    
    (scroll-into-view elem align-with-top?)
    (selector data)
    Returns a selector in string format.
    Accepts string, keyword, or collection.
    (set-attr! elem k)(set-attr! elem k v)(set-attr! elem k v & kvs)
    Sets dom attributes on and returns elem.
    Attributes without values will be set to "true":
    
        (set-attr! elem :disabled)
    
    With values, the function takes variadic kv pairs:
    
        (set-attr! elem :id "some-id"
                        :name "some-name")
    (set-class! elem c)
    Set the css class of elem to elem
    
    (set-html! elem html)
    Set the innerHTML of elem to html
    
    (set-px! elem & kvs)
    (set-style! elem & kvs)
    Set the style of elem using key-value pairs:
    
    (set-style! elem :display "block" :color "red")
    (set-text! elem text)
    Set the textContent of elem to text, fall back to innerText
    
    (set-value! elem value)
    Set the value of elem to value
    
    (show! elem)
    (style elem)(style elem k)
    The computed style of elem, optionally specifying the key of
    a particular style to return
    (text elem)
    (toggle! elem show?)(toggle! elem)
    Display or hide the given elem (using display: none).
    Takes an optional boolean show?
    (toggle-attr! elem k)(toggle-attr! elem k add?)
    Toggles a dom attribute k on elem, optionally specifying
    the boolean value with add?
    (toggle-class! elem c)(toggle-class! elem class add?)
    (toggle-class! elem class) will add-class! if elem does not have class
    and remove-class! otherwise.
    (toggle-class! elem class add?) will add-class! if add? is truthy,
    otherwise it will remove-class!
    (unlisten! elem-sel & type-fs)
    Removes event listener for the element defined in elem-sel,
     which is the same format as listen!.
    
    The following forms are allowed, and will remove all handlers
    that match the parameters passed in:
    
        (unlisten! [elem :.selector] :click event-listener)
    
        (unlisten! [elem :.selector]
          :click event-listener
          :mouseover other-event-listener)
    Private
    (update-event-listeners! elem f & args)
    (value elem)