From 9aa6a96b8831b6324bcc698e88a0ecd0c30a6ba7 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 29 Mar 2012 12:05:11 -0400 Subject: [PATCH] Update docs --- docs/files.html | 2 +- docs/index.html | 2 +- docs/symbols/$_.dom.html | 2 +- docs/symbols/$_.event.html | 2 +- docs/symbols/$_.html | 2 +- docs/symbols/$_.indexedDB.html | 2 +- docs/symbols/$_.store.html | 2 +- docs/symbols/$_.util.html | 2 +- docs/symbols/_global_.html | 2 +- docs/symbols/src/kis-js_src_core.js.html | 114 +-- .../src/kis-js_src_modules_DOM.js.html | 103 ++- .../src/kis-js_src_modules_ajax.js.html | 27 +- .../src/kis-js_src_modules_event.js.html | 503 +++++++------ .../src/kis-js_src_modules_indexedDB.js.html | 58 +- .../src/kis-js_src_modules_store.js.html | 241 +++--- .../src/kis-js_src_modules_util.js.html | 707 +++++++++--------- kis-all.js | 617 ++++++--------- kis-lite-dom-min.js | 204 ++--- kis-lite-dom.js | 204 ++--- kis-lite-min.js | 8 +- kis-lite.js | 135 ++-- kis-min.js | 50 +- 22 files changed, 1419 insertions(+), 1570 deletions(-) mode change 100644 => 100755 docs/symbols/$_.indexedDB.html mode change 100644 => 100755 docs/symbols/src/kis-js_src_modules_indexedDB.js.html diff --git a/docs/files.html b/docs/files.html index 4c726cc..75a04fe 100755 --- a/docs/files.html +++ b/docs/files.html @@ -1 +1 @@ -JsDoc Reference - File Index
 
Project Outline
 
$_
$(string, object)
ext(string, object)
each(function)
type(mixed)
get(string, object, function)
post(string, object, function)
addClass(string)
removeClass(string)
show(string)
attr(string, string)
text(string)
css(string, string)
append(string)
prepend(string)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
connect(string, int, function)
get(string, bool)
set(string, mixed, bool)
remove(string, bool)
getAll(bool)
clear(bool)
get(string)
parse(string, object)
apply(string, string, object)
object_keys(object)
array_combine(array/object, array/object)
object_merge(object)
str_trans(string, mixed, string)
«
Kis JS Docs

File Index

core.js../kis-js/src/modules/template.js
ajax.js../kis-js/src/modules/template.js
DOM.js../kis-js/src/modules/template.js
event.js../kis-js/src/modules/template.js
indexedDB.js../kis-js/src/modules/template.js
store.js../kis-js/src/modules/template.js
template.js../kis-js/src/modules/template.js
util.js../kis-js/src/modules/template.js
\ No newline at end of file +JsDoc Reference - File Index
 
Project Outline
 
$_
$(string, object)
ext(string, object)
each(function)
type(mixed)
get(string, object, function)
post(string, object, function)
addClass(string)
removeClass(string)
show(string)
attr(string, string)
text(string)
css(string, string)
append(string)
prepend(string)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
connect(string, int, function)
create_store(string, string, bool)
delete_store(string)
get(string, bool)
set(string, mixed, bool)
remove(string, bool)
getAll(bool)
clear(bool)
object_keys(object)
array_combine(array/object, array/object)
object_merge(object)
str_trans(string, mixed, string)
«
Kis JS Docs

File Index

core.js../kis-js/src/modules/event.js
ajax.js../kis-js/src/modules/event.js
DOM.js../kis-js/src/modules/event.js
event.js../kis-js/src/modules/event.js
indexedDB.js../kis-js/src/modules/event.js
store.js../kis-js/src/modules/event.js
util.js../kis-js/src/modules/event.js
\ No newline at end of file diff --git a/docs/index.html b/docs/index.html index d189a0d..d65257f 100755 --- a/docs/index.html +++ b/docs/index.html @@ -1 +1 @@ -JsDoc Reference - Index
 
Project Outline
 
$_
$(string, object)
ext(string, object)
each(function)
type(mixed)
get(string, object, function)
post(string, object, function)
addClass(string)
removeClass(string)
show(string)
attr(string, string)
text(string)
css(string, string)
append(string)
prepend(string)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
connect(string, int, function)
get(string, bool)
set(string, mixed, bool)
remove(string, bool)
getAll(bool)
clear(bool)
get(string)
parse(string, object)
apply(string, string, object)
object_keys(object)
array_combine(array/object, array/object)
object_merge(object)
str_trans(string, mixed, string)
«
Kis JS Docs

Class Index

_global_

Global namespace.

\ No newline at end of file +JsDoc Reference - Index
 
Project Outline
 
$_
$(string, object)
ext(string, object)
each(function)
type(mixed)
get(string, object, function)
post(string, object, function)
addClass(string)
removeClass(string)
show(string)
attr(string, string)
text(string)
css(string, string)
append(string)
prepend(string)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
connect(string, int, function)
create_store(string, string, bool)
delete_store(string)
get(string, bool)
set(string, mixed, bool)
remove(string, bool)
getAll(bool)
clear(bool)
object_keys(object)
array_combine(array/object, array/object)
object_merge(object)
str_trans(string, mixed, string)
«
Kis JS Docs

Class Index

_global_

Global namespace.

\ No newline at end of file diff --git a/docs/symbols/$_.dom.html b/docs/symbols/$_.dom.html index 56ca59b..7fc77aa 100755 --- a/docs/symbols/$_.dom.html +++ b/docs/symbols/$_.dom.html @@ -1 +1 @@ -JsDoc Reference - $_.dom
 
Project Outline
 
$_
$(string, object)
ext(string, object)
each(function)
type(mixed)
get(string, object, function)
post(string, object, function)
addClass(string)
removeClass(string)
show(string)
attr(string, string)
text(string)
css(string, string)
append(string)
prepend(string)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
connect(string, int, function)
get(string, bool)
set(string, mixed, bool)
remove(string, bool)
getAll(bool)
clear(bool)
get(string)
parse(string, object)
apply(string, string, object)
object_keys(object)
array_combine(array/object, array/object)
object_merge(object)
str_trans(string, mixed, string)
«
Kis JS Docs

Module $_.dom

Defined in: DOM.js.

Method Summary
addClass(string)Adds a class to the element(s) specified by the current selector
removeClass(string)Removes a class from the element(s) specified by the current selector
hide()Hides the element(s) specified by the current selector
show(string)Shows the element(s) specified by the current selector.
attr(string, string)Sets attributes on element(s) specified by the current selector, or, if name is not specified, returns the value of the attribute of the element specified by the current selector.
text(string)Sets or retrieves the text content of the element specified by the current selector.
css(string, string)Sets or retrieves a css property of the element specified by the current selector.
append(string)Adds to the innerHTML of the current element, after the last child.
prepend(string)Adds to the innerHTML of the selected element, before the current children
html(string)Sets or gets the innerHTML propery of the element(s) passed
Method Detail
$_.dom.addClass(string)
Adds a class to the element(s) specified by the current selector
Parameters:
string class
$_.dom.removeClass(string)
Removes a class from the element(s) specified by the current selector
Parameters:
string class
$_.dom.hide()
Hides the element(s) specified by the current selector
$_.dom.show(string)
Shows the element(s) specified by the current selector. if type is specified, the element will have it's style property set to "display:[your type]". If type is not specified, the element is set to "display:block".
Parameters:
string?, Default: type
$_.dom.attr(string, string): string
Sets attributes on element(s) specified by the current selector, or, if name is not specified, returns the value of the attribute of the element specified by the current selector.
Parameters:
string name
string?, Default: value
Returns:
string
$_.dom.text(string): string
Sets or retrieves the text content of the element specified by the current selector. If a value is passed, it will set that value on the current element, otherwise it will return the value of the current element
Parameters:
string?, Default: value
Returns:
string
$_.dom.css(string, string): string
Sets or retrieves a css property of the element specified by the current selector. If a value is passed, it will set that value on the current element, otherwise it will return the value of the css property on the current element
Parameters:
string property
string?, Default: value
Returns:
string
$_.dom.append(string)
Adds to the innerHTML of the current element, after the last child.
$_("ul").dom.append("<li></li>") adds an li element to the end of the selected ul element
Parameters:
string htm
$_.dom.prepend(string)
Adds to the innerHTML of the selected element, before the current children
Parameters:
string htm
$_.dom.html(string): string
Sets or gets the innerHTML propery of the element(s) passed
Parameters:
string?, Default: htm
Returns:
string
\ No newline at end of file +JsDoc Reference - $_.dom
 
Project Outline
 
$_
$(string, object)
ext(string, object)
each(function)
type(mixed)
get(string, object, function)
post(string, object, function)
addClass(string)
removeClass(string)
show(string)
attr(string, string)
text(string)
css(string, string)
append(string)
prepend(string)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
connect(string, int, function)
create_store(string, string, bool)
delete_store(string)
get(string, bool)
set(string, mixed, bool)
remove(string, bool)
getAll(bool)
clear(bool)
object_keys(object)
array_combine(array/object, array/object)
object_merge(object)
str_trans(string, mixed, string)
«
Kis JS Docs

Module $_.dom

Defined in: DOM.js.

Method Summary
addClass(string)Adds a class to the element(s) specified by the current selector
removeClass(string)Removes a class from the element(s) specified by the current selector
hide()Hides the element(s) specified by the current selector
show(string)Shows the element(s) specified by the current selector.
attr(string, string)Sets attributes on element(s) specified by the current selector, or, if name is not specified, returns the value of the attribute of the element specified by the current selector.
text(string)Sets or retrieves the text content of the element specified by the current selector.
css(string, string)Sets or retrieves a css property of the element specified by the current selector.
append(string)Adds to the innerHTML of the current element, after the last child.
prepend(string)Adds to the innerHTML of the selected element, before the current children
html(string)Sets or gets the innerHTML propery of the element(s) passed
Method Detail
$_.dom.addClass(string)
Adds a class to the element(s) specified by the current selector
Parameters:
string class
$_.dom.removeClass(string)
Removes a class from the element(s) specified by the current selector
Parameters:
string class
$_.dom.hide()
Hides the element(s) specified by the current selector
$_.dom.show(string)
Shows the element(s) specified by the current selector. if type is specified, the element will have it's style property set to "display:[your type]". If type is not specified, the element is set to "display:block".
Parameters:
string?, Default: type
$_.dom.attr(string, string): string
Sets attributes on element(s) specified by the current selector, or, if name is not specified, returns the value of the attribute of the element specified by the current selector.
Parameters:
string name
string?, Default: value
Returns:
string
$_.dom.text(string): string
Sets or retrieves the text content of the element specified by the current selector. If a value is passed, it will set that value on the current element, otherwise it will return the value of the current element
Parameters:
string?, Default: value
Returns:
string
$_.dom.css(string, string): string
Sets or retrieves a css property of the element specified by the current selector. If a value is passed, it will set that value on the current element, otherwise it will return the value of the css property on the current element
Parameters:
string property
string?, Default: value
Returns:
string
$_.dom.append(string)
Adds to the innerHTML of the current element, after the last child.
$_("ul").dom.append("<li></li>") adds an li element to the end of the selected ul element
Parameters:
string htm
$_.dom.prepend(string)
Adds to the innerHTML of the selected element, before the current children
Parameters:
string htm
$_.dom.html(string): string
Sets or gets the innerHTML propery of the element(s) passed
Parameters:
string?, Default: htm
Returns:
string
\ No newline at end of file diff --git a/docs/symbols/$_.event.html b/docs/symbols/$_.event.html index 2ae0c56..51fe451 100755 --- a/docs/symbols/$_.event.html +++ b/docs/symbols/$_.event.html @@ -1 +1 @@ -JsDoc Reference - $_.event
 
Project Outline
 
$_
$(string, object)
ext(string, object)
each(function)
type(mixed)
get(string, object, function)
post(string, object, function)
addClass(string)
removeClass(string)
show(string)
attr(string, string)
text(string)
css(string, string)
append(string)
prepend(string)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
connect(string, int, function)
get(string, bool)
set(string, mixed, bool)
remove(string, bool)
getAll(bool)
clear(bool)
get(string)
parse(string, object)
apply(string, string, object)
object_keys(object)
array_combine(array/object, array/object)
object_merge(object)
str_trans(string, mixed, string)
«
Kis JS Docs

Module $_.event

Defined in: event.js.

Method Summary
add(string, function)Adds an event that returns a callback when triggered on the selected event and selector
remove(string, string)Removes an event bound the the specified selector, event type, and callback
live(string, string, function)Binds a persistent event to the document
delegate(string, string, function)Binds an event to a parent object
Method Detail
$_.event.add(string, function)
Adds an event that returns a callback when triggered on the selected event and selector
Eg. $_("#selector").event.add("click", do_something());
Parameters:
string event
function callback
$_.event.remove(string, string)
Removes an event bound the the specified selector, event type, and callback
Eg. $_("#selector").event.remove("click", do_something());
Parameters:
string event
string callback
$_.event.live(string, string, function)
Binds a persistent event to the document
Eg. $_.event.live(".button", "click", do_something());
Parameters:
string target
string event
function callback
$_.event.delegate(string, string, function)
Binds an event to a parent object
Eg. $_("#parent").delegate(".button", "click", do_something());
Parameters:
string target
string event_type
function callback
\ No newline at end of file +JsDoc Reference - $_.event
 
Project Outline
 
$_
$(string, object)
ext(string, object)
each(function)
type(mixed)
get(string, object, function)
post(string, object, function)
addClass(string)
removeClass(string)
show(string)
attr(string, string)
text(string)
css(string, string)
append(string)
prepend(string)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
connect(string, int, function)
create_store(string, string, bool)
delete_store(string)
get(string, bool)
set(string, mixed, bool)
remove(string, bool)
getAll(bool)
clear(bool)
object_keys(object)
array_combine(array/object, array/object)
object_merge(object)
str_trans(string, mixed, string)
«
Kis JS Docs

Module $_.event

Defined in: event.js.

Method Summary
add(string, function)Adds an event that returns a callback when triggered on the selected event and selector
remove(string, string)Removes an event bound the the specified selector, event type, and callback
live(string, string, function)Binds a persistent event to the document
delegate(string, string, function)Binds an event to a parent object
Method Detail
$_.event.add(string, function)
Adds an event that returns a callback when triggered on the selected event and selector
Eg. $_("#selector").event.add("click", do_something());
Parameters:
string event
function callback
$_.event.remove(string, string)
Removes an event bound the the specified selector, event type, and callback
Eg. $_("#selector").event.remove("click", do_something());
Parameters:
string event
string callback
$_.event.live(string, string, function)
Binds a persistent event to the document
Eg. $_.event.live(".button", "click", do_something());
Parameters:
string target
string event
function callback
$_.event.delegate(string, string, function)
Binds an event to a parent object
Eg. $_("#parent").delegate(".button", "click", do_something());
Parameters:
string target
string event_type
function callback
\ No newline at end of file diff --git a/docs/symbols/$_.html b/docs/symbols/$_.html index 034d936..b52968e 100755 --- a/docs/symbols/$_.html +++ b/docs/symbols/$_.html @@ -1 +1 @@ -JsDoc Reference - $_
 
Project Outline
 
$_
$(string, object)
ext(string, object)
each(function)
type(mixed)
get(string, object, function)
post(string, object, function)
addClass(string)
removeClass(string)
show(string)
attr(string, string)
text(string)
css(string, string)
append(string)
prepend(string)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
connect(string, int, function)
get(string, bool)
set(string, mixed, bool)
remove(string, bool)
getAll(bool)
clear(bool)
get(string)
parse(string, object)
apply(string, string, object)
object_keys(object)
array_combine(array/object, array/object)
object_merge(object)
str_trans(string, mixed, string)
«
Kis JS Docs

Module $_

Defined in: core.js.

Field Summary
domDOM Dom manipulation module
storeWrapper for localstorage / sessionstorage data serialization.
indexedDBModule for simplifying Indexed DB access
utilString and object manipulation utilities
eventEvent Listener module
templateModule for html templating.
Method Summary
$(string, object)Simple DOM selector function
ext(string, object)Adds the property `obj` to the $_ object, calling it `name`
each(function)Iterates over a $_ object, applying a callback to each item
type(mixed)Retrieves the type of the passed variable
get(string, object, function)Sends a GET type ajax request
post(string, object, function)Sends a POST type ajax request
Field Detail
$_.dom
DOM Dom manipulation module

Defined in: DOM.js.

$_.store
Wrapper for localstorage / sessionstorage data serialization. Each method has a boolean parameter, that when set as true switches the method to use sessionStorage rather than the default localStorage.

