diff --git a/.gitignore b/.gitignore index bc88642..476d211 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ kis-custom.js kis-custom-min.js combine-build.php test.html -.* \ No newline at end of file +config.json +docs.conf +.* diff --git a/README.md b/README.md index 499c6d0..d08c4a0 100755 --- a/README.md +++ b/README.md @@ -25,31 +25,28 @@ Browser support: IE10+, Latest versions of Firefox, Chrome, Safari, Opera * each: For applying changes to every item matched by a selector - $_(selector).each(callback); + $_(selector).each(callback); Example : - $_(".foo").each(function(e){ + $_(".foo").each(function(e){ $_(e).dom.text(value); }): * ext: For extending the library, adds this.el to the object or function supplied - - $_.ext("name", functionOrObject); - + $_.ext("name", functionOrObject); Example: - $_.ext("zip", function(){ //function }); - Adds 'zip' function to $_. + $_.ext("zip", function(){ ... }); // Adds 'zip' function to $_. * type: For getting the type of a variable $_.type(var); -Have a look at the /docs folder included with the library for documentation on the included modules. The development version of the documentation is avaliable at +Have a look at the right sidebar of the docs included with the library for documentation on the included modules. The development version of the documentation is avaliable at [http://github.timshomepage.net/kis-js/docs/](http://github.timshomepage.net/kis-js/docs/) diff --git a/docs/$_.dom.html b/docs/$_.dom.html index 21888a3..fc12ad9 100644 --- a/docs/$_.dom.html +++ b/docs/$_.dom.html @@ -313,7 +313,7 @@ selector
Source:
@@ -340,7 +340,7 @@ selector
Example
-
$_("ul").dom.append("<li></li>") adds an li element to the end of the selected ul element
+
$_("ul").dom.append("<li></li>"); // Adds an li element to the end of the selected ul element
@@ -720,6 +720,13 @@ multiple key/value pairs. +
Examples
+ +
$_('#foo').dom.css('border', 0);
+ +
$_('#foo').dom.css({background:'#000', color:'#fff'});
+ + @@ -899,7 +906,7 @@ multiple key/value pairs.
Source:
@@ -1036,7 +1043,7 @@ multiple key/value pairs.
Source:
@@ -1061,6 +1068,11 @@ multiple key/value pairs. +
Example
+ +
$_("ul").dom.append("<li></li>"); // Adds an li element to the beginning of the selected ul element
+ + @@ -1493,7 +1505,7 @@ otherwise it will return the value of the current element
diff --git a/docs/$_.event.html b/docs/$_.event.html index 5f298e9..100a1ac 100644 --- a/docs/$_.event.html +++ b/docs/$_.event.html @@ -242,7 +242,7 @@ event and selector
Example
-
Eg. $_("#selector").event.add("click", do_something());
+
$_("#selector").event.add("click", do_something());
@@ -427,7 +427,7 @@ event and selector
Example
-
Eg. var event = $_("#selector").event.create('foo', {});
+
var event = $_("#selector").event.create('foo', {});
@@ -597,7 +597,7 @@ event and selector
Example
-
Eg. $_("#parent").delegate(".button", "click", do_something());
+
$_("#parent").delegate(".button", "click", do_something());
@@ -767,7 +767,7 @@ event and selector
Example
-
Eg. $_.event.live(".button", "click", do_something());
+
$_.event.live(".button", "click", do_something());
@@ -914,7 +914,7 @@ event and selector
Example
-
Eg. $_("#selector").event.remove("click", do_something());
+
$_("#selector").event.remove("click", do_something());
@@ -1056,7 +1056,7 @@ event and selector
Example
-
Eg. $_("#my_id").trigger('click');
+
$_("#my_id").trigger('click');
@@ -1083,7 +1083,7 @@ event and selector
diff --git a/docs/$_.html b/docs/$_.html index 7a2fd1d..90cc87d 100644 --- a/docs/$_.html +++ b/docs/$_.html @@ -66,7 +66,7 @@ Constructor function
Source:
@@ -108,6 +108,66 @@ Constructor function +

Members

+ +
+ +
+

(static) el

+ + +
+
+ +
+ Current selector object +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + +
+ +
+

Methods

@@ -247,7 +307,7 @@ Constructor function
Source:
@@ -290,6 +350,230 @@ Constructor function + + + + +
+

(static) delete(url, data, success_callback, error_callbackopt)

+ + +
+
+ + +
+ Sends a DELETE type ajax request +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
url + + +string + + + + + + + + + + The url to post to
data + + +Object + + + + + + + + + + delete parameters to send
success_callback + + +function + + + + + + + + + + callback called on success
error_callback + + +function + + + + + + <optional>
+ + + + + +
callback called if there is an error
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + +
@@ -384,7 +668,7 @@ Constructor function
Source:
@@ -409,6 +693,158 @@ Constructor function +
Example
+ +
$_('form input').each(function(item) { alert(item) });
+ + + + + + +
+

(static) ext(name, obj)

+ + +
+
+ + +
+ Adds the property `obj` to the $_ object, calling it `name` +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + name of the module
obj + + +object + + + + the object to add
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Example
+ +
$_.ext('foo', {});
+ +
@@ -608,7 +1044,7 @@ Constructor function
Source:
@@ -832,7 +1268,7 @@ Constructor function
Source:
@@ -857,6 +1293,372 @@ Constructor function + + + + +
+

(static) put(url, data, success_callback, error_callbackopt)

+ + +
+
+ + +
+ Sends a PUT type ajax request +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
url + + +string + + + + + + + + + + The url to post to
data + + +Object + + + + + + + + + + PUT parameters to send
success_callback + + +function + + + + + + + + + + callback called on success
error_callback + + +function + + + + + + <optional>
+ + + + + +
callback called if there is an error
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+

(static) type(obj) → {string}

+ + +
+
+ + +
+ Retrieves the type of the passed variable +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
obj + + +* + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +string + + +
+
+ + + + +
Example
+ +
$_.type([]); // Returns 'array'
+ +
@@ -881,7 +1683,7 @@ Constructor function
diff --git a/docs/$_.store.html b/docs/$_.store.html index f31f2a5..992ae4d 100644 --- a/docs/$_.store.html +++ b/docs/$_.store.html @@ -848,7 +848,7 @@ and JSON-encodes the value if not a string
diff --git a/docs/DOM.js.html b/docs/DOM.js.html index 6c1548d..9ffab0a 100644 --- a/docs/DOM.js.html +++ b/docs/DOM.js.html @@ -250,6 +250,8 @@ * Accepts either key/value arguments, or an object with * multiple key/value pairs. * + * @example $_('#foo').dom.css('border', 0); + * @example $_('#foo').dom.css({background:'#000', color:'#fff'}); * @name css * @memberOf $_.dom * @function @@ -283,7 +285,7 @@ /** * Adds to the innerHTML of the current element, after the last child. * - * @example $_("ul").dom.append("&lt;li&gt;&lt;/li&gt;") adds an li element to the end of the selected ul element + * @example $_("ul").dom.append("<li></li>"); // Adds an li element to the end of the selected ul element * @name append * @memberOf $_.dom * @function @@ -296,6 +298,7 @@ /** * Adds to the innerHTML of the selected element, before the current children * + * @example $_("ul").dom.append("<li></li>"); // Adds an li element to the beginning of the selected ul element * @name prepend * @memberOf $_.dom * @function @@ -345,7 +348,7 @@
diff --git a/docs/ajax.js.html b/docs/ajax.js.html index 0a305b3..59dd5a0 100644 --- a/docs/ajax.js.html +++ b/docs/ajax.js.html @@ -35,7 +35,7 @@ "use strict"; var ajax = { - _do: function (url, data, success_callback, error_callback, isPost) + _do: function (url, data, success_callback, error_callback, type) { var type, request = new XMLHttpRequest(); @@ -48,8 +48,6 @@ success_callback = function (){}; } - type = (isPost) ? "POST" : "GET"; - if (type === "GET") { url += (url.match(/\?/)) @@ -78,7 +76,7 @@ } }; - if (type === "POST") + if (type !== "GET") { request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); request.send(this._serialize(data)); @@ -123,8 +121,7 @@ /** * Sends a GET type ajax request * - * @name get - * @function + * @function get * @memberOf $_ * @param {string} url - The url to retrieve * @param {Object} data - get parameters to send @@ -132,14 +129,13 @@ * @param {function} [error_callback] - callback called if there is an error */ $_.ext('get', function (url, data, success_callback, error_callback){ - ajax._do(url, data, success_callback, error_callback, false); + ajax._do(url, data, success_callback, error_callback, 'GET'); }); /** * Sends a POST type ajax request * - * @name post - * @function + * @function post * @memberOf $_ * @param {string} url - The url to post to * @param {Object} data - post parameters to send @@ -147,7 +143,35 @@ * @param {function} [error_callback] - callback called if there is an error */ $_.ext('post', function (url, data, success_callback, error_callback){ - ajax._do(url, data, success_callback, error_callback, true); + ajax._do(url, data, success_callback, error_callback, 'POST'); + }); + + /** + * Sends a PUT type ajax request + * + * @function put + * @memberOf $_ + * @param {string} url - The url to post to + * @param {Object} data - PUT parameters to send + * @param {function} success_callback - callback called on success + * @param {function} [error_callback] - callback called if there is an error + */ + $_.ext('put', function (url, data, success_callback, error_callback){ + ajax._do(url, data, success_callback, error_callback, 'PUT'); + }); + + /** + * Sends a DELETE type ajax request + * + * @function delete + * @memberOf $_ + * @param {string} url - The url to post to + * @param {Object} data - delete parameters to send + * @param {function} success_callback - callback called on success + * @param {function} [error_callback] - callback called if there is an error + */ + $_.ext('delete', function (url, data, success_callback, error_callback){ + ajax._do(url, data, success_callback, error_callback, 'DELETE'); }); }()); @@ -166,7 +190,7 @@
diff --git a/docs/core.js.html b/docs/core.js.html index 6b45804..a4e13ae 100644 --- a/docs/core.js.html +++ b/docs/core.js.html @@ -29,13 +29,19 @@ Kis JS Keep It Simple JS Library Copyright Timothy J. Warren License Public Domain - Version 0.8.0 + Version 0.9.0 */ (function (undefined){ "use strict"; - var $_, $, sel; + /** + * Current selector object + * + * @memberOf $_ + * @name el + */ + var sel; /** @@ -49,7 +55,7 @@ * @param {Object} [context] - Context of the dom selector string * @return {Object} */ - $_ = function(s, context) + var $_ = function(s, context) { // Have documentElement be default selector, just in case if (s === undefined) @@ -92,7 +98,7 @@ * @param {Object} [context] * @return {Object} */ - $ = function (selector, context) + var $ = function (selector, context) { var elements; @@ -120,6 +126,9 @@ /** * Adds the property `obj` to the $_ object, calling it `name` * + * @memberOf $_ + * @function ext + * @example $_.ext('foo', {}); * @param {string} name - name of the module * @param {object} obj - the object to add */ @@ -132,11 +141,12 @@ /** * Iterates over a $_ object, applying a callback to each item * - * @name $_.each - * @function + * @memberOf $_ + * @function each + * @example $_('form input').each(function(item) { alert(item) }); * @param {function} callback - iteration callback */ - $_.ext('each', function (callback) + $_.ext('each', function(callback) { if(sel.length !== undefined && sel !== window) { @@ -151,10 +161,13 @@ /** * Retrieves the type of the passed variable * + * @memberOf $_ + * @function type + * @example $_.type([]); // Returns 'array' * @param {*} obj * @return {string} */ - $_.type = function(obj) + var type = function(obj) { if((function() {return obj && (obj !== this)}).call(obj)) { @@ -169,8 +182,8 @@ //Set global variables $_ = window.$_ = window.$_ || $_; $_.$ = $; -}()); - + $_.type = type; +}()); @@ -186,7 +199,7 @@
diff --git a/docs/event.js.html b/docs/event.js.html index 30c5d82..58c48cb 100644 --- a/docs/event.js.html +++ b/docs/event.js.html @@ -105,7 +105,7 @@ * @memberOf $_.event * @name create * @function - * @example Eg. var event = $_("#selector").event.create('foo', {}); + * @example var event = $_("#selector").event.create('foo', {}); * @param {string} name * @param {object} [data] * @return {Object} @@ -113,12 +113,12 @@ create: function(name, data) { data = data || {}; - - // Okay, I guess we have to do this the hard way... :( - var e = document.createEvent('CustomEvent'); - e.initCustomEvent(name, true, true, data); - return e; + // Okay, I guess we have to do this the hard way... :( + var e = document.createEvent('CustomEvent'); + e.initCustomEvent(name, true, true, data); + + return e; }, /** * Adds an event that returns a callback when triggered on the selected @@ -127,7 +127,7 @@ * @memberOf $_.event * @name add * @function - * @example Eg. $_("#selector").event.add("click", do_something()); + * @example $_("#selector").event.add("click", do_something()); * @param {string} event * @param {function} callback */ @@ -143,7 +143,7 @@ * @memberOf $_.event * @name remove * @function - * @example Eg. $_("#selector").event.remove("click", do_something()); + * @example $_("#selector").event.remove("click", do_something()); * @param {string} event * @param {string} callback */ @@ -159,7 +159,7 @@ * @memberOf $_.event * @name live * @function - * @example Eg. $_.event.live(".button", "click", do_something()); + * @example $_.event.live(".button", "click", do_something()); * @param {string} target * @param {string} event * @param {function} callback @@ -174,7 +174,7 @@ * @memberOf $_.event * @name delegate * @function - * @example Eg. $_("#parent").delegate(".button", "click", do_something()); + * @example $_("#parent").delegate(".button", "click", do_something()); * @param {string} target * @param {string} event * @param {function} callback @@ -191,14 +191,13 @@ * @memberOf $_.event * @name trigger * @function - * @example Eg. $_("#my_id").trigger('click'); + * @example $_("#my_id").trigger('click'); * @param {object} event * @return {boolean} */ trigger: function(event) { - var target = this.el; - return target.dispatchEvent(event); + return this.el.dispatchEvent(event); } }; @@ -220,7 +219,7 @@
diff --git a/docs/global.html b/docs/global.html index 54090dc..3702bb5 100644 --- a/docs/global.html +++ b/docs/global.html @@ -81,6 +81,8 @@ + + @@ -89,20 +91,30 @@
-

data[undefined]

+

el :Object

- Ajax + $_ -Module for making ajax requests +Constructor function
+
Type:
+ +
@@ -127,7 +139,7 @@ Module for making ajax requests
Source:
@@ -162,13 +174,13 @@ Module for making ajax requests
- Documentation generated by JSDoc 3.3.0-alpha5 on Wed Sep 10 2014 00:23:43 GMT-0400 (EDT) + Documentation generated by JSDoc 3.3.0-alpha9 on Tue Sep 16 2014 15:49:39 GMT-0400 (EDT)
diff --git a/docs/index.html b/docs/index.html index 69f35f9..883dbb0 100644 --- a/docs/index.html +++ b/docs/index.html @@ -40,96 +40,48 @@ +
+

Keep It Simple JS Library

A Minimal, Modular Javascript library for Modern browsers.

+

Aims to be fast, small, and easily split into individual modules.

+

You can create your own library by adding and removing modules from the +src directory, and running the "combine.php" script. This will output a +"kis-custom.js" file. (Be careful, as the script will overwrite any "kis-custom.js" +file that already exists).

+

Browser support: IE10+, Latest versions of Firefox, Chrome, Safari, Opera

+

Basic Use:

    +
  • Function: $_(selector).module.function(params);
  • +
+

Core Methods

properties:

+
    +
  • el: The html object returned by the selector function.
  • +
+

functions:

+
    +
  • each: For applying changes to every item matched by a selector

    +

    $_(selector).each(callback);

    +

    Example :

    +
      $_(".foo").each(function(e){
    +      $_(e).dom.text(value);
    +  }):
  • +
  • ext: For extending the library, adds this.el to the object or function supplied

    +

    $_.ext("name", functionOrObject);

    +

    Example:

    +
      $_.ext("zip", function(){ ... }); // Adds 'zip' function to $_.
  • +
  • type: For getting the type of a variable

    +
      $_.type(var);
  • +
+

Have a look at the right sidebar of the docs included with the library for documentation on the included modules. The development version of the documentation is avaliable at

+

http://github.timshomepage.net/kis-js/docs/

+

Lite Versions

There are two lite versions:

+
1. Lite - Includes only the ajax and events modules
+2. Lite-dom - Includes ajax, events, and dom modules
+
- -
- -
-

- polyfill.js -

- -
- -
-
- - - - -
polyfill.js
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - -
- -
- - - -