From 8193bbab380232dcac612e58c75b37461130b041 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 4 Oct 2012 17:25:09 +0000 Subject: [PATCH] Slim down library by removing IE 8 support --- README.md | 50 +-- docs/files.html | 2 +- docs/symbols/src/kis-js_src_core.js.html | 14 +- .../src/kis-js_src_modules_DOM.js.html | 216 +++++----- .../src/kis-js_src_modules_ajax.js.html | 28 +- .../src/kis-js_src_modules_event.js.html | 380 +++++++----------- kis-all.js | 172 ++------ kis-lite-dom-min.js | 31 +- kis-lite-dom.js | 172 ++------ kis-lite-min.js | 16 +- kis-lite.js | 160 ++------ kis-min.js | 37 +- src/core.js | 12 +- src/modules/DOM.js | 12 +- src/modules/ajax.js | 16 +- src/modules/event.js | 114 +----- src/polyfill.js | 18 - tests/index.html | 0 18 files changed, 438 insertions(+), 1012 deletions(-) mode change 100755 => 100644 src/core.js mode change 100755 => 100644 tests/index.html diff --git a/README.md b/README.md index b02529d..e81cb8e 100755 --- a/README.md +++ b/README.md @@ -2,54 +2,54 @@ A Minimal, Modular Javascript library for Modern browsers. -Aims to be fast, small, and easily split into individual modules. +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 +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: IE8+, Latest versions of Firefox, Chrome, Safari, Opera +Browser support: IE9+, 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 : - + + 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: - + + + Example: + $_.ext("zip", function(){ //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 /docs folder 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/) @@ -59,10 +59,10 @@ There are two lite versions: 1. Lite - Includes only the ajax and events modules 2. Lite-dom - Includes ajax, events, and dom modules - - - - - - + + + + + + diff --git a/docs/files.html b/docs/files.html index abfd7f0..f6c1b34 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, function)
post(string, object, function, function)
sse(string, 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)
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, function)
post(string, object, function, function)
sse(string, 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)
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/old_event.js
ajax.js../kis-js/src/modules/old_event.js
DOM.js../kis-js/src/modules/old_event.js
event.js../kis-js/src/modules/old_event.js
old_event.js../kis-js/src/modules/old_event.js
store.js../kis-js/src/modules/old_event.js
util.js../kis-js/src/modules/old_event.js
\ 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 738beac..9f475c5 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.6.0 + 5 Version 0.7.0 6 */ 7 (function (){ 8 @@ -41,17 +41,17 @@ 34 */ 35 $_ = function(s) 36 { - 37 //Have documentElement be default selector, just in case - 38 if(typeof s === "undefined") + 37 // Have documentElement be default selector, just in case + 38 if (typeof s === "undefined") 39 { - 40 //Defines a "global" selector for that instance + 40 // Defines a "global" selector for that instance 41 sel = (typeof $_.el !== "undefined") 42 ? $_.el 43 : document.documentElement; 44 } 45 else 46 { - 47 sel = (typeof s !== "object") ? $(s) : s; + 47 sel = $(s); 48 } 49 50 // Add the selector to the prototype @@ -177,8 +177,8 @@ 170 [].forEach.call(sel, callback); 171 return; 172 } -173 -174 // Otherwise, fall back to a for loop +173 +174 // Otherwise, fall back to a for loop 175 var len = sel.length; 176 177 if (len === 0) 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 b8c3b2b..f2131d1 100755 --- a/docs/symbols/src/kis-js_src_modules_DOM.js.html +++ b/docs/symbols/src/kis-js_src_modules_DOM.js.html @@ -423,119 +423,113 @@ 416 */ 417 text: function (value) 418 { -419 var oldValue, set, type, sel; +419 var oldValue, set, sel; 420 421 sel = this.el; 422 423 set = (typeof value !== "undefined") ? true : false; 424 -425 type = (typeof sel.textContent !== "undefined") -426 ? "textContent" -427 : (typeof sel.innerText !== "undefined") -428 ? "innerText" -429 : "innerHTML"; -430 -431 oldValue = sel[type]; -432 -433 if(set) -434 { -435 sel[type] = value; -436 return value; -437 } -438 else -439 { -440 return oldValue; -441 } -442 }, -443 /** -444 * Sets or retrieves a css property of the element -445 * specified by the current selector. If a value is -446 * passed, it will set that value on the current element, -447 * otherwise it will return the value of the css property -448 * on the current element -449 * -450 * @name css -451 * @memberOf $_.dom -452 * @function -453 * @param string property -454 * @param [string] value -455 * @return string -456 * @type string -457 */ -458 css: function (prop, val) -459 { -460 //Return the current value if a value is not set -461 if(typeof val === "undefined") -462 { -463 return _css(this.el, prop); -464 } -465 -466 $_.each(function (e){ -467 _css(e, prop, val); -468 }); -469 }, -470 /** -471 * Adds to the innerHTML of the current element, after the last child. -472 * -473 * @example $_("ul").dom.append("<li></li>") adds an li element to the end of the selected ul element -474 * @name append -475 * @memberOf $_.dom -476 * @function -477 * @param string htm -478 */ -479 append: function(htm) -480 { -481 if(typeof document.insertAdjacentHTML !== "undefined") -482 { -483 this.el.insertAdjacentHTML('beforeend', htm); -484 } -485 else -486 { -487 this.el.innerHTML += htm; -488 } -489 }, -490 /** -491 * Adds to the innerHTML of the selected element, before the current children -492 * -493 * @name prepend -494 * @memberOf $_.dom -495 * @function -496 * @param string htm -497 */ -498 prepend: function(htm) -499 { -500 if(typeof document.insertAdjacentHTML !== "undefined") -501 { -502 this.el.insertAdjacentHTML('afterbegin', htm); -503 } -504 else -505 { -506 this.el.innerHTML = htm + this.el.innerHTML; -507 } -508 }, -509 /** -510 * Sets or gets the innerHTML propery of the element(s) passed -511 * -512 * @name html -513 * @memberOf $_.dom -514 * @function -515 * @param [string] htm -516 * @return string -517 * @type string -518 */ -519 html: function(htm) -520 { -521 -522 if(typeof htm !== "undefined") -523 { -524 this.el.innerHTML = htm; -525 } -526 -527 //If the parameter is undefined, just return the current value -528 return this.el.innerHTML; -529 } -530 }; -531 -532 $_.ext('dom', d); -533 -534 }()); \ No newline at end of file +425 oldValue = sel.textContent; +426 +427 if(set) +428 { +429 sel.textContent = value; +430 return value; +431 } +432 else +433 { +434 return oldValue; +435 } +436 }, +437 /** +438 * Sets or retrieves a css property of the element +439 * specified by the current selector. If a value is +440 * passed, it will set that value on the current element, +441 * otherwise it will return the value of the css property +442 * on the current element +443 * +444 * @name css +445 * @memberOf $_.dom +446 * @function +447 * @param string property +448 * @param [string] value +449 * @return string +450 * @type string +451 */ +452 css: function (prop, val) +453 { +454 //Return the current value if a value is not set +455 if(typeof val === "undefined") +456 { +457 return _css(this.el, prop); +458 } +459 +460 $_.each(function (e){ +461 _css(e, prop, val); +462 }); +463 }, +464 /** +465 * Adds to the innerHTML of the current element, after the last child. +466 * +467 * @example $_("ul").dom.append("<li></li>") adds an li element to the end of the selected ul element +468 * @name append +469 * @memberOf $_.dom +470 * @function +471 * @param string htm +472 */ +473 append: function(htm) +474 { +475 if(typeof document.insertAdjacentHTML !== "undefined") +476 { +477 this.el.insertAdjacentHTML('beforeend', htm); +478 } +479 else +480 { +481 this.el.innerHTML += htm; +482 } +483 }, +484 /** +485 * Adds to the innerHTML of the selected element, before the current children +486 * +487 * @name prepend +488 * @memberOf $_.dom +489 * @function +490 * @param string htm +491 */ +492 prepend: function(htm) +493 { +494 if(typeof document.insertAdjacentHTML !== "undefined") +495 { +496 this.el.insertAdjacentHTML('afterbegin', htm); +497 } +498 else +499 { +500 this.el.innerHTML = htm + this.el.innerHTML; +501 } +502 }, +503 /** +504 * Sets or gets the innerHTML propery of the element(s) passed +505 * +506 * @name html +507 * @memberOf $_.dom +508 * @function +509 * @param [string] htm +510 * @return string +511 * @type string +512 */ +513 html: function(htm) +514 { +515 +516 if(typeof htm !== "undefined") +517 { +518 this.el.innerHTML = htm; +519 } +520 +521 //If the parameter is undefined, just return the current value +522 return this.el.innerHTML; +523 } +524 }; +525 +526 $_.ext('dom', d); +527 +528 }()); \ 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 19a7765..a0a8e26 100755 --- a/docs/symbols/src/kis-js_src_modules_ajax.js.html +++ b/docs/symbols/src/kis-js_src_modules_ajax.js.html @@ -55,8 +55,8 @@ 48 error_callback.call(request.status, request.status); 49 } 50 } - 51 - 52 } + 51 + 52 } 53 }; 54 55 if (type === "POST") @@ -127,8 +127,8 @@ 120 $_.ext('post', function (url, data, success_callback, error_callback){ 121 ajax._do(url, data, success_callback, error_callback, true); 122 }); -123 -124 /** +123 +124 /** 125 * Watches for server-sent events and applies a callback on message 126 * 127 * @name sse @@ -137,20 +137,20 @@ 130 * @param string url 131 * @param function callback 132 */ -133 $_.ext('sse', function(url, callback, poll_rate){ -134 -135 var source; -136 -137 // Check for server-sent event support +133 $_.ext('sse', function(url, callback){ +134 +135 var source; +136 +137 // Check for server-sent event support 138 if (typeof EventSource !== 'undefined') 139 { 140 source = new EventSource(url); -141 -142 // Apply the callback +141 +142 // Apply the callback 143 source.onmessage = function(event){ -144 callback.call(event.data, event.data); -145 }; +144 callback.call(event.data, event.data); +145 }; 146 } 147 }); -148 +148 149 }()); \ 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 68e3e6d..dece4c5 100755 --- a/docs/symbols/src/kis-js_src_modules_event.js.html +++ b/docs/symbols/src/kis-js_src_modules_event.js.html @@ -15,242 +15,148 @@ 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) + 11 var _add_remove, e, _attach_delegate; + 12 + 13 // Don't bother defining the methods if event api isn't supports + 14 if (typeof document.addEventListener === "undefined") + 15 { + 16 return false; + 17 } + 18 + 19 _add_remove = function (sel, event, callback, add) + 20 { + 21 var i, len; + 22 + 23 if(typeof sel === "undefined") 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 } + 25 return null; + 26 } + 27 + 28 // Multiple events? Run recursively! + 29 if ( ! event.match(/^([\w\-]+)$/)) + 30 { + 31 event = event.split(" "); + 32 + 33 len = event.length; + 34 + 35 for (i = 0; i < len; i++) + 36 { + 37 _add_remove(sel, event[i], callback, add); + 38 } + 39 + 40 return; + 41 } + 42 + 43 // Bind the event + 44 (add === true) + 45 ? sel.addEventListener(event, callback, false) + 46 : sel.removeEventListener(event, callback, false); + 47 }; + 48 + 49 _attach_delegate = function(sel, target, event, callback) + 50 { + 51 // attach the listener to the parent object + 52 _add_remove(sel, event, function(e){ + 53 + 54 var elem, t; 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 }; - 71 /** - 72 * @private - 73 */ - 74 _remove = function (sel, event, callback) - 75 { - 76 if(typeof sel.detachEvent !== "undefined") - 77 { - 78 var expando = sel[kis_expando]; - 79 if (expando && expando.listeners - 80 && expando.listeners[event]) - 81 { - 82 var listeners = expando.listeners[event]; - 83 var len = listeners.length; - 84 for (var i=0; i<len; i++) - 85 { - 86 if (listeners[i].callback === callback) - 87 { - 88 sel.detachEvent("on" + event, listeners[i]._listener); - 89 listeners.splice(i, 1); - 90 if(listeners.length === 0) - 91 { - 92 delete expando.listeners[event]; - 93 } - 94 return; - 95 } - 96 } - 97 } - 98 } - 99 }; -100 } -101 -102 _add_remove = function (sel, event, callback, add) -103 { -104 var i, len; -105 -106 if(typeof sel === "undefined") -107 { -108 return null; -109 } -110 -111 // Multiple events? Run recursively! -112 if ( ! event.match(/^([\w\-]+)$/)) -113 { -114 event = event.split(" "); -115 -116 len = event.length; -117 -118 for (i = 0; i < len; i++) -119 { -120 _add_remove(sel, event[i], callback, add); -121 } -122 -123 return; -124 } -125 -126 -127 if(add === true) -128 { -129 _attach(sel, event, callback); -130 } -131 else -132 { -133 _remove(sel, event, callback); -134 } -135 }; -136 -137 _attach_delegate = function(sel, target, event, callback) -138 { -139 // attach the listener to the parent object -140 _add_remove(sel, event, function(e){ -141 -142 var elem, t, tar; -143 -144 // IE 8 doesn't have event bound to element -145 e = e || window.event; -146 -147 // Get the live version of the target selector -148 t = $_.$(target, sel); -149 -150 // Check each element to see if it matches the target -151 for(elem in t) -152 { -153 // IE 8 doesn't have target in the event object -154 tar = e.target || e.srcElement; -155 -156 // Fire target callback when event bubbles from target -157 if(tar == t[elem]) -158 { -159 // Trigger the event callback -160 callback.call(t[elem], e); -161 -162 // Stop event propegation -163 e.stopPropagation(); -164 } -165 } -166 -167 }, true); -168 }; -169 -170 // -------------------------------------------------------------------------- -171 -172 /** -173 * Event Listener module -174 * -175 * @namespace -176 * @name event -177 * @memberOf $_ -178 */ -179 e = { -180 /** -181 * Adds an event that returns a callback when triggered on the selected -182 * event and selector -183 * -184 * @memberOf $_.event -185 * @name add -186 * @function -187 * @example Eg. $_("#selector").event.add("click", do_something()); -188 * @param string event -189 * @param function callback -190 */ -191 add: function (event, callback) -192 { -193 $_.each(function(e){ -194 _add_remove(e, event, callback, true); -195 }); -196 }, -197 /** -198 * Removes an event bound the the specified selector, event type, and callback -199 * -200 * @memberOf $_.event -201 * @name remove -202 * @function -203 * @example Eg. $_("#selector").event.remove("click", do_something()); -204 * @param string event -205 * @param string callback -206 */ -207 remove: function (event, callback) -208 { -209 $_.each(function(e){ -210 _add_remove(e, event, callback, false); -211 }); -212 }, -213 /** -214 * Binds a persistent event to the document -215 * -216 * @memberOf $_.event -217 * @name live -218 * @function -219 * @example Eg. $_.event.live(".button", "click", do_something()); -220 * @param string target -221 * @param string event -222 * @param function callback -223 */ -224 live: function (target, event, callback) -225 { -226 _attach_delegate(document.documentElement, target, event, callback); -227 }, -228 /** -229 * Binds an event to a parent object -230 * -231 * @memberOf $_.event -232 * @name delegate -233 * @function -234 * @example Eg. $_("#parent").delegate(".button", "click", do_something()); -235 * @param string target -236 * @param string event_type -237 * @param function callback -238 */ -239 delegate: function (target, event, callback) -240 { -241 $_.each(function(e){ -242 _attach_delegate(e, target, event, callback); -243 }); -244 } -245 }; -246 -247 $_.ext('event', e); -248 -249 }()); \ No newline at end of file + 56 // Get the live version of the target selector + 57 t = $_.$(target, sel); + 58 + 59 // Check each element to see if it matches the target + 60 for(elem in t) + 61 { + 62 // Fire target callback when event bubbles from target + 63 if(e.target == t[elem]) + 64 { + 65 // Trigger the event callback + 66 callback.call(t[elem], e); + 67 + 68 // Stop event propegation + 69 e.stopPropagation(); + 70 } + 71 } + 72 + 73 }, true); + 74 }; + 75 + 76 // -------------------------------------------------------------------------- + 77 + 78 /** + 79 * Event Listener module + 80 * + 81 * @namespace + 82 * @name event + 83 * @memberOf $_ + 84 */ + 85 e = { + 86 /** + 87 * Adds an event that returns a callback when triggered on the selected + 88 * event and selector + 89 * + 90 * @memberOf $_.event + 91 * @name add + 92 * @function + 93 * @example Eg. $_("#selector").event.add("click", do_something()); + 94 * @param string event + 95 * @param function callback + 96 */ + 97 add: function (event, callback) + 98 { + 99 $_.each(function(e){ +100 _add_remove(e, event, callback, true); +101 }); +102 }, +103 /** +104 * Removes an event bound the the specified selector, event type, and callback +105 * +106 * @memberOf $_.event +107 * @name remove +108 * @function +109 * @example Eg. $_("#selector").event.remove("click", do_something()); +110 * @param string event +111 * @param string callback +112 */ +113 remove: function (event, callback) +114 { +115 $_.each(function(e){ +116 _add_remove(e, event, callback, false); +117 }); +118 }, +119 /** +120 * Binds a persistent event to the document +121 * +122 * @memberOf $_.event +123 * @name live +124 * @function +125 * @example Eg. $_.event.live(".button", "click", do_something()); +126 * @param string target +127 * @param string event +128 * @param function callback +129 */ +130 live: function (target, event, callback) +131 { +132 _attach_delegate(document.documentElement, target, event, callback); +133 }, +134 /** +135 * Binds an event to a parent object +136 * +137 * @memberOf $_.event +138 * @name delegate +139 * @function +140 * @example Eg. $_("#parent").delegate(".button", "click", do_something()); +141 * @param string target +142 * @param string event_type +143 * @param function callback +144 */ +145 delegate: function (target, event, callback) +146 { +147 $_.each(function(e){ +148 _attach_delegate(e, target, event, callback); +149 }); +150 } +151 }; +152 +153 $_.ext('event', e); +154 +155 }()); \ No newline at end of file diff --git a/kis-all.js b/kis-all.js index a0c0705..132eebe 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.6.0 + Version 0.7.0 */ (function (){ @@ -34,17 +34,17 @@ */ $_ = function(s) { - //Have documentElement be default selector, just in case - if(typeof s === "undefined") + // Have documentElement be default selector, just in case + if (typeof s === "undefined") { - //Defines a "global" selector for that instance + // Defines a "global" selector for that instance sel = (typeof $_.el !== "undefined") ? $_.el : document.documentElement; } else { - sel = (typeof s !== "object") ? $(s) : s; + sel = $(s); } // Add the selector to the prototype @@ -170,7 +170,7 @@ [].forEach.call(sel, callback); return; } - + // Otherwise, fall back to a for loop var len = sel.length; @@ -240,24 +240,6 @@ if(typeof String.prototype.trim === "undefined") // -------------------------------------------------------------------------- -/** - * event.preventDefault/e.stopPropagation polyfill - * @private - */ -if(typeof Event.preventDefault === "undefined" && typeof window.event !== "undefined") -{ - Event.prototype.preventDefault = function() - { - window.event.returnValue = false; - }, - Event.prototype.stopPropagation = function() - { - window.event.cancelBubble = true; - } -} - -// -------------------------------------------------------------------------- - /** * Array.isArray polyfill */ @@ -695,23 +677,17 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" */ text: function (value) { - var oldValue, set, type, sel; + var oldValue, set, sel; sel = this.el; set = (typeof value !== "undefined") ? true : false; - type = (typeof sel.textContent !== "undefined") - ? "textContent" - : (typeof sel.innerText !== "undefined") - ? "innerText" - : "innerHTML"; - - oldValue = sel[type]; + oldValue = sel.textContent; if(set) { - sel[type] = value; + sel.textContent = value; return value; } else @@ -862,7 +838,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" error_callback.call(request.status, request.status); } } - + } }; @@ -934,7 +910,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" $_.ext('post', function (url, data, success_callback, error_callback){ ajax._do(url, data, success_callback, error_callback, true); }); - + /** * Watches for server-sent events and applies a callback on message * @@ -944,22 +920,22 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" * @param string url * @param function callback */ - $_.ext('sse', function(url, callback, poll_rate){ - + $_.ext('sse', function(url, callback){ + var source; - + // Check for server-sent event support if (typeof EventSource !== 'undefined') { source = new EventSource(url); - + // Apply the callback source.onmessage = function(event){ - callback.call(event.data, event.data); + callback.call(event.data, event.data); }; } }); - + // -------------------------------------------------------------------------- @@ -972,95 +948,12 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" */ - // Property name for expandos on DOM objects - var kis_expando = "KIS_0_6_0"; + var _add_remove, e, _attach_delegate; - var _attach, _remove, _add_remove, e, _attach_delegate; - - // Define the proper _attach and _remove functions - // based on browser support - if(typeof document.addEventListener !== "undefined") + // Don't bother defining the methods if event api isn't supports + 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 - }); - } - }; - /** - * @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; i1&&typeof b==="undefined")return null;if(e.length>1&&typeof b!=="undefined")$_.each(function(d){return c(d,a,b)});else return c(e,a,b)},text:function(a){var b,c,d;d=this.el;c=typeof d.textContent!=="undefined"?"textContent":typeof d.innerText!=="undefined"?"innerText": -"innerHTML";b=d[c];if(typeof a!=="undefined")return d[c]=a;return b},css:function(a,b){if(typeof b==="undefined")return e(this.el,a);$_.each(function(c){e(c,a,b)})},append:function(a){typeof document.insertAdjacentHTML!=="undefined"?this.el.insertAdjacentHTML("beforeend",a):this.el.innerHTML=this.el.innerHTML+a},prepend:function(a){typeof document.insertAdjacentHTML!=="undefined"?this.el.insertAdjacentHTML("afterbegin",a):this.el.innerHTML=a+this.el.innerHTML},html:function(a){if(typeof a!=="undefined")this.el.innerHTML= -a;return this.el.innerHTML}})})(); +(function(){if("undefined"!==typeof document.querySelector){var d,f,a,b;d=function(c){b="undefined"===typeof c?"undefined"!==typeof d.el?d.el:document.documentElement:f(c);d.prototype.el=b;var c=a(d),g;for(g in c)"object"===typeof c[g]&&(c[g].el=b);c.el=b;return c};f=function(c,b){var a;if("string"!=typeof c||"undefined"===typeof c)return c;a=null!=b&&1===b.nodeType?b:document;if(c.match(/^#([\w\-]+$)/))return document.getElementById(c.split("#")[1]);a=a.querySelectorAll(c);return 1===a.length?a[0]: +a};a=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}};d.ext=function(a,g){g.el=b;d[a]=g};d.ext("each",function(a){if("undefined"!==typeof b.length&&b!==window)if("undefined"!==typeof Array.prototype.forEach)[].forEach.call(b,a);else{var g=b.length;if(0!==g)for(var e,d=0;d1&&typeof b==="undefined")return null;if(c.length>1&&typeof b!=="undefined")d.each(function(c){return o(c,a,b)});else return o(c,a,b)},text:function(a){var b,c,f;f=this.el;c=typeof f.textContent!=="undefined"?"textContent":typeof f.innerText!=="undefined"?"innerText": -"innerHTML";b=f[c];if(typeof a!=="undefined")return f[c]=a;return b},css:function(a,b){if(typeof b==="undefined")return e(this.el,a);d.each(function(c){e(c,a,b)})},append:function(a){typeof document.insertAdjacentHTML!=="undefined"?this.el.insertAdjacentHTML("beforeend",a):this.el.innerHTML=this.el.innerHTML+a},prepend:function(a){typeof document.insertAdjacentHTML!=="undefined"?this.el.insertAdjacentHTML("afterbegin",a):this.el.innerHTML=a+this.el.innerHTML},html:function(a){if(typeof a!=="undefined")this.el.innerHTML= -a;return this.el.innerHTML}});if(typeof window.XMLHttpRequest!=="undefined"){var g={_do:function(a,b,c,f,j){var d=new XMLHttpRequest;typeof c==="undefined"&&(c=function(){});j=j?"POST":"GET";a=a+(j==="GET"?"?"+this._serialize(b):"");d.open(j,a);d.onreadystatechange=function(){d.readyState===4&&(d.status===200?c.call(d.responseText,d.responseText):typeof f!=="undefined"&&f.call(d.status,d.status))};if(j==="POST"){d.setRequestHeader("Content-Type","application/x-www-form-urlencoded");d.send(this._serialize(b))}else d.send(null)}, -_serialize:function(a){var b,c,f=[];for(b in a)if(a.hasOwnProperty(b)&&typeof a[b]!=="function"){c=a[b].toString();b=encodeURIComponent(b);c=encodeURIComponent(c);f.push(b+"="+c)}return f.join("&")}};d.ext("get",function(a,b,c,f){g._do(a,b,c,f,false)});d.ext("post",function(a,b,c,f){g._do(a,b,c,f,true)});d.ext("sse",function(a,b){var c;if(typeof EventSource!=="undefined"){c=new EventSource(a);c.onmessage=function(a){b.call(a.data,a.data)}}});var i,l,k,q;if(typeof document.addEventListener!=="undefined"){i= -function(a,b,c){typeof a.addEventListener!=="undefined"&&a.addEventListener(b,c,false)};l=function(a,b,c){typeof a.removeEventListener!=="undefined"&&a.removeEventListener(b,c,false)}}else if(typeof document.attachEvent!=="undefined"){i=function(a,b,c){function f(a){c.apply(a)}if(typeof a.attachEvent!=="undefined"){l(b,c);a.attachEvent("on"+b,f);a=a.KIS_0_6_0=a.KIS_0_6_0||{};a.listeners=a.listeners||{};a.listeners[b]=a.listeners[b]||[];a.listeners[b].push({callback:c,_listener:f})}};l=function(a, -b,c){if(typeof a.detachEvent!=="undefined"){var f=a.KIS_0_6_0;if(f&&f.listeners&&f.listeners[b])for(var d=f.listeners[b],e=d.length,h=0;hd?1:ca?1:bd?1:ca?1:b