From 1a8addc49ccd3196bd1be712fc5433648d631a92 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 8 Feb 2012 11:54:46 -0500 Subject: [PATCH] Fixed broken tests --- .../src/kis-js_src_modules_indexedDB.js.html | 112 +- kis-all.js | 1302 +++++++++-------- kis-min.js | 15 +- src/modules/indexedDB.js | 44 +- tests/index.html | 2 +- tests/qunit/qunit.css | 2 +- tests/qunit/qunit.js | 17 +- 7 files changed, 756 insertions(+), 738 deletions(-) diff --git a/docs/symbols/src/kis-js_src_modules_indexedDB.js.html b/docs/symbols/src/kis-js_src_modules_indexedDB.js.html index 7f81b6d..a92da9e 100644 --- a/docs/symbols/src/kis-js_src_modules_indexedDB.js.html +++ b/docs/symbols/src/kis-js_src_modules_indexedDB.js.html @@ -12,59 +12,61 @@ 5 "use strict"; 6 7 var db = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || window.msIndexedDB, - 8 request = null; - 9 indexedDB = {}; - 10 - 11 /** - 12 * @private - 13 */ - 14 request.onerror = function(event) - 15 { - 16 console.log("IndexedDB disallowed."); - 17 }; - 18 - 19 /** - 20 * @private - 21 */ - 22 request.onsuccess = function(event) - 23 { - 24 // Connect to the specified db - 25 indexedDB.current_db = request.result; - 26 }; - 27 - 28 /** - 29 * Module for simplifying Indexed DB access - 30 * - 31 * @namespace - 32 * @name indexedDB - 33 * @memberOf $_ - 34 */ - 35 indexedDB = { - 36 current_db: null, - 37 /** - 38 * Connects to an indexedDB database - 39 * - 40 * @memberOf $_.indexedDB - 41 * @name connect - 42 * @function - 43 * @param string dbname - 44 * @param [int] version - 45 * @param [function] onupgradeneeded - 46 */ - 47 connect: function(dbname, version, onupgradeneeded) - 48 { - 49 version = version || 0; - 50 - 51 if(typeof onupgradeneeded !== "undefined") - 52 { - 53 request.onupgradeneeded = onupgradeneeded; - 54 } - 55 - 56 // Ask for permission to use db - 57 this.current_db = db.open(dbname, version); - 58 } - 59 }; - 60 - 61 $_.ext('indexedDB', indexedDB); + 8 indexedDB = {}; + 9 + 10 /** + 11 * Module for simplifying Indexed DB access + 12 * + 13 * @namespace + 14 * @name indexedDB + 15 * @memberOf $_ + 16 */ + 17 indexedDB = { + 18 current_db: null, + 19 /** + 20 * Connects to an indexedDB database + 21 * + 22 * @memberOf $_.indexedDB + 23 * @name connect + 24 * @function + 25 * @param string dbname + 26 * @param [int] version + 27 * @param [function] onupgradeneeded + 28 */ + 29 connect: function(dbname, version, onupgradeneeded) + 30 { + 31 var request = {}; + 32 + 33 version = version || 0; + 34 + 35 // Ask for permission to use db + 36 request = db.open(dbname, version); + 37 + 38 // Assign onupgradeneeded callback + 39 if(typeof onupgradeneeded !== "undefined") + 40 { + 41 request.onupgradeneeded = onupgradeneeded; + 42 } + 43 + 44 /** + 45 * @private + 46 */ + 47 request.onerror = function(event) + 48 { + 49 console.log("IndexedDB disallowed."); + 50 }; + 51 + 52 /** + 53 * @private + 54 */ + 55 request.onsuccess = function(event) + 56 { + 57 // Connect to the specified db + 58 indexedDB.current_db = request.result; + 59 }; + 60 } + 61 }; 62 - 63 }()); \ No newline at end of file + 63 $_.ext('indexedDB', indexedDB); + 64 + 65 }()); \ No newline at end of file diff --git a/kis-all.js b/kis-all.js index 1177a4c..d03be6e 100755 --- a/kis-all.js +++ b/kis-all.js @@ -804,6 +804,446 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" // -------------------------------------------------------------------------- +/** + * Ajax + * + * Module for making ajax requests + */ +(function (){ + + "use strict"; + + // Don't bother even defining the object if the XMLHttpRequest isn't available + if(typeof window.XMLHttpRequest === "undefined") + { + return; + } + + var ajax = { + _do: function (url, data, callback, isPost) + { + var type, + request = new XMLHttpRequest(); + + if (typeof callback === "undefined") + { + /** + * @private + */ + callback = function (){}; + } + + type = (isPost) ? "POST" : "GET"; + + url += (type === "GET") ? "?"+this._serialize(data) : ''; + + request.open(type, url); + + request.onreadystatechange = function () + { + if (request.readyState === 4) + { + callback(request.responseText); + } + }; + + if (type === "POST") + { + request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + request.send(this._serialize(data)); + } + else + { + request.send(null); + } + }, + _serialize: function (data) + { + var name, + value, + pairs = []; + + for (name in data) + { + if (!data.hasOwnProperty(name)) + { + continue; + } + if (typeof data[name] === "function") + { + continue; + } + + value = data[name].toString(); + + name = encodeURIComponent(name); + value = encodeURIComponent(value); + + pairs.push(name + "=" + value); + } + + return pairs.join("&"); + } + }; + + /** + * Sends a GET type ajax request + * + * @name get + * @function + * @memberOf $_ + * @param string url + * @param object data + * @param function callback + */ + $_.ext('get', function (url, data, callback){ + ajax._do(url, data, callback, false); + }); + + /** + * Sends a POST type ajax request + * + * @name post + * @function + * @memberOf $_ + * @param string url + * @param object data + * @param function callback + */ + $_.ext('post', function (url, data, callback){ + ajax._do(url, data, callback, true); + }); +}()); + +// -------------------------------------------------------------------------- + +/** + * Event + * + * Event api wrapper + */ +(function (){ + + "use strict"; + + // Property name for expandos on DOM objects + var kis_expando = "KIS_0_5_0"; + + var _attach, _remove, _add_remove, e, _attach_delegate; + + // Define the proper _attach and _remove functions + // based on browser support + if(typeof document.addEventListener !== "undefined") + { + /** + * @private + */ + _attach = function (sel, event, callback) + { + if(typeof sel.addEventListener !== "undefined") + { + // Duplicated events are dropped, per the specification + sel.addEventListener(event, callback, false); + } + }; + /** + * @private + */ + _remove = function (sel, event, callback) + { + if(typeof sel.removeEventListener !== "undefined") + { + sel.removeEventListener(event, callback, false); + } + }; + } + // typeof function doesn't work in IE where attachEvent is available: brute force it + else if(typeof document.attachEvent !== "undefined") + { + /** + * @private + */ + _attach = function (sel, event, callback) + { + function _listener () { + // Internet Explorer fails to correctly set the 'this' object + // 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] || {}; + expando.listeners = expando.listeners || {}; + expando.listeners[event] = expando.listeners[event] || []; + expando.listeners[event].push({ + callback: callback, + _listener: _listener + }); + } + else + { + console.log("Failed to _attach event:"+event+" on "+sel); + } + }; + /** + * @private + */ + _remove = function (sel, event, callback) + { + if(typeof sel.detachEvent !== "undefined") + { + var expando = sel[kis_expando]; + if (expando && expando.listeners + && expando.listeners[event]) + { + var listeners = expando.listeners[event]; + var len = listeners.length; + for (var i=0; i\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\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;je?1:ba?1:c\s+<"),a=a.replace(/>\s+\{/gim,">{"),a=a.replace(/\}\s+d?1:ca?1:b - +