From db76e163939f788eedf23af39b18660bd0159e61 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 20 Oct 2011 17:31:29 -0400 Subject: [PATCH] Added start of util module, removed ..dom.children function --- README.md | 12 ++++++ kis-all.js | 113 +++++++++++++++++++++---------------------------- kis-min.js | 35 ++++++++------- src/DOM.js | 63 --------------------------- src/core.js | 7 ++- src/util.js | 40 +++++++++++++++++ tests/tests.js | 10 ++++- 7 files changed, 130 insertions(+), 150 deletions(-) create mode 100644 src/util.js diff --git a/README.md b/README.md index 1dae13c..d7be222 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,18 @@ functions: Set: $_(selector).dom.css(property, value); Get: $_(selector).dom.css(property); + +### Util: Array and string manipulation functions ### + +** functions:** + +* object_keys: Gets the name of the properties of an object + + $_.util.object_keys(object); + +* object_values: Gets the values of the top-level members of an object + + $_.util.object_values(object); diff --git a/kis-all.js b/kis-all.js index d037f03..d0fb1c0 100644 --- a/kis-all.js +++ b/kis-all.js @@ -27,11 +27,11 @@ if (typeof a !== "string" || typeof a === "undefined"){ return a;} //Pick the quickest method for each kind of selector - if(a.match(/^#([\w\-]+$)/)) + if (a.match(/^#([\w\-]+$)/)) { return document.getElementById(a.split('#')[1]); } - else if(a.match(/^([\w\-]+)$/)) + else if (a.match(/^([\w\-]+)$/)) { x = document.getElementsByTagName(a); } @@ -62,6 +62,9 @@ { sel = (typeof s !== "object") ? $(s) : s; } + + // Add the selector to the prototype + $_.prototype.el = sel; // Make a copy before adding properties var self = dcopy($_); @@ -478,45 +481,6 @@ console.log("Property " + prop + " nor an equivalent seems to exist"); } - function _sel_filter(filter, curr_sel) - { - var i, - len = curr_sel.length, - matches = []; - - //Filter by tag - if(filter.match(tag_reg)) - { - for(i=0;i1&&typeof b==="undefined")console.log(a),console.log("Must be a singular element");else if(a.length> -1&&typeof b!=="undefined")e.each(function(a){return c(a,d,b)});else return c(a,d,b)},text:function(d){var b,a,c;c=this.el;a=typeof c.innerText!=="undefined"?"innerText":typeof c.textContent!=="undefined"?"textContent":"innerHTML";b=c[a];return typeof d!=="undefined"?c[a]=d:b},css:function(d,b){if(typeof b==="undefined")return f(this.el,d);e.each(function(a){f(a,d,b)})},children:function(d){if(typeof d==="undefined")return e(this.el.children);var b=typeof this.el.children!=="undefined"?this.el.children: -this.el;if(e.type(d)!=="string")return e(d);else if(d.match(/#([\w\-]+$)/))return e(e.$(d));else{var c,f=b.length,g=[];if(d.match(a))for(c=0;c1?c[1]:"";else if(c===false||c===void 0)c=window.location.search.substring(1);else return false; -g=c.split("&");f=g.length;for(c=0;c1&&typeof b==="undefined")console.log(e),console.log("Must be a singular element");else if(e.length>1&&typeof b!=="undefined")g.each(function(e){return c(e, +a,b)});else return c(e,a,b)},text:function(a){var b,e,h;h=this.el;e=typeof h.innerText!=="undefined"?"innerText":typeof h.textContent!=="undefined"?"textContent":"innerHTML";b=h[e];return typeof a!=="undefined"?h[e]=a:b},css:function(a,b){if(typeof b==="undefined")return d(this.el,a);g.each(function(e){d(e,a,b)})}})})();(function(){g.ext("store",{get:function(c){return JSON.parse(localStorage.getItem(c))},set:function(c,f){typeof f!=="string"&&(f=JSON.stringify(f));localStorage.setItem(c,f)},remove:function(c){localStorage.removeItem(c)}, +getAll:function(){var c,f,d;f=localStorage.length;d={};for(c=0;c1?c[1]:"";else if(c===false||c===void 0)c=window.location.search.substring(1);else return false;f=c.split("&");d=f.length;for(c=0;c