Class Simples
Defined in: core.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Simples(selector, context)
to initialize the Simples constructor
|
Field Attributes | Field Name and Description |
---|---|
<static> |
Simples.isReady
a value to indicate whether the browser has been triggered as ready
|
Method Attributes | Method Name and Description |
---|---|
<static> |
Simples.ajax(url, options)
used to send an ajax requests
|
<static> |
Simples.ajaxSettings(opts)
used to update the global default settings, see Simples.ajaxDefaults description
|
<static> |
Simples.attach(elem, type, callback)
to add the event to the provided element
|
<static> |
Simples.attr(elem, name, value)
read / write the attribute on an element
|
<static> |
Simples.bodyOffset(body)
to get the offset of the body
|
<static> |
Simples.className(elem, className, action)
to either check for a className, add or remove a className
|
<static> |
Simples.cleanData(elem, andSelf)
for the provided element you can save data to the elements dataset where a simple string or read data off of the element
|
<static> |
Simples.currentCSS(elem, name)
to read the current style attribute
|
<static> |
Simples.data(elem, key, value)
for the provided element you can save data to the elements dataset where a simple string or read data off of the element
|
<static> |
Simples.detach(elem, type, callback)
to remove the event from the provided element
|
<static> |
Simples.domManip(elem, location, html)
to write the dom new html string or dom elements
|
<static> |
Simples.domRead(elem, location)
to read the html from a elem
|
<static> |
Simples.extend(addMethods)
used to add functionality to the Simples instance object
|
<static> |
Simples.getConstructor(the)
used to test the Constructor / Class of an object
|
<static> |
Simples.getScroll(elem, name)
To retrieve the scrollTop / scrollLeft for a given element
|
<static> |
Simples.getStyle(elem, type, extra)
Used to read the current computed style of the element including width, height, innerWidth, innerHeight, offset.top, offset.left, border, etc.
|
<static> |
Simples.isConstructor(object, objectClass, doCapitalisation)
used to test the Constructor / Class of an object
|
<static> |
Simples.isEmptyObject(obj)
used to check an object to see whether it is empty
|
<static> |
Simples.makeArray(object, output)
used to coerce a NodeList, HTMLElementCollection or Object into Array
|
<static> |
Simples.merge(target, obj1,)
used to merge objects onto the first specfied object
|
<static> |
Simples.noop()
an empty function to use as noop function
|
<static> |
Simples.offset(elem)
to get the top, left offset of an element
|
<static> |
Simples.offsetParent(elem)
to get the offsetParent of an element
|
<static> |
Simples.params(name, value)
used to format data into a transmittable format takes either one argument of an object of array of objects or 2 arguments of strings
|
<static> |
Simples.position(elem)
to get the position of the element
|
<static> |
Simples.ready(callback)
used to add functions to browser ready queue and are triggered when DOMContentLoaded has been fired or latest window.onload
|
<static> |
Simples.scriptLoader(src, callback)
used to get scripts from a server
|
<static> |
Simples.Selector(selector, context, results)
used to create or select Elements selector based on .class #id and [name=name]
|
<static> |
Simples.setContext(context, func)
used to set the context on a function when the returned function is executed
|
<static> |
Simples.setOffset(elem, options)
to set the offset of the top and left of an element passed on its current offset
|
<static> |
Simples.setScroll(elem, name, value)
To set the scrollTop / scrollLeft for a given element
|
<static> |
Simples.setStyle(elem, name, value)
use to set the supplied elements style attribute
|
<static> |
Simples.trigger(elem, type, data)
to trigger an event on a supplied element
|
<static> |
Simples.trim(text)
Use native String.trim function wherever possible, Otherwise use our own trimming functionality
|
<static> |
Simples.uaMatch(ua)
takes a navigator.userAgent and returns a usable rendition of it
|
Class Detail
Simples(selector, context)
to initialize the Simples constructor
- Parameters:
- {String|Element} selector
- Query String to find in the DOM and add to Simples instance or the Element use as the selected object
- {Object} context
- The document or element used to do the query on
- Returns:
- {Simples} the simples onject with the results of the selector
Field Detail
<static>
Simples.isReady
a value to indicate whether the browser has been triggered as ready
Method Detail
<static>
Simples.ajax(url, options)
used to send an ajax requests
Defined in: ajax.js.
Defined in: ajax.js.
- Parameters:
- url
- {String}
- options
- {Object} the options to use specified for each individual request see Simples.ajaxDefaults for description of options
<static>
Simples.ajaxSettings(opts)
used to update the global default settings, see Simples.ajaxDefaults description
Defined in: ajax.js.
Defined in: ajax.js.
- Parameters:
- opts
<static>
Simples.attach(elem, type, callback)
to add the event to the provided element
Defined in: events.js.
Defined in: events.js.
- Parameters:
- {Element} elem
- the element to attach the event to
- {String} type
- the type of event to bind i.e. click, custom, etc
- {Function} callback
- the callback to bind, false can be specified to have a return false callback
<static>
Simples.attr(elem, name, value)
read / write the attribute on an element
Defined in: dom.js.
Defined in: dom.js.
- Parameters:
- {Element} elem
- the element to manipulate the attribute
- {String} name
- the name of the attribute
- {String} value
- the value to specify, if undefined will read the attribute, if null will remove the attribute, else will add the value as a string
<static>
{Object}
Simples.bodyOffset(body)
to get the offset of the body
Defined in: position.js.
Defined in: position.js.
- Parameters:
- {Body} body
- body element to measure
- Returns:
- {Object} top, left
<static>
Simples.className(elem, className, action)
to either check for a className, add or remove a className
Defined in: dom.js.
Defined in: dom.js.
- Parameters:
- {Element} elem
- the element to manipulate the className on
- {String} className
- the class to work with
- {String} action
- to perform the step [ add, remove, has/undefined ]
<static>
Simples.cleanData(elem, andSelf)
for the provided element you can save data to the elements dataset where a simple string or read data off of the element
Defined in: data.js.
Defined in: data.js.
- Parameters:
- {Element} elem
- the element to clean all data off of the children
- {Boolean} andSelf
- whether to include the provided element in with its children in the cleaning process
<static>
Simples.currentCSS(elem, name)
to read the current style attribute
Defined in: css.js.
Defined in: css.js.
- Parameters:
- {Element} elem
- the element to read the current style attributes off
- {String} name
- of the style atttribute to read
<static>
{Object|Null|All}
Simples.data(elem, key, value)
for the provided element you can save data to the elements dataset where a simple string or read data off of the element
Defined in: data.js.
Defined in: data.js.
- Parameters:
- {Element} elem
- the element to read and manipulate dataset
- {String} key
- the name of the dataset to work with
- {All} value
- the value to write to the dataset, where value is undefined will read, where value is null will remove the key and data
- Returns:
- {Object|Null|All} returns dataset object for read where no key, returns value where read and null for eveything else
<static>
Simples.detach(elem, type, callback)
to remove the event from the provided element
Defined in: events.js.
Defined in: events.js.
- Parameters:
- {Element} elem
- the element to detach the event from
- {String} type
- the type of event to unbind i.e. click, custom, etc, if no type is specifed then all events are unbound
- {Function} callback
- the callback to unbind, if not specified will unbind all the callbacks to this event
<static>
Simples.domManip(elem, location, html)
to write the dom new html string or dom elements
Defined in: dom.js.
Defined in: dom.js.
- Parameters:
- {Element} elem
- the element to read the dom html from
- {String} location
- to specify how to return the dom options are desctructive: [remove, empty, outer, text, inner/undefined ], non-destructive: [top, bottom, unwrap, before, after, wrap ]
- {String|Elements} html
- the string or Elements to put into the dom
<static>
Simples.domRead(elem, location)
to read the html from a elem
Defined in: dom.js.
Defined in: dom.js.
- Parameters:
- {Element} elem
- the element to read the dom html from
- {String} location
- to specify how to return the dom options are [ outer, text, inner/undefined ] use outer for outerHTML, text to read all the textNodes and inner or no argument for innerHTML
<static>
Simples.extend(addMethods)
used to add functionality to the Simples instance object
- Parameters:
- {Object|String} addMethods
- list of names of functions and the function in a opbject, when 2 arguments provided the first should be the name of the function and the function to be added.
<static>
Simples.getConstructor(the)
used to test the Constructor / Class of an object
- Parameters:
- {Object} the
- object to test
<static>
{Number}
Simples.getScroll(elem, name)
To retrieve the scrollTop / scrollLeft for a given element
Defined in: position.js.
Defined in: position.js.
- Parameters:
- {Element} elem
- element to get the scroll of
- {String} name
- 'top' or 'left'
- Returns:
- {Number} the value of the scrollTop / scrollLeft
<static>
Simples.getStyle(elem, type, extra)
Used to read the current computed style of the element including width, height, innerWidth, innerHeight, offset.top, offset.left, border, etc.
Defined in: css.js.
Defined in: css.js.
- Parameters:
- {Element} elem
- the element to read the somputed style off
- {String} type
- of the attribute to read
- {Boolean} extra
- used to determine on outerHeight, outerWidth whether to include the margin or just the border
<static>
Simples.isConstructor(object, objectClass, doCapitalisation)
used to test the Constructor / Class of an object
- Parameters:
- {Object} object
- the object to test
- {String} objectClass
- the class name to test
- {Boolean} doCapitalisation
- if you don't want to force the capitalisation of the className
<static>
Simples.isEmptyObject(obj)
used to check an object to see whether it is empty
- Parameters:
- {Object} obj
- object to check whether is empty
<static>
Simples.makeArray(object, output)
used to coerce a NodeList, HTMLElementCollection or Object into Array
- Parameters:
- {NodeList|HTMLElementCollection|Object} object
- to be coerced
- {Array|Object} output
- object to have coerced object added to
<static>
Simples.merge(target, obj1,)
used to merge objects onto the first specfied object
- Parameters:
- {Object} target
- native javascript object to be merged
- {Object|Array} obj1,
- obj2.... native javascript object or array to be merged onto first
<static>
Simples.noop()
an empty function to use as noop function
<static>
{Object}
Simples.offset(elem)
to get the top, left offset of an element
Defined in: position.js.
Defined in: position.js.
- Parameters:
- {Element} elem
- the element to get the offset of
- Returns:
- {Object} top, left
<static>
{Element}
Simples.offsetParent(elem)
to get the offsetParent of an element
Defined in: position.js.
Defined in: position.js.
- Parameters:
- {Element} elem
- the element to get the offsetParent of
- Returns:
- {Element}
<static>
Simples.params(name, value)
used to format data into a transmittable format takes either one argument of an object of array of objects or 2 arguments of strings
Defined in: ajax.js.
Defined in: ajax.js.
- Parameters:
- {Object|Array|String} name
- : value OR [{name:'',value:''}] OR "name"
- {String} value
<static>
{Object}
Simples.position(elem)
to get the position of the element
Defined in: position.js.
Defined in: position.js.
- Parameters:
- {Element} elem
- to get the position of
- Returns:
- {Object} top, left
<static>
Simples.ready(callback)
used to add functions to browser ready queue and are triggered when DOMContentLoaded has been fired or latest window.onload
- Parameters:
- {Function} callback
- the function to be fired when ready and or fired if already ready
<static>
Simples.scriptLoader(src, callback)
used to get scripts from a server
Defined in: ajax.js.
Defined in: ajax.js.
- Parameters:
- src
- {String} the source to point to for the request
- callback
- {Function} called when the script is finished loading
<static>
Simples.Selector(selector, context, results)
used to create or select Elements selector based on .class #id and [name=name]
Defined in: selector.js.
Defined in: selector.js.
- Parameters:
- {String|Element} selector
- element is used by object and string is used to select Element(s), based on className, id and name and where the querySelector is available using querySelectorAll
- {Element} context
- element used to provide context
- {Object|Array} results
- optional object to return selected Elements
<static>
Simples.setContext(context, func)
used to set the context on a function when the returned function is executed
- Parameters:
- {Object} context
- object to use as the execution context
- {Function} func
- the function you want to call with the given context
<static>
Simples.setOffset(elem, options)
to set the offset of the top and left of an element passed on its current offset
Defined in: position.js.
Defined in: position.js.
- Parameters:
- {Element} elem
- element to set the offset on
- {Object} options
- {Number} options.top
- the top offset desired
- {Number} options.left
- the left offset desired
<static>
Simples.setScroll(elem, name, value)
To set the scrollTop / scrollLeft for a given element
Defined in: position.js.
Defined in: position.js.
- Parameters:
- {Element} elem
- element to set the scroll on
- {String} name
- 'top' or 'left'
- {Number} value
<static>
Simples.setStyle(elem, name, value)
use to set the supplied elements style attribute
Defined in: css.js.
Defined in: css.js.
- Parameters:
- {Element} elem
- the element to set the style attribute on
- {String} name
- the name of the attribute to set
- {Number|String} value
- to be set either a pure number 12 or string with the 12px
<static>
Simples.trigger(elem, type, data)
to trigger an event on a supplied element
Defined in: events.js.
Defined in: events.js.
- Parameters:
- {Element} elem
- the element to trigger the event on
- {String} type
- the type of event to trigger i.e. click, custom, etc
- {Any} data
- the data to attach to the event
<static>
Simples.trim(text)
Use native String.trim function wherever possible, Otherwise use our own trimming functionality
- Parameters:
- {String} text
- String to trim
<static>
{Object}
Simples.uaMatch(ua)
takes a navigator.userAgent and returns a usable rendition of it
Defined in: support.js.
Defined in: support.js.
- Parameters:
- ua
- Returns:
- {Object} i.e. { browser: msie|opera|webkit|mozilla, version: 1 }