diff --git a/.gitignore b/.gitignore index e5065e8..d2231c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ kis-custom.js kis-custom-min.js combine-build.php -test.html \ No newline at end of file +test.html +index.php diff --git a/docs/files.html b/docs/files.html index 81dfe27..41f948f 100644 --- 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)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
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
store.js../kis-js/src/modules/event.js
util.js../kis-js/src/modules/event.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)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, 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
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 diff --git a/docs/index.html b/docs/index.html index d9dfc43..bfc11f4 100644 --- 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)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
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 +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)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, 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 diff --git a/docs/symbols/$_.dom.html b/docs/symbols/$_.dom.html index ea57490..2161f38 100644 --- 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)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
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.
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.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)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, 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.
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.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 e531fe9..dcbb398 100644 --- 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)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
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 +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)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, 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 diff --git a/docs/symbols/$_.html b/docs/symbols/$_.html index e5bf475..6b00f51 100644 --- 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)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
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.
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.

$_.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 +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)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, 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.
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.

$_.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 diff --git a/docs/symbols/$_.store.html b/docs/symbols/$_.store.html index e6b769a..46cafa8 100644 --- 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)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
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 +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)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, 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 diff --git a/docs/symbols/$_.template.html b/docs/symbols/$_.template.html new file mode 100644 index 0000000..a125238 --- /dev/null +++ b/docs/symbols/$_.template.html @@ -0,0 +1 @@ +JsDoc Reference - $_.template
 
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)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, 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 $_.template

Defined in: template.js.