Defined in: store.js.

$_.indexedDB
Module for simplifying Indexed DB access

Defined in: indexedDB.js.

$_.util
String and object manipulation utilities

Defined in: util.js.

$_.event
Event Listener module

Defined in: event.js.

$_.template
Module for html templating. Requires ajax module.

Defined in: template.js.

Method Detail
$_.$(string, object): object
Simple DOM selector function
Parameters:
string selector
object context
Returns:
object
$_.ext(string, object)
Adds the property `obj` to the $_ object, calling it `name`
Parameters:
string name
object obj
$_.each(function)
Iterates over a $_ object, applying a callback to each item
Parameters:
function callback
$_.type(mixed): string
Retrieves the type of the passed variable
Parameters:
mixed obj
Returns:
string
$_.get(string, object, function)
Sends a GET type ajax request

Defined in: ajax.js.

Parameters:
string url
object data
function callback
$_.post(string, object, function)
Sends a POST type ajax request

Defined in: ajax.js.

Parameters:
string url
object data
function callback
\ No newline at end of file +JsDoc Reference - $_
 
Project Outline
 
$_
$(string, object)
ext(string, object)
each(function)
type(mixed)
get(string, object, function)
post(string, object, function)
addClass(string)
removeClass(string)
show(string)
attr(string, string)
text(string)
css(string, string)
append(string)
prepend(string)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
connect(string, int, function)
create_store(string, string, bool)
delete_store(string)
get(string, bool)
set(string, mixed, bool)
remove(string, bool)
getAll(bool)
clear(bool)
object_keys(object)
array_combine(array/object, array/object)
object_merge(object)
str_trans(string, mixed, string)
«
Kis JS Docs

Module $_

Defined in: core.js.

Field Summary
domDOM Dom manipulation module
storeWrapper for localstorage / sessionstorage data serialization.
indexedDBModule for simplifying Indexed DB access
utilString and object manipulation utilities
eventEvent Listener module
Method Summary
$(string, object)Simple DOM selector function
ext(string, object)Adds the property `obj` to the $_ object, calling it `name`
each(function)Iterates over a $_ object, applying a callback to each item
type(mixed)Retrieves the type of the passed variable
get(string, object, function)Sends a GET type ajax request
post(string, object, function)Sends a POST type ajax request
Field Detail
$_.dom
DOM Dom manipulation module

Defined in: DOM.js.

$_.store
Wrapper for localstorage / sessionstorage data serialization. Each method has a boolean parameter, that when set as true switches the method to use sessionStorage rather than the default localStorage.

Defined in: store.js.

$_.indexedDB
Module for simplifying Indexed DB access

Defined in: indexedDB.js.

$_.util
String and object manipulation utilities

Defined in: util.js.

$_.event
Event Listener module

Defined in: event.js.

Method Detail
$_.$(string, object): object
Simple DOM selector function
Parameters:
string selector
object context
Returns:
object
$_.ext(string, object)
Adds the property `obj` to the $_ object, calling it `name`
Parameters:
string name
object obj
$_.each(function)
Iterates over a $_ object, applying a callback to each item
Parameters:
function callback
$_.type(mixed): string
Retrieves the type of the passed variable
Parameters:
mixed obj
Returns:
string
$_.get(string, object, function)
Sends a GET type ajax request

Defined in: ajax.js.

Parameters:
string url
object data
function callback
$_.post(string, object, function)
Sends a POST type ajax request

Defined in: ajax.js.

Parameters:
string url
object data
function callback
\ No newline at end of file diff --git a/docs/symbols/$_.indexedDB.html b/docs/symbols/$_.indexedDB.html old mode 100644 new mode 100755 index 5584e75..d38f61e --- a/docs/symbols/$_.indexedDB.html +++ b/docs/symbols/$_.indexedDB.html @@ -1 +1 @@ -JsDoc Reference - $_.indexedDB
 
Project Outline
 
$_
$(string, object)
ext(string, object)
each(function)
type(mixed)
get(string, object, function)
post(string, object, function)
addClass(string)
removeClass(string)
show(string)
attr(string, string)
text(string)
css(string, string)
append(string)
prepend(string)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
connect(string, int, function)
get(string, bool)
set(string, mixed, bool)
remove(string, bool)
getAll(bool)
clear(bool)
get(string)
parse(string, object)
apply(string, string, object)
object_keys(object)
array_combine(array/object, array/object)
object_merge(object)
str_trans(string, mixed, string)
«
Kis JS Docs

Module $_.indexedDB

Defined in: indexedDB.js.

Method Summary
connect(string, int, function)Connects to an indexedDB database
Method Detail
$_.indexedDB.connect(string, int, function)
Connects to an indexedDB database
Parameters:
string dbname
int?, Default: version
function?, Default: onupgradeneeded
\ No newline at end of file +JsDoc Reference - $_.indexedDB
 
Project Outline
 
$_
$(string, object)
ext(string, object)
each(function)
type(mixed)
get(string, object, function)
post(string, object, function)
addClass(string)
removeClass(string)
show(string)
attr(string, string)
text(string)
css(string, string)
append(string)
prepend(string)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
connect(string, int, function)
create_store(string, string, bool)
delete_store(string)
get(string, bool)
set(string, mixed, bool)
remove(string, bool)
getAll(bool)
clear(bool)
object_keys(object)
array_combine(array/object, array/object)
object_merge(object)
str_trans(string, mixed, string)
«
Kis JS Docs

Module $_.indexedDB

Defined in: indexedDB.js.

Method Summary
connect(string, int, function)Connects to an indexedDB database
create_store(string, string, bool)Helper function to create a new object store
delete_store(string)Delete an object store
Method Detail
$_.indexedDB.connect(string, int, function)
Connects to an indexedDB database
Parameters:
string dbname
int?, Default: version
function?, Default: onupgradeneeded
$_.indexedDB.create_store(string, string, bool)
Helper function to create a new object store
Parameters:
string name
string?, Default: key
bool?, Default: generator
Returns:
IDBDataStore object
$_.indexedDB.delete_store(string)
Delete an object store
Parameters:
string name
\ No newline at end of file diff --git a/docs/symbols/$_.store.html b/docs/symbols/$_.store.html index 9bd85f2..d8b4b5a 100755 --- a/docs/symbols/$_.store.html +++ b/docs/symbols/$_.store.html @@ -1 +1 @@ -JsDoc Reference - $_.store
 
Project Outline
 
$_
$(string, object)
ext(string, object)
each(function)
type(mixed)
get(string, object, function)
post(string, object, function)
addClass(string)
removeClass(string)
show(string)
attr(string, string)
text(string)
css(string, string)
append(string)
prepend(string)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
connect(string, int, function)
get(string, bool)
set(string, mixed, bool)
remove(string, bool)
getAll(bool)
clear(bool)
get(string)
parse(string, object)
apply(string, string, object)
object_keys(object)
array_combine(array/object, array/object)
object_merge(object)
str_trans(string, mixed, string)
«
Kis JS Docs

Module $_.store

Defined in: store.js.

Method Summary
get(string, bool)Retrieves and deserializes a value from localstorage, based on the specified key
set(string, mixed, bool)Puts a value into localstorage at the specified key, and JSON-encodes the value if not a string
remove(string, bool)Removes the specified item from storage
getAll(bool)Returns an object of all the raw values in storage
clear(bool)Removes all values from the same domain storage
Method Detail
$_.store.get(string, bool): object
Retrieves and deserializes a value from localstorage, based on the specified key
Parameters:
string key
bool session
Returns:
object
$_.store.set(string, mixed, bool)
Puts a value into localstorage at the specified key, and JSON-encodes the value if not a string
Parameters:
string key
mixed value
bool session
$_.store.remove(string, bool)
Removes the specified item from storage
Parameters:
string key
bool session
$_.store.getAll(bool): object
Returns an object of all the raw values in storage
Parameters:
bool session
Returns:
object
$_.store.clear(bool)
Removes all values from the same domain storage
Parameters:
bool session
\ No newline at end of file +JsDoc Reference - $_.store
 
Project Outline
 
$_
$(string, object)
ext(string, object)
each(function)
type(mixed)
get(string, object, function)
post(string, object, function)
addClass(string)
removeClass(string)
show(string)
attr(string, string)
text(string)
css(string, string)
append(string)
prepend(string)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
connect(string, int, function)
create_store(string, string, bool)
delete_store(string)
get(string, bool)
set(string, mixed, bool)
remove(string, bool)
getAll(bool)
clear(bool)
object_keys(object)
array_combine(array/object, array/object)
object_merge(object)
str_trans(string, mixed, string)
«
Kis JS Docs

Module $_.store

Defined in: store.js.

Method Summary
get(string, bool)Retrieves and deserializes a value from localstorage, based on the specified key
set(string, mixed, bool)Puts a value into localstorage at the specified key, and JSON-encodes the value if not a string
remove(string, bool)Removes the specified item from storage
getAll(bool)Returns an object of all the raw values in storage
clear(bool)Removes all values from the same domain storage
Method Detail
$_.store.get(string, bool): object
Retrieves and deserializes a value from localstorage, based on the specified key
Parameters:
string key
bool session
Returns:
object
$_.store.set(string, mixed, bool)
Puts a value into localstorage at the specified key, and JSON-encodes the value if not a string
Parameters:
string key
mixed value
bool session
$_.store.remove(string, bool)
Removes the specified item from storage
Parameters:
string key
bool session
$_.store.getAll(bool): object
Returns an object of all the raw values in storage
Parameters:
bool session
Returns:
object
$_.store.clear(bool)
Removes all values from the same domain storage
Parameters:
bool session
\ No newline at end of file diff --git a/docs/symbols/$_.util.html b/docs/symbols/$_.util.html index 420f492..d75768d 100755 --- a/docs/symbols/$_.util.html +++ b/docs/symbols/$_.util.html @@ -1 +1 @@ -JsDoc Reference - $_.util
 
Project Outline
 
$_
$(string, object)
ext(string, object)
each(function)
type(mixed)
get(string, object, function)
post(string, object, function)
addClass(string)
removeClass(string)
show(string)
attr(string, string)
text(string)
css(string, string)
append(string)
prepend(string)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
connect(string, int, function)
get(string, bool)
set(string, mixed, bool)
remove(string, bool)
getAll(bool)
clear(bool)
get(string)
parse(string, object)
apply(string, string, object)
object_keys(object)
array_combine(array/object, array/object)
object_merge(object)
str_trans(string, mixed, string)
«
Kis JS Docs

Module $_.util

Defined in: util.js.

Method Summary
object_keys(object)Retrieve the keys, or member names of an object
object_values(object)Retrieves the values of an object, and returns them as an array
array_combine(array/object, array/object)Creates an object, with the property names of the first array, and the values of the second.
object_merge(object)Combines two or more objects/arrays.
str_trans(string, mixed, string)Replaces sections of strings in a greedy fashion, starting with the longest replace pairs first.
Method Detail
$_.util.object_keys(object): array
Retrieve the keys, or member names of an object
Parameters:
object
Returns:
array
$_.util.object_values(object): array
Retrieves the values of an object, and returns them as an array
Parameters:
object
Returns:
array
$_.util.array_combine(array/object, array/object): object
Creates an object, with the property names of the first array, and the values of the second. If objects are passed, the values of the object are used. If the arrays or objects passed are not the same size, the function will return false.
Parameters:
array/object keys
array/object vals
Returns:
object
$_.util.object_merge(object): object
Combines two or more objects/arrays. If the keys are numeric, the outputted object will have re-indexed keys. If a key/value pair exists in both objects, indentical values will be droped, but if a key exists with a different value, with the same key, the value in the second array will replace the value in the first
Parameters:
object [as many as you wish to combine]
Returns:
object
$_.util.str_trans(string, mixed, string): string
Replaces sections of strings in a greedy fashion, starting with the longest replace pairs first. Accepts one replace pair as two parameters, or an object, with from => to replacements as key/value pairs
Parameters:
string input_string
mixed from (string)/replace pairs (object)
string?, Default:
Returns:
string
\ No newline at end of file +JsDoc Reference - $_.util
 
Project Outline
 
$_
$(string, object)
ext(string, object)
each(function)
type(mixed)
get(string, object, function)
post(string, object, function)
addClass(string)
removeClass(string)
show(string)
attr(string, string)
text(string)
css(string, string)
append(string)
prepend(string)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
connect(string, int, function)
create_store(string, string, bool)
delete_store(string)
get(string, bool)
set(string, mixed, bool)
remove(string, bool)
getAll(bool)
clear(bool)
object_keys(object)
array_combine(array/object, array/object)
object_merge(object)
str_trans(string, mixed, string)
«
Kis JS Docs

Module $_.util

Defined in: util.js.

Method Summary
object_keys(object)Retrieve the keys, or member names of an object
object_values(object)Retrieves the values of an object, and returns them as an array
array_combine(array/object, array/object)Creates an object, with the property names of the first array, and the values of the second.
object_merge(object)Combines two or more objects/arrays.
str_trans(string, mixed, string)Replaces sections of strings in a greedy fashion, starting with the longest replace pairs first.
Method Detail
$_.util.object_keys(object): array
Retrieve the keys, or member names of an object
Parameters:
object
Returns:
array
$_.util.object_values(object): array
Retrieves the values of an object, and returns them as an array
Parameters:
object
Returns:
array
$_.util.array_combine(array/object, array/object): object
Creates an object, with the property names of the first array, and the values of the second. If objects are passed, the values of the object are used. If the arrays or objects passed are not the same size, the function will return false.
Parameters:
array/object keys
array/object vals
Returns:
object
$_.util.object_merge(object): object
Combines two or more objects/arrays. If the keys are numeric, the outputted object will have re-indexed keys. If a key/value pair exists in both objects, indentical values will be droped, but if a key exists with a different value, with the same key, the value in the second array will replace the value in the first
Parameters:
object [as many as you wish to combine]
Returns:
object
$_.util.str_trans(string, mixed, string): string
Replaces sections of strings in a greedy fashion, starting with the longest replace pairs first. Accepts one replace pair as two parameters, or an object, with from => to replacements as key/value pairs
Parameters:
string input_string
mixed from (string)/replace pairs (object)
string?, Default:
Returns:
string
\ No newline at end of file diff --git a/docs/symbols/_global_.html b/docs/symbols/_global_.html index 3b55736..4f09d9d 100755 --- a/docs/symbols/_global_.html +++ b/docs/symbols/_global_.html @@ -1 +1 @@ -JsDoc Reference - _global_
 
Project Outline
 
$_
$(string, object)
ext(string, object)
each(function)
type(mixed)
get(string, object, function)
post(string, object, function)
addClass(string)
removeClass(string)
show(string)
attr(string, string)
text(string)
css(string, string)
append(string)
prepend(string)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
connect(string, int, function)
get(string, bool)
set(string, mixed, bool)
remove(string, bool)
getAll(bool)
clear(bool)
get(string)
parse(string, object)
apply(string, string, object)
object_keys(object)
array_combine(array/object, array/object)
object_merge(object)
str_trans(string, mixed, string)
«
Kis JS Docs

Built-In Module _global_

\ No newline at end of file +JsDoc Reference - _global_
 
Project Outline
 
$_
$(string, object)
ext(string, object)
each(function)
type(mixed)
get(string, object, function)
post(string, object, function)
addClass(string)
removeClass(string)
show(string)
attr(string, string)
text(string)
css(string, string)
append(string)
prepend(string)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
connect(string, int, function)
create_store(string, string, bool)
delete_store(string)
get(string, bool)
set(string, mixed, bool)
remove(string, bool)
getAll(bool)
clear(bool)
object_keys(object)
array_combine(array/object, array/object)
object_merge(object)
str_trans(string, mixed, string)
«
Kis JS Docs

Built-In Module _global_

