Module: UWA/Element

UWA/Element

Cross-Platform API for DOM Elements manupilation.

Features
  • Element's className manipulation.
    • addClassName
    • hasClassName
    • toggleClassName
  • Element's events manipulation, including many polyfills and custom events
    • addEvent
    • triggerEvent
    • removeEvent
  • Element's selector polyfills and enhancements
    • getElements
    • getElement
    • match
  • Element's styles manipulation including CSS3 polyfills (e.g no need preffix)
    • setStyles
    • setStyle
    • getStyle
  • Element's dimensions and position caculations
    • getOffsets
    • getSize
    • getPosition
    • getScrolls
    • isInViewport
  • Easy HTML content injection using JSON object instead of string
    • addContent
    • setContent
    • inject
    • grab

Example

var myElement = UWA.createElement('ul', {
    'class': 'myElement items',
    html: [
        {
            tag: 'li',
            'class': 'item',
            text: 'My first item'
        },
        {
            tag: 'li',
            'class': 'item',
            text: 'My second item'
        }
    ],
    styles: {
        borderRadius: '5px',
        background: 'red'
    },
    events: {
        click: function (event) {

            // Handle click on li here
            var eventElement = UWA.Event.getElement(event);
        }
    }
}).inject(widget.body);

Classes

UWA.Element

Namespaces

Element.Events