2011-06-14 12:48:24 -04:00
|
|
|
# Keep It Simple JS Library #
|
|
|
|
|
|
|
|
A Minimal, Modular Javascript library for Modern browsers.
|
|
|
|
|
|
|
|
Aims to be fast, small, and easily split into individual modules.
|
|
|
|
|
2011-07-01 18:18:38 -04:00
|
|
|
Browser support: IE8+, Latest versions of Firefox, Chrome, Safari, Opera
|
2011-06-14 12:48:24 -04:00
|
|
|
|
|
|
|
## Basic Use: ##
|
|
|
|
|
2011-07-07 17:08:38 -04:00
|
|
|
* Function: `$_(selector).module.function(params);`
|
2011-06-14 12:48:24 -04:00
|
|
|
|
|
|
|
## Modules: ##
|
2011-07-07 17:08:38 -04:00
|
|
|
**Global**: Core functions
|
|
|
|
|
2011-07-08 13:03:38 -04:00
|
|
|
properties:
|
|
|
|
|
|
|
|
* el: The html object returned by the selector function.
|
|
|
|
|
2011-07-07 17:08:38 -04:00
|
|
|
functions:
|
|
|
|
|
|
|
|
*each: For applying changes to every item matched by a selector
|
|
|
|
Use:
|
|
|
|
$_(selector).dom.each(callback);
|
|
|
|
|
|
|
|
Example : $_(".foo").dom.each(function(e){
|
|
|
|
$_(e).dom.text(value);
|
|
|
|
}):
|
|
|
|
|
2011-06-14 12:48:24 -04:00
|
|
|
|
|
|
|
**Ajax**: simple, jQuery-like ajax functions
|
|
|
|
|
|
|
|
functions:
|
|
|
|
|
2011-06-16 12:19:47 -04:00
|
|
|
* Get:
|
|
|
|
Use:
|
|
|
|
$_.get(url, data_object, callback);
|
|
|
|
|
|
|
|
* Post:
|
|
|
|
Use:
|
|
|
|
$_.post(url, data_object, callback);
|
2011-06-14 12:48:24 -04:00
|
|
|
|
|
|
|
**QS**: querystring parsing and serialization for hashbang strings, and pushState urls
|
|
|
|
|
|
|
|
functions:
|
|
|
|
|
|
|
|
* Parse:
|
2011-06-14 12:54:47 -04:00
|
|
|
Use:
|
|
|
|
$_.qs.parse(hb);
|
2011-06-14 12:48:24 -04:00
|
|
|
|
|
|
|
* Set: This function will set the hash url if browser doesn't have history.pushState
|
2011-06-14 12:54:47 -04:00
|
|
|
Use:
|
|
|
|
$_.qs.set(key, value);
|
2011-06-14 12:48:24 -04:00
|
|
|
|
|
|
|
* Get: Retrieves the value of the key in the url string
|
2011-06-14 12:54:47 -04:00
|
|
|
Use:
|
|
|
|
$_.qs.get(key);
|
2011-06-14 12:59:38 -04:00
|
|
|
|
|
|
|
**Store**: localstorage wrapper with automatic data serialization
|
|
|
|
|
2011-06-15 08:33:16 -04:00
|
|
|
functions:
|
2011-06-14 12:59:38 -04:00
|
|
|
|
|
|
|
* Get:
|
|
|
|
Use:
|
|
|
|
$_.store.get(key);
|
|
|
|
|
|
|
|
* Set
|
|
|
|
Use:
|
|
|
|
$_.store.set(key, value);
|
|
|
|
|
|
|
|
* getALL: Retreives all localstorage data in raw form
|
|
|
|
Use:
|
|
|
|
$_.store.getAll();
|
2011-06-15 08:33:16 -04:00
|
|
|
|
|
|
|
|
|
|
|
**Event**: wrapper for applying events to DOM objects
|
|
|
|
|
2011-06-21 10:43:31 -04:00
|
|
|
functions:
|
2011-06-15 08:33:16 -04:00
|
|
|
|
|
|
|
*Add:
|
|
|
|
Use:
|
2011-07-07 17:08:38 -04:00
|
|
|
$_(selector).event.add(event, callback);
|
2011-06-15 08:33:16 -04:00
|
|
|
|
|
|
|
*Remove
|
|
|
|
Use:
|
2011-07-07 17:08:38 -04:00
|
|
|
$_(selector).event.remove(event, callback);
|
2011-06-21 10:43:31 -04:00
|
|
|
|
|
|
|
**DOM**: Dom manipulation module
|
|
|
|
|
|
|
|
function:
|
|
|
|
|
|
|
|
*addClass:
|
|
|
|
Use:
|
2011-07-07 17:08:38 -04:00
|
|
|
$_(selector).dom.addClass(className);
|
2011-06-21 10:43:31 -04:00
|
|
|
|
|
|
|
*RemoveClass:
|
|
|
|
Use:
|
2011-07-07 17:08:38 -04:00
|
|
|
$_(selector).dom.removeClass(className);
|
2011-06-29 15:52:33 -04:00
|
|
|
|
2011-06-21 13:33:03 -04:00
|
|
|
*show: For setting dom elements as visible. Type defaults as "block", can be set with optional second parameter.
|
|
|
|
Use:
|
2011-07-07 17:08:38 -04:00
|
|
|
$_(selector).dom.show([type]);
|
2011-06-21 13:33:03 -04:00
|
|
|
|
|
|
|
*hide: Hides the elements matching the selector
|
|
|
|
Use:
|
2011-07-07 17:08:38 -04:00
|
|
|
$_(selector).dom.hide();
|
2011-06-23 13:16:02 -04:00
|
|
|
|
2011-06-29 15:52:33 -04:00
|
|
|
*attr: Gets, sets, or removes an attribute from a selector.
|
2011-06-23 13:16:02 -04:00
|
|
|
Use:
|
2011-07-07 17:08:38 -04:00
|
|
|
Set: $_(selector).dom.attr(attributeName, attributeValue);
|
|
|
|
Get: $_(selector).dom.attr(attributeName);
|
|
|
|
Remove: $_(selector).dom.attr(attributeName, null);
|
2011-06-14 12:48:24 -04:00
|
|
|
|
2011-06-29 15:52:33 -04:00
|
|
|
*text: Gets or sets the text in between an element's tags
|
|
|
|
Use:
|
2011-07-07 17:08:38 -04:00
|
|
|
Set: $_(selector).dom.text(text);
|
|
|
|
Get: $_(selector).dom.text();
|
2011-07-08 13:03:38 -04:00
|
|
|
|
|
|
|
|
2011-06-29 15:52:33 -04:00
|
|
|
|
2011-06-14 12:48:24 -04:00
|
|
|
|
|
|
|
|
|
|
|
|