\ No newline at end of file diff --git a/docs/symbols/src/kis-js_src_core.js.html b/docs/symbols/src/kis-js_src_core.js.html index d09107d..350be6d 100755 --- a/docs/symbols/src/kis-js_src_core.js.html +++ b/docs/symbols/src/kis-js_src_core.js.html @@ -9,7 +9,7 @@ 2 Kis JS Keep It Simple JS Library 3 Copyright Timothy J. Warren 4 License Public Domain - 5 Version 0.5.0 + 5 Version 0.6.0 6 */ 7 (function (){ 8 @@ -27,9 +27,9 @@ 20 } 21 22 var $_, $, dcopy, sel; - 23 + 23 24 - 25 /** + 25 /** 26 * $_ 27 * 28 * Constructor function @@ -45,36 +45,36 @@ 38 if(typeof s === "undefined") 39 { 40 //Defines a "global" selector for that instance - 41 sel = (typeof $_.el !== "undefined") - 42 ? $_.el + 41 sel = (typeof $_.el !== "undefined") + 42 ? $_.el 43 : document.documentElement; 44 } 45 else 46 { 47 sel = (typeof s !== "object") ? $(s) : s; 48 } - 49 - 50 // Add the selector to the prototype + 49 + 50 // Add the selector to the prototype 51 $_.prototype.el = sel; 52 53 // Make a copy before adding properties 54 var self = dcopy($_); 55 56 // Give sel to each extension. - 57 for(var i in self) - 58 { + 57 for(var i in self) + 58 { 59 if(typeof self[i] === "object") 60 { 61 self[i].el = sel; - 62 } - 63 } + 62 } + 63 } 64 65 self.el = sel; - 66 - 67 return self; + 66 + 67 return self; 68 }; - 69 - 70 /** + 69 + 70 /** 71 * Simple DOM selector function 72 * 73 * @memberOf $_ @@ -86,15 +86,15 @@ 79 $ = function (a, context) 80 { 81 var x, c; - 82 - 83 if (typeof a != "string" || typeof a === "undefined"){ return a;} - 84 - 85 //Check for a context of a specific element, otherwise, just run on the document - 86 c = (context != null && context.nodeType === 1) - 87 ? context - 88 : document; - 89 - 90 //Pick the quickest method for each kind of selector + 82 + 83 if (typeof a != "string" || typeof a === "undefined"){ return a;} + 84 + 85 //Check for a context of a specific element, otherwise, just run on the document + 86 c = (context != null && context.nodeType === 1) + 87 ? context + 88 : document; + 89 + 90 //Pick the quickest method for each kind of selector 91 if (a.match(/^#([\w\-]+$)/)) 92 { 93 return document.getElementById(a.split('#')[1]); @@ -103,12 +103,12 @@ 96 { 97 x = c.querySelectorAll(a); 98 } - 99 -100 //Return the single object if applicable + 99 +100 //Return the single object if applicable 101 return (x.length === 1) ? x[0] : x; 102 }; -103 -104 /** +103 +104 /** 105 * Deep copy/prototypical constructor function 106 * 107 * @param object obj @@ -119,38 +119,38 @@ 112 dcopy = function(obj) 113 { 114 var type, F; -115 -116 if(typeof obj === "undefined") +115 +116 if(typeof obj === "undefined") 117 { 118 return; 119 } -120 -121 if(typeof Object.create !== "undefined") +120 +121 if(typeof Object.create !== "undefined") 122 { 123 return Object.create(obj); 124 } -125 -126 type = typeof obj; -127 -128 if(type !== "object" && type !== "function") +125 +126 type = typeof obj; +127 +128 if(type !== "object" && type !== "function") 129 { 130 return; 131 } -132 -133 /** +132 +133 /** 134 * @private 135 */ 136 F = function(){}; -137 -138 F.prototype = obj; -139 -140 return new F(); -141 -142 }; -143 -144 /** +137 +138 F.prototype = obj; +139 +140 return new F(); +141 +142 }; +143 +144 /** 145 * Adds the property `obj` to the $_ object, calling it `name` -146 * +146 * 147 * @param string name 148 * @param object obj 149 */ @@ -159,8 +159,8 @@ 152 obj.el = sel; 153 $_[name] = obj; 154 }; -155 -156 /** +155 +156 /** 157 * Iterates over a $_ object, applying a callback to each item 158 * 159 * @name $_.each @@ -190,28 +190,28 @@ 183 callback.call(sel, sel); 184 } 185 }); -186 -187 /** +186 +187 /** 188 * Retrieves the type of the passed variable 189 * 190 * @param mixed obj 191 * @return string 192 * @type string 193 */ -194 $_.type = function(obj) -195 { -196 if((function() {return obj && (obj !== this)}).call(obj)) +194 $_.type = function(obj) +195 { +196 if((function() {return obj && (obj !== this)}).call(obj)) 197 { 198 //fallback on 'typeof' for truthy primitive values 199 return (typeof obj).toLowerCase(); 200 } -201 -202 //Strip x from [object x] and return +201 +202 //Strip x from [object x] and return 203 return ({}).toString.call(obj).match(/\s([a-z|A-Z]+)/)[1].toLowerCase(); 204 }; 205 206 //Set global variables 207 $_ = window.$_ = window.$_ || $_; 208 $_.$ = $; -209 +209 210 }()); \ No newline at end of file diff --git a/docs/symbols/src/kis-js_src_modules_DOM.js.html b/docs/symbols/src/kis-js_src_modules_DOM.js.html index 746887b..4e0d4ee 100755 --- a/docs/symbols/src/kis-js_src_modules_DOM.js.html +++ b/docs/symbols/src/kis-js_src_modules_DOM.js.html @@ -18,8 +18,8 @@ 11 if (typeof document !== "undefined" && !("classList" in document.createElement("a"))) 12 { 13 (function (view){ - 14 - 15 var classListProp = "classList", + 14 + 15 var classListProp = "classList", 16 protoProp = "prototype", 17 elemCtrProto = (view.HTMLElement || view.Element)[protoProp], 18 objCtr = Object, @@ -174,7 +174,7 @@ 167 168 /** 169 * DOM -170 * +170 * 171 * Dom manipulation module 172 */ 173 (function (){ @@ -182,8 +182,8 @@ 175 "use strict"; 176 177 var d; -178 -179 //Private function for getting/setting attributes/properties +178 +179 //Private function for getting/setting attributes/properties 180 function _attr(sel, name, value) 181 { 182 var oldVal, doAttr; @@ -216,7 +216,7 @@ 209 console.log(value); 210 console.log(sel); 211 console.log("Element does not have the selected attribute"); -212 return; +212 return null; 213 } 214 215 //No value to set? Return the current value @@ -235,8 +235,8 @@ 228 else 229 { 230 sel[name] = value; -231 } -232 } +231 } +232 } 233 else if (value === null) 234 { 235 if(doAttr === true) @@ -246,13 +246,13 @@ 239 else 240 { 241 delete sel[name]; -242 } -243 } +242 } +243 } 244 245 return (typeof value !== "undefined") ? value : oldVal; 246 } -247 -248 /** +247 +248 /** 249 * Change css property name to it's 250 * javascript camel case equivalent 251 */ @@ -266,8 +266,8 @@ 259 function _css(sel, prop, val) 260 { 261 var equi; -262 -263 //Camel-case +262 +263 //Camel-case 264 prop = _toCamel(prop); 265 266 //Equivalent properties for 'special' browsers @@ -276,9 +276,9 @@ 269 outerWidth: "offsetWidth", 270 top: "posTop" 271 }; -272 -273 -274 //If you don't define a value, try returning the existing value +272 +273 +274 //If you don't define a value, try returning the existing value 275 if(typeof val === "undefined" && sel.style[prop] !== "undefined") 276 { 277 return sel.style[prop]; @@ -294,23 +294,23 @@ 287 sel.style[prop] = val; 288 289 //Short circuit -290 return; +290 return null; 291 } 292 else if(sel.style[equi[prop]]) 293 { 294 sel.style[equi[prop]] = val; -295 return; +295 return null; 296 } -297 -298 //No matches? Well, lets log it for now +297 +298 //No matches? Well, lets log it for now 299 console.log("Property " + prop + " nor an equivalent seems to exist"); 300 } -301 -302 // -------------------------------------------------------------------------- +301 +302 // -------------------------------------------------------------------------- 303 304 /** 305 * DOM -306 * +306 * 307 * Dom manipulation module 308 * @namespace 309 * @memberOf $_ @@ -320,7 +320,7 @@ 313 /** 314 * Adds a class to the element(s) specified by the current 315 * selector -316 * +316 * 317 * @name addClass 318 * @memberOf $_.dom 319 * @function @@ -335,7 +335,7 @@ 328 /** 329 * Removes a class from the element(s) specified by the current 330 * selector -331 * +331 * 332 * @name removeClass 333 * @memberOf $_.dom 334 * @function @@ -349,7 +349,7 @@ 342 }, 343 /** 344 * Hides the element(s) specified by the current selector -345 * +345 * 346 * @name hide 347 * @memberOf $_.dom 348 * @function @@ -359,11 +359,11 @@ 352 this.css('display', 'none'); 353 }, 354 /** -355 * Shows the element(s) specified by the current selector. +355 * Shows the element(s) specified by the current selector. 356 * if type is specified, the element will have it's style 357 * property set to "display:[your type]". If type is not 358 * specified, the element is set to "display:block". -359 * +359 * 360 * @name show 361 * @memberOf $_.dom 362 * @function @@ -379,8 +379,8 @@ 372 this.css("display", type); 373 }, 374 /** -375 * Sets attributes on element(s) specified by the current -376 * selector, or, if name is not specified, returns the +375 * Sets attributes on element(s) specified by the current +376 * selector, or, if name is not specified, returns the 377 * value of the attribute of the element specified by the 378 * current selector. 379 * @@ -416,7 +416,7 @@ 409 }, 410 /** 411 * Sets or retrieves the text content of the element -412 * specified by the current selector. If a value is +412 * specified by the current selector. If a value is 413 * passed, it will set that value on the current element, 414 * otherwise it will return the value of the current element 415 * @@ -430,20 +430,20 @@ 423 text: function (value) 424 { 425 var oldValue, set, type, sel; -426 -427 sel = this.el; -428 -429 set = (typeof value !== "undefined") ? true : false; -430 -431 type = (typeof sel.textContent !== "undefined") +426 +427 sel = this.el; +428 +429 set = (typeof value !== "undefined") ? true : false; +430 +431 type = (typeof sel.textContent !== "undefined") 432 ? "textContent" 433 : (typeof sel.innerText !== "undefined") 434 ? "innerText" 435 : "innerHTML"; 436 437 oldValue = sel[type]; -438 -439 if(set) +438 +439 if(set) 440 { 441 sel[type] = value; 442 return value; @@ -455,7 +455,7 @@ 448 }, 449 /** 450 * Sets or retrieves a css property of the element -451 * specified by the current selector. If a value is +451 * specified by the current selector. If a value is 452 * passed, it will set that value on the current element, 453 * otherwise it will return the value of the css property 454 * on the current element @@ -475,14 +475,14 @@ 468 { 469 return _css(this.el, prop); 470 } -471 -472 $_.each(function (e){ +471 +472 $_.each(function (e){ 473 _css(e, prop, val); 474 }); 475 }, 476 /** 477 * Adds to the innerHTML of the current element, after the last child. -478 * +478 * 479 * @example $_("ul").dom.append("<li></li>") adds an li element to the end of the selected ul element 480 * @name append 481 * @memberOf $_.dom @@ -502,7 +502,7 @@ 495 }, 496 /** 497 * Adds to the innerHTML of the selected element, before the current children -498 * +498 * 499 * @name prepend 500 * @memberOf $_.dom 501 * @function @@ -531,18 +531,17 @@ 524 */ 525 html: function(htm) 526 { -527 -528 if(typeof htm !== "undefined") +527 +528 if(typeof htm !== "undefined") 529 { 530 this.el.innerHTML = htm; 531 } -532 -533 //If the parameter is undefined, just return the current value +532 +533 //If the parameter is undefined, just return the current value 534 return this.el.innerHTML; 535 } 536 }; 537 538 $_.ext('dom', d); -539 -540 }()); -541 \ No newline at end of file +539 +540 }()); \ No newline at end of file diff --git a/docs/symbols/src/kis-js_src_modules_ajax.js.html b/docs/symbols/src/kis-js_src_modules_ajax.js.html index 19737f0..f704fda 100755 --- a/docs/symbols/src/kis-js_src_modules_ajax.js.html +++ b/docs/symbols/src/kis-js_src_modules_ajax.js.html @@ -13,8 +13,8 @@ 6 (function (){ 7 8 "use strict"; - 9 - 10 // Don't bother even defining the object if the XMLHttpRequest isn't available + 9 + 10 // Don't bother even defining the object if the XMLHttpRequest isn't available 11 if(typeof window.XMLHttpRequest === "undefined") 12 { 13 return; @@ -23,10 +23,10 @@ 16 var ajax = { 17 _do: function (url, data, callback, isPost) 18 { - 19 var type, - 20 request = new XMLHttpRequest(); - 21 - 22 if (typeof callback === "undefined") + 19 var type, + 20 request = new XMLHttpRequest(); + 21 + 22 if (typeof callback === "undefined") 23 { 24 /** 25 * @private @@ -37,8 +37,8 @@ 30 type = (isPost) ? "POST" : "GET"; 31 32 url += (type === "GET") ? "?"+this._serialize(data) : ''; - 33 - 34 request.open(type, url); + 33 + 34 request.open(type, url); 35 36 request.onreadystatechange = function () 37 { @@ -89,7 +89,7 @@ 82 83 /** 84 * Sends a GET type ajax request - 85 * + 85 * 86 * @name get 87 * @function 88 * @memberOf $_ @@ -100,10 +100,10 @@ 93 $_.ext('get', function (url, data, callback){ 94 ajax._do(url, data, callback, false); 95 }); - 96 - 97 /** + 96 + 97 /** 98 * Sends a POST type ajax request - 99 * + 99 * 100 * @name post 101 * @function 102 * @memberOf $_ @@ -114,4 +114,5 @@ 107 $_.ext('post', function (url, data, callback){ 108 ajax._do(url, data, callback, true); 109 }); -110 }()); \ No newline at end of file +110 +111 }()); \ No newline at end of file diff --git a/docs/symbols/src/kis-js_src_modules_event.js.html b/docs/symbols/src/kis-js_src_modules_event.js.html index 8b7dc90..ebc7751 100755 --- a/docs/symbols/src/kis-js_src_modules_event.js.html +++ b/docs/symbols/src/kis-js_src_modules_event.js.html @@ -9,255 +9,254 @@ 2 * Event 3 * 4 * Event api wrapper - 5 */ - 6 (function (){ - 7 - 8 "use strict"; - 9 - 10 // Property name for expandos on DOM objects - 11 var kis_expando = "KIS_0_5_0"; - 12 - 13 var _attach, _remove, _add_remove, e, _attach_delegate; - 14 - 15 // Define the proper _attach and _remove functions - 16 // based on browser support - 17 if(typeof document.addEventListener !== "undefined") - 18 { - 19 /** - 20 * @private - 21 */ - 22 _attach = function (sel, event, callback) - 23 { - 24 if(typeof sel.addEventListener !== "undefined") - 25 { - 26 // Duplicated events are dropped, per the specification - 27 sel.addEventListener(event, callback, false); - 28 } - 29 }; - 30 /** - 31 * @private - 32 */ - 33 _remove = function (sel, event, callback) - 34 { - 35 if(typeof sel.removeEventListener !== "undefined") - 36 { - 37 sel.removeEventListener(event, callback, false); - 38 } - 39 }; - 40 } - 41 // typeof function doesn't work in IE where attachEvent is available: brute force it - 42 else if(typeof document.attachEvent !== "undefined") - 43 { - 44 /** - 45 * @private - 46 */ - 47 _attach = function (sel, event, callback) - 48 { - 49 function _listener () { - 50 // Internet Explorer fails to correctly set the 'this' object - 51 // for event listeners, so we need to set it ourselves. - 52 callback.apply(arguments[0]); - 53 } - 54 - 55 if (typeof sel.attachEvent !== "undefined") - 56 { - 57 _remove(event, callback); // Make sure we don't have duplicate listeners - 58 - 59 sel.attachEvent("on" + event, _listener); - 60 // Store our listener so we can remove it later - 61 var expando = sel[kis_expando] = sel[kis_expando] || {}; - 62 expando.listeners = expando.listeners || {}; - 63 expando.listeners[event] = expando.listeners[event] || []; - 64 expando.listeners[event].push({ - 65 callback: callback, - 66 _listener: _listener - 67 }); - 68 } - 69 else - 70 { - 71 console.log("Failed to _attach event:"+event+" on "+sel); - 72 } - 73 }; - 74 /** - 75 * @private - 76 */ - 77 _remove = function (sel, event, callback) - 78 { - 79 if(typeof sel.detachEvent !== "undefined") - 80 { - 81 var expando = sel[kis_expando]; - 82 if (expando && expando.listeners - 83 && expando.listeners[event]) - 84 { - 85 var listeners = expando.listeners[event]; - 86 var len = listeners.length; - 87 for (var i=0; i<len; i++) - 88 { - 89 if (listeners[i].callback === callback) - 90 { - 91 sel.detachEvent("on" + event, listeners[i]._listener); - 92 listeners.splice(i, 1); - 93 if(listeners.length === 0) - 94 { - 95 delete expando.listeners[event]; - 96 } - 97 return; - 98 } - 99 } -100 } -101 } -102 }; -103 } -104 -105 _add_remove = function (sel, event, callback, add) -106 { -107 var i, len; -108 -109 if(typeof sel === "undefined") -110 { -111 console.log(arguments); -112 console.log(event); -113 return false; -114 } -115 -116 // Multiple events? Run recursively! -117 if ( ! event.match(/^([\w\-]+)$/)) -118 { -119 event = event.split(" "); -120 -121 len = event.length; -122 -123 for (i = 0; i < len; i++) -124 { -125 _add_remove(sel, event[i], callback, add); -126 } -127 -128 return; -129 } -130 -131 -132 if(add === true) -133 { -134 _attach(sel, event, callback); -135 } -136 else -137 { -138 _remove(sel, event, callback); -139 } -140 }; -141 -142 _attach_delegate = function(sel, target, event, callback) -143 { -144 // attach the listener to the parent object -145 _add_remove(sel, event, function(e){ -146 -147 var elem, t, tar; -148 -149 // IE 8 doesn't have event bound to element -150 e = e || window.event; -151 -152 // Get the live version of the target selector -153 t = $_.$(target, sel); -154 -155 // Check each element to see if it matches the target -156 for(elem in t) -157 { -158 // IE 8 doesn't have target in the event object -159 tar = e.target || e.srcElement; -160 -161 // Fire target callback when event bubbles from target -162 if(tar == t[elem]) -163 { -164 // Trigger the event callback -165 callback.call(t[elem], e); -166 -167 // Stop event propegation -168 e.stopPropagation(); -169 } -170 } -171 -172 }, true); -173 }; -174 -175 -176 -177 // -------------------------------------------------------------------------- -178 -179 /** -180 * Event Listener module -181 * -182 * @namespace -183 * @name event -184 * @memberOf $_ -185 */ -186 e = { -187 /** -188 * Adds an event that returns a callback when triggered on the selected -189 * event and selector -190 * -191 * @memberOf $_.event -192 * @name add -193 * @function -194 * @example Eg. $_("#selector").event.add("click", do_something()); -195 * @param string event -196 * @param function callback -197 */ -198 add: function (event, callback) -199 { -200 $_.each(function(e){ -201 _add_remove(e, event, callback, true); -202 }); -203 }, -204 /** -205 * Removes an event bound the the specified selector, event type, and callback -206 * -207 * @memberOf $_.event -208 * @name remove -209 * @function -210 * @example Eg. $_("#selector").event.remove("click", do_something()); -211 * @param string event -212 * @param string callback -213 */ -214 remove: function (event, callback) -215 { -216 $_.each(function(e){ -217 _add_remove(e, event, callback, false); -218 }); -219 }, -220 /** -221 * Binds a persistent event to the document -222 * -223 * @memberOf $_.event -224 * @name live -225 * @function -226 * @example Eg. $_.event.live(".button", "click", do_something()); -227 * @param string target -228 * @param string event -229 * @param function callback -230 */ -231 live: function (target, event, callback) -232 { -233 _attach_delegate(document.documentElement, target, event, callback); -234 }, -235 /** -236 * Binds an event to a parent object -237 * -238 * @memberOf $_.event -239 * @name delegate -240 * @function -241 * @example Eg. $_("#parent").delegate(".button", "click", do_something()); -242 * @param string target -243 * @param string event_type -244 * @param function callback -245 */ -246 delegate: function (target, event, callback) -247 { -248 $_.each(function(e){ -249 _attach_delegate(e, target, event, callback); -250 }); -251 } -252 }; -253 -254 $_.ext('event', e); -255 -256 }()); \ No newline at end of file + 5 * @todo Add method for triggering events + 6 */ + 7 (function (){ + 8 + 9 "use strict"; + 10 + 11 // Property name for expandos on DOM objects + 12 var kis_expando = "KIS_0_6_0"; + 13 + 14 var _attach, _remove, _add_remove, e, _attach_delegate; + 15 + 16 // Define the proper _attach and _remove functions + 17 // based on browser support + 18 if(typeof document.addEventListener !== "undefined") + 19 { + 20 /** + 21 * @private + 22 */ + 23 _attach = function (sel, event, callback) + 24 { + 25 if(typeof sel.addEventListener !== "undefined") + 26 { + 27 // Duplicated events are dropped, per the specification + 28 sel.addEventListener(event, callback, false); + 29 } + 30 }; + 31 /** + 32 * @private + 33 */ + 34 _remove = function (sel, event, callback) + 35 { + 36 if(typeof sel.removeEventListener !== "undefined") + 37 { + 38 sel.removeEventListener(event, callback, false); + 39 } + 40 }; + 41 } + 42 // typeof function doesn't work in IE where attachEvent is available: brute force it + 43 else if(typeof document.attachEvent !== "undefined") + 44 { + 45 /** + 46 * @private + 47 */ + 48 _attach = function (sel, event, callback) + 49 { + 50 function _listener () { + 51 // Internet Explorer fails to correctly set the 'this' object + 52 // for event listeners, so we need to set it ourselves. + 53 callback.apply(arguments[0]); + 54 } + 55 + 56 if (typeof sel.attachEvent !== "undefined") + 57 { + 58 _remove(event, callback); // Make sure we don't have duplicate listeners + 59 + 60 sel.attachEvent("on" + event, _listener); + 61 // Store our listener so we can remove it later + 62 var expando = sel[kis_expando] = sel[kis_expando] || {}; + 63 expando.listeners = expando.listeners || {}; + 64 expando.listeners[event] = expando.listeners[event] || []; + 65 expando.listeners[event].push({ + 66 callback: callback, + 67 _listener: _listener + 68 }); + 69 } + 70 else + 71 { + 72 console.log("Failed to _attach event:"+event+" on "+sel); + 73 } + 74 }; + 75 /** + 76 * @private + 77 */ + 78 _remove = function (sel, event, callback) + 79 { + 80 if(typeof sel.detachEvent !== "undefined") + 81 { + 82 var expando = sel[kis_expando]; + 83 if (expando && expando.listeners + 84 && expando.listeners[event]) + 85 { + 86 var listeners = expando.listeners[event]; + 87 var len = listeners.length; + 88 for (var i=0; i<len; i++) + 89 { + 90 if (listeners[i].callback === callback) + 91 { + 92 sel.detachEvent("on" + event, listeners[i]._listener); + 93 listeners.splice(i, 1); + 94 if(listeners.length === 0) + 95 { + 96 delete expando.listeners[event]; + 97 } + 98 return; + 99 } +100 } +101 } +102 } +103 }; +104 } +105 +106 _add_remove = function (sel, event, callback, add) +107 { +108 var i, len; +109 +110 if(typeof sel === "undefined") +111 { +112 console.log(arguments); +113 console.log(event); +114 return false; +115 } +116 +117 // Multiple events? Run recursively! +118 if ( ! event.match(/^([\w\-]+)$/)) +119 { +120 event = event.split(" "); +121 +122 len = event.length; +123 +124 for (i = 0; i < len; i++) +125 { +126 _add_remove(sel, event[i], callback, add); +127 } +128 +129 return; +130 } +131 +132 +133 if(add === true) +134 { +135 _attach(sel, event, callback); +136 } +137 else +138 { +139 _remove(sel, event, callback); +140 } +141 }; +142 +143 _attach_delegate = function(sel, target, event, callback) +144 { +145 // attach the listener to the parent object +146 _add_remove(sel, event, function(e){ +147 +148 var elem, t, tar; +149 +150 // IE 8 doesn't have event bound to element +151 e = e || window.event; +152 +153 // Get the live version of the target selector +154 t = $_.$(target, sel); +155 +156 // Check each element to see if it matches the target +157 for(elem in t) +158 { +159 // IE 8 doesn't have target in the event object +160 tar = e.target || e.srcElement; +161 +162 // Fire target callback when event bubbles from target +163 if(tar == t[elem]) +164 { +165 // Trigger the event callback +166 callback.call(t[elem], e); +167 +168 // Stop event propegation +169 e.stopPropagation(); +170 } +171 } +172 +173 }, true); +174 }; +175 +176 // -------------------------------------------------------------------------- +177 +178 /** +179 * Event Listener module +180 * +181 * @namespace +182 * @name event +183 * @memberOf $_ +184 */ +185 e = { +186 /** +187 * Adds an event that returns a callback when triggered on the selected +188 * event and selector +189 * +190 * @memberOf $_.event +191 * @name add +192 * @function +193 * @example Eg. $_("#selector").event.add("click", do_something()); +194 * @param string event +195 * @param function callback +196 */ +197 add: function (event, callback) +198 { +199 $_.each(function(e){ +200 _add_remove(e, event, callback, true); +201 }); +202 }, +203 /** +204 * Removes an event bound the the specified selector, event type, and callback +205 * +206 * @memberOf $_.event +207 * @name remove +208 * @function +209 * @example Eg. $_("#selector").event.remove("click", do_something()); +210 * @param string event +211 * @param string callback +212 */ +213 remove: function (event, callback) +214 { +215 $_.each(function(e){ +216 _add_remove(e, event, callback, false); +217 }); +218 }, +219 /** +220 * Binds a persistent event to the document +221 * +222 * @memberOf $_.event +223 * @name live +224 * @function +225 * @example Eg. $_.event.live(".button", "click", do_something()); +226 * @param string target +227 * @param string event +228 * @param function callback +229 */ +230 live: function (target, event, callback) +231 { +232 _attach_delegate(document.documentElement, target, event, callback); +233 }, +234 /** +235 * Binds an event to a parent object +236 * +237 * @memberOf $_.event +238 * @name delegate +239 * @function +240 * @example Eg. $_("#parent").delegate(".button", "click", do_something()); +241 * @param string target +242 * @param string event_type +243 * @param function callback +244 */ +245 delegate: function (target, event, callback) +246 { +247 $_.each(function(e){ +248 _attach_delegate(e, target, event, callback); +249 }); +250 } +251 }; +252 +253 $_.ext('event', e); +254 +255 }()); \ No newline at end of file diff --git a/docs/symbols/src/kis-js_src_modules_indexedDB.js.html b/docs/symbols/src/kis-js_src_modules_indexedDB.js.html old mode 100644 new mode 100755 index 6a24d8d..27a7bd5 --- a/docs/symbols/src/kis-js_src_modules_indexedDB.js.html +++ b/docs/symbols/src/kis-js_src_modules_indexedDB.js.html @@ -43,7 +43,7 @@ 36 { 37 var request = {}; 38 - 39 version = version || 0; + 39 version = version || 1; 40 41 // Ask for permission to use db 42 request = db.open(dbname, version); @@ -70,9 +70,53 @@ 63 // Connect to the specified db 64 indexedDB.current_db = request.result; 65 }; - 66 } - 67 }; - 68 - 69 $_.ext('indexedDB', indexedDB); - 70 - 71 }()); \ No newline at end of file + 66 }, + 67 /** + 68 * Helper function to create a new object store + 69 * + 70 * @memberOf $_.indexedDB + 71 * @name create_store + 72 * @function + 73 * @param string name + 74 * @param [string] key + 75 * @param [bool] generator + 76 * @return IDBDataStore object + 77 */ + 78 create_store: function(name, key, generator) + 79 { + 80 var params = {}; + 81 + 82 if(typeof key !== "undefined") + 83 { + 84 params.keyPath = key; + 85 } + 86 + 87 if(typeof generator !== "undefined") + 88 { + 89 // Cast to a boolean value + 90 params.autoIncrement = !! generator; + 91 } + 92 + 93 return db.createObjectStore(name, params); + 94 }, + 95 /** + 96 * Delete an object store + 97 * + 98 * @memberOf $_.indexedDB + 99 * @name delete_store +100 * @function +101 * @param string name +102 */ +103 delete_store: function(name) +104 { +105 var request = db.deleteObjectStore(); +106 +107 // Pass the error up +108 request.onerror = db.onerror; +109 } +110 +111 }; +112 +113 $_.ext('indexedDB', indexedDB); +114 +115 }()); \ No newline at end of file diff --git a/docs/symbols/src/kis-js_src_modules_store.js.html b/docs/symbols/src/kis-js_src_modules_store.js.html index 19c4e35..1a97edf 100755 --- a/docs/symbols/src/kis-js_src_modules_store.js.html +++ b/docs/symbols/src/kis-js_src_modules_store.js.html @@ -6,126 +6,127 @@ .REGX {color: #339;} .line {border-right: 1px dotted #666; color: #666; font-style: normal;}
  1 /**
-  2  * Store 
-  3  * 
+  2  * Store
+  3  *
   4  * Wrapper for local / sessionstorage
   5  */
   6 (function (){
-  7 	"use strict";
-  8 	
-  9 	//No support for localstorage? Bail out early
- 10 	if(typeof localStorage === "undefined" || typeof JSON === "undefined")
- 11 	{
- 12 		return;
- 13 	}
- 14 	
- 15 	//Shortcuts for wrapper
- 16 	var l = localStorage,
- 17 		s = sessionStorage;
- 18 
- 19 	/**
- 20 	 * Wrapper for localstorage / sessionstorage data serialization.
- 21 	 * Each method has a boolean parameter, that when set as true switches the method
- 22 	 * to use sessionStorage rather than the default localStorage.
- 23 	 *
- 24 	 * @name store
- 25 	 * @namespace
- 26 	 * @memberOf $_
- 27 	 */
- 28 	var store = {		
- 29 		/**
- 30 		 * Retrieves and deserializes a value from localstorage, 
- 31 		 * based on the specified key
- 32 		 * 
- 33 		 * @param string key
- 34 		 * @param bool session
- 35 		 * @name get
- 36 		 * @memberOf $_.store
- 37 		 * @function
- 38 		 * @return object
- 39 		 * @type object
- 40 		 */
- 41 		get: function (key, sess)
- 42 		{
- 43 			var val = (sess) ? s.getItem(key) : l.getItem(key);
- 44 		
- 45 			return JSON.parse(val);
- 46 		},
- 47 		/**
- 48 		 * Puts a value into localstorage at the specified key,
- 49 		 * and JSON-encodes the value if not a string
- 50 		 *
- 51 		 * @param string key
- 52 		 * @param mixed value
- 53 		 * @param bool session
- 54 		 * @name set
- 55 		 * @memberOf $_.store
- 56 		 * @function
- 57 		 */
- 58 		set: function (key, value, sess)
- 59 		{
- 60 			// Localstorage generally only accepts strings
- 61 			value = JSON.stringify(value);			
- 62 			
- 63 			(sess) ? s.setItem(key, value) : l.setItem(key, value);
- 64 		},
- 65 		/**
- 66 		 * Removes the specified item from storage
- 67 		 * 
- 68 		 * @param string key
- 69 		 * @param bool session
- 70 		 * @name remove
- 71 		 * @memberOf $_.store
- 72 		 * @function
- 73 		 */
- 74 		remove: function (key, sess)
- 75 		{
- 76 			(sess) ? s.removeItem(key) : l.removeItem(key);
- 77 		},
- 78 		/**
- 79 		 * Returns an object of all the raw values in storage
- 80 		 * 
- 81 		 * @param bool session
- 82 		 * @name getAll
- 83 		 * @memberOf $_.store
- 84 		 * @function
- 85 		 * @return object
- 86 		 * @type object
- 87 		 */
- 88 		getAll: function (sess)
- 89 		{
- 90 			var i,
- 91 				len,
- 92 				data = {},
- 93 				k,
- 94 				o;
- 95 			
- 96 			//Reference to session/localstorage
- 97 			o = (sess) ? l : s;
- 98 				
- 99 			len = o.length;
-100 
-101 			for (i = 0; i < len; i++)
-102 			{
-103 				k = o.key(i);
-104 				data[k] = o.getItem(k);
-105 			}
-106 
-107 			return data;
-108 		},
-109 		/**
-110 		 * Removes all values from the same domain storage
-111 		 *
-112 		 * @param bool session
-113 		 * @name clear
-114 		 * @memberOf $_.store
-115 		 * @function
-116 		 */
-117 		clear: function(sess)
-118 		{
-119 			(sess) ? s.clear() : l.clear();
-120 		}
-121 	};
-122 
-123 	$_.ext('store', store);
-124 }());
\ No newline at end of file + 7 + 8 "use strict"; + 9 + 10 //No support for localstorage? Bail out early + 11 if(typeof localStorage === "undefined" || typeof JSON === "undefined") + 12 { + 13 return null; + 14 } + 15 + 16 //Shortcuts for wrapper + 17 var l = localStorage, + 18 s = sessionStorage; + 19 + 20 /** + 21 * Wrapper for localstorage / sessionstorage data serialization. + 22 * Each method has a boolean parameter, that when set as true switches the method + 23 * to use sessionStorage rather than the default localStorage. + 24 * + 25 * @name store + 26 * @namespace + 27 * @memberOf $_ + 28 */ + 29 var store = { + 30 /** + 31 * Retrieves and deserializes a value from localstorage, + 32 * based on the specified key + 33 * + 34 * @param string key + 35 * @param bool session + 36 * @name get + 37 * @memberOf $_.store + 38 * @function + 39 * @return object + 40 * @type object + 41 */ + 42 get: function (key, sess) + 43 { + 44 var val = (sess) ? s.getItem(key) : l.getItem(key); + 45 + 46 return JSON.parse(val); + 47 }, + 48 /** + 49 * Puts a value into localstorage at the specified key, + 50 * and JSON-encodes the value if not a string + 51 * + 52 * @param string key + 53 * @param mixed value + 54 * @param bool session + 55 * @name set + 56 * @memberOf $_.store + 57 * @function + 58 */ + 59 set: function (key, value, sess) + 60 { + 61 // Localstorage generally only accepts strings + 62 value = JSON.stringify(value); + 63 + 64 (sess) ? s.setItem(key, value) : l.setItem(key, value); + 65 }, + 66 /** + 67 * Removes the specified item from storage + 68 * + 69 * @param string key + 70 * @param bool session + 71 * @name remove + 72 * @memberOf $_.store + 73 * @function + 74 */ + 75 remove: function (key, sess) + 76 { + 77 (sess) ? s.removeItem(key) : l.removeItem(key); + 78 }, + 79 /** + 80 * Returns an object of all the raw values in storage + 81 * + 82 * @param bool session + 83 * @name getAll + 84 * @memberOf $_.store + 85 * @function + 86 * @return object + 87 * @type object + 88 */ + 89 getAll: function (sess) + 90 { + 91 var i, + 92 len, + 93 data = {}, + 94 k, + 95 o; + 96 + 97 //Reference to session/localstorage + 98 o = (sess) ? l : s; + 99 +100 len = o.length; +101 +102 for (i = 0; i < len; i++) +103 { +104 k = o.key(i); +105 data[k] = o.getItem(k); +106 } +107 +108 return data; +109 }, +110 /** +111 * Removes all values from the same domain storage +112 * +113 * @param bool session +114 * @name clear +115 * @memberOf $_.store +116 * @function +117 */ +118 clear: function(sess) +119 { +120 (sess) ? s.clear() : l.clear(); +121 } +122 }; +123 +124 $_.ext('store', store); +125 }()); \ No newline at end of file diff --git a/docs/symbols/src/kis-js_src_modules_util.js.html b/docs/symbols/src/kis-js_src_modules_util.js.html index b7b6975..7badfcd 100755 --- a/docs/symbols/src/kis-js_src_modules_util.js.html +++ b/docs/symbols/src/kis-js_src_modules_util.js.html @@ -7,7 +7,7 @@ .line {border-right: 1px dotted #666; color: #666; font-style: normal;}
  1 /**
   2  * Util Object
-  3  * 
+  3  *
   4  * Various object and string manipulation functions
   5  * Note: these are based on similar phpjs functions: http://phpjs.org
   6  */
@@ -15,356 +15,355 @@
   8 
   9 	"use strict";
  10 
- 11 	var 
- 12 	reverse_key_sort =  function(o)
- 13 	{
- 14 		//Define some variables
- 15 		var keys = [],
- 16 			num_keys = 0,
- 17 			new_o = {},
- 18 			i;
- 19 	
- 20 		//Extract the keys
- 21 		keys = u.object_keys(o);
- 22 		
- 23 		//Sort the keys
- 24 		keys.sort(function (b, a) {		
- 25 			var aFloat = parseFloat(a),
- 26 				bFloat = parseFloat(b),
- 27 				aNumeric = aFloat + '' === a,
- 28 				bNumeric = bFloat + '' === b;
- 29 
- 30 			if (aNumeric && bNumeric) 
- 31 			{
- 32 				return aFloat > bFloat ? 1 : aFloat < bFloat ? -1 : 0;
- 33 			} 
- 34 			else if (aNumeric && !bNumeric) 
- 35 			{
- 36 				return 1;
- 37 			} 
- 38 			else if (!aNumeric && bNumeric) 
- 39 			{
- 40 				return -1;
- 41 			}
- 42 			
- 43 			return a > b ? 1 : a < b ? -1 : 0;
- 44 		});
- 45 		
- 46 		// cache object/array size
- 47 		num_keys = keys.length;
- 48 		
- 49 		// Recreate the object/array
- 50 		for(i=0; i < num_keys; i++)
- 51 		{
- 52 			new_o[keys[i]] = o[keys[i]];
- 53 		}
- 54 		
- 55 		return new_o;
- 56 	},
- 57 	
- 58 	/**
- 59 	 * String and object manipulation utilities
- 60 	 *	
- 61 	 * @namespace
- 62 	 * @name util
- 63 	 * @memberOf $_
- 64 	 */
- 65 	u = {
- 66 		/**
- 67 		 * Retrieve the keys, or member names of an object
- 68 		 * 
- 69 		 * @name object_keys
- 70 		 * @memberOf $_.util
- 71 		 * @function
- 72 		 * @param object
- 73 		 * @return array
- 74 		 * @type array
- 75 		 */
- 76 		object_keys: function(o)
- 77 		{
- 78 			var keys = [],
- 79 				k;
- 80 				
- 81 			for(k in o)
- 82 			{
- 83 				if(o.hasOwnProperty(k))
- 84 				{
- 85 					keys.push(k);
- 86 				}
- 87 			}
- 88 			
- 89 			return keys;
- 90 		},
- 91 		/**
- 92 		 * Retrieves the values of an object, and returns
- 93 		 * them as an array
- 94 		 *
- 95 		 * @name object_values
- 96 		 * @memberOf $_.util
- 97 		 * @function
- 98 		 * @param object
- 99 		 * @return array
-100 		 * @type array
-101 		 */
-102 		object_values: function(o)
-103 		{
-104 			var vals = [],
-105 				prop;
-106 			
-107 			for(prop in o)
-108 			{
-109 				vals.push(o[prop]);
-110 			}
-111 			
-112 			return vals;
-113 		},
-114 		/**
-115 		 * Creates an object, with the property names of the first array, 
-116 		 * and the values of the second. If objects are passed, the values 
-117 		 * of the object are used. If the arrays or objects passed are 
-118 		 * not the same size, the function will return false.
-119 		 * 
-120 		 * @name array_combine
-121 		 * @memberOf $_.util
-122 		 * @function
-123 		 * @param array/object keys
-124 		 * @param array/object vals
-125 		 * @return object
-126 		 * @type object
-127 		 */
-128 		array_combine: function(keys, vals)
-129 		{
-130 			var new_object = {},
-131 				num_keys,
-132 				i = 0;
-133 				
-134 			// Extract the keys or values if needed
-135 			if($_.type(keys) !== "array")
-136 			{
-137 				keys = this.object_values(keys);
-138 			}
-139 			if($_.type(vals) !== "array")
-140 			{
-141 				vals = this.object_values(vals);
-142 			}
-143 			
-144 			// cache the number of keys
-145 			num_keys = keys.length;
-146 			
-147 			if(num_keys !== vals.length)
-148 			{
-149 				console.log("Object combine requires two arrays of the same size");
-150 				return false;
-151 			}
-152 			
-153 			// Create and return the new object
-154 			for(i = 0; i < num_keys; i++)
-155 			{
-156 				new_object[keys[i]] = vals[i];
-157 			}
-158 			
-159 			return new_object;
-160 		},
-161 		/**
-162 		 * Combines two or more objects/arrays. If the keys are numeric, the outputted
-163 		 * object will have re-indexed keys. If a key/value pair exists in both objects,
-164 		 * indentical values will be droped, but if a key exists with a different value, 
-165 		 * with the same key, the value in the second array will replace the value in the
-166 		 * first
-167 		 * 
-168 		 * @name object_merge
-169 		 * @memberOf $_.util
-170 		 * @function
-171 		 * @param object [as many as you wish to combine]
-172 		 * @type object
-173 		 * @return object
-174 		 */
-175 		object_merge: function()
-176 		{
-177 			var args = Array.prototype.slice.call(arguments),
-178 				arg_len = args.length,
-179 				new_obj = {},
-180 				arg,
-181 				iarg_len = 0,
-182 				i,
-183 				j,
-184 				x,
-185 				is_array = true;
-186 				
-187 			// Check for an array in the arguments
-188 			for(i=0; i < arg_len; i++)
-189 			{
-190 				if($_.type(args[i]) !== "array")
-191 				{
-192 					is_array = false;
-193 					break;
-194 				}
-195 			}
-196 			
-197 			// If all the arguments are javascript arrays
-198 			if(is_array)
-199 			{
-200 				new_obj = [];
-201 				// Let javascript do all the work!
-202 				for(i=0; i< arg_len; i++)
-203 				{
-204 					new_obj = new_obj.contact(args[i]);
-205 				}
-206 				
-207 				// Return early
-208 				return new_obj;
-209 			}
-210 			
-211 			// No, there's at least one object
-212 			for(i=0, x=0; i < arg_len; i++)
-213 			{
-214 				arg = args[i];
-215 				
-216 				// If the argument is an array, add the array items as
-217 				// numeric object properties
-218 				if ($_.type(arg) == "array")
-219 				{
-220 					for (j=0, iarg_len= arg.length; j < iarg_len; j++)
-221 					{
-222 						new_obj[x++] = arg[j];
-223 					}
-224 				}
-225 				else
-226 				{
-227 					for (j in arg)
-228 					{
-229 						if(arg.hasOwnProperty(j))
-230 						{
-231 							// If the key is numeric, add the property with
-232 							// a numeric key
-233 							if(parseInt(j, 10) + '' === j)
-234 							{
-235 								new_obj[x++] = arg[j];
-236 							}
-237 							else
-238 							{
-239 								new_obj[j] = arg[j];
-240 							} 
-241 						}
-242 					}
-243 				} 
-244 			}
-245 			
-246 			return new_obj;
-247 		},
-248 		/**
-249 		 * Replaces sections of strings in a greedy fashion, 
-250 		 * starting with the longest replace pairs first. Accepts
-251 		 * one replace pair as two parameters, or an object, with
-252 		 * from => to replacements as key/value pairs
-253 		 *
-254 		 * @name str_trans
-255 		 * @memberOf $_.util
-256 		 * @function
-257 		 * @param string input_string
-258 		 * @param mixed from (string)/replace pairs (object)
-259 		 * @param [string]
-260 		 * @return string
-261 		 * @type string
-262 		 */
-263 		str_trans: function(str, from, to)
-264 		{
-265 			var froms = [],
-266 				tos = [],
-267 				ret = '',
-268 				match = false,
-269 				from_len = 0,
-270 				str_len = 0,
-271 				to_len = 0,
-272 				to_is_str = '',
-273 				from_is_str = '',
-274 				strx = '',
-275 				strw = '',
-276 				stry = '',
-277 				from_strx = '',
-278 				new_str = '',
-279 				f,
-280 				i,
-281 				j;
-282 				
-283 			//Replace pairs? add them to the internal arrays
-284 			if(typeof from === 'object')
-285 			{
-286 				// Sort the keys in descending order for better
-287 				// replacement functionality
-288 				from = reverse_key_sort(from);
-289 				
-290 				for(f in from)
-291 				{
-292 					if(from.hasOwnProperty(f))
-293 					{
-294 						froms.push(f);
-295 						tos.push(from[f]);
-296 					}
-297 				}
-298 				
-299 				from = froms;
-300 				to = tos;
-301 			}
-302 			
-303 			//Go through the string, and replace characters as needed
-304 			str_len = str.length;
-305 			from_len = from.length;
-306 			to_len = to.length;
-307 			to_is_str = typeof to === 'string';
-308 			from_is_str = typeof from === 'string';
-309 			
-310 			for(i=0; i < str_len; i++)
-311 			{
-312 				match = false;
-313 				if(from_is_str)
-314 				{
-315 					strw = str.charAt(i-1);
-316 					strx = str.charAt(i);
-317 					stry = str.charAt(i+1);
-318 					for(j=0; j < from_len; j++)
-319 					{
-320 						if(strx == from.charAt(j))
-321 						{
-322 							match = true;
-323 							break;
-324 						}
-325 					}
-326 				}
-327 				else
-328 				{
-329 					for(j=0; j < from_len; j++)
-330 					{
-331 						if(str.substr(i, from[j].length) == from[j])
-332 						{
-333 							match = true;
-334 							
-335 							//Go past the current match
-336 							i = (i + from[j].length) -1;
-337 							break;
-338 
-339 						}
-340 					}
-341 				}
-342 
-343 				if(match)
-344 				{
-345 					new_str += (to_is_str) ? to.charAt(j) : to[j];
-346 				}
-347 				else
-348 				{
-349 					new_str += str.charAt(i);
-350 				}
-351 			}
-352 
-353 			return new_str;
-354 				
-355 		}
-356 		
-357 	};
-358 
-359 	//Add it to the $_ object
-360 	$_.ext('util', u);
-361 }());
-362 
-363 
\ No newline at end of file + 11 var reverse_key_sort = function(o) + 12 { + 13 //Define some variables + 14 var keys = [], + 15 num_keys = 0, + 16 new_o = {}, + 17 i; + 18 + 19 //Extract the keys + 20 keys = u.object_keys(o); + 21 + 22 //Sort the keys + 23 keys.sort(function (b, a) { + 24 var aFloat = parseFloat(a), + 25 bFloat = parseFloat(b), + 26 aNumeric = aFloat + '' === a, + 27 bNumeric = bFloat + '' === b; + 28 + 29 if (aNumeric && bNumeric) + 30 { + 31 return aFloat > bFloat ? 1 : aFloat < bFloat ? -1 : 0; + 32 } + 33 else if (aNumeric && !bNumeric) + 34 { + 35 return 1; + 36 } + 37 else if (!aNumeric && bNumeric) + 38 { + 39 return -1; + 40 } + 41 + 42 return a > b ? 1 : a < b ? -1 : 0; + 43 }); + 44 + 45 // cache object/array size + 46 num_keys = keys.length; + 47 + 48 // Recreate the object/array + 49 for(i=0; i < num_keys; i++) + 50 { + 51 new_o[keys[i]] = o[keys[i]]; + 52 } + 53 + 54 return new_o; + 55 }, + 56 + 57 /** + 58 * String and object manipulation utilities + 59 * + 60 * @namespace + 61 * @name util + 62 * @memberOf $_ + 63 */ + 64 u = { + 65 /** + 66 * Retrieve the keys, or member names of an object + 67 * + 68 * @name object_keys + 69 * @memberOf $_.util + 70 * @function + 71 * @param object + 72 * @return array + 73 * @type array + 74 */ + 75 object_keys: function(o) + 76 { + 77 var keys = [], + 78 k; + 79 + 80 for(k in o) + 81 { + 82 if(o.hasOwnProperty(k)) + 83 { + 84 keys.push(k); + 85 } + 86 } + 87 + 88 return keys; + 89 }, + 90 /** + 91 * Retrieves the values of an object, and returns + 92 * them as an array + 93 * + 94 * @name object_values + 95 * @memberOf $_.util + 96 * @function + 97 * @param object + 98 * @return array + 99 * @type array +100 */ +101 object_values: function(o) +102 { +103 var vals = [], +104 prop; +105 +106 for(prop in o) +107 { +108 vals.push(o[prop]); +109 } +110 +111 return vals; +112 }, +113 /** +114 * Creates an object, with the property names of the first array, +115 * and the values of the second. If objects are passed, the values +116 * of the object are used. If the arrays or objects passed are +117 * not the same size, the function will return false. +118 * +119 * @name array_combine +120 * @memberOf $_.util +121 * @function +122 * @param array/object keys +123 * @param array/object vals +124 * @return object +125 * @type object +126 */ +127 array_combine: function(keys, vals) +128 { +129 var new_object = {}, +130 num_keys, +131 i = 0; +132 +133 // Extract the keys or values if needed +134 if($_.type(keys) !== "array") +135 { +136 keys = this.object_values(keys); +137 } +138 if($_.type(vals) !== "array") +139 { +140 vals = this.object_values(vals); +141 } +142 +143 // cache the number of keys +144 num_keys = keys.length; +145 +146 if(num_keys !== vals.length) +147 { +148 console.log("Object combine requires two arrays of the same size"); +149 return false; +150 } +151 +152 // Create and return the new object +153 for(i = 0; i < num_keys; i++) +154 { +155 new_object[keys[i]] = vals[i]; +156 } +157 +158 return new_object; +159 }, +160 /** +161 * Combines two or more objects/arrays. If the keys are numeric, the outputted +162 * object will have re-indexed keys. If a key/value pair exists in both objects, +163 * indentical values will be droped, but if a key exists with a different value, +164 * with the same key, the value in the second array will replace the value in the +165 * first +166 * +167 * @name object_merge +168 * @memberOf $_.util +169 * @function +170 * @param object [as many as you wish to combine] +171 * @type object +172 * @return object +173 */ +174 object_merge: function() +175 { +176 var args = Array.prototype.slice.call(arguments), +177 arg_len = args.length, +178 new_obj = {}, +179 arg, +180 iarg_len = 0, +181 i, +182 j, +183 x, +184 is_array = true; +185 +186 // Check for an array in the arguments +187 for(i=0; i < arg_len; i++) +188 { +189 if($_.type(args[i]) !== "array") +190 { +191 is_array = false; +192 break; +193 } +194 } +195 +196 // If all the arguments are javascript arrays +197 if(is_array) +198 { +199 new_obj = []; +200 // Let javascript do all the work! +201 for(i=0; i< arg_len; i++) +202 { +203 new_obj = new_obj.contact(args[i]); +204 } +205 +206 // Return early +207 return new_obj; +208 } +209 +210 // No, there's at least one object +211 for(i=0, x=0; i < arg_len; i++) +212 { +213 arg = args[i]; +214 +215 // If the argument is an array, add the array items as +216 // numeric object properties +217 if ($_.type(arg) == "array") +218 { +219 for (j=0, iarg_len= arg.length; j < iarg_len; j++) +220 { +221 new_obj[x++] = arg[j]; +222 } +223 } +224 else +225 { +226 for (j in arg) +227 { +228 if(arg.hasOwnProperty(j)) +229 { +230 // If the key is numeric, add the property with +231 // a numeric key +232 if(parseInt(j, 10) + '' === j) +233 { +234 new_obj[x++] = arg[j]; +235 } +236 else +237 { +238 new_obj[j] = arg[j]; +239 } +240 } +241 } +242 } +243 } +244 +245 return new_obj; +246 }, +247 /** +248 * Replaces sections of strings in a greedy fashion, +249 * starting with the longest replace pairs first. Accepts +250 * one replace pair as two parameters, or an object, with +251 * from => to replacements as key/value pairs +252 * +253 * @name str_trans +254 * @memberOf $_.util +255 * @function +256 * @param string input_string +257 * @param mixed from (string)/replace pairs (object) +258 * @param [string] +259 * @return string +260 * @type string +261 */ +262 str_trans: function(str, from, to) +263 { +264 var froms = [], +265 tos = [], +266 ret = '', +267 match = false, +268 from_len = 0, +269 str_len = 0, +270 to_len = 0, +271 to_is_str = '', +272 from_is_str = '', +273 strx = '', +274 strw = '', +275 stry = '', +276 from_strx = '', +277 new_str = '', +278 f, +279 i, +280 j; +281 +282 //Replace pairs? add them to the internal arrays +283 if(typeof from === 'object') +284 { +285 // Sort the keys in descending order for better +286 // replacement functionality +287 from = reverse_key_sort(from); +288 +289 for(f in from) +290 { +291 if(from.hasOwnProperty(f)) +292 { +293 froms.push(f); +294 tos.push(from[f]); +295 } +296 } +297 +298 from = froms; +299 to = tos; +300 } +301 +302 //Go through the string, and replace characters as needed +303 str_len = str.length; +304 from_len = from.length; +305 to_len = to.length; +306 to_is_str = typeof to === 'string'; +307 from_is_str = typeof from === 'string'; +308 +309 for(i=0; i < str_len; i++) +310 { +311 match = false; +312 if(from_is_str) +313 { +314 strw = str.charAt(i-1); +315 strx = str.charAt(i); +316 stry = str.charAt(i+1); +317 for(j=0; j < from_len; j++) +318 { +319 if(strx == from.charAt(j)) +320 { +321 match = true; +322 break; +323 } +324 } +325 } +326 else +327 { +328 for(j=0; j < from_len; j++) +329 { +330 if(str.substr(i, from[j].length) == from[j]) +331 { +332 match = true; +333 +334 //Go past the current match +335 i = (i + from[j].length) -1; +336 break; +337 +338 } +339 } +340 } +341 +342 if(match) +343 { +344 new_str += (to_is_str) ? to.charAt(j) : to[j]; +345 } +346 else +347 { +348 new_str += str.charAt(i); +349 } +350 } +351 +352 return new_str; +353 +354 } +355 +356 }; +357 +358 //Add it to the $_ object +359 $_.ext('util', u); +360 }()); +361 +362 \ No newline at end of file diff --git a/kis-all.js b/kis-all.js index 55dc98b..113210d 100755 --- a/kis-all.js +++ b/kis-all.js @@ -2,7 +2,7 @@ Kis JS Keep It Simple JS Library Copyright Timothy J. Warren License Public Domain - Version 0.5.0 + Version 0.6.0 */ (function (){ @@ -20,7 +20,7 @@ } var $_, $, dcopy, sel; - + /** * $_ @@ -38,7 +38,7 @@ if(typeof s === "undefined") { //Defines a "global" selector for that instance - sel = (typeof $_.el !== "undefined") + sel = (typeof $_.el !== "undefined") ? $_.el : document.documentElement; } @@ -46,7 +46,7 @@ { sel = (typeof s !== "object") ? $(s) : s; } - + // Add the selector to the prototype $_.prototype.el = sel; @@ -54,19 +54,19 @@ var self = dcopy($_); // Give sel to each extension. - for(var i in self) + for(var i in self) { if(typeof self[i] === "object") { self[i].el = sel; - } + } } self.el = sel; - + return self; }; - + /** * Simple DOM selector function * @@ -79,14 +79,14 @@ $ = function (a, context) { var x, c; - + if (typeof a != "string" || typeof a === "undefined"){ return a;} - + //Check for a context of a specific element, otherwise, just run on the document - c = (context != null && context.nodeType === 1) - ? context + c = (context != null && context.nodeType === 1) + ? context : document; - + //Pick the quickest method for each kind of selector if (a.match(/^#([\w\-]+$)/)) { @@ -96,11 +96,11 @@ { x = c.querySelectorAll(a); } - + //Return the single object if applicable return (x.length === 1) ? x[0] : x; }; - + /** * Deep copy/prototypical constructor function * @@ -112,38 +112,38 @@ dcopy = function(obj) { var type, F; - + if(typeof obj === "undefined") { return; } - + if(typeof Object.create !== "undefined") { return Object.create(obj); } - + type = typeof obj; - + if(type !== "object" && type !== "function") { return; } - + /** * @private */ F = function(){}; - + F.prototype = obj; - + return new F(); - + }; - + /** * Adds the property `obj` to the $_ object, calling it `name` - * + * * @param string name * @param object obj */ @@ -152,7 +152,7 @@ obj.el = sel; $_[name] = obj; }; - + /** * Iterates over a $_ object, applying a callback to each item * @@ -183,7 +183,7 @@ callback.call(sel, sel); } }); - + /** * Retrieves the type of the passed variable * @@ -191,22 +191,22 @@ * @return string * @type string */ - $_.type = function(obj) - { + $_.type = function(obj) + { if((function() {return obj && (obj !== this)}).call(obj)) { //fallback on 'typeof' for truthy primitive values return (typeof obj).toLowerCase(); } - - //Strip x from [object x] and return + + //Strip x from [object x] and return return ({}).toString.call(obj).match(/\s([a-z|A-Z]+)/)[1].toLowerCase(); }; //Set global variables $_ = window.$_ = window.$_ || $_; $_.$ = $; - + }()); // -------------------------------------------------------------------------- @@ -214,11 +214,12 @@ /** * A module of various browser polyfills * @file polyfill.js + * @todo create ES5 Foreach polyfill */ (function(){ "use strict"; - + // Console.log polyfill for IE 8 stupidity if(typeof window.console === "undefined") { @@ -226,9 +227,9 @@ log:function(){} }; } - + // -------------------------------------------------------------------------- - + /** * String trim function polyfill */ @@ -244,23 +245,23 @@ } // -------------------------------------------------------------------------- - + /** * event.preventDefault/e.stopPropagation polyfill * @private */ if(typeof Event.preventDefault === "undefined" && typeof window.event !== "undefined") { - Event.prototype.preventDefault = function() + Event.prototype.preventDefault = function() { window.event.returnValue = false; }, Event.prototype.stopPropagation = function() { window.event.cancelBubble = true; - } + } } - + }()); // -------------------------------------------------------------------------- @@ -278,7 +279,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("a"))) { (function (view){ - + var classListProp = "classList", protoProp = "prototype", elemCtrProto = (view.HTMLElement || view.Element)[protoProp], @@ -434,7 +435,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" /** * DOM - * + * * Dom manipulation module */ (function (){ @@ -442,7 +443,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" "use strict"; var d; - + //Private function for getting/setting attributes/properties function _attr(sel, name, value) { @@ -476,7 +477,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" console.log(value); console.log(sel); console.log("Element does not have the selected attribute"); - return; + return null; } //No value to set? Return the current value @@ -495,7 +496,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" else { sel[name] = value; - } + } } else if (value === null) { @@ -506,12 +507,12 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" else { delete sel[name]; - } + } } return (typeof value !== "undefined") ? value : oldVal; } - + /** * Change css property name to it's * javascript camel case equivalent @@ -526,7 +527,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" function _css(sel, prop, val) { var equi; - + //Camel-case prop = _toCamel(prop); @@ -536,8 +537,8 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" outerWidth: "offsetWidth", top: "posTop" }; - - + + //If you don't define a value, try returning the existing value if(typeof val === "undefined" && sel.style[prop] !== "undefined") { @@ -554,23 +555,23 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" sel.style[prop] = val; //Short circuit - return; + return null; } else if(sel.style[equi[prop]]) { sel.style[equi[prop]] = val; - return; + return null; } - + //No matches? Well, lets log it for now console.log("Property " + prop + " nor an equivalent seems to exist"); } - + // -------------------------------------------------------------------------- /** * DOM - * + * * Dom manipulation module * @namespace * @memberOf $_ @@ -580,7 +581,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" /** * Adds a class to the element(s) specified by the current * selector - * + * * @name addClass * @memberOf $_.dom * @function @@ -595,7 +596,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" /** * Removes a class from the element(s) specified by the current * selector - * + * * @name removeClass * @memberOf $_.dom * @function @@ -609,7 +610,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" }, /** * Hides the element(s) specified by the current selector - * + * * @name hide * @memberOf $_.dom * @function @@ -619,11 +620,11 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" this.css('display', 'none'); }, /** - * Shows the element(s) specified by the current selector. + * Shows the element(s) specified by the current selector. * if type is specified, the element will have it's style * property set to "display:[your type]". If type is not * specified, the element is set to "display:block". - * + * * @name show * @memberOf $_.dom * @function @@ -639,8 +640,8 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" this.css("display", type); }, /** - * Sets attributes on element(s) specified by the current - * selector, or, if name is not specified, returns the + * Sets attributes on element(s) specified by the current + * selector, or, if name is not specified, returns the * value of the attribute of the element specified by the * current selector. * @@ -676,7 +677,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" }, /** * Sets or retrieves the text content of the element - * specified by the current selector. If a value is + * specified by the current selector. If a value is * passed, it will set that value on the current element, * otherwise it will return the value of the current element * @@ -690,11 +691,11 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" text: function (value) { var oldValue, set, type, sel; - + sel = this.el; - + set = (typeof value !== "undefined") ? true : false; - + type = (typeof sel.textContent !== "undefined") ? "textContent" : (typeof sel.innerText !== "undefined") @@ -702,7 +703,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" : "innerHTML"; oldValue = sel[type]; - + if(set) { sel[type] = value; @@ -715,7 +716,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" }, /** * Sets or retrieves a css property of the element - * specified by the current selector. If a value is + * specified by the current selector. If a value is * passed, it will set that value on the current element, * otherwise it will return the value of the css property * on the current element @@ -735,14 +736,14 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" { return _css(this.el, prop); } - + $_.each(function (e){ _css(e, prop, val); }); }, /** * Adds to the innerHTML of the current element, after the last child. - * + * * @example $_("ul").dom.append("<li></li>") adds an li element to the end of the selected ul element * @name append * @memberOf $_.dom @@ -762,7 +763,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" }, /** * Adds to the innerHTML of the selected element, before the current children - * + * * @name prepend * @memberOf $_.dom * @function @@ -791,19 +792,19 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" */ html: function(htm) { - + if(typeof htm !== "undefined") { this.el.innerHTML = htm; } - + //If the parameter is undefined, just return the current value return this.el.innerHTML; } }; $_.ext('dom', d); - + }()); // -------------------------------------------------------------------------- @@ -816,7 +817,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" (function (){ "use strict"; - + // Don't bother even defining the object if the XMLHttpRequest isn't available if(typeof window.XMLHttpRequest === "undefined") { @@ -826,9 +827,9 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" var ajax = { _do: function (url, data, callback, isPost) { - var type, + var type, request = new XMLHttpRequest(); - + if (typeof callback === "undefined") { /** @@ -840,7 +841,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" type = (isPost) ? "POST" : "GET"; url += (type === "GET") ? "?"+this._serialize(data) : ''; - + request.open(type, url); request.onreadystatechange = function () @@ -892,7 +893,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" /** * Sends a GET type ajax request - * + * * @name get * @function * @memberOf $_ @@ -903,10 +904,10 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" $_.ext('get', function (url, data, callback){ ajax._do(url, data, callback, false); }); - + /** * Sends a POST type ajax request - * + * * @name post * @function * @memberOf $_ @@ -917,6 +918,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" $_.ext('post', function (url, data, callback){ ajax._do(url, data, callback, true); }); + }()); // -------------------------------------------------------------------------- @@ -925,13 +927,14 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" * Event * * Event api wrapper + * @todo Add method for triggering events */ (function (){ "use strict"; // Property name for expandos on DOM objects - var kis_expando = "KIS_0_5_0"; + var kis_expando = "KIS_0_6_0"; var _attach, _remove, _add_remove, e, _attach_delegate; @@ -962,7 +965,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" }; } // typeof function doesn't work in IE where attachEvent is available: brute force it - else if(typeof document.attachEvent !== "undefined") + else if(typeof document.attachEvent !== "undefined") { /** * @private @@ -974,11 +977,11 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" // for event listeners, so we need to set it ourselves. callback.apply(arguments[0]); } - + if (typeof sel.attachEvent !== "undefined") { _remove(event, callback); // Make sure we don't have duplicate listeners - + sel.attachEvent("on" + event, _listener); // Store our listener so we can remove it later var expando = sel[kis_expando] = sel[kis_expando] || {}; @@ -1024,11 +1027,11 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" } }; } - + _add_remove = function (sel, event, callback, add) { var i, len; - + if(typeof sel === "undefined") { console.log(arguments); @@ -1040,7 +1043,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" if ( ! event.match(/^([\w\-]+)$/)) { event = event.split(" "); - + len = event.length; for (i = 0; i < len; i++) @@ -1051,7 +1054,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" return; } - + if(add === true) { _attach(sel, event, callback); @@ -1066,37 +1069,35 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" { // attach the listener to the parent object _add_remove(sel, event, function(e){ - + var elem, t, tar; - + // IE 8 doesn't have event bound to element e = e || window.event; - + // Get the live version of the target selector t = $_.$(target, sel); - + // Check each element to see if it matches the target for(elem in t) { // IE 8 doesn't have target in the event object tar = e.target || e.srcElement; - + // Fire target callback when event bubbles from target if(tar == t[elem]) { // Trigger the event callback callback.call(t[elem], e); - + // Stop event propegation e.stopPropagation(); } } - + }, true); }; - - - + // -------------------------------------------------------------------------- /** @@ -1110,7 +1111,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" /** * Adds an event that returns a callback when triggered on the selected * event and selector - * + * * @memberOf $_.event * @name add * @function @@ -1140,7 +1141,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" _add_remove(e, event, callback, false); }); }, - /** + /** * Binds a persistent event to the document * * @memberOf $_.event @@ -1155,7 +1156,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" { _attach_delegate(document.documentElement, target, event, callback); }, - /** + /** * Binds an event to a parent object * * @memberOf $_.event @@ -1218,7 +1219,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" { var request = {}; - version = version || 0; + version = version || 1; // Ask for permission to use db request = db.open(dbname, version); @@ -1245,7 +1246,51 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" // Connect to the specified db indexedDB.current_db = request.result; }; + }, + /** + * Helper function to create a new object store + * + * @memberOf $_.indexedDB + * @name create_store + * @function + * @param string name + * @param [string] key + * @param [bool] generator + * @return IDBDataStore object + */ + create_store: function(name, key, generator) + { + var params = {}; + + if(typeof key !== "undefined") + { + params.keyPath = key; + } + + if(typeof generator !== "undefined") + { + // Cast to a boolean value + params.autoIncrement = !! generator; + } + + return db.createObjectStore(name, params); + }, + /** + * Delete an object store + * + * @memberOf $_.indexedDB + * @name delete_store + * @function + * @param string name + */ + delete_store: function(name) + { + var request = db.deleteObjectStore(); + + // Pass the error up + request.onerror = db.onerror; } + }; $_.ext('indexedDB', indexedDB); @@ -1255,19 +1300,20 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" // -------------------------------------------------------------------------- /** - * Store - * + * Store + * * Wrapper for local / sessionstorage */ (function (){ + "use strict"; - + //No support for localstorage? Bail out early if(typeof localStorage === "undefined" || typeof JSON === "undefined") { - return; + return null; } - + //Shortcuts for wrapper var l = localStorage, s = sessionStorage; @@ -1281,11 +1327,11 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" * @namespace * @memberOf $_ */ - var store = { + var store = { /** - * Retrieves and deserializes a value from localstorage, + * Retrieves and deserializes a value from localstorage, * based on the specified key - * + * * @param string key * @param bool session * @name get @@ -1297,7 +1343,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" get: function (key, sess) { var val = (sess) ? s.getItem(key) : l.getItem(key); - + return JSON.parse(val); }, /** @@ -1314,13 +1360,13 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" set: function (key, value, sess) { // Localstorage generally only accepts strings - value = JSON.stringify(value); - + value = JSON.stringify(value); + (sess) ? s.setItem(key, value) : l.setItem(key, value); }, /** * Removes the specified item from storage - * + * * @param string key * @param bool session * @name remove @@ -1333,7 +1379,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" }, /** * Returns an object of all the raw values in storage - * + * * @param bool session * @name getAll * @memberOf $_.store @@ -1348,10 +1394,10 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" data = {}, k, o; - + //Reference to session/localstorage o = (sess) ? l : s; - + len = o.length; for (i = 0; i < len; i++) @@ -1381,247 +1427,9 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" // -------------------------------------------------------------------------- -/** - * Template module for simple javascript templating - */ -(function(){ - "use strict"; - - //This module relies on some others for simplicity - //so, if they aren't there, don't initialize the module - if($_.ajax === "undefined") - { - return; - } - - var t, _t, _p; - - - //Private object to store retrieved templates - _t = {}; - - //Private object to store parsed templates - _p = {}; - - - /** - * Module for html templating. Requires ajax module. - * - * @name template - * @namespace - * @memberOf $_ - */ - t = { - /** - * Retrieves a template - * - * @memberOf $_.template - * @name get - * @param string name - * @return string - * @function - * @type string - */ - get: function(name) - { - var res; - - res = this.el.innerHTML; - - if(res === "") - { - console.log("Template is empty or cannot be found"); - return; - } - - _t[name] = res; - return res; - }, - /** - * Formats a template - * - * @memberOf $_.template - * @name parse - * @param string template_name - * @param object replace_data - * @return string - * @function - * @type string - */ - parse: function(name, data) - { - var tmp = _t[name], - pairs = [], - pair_reg = /\{([A-Z0-9_\-]+)\}(.*)\{\/\1\}/gim, - var_reg = /\{([A-Z0-9_\-]+)\}/gim, - pseudos = [], - num_pairs = 0, - num_pseudos = 0, - i = 0, - j = 0, - var_name = '', - rep_data = {}, - tmp_data = '', - data_len, - frag, - frag_section, - emptys, - x; - - tmp = String(tmp); - - //Remove newlines and tabs from template because - //those whitespace characters are extra bandwidth - tmp = tmp.replace(/\s+/gim, " "); - tmp = tmp.replace(/>\s+<"); - tmp = tmp.replace(/>\s+\{/gim, ">{"); - tmp = tmp.replace(/\}\s+ 0) - { - data_len = rep_data.length; - - //Get rid of the loop tags - pairs[i] = pairs[i].replace(pair_reg, "$2"); - - //Replace psudovariables with data - for(j=0;j bFloat ? 1 : aFloat < bFloat ? -1 : 0; - } - else if (aNumeric && !bNumeric) + } + else if (aNumeric && !bNumeric) { return 1; - } - else if (!aNumeric && bNumeric) + } + else if (!aNumeric && bNumeric) { return -1; } - + return a > b ? 1 : a < b ? -1 : 0; }); - + // cache object/array size num_keys = keys.length; - + // Recreate the object/array for(i=0; i < num_keys; i++) { new_o[keys[i]] = o[keys[i]]; } - + return new_o; }, - + /** * String and object manipulation utilities - * + * * @namespace * @name util * @memberOf $_ @@ -1686,7 +1493,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" u = { /** * Retrieve the keys, or member names of an object - * + * * @name object_keys * @memberOf $_.util * @function @@ -1698,7 +1505,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" { var keys = [], k; - + for(k in o) { if(o.hasOwnProperty(k)) @@ -1706,7 +1513,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" keys.push(k); } } - + return keys; }, /** @@ -1724,20 +1531,20 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" { var vals = [], prop; - + for(prop in o) { vals.push(o[prop]); } - + return vals; }, /** - * Creates an object, with the property names of the first array, - * and the values of the second. If objects are passed, the values - * of the object are used. If the arrays or objects passed are + * Creates an object, with the property names of the first array, + * and the values of the second. If objects are passed, the values + * of the object are used. If the arrays or objects passed are * not the same size, the function will return false. - * + * * @name array_combine * @memberOf $_.util * @function @@ -1751,7 +1558,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" var new_object = {}, num_keys, i = 0; - + // Extract the keys or values if needed if($_.type(keys) !== "array") { @@ -1761,31 +1568,31 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" { vals = this.object_values(vals); } - + // cache the number of keys num_keys = keys.length; - + if(num_keys !== vals.length) { console.log("Object combine requires two arrays of the same size"); return false; } - + // Create and return the new object for(i = 0; i < num_keys; i++) { new_object[keys[i]] = vals[i]; } - + return new_object; }, /** * Combines two or more objects/arrays. If the keys are numeric, the outputted * object will have re-indexed keys. If a key/value pair exists in both objects, - * indentical values will be droped, but if a key exists with a different value, + * indentical values will be droped, but if a key exists with a different value, * with the same key, the value in the second array will replace the value in the * first - * + * * @name object_merge * @memberOf $_.util * @function @@ -1804,7 +1611,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" j, x, is_array = true; - + // Check for an array in the arguments for(i=0; i < arg_len; i++) { @@ -1814,7 +1621,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" break; } } - + // If all the arguments are javascript arrays if(is_array) { @@ -1824,16 +1631,16 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" { new_obj = new_obj.contact(args[i]); } - + // Return early return new_obj; } - + // No, there's at least one object for(i=0, x=0; i < arg_len; i++) { arg = args[i]; - + // If the argument is an array, add the array items as // numeric object properties if ($_.type(arg) == "array") @@ -1858,16 +1665,16 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" else { new_obj[j] = arg[j]; - } + } } } - } + } } - + return new_obj; }, /** - * Replaces sections of strings in a greedy fashion, + * Replaces sections of strings in a greedy fashion, * starting with the longest replace pairs first. Accepts * one replace pair as two parameters, or an object, with * from => to replacements as key/value pairs @@ -1900,14 +1707,14 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" f, i, j; - + //Replace pairs? add them to the internal arrays if(typeof from === 'object') { // Sort the keys in descending order for better // replacement functionality from = reverse_key_sort(from); - + for(f in from) { if(from.hasOwnProperty(f)) @@ -1916,18 +1723,18 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" tos.push(from[f]); } } - + from = froms; to = tos; } - + //Go through the string, and replace characters as needed str_len = str.length; from_len = from.length; to_len = to.length; to_is_str = typeof to === 'string'; from_is_str = typeof from === 'string'; - + for(i=0; i < str_len; i++) { match = false; @@ -1952,7 +1759,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" if(str.substr(i, from[j].length) == from[j]) { match = true; - + //Go past the current match i = (i + from[j].length) -1; break; @@ -1972,9 +1779,9 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" } return new_str; - + } - + }; //Add it to the $_ object diff --git a/kis-lite-dom-min.js b/kis-lite-dom-min.js index 301a396..68994a3 100755 --- a/kis-lite-dom-min.js +++ b/kis-lite-dom-min.js @@ -2,7 +2,7 @@ Kis JS Keep It Simple JS Library Copyright Timothy J. Warren License Public Domain - Version 0.5.0 + Version 0.6.0 */ (function (){ @@ -20,7 +20,7 @@ } var $_, $, dcopy, sel; - + /** * $_ @@ -38,7 +38,7 @@ if(typeof s === "undefined") { //Defines a "global" selector for that instance - sel = (typeof $_.el !== "undefined") + sel = (typeof $_.el !== "undefined") ? $_.el : document.documentElement; } @@ -46,7 +46,7 @@ { sel = (typeof s !== "object") ? $(s) : s; } - + // Add the selector to the prototype $_.prototype.el = sel; @@ -54,19 +54,19 @@ var self = dcopy($_); // Give sel to each extension. - for(var i in self) + for(var i in self) { if(typeof self[i] === "object") { self[i].el = sel; - } + } } self.el = sel; - + return self; }; - + /** * Simple DOM selector function * @@ -79,14 +79,14 @@ $ = function (a, context) { var x, c; - + if (typeof a != "string" || typeof a === "undefined"){ return a;} - + //Check for a context of a specific element, otherwise, just run on the document - c = (context != null && context.nodeType === 1) - ? context + c = (context != null && context.nodeType === 1) + ? context : document; - + //Pick the quickest method for each kind of selector if (a.match(/^#([\w\-]+$)/)) { @@ -96,11 +96,11 @@ { x = c.querySelectorAll(a); } - + //Return the single object if applicable return (x.length === 1) ? x[0] : x; }; - + /** * Deep copy/prototypical constructor function * @@ -112,38 +112,38 @@ dcopy = function(obj) { var type, F; - + if(typeof obj === "undefined") { return; } - + if(typeof Object.create !== "undefined") { return Object.create(obj); } - + type = typeof obj; - + if(type !== "object" && type !== "function") { return; } - + /** * @private */ F = function(){}; - + F.prototype = obj; - + return new F(); - + }; - + /** * Adds the property `obj` to the $_ object, calling it `name` - * + * * @param string name * @param object obj */ @@ -152,7 +152,7 @@ obj.el = sel; $_[name] = obj; }; - + /** * Iterates over a $_ object, applying a callback to each item * @@ -183,7 +183,7 @@ callback.call(sel, sel); } }); - + /** * Retrieves the type of the passed variable * @@ -191,22 +191,22 @@ * @return string * @type string */ - $_.type = function(obj) - { + $_.type = function(obj) + { if((function() {return obj && (obj !== this)}).call(obj)) { //fallback on 'typeof' for truthy primitive values return (typeof obj).toLowerCase(); } - - //Strip x from [object x] and return + + //Strip x from [object x] and return return ({}).toString.call(obj).match(/\s([a-z|A-Z]+)/)[1].toLowerCase(); }; //Set global variables $_ = window.$_ = window.$_ || $_; $_.$ = $; - + }()); // -------------------------------------------------------------------------- @@ -214,11 +214,12 @@ /** * A module of various browser polyfills * @file polyfill.js + * @todo create ES5 Foreach polyfill */ (function(){ "use strict"; - + // Console.log polyfill for IE 8 stupidity if(typeof window.console === "undefined") { @@ -226,9 +227,9 @@ log:function(){} }; } - + // -------------------------------------------------------------------------- - + /** * String trim function polyfill */ @@ -244,23 +245,23 @@ } // -------------------------------------------------------------------------- - + /** * event.preventDefault/e.stopPropagation polyfill * @private */ if(typeof Event.preventDefault === "undefined" && typeof window.event !== "undefined") { - Event.prototype.preventDefault = function() + Event.prototype.preventDefault = function() { window.event.returnValue = false; }, Event.prototype.stopPropagation = function() { window.event.cancelBubble = true; - } + } } - + }()); // -------------------------------------------------------------------------- @@ -273,7 +274,7 @@ (function (){ "use strict"; - + // Don't bother even defining the object if the XMLHttpRequest isn't available if(typeof window.XMLHttpRequest === "undefined") { @@ -283,9 +284,9 @@ var ajax = { _do: function (url, data, callback, isPost) { - var type, + var type, request = new XMLHttpRequest(); - + if (typeof callback === "undefined") { /** @@ -297,7 +298,7 @@ type = (isPost) ? "POST" : "GET"; url += (type === "GET") ? "?"+this._serialize(data) : ''; - + request.open(type, url); request.onreadystatechange = function () @@ -349,7 +350,7 @@ /** * Sends a GET type ajax request - * + * * @name get * @function * @memberOf $_ @@ -360,10 +361,10 @@ $_.ext('get', function (url, data, callback){ ajax._do(url, data, callback, false); }); - + /** * Sends a POST type ajax request - * + * * @name post * @function * @memberOf $_ @@ -374,6 +375,7 @@ $_.ext('post', function (url, data, callback){ ajax._do(url, data, callback, true); }); + }()); // -------------------------------------------------------------------------- @@ -382,13 +384,14 @@ * Event * * Event api wrapper + * @todo Add method for triggering events */ (function (){ "use strict"; // Property name for expandos on DOM objects - var kis_expando = "KIS_0_5_0"; + var kis_expando = "KIS_0_6_0"; var _attach, _remove, _add_remove, e, _attach_delegate; @@ -419,7 +422,7 @@ }; } // typeof function doesn't work in IE where attachEvent is available: brute force it - else if(typeof document.attachEvent !== "undefined") + else if(typeof document.attachEvent !== "undefined") { /** * @private @@ -431,11 +434,11 @@ // for event listeners, so we need to set it ourselves. callback.apply(arguments[0]); } - + if (typeof sel.attachEvent !== "undefined") { _remove(event, callback); // Make sure we don't have duplicate listeners - + sel.attachEvent("on" + event, _listener); // Store our listener so we can remove it later var expando = sel[kis_expando] = sel[kis_expando] || {}; @@ -481,11 +484,11 @@ } }; } - + _add_remove = function (sel, event, callback, add) { var i, len; - + if(typeof sel === "undefined") { console.log(arguments); @@ -497,7 +500,7 @@ if ( ! event.match(/^([\w\-]+)$/)) { event = event.split(" "); - + len = event.length; for (i = 0; i < len; i++) @@ -508,7 +511,7 @@ return; } - + if(add === true) { _attach(sel, event, callback); @@ -523,37 +526,35 @@ { // attach the listener to the parent object _add_remove(sel, event, function(e){ - + var elem, t, tar; - + // IE 8 doesn't have event bound to element e = e || window.event; - + // Get the live version of the target selector t = $_.$(target, sel); - + // Check each element to see if it matches the target for(elem in t) { // IE 8 doesn't have target in the event object tar = e.target || e.srcElement; - + // Fire target callback when event bubbles from target if(tar == t[elem]) { // Trigger the event callback callback.call(t[elem], e); - + // Stop event propegation e.stopPropagation(); } } - + }, true); }; - - - + // -------------------------------------------------------------------------- /** @@ -567,7 +568,7 @@ /** * Adds an event that returns a callback when triggered on the selected * event and selector - * + * * @memberOf $_.event * @name add * @function @@ -597,7 +598,7 @@ _add_remove(e, event, callback, false); }); }, - /** + /** * Binds a persistent event to the document * * @memberOf $_.event @@ -612,7 +613,7 @@ { _attach_delegate(document.documentElement, target, event, callback); }, - /** + /** * Binds an event to a parent object * * @memberOf $_.event @@ -650,7 +651,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("a"))) { (function (view){ - + var classListProp = "classList", protoProp = "prototype", elemCtrProto = (view.HTMLElement || view.Element)[protoProp], @@ -806,7 +807,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" /** * DOM - * + * * Dom manipulation module */ (function (){ @@ -814,7 +815,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" "use strict"; var d; - + //Private function for getting/setting attributes/properties function _attr(sel, name, value) { @@ -848,7 +849,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" console.log(value); console.log(sel); console.log("Element does not have the selected attribute"); - return; + return null; } //No value to set? Return the current value @@ -867,7 +868,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" else { sel[name] = value; - } + } } else if (value === null) { @@ -878,12 +879,12 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" else { delete sel[name]; - } + } } return (typeof value !== "undefined") ? value : oldVal; } - + /** * Change css property name to it's * javascript camel case equivalent @@ -898,7 +899,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" function _css(sel, prop, val) { var equi; - + //Camel-case prop = _toCamel(prop); @@ -908,8 +909,8 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" outerWidth: "offsetWidth", top: "posTop" }; - - + + //If you don't define a value, try returning the existing value if(typeof val === "undefined" && sel.style[prop] !== "undefined") { @@ -926,23 +927,23 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" sel.style[prop] = val; //Short circuit - return; + return null; } else if(sel.style[equi[prop]]) { sel.style[equi[prop]] = val; - return; + return null; } - + //No matches? Well, lets log it for now console.log("Property " + prop + " nor an equivalent seems to exist"); } - + // -------------------------------------------------------------------------- /** * DOM - * + * * Dom manipulation module * @namespace * @memberOf $_ @@ -952,7 +953,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" /** * Adds a class to the element(s) specified by the current * selector - * + * * @name addClass * @memberOf $_.dom * @function @@ -967,7 +968,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" /** * Removes a class from the element(s) specified by the current * selector - * + * * @name removeClass * @memberOf $_.dom * @function @@ -981,7 +982,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" }, /** * Hides the element(s) specified by the current selector - * + * * @name hide * @memberOf $_.dom * @function @@ -991,11 +992,11 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" this.css('display', 'none'); }, /** - * Shows the element(s) specified by the current selector. + * Shows the element(s) specified by the current selector. * if type is specified, the element will have it's style * property set to "display:[your type]". If type is not * specified, the element is set to "display:block". - * + * * @name show * @memberOf $_.dom * @function @@ -1011,8 +1012,8 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" this.css("display", type); }, /** - * Sets attributes on element(s) specified by the current - * selector, or, if name is not specified, returns the + * Sets attributes on element(s) specified by the current + * selector, or, if name is not specified, returns the * value of the attribute of the element specified by the * current selector. * @@ -1048,7 +1049,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" }, /** * Sets or retrieves the text content of the element - * specified by the current selector. If a value is + * specified by the current selector. If a value is * passed, it will set that value on the current element, * otherwise it will return the value of the current element * @@ -1062,11 +1063,11 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" text: function (value) { var oldValue, set, type, sel; - + sel = this.el; - + set = (typeof value !== "undefined") ? true : false; - + type = (typeof sel.textContent !== "undefined") ? "textContent" : (typeof sel.innerText !== "undefined") @@ -1074,7 +1075,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" : "innerHTML"; oldValue = sel[type]; - + if(set) { sel[type] = value; @@ -1087,7 +1088,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" }, /** * Sets or retrieves a css property of the element - * specified by the current selector. If a value is + * specified by the current selector. If a value is * passed, it will set that value on the current element, * otherwise it will return the value of the css property * on the current element @@ -1107,14 +1108,14 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" { return _css(this.el, prop); } - + $_.each(function (e){ _css(e, prop, val); }); }, /** * Adds to the innerHTML of the current element, after the last child. - * + * * @example $_("ul").dom.append("<li></li>") adds an li element to the end of the selected ul element * @name append * @memberOf $_.dom @@ -1134,7 +1135,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" }, /** * Adds to the innerHTML of the selected element, before the current children - * + * * @name prepend * @memberOf $_.dom * @function @@ -1163,18 +1164,17 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" */ html: function(htm) { - + if(typeof htm !== "undefined") { this.el.innerHTML = htm; } - + //If the parameter is undefined, just return the current value return this.el.innerHTML; } }; $_.ext('dom', d); - -}()); +}()); diff --git a/kis-lite-dom.js b/kis-lite-dom.js index 301a396..68994a3 100755 --- a/kis-lite-dom.js +++ b/kis-lite-dom.js @@ -2,7 +2,7 @@ Kis JS Keep It Simple JS Library Copyright Timothy J. Warren License Public Domain - Version 0.5.0 + Version 0.6.0 */ (function (){ @@ -20,7 +20,7 @@ } var $_, $, dcopy, sel; - + /** * $_ @@ -38,7 +38,7 @@ if(typeof s === "undefined") { //Defines a "global" selector for that instance - sel = (typeof $_.el !== "undefined") + sel = (typeof $_.el !== "undefined") ? $_.el : document.documentElement; } @@ -46,7 +46,7 @@ { sel = (typeof s !== "object") ? $(s) : s; } - + // Add the selector to the prototype $_.prototype.el = sel; @@ -54,19 +54,19 @@ var self = dcopy($_); // Give sel to each extension. - for(var i in self) + for(var i in self) { if(typeof self[i] === "object") { self[i].el = sel; - } + } } self.el = sel; - + return self; }; - + /** * Simple DOM selector function * @@ -79,14 +79,14 @@ $ = function (a, context) { var x, c; - + if (typeof a != "string" || typeof a === "undefined"){ return a;} - + //Check for a context of a specific element, otherwise, just run on the document - c = (context != null && context.nodeType === 1) - ? context + c = (context != null && context.nodeType === 1) + ? context : document; - + //Pick the quickest method for each kind of selector if (a.match(/^#([\w\-]+$)/)) { @@ -96,11 +96,11 @@ { x = c.querySelectorAll(a); } - + //Return the single object if applicable return (x.length === 1) ? x[0] : x; }; - + /** * Deep copy/prototypical constructor function * @@ -112,38 +112,38 @@ dcopy = function(obj) { var type, F; - + if(typeof obj === "undefined") { return; } - + if(typeof Object.create !== "undefined") { return Object.create(obj); } - + type = typeof obj; - + if(type !== "object" && type !== "function") { return; } - + /** * @private */ F = function(){}; - + F.prototype = obj; - + return new F(); - + }; - + /** * Adds the property `obj` to the $_ object, calling it `name` - * + * * @param string name * @param object obj */ @@ -152,7 +152,7 @@ obj.el = sel; $_[name] = obj; }; - + /** * Iterates over a $_ object, applying a callback to each item * @@ -183,7 +183,7 @@ callback.call(sel, sel); } }); - + /** * Retrieves the type of the passed variable * @@ -191,22 +191,22 @@ * @return string * @type string */ - $_.type = function(obj) - { + $_.type = function(obj) + { if((function() {return obj && (obj !== this)}).call(obj)) { //fallback on 'typeof' for truthy primitive values return (typeof obj).toLowerCase(); } - - //Strip x from [object x] and return + + //Strip x from [object x] and return return ({}).toString.call(obj).match(/\s([a-z|A-Z]+)/)[1].toLowerCase(); }; //Set global variables $_ = window.$_ = window.$_ || $_; $_.$ = $; - + }()); // -------------------------------------------------------------------------- @@ -214,11 +214,12 @@ /** * A module of various browser polyfills * @file polyfill.js + * @todo create ES5 Foreach polyfill */ (function(){ "use strict"; - + // Console.log polyfill for IE 8 stupidity if(typeof window.console === "undefined") { @@ -226,9 +227,9 @@ log:function(){} }; } - + // -------------------------------------------------------------------------- - + /** * String trim function polyfill */ @@ -244,23 +245,23 @@ } // -------------------------------------------------------------------------- - + /** * event.preventDefault/e.stopPropagation polyfill * @private */ if(typeof Event.preventDefault === "undefined" && typeof window.event !== "undefined") { - Event.prototype.preventDefault = function() + Event.prototype.preventDefault = function() { window.event.returnValue = false; }, Event.prototype.stopPropagation = function() { window.event.cancelBubble = true; - } + } } - + }()); // -------------------------------------------------------------------------- @@ -273,7 +274,7 @@ (function (){ "use strict"; - + // Don't bother even defining the object if the XMLHttpRequest isn't available if(typeof window.XMLHttpRequest === "undefined") { @@ -283,9 +284,9 @@ var ajax = { _do: function (url, data, callback, isPost) { - var type, + var type, request = new XMLHttpRequest(); - + if (typeof callback === "undefined") { /** @@ -297,7 +298,7 @@ type = (isPost) ? "POST" : "GET"; url += (type === "GET") ? "?"+this._serialize(data) : ''; - + request.open(type, url); request.onreadystatechange = function () @@ -349,7 +350,7 @@ /** * Sends a GET type ajax request - * + * * @name get * @function * @memberOf $_ @@ -360,10 +361,10 @@ $_.ext('get', function (url, data, callback){ ajax._do(url, data, callback, false); }); - + /** * Sends a POST type ajax request - * + * * @name post * @function * @memberOf $_ @@ -374,6 +375,7 @@ $_.ext('post', function (url, data, callback){ ajax._do(url, data, callback, true); }); + }()); // -------------------------------------------------------------------------- @@ -382,13 +384,14 @@ * Event * * Event api wrapper + * @todo Add method for triggering events */ (function (){ "use strict"; // Property name for expandos on DOM objects - var kis_expando = "KIS_0_5_0"; + var kis_expando = "KIS_0_6_0"; var _attach, _remove, _add_remove, e, _attach_delegate; @@ -419,7 +422,7 @@ }; } // typeof function doesn't work in IE where attachEvent is available: brute force it - else if(typeof document.attachEvent !== "undefined") + else if(typeof document.attachEvent !== "undefined") { /** * @private @@ -431,11 +434,11 @@ // for event listeners, so we need to set it ourselves. callback.apply(arguments[0]); } - + if (typeof sel.attachEvent !== "undefined") { _remove(event, callback); // Make sure we don't have duplicate listeners - + sel.attachEvent("on" + event, _listener); // Store our listener so we can remove it later var expando = sel[kis_expando] = sel[kis_expando] || {}; @@ -481,11 +484,11 @@ } }; } - + _add_remove = function (sel, event, callback, add) { var i, len; - + if(typeof sel === "undefined") { console.log(arguments); @@ -497,7 +500,7 @@ if ( ! event.match(/^([\w\-]+)$/)) { event = event.split(" "); - + len = event.length; for (i = 0; i < len; i++) @@ -508,7 +511,7 @@ return; } - + if(add === true) { _attach(sel, event, callback); @@ -523,37 +526,35 @@ { // attach the listener to the parent object _add_remove(sel, event, function(e){ - + var elem, t, tar; - + // IE 8 doesn't have event bound to element e = e || window.event; - + // Get the live version of the target selector t = $_.$(target, sel); - + // Check each element to see if it matches the target for(elem in t) { // IE 8 doesn't have target in the event object tar = e.target || e.srcElement; - + // Fire target callback when event bubbles from target if(tar == t[elem]) { // Trigger the event callback callback.call(t[elem], e); - + // Stop event propegation e.stopPropagation(); } } - + }, true); }; - - - + // -------------------------------------------------------------------------- /** @@ -567,7 +568,7 @@ /** * Adds an event that returns a callback when triggered on the selected * event and selector - * + * * @memberOf $_.event * @name add * @function @@ -597,7 +598,7 @@ _add_remove(e, event, callback, false); }); }, - /** + /** * Binds a persistent event to the document * * @memberOf $_.event @@ -612,7 +613,7 @@ { _attach_delegate(document.documentElement, target, event, callback); }, - /** + /** * Binds an event to a parent object * * @memberOf $_.event @@ -650,7 +651,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("a"))) { (function (view){ - + var classListProp = "classList", protoProp = "prototype", elemCtrProto = (view.HTMLElement || view.Element)[protoProp], @@ -806,7 +807,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" /** * DOM - * + * * Dom manipulation module */ (function (){ @@ -814,7 +815,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" "use strict"; var d; - + //Private function for getting/setting attributes/properties function _attr(sel, name, value) { @@ -848,7 +849,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" console.log(value); console.log(sel); console.log("Element does not have the selected attribute"); - return; + return null; } //No value to set? Return the current value @@ -867,7 +868,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" else { sel[name] = value; - } + } } else if (value === null) { @@ -878,12 +879,12 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" else { delete sel[name]; - } + } } return (typeof value !== "undefined") ? value : oldVal; } - + /** * Change css property name to it's * javascript camel case equivalent @@ -898,7 +899,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" function _css(sel, prop, val) { var equi; - + //Camel-case prop = _toCamel(prop); @@ -908,8 +909,8 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" outerWidth: "offsetWidth", top: "posTop" }; - - + + //If you don't define a value, try returning the existing value if(typeof val === "undefined" && sel.style[prop] !== "undefined") { @@ -926,23 +927,23 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" sel.style[prop] = val; //Short circuit - return; + return null; } else if(sel.style[equi[prop]]) { sel.style[equi[prop]] = val; - return; + return null; } - + //No matches? Well, lets log it for now console.log("Property " + prop + " nor an equivalent seems to exist"); } - + // -------------------------------------------------------------------------- /** * DOM - * + * * Dom manipulation module * @namespace * @memberOf $_ @@ -952,7 +953,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" /** * Adds a class to the element(s) specified by the current * selector - * + * * @name addClass * @memberOf $_.dom * @function @@ -967,7 +968,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" /** * Removes a class from the element(s) specified by the current * selector - * + * * @name removeClass * @memberOf $_.dom * @function @@ -981,7 +982,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" }, /** * Hides the element(s) specified by the current selector - * + * * @name hide * @memberOf $_.dom * @function @@ -991,11 +992,11 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" this.css('display', 'none'); }, /** - * Shows the element(s) specified by the current selector. + * Shows the element(s) specified by the current selector. * if type is specified, the element will have it's style * property set to "display:[your type]". If type is not * specified, the element is set to "display:block". - * + * * @name show * @memberOf $_.dom * @function @@ -1011,8 +1012,8 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" this.css("display", type); }, /** - * Sets attributes on element(s) specified by the current - * selector, or, if name is not specified, returns the + * Sets attributes on element(s) specified by the current + * selector, or, if name is not specified, returns the * value of the attribute of the element specified by the * current selector. * @@ -1048,7 +1049,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" }, /** * Sets or retrieves the text content of the element - * specified by the current selector. If a value is + * specified by the current selector. If a value is * passed, it will set that value on the current element, * otherwise it will return the value of the current element * @@ -1062,11 +1063,11 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" text: function (value) { var oldValue, set, type, sel; - + sel = this.el; - + set = (typeof value !== "undefined") ? true : false; - + type = (typeof sel.textContent !== "undefined") ? "textContent" : (typeof sel.innerText !== "undefined") @@ -1074,7 +1075,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" : "innerHTML"; oldValue = sel[type]; - + if(set) { sel[type] = value; @@ -1087,7 +1088,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" }, /** * Sets or retrieves a css property of the element - * specified by the current selector. If a value is + * specified by the current selector. If a value is * passed, it will set that value on the current element, * otherwise it will return the value of the css property * on the current element @@ -1107,14 +1108,14 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" { return _css(this.el, prop); } - + $_.each(function (e){ _css(e, prop, val); }); }, /** * Adds to the innerHTML of the current element, after the last child. - * + * * @example $_("ul").dom.append("<li></li>") adds an li element to the end of the selected ul element * @name append * @memberOf $_.dom @@ -1134,7 +1135,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" }, /** * Adds to the innerHTML of the selected element, before the current children - * + * * @name prepend * @memberOf $_.dom * @function @@ -1163,18 +1164,17 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" */ html: function(htm) { - + if(typeof htm !== "undefined") { this.el.innerHTML = htm; } - + //If the parameter is undefined, just return the current value return this.el.innerHTML; } }; $_.ext('dom', d); - -}()); +}()); diff --git a/kis-lite-min.js b/kis-lite-min.js index 00ee746..227bc1d 100755 --- a/kis-lite-min.js +++ b/kis-lite-min.js @@ -1,9 +1,9 @@ (function(){if("undefined"!==typeof document.querySelector){var e,f,d,c;e=function(a){c="undefined"===typeof a?"undefined"!==typeof e.el?e.el:document.documentElement:"object"!==typeof a?f(a):a;e.prototype.el=c;var a=d(e),b;for(b in a)"object"===typeof a[b]&&(a[b].el=c);a.el=c;return a};f=function(a,b){var g;if("string"!=typeof a||"undefined"===typeof a)return a;g=null!=b&&1===b.nodeType?b:document;if(a.match(/^#([\w\-]+$)/))return document.getElementById(a.split("#")[1]);g=g.querySelectorAll(a); return 1===g.length?g[0]:g};d=function(a){var b;if("undefined"!==typeof a){if("undefined"!==typeof Object.create)return Object.create(a);b=typeof a;if(!("object"!==b&&"function"!==b))return b=function(){},b.prototype=a,new b}};e.ext=function(a,b){b.el=c;e[a]=b};e.ext("each",function(a){if("undefined"!==typeof c.length&&c!==window){var b=c.length;if(0!==b)for(var g,d=0;d\s+<"),a=a.replace(/>\s+\{/gim,">{"),a=a.replace(/\}\s+d?1:ca?1:bd?1:ca?1:b