Method Summary
get(string)Retrieves a template
parse(string, object)Formats a template
apply(string, string, object)Inserts the formatted template into the page.
Method Detail
$_.template.get(string): string
Retrieves a template
Parameters:
string name
Returns:
string
$_.template.parse(string, object): string
Formats a template
Parameters:
string template_name
object replace_data
Returns:
string
$_.template.apply(string, string, object)
Inserts the formatted template into the page. If the url and data parameters are passed, it will retrieve a template file from the same domain, parse, and insert the template into the page.
Parameters:
string parsed_template/template_name
string?, Default: url
object?, Default: data
\ No newline at end of file diff --git a/docs/symbols/$_.util.html b/docs/symbols/$_.util.html index c82a60a..9f1d6a6 100644 --- 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)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
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 +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)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, 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 diff --git a/docs/symbols/_global_.html b/docs/symbols/_global_.html index ce73b8f..8d84853 100644 --- 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)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, function)
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 +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)
html(string)
add(string, function)
remove(string, string)
live(string, string, function)
delegate(string, string, 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 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 d436cf4..89c3a91 100644 --- a/docs/symbols/src/kis-js_src_modules_DOM.js.html +++ b/docs/symbols/src/kis-js_src_modules_DOM.js.html @@ -16,7 +16,7 @@ 9 10 var d; 11 - 12 //Private function for getting/setting attributes + 12 //Private function for getting/setting attributes/properties 13 function _attr(sel, name, value) 14 { 15 var oldVal, doAttr; diff --git a/docs/symbols/src/kis-js_src_modules_template.js.html b/docs/symbols/src/kis-js_src_modules_template.js.html new file mode 100644 index 0000000..6a808f8 --- /dev/null +++ b/docs/symbols/src/kis-js_src_modules_template.js.html @@ -0,0 +1,240 @@ +
  1 /** 
+  2  * Template module for simple javascript templating
+  3  */
+  4 (function(){
+  5 	"use strict";
+  6 	
+  7 	//This module relies on some others for simplicity
+  8 	//so, if they aren't there, don't initialize the module
+  9 	if($_.ajax === "undefined")
+ 10 	{
+ 11 		return;
+ 12 	}
+ 13 	
+ 14 	var t, _t, _p;
+ 15 	
+ 16 	
+ 17 	//Private object to store retrieved templates
+ 18 	_t = {};
+ 19 	
+ 20 	//Private object to store parsed templates
+ 21 	_p = {};
+ 22 	
+ 23 	
+ 24 	/**
+ 25 	 * Module for html templating. Requires ajax module.
+ 26 	 * 
+ 27 	 * @name template
+ 28 	 * @namespace
+ 29 	 * @memberOf $_
+ 30 	 */
+ 31 	t = {
+ 32 		/**
+ 33 		 * Retrieves a template
+ 34 		 * 
+ 35 		 * @memberOf $_.template
+ 36 		 * @name get
+ 37 		 * @param string name
+ 38 		 * @return string
+ 39 		 * @function
+ 40 		 * @type string
+ 41 		 */
+ 42 		get: function(name)
+ 43 		{
+ 44 			var res;
+ 45 
+ 46 			res = this.el.innerHTML;
+ 47 			
+ 48 			if(res === "")
+ 49 			{
+ 50 				console.log("Template is empty or cannot be found");
+ 51 				return;
+ 52 			}
+ 53 			
+ 54 			_t[name] = res;
+ 55 			return res;
+ 56 		},
+ 57 		/**
+ 58 		 * Formats a template
+ 59 		 * 
+ 60 		 * @memberOf $_.template
+ 61 		 * @name parse
+ 62 		 * @param string template_name
+ 63 		 * @param object replace_data
+ 64 		 * @return string
+ 65 		 * @function
+ 66 		 * @type string
+ 67 		 */
+ 68 		parse: function(name, data)
+ 69 		{
+ 70 			var tmp = _t[name],
+ 71 				pairs = [],
+ 72 				pseudos = [], 
+ 73 				num_pairs = 0,
+ 74 				num_pseudos = 0,
+ 75 				i = 0,
+ 76 				j = 0,
+ 77 				var_name = '',
+ 78 				rep_data = {},
+ 79 				tmp_data = '',
+ 80 				data_len,
+ 81 				frag,
+ 82 				frag_section,
+ 83 				emptys,
+ 84 				x;
+ 85 				
+ 86 			tmp = String(tmp);
+ 87 		
+ 88 			//Remove newlines and tabs from template because
+ 89 			//those whitespace characters are extra bandwidth
+ 90 			tmp = tmp.replace(/\s+/gim, " ");
+ 91 			tmp = tmp.replace(/>\s+</gim, "><");
+ 92 			tmp = tmp.replace(/>\s+\{/gim, ">{");
+ 93 			tmp = tmp.replace(/\}\s+</gim, "}<");
+ 94 			
+ 95 			//Match all the looped sections of content
+ 96 			pairs = tmp.match(/\{([A-Z0-9_\-]+)\}(.*)\{\/\1\}/gim);
+ 97 			
+ 98 			if(pairs != null)
+ 99 			{
+100 				num_pairs = pairs.length;
+101 				
+102 				//Go through the template, and match the pairs
+103 				for(i=0;i<num_pairs;i++)
+104 				{
+105 					//Put the loop in a placeholder
+106 					tmp = tmp.replace(pairs[i], "{"+i+"}");
+107 					
+108 					//Create a place to store looped data
+109 					tmp_data = "";
+110 					
+111 					//The replace variable is the name of the tag
+112 					var_name = String(pairs[i]).match(/^\{([A-Z0-9_\-]+)\}/i);
+113 					rep_data = data[var_name[1]];
+114 					
+115 					//Make sure there are loops
+116 					if(rep_data.length > 0)
+117 					{
+118 						data_len = rep_data.length;
+119 						
+120 						//Get rid of the loop tags
+121 						pairs[i] = pairs[i].replace(/\{([A-Z0-9_\-]+)\}(.*)\{\/\1\}/gim, "$2");
+122 						
+123 						//Replace psudovariables with data
+124 						for(j=0;j<data_len;j++)
+125 						{
+126 							//Is there a better way to do this, rather than an inline function?
+127 							tmp_data += pairs[i].replace(/\{([A-Z0-9 _\-]+)\}/gi, function(_, varName){
+128 								return (rep_data[j][varName]) ? rep_data[j][varName] : ""; 
+129 							});
+130 						}
+131 					}
+132 					
+133 					//Replace the looped content
+134 					tmp = tmp.replace("{"+i+"}", tmp_data);
+135 				}
+136 			}
+137 			
+138 			//Replace all the rest of the psudeovariables
+139 			pseudos = tmp.match(/\{([A-Z0-9_\-]+)\}/gim);
+140 			
+141 			if(pseudos != null)
+142 			{
+143 				num_pseudos = pseudos.length;
+144 			
+145 				for(i=0;i<num_pseudos;i++)
+146 				{
+147 					//Remove the {} from the pseudos
+148 					var_name = pseudos[i].replace('{', '');
+149 					var_name = var_name.replace('}', '');
+150 					
+151 					//Replace each pseudovariable with the value of the object
+152 					//property of the same name
+153 					tmp = tmp.replace(pseudos[i], data[var_name]);
+154 				}
+155 			}
+156 			
+157 			//Create an empty fragement
+158 			frag = document.createDocumentFragment();
+159 			
+160 			//Insert the html
+161 			frag.appendChild(document.createElement('section'));
+162 			frag_section = frag.querySelectorAll('section')[0];
+163 			frag_section.innerHTML = tmp;
+164 			
+165 			//Remove bad elements in the fragment, should be faster than being done live
+166 			emptys = frag_section.querySelectorAll('[src=""], [href=""]');
+167 			
+168 			for(x in emptys)
+169 			{
+170 				if(emptys[x].parentNode)
+171 				{
+172 					emptys[x].parentNode.removeChild(emptys[x]);
+173 				}
+174 			}
+175 			
+176 			//Save the parsed template in an object for later retrieval
+177 			_p[name] = tmp;
+178 			
+179 			return tmp;
+180 		},
+181 		/** 
+182 		 * Inserts the formatted template into the page. If the url and data parameters
+183 		 * are passed, it will retrieve a template file from the same domain, parse, 
+184 		 * and insert the template into the page. 
+185 		 *
+186 		 * @memberOf $_.template
+187 		 * @name apply
+188 		 * @function
+189 		 * @param string parsed_template/template_name
+190 		 * @param [string] url
+191 		 * @param [object] data
+192 		 */
+193 		apply: function(name, url, data)
+194 		{
+195 			//If the parsed template is supplied, just apply it to the passed selector
+196 			if(typeof url === "undefined" && typeof data === "undefined")
+197 			{
+198 				//If the "name" variable is in the _p object, set that
+199 				if(typeof _p[name] !== "undefined")
+200 				{
+201 					this.el.innerHTML = _p[name];
+202 					return;
+203 				}
+204 			
+205 				//Otherwise, set the passed string to the current selector
+206 				this.el.innerHTML = name;
+207 				return;
+208 			}
+209 			
+210 			//Otherwise, get the template, parse it, and apply it
+211 			$_.get(url, {}, function(res){
+212 				var parsed;
+213 			
+214 				if(res === "")
+215 				{
+216 					console.log("Template is empty or can not be found");
+217 					return;
+218 				}
+219 				
+220 				//Cache the template in an object for later use
+221 				_t[name] = res;
+222 				parsed = this.parse(name, data);
+223 				_p[name] = parsed;
+224 				
+225 				this.el.innerHTML = parsed;
+226 			});
+227 		}
+228 	};
+229 	
+230 	//Add the module to the library
+231 	$_.ext('template', t);
+232 	
+233 })();
\ No newline at end of file diff --git a/kis-all.js b/kis-all.js index 0545bf7..2f6da00 100644 --- a/kis-all.js +++ b/kis-all.js @@ -445,7 +445,7 @@ var d; - //Private function for getting/setting attributes + //Private function for getting/setting attributes/properties function _attr(sel, name, value) { var oldVal, doAttr; @@ -1623,3 +1623,239 @@ $_.ext('event', e); }()); + +// -------------------------------------------------------------------------- + +/** + * 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 = [], + 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(/\{([A-Z0-9_\-]+)\}(.*)\{\/\1\}/gim, "$2"); + + //Replace psudovariables with data + for(j=0;j1&&typeof a==="undefined")console.log(c),console.log("Must be a singular element");else if(c.length>1&&typeof a!== -"undefined")$_.each(function(c){return f(c,b,a)});else return f(c,b,a)},text:function(b){var a,c,e;e=this.el;c=typeof e.innerText!=="undefined"?"innerText":typeof e.textContent!=="undefined"?"textContent":"innerHTML";a=e[c];return typeof b!=="undefined"?e[c]=b:a},css:function(b,a){if(typeof a==="undefined")return d(this.el,b);$_.each(function(c){d(c,b,a)})},html:function(b){if(typeof b!=="undefined")this.el.innerHTML=b;return this.el.innerHTML}})})(); -(function(){if(!(typeof localStorage==="undefined"||typeof JSON==="undefined")){var f=localStorage,g=sessionStorage;$_.ext("store",{get:function(d,b){var a=b?g.getItem(d):f.getItem(d);return JSON.parse(a)},set:function(d,b,a){b=JSON.stringify(b);a?g.setItem(d,b):f.setItem(d,b)},remove:function(d,b){b?g.removeItem(d):f.removeItem(d)},getAll:function(d){var b,a={},c,e;e=d?f:g;b=e.length;for(d=0;de?1:ba?1:c1&&typeof a==="undefined")console.log(b),console.log("Must be a singular element");else if(b.length>1&&typeof a!== +"undefined")$_.each(function(b){return g(b,c,a)});else return g(b,c,a)},text:function(c){var a,b,e;e=this.el;b=typeof e.innerText!=="undefined"?"innerText":typeof e.textContent!=="undefined"?"textContent":"innerHTML";a=e[b];return typeof c!=="undefined"?e[b]=c:a},css:function(c,a){if(typeof a==="undefined")return d(this.el,c);$_.each(function(b){d(b,c,a)})},html:function(c){if(typeof c!=="undefined")this.el.innerHTML=c;return this.el.innerHTML}})})(); +(function(){if(!(typeof localStorage==="undefined"||typeof JSON==="undefined")){var g=localStorage,h=sessionStorage;$_.ext("store",{get:function(d,c){var a=c?h.getItem(d):g.getItem(d);return JSON.parse(a)},set:function(d,c,a){c=JSON.stringify(c);a?h.setItem(d,c):g.setItem(d,c)},remove:function(d,c){c?h.removeItem(d):g.removeItem(d)},getAll:function(d){var c,a={},b,e;e=d?g:h;c=e.length;for(d=0;de?1:ca?1:b\s+<"),a=a.replace(/>\s+\{/gim,">{"),a=a.replace(/\}\s+0){i=j.length;b[f]=b[f].replace(/\{([A-Z0-9_\-]+)\}(.*)\{\/\1\}/gim,"$2");for(k=0;k\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(/\{([A-Z0-9_\-]+)\}(.*)\{\/\1\}/gim, "$2"); + + //Replace psudovariables with data + for(j=0;j