Updated undefined checks for smaller minified script.

This commit is contained in:
Timothy Warren 2013-06-19 10:13:21 -04:00
parent 35bdf75408
commit 67991ae40d
18 changed files with 555 additions and 1214 deletions

View File

@ -9,9 +9,9 @@
<span class='line'> 2</span> Kis JS Keep It Simple JS Library <span class='line'> 2</span> Kis JS Keep It Simple JS Library
<span class='line'> 3</span> Copyright Timothy J. Warren <span class='line'> 3</span> Copyright Timothy J. Warren
<span class='line'> 4</span> License Public Domain <span class='line'> 4</span> License Public Domain
<span class='line'> 5</span> Version 0.7.0 <span class='line'> 5</span> Version 0.8.0
<span class='line'> 6</span> */</span><span class="WHIT"> <span class='line'> 6</span> */</span><span class="WHIT">
<span class='line'> 7</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 7</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 8</span> <span class='line'> 8</span>
<span class='line'> 9</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 9</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 10</span> <span class='line'> 10</span>
@ -21,7 +21,7 @@
<span class='line'> 14</span> </span><span class="WHIT"> </span><span class="COMM">// selector engine. I choose to just use the</span><span class="WHIT"> <span class='line'> 14</span> </span><span class="WHIT"> </span><span class="COMM">// selector engine. I choose to just use the</span><span class="WHIT">
<span class='line'> 15</span> </span><span class="WHIT"> </span><span class="COMM">// browser feature, since it is present in</span><span class="WHIT"> <span class='line'> 15</span> </span><span class="WHIT"> </span><span class="COMM">// browser feature, since it is present in</span><span class="WHIT">
<span class='line'> 16</span> </span><span class="WHIT"> </span><span class="COMM">// IE 8+, and all other major browsers</span><span class="WHIT"> <span class='line'> 16</span> </span><span class="WHIT"> </span><span class="COMM">// IE 8+, and all other major browsers</span><span class="WHIT">
<span class='line'> 17</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">document.querySelector</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 17</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">document.querySelector</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 18</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 18</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 19</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 19</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 20</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 20</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
@ -42,10 +42,10 @@
<span class='line'> 35</span> </span><span class="WHIT"> </span><span class="NAME">$_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 35</span> </span><span class="WHIT"> </span><span class="NAME">$_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 36</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 36</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 37</span> </span><span class="WHIT"> </span><span class="COMM">// Have documentElement be default selector, just in case</span><span class="WHIT"> <span class='line'> 37</span> </span><span class="WHIT"> </span><span class="COMM">// Have documentElement be default selector, just in case</span><span class="WHIT">
<span class='line'> 38</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 38</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 39</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 39</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 40</span> </span><span class="WHIT"> </span><span class="COMM">// Defines a "global" selector for that instance</span><span class="WHIT"> <span class='line'> 40</span> </span><span class="WHIT"> </span><span class="COMM">// Defines a "global" selector for that instance</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="WHIT"> </span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">$_.el</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 41</span> </span><span class="WHIT"> </span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">$_.el</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">$_.el</span><span class="WHIT"> <span class='line'> 42</span> </span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">$_.el</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">document.documentElement</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 43</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">document.documentElement</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 44</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
@ -87,7 +87,7 @@
<span class='line'> 80</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 80</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">c</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 81</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">c</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 82</span> <span class='line'> 82</span>
<span class='line'> 83</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"string"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 83</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"string"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 84</span> <span class='line'> 84</span>
<span class='line'> 85</span> </span><span class="WHIT"> </span><span class="COMM">//Check for a context of a specific element, otherwise, just run on the document</span><span class="WHIT"> <span class='line'> 85</span> </span><span class="WHIT"> </span><span class="COMM">//Check for a context of a specific element, otherwise, just run on the document</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT"> </span><span class="NAME">c</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">context</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">context.nodeType</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 86</span> </span><span class="WHIT"> </span><span class="NAME">c</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">context</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">context.nodeType</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
@ -120,12 +120,12 @@
<span class='line'>113</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'>113</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">F</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>114</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">F</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>115</span> <span class='line'>115</span>
<span class='line'>116</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'>116</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'>117</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>118</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'>119</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>120</span> <span class='line'>120</span>
<span class='line'>121</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">Object.create</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'>121</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">Object.create</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'>122</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">Object.create</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>123</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">Object.create</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>124</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'>124</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
@ -169,10 +169,10 @@
<span class='line'>162</span> */</span><span class="WHIT"> <span class='line'>162</span> */</span><span class="WHIT">
<span class='line'>163</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'each'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'>163</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'each'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>164</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'>164</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>165</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.length</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">window</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'>165</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">sel.length</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">window</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>166</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'>166</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>167</span> </span><span class="WHIT"> </span><span class="COMM">// Use the native method, if it exists</span><span class="WHIT"> <span class='line'>167</span> </span><span class="WHIT"> </span><span class="COMM">// Use the native method, if it exists</span><span class="WHIT">
<span class='line'>168</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">Array.prototype.forEach</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'>168</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">Array.prototype.forEach</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>169</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'>169</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>170</span> </span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">forEach.call</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>170</span> </span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">forEach.call</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>171</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>171</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">

File diff suppressed because one or more lines are too long

View File

@ -10,12 +10,12 @@
<span class='line'> 3</span> * <span class='line'> 3</span> *
<span class='line'> 4</span> * Module for making ajax requests <span class='line'> 4</span> * Module for making ajax requests
<span class='line'> 5</span> */</span><span class="WHIT"> <span class='line'> 5</span> */</span><span class="WHIT">
<span class='line'> 6</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 6</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 7</span> <span class='line'> 7</span>
<span class='line'> 8</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 8</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 9</span> <span class='line'> 9</span>
<span class='line'> 10</span> </span><span class="WHIT"> </span><span class="COMM">// Don't bother even defining the object if the XMLHttpRequest isn't available</span><span class="WHIT"> <span class='line'> 10</span> </span><span class="WHIT"> </span><span class="COMM">// Don't bother even defining the object if the XMLHttpRequest isn't available</span><span class="WHIT">
<span class='line'> 11</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">window.XMLHttpRequest</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 11</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">window.XMLHttpRequest</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 12</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 12</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 13</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 13</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 14</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 14</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
@ -26,7 +26,7 @@
<span class='line'> 19</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> <span class='line'> 19</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 20</span> </span><span class="WHIT"> </span><span class="NAME">request</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">XMLHttpRequest</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 20</span> </span><span class="WHIT"> </span><span class="NAME">request</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">XMLHttpRequest</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 21</span> <span class='line'> 21</span>
<span class='line'> 22</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">success_callback</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 22</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">success_callback</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 23</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 23</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 24</span> </span><span class="WHIT"> </span><span class="COMM">/** <span class='line'> 24</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 25</span> * @private <span class='line'> 25</span> * @private
@ -55,7 +55,7 @@
<span class='line'> 48</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 48</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 49</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> <span class='line'> 49</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'> 50</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 50</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">error_callback</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 51</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">error_callback</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 52</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 53</span> </span><span class="WHIT"> </span><span class="NAME">error_callback.call</span><span class="PUNC">(</span><span class="NAME">request.status</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">request.status</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 53</span> </span><span class="WHIT"> </span><span class="NAME">error_callback.call</span><span class="PUNC">(</span><span class="NAME">request.status</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">request.status</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 54</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 54</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
@ -147,7 +147,7 @@
<span class='line'>140</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">source</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>140</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">source</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>141</span> <span class='line'>141</span>
<span class='line'>142</span> </span><span class="WHIT"> </span><span class="COMM">// Check for server-sent event support</span><span class="WHIT"> <span class='line'>142</span> </span><span class="WHIT"> </span><span class="COMM">// Check for server-sent event support</span><span class="WHIT">
<span class='line'>143</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">EventSource</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'>143</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">EventSource</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'>144</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT"> </span><span class="NAME">source</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">EventSource</span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>145</span> </span><span class="WHIT"> </span><span class="NAME">source</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">EventSource</span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>146</span> <span class='line'>146</span>

View File

@ -11,14 +11,14 @@
<span class='line'> 4</span> * Event api wrapper <span class='line'> 4</span> * Event api wrapper
<span class='line'> 5</span> * @todo Add method for triggering events <span class='line'> 5</span> * @todo Add method for triggering events
<span class='line'> 6</span> */</span><span class="WHIT"> <span class='line'> 6</span> */</span><span class="WHIT">
<span class='line'> 7</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 7</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 8</span> <span class='line'> 8</span>
<span class='line'> 9</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 9</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 10</span> <span class='line'> 10</span>
<span class='line'> 11</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_add_remove</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_attach_delegate</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 11</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_add_remove</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_attach_delegate</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 12</span> <span class='line'> 12</span>
<span class='line'> 13</span> </span><span class="WHIT"> </span><span class="COMM">// Don't bother defining the methods if event api isn't supports</span><span class="WHIT"> <span class='line'> 13</span> </span><span class="WHIT"> </span><span class="COMM">// Don't bother defining the methods if event api isn't supports</span><span class="WHIT">
<span class='line'> 14</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">document.addEventListener</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 14</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">document.addEventListener</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 15</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 15</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 16</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 16</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 17</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 17</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
@ -27,7 +27,7 @@
<span class='line'> 20</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 20</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 21</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 21</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 22</span> <span class='line'> 22</span>
<span class='line'> 23</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 23</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 24</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 24</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 25</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 25</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 26</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 26</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">

View File

@ -10,12 +10,12 @@
<span class='line'> 3</span> * <span class='line'> 3</span> *
<span class='line'> 4</span> * Wrapper for local / sessionstorage <span class='line'> 4</span> * Wrapper for local / sessionstorage
<span class='line'> 5</span> */</span><span class="WHIT"> <span class='line'> 5</span> */</span><span class="WHIT">
<span class='line'> 6</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 6</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 7</span> <span class='line'> 7</span>
<span class='line'> 8</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 8</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 9</span> <span class='line'> 9</span>
<span class='line'> 10</span> </span><span class="WHIT"> </span><span class="COMM">//No support for localstorage? Bail out early</span><span class="WHIT"> <span class='line'> 10</span> </span><span class="WHIT"> </span><span class="COMM">//No support for localstorage? Bail out early</span><span class="WHIT">
<span class='line'> 11</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">localStorage</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">JSON</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 11</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">localStorage</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">JSON</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 12</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 12</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 13</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 13</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 14</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 14</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">

View File

@ -11,7 +11,7 @@
<span class='line'> 4</span> * Various object and string manipulation functions <span class='line'> 4</span> * Various object and string manipulation functions
<span class='line'> 5</span> * Note: these are based on similar phpjs functions: http://phpjs.org <span class='line'> 5</span> * Note: these are based on similar phpjs functions: http://phpjs.org
<span class='line'> 6</span> */</span><span class="WHIT"> <span class='line'> 6</span> */</span><span class="WHIT">
<span class='line'> 7</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 7</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 8</span> <span class='line'> 8</span>
<span class='line'> 9</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 9</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 10</span> <span class='line'> 10</span>

View File

@ -2,9 +2,9 @@
Kis JS Keep It Simple JS Library Kis JS Keep It Simple JS Library
Copyright Timothy J. Warren Copyright Timothy J. Warren
License Public Domain License Public Domain
Version 0.7.0 Version 0.8.0
*/ */
(function (){ (function (undefined){
"use strict"; "use strict";
@ -14,7 +14,7 @@
// selector engine. I choose to just use the // selector engine. I choose to just use the
// browser feature, since it is present in // browser feature, since it is present in
// IE 8+, and all other major browsers // IE 8+, and all other major browsers
if (typeof document.querySelector === "undefined") if (document.querySelector === undefined)
{ {
return; return;
} }
@ -35,10 +35,10 @@
$_ = function(s) $_ = function(s)
{ {
// Have documentElement be default selector, just in case // Have documentElement be default selector, just in case
if (typeof s === "undefined") if (s === undefined)
{ {
// Defines a "global" selector for that instance // Defines a "global" selector for that instance
sel = (typeof $_.el !== "undefined") sel = ($_.el !== undefined)
? $_.el ? $_.el
: document.documentElement; : document.documentElement;
} }
@ -80,7 +80,7 @@
{ {
var x, c; var x, c;
if (typeof a != "string" || typeof a === "undefined"){ return a;} if (typeof a != "string" || a === undefined){ return a;}
//Check for a context of a specific element, otherwise, just run on the document //Check for a context of a specific element, otherwise, just run on the document
c = (context != null && context.nodeType === 1) c = (context != null && context.nodeType === 1)
@ -113,12 +113,12 @@
{ {
var type, F; var type, F;
if(typeof obj === "undefined") if(obj === undefined)
{ {
return; return;
} }
if(typeof Object.create !== "undefined") if(Object.create !== undefined)
{ {
return Object.create(obj); return Object.create(obj);
} }
@ -162,10 +162,10 @@
*/ */
$_.ext('each', function (callback) $_.ext('each', function (callback)
{ {
if(typeof sel.length !== "undefined" && sel !== window) if(sel.length !== undefined && sel !== window)
{ {
// Use the native method, if it exists // Use the native method, if it exists
if(typeof Array.prototype.forEach !== 'undefined') if(Array.prototype.forEach !== undefined)
{ {
[].forEach.call(sel, callback); [].forEach.call(sel, callback);
return; return;
@ -255,177 +255,15 @@ if (typeof Array.isArray === "undefined")
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
(function ($_){ (function ($_, undefined){
"use strict" "use strict"
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
//This is used so IE can use the classList api //This is used so IE can use the classList api
/* /*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js*/
* classList.js: Cross-browser full element.classList implementation. if(typeof document!=="undefined"&&!("classList" in document.createElement("a"))){(function(j){if(!("HTMLElement" in j)&&!("Element" in j)){return}var a="classList",f="prototype",m=(j.HTMLElement||j.Element)[f],b=Object,k=String[f].trim||function(){return this.replace(/^\s+|\s+$/g,"")},c=Array[f].indexOf||function(q){var p=0,o=this.length;for(;p<o;p++){if(p in this&&this[p]===q){return p}}return -1},n=function(o,p){this.name=o;this.code=DOMException[o];this.message=p},g=function(p,o){if(o===""){throw new n("SYNTAX_ERR","An invalid or illegal string was specified")}if(/\s/.test(o)){throw new n("INVALID_CHARACTER_ERR","String contains an invalid character")}return c.call(p,o)},d=function(s){var r=k.call(s.className),q=r?r.split(/\s+/):[],p=0,o=q.length;for(;p<o;p++){this.push(q[p])}this._updateClassName=function(){s.className=this.toString()}},e=d[f]=[],i=function(){return new d(this)};n[f]=Error[f];e.item=function(o){return this[o]||null};e.contains=function(o){o+="";return g(this,o)!==-1};e.add=function(){var s=arguments,r=0,p=s.length,q,o=false;do{q=s[r]+"";if(g(this,q)===-1){this.push(q);o=true}}while(++r<p);if(o){this._updateClassName()}};e.remove=function(){var t=arguments,s=0,p=t.length,r,o=false;do{r=t[s]+"";var q=g(this,r);if(q!==-1){this.splice(q,1);o=true}}while(++s<p);if(o){this._updateClassName()}};e.toggle=function(p,q){p+="";var o=this.contains(p),r=o?q!==true&&"remove":q!==false&&"add";if(r){this[r](p)}return !o};e.toString=function(){return this.join(" ")};if(b.defineProperty){var l={get:i,enumerable:true,configurable:true};try{b.defineProperty(m,a,l)}catch(h){if(h.number===-2146823252){l.enumerable=false;b.defineProperty(m,a,l)}}}else{if(b[f].__defineGetter__){m.__defineGetter__(a,i)}}}(self))};
* 2011-06-15
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
if (typeof document !== "undefined" && !("classList" in document.createElement("a")))
{
(function (view){
var classListProp = "classList",
protoProp = "prototype",
elemCtrProto = (view.HTMLElement || view.Element)[protoProp],
objCtr = Object,
strTrim = String[protoProp].trim ||
function ()
{
return this.replace(/^\s+|\s+$/g, "");
},
arrIndexOf = Array[protoProp].indexOf ||
function (item)
{
var
i = 0,
len = this.length;
for (; i < len; i++)
{
if (i in this && this[i] === item)
{
return i;
}
}
return -1;
}
// Vendors: please allow content code to instantiate DOMExceptions
,
/**
* @private
*/
DOMEx = function (type, message)
{
this.name = type;
this.code = DOMException[type];
this.message = message;
},
/**
* @private
*/
checkTokenAndGetIndex = function (classList, token)
{
if (token === "")
{
throw new DOMEx("SYNTAX_ERR", "An invalid or illegal string was specified");
}
if (/\s/.test(token))
{
throw new DOMEx("INVALID_CHARACTER_ERR", "String contains an invalid character");
}
return arrIndexOf.call(classList, token);
},
/**
* @private
*/
ClassList = function (elem)
{
var
trimmedClasses = strTrim.call(elem.className),
classes = trimmedClasses ? trimmedClasses.split(/\s+/) : [],
i = 0,
len = classes.length;
for (; i < len; i++)
{
this.push(classes[i]);
}
this._updateClassName = function ()
{
elem.className = this.toString();
};
},
classListProto = ClassList[protoProp] = [],
/**
* @private
*/
classListGetter = function ()
{
return new ClassList(this);
};
// Most DOMException implementations don't allow calling DOMException's toString()
// on non-DOMExceptions. Error's toString() is sufficient here.
DOMEx[protoProp] = Error[protoProp];
classListProto.item = function (i)
{
return this[i] || null;
};
classListProto.contains = function (token)
{
token += "";
return checkTokenAndGetIndex(this, token) !== -1;
};
classListProto.add = function (token)
{
token += "";
if (checkTokenAndGetIndex(this, token) === -1)
{
this.push(token);
this._updateClassName();
}
};
classListProto.remove = function (token)
{
token += "";
var index = checkTokenAndGetIndex(this, token);
if (index !== -1)
{
this.splice(index, 1);
this._updateClassName();
}
};
classListProto.toggle = function (token)
{
token += "";
if (checkTokenAndGetIndex(this, token) === -1)
{
this.add(token);
}
else
{
this.remove(token);
}
};
classListProto.toString = function ()
{
return this.join(" ");
};
if (objCtr.defineProperty)
{
var classListPropDesc = {
get: classListGetter,
enumerable: true,
configurable: true
};
try
{
objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
}
catch (ex)
{ // IE 8 doesn't support enumerable:true
if (ex.number === -0x7FF5EC54)
{
classListPropDesc.enumerable = false;
objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
}
}
}
else if (objCtr[protoProp].__defineGetter__)
{
elemCtrProto.__defineGetter__(classListProp, classListGetter);
}
}(self));
}
/** /**
* DOM * DOM
@ -442,7 +280,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
var oldVal, doAttr; var oldVal, doAttr;
//Get the value of the attribute, if it exists //Get the value of the attribute, if it exists
if (typeof sel.hasAttribute !== "undefined") if (sel.hasAttribute !== undefined)
{ {
if (sel.hasAttribute(name)) if (sel.hasAttribute(name))
{ {
@ -451,12 +289,12 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
doAttr = true; doAttr = true;
} }
else if (typeof sel[name] !== "undefined") else if (sel[name] !== undefined)
{ {
oldVal = sel[name]; oldVal = sel[name];
doAttr = false; doAttr = false;
} }
else if (name === "class" && typeof sel.className !== "undefined") //className attribute else if (name === "class" && sel.className !== undefined) //className attribute
{ {
name = "className"; name = "className";
oldVal = sel.className; oldVal = sel.className;
@ -464,22 +302,19 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
} }
//Well, I guess that attribute doesn't exist //Well, I guess that attribute doesn't exist
if (typeof oldVal === "undefined" && (typeof value === "undefined" || value === null)) if (oldVal === undefined && (value === undefined || value === null))
{ {
/*console.log(value);
console.log(sel);
console.log("Element does not have the selected attribute");*/
return null; return null;
} }
//No value to set? Return the current value //No value to set? Return the current value
if (typeof value === "undefined") if (value === undefined)
{ {
return oldVal; return oldVal;
} }
//Determine what to do with the attribute //Determine what to do with the attribute
if (typeof value !== "undefined" && value !== null) if (value !== undefined && value !== null)
{ {
if(doAttr === true) if(doAttr === true)
{ {
@ -502,7 +337,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
} }
} }
return (typeof value !== "undefined") ? value : oldVal; return (value !== undefined) ? value : oldVal;
} }
/** /**
@ -532,17 +367,17 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
//If you don't define a value, try returning the existing value //If you don't define a value, try returning the existing value
if(typeof val === "undefined" && sel.style[prop] !== "undefined") if(val === undefined && sel.style[prop] !== undefined)
{ {
return sel.style[prop]; return sel.style[prop];
} }
else if(typeof val === "undefined" && sel.style[equi[prop]] !== "undefined") else if(val === undefined && sel.style[equi[prop]] !== undefined)
{ {
return sel.style[equi[prop]]; return sel.style[equi[prop]];
} }
//Let's try the easy way first //Let's try the easy way first
if(typeof sel.style[prop] !== "undefined") if(sel.style[prop] !== undefined)
{ {
sel.style[prop] = val; sel.style[prop] = val;
@ -579,7 +414,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
addClass: function (c) addClass: function (c)
{ {
$_.each(function (e){ $_.each(function (e){
e.classList.add(c); this.classList.add(c);
}); });
}, },
/** /**
@ -621,7 +456,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
*/ */
show: function (type) show: function (type)
{ {
if (typeof type === "undefined") if (type === undefined)
{ {
type = "block"; type = "block";
} }
@ -647,11 +482,11 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
var sel = this.el; var sel = this.el;
//Make sure you don't try to get a bunch of elements //Make sure you don't try to get a bunch of elements
if (sel.length > 1 && typeof value === "undefined") if (sel.length > 1 && value === undefined)
{ {
return null; return null;
} }
else if (sel.length > 1 && typeof value !== "undefined") //You can set a bunch, though else if (sel.length > 1 && value !== undefined) //You can set a bunch, though
{ {
$_.each(function (e){ $_.each(function (e){
return _attr(e, name, value); return _attr(e, name, value);
@ -681,7 +516,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
sel = this.el; sel = this.el;
set = (typeof value !== "undefined") ? true : false; set = (value !== undefined) ? true : false;
oldValue = sel.textContent; oldValue = sel.textContent;
@ -713,7 +548,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
css: function (prop, val) css: function (prop, val)
{ {
//Return the current value if a value is not set //Return the current value if a value is not set
if(typeof val === "undefined") if(val === undefined)
{ {
return _css(this.el, prop); return _css(this.el, prop);
} }
@ -733,7 +568,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
*/ */
append: function(htm) append: function(htm)
{ {
if(typeof document.insertAdjacentHTML !== "undefined") if(document.insertAdjacentHTML !== undefined)
{ {
this.el.insertAdjacentHTML('beforeend', htm); this.el.insertAdjacentHTML('beforeend', htm);
} }
@ -752,7 +587,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
*/ */
prepend: function(htm) prepend: function(htm)
{ {
if(typeof document.insertAdjacentHTML !== "undefined") if(document.insertAdjacentHTML !== undefined)
{ {
this.el.insertAdjacentHTML('afterbegin', htm); this.el.insertAdjacentHTML('afterbegin', htm);
} }
@ -774,7 +609,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
html: function(htm) html: function(htm)
{ {
if(typeof htm !== "undefined") if(htm !== undefined)
{ {
this.el.innerHTML = htm; this.el.innerHTML = htm;
} }
@ -798,7 +633,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
// Don't bother even defining the object if the XMLHttpRequest isn't available // Don't bother even defining the object if the XMLHttpRequest isn't available
if(typeof window.XMLHttpRequest === "undefined") if(window.XMLHttpRequest === undefined)
{ {
return; return;
} }
@ -809,7 +644,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
var type, var type,
request = new XMLHttpRequest(); request = new XMLHttpRequest();
if (typeof success_callback === "undefined") if (success_callback === undefined)
{ {
/** /**
* @private * @private
@ -838,7 +673,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
} }
else else
{ {
if (typeof error_callback !== 'undefined') if (error_callback !== undefined)
{ {
error_callback.call(request.status, request.status); error_callback.call(request.status, request.status);
} }
@ -930,7 +765,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
var source; var source;
// Check for server-sent event support // Check for server-sent event support
if (typeof EventSource !== 'undefined') if (EventSource !== undefined)
{ {
source = new EventSource(url); source = new EventSource(url);
@ -956,7 +791,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
var _add_remove, e, _attach_delegate; var _add_remove, e, _attach_delegate;
// Don't bother defining the methods if event api isn't supports // Don't bother defining the methods if event api isn't supports
if (typeof document.addEventListener === "undefined") if (document.addEventListener === undefined)
{ {
return false; return false;
} }
@ -965,7 +800,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
{ {
var i, len; var i, len;
if(typeof sel === "undefined") if(sel === undefined)
{ {
return null; return null;
} }
@ -1109,7 +944,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
//No support for localstorage? Bail out early //No support for localstorage? Bail out early
if(typeof localStorage === "undefined" || typeof JSON === "undefined") if(localStorage === undefined || JSON === undefined)
{ {
return null; return null;
} }

29
kis-lite-dom-min.js vendored
View File

@ -1,14 +1,15 @@
(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]: (function(d){if(document.querySelector!==d){var e,g,a,b;e=function(c){b=c===d?e.el!==d?e.el:document.documentElement:g(c);e.prototype.el=b;c=a(e);for(var h in c)"object"===typeof c[h]&&(c[h].el=b);c.el=b;return c};g=function(c,b){var a;if("string"!=typeof c||c===d)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(a!==d){if(Object.create!==d)return Object.create(a);
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;d<g;d++)e=b.item(d)?b.item(d):b[d],a.call(e,e)}else a.call(b,b)});d.type=function(a){return function(){return a&& b=typeof a;if(!("object"!==b&&"function"!==b))return b=function(){},b.prototype=a,new b}};e.ext=function(a,d){d.el=b;e[a]=d};e.ext("each",function(a){if(b.length!==d&&b!==window)if(Array.prototype.forEach!==d)[].forEach.call(b,a);else{var h=b.length;if(0!==h)for(var f,e=0;e<h;e++)f=b.item(e)?b.item(e):b[e],a.call(f,f)}else a.call(b,b)});e.type=function(a){return function(){return a&&a!==this}.call(a)?(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};e=window.$_=
a!==this}.call(a)?(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};d=window.$_=window.$_||d;d.$=f}})();"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});"undefined"===typeof Array.isArray&&(Array.isArray=function(d){return"[object Array]"===Object.prototype.toString.apply(d)}); window.$_||e;e.$=g}})();"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});"undefined"===typeof Array.isArray&&(Array.isArray=function(d){return"[object Array]"===Object.prototype.toString.apply(d)});
(function(){if("undefined"!==typeof window.XMLHttpRequest){var d={_do:function(d,a,b,c,g){var e=new XMLHttpRequest;"undefined"===typeof b&&(b=function(){});g=g?"POST":"GET";"GET"===g&&(d+=d.match(/\?/)?this._serialize(a):"?"+this._serialize(a));e.open(g,d);e.onreadystatechange=function(){4===e.readyState&&(200===e.status?b.call(e.responseText,e.responseText):"undefined"!==typeof c&&c.call(e.status,e.status))};"POST"===g?(e.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),e.send(this._serialize(a))): (function(d){if(window.XMLHttpRequest!==d){var e={_do:function(e,a,b,c,h){var f=new XMLHttpRequest;b===d&&(b=function(){});h=h?"POST":"GET";"GET"===h&&(e+=e.match(/\?/)?this._serialize(a):"?"+this._serialize(a));f.open(h,e);f.onreadystatechange=function(){4===f.readyState&&(200===f.status?b.call(f.responseText,f.responseText):c!==d&&c.call(f.status,f.status))};"POST"===h?(f.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),f.send(this._serialize(a))):f.send(null)},_serialize:function(d){var a,
e.send(null)},_serialize:function(d){var a,b,c=[];for(a in d)d.hasOwnProperty(a)&&"function"!==typeof d[a]&&(b=d[a].toString(),a=encodeURIComponent(a),b=encodeURIComponent(b),c.push(a+"="+b));return c.join("&")}};$_.ext("get",function(f,a,b,c){d._do(f,a,b,c,!1)});$_.ext("post",function(f,a,b,c){d._do(f,a,b,c,!0)});$_.ext("sse",function(d,a){var b;"undefined"!==typeof EventSource&&(b=new EventSource(d),b.onmessage=function(b){a.call(b.data,b.data)})})}})(); b,c=[];for(a in d)d.hasOwnProperty(a)&&"function"!==typeof d[a]&&(b=d[a].toString(),a=encodeURIComponent(a),b=encodeURIComponent(b),c.push(a+"="+b));return c.join("&")}};$_.ext("get",function(d,a,b,c){e._do(d,a,b,c,!1)});$_.ext("post",function(d,a,b,c){e._do(d,a,b,c,!0)});$_.ext("sse",function(e,a){var b;EventSource!==d&&(b=new EventSource(e),b.onmessage=function(b){a.call(b.data,b.data)})})}})();
(function(){var d,f;if("undefined"===typeof document.addEventListener)return!1;d=function(a,b,c,g){var e,f;if("undefined"===typeof a)return null;if(b.match(/^([\w\-]+)$/))!0===g?a.addEventListener(b,c,!1):a.removeEventListener(b,c,!1);else{b=b.split(" ");f=b.length;for(e=0;e<f;e++)d(a,b[e],c,g)}};f=function(a,b,c,g){d(a,c,function(c){var d,f;f=$_.$(b,a);for(d in f)c.target==f[d]&&(g.call(f[d],c),c.stopPropagation())},!0)};$_.ext("event",{add:function(a,b){$_.each(function(c){d(c,a,b,!0)})},remove:function(a, (function(d){var e,g;if(document.addEventListener===d)return!1;e=function(a,b,c,h){var f,g;if(a===d)return null;if(b.match(/^([\w\-]+)$/))!0===h?a.addEventListener(b,c,!1):a.removeEventListener(b,c,!1);else{b=b.split(" ");g=b.length;for(f=0;f<g;f++)e(a,b[f],c,h)}};g=function(a,b,c,d){e(a,c,function(c){var e,g;g=$_.$(b,a);for(e in g)c.target==g[e]&&(d.call(g[e],c),c.stopPropagation())},!0)};$_.ext("event",{add:function(a,b){$_.each(function(c){e(c,a,b,!0)})},remove:function(a,b){$_.each(function(c){e(c,
b){$_.each(function(c){d(c,a,b,!1)})},live:function(a,b,c){f(document.documentElement,a,b,c)},delegate:function(a,b,c){$_.each(function(d){f(d,a,b,c)})}})})(); a,b,!1)})},live:function(a,b,c){g(document.documentElement,a,b,c)},delegate:function(a,b,c){$_.each(function(d){g(d,a,b,c)})}})})();
"undefined"!==typeof document&&!("classList"in document.createElement("a"))&&function(d){var d=(d.HTMLElement||d.Element).prototype,f=Object,a=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},b=Array.prototype.indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;return-1},c=function(a,b){this.name=a;this.code=DOMException[a];this.message=b},g=function(a,d){if(""===d)throw new c("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(d))throw new c("INVALID_CHARACTER_ERR", "undefined"!==typeof document&&!("classList"in document.createElement("a"))&&function(d){if("HTMLElement"in d||"Element"in d){d=(d.HTMLElement||d.Element).prototype;var e=Object,g=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},a=Array.prototype.indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;return-1},b=function(a,b){this.name=a;this.code=DOMException[a];this.message=b},c=function(c,d){if(""===d)throw new b("SYNTAX_ERR","An invalid or illegal string was specified");
"String contains an invalid character");return b.call(a,d)},e=function(b){for(var c=a.call(b.className),c=c?c.split(/\s+/):[],d=0,g=c.length;d<g;d++)this.push(c[d]);this._updateClassName=function(){b.className=this.toString()}},h=e.prototype=[],i=function(){return new e(this)};c.prototype=Error.prototype;h.item=function(a){return this[a]||null};h.contains=function(a){return-1!==g(this,a+"")};h.add=function(a){a+="";-1===g(this,a)&&(this.push(a),this._updateClassName())};h.remove=function(a){a=g(this, if(/\s/.test(d))throw new b("INVALID_CHARACTER_ERR","String contains an invalid character");return a.call(c,d)},h=function(a){for(var b=g.call(a.className),b=b?b.split(/\s+/):[],c=0,d=b.length;c<d;c++)this.push(b[c]);this._updateClassName=function(){a.className=this.toString()}},f=h.prototype=[],j=function(){return new h(this)};b.prototype=Error.prototype;f.item=function(a){return this[a]||null};f.contains=function(a){return-1!==c(this,a+"")};f.add=function(){var a=arguments,b=0,d=a.length,e,f=!1;
a+"");-1!==a&&(this.splice(a,1),this._updateClassName())};h.toggle=function(a){a+="";-1===g(this,a)?this.add(a):this.remove(a)};h.toString=function(){return this.join(" ")};if(f.defineProperty){h={get:i,enumerable:!0,configurable:!0};try{f.defineProperty(d,"classList",h)}catch(j){-2146823252===j.number&&(h.enumerable=!1,f.defineProperty(d,"classList",h))}}else f.prototype.__defineGetter__&&d.__defineGetter__("classList",i)}(self); do e=a[b]+"",-1===c(this,e)&&(this.push(e),f=!0);while(++b<d);f&&this._updateClassName()};f.remove=function(){var a=arguments,b=0,d=a.length,e,f=!1;do e=a[b]+"",e=c(this,e),-1!==e&&(this.splice(e,1),f=!0);while(++b<d);f&&this._updateClassName()};f.toggle=function(a,b){a+="";var c=this.contains(a),d=c?!0!==b&&"remove":!1!==b&&"add";if(d)this[d](a);return!c};f.toString=function(){return this.join(" ")};if(e.defineProperty){f={get:j,enumerable:!0,configurable:!0};try{e.defineProperty(d,"classList",f)}catch(k){-2146823252===
(function(){function d(a,b,c){var d,e;"undefined"!==typeof a.hasAttribute?(a.hasAttribute(b)&&(d=a.getAttribute(b)),e=!0):"undefined"!==typeof a[b]?(d=a[b],e=!1):"class"===b&&"undefined"!==typeof a.className&&(b="className",d=a.className,e=!1);if("undefined"===typeof d&&("undefined"===typeof c||null===c))return null;if("undefined"===typeof c)return d;"undefined"!==typeof c&&null!==c?!0===e?a.setAttribute(b,c):a[b]=c:null===c&&(!0===e?a.removeAttribute(b):delete a[b]);return"undefined"!==typeof c? k.number&&(f.enumerable=!1,e.defineProperty(d,"classList",f))}}else e.prototype.__defineGetter__&&d.__defineGetter__("classList",j)}}(self);
c:d}function f(a,b,c){var d,b=b.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")});d={outerHeight:"offsetHeight",outerWidth:"offsetWidth",top:"posTop"};if("undefined"===typeof c&&"undefined"!==a.style[b])return a.style[b];if("undefined"===typeof c&&"undefined"!==a.style[d[b]])return a.style[d[b]];if("undefined"!==typeof a.style[b])return a.style[b]=c,null;if(a.style[d[b]])return a.style[d[b]]=c,null}$_.ext("dom",{addClass:function(a){$_.each(function(b){b.classList.add(a)})}, (function(d){function e(a,b,c){var e,f;a.hasAttribute!==d?(a.hasAttribute(b)&&(e=a.getAttribute(b)),f=!0):a[b]!==d?(e=a[b],f=!1):"class"===b&&a.className!==d&&(b="className",e=a.className,f=!1);if(e===d&&(c===d||null===c))return null;if(c===d)return e;c!==d&&null!==c?!0===f?a.setAttribute(b,c):a[b]=c:null===c&&(!0===f?a.removeAttribute(b):delete a[b]);return c!==d?c:e}function g(a,b,c){var e;b=b.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")});e={outerHeight:"offsetHeight",
removeClass:function(a){$_.each(function(b){b.classList.remove(a)})},hide:function(){this.css("display","none")},show:function(a){"undefined"===typeof a&&(a="block");this.css("display",a)},attr:function(a,b){var c=this.el;if(1<c.length&&"undefined"===typeof b)return null;if(1<c.length&&"undefined"!==typeof b)$_.each(function(c){return d(c,a,b)});else return d(c,a,b)},text:function(a){var b,c;c=this.el;b=c.textContent;return"undefined"!==typeof a?c.textContent=a:b},css:function(a,b){if("undefined"=== outerWidth:"offsetWidth",top:"posTop"};if(c===d&&a.style[b]!==d)return a.style[b];if(c===d&&a.style[e[b]]!==d)return a.style[e[b]];if(a.style[b]!==d)return a.style[b]=c,null;if(a.style[e[b]])return a.style[e[b]]=c,null}$_.ext("dom",{addClass:function(a){$_.each(function(){this.classList.add(a)})},removeClass:function(a){$_.each(function(b){b.classList.remove(a)})},hide:function(){this.css("display","none")},show:function(a){a===d&&(a="block");this.css("display",a)},attr:function(a,b){var c=this.el;
typeof b)return f(this.el,a);$_.each(function(c){f(c,a,b)})},append:function(a){"undefined"!==typeof document.insertAdjacentHTML?this.el.insertAdjacentHTML("beforeend",a):this.el.innerHTML+=a},prepend:function(a){"undefined"!==typeof document.insertAdjacentHTML?this.el.insertAdjacentHTML("afterbegin",a):this.el.innerHTML=a+this.el.innerHTML},html:function(a){"undefined"!==typeof a&&(this.el.innerHTML=a);return this.el.innerHTML}})})(); if(1<c.length&&b===d)return null;if(1<c.length&&b!==d)$_.each(function(c){return e(c,a,b)});else return e(c,a,b)},text:function(a){var b,c,e;e=this.el;c=a!==d?!0:!1;b=e.textContent;return c?e.textContent=a:b},css:function(a,b){if(b===d)return g(this.el,a);$_.each(function(c){g(c,a,b)})},append:function(a){document.insertAdjacentHTML!==d?this.el.insertAdjacentHTML("beforeend",a):this.el.innerHTML+=a},prepend:function(a){document.insertAdjacentHTML!==d?this.el.insertAdjacentHTML("afterbegin",a):this.el.innerHTML=
a+this.el.innerHTML},html:function(a){a!==d&&(this.el.innerHTML=a);return this.el.innerHTML}})})();

View File

@ -2,9 +2,9 @@
Kis JS Keep It Simple JS Library Kis JS Keep It Simple JS Library
Copyright Timothy J. Warren Copyright Timothy J. Warren
License Public Domain License Public Domain
Version 0.7.0 Version 0.8.0
*/ */
(function (){ (function (undefined){
"use strict"; "use strict";
@ -14,7 +14,7 @@
// selector engine. I choose to just use the // selector engine. I choose to just use the
// browser feature, since it is present in // browser feature, since it is present in
// IE 8+, and all other major browsers // IE 8+, and all other major browsers
if (typeof document.querySelector === "undefined") if (document.querySelector === undefined)
{ {
return; return;
} }
@ -35,10 +35,10 @@
$_ = function(s) $_ = function(s)
{ {
// Have documentElement be default selector, just in case // Have documentElement be default selector, just in case
if (typeof s === "undefined") if (s === undefined)
{ {
// Defines a "global" selector for that instance // Defines a "global" selector for that instance
sel = (typeof $_.el !== "undefined") sel = ($_.el !== undefined)
? $_.el ? $_.el
: document.documentElement; : document.documentElement;
} }
@ -80,7 +80,7 @@
{ {
var x, c; var x, c;
if (typeof a != "string" || typeof a === "undefined"){ return a;} if (typeof a != "string" || a === undefined){ return a;}
//Check for a context of a specific element, otherwise, just run on the document //Check for a context of a specific element, otherwise, just run on the document
c = (context != null && context.nodeType === 1) c = (context != null && context.nodeType === 1)
@ -113,12 +113,12 @@
{ {
var type, F; var type, F;
if(typeof obj === "undefined") if(obj === undefined)
{ {
return; return;
} }
if(typeof Object.create !== "undefined") if(Object.create !== undefined)
{ {
return Object.create(obj); return Object.create(obj);
} }
@ -162,10 +162,10 @@
*/ */
$_.ext('each', function (callback) $_.ext('each', function (callback)
{ {
if(typeof sel.length !== "undefined" && sel !== window) if(sel.length !== undefined && sel !== window)
{ {
// Use the native method, if it exists // Use the native method, if it exists
if(typeof Array.prototype.forEach !== 'undefined') if(Array.prototype.forEach !== undefined)
{ {
[].forEach.call(sel, callback); [].forEach.call(sel, callback);
return; return;
@ -258,12 +258,12 @@ if (typeof Array.isArray === "undefined")
* *
* Module for making ajax requests * Module for making ajax requests
*/ */
(function (){ (function (undefined){
"use strict"; "use strict";
// Don't bother even defining the object if the XMLHttpRequest isn't available // Don't bother even defining the object if the XMLHttpRequest isn't available
if(typeof window.XMLHttpRequest === "undefined") if(window.XMLHttpRequest === undefined)
{ {
return; return;
} }
@ -274,7 +274,7 @@ if (typeof Array.isArray === "undefined")
var type, var type,
request = new XMLHttpRequest(); request = new XMLHttpRequest();
if (typeof success_callback === "undefined") if (success_callback === undefined)
{ {
/** /**
* @private * @private
@ -303,7 +303,7 @@ if (typeof Array.isArray === "undefined")
} }
else else
{ {
if (typeof error_callback !== 'undefined') if (error_callback !== undefined)
{ {
error_callback.call(request.status, request.status); error_callback.call(request.status, request.status);
} }
@ -395,7 +395,7 @@ if (typeof Array.isArray === "undefined")
var source; var source;
// Check for server-sent event support // Check for server-sent event support
if (typeof EventSource !== 'undefined') if (EventSource !== undefined)
{ {
source = new EventSource(url); source = new EventSource(url);
@ -416,14 +416,14 @@ if (typeof Array.isArray === "undefined")
* Event api wrapper * Event api wrapper
* @todo Add method for triggering events * @todo Add method for triggering events
*/ */
(function (){ (function (undefined){
"use strict"; "use strict";
var _add_remove, e, _attach_delegate; var _add_remove, e, _attach_delegate;
// Don't bother defining the methods if event api isn't supports // Don't bother defining the methods if event api isn't supports
if (typeof document.addEventListener === "undefined") if (document.addEventListener === undefined)
{ {
return false; return false;
} }
@ -432,7 +432,7 @@ if (typeof Array.isArray === "undefined")
{ {
var i, len; var i, len;
if(typeof sel === "undefined") if(sel === undefined)
{ {
return null; return null;
} }
@ -569,177 +569,15 @@ if (typeof Array.isArray === "undefined")
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
//This is used so IE can use the classList api //This is used so IE can use the classList api
/* /*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js*/
* classList.js: Cross-browser full element.classList implementation. if(typeof document!=="undefined"&&!("classList" in document.createElement("a"))){(function(j){if(!("HTMLElement" in j)&&!("Element" in j)){return}var a="classList",f="prototype",m=(j.HTMLElement||j.Element)[f],b=Object,k=String[f].trim||function(){return this.replace(/^\s+|\s+$/g,"")},c=Array[f].indexOf||function(q){var p=0,o=this.length;for(;p<o;p++){if(p in this&&this[p]===q){return p}}return -1},n=function(o,p){this.name=o;this.code=DOMException[o];this.message=p},g=function(p,o){if(o===""){throw new n("SYNTAX_ERR","An invalid or illegal string was specified")}if(/\s/.test(o)){throw new n("INVALID_CHARACTER_ERR","String contains an invalid character")}return c.call(p,o)},d=function(s){var r=k.call(s.className),q=r?r.split(/\s+/):[],p=0,o=q.length;for(;p<o;p++){this.push(q[p])}this._updateClassName=function(){s.className=this.toString()}},e=d[f]=[],i=function(){return new d(this)};n[f]=Error[f];e.item=function(o){return this[o]||null};e.contains=function(o){o+="";return g(this,o)!==-1};e.add=function(){var s=arguments,r=0,p=s.length,q,o=false;do{q=s[r]+"";if(g(this,q)===-1){this.push(q);o=true}}while(++r<p);if(o){this._updateClassName()}};e.remove=function(){var t=arguments,s=0,p=t.length,r,o=false;do{r=t[s]+"";var q=g(this,r);if(q!==-1){this.splice(q,1);o=true}}while(++s<p);if(o){this._updateClassName()}};e.toggle=function(p,q){p+="";var o=this.contains(p),r=o?q!==true&&"remove":q!==false&&"add";if(r){this[r](p)}return !o};e.toString=function(){return this.join(" ")};if(b.defineProperty){var l={get:i,enumerable:true,configurable:true};try{b.defineProperty(m,a,l)}catch(h){if(h.number===-2146823252){l.enumerable=false;b.defineProperty(m,a,l)}}}else{if(b[f].__defineGetter__){m.__defineGetter__(a,i)}}}(self))};
* 2011-06-15
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
if (typeof document !== "undefined" && !("classList" in document.createElement("a")))
{
(function (view){
var classListProp = "classList",
protoProp = "prototype",
elemCtrProto = (view.HTMLElement || view.Element)[protoProp],
objCtr = Object,
strTrim = String[protoProp].trim ||
function ()
{
return this.replace(/^\s+|\s+$/g, "");
},
arrIndexOf = Array[protoProp].indexOf ||
function (item)
{
var
i = 0,
len = this.length;
for (; i < len; i++)
{
if (i in this && this[i] === item)
{
return i;
}
}
return -1;
}
// Vendors: please allow content code to instantiate DOMExceptions
,
/**
* @private
*/
DOMEx = function (type, message)
{
this.name = type;
this.code = DOMException[type];
this.message = message;
},
/**
* @private
*/
checkTokenAndGetIndex = function (classList, token)
{
if (token === "")
{
throw new DOMEx("SYNTAX_ERR", "An invalid or illegal string was specified");
}
if (/\s/.test(token))
{
throw new DOMEx("INVALID_CHARACTER_ERR", "String contains an invalid character");
}
return arrIndexOf.call(classList, token);
},
/**
* @private
*/
ClassList = function (elem)
{
var
trimmedClasses = strTrim.call(elem.className),
classes = trimmedClasses ? trimmedClasses.split(/\s+/) : [],
i = 0,
len = classes.length;
for (; i < len; i++)
{
this.push(classes[i]);
}
this._updateClassName = function ()
{
elem.className = this.toString();
};
},
classListProto = ClassList[protoProp] = [],
/**
* @private
*/
classListGetter = function ()
{
return new ClassList(this);
};
// Most DOMException implementations don't allow calling DOMException's toString()
// on non-DOMExceptions. Error's toString() is sufficient here.
DOMEx[protoProp] = Error[protoProp];
classListProto.item = function (i)
{
return this[i] || null;
};
classListProto.contains = function (token)
{
token += "";
return checkTokenAndGetIndex(this, token) !== -1;
};
classListProto.add = function (token)
{
token += "";
if (checkTokenAndGetIndex(this, token) === -1)
{
this.push(token);
this._updateClassName();
}
};
classListProto.remove = function (token)
{
token += "";
var index = checkTokenAndGetIndex(this, token);
if (index !== -1)
{
this.splice(index, 1);
this._updateClassName();
}
};
classListProto.toggle = function (token)
{
token += "";
if (checkTokenAndGetIndex(this, token) === -1)
{
this.add(token);
}
else
{
this.remove(token);
}
};
classListProto.toString = function ()
{
return this.join(" ");
};
if (objCtr.defineProperty)
{
var classListPropDesc = {
get: classListGetter,
enumerable: true,
configurable: true
};
try
{
objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
}
catch (ex)
{ // IE 8 doesn't support enumerable:true
if (ex.number === -0x7FF5EC54)
{
classListPropDesc.enumerable = false;
objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
}
}
}
else if (objCtr[protoProp].__defineGetter__)
{
elemCtrProto.__defineGetter__(classListProp, classListGetter);
}
}(self));
}
/** /**
* DOM * DOM
* *
* Dom manipulation module * Dom manipulation module
*/ */
(function (){ (function (undefined){
"use strict"; "use strict";
@ -751,7 +589,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
var oldVal, doAttr; var oldVal, doAttr;
//Get the value of the attribute, if it exists //Get the value of the attribute, if it exists
if (typeof sel.hasAttribute !== "undefined") if (sel.hasAttribute !== undefined)
{ {
if (sel.hasAttribute(name)) if (sel.hasAttribute(name))
{ {
@ -760,12 +598,12 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
doAttr = true; doAttr = true;
} }
else if (typeof sel[name] !== "undefined") else if (sel[name] !== undefined)
{ {
oldVal = sel[name]; oldVal = sel[name];
doAttr = false; doAttr = false;
} }
else if (name === "class" && typeof sel.className !== "undefined") //className attribute else if (name === "class" && sel.className !== undefined) //className attribute
{ {
name = "className"; name = "className";
oldVal = sel.className; oldVal = sel.className;
@ -773,22 +611,19 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
} }
//Well, I guess that attribute doesn't exist //Well, I guess that attribute doesn't exist
if (typeof oldVal === "undefined" && (typeof value === "undefined" || value === null)) if (oldVal === undefined && (value === undefined || value === null))
{ {
/*console.log(value);
console.log(sel);
console.log("Element does not have the selected attribute");*/
return null; return null;
} }
//No value to set? Return the current value //No value to set? Return the current value
if (typeof value === "undefined") if (value === undefined)
{ {
return oldVal; return oldVal;
} }
//Determine what to do with the attribute //Determine what to do with the attribute
if (typeof value !== "undefined" && value !== null) if (value !== undefined && value !== null)
{ {
if(doAttr === true) if(doAttr === true)
{ {
@ -811,7 +646,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
} }
} }
return (typeof value !== "undefined") ? value : oldVal; return (value !== undefined) ? value : oldVal;
} }
/** /**
@ -841,17 +676,17 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
//If you don't define a value, try returning the existing value //If you don't define a value, try returning the existing value
if(typeof val === "undefined" && sel.style[prop] !== "undefined") if(val === undefined && sel.style[prop] !== undefined)
{ {
return sel.style[prop]; return sel.style[prop];
} }
else if(typeof val === "undefined" && sel.style[equi[prop]] !== "undefined") else if(val === undefined && sel.style[equi[prop]] !== undefined)
{ {
return sel.style[equi[prop]]; return sel.style[equi[prop]];
} }
//Let's try the easy way first //Let's try the easy way first
if(typeof sel.style[prop] !== "undefined") if(sel.style[prop] !== undefined)
{ {
sel.style[prop] = val; sel.style[prop] = val;
@ -888,7 +723,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
addClass: function (c) addClass: function (c)
{ {
$_.each(function (e){ $_.each(function (e){
e.classList.add(c); this.classList.add(c);
}); });
}, },
/** /**
@ -930,7 +765,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
*/ */
show: function (type) show: function (type)
{ {
if (typeof type === "undefined") if (type === undefined)
{ {
type = "block"; type = "block";
} }
@ -956,11 +791,11 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
var sel = this.el; var sel = this.el;
//Make sure you don't try to get a bunch of elements //Make sure you don't try to get a bunch of elements
if (sel.length > 1 && typeof value === "undefined") if (sel.length > 1 && value === undefined)
{ {
return null; return null;
} }
else if (sel.length > 1 && typeof value !== "undefined") //You can set a bunch, though else if (sel.length > 1 && value !== undefined) //You can set a bunch, though
{ {
$_.each(function (e){ $_.each(function (e){
return _attr(e, name, value); return _attr(e, name, value);
@ -990,7 +825,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
sel = this.el; sel = this.el;
set = (typeof value !== "undefined") ? true : false; set = (value !== undefined) ? true : false;
oldValue = sel.textContent; oldValue = sel.textContent;
@ -1022,7 +857,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
css: function (prop, val) css: function (prop, val)
{ {
//Return the current value if a value is not set //Return the current value if a value is not set
if(typeof val === "undefined") if(val === undefined)
{ {
return _css(this.el, prop); return _css(this.el, prop);
} }
@ -1042,7 +877,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
*/ */
append: function(htm) append: function(htm)
{ {
if(typeof document.insertAdjacentHTML !== "undefined") if(document.insertAdjacentHTML !== undefined)
{ {
this.el.insertAdjacentHTML('beforeend', htm); this.el.insertAdjacentHTML('beforeend', htm);
} }
@ -1061,7 +896,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
*/ */
prepend: function(htm) prepend: function(htm)
{ {
if(typeof document.insertAdjacentHTML !== "undefined") if(document.insertAdjacentHTML !== undefined)
{ {
this.el.insertAdjacentHTML('afterbegin', htm); this.el.insertAdjacentHTML('afterbegin', htm);
} }
@ -1083,7 +918,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
html: function(htm) html: function(htm)
{ {
if(typeof htm !== "undefined") if(htm !== undefined)
{ {
this.el.innerHTML = htm; this.el.innerHTML = htm;
} }

14
kis-lite-min.js vendored
View File

@ -1,7 +1,7 @@
(function(){if("undefined"!==typeof document.querySelector){var d,f,c,a;d=function(b){a="undefined"===typeof b?"undefined"!==typeof d.el?d.el:document.documentElement:f(b);d.prototype.el=a;var b=c(d),g;for(g in b)"object"===typeof b[g]&&(b[g].el=a);b.el=a;return b};f=function(b,a){var c;if("string"!=typeof b||"undefined"===typeof b)return b;c=null!=a&&1===a.nodeType?a:document;if(b.match(/^#([\w\-]+$)/))return document.getElementById(b.split("#")[1]);c=c.querySelectorAll(b);return 1===c.length?c[0]: (function(f){if(document.querySelector!==f){var e,d,c,a;e=function(b){a=b===f?e.el!==f?e.el:document.documentElement:d(b);e.prototype.el=a;b=c(e);for(var h in b)"object"===typeof b[h]&&(b[h].el=a);b.el=a;return b};d=function(b,a){var c;if("string"!=typeof b||b===f)return b;c=null!=a&&1===a.nodeType?a:document;if(b.match(/^#([\w\-]+$)/))return document.getElementById(b.split("#")[1]);c=c.querySelectorAll(b);return 1===c.length?c[0]:c};c=function(b){var a;if(b!==f){if(Object.create!==f)return Object.create(b);
c};c=function(b){var a;if("undefined"!==typeof b){if("undefined"!==typeof Object.create)return Object.create(b);a=typeof b;if(!("object"!==a&&"function"!==a))return a=function(){},a.prototype=b,new a}};d.ext=function(b,c){c.el=a;d[b]=c};d.ext("each",function(b){if("undefined"!==typeof a.length&&a!==window)if("undefined"!==typeof Array.prototype.forEach)[].forEach.call(a,b);else{var c=a.length;if(0!==c)for(var e,d=0;d<c;d++)e=a.item(d)?a.item(d):a[d],b.call(e,e)}else b.call(a,a)});d.type=function(a){return function(){return a&& a=typeof b;if(!("object"!==a&&"function"!==a))return a=function(){},a.prototype=b,new a}};e.ext=function(b,c){c.el=a;e[b]=c};e.ext("each",function(b){if(a.length!==f&&a!==window)if(Array.prototype.forEach!==f)[].forEach.call(a,b);else{var c=a.length;if(0!==c)for(var g,d=0;d<c;d++)g=a.item(d)?a.item(d):a[d],b.call(g,g)}else b.call(a,a)});e.type=function(a){return function(){return a&&a!==this}.call(a)?(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};e=window.$_=
a!==this}.call(a)?(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};d=window.$_=window.$_||d;d.$=f}})();"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});"undefined"===typeof Array.isArray&&(Array.isArray=function(d){return"[object Array]"===Object.prototype.toString.apply(d)}); window.$_||e;e.$=d}})();"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});"undefined"===typeof Array.isArray&&(Array.isArray=function(f){return"[object Array]"===Object.prototype.toString.apply(f)});
(function(){if("undefined"!==typeof window.XMLHttpRequest){var d={_do:function(d,c,a,b,g){var e=new XMLHttpRequest;"undefined"===typeof a&&(a=function(){});g=g?"POST":"GET";"GET"===g&&(d+=d.match(/\?/)?this._serialize(c):"?"+this._serialize(c));e.open(g,d);e.onreadystatechange=function(){4===e.readyState&&(200===e.status?a.call(e.responseText,e.responseText):"undefined"!==typeof b&&b.call(e.status,e.status))};"POST"===g?(e.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),e.send(this._serialize(c))): (function(f){if(window.XMLHttpRequest!==f){var e={_do:function(d,c,a,b,e){var g=new XMLHttpRequest;a===f&&(a=function(){});e=e?"POST":"GET";"GET"===e&&(d+=d.match(/\?/)?this._serialize(c):"?"+this._serialize(c));g.open(e,d);g.onreadystatechange=function(){4===g.readyState&&(200===g.status?a.call(g.responseText,g.responseText):b!==f&&b.call(g.status,g.status))};"POST"===e?(g.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),g.send(this._serialize(c))):g.send(null)},_serialize:function(d){var c,
e.send(null)},_serialize:function(d){var c,a,b=[];for(c in d)d.hasOwnProperty(c)&&"function"!==typeof d[c]&&(a=d[c].toString(),c=encodeURIComponent(c),a=encodeURIComponent(a),b.push(c+"="+a));return b.join("&")}};$_.ext("get",function(f,c,a,b){d._do(f,c,a,b,!1)});$_.ext("post",function(f,c,a,b){d._do(f,c,a,b,!0)});$_.ext("sse",function(d,c){var a;"undefined"!==typeof EventSource&&(a=new EventSource(d),a.onmessage=function(a){c.call(a.data,a.data)})})}})(); a,b=[];for(c in d)d.hasOwnProperty(c)&&"function"!==typeof d[c]&&(a=d[c].toString(),c=encodeURIComponent(c),a=encodeURIComponent(a),b.push(c+"="+a));return b.join("&")}};$_.ext("get",function(d,c,a,b){e._do(d,c,a,b,!1)});$_.ext("post",function(d,c,a,b){e._do(d,c,a,b,!0)});$_.ext("sse",function(d,c){var a;EventSource!==f&&(a=new EventSource(d),a.onmessage=function(a){c.call(a.data,a.data)})})}})();
(function(){var d,f;if("undefined"===typeof document.addEventListener)return!1;d=function(c,a,b,g){var e,f;if("undefined"===typeof c)return null;if(a.match(/^([\w\-]+)$/))!0===g?c.addEventListener(a,b,!1):c.removeEventListener(a,b,!1);else{a=a.split(" ");f=a.length;for(e=0;e<f;e++)d(c,a[e],b,g)}};f=function(c,a,b,g){d(c,b,function(b){var d,f;f=$_.$(a,c);for(d in f)b.target==f[d]&&(g.call(f[d],b),b.stopPropagation())},!0)};$_.ext("event",{add:function(c,a){$_.each(function(b){d(b,c,a,!0)})},remove:function(c, (function(f){var e,d;if(document.addEventListener===f)return!1;e=function(c,a,b,d){var g,j;if(c===f)return null;if(a.match(/^([\w\-]+)$/))!0===d?c.addEventListener(a,b,!1):c.removeEventListener(a,b,!1);else{a=a.split(" ");j=a.length;for(g=0;g<j;g++)e(c,a[g],b,d)}};d=function(c,a,b,d){e(c,b,function(b){var e,f;f=$_.$(a,c);for(e in f)b.target==f[e]&&(d.call(f[e],b),b.stopPropagation())},!0)};$_.ext("event",{add:function(c,a){$_.each(function(b){e(b,c,a,!0)})},remove:function(c,a){$_.each(function(b){e(b,
a){$_.each(function(b){d(b,c,a,!1)})},live:function(c,a,b){f(document.documentElement,c,a,b)},delegate:function(c,a,b){$_.each(function(d){f(d,c,a,b)})}})})(); c,a,!1)})},live:function(c,a,b){d(document.documentElement,c,a,b)},delegate:function(c,a,b){$_.each(function(e){d(e,c,a,b)})}})})();

View File

@ -2,9 +2,9 @@
Kis JS Keep It Simple JS Library Kis JS Keep It Simple JS Library
Copyright Timothy J. Warren Copyright Timothy J. Warren
License Public Domain License Public Domain
Version 0.7.0 Version 0.8.0
*/ */
(function (){ (function (undefined){
"use strict"; "use strict";
@ -14,7 +14,7 @@
// selector engine. I choose to just use the // selector engine. I choose to just use the
// browser feature, since it is present in // browser feature, since it is present in
// IE 8+, and all other major browsers // IE 8+, and all other major browsers
if (typeof document.querySelector === "undefined") if (document.querySelector === undefined)
{ {
return; return;
} }
@ -35,10 +35,10 @@
$_ = function(s) $_ = function(s)
{ {
// Have documentElement be default selector, just in case // Have documentElement be default selector, just in case
if (typeof s === "undefined") if (s === undefined)
{ {
// Defines a "global" selector for that instance // Defines a "global" selector for that instance
sel = (typeof $_.el !== "undefined") sel = ($_.el !== undefined)
? $_.el ? $_.el
: document.documentElement; : document.documentElement;
} }
@ -80,7 +80,7 @@
{ {
var x, c; var x, c;
if (typeof a != "string" || typeof a === "undefined"){ return a;} if (typeof a != "string" || a === undefined){ return a;}
//Check for a context of a specific element, otherwise, just run on the document //Check for a context of a specific element, otherwise, just run on the document
c = (context != null && context.nodeType === 1) c = (context != null && context.nodeType === 1)
@ -113,12 +113,12 @@
{ {
var type, F; var type, F;
if(typeof obj === "undefined") if(obj === undefined)
{ {
return; return;
} }
if(typeof Object.create !== "undefined") if(Object.create !== undefined)
{ {
return Object.create(obj); return Object.create(obj);
} }
@ -162,10 +162,10 @@
*/ */
$_.ext('each', function (callback) $_.ext('each', function (callback)
{ {
if(typeof sel.length !== "undefined" && sel !== window) if(sel.length !== undefined && sel !== window)
{ {
// Use the native method, if it exists // Use the native method, if it exists
if(typeof Array.prototype.forEach !== 'undefined') if(Array.prototype.forEach !== undefined)
{ {
[].forEach.call(sel, callback); [].forEach.call(sel, callback);
return; return;
@ -258,12 +258,12 @@ if (typeof Array.isArray === "undefined")
* *
* Module for making ajax requests * Module for making ajax requests
*/ */
(function (){ (function (undefined){
"use strict"; "use strict";
// Don't bother even defining the object if the XMLHttpRequest isn't available // Don't bother even defining the object if the XMLHttpRequest isn't available
if(typeof window.XMLHttpRequest === "undefined") if(window.XMLHttpRequest === undefined)
{ {
return; return;
} }
@ -274,7 +274,7 @@ if (typeof Array.isArray === "undefined")
var type, var type,
request = new XMLHttpRequest(); request = new XMLHttpRequest();
if (typeof success_callback === "undefined") if (success_callback === undefined)
{ {
/** /**
* @private * @private
@ -303,7 +303,7 @@ if (typeof Array.isArray === "undefined")
} }
else else
{ {
if (typeof error_callback !== 'undefined') if (error_callback !== undefined)
{ {
error_callback.call(request.status, request.status); error_callback.call(request.status, request.status);
} }
@ -395,7 +395,7 @@ if (typeof Array.isArray === "undefined")
var source; var source;
// Check for server-sent event support // Check for server-sent event support
if (typeof EventSource !== 'undefined') if (EventSource !== undefined)
{ {
source = new EventSource(url); source = new EventSource(url);
@ -416,14 +416,14 @@ if (typeof Array.isArray === "undefined")
* Event api wrapper * Event api wrapper
* @todo Add method for triggering events * @todo Add method for triggering events
*/ */
(function (){ (function (undefined){
"use strict"; "use strict";
var _add_remove, e, _attach_delegate; var _add_remove, e, _attach_delegate;
// Don't bother defining the methods if event api isn't supports // Don't bother defining the methods if event api isn't supports
if (typeof document.addEventListener === "undefined") if (document.addEventListener === undefined)
{ {
return false; return false;
} }
@ -432,7 +432,7 @@ if (typeof Array.isArray === "undefined")
{ {
var i, len; var i, len;
if(typeof sel === "undefined") if(sel === undefined)
{ {
return null; return null;
} }

34
kis-min.js vendored
View File

@ -1,17 +1,17 @@
(function(){if("undefined"!==typeof document.querySelector){var d,j,m,e;d=function(g){e="undefined"===typeof g?"undefined"!==typeof d.el?d.el:document.documentElement:j(g);d.prototype.el=e;var g=m(d),i;for(i in g)"object"===typeof g[i]&&(g[i].el=e);g.el=e;return g};j=function(g,d){var e;if("string"!=typeof g||"undefined"===typeof g)return g;e=null!=d&&1===d.nodeType?d:document;if(g.match(/^#([\w\-]+$)/))return document.getElementById(g.split("#")[1]);e=e.querySelectorAll(g);return 1===e.length?e[0]: (function(g){if(document.querySelector!==g){var c,n,r,f;c=function(k){f=k===g?c.el!==g?c.el:document.documentElement:n(k);c.prototype.el=f;k=r(c);for(var j in k)"object"===typeof k[j]&&(k[j].el=f);k.el=f;return k};n=function(c,j){var f;if("string"!=typeof c||c===g)return c;f=null!=j&&1===j.nodeType?j:document;if(c.match(/^#([\w\-]+$)/))return document.getElementById(c.split("#")[1]);f=f.querySelectorAll(c);return 1===f.length?f[0]:f};r=function(c){var f;if(c!==g){if(Object.create!==g)return Object.create(c);
e};m=function(d){var e;if("undefined"!==typeof d){if("undefined"!==typeof Object.create)return Object.create(d);e=typeof d;if(!("object"!==e&&"function"!==e))return e=function(){},e.prototype=d,new e}};d.ext=function(g,i){i.el=e;d[g]=i};d.ext("each",function(d){if("undefined"!==typeof e.length&&e!==window)if("undefined"!==typeof Array.prototype.forEach)[].forEach.call(e,d);else{var i=e.length;if(0!==i)for(var j,l=0;l<i;l++)j=e.item(l)?e.item(l):e[l],d.call(j,j)}else d.call(e,e)});d.type=function(d){return function(){return d&& f=typeof c;if(!("object"!==f&&"function"!==f))return f=function(){},f.prototype=c,new f}};c.ext=function(g,j){j.el=f;c[g]=j};c.ext("each",function(c){if(f.length!==g&&f!==window)if(Array.prototype.forEach!==g)[].forEach.call(f,c);else{var j=f.length;if(0!==j)for(var n,m=0;m<j;m++)n=f.item(m)?f.item(m):f[m],c.call(n,n)}else c.call(f,f)});c.type=function(c){return function(){return c&&c!==this}.call(c)?(typeof c).toLowerCase():{}.toString.call(c).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};c=window.$_=
d!==this}.call(d)?(typeof d).toLowerCase():{}.toString.call(d).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};d=window.$_=window.$_||d;d.$=j}})();"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});"undefined"===typeof Array.isArray&&(Array.isArray=function(d){return"[object Array]"===Object.prototype.toString.apply(d)}); window.$_||c;c.$=n}})();"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});"undefined"===typeof Array.isArray&&(Array.isArray=function(g){return"[object Array]"===Object.prototype.toString.apply(g)});
(function(d){function j(a,b,c){var f,d;"undefined"!==typeof a.hasAttribute?(a.hasAttribute(b)&&(f=a.getAttribute(b)),d=!0):"undefined"!==typeof a[b]?(f=a[b],d=!1):"class"===b&&"undefined"!==typeof a.className&&(b="className",f=a.className,d=!1);if("undefined"===typeof f&&("undefined"===typeof c||null===c))return null;if("undefined"===typeof c)return f;"undefined"!==typeof c&&null!==c?!0===d?a.setAttribute(b,c):a[b]=c:null===c&&(!0===d?a.removeAttribute(b):delete a[b]);return"undefined"!==typeof c? (function(g,c){function n(a,b,d){var e,l;a.hasAttribute!==c?(a.hasAttribute(b)&&(e=a.getAttribute(b)),l=!0):a[b]!==c?(e=a[b],l=!1):"class"===b&&a.className!==c&&(b="className",e=a.className,l=!1);if(e===c&&(d===c||null===d))return null;if(d===c)return e;d!==c&&null!==d?!0===l?a.setAttribute(b,d):a[b]=d:null===d&&(!0===l?a.removeAttribute(b):delete a[b]);return d!==c?d:e}function r(a,b,d){var e;b=b.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")});e={outerHeight:"offsetHeight",
c:f}function m(a,b,c){var f,b=b.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")});f={outerHeight:"offsetHeight",outerWidth:"offsetWidth",top:"posTop"};if("undefined"===typeof c&&"undefined"!==a.style[b])return a.style[b];if("undefined"===typeof c&&"undefined"!==a.style[f[b]])return a.style[f[b]];if("undefined"!==typeof a.style[b])return a.style[b]=c,null;if(a.style[f[b]])return a.style[f[b]]=c,null}if("undefined"!==typeof document&&!("classList"in document.createElement("a"))){var e= outerWidth:"offsetWidth",top:"posTop"};if(d===c&&a.style[b]!==c)return a.style[b];if(d===c&&a.style[e[b]]!==c)return a.style[e[b]];if(a.style[b]!==c)return a.style[b]=d,null;if(a.style[e[b]])return a.style[e[b]]=d,null}if("undefined"!==typeof document&&!("classList"in document.createElement("a"))&&("HTMLElement"in self||"Element"in self)){var f=(self.HTMLElement||self.Element).prototype,k=Object,j=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},B=Array.prototype.indexOf||function(a){for(var b=
(self.HTMLElement||self.Element).prototype,g=Object,i=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=Array.prototype.indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;return-1},l=function(a,b){this.name=a;this.code=DOMException[a];this.message=b},s=function(a,b){if(""===b)throw new l("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(b))throw new l("INVALID_CHARACTER_ERR","String contains an invalid character"); 0,d=this.length;b<d;b++)if(b in this&&this[b]===a)return b;return-1},m=function(a,b){this.name=a;this.code=DOMException[a];this.message=b},v=function(a,b){if(""===b)throw new m("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(b))throw new m("INVALID_CHARACTER_ERR","String contains an invalid character");return B.call(a,b)},x=function(a){for(var b=j.call(a.className),b=b?b.split(/\s+/):[],d=0,e=b.length;d<e;d++)this.push(b[d]);this._updateClassName=function(){a.className=this.toString()}},
return y.call(a,b)},u=function(a){for(var b=i.call(a.className),b=b?b.split(/\s+/):[],c=0,f=b.length;c<f;c++)this.push(b[c]);this._updateClassName=function(){a.className=this.toString()}},k=u.prototype=[],v=function(){return new u(this)};l.prototype=Error.prototype;k.item=function(a){return this[a]||null};k.contains=function(a){return-1!==s(this,a+"")};k.add=function(a){a+="";-1===s(this,a)&&(this.push(a),this._updateClassName())};k.remove=function(a){a=s(this,a+"");-1!==a&&(this.splice(a,1),this._updateClassName())}; p=x.prototype=[],y=function(){return new x(this)};m.prototype=Error.prototype;p.item=function(a){return this[a]||null};p.contains=function(a){return-1!==v(this,a+"")};p.add=function(){var a=arguments,b=0,d=a.length,e,c=!1;do e=a[b]+"",-1===v(this,e)&&(this.push(e),c=!0);while(++b<d);c&&this._updateClassName()};p.remove=function(){var a=arguments,b=0,d=a.length,e,c=!1;do e=a[b]+"",e=v(this,e),-1!==e&&(this.splice(e,1),c=!0);while(++b<d);c&&this._updateClassName()};p.toggle=function(a,b){a+="";var d=
k.toggle=function(a){a+="";-1===s(this,a)?this.add(a):this.remove(a)};k.toString=function(){return this.join(" ")};if(g.defineProperty){k={get:v,enumerable:!0,configurable:!0};try{g.defineProperty(e,"classList",k)}catch(z){-2146823252===z.number&&(k.enumerable=!1,g.defineProperty(e,"classList",k))}}else g.prototype.__defineGetter__&&e.__defineGetter__("classList",v)}d.ext("dom",{addClass:function(a){d.each(function(b){b.classList.add(a)})},removeClass:function(a){d.each(function(b){b.classList.remove(a)})}, this.contains(a),e=d?!0!==b&&"remove":!1!==b&&"add";if(e)this[e](a);return!d};p.toString=function(){return this.join(" ")};if(k.defineProperty){p={get:y,enumerable:!0,configurable:!0};try{k.defineProperty(f,"classList",p)}catch(C){-2146823252===C.number&&(p.enumerable=!1,k.defineProperty(f,"classList",p))}}else k.prototype.__defineGetter__&&f.__defineGetter__("classList",y)}g.ext("dom",{addClass:function(a){g.each(function(){this.classList.add(a)})},removeClass:function(a){g.each(function(b){b.classList.remove(a)})},
hide:function(){this.css("display","none")},show:function(a){"undefined"===typeof a&&(a="block");this.css("display",a)},attr:function(a,b){var c=this.el;if(1<c.length&&"undefined"===typeof b)return null;if(1<c.length&&"undefined"!==typeof b)d.each(function(c){return j(c,a,b)});else return j(c,a,b)},text:function(a){var b,c;c=this.el;b=c.textContent;return"undefined"!==typeof a?c.textContent=a:b},css:function(a,b){if("undefined"===typeof b)return m(this.el,a);d.each(function(c){m(c,a,b)})},append:function(a){"undefined"!== hide:function(){this.css("display","none")},show:function(a){a===c&&(a="block");this.css("display",a)},attr:function(a,b){var d=this.el;if(1<d.length&&b===c)return null;if(1<d.length&&b!==c)g.each(function(d){return n(d,a,b)});else return n(d,a,b)},text:function(a){var b,d,e;e=this.el;d=a!==c?!0:!1;b=e.textContent;return d?e.textContent=a:b},css:function(a,b){if(b===c)return r(this.el,a);g.each(function(d){r(d,a,b)})},append:function(a){document.insertAdjacentHTML!==c?this.el.insertAdjacentHTML("beforeend",
typeof document.insertAdjacentHTML?this.el.insertAdjacentHTML("beforeend",a):this.el.innerHTML+=a},prepend:function(a){"undefined"!==typeof document.insertAdjacentHTML?this.el.insertAdjacentHTML("afterbegin",a):this.el.innerHTML=a+this.el.innerHTML},html:function(a){"undefined"!==typeof a&&(this.el.innerHTML=a);return this.el.innerHTML}});if("undefined"!==typeof window.XMLHttpRequest){var w={_do:function(a,b,c,f,d){var h=new XMLHttpRequest;"undefined"===typeof c&&(c=function(){});d=d?"POST":"GET"; a):this.el.innerHTML+=a},prepend:function(a){document.insertAdjacentHTML!==c?this.el.insertAdjacentHTML("afterbegin",a):this.el.innerHTML=a+this.el.innerHTML},html:function(a){a!==c&&(this.el.innerHTML=a);return this.el.innerHTML}});if(window.XMLHttpRequest!==c){var z={_do:function(a,b,d,e,l){var h=new XMLHttpRequest;d===c&&(d=function(){});l=l?"POST":"GET";"GET"===l&&(a+=a.match(/\?/)?this._serialize(b):"?"+this._serialize(b));h.open(l,a);h.onreadystatechange=function(){4===h.readyState&&(200===
"GET"===d&&(a+=a.match(/\?/)?this._serialize(b):"?"+this._serialize(b));h.open(d,a);h.onreadystatechange=function(){4===h.readyState&&(200===h.status?c.call(h.responseText,h.responseText):"undefined"!==typeof f&&f.call(h.status,h.status))};"POST"===d?(h.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),h.send(this._serialize(b))):h.send(null)},_serialize:function(a){var b,c,f=[];for(b in a)a.hasOwnProperty(b)&&"function"!==typeof a[b]&&(c=a[b].toString(),b=encodeURIComponent(b), h.status?d.call(h.responseText,h.responseText):e!==c&&e.call(h.status,h.status))};"POST"===l?(h.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),h.send(this._serialize(b))):h.send(null)},_serialize:function(a){var b,d,e=[];for(b in a)a.hasOwnProperty(b)&&"function"!==typeof a[b]&&(d=a[b].toString(),b=encodeURIComponent(b),d=encodeURIComponent(d),e.push(b+"="+d));return e.join("&")}};g.ext("get",function(a,b,d,e){z._do(a,b,d,e,!1)});g.ext("post",function(a,b,d,e){z._do(a,b,d,e,
c=encodeURIComponent(c),f.push(b+"="+c));return f.join("&")}};d.ext("get",function(a,b,c,f){w._do(a,b,c,f,!1)});d.ext("post",function(a,b,c,f){w._do(a,b,c,f,!0)});d.ext("sse",function(a,b){var c;"undefined"!==typeof EventSource&&(c=new EventSource(a),c.onmessage=function(a){b.call(a.data,a.data)})});var n,t;if("undefined"===typeof document.addEventListener)return!1;n=function(a,b,c,d){var r,h;if("undefined"===typeof a)return null;if(b.match(/^([\w\-]+)$/))!0===d?a.addEventListener(b,c,!1):a.removeEventListener(b, !0)});g.ext("sse",function(a,b){var d;EventSource!==c&&(d=new EventSource(a),d.onmessage=function(a){b.call(a.data,a.data)})});var s,w;if(document.addEventListener===c)return!1;s=function(a,b,d,e){var l,h;if(a===c)return null;if(b.match(/^([\w\-]+)$/))!0===e?a.addEventListener(b,d,!1):a.removeEventListener(b,d,!1);else{b=b.split(" ");h=b.length;for(l=0;l<h;l++)s(a,b[l],d,e)}};w=function(a,b,d,e){s(a,d,function(d){var c,f;f=g.$(b,a);for(c in f)d.target==f[c]&&(e.call(f[c],d),d.stopPropagation())},
c,!1);else{b=b.split(" ");h=b.length;for(r=0;r<h;r++)n(a,b[r],c,d)}};t=function(a,b,c,f){n(a,c,function(c){var h,e;e=d.$(b,a);for(h in e)c.target==e[h]&&(f.call(e[h],c),c.stopPropagation())},!0)};d.ext("event",{add:function(a,b){d.each(function(c){n(c,a,b,!0)})},remove:function(a,b){d.each(function(c){n(c,a,b,!1)})},live:function(a,b,c){t(document.documentElement,a,b,c)},delegate:function(a,b,c){d.each(function(d){t(d,a,b,c)})}});if("undefined"===typeof localStorage||"undefined"===typeof JSON)return null; !0)};g.ext("event",{add:function(a,b){g.each(function(d){s(d,a,b,!0)})},remove:function(a,b){g.each(function(d){s(d,a,b,!1)})},live:function(a,b,d){w(document.documentElement,a,b,d)},delegate:function(a,b,d){g.each(function(e){w(e,a,b,d)})}});if(localStorage===c||JSON===c)return null;var t=localStorage,u=sessionStorage;g.ext("store",{get:function(a,b){var d=b?u.getItem(a):t.getItem(a);return JSON.parse(d)},set:function(a,b,d){b=JSON.stringify(b);d?u.setItem(a,b):t.setItem(a,b)},remove:function(a,
var p=localStorage,q=sessionStorage;d.ext("store",{get:function(a,b){var c=b?q.getItem(a):p.getItem(a);return JSON.parse(c)},set:function(a,b,c){b=JSON.stringify(b);c?q.setItem(a,b):p.setItem(a,b)},remove:function(a,b){b?q.removeItem(a):p.removeItem(a)},getAll:function(a){var b,c={},d,e;e=a?p:q;b=e.length;for(a=0;a<b;a++)d=e.key(a),c[d]=e.getItem(d);return c},clear:function(a){a?q.clear():p.clear()}});var x={object_keys:function(a){var b=[],c;for(c in a)a.hasOwnProperty(c)&&b.push(c);return b},object_values:function(a){var b= b){b?u.removeItem(a):t.removeItem(a)},getAll:function(a){var b,d={},e,c;c=a?t:u;b=c.length;for(a=0;a<b;a++)e=c.key(a),d[e]=c.getItem(e);return d},clear:function(a){a?u.clear():t.clear()}});var A={object_keys:function(a){var b=[],d;for(d in a)a.hasOwnProperty(d)&&b.push(d);return b},object_values:function(a){var b=[],d;for(d in a)b.push(a[d]);return b},array_combine:function(a,b){var d={},e,c=0;"array"!==g.type(a)&&(a=this.object_values(a));"array"!==g.type(b)&&(b=this.object_values(b));e=a.length;
[],c;for(c in a)b.push(a[c]);return b},array_combine:function(a,b){var c={},f,e=0;"array"!==d.type(a)&&(a=this.object_values(a));"array"!==d.type(b)&&(b=this.object_values(b));f=a.length;if(f!==b.length)return!1;for(e=0;e<f;e++)c[a[e]]=b[e];return c},object_merge:function(){var a=Array.prototype.slice.call(arguments),b=a.length,c={},f,e=0,h,g,i;f=!0;for(h=0;h<b;h++)if("array"!==d.type(a[h])){f=!1;break}if(f){c=[];for(h=0;h<b;h++)c=c.contact(a[h]);return c}for(i=h=0;h<b;h++)if(f=a[h],"array"==d.type(f)){g= if(e!==b.length)return!1;for(c=0;c<e;c++)d[a[c]]=b[c];return d},object_merge:function(){var a=Array.prototype.slice.call(arguments),b=a.length,d={},c,f=0,h,q,j;c=!0;for(h=0;h<b;h++)if("array"!==g.type(a[h])){c=!1;break}if(c){d=[];for(h=0;h<b;h++)d=d.contact(a[h]);return d}for(j=h=0;h<b;h++)if(c=a[h],"array"==g.type(c)){q=0;for(f=c.length;q<f;q++)d[j++]=c[q]}else for(q in c)c.hasOwnProperty(q)&&(parseInt(q,10)+""===q?d[j++]=c[q]:d[q]=c[q]);return d},str_trans:function(a,b,d){var c=[],f=[],h=!1,g=0,
0;for(e=f.length;g<e;g++)c[i++]=f[g]}else for(g in f)f.hasOwnProperty(g)&&(parseInt(g,10)+""===g?c[i++]=f[g]:c[g]=f[g]);return c},str_trans:function(a,b,c){var d=[],e=[],h=!1,g=0,i=0,j="",k="",l="",m="",n;if("object"===typeof b){c=[];h=0;g={};c=x.object_keys(b);c.sort(function(a,b){var c=parseFloat(b),d=parseFloat(a),e=c+""===b,f=d+""===a;return e&&f?c>d?1:c<d?-1:0:e&&!f?1:!e&&f?-1:b>a?1:b<a?-1:0});h=c.length;for(i=0;i<h;i++)g[c[i]]=b[c[i]];b=g;for(n in b)b.hasOwnProperty(n)&&(d.push(n),e.push(b[n])); j=0,k="",n="",p="",m="",r;if("object"===typeof b){d=[];h=0;g={};d=A.object_keys(b);d.sort(function(a,b){var c=parseFloat(b),d=parseFloat(a),e=c+""===b,f=d+""===a;return e&&f?c>d?1:c<d?-1:0:e&&!f?1:!e&&f?-1:b>a?1:b<a?-1:0});h=d.length;for(j=0;j<h;j++)g[d[j]]=b[d[j]];b=g;for(r in b)b.hasOwnProperty(r)&&(c.push(r),f.push(b[r]));b=c;d=f}j=a.length;g=b.length;k="string"===typeof d;n="string"===typeof b;for(c=0;c<j;c++){h=!1;if(n){a.charAt(c-1);p=a.charAt(c);a.charAt(c+1);for(f=0;f<g;f++)if(p==b.charAt(f)){h=
b=d;c=e}i=a.length;g=b.length;j="string"===typeof c;k="string"===typeof b;for(d=0;d<i;d++){h=!1;if(k){a.charAt(d-1);l=a.charAt(d);a.charAt(d+1);for(e=0;e<g;e++)if(l==b.charAt(e)){h=!0;break}}else for(e=0;e<g;e++)if(a.substr(d,b[e].length)==b[e]){h=!0;d=d+b[e].length-1;break}m=h?m+(j?c.charAt(e):c[e]):m+a.charAt(d)}return m}};d.ext("util",x)}})($_); !0;break}}else for(f=0;f<g;f++)if(a.substr(c,b[f].length)==b[f]){h=!0;c=c+b[f].length-1;break}m=h?m+(k?d.charAt(f):d[f]):m+a.charAt(c)}return m}};g.ext("util",A)}})($_);

20
src/core.js Normal file → Executable file
View File

@ -2,9 +2,9 @@
Kis JS Keep It Simple JS Library Kis JS Keep It Simple JS Library
Copyright Timothy J. Warren Copyright Timothy J. Warren
License Public Domain License Public Domain
Version 0.7.0 Version 0.8.0
*/ */
(function (){ (function (undefined){
"use strict"; "use strict";
@ -14,7 +14,7 @@
// selector engine. I choose to just use the // selector engine. I choose to just use the
// browser feature, since it is present in // browser feature, since it is present in
// IE 8+, and all other major browsers // IE 8+, and all other major browsers
if (typeof document.querySelector === "undefined") if (document.querySelector === undefined)
{ {
return; return;
} }
@ -35,10 +35,10 @@
$_ = function(s) $_ = function(s)
{ {
// Have documentElement be default selector, just in case // Have documentElement be default selector, just in case
if (typeof s === "undefined") if (s === undefined)
{ {
// Defines a "global" selector for that instance // Defines a "global" selector for that instance
sel = (typeof $_.el !== "undefined") sel = ($_.el !== undefined)
? $_.el ? $_.el
: document.documentElement; : document.documentElement;
} }
@ -80,7 +80,7 @@
{ {
var x, c; var x, c;
if (typeof a != "string" || typeof a === "undefined"){ return a;} if (typeof a != "string" || a === undefined){ return a;}
//Check for a context of a specific element, otherwise, just run on the document //Check for a context of a specific element, otherwise, just run on the document
c = (context != null && context.nodeType === 1) c = (context != null && context.nodeType === 1)
@ -113,12 +113,12 @@
{ {
var type, F; var type, F;
if(typeof obj === "undefined") if(obj === undefined)
{ {
return; return;
} }
if(typeof Object.create !== "undefined") if(Object.create !== undefined)
{ {
return Object.create(obj); return Object.create(obj);
} }
@ -162,10 +162,10 @@
*/ */
$_.ext('each', function (callback) $_.ext('each', function (callback)
{ {
if(typeof sel.length !== "undefined" && sel !== window) if(sel.length !== undefined && sel !== window)
{ {
// Use the native method, if it exists // Use the native method, if it exists
if(typeof Array.prototype.forEach !== 'undefined') if(Array.prototype.forEach !== undefined)
{ {
[].forEach.call(sel, callback); [].forEach.call(sel, callback);
return; return;

209
src/modules/DOM.js Normal file → Executable file
View File

@ -1,175 +1,13 @@
//This is used so IE can use the classList api //This is used so IE can use the classList api
/* /*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js*/
* classList.js: Cross-browser full element.classList implementation. if(typeof document!=="undefined"&&!("classList" in document.createElement("a"))){(function(j){if(!("HTMLElement" in j)&&!("Element" in j)){return}var a="classList",f="prototype",m=(j.HTMLElement||j.Element)[f],b=Object,k=String[f].trim||function(){return this.replace(/^\s+|\s+$/g,"")},c=Array[f].indexOf||function(q){var p=0,o=this.length;for(;p<o;p++){if(p in this&&this[p]===q){return p}}return -1},n=function(o,p){this.name=o;this.code=DOMException[o];this.message=p},g=function(p,o){if(o===""){throw new n("SYNTAX_ERR","An invalid or illegal string was specified")}if(/\s/.test(o)){throw new n("INVALID_CHARACTER_ERR","String contains an invalid character")}return c.call(p,o)},d=function(s){var r=k.call(s.className),q=r?r.split(/\s+/):[],p=0,o=q.length;for(;p<o;p++){this.push(q[p])}this._updateClassName=function(){s.className=this.toString()}},e=d[f]=[],i=function(){return new d(this)};n[f]=Error[f];e.item=function(o){return this[o]||null};e.contains=function(o){o+="";return g(this,o)!==-1};e.add=function(){var s=arguments,r=0,p=s.length,q,o=false;do{q=s[r]+"";if(g(this,q)===-1){this.push(q);o=true}}while(++r<p);if(o){this._updateClassName()}};e.remove=function(){var t=arguments,s=0,p=t.length,r,o=false;do{r=t[s]+"";var q=g(this,r);if(q!==-1){this.splice(q,1);o=true}}while(++s<p);if(o){this._updateClassName()}};e.toggle=function(p,q){p+="";var o=this.contains(p),r=o?q!==true&&"remove":q!==false&&"add";if(r){this[r](p)}return !o};e.toString=function(){return this.join(" ")};if(b.defineProperty){var l={get:i,enumerable:true,configurable:true};try{b.defineProperty(m,a,l)}catch(h){if(h.number===-2146823252){l.enumerable=false;b.defineProperty(m,a,l)}}}else{if(b[f].__defineGetter__){m.__defineGetter__(a,i)}}}(self))};
* 2011-06-15
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
if (typeof document !== "undefined" && !("classList" in document.createElement("a")))
{
(function (view){
var classListProp = "classList",
protoProp = "prototype",
elemCtrProto = (view.HTMLElement || view.Element)[protoProp],
objCtr = Object,
strTrim = String[protoProp].trim ||
function ()
{
return this.replace(/^\s+|\s+$/g, "");
},
arrIndexOf = Array[protoProp].indexOf ||
function (item)
{
var
i = 0,
len = this.length;
for (; i < len; i++)
{
if (i in this && this[i] === item)
{
return i;
}
}
return -1;
}
// Vendors: please allow content code to instantiate DOMExceptions
,
/**
* @private
*/
DOMEx = function (type, message)
{
this.name = type;
this.code = DOMException[type];
this.message = message;
},
/**
* @private
*/
checkTokenAndGetIndex = function (classList, token)
{
if (token === "")
{
throw new DOMEx("SYNTAX_ERR", "An invalid or illegal string was specified");
}
if (/\s/.test(token))
{
throw new DOMEx("INVALID_CHARACTER_ERR", "String contains an invalid character");
}
return arrIndexOf.call(classList, token);
},
/**
* @private
*/
ClassList = function (elem)
{
var
trimmedClasses = strTrim.call(elem.className),
classes = trimmedClasses ? trimmedClasses.split(/\s+/) : [],
i = 0,
len = classes.length;
for (; i < len; i++)
{
this.push(classes[i]);
}
this._updateClassName = function ()
{
elem.className = this.toString();
};
},
classListProto = ClassList[protoProp] = [],
/**
* @private
*/
classListGetter = function ()
{
return new ClassList(this);
};
// Most DOMException implementations don't allow calling DOMException's toString()
// on non-DOMExceptions. Error's toString() is sufficient here.
DOMEx[protoProp] = Error[protoProp];
classListProto.item = function (i)
{
return this[i] || null;
};
classListProto.contains = function (token)
{
token += "";
return checkTokenAndGetIndex(this, token) !== -1;
};
classListProto.add = function (token)
{
token += "";
if (checkTokenAndGetIndex(this, token) === -1)
{
this.push(token);
this._updateClassName();
}
};
classListProto.remove = function (token)
{
token += "";
var index = checkTokenAndGetIndex(this, token);
if (index !== -1)
{
this.splice(index, 1);
this._updateClassName();
}
};
classListProto.toggle = function (token)
{
token += "";
if (checkTokenAndGetIndex(this, token) === -1)
{
this.add(token);
}
else
{
this.remove(token);
}
};
classListProto.toString = function ()
{
return this.join(" ");
};
if (objCtr.defineProperty)
{
var classListPropDesc = {
get: classListGetter,
enumerable: true,
configurable: true
};
try
{
objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
}
catch (ex)
{ // IE 8 doesn't support enumerable:true
if (ex.number === -0x7FF5EC54)
{
classListPropDesc.enumerable = false;
objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
}
}
}
else if (objCtr[protoProp].__defineGetter__)
{
elemCtrProto.__defineGetter__(classListProp, classListGetter);
}
}(self));
}
/** /**
* DOM * DOM
* *
* Dom manipulation module * Dom manipulation module
*/ */
(function (){ (function (undefined){
"use strict"; "use strict";
@ -181,7 +19,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
var oldVal, doAttr; var oldVal, doAttr;
//Get the value of the attribute, if it exists //Get the value of the attribute, if it exists
if (typeof sel.hasAttribute !== "undefined") if (sel.hasAttribute !== undefined)
{ {
if (sel.hasAttribute(name)) if (sel.hasAttribute(name))
{ {
@ -190,12 +28,12 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
doAttr = true; doAttr = true;
} }
else if (typeof sel[name] !== "undefined") else if (sel[name] !== undefined)
{ {
oldVal = sel[name]; oldVal = sel[name];
doAttr = false; doAttr = false;
} }
else if (name === "class" && typeof sel.className !== "undefined") //className attribute else if (name === "class" && sel.className !== undefined) //className attribute
{ {
name = "className"; name = "className";
oldVal = sel.className; oldVal = sel.className;
@ -203,22 +41,19 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
} }
//Well, I guess that attribute doesn't exist //Well, I guess that attribute doesn't exist
if (typeof oldVal === "undefined" && (typeof value === "undefined" || value === null)) if (oldVal === undefined && (value === undefined || value === null))
{ {
/*console.log(value);
console.log(sel);
console.log("Element does not have the selected attribute");*/
return null; return null;
} }
//No value to set? Return the current value //No value to set? Return the current value
if (typeof value === "undefined") if (value === undefined)
{ {
return oldVal; return oldVal;
} }
//Determine what to do with the attribute //Determine what to do with the attribute
if (typeof value !== "undefined" && value !== null) if (value !== undefined && value !== null)
{ {
if(doAttr === true) if(doAttr === true)
{ {
@ -241,7 +76,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
} }
} }
return (typeof value !== "undefined") ? value : oldVal; return (value !== undefined) ? value : oldVal;
} }
/** /**
@ -271,17 +106,17 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
//If you don't define a value, try returning the existing value //If you don't define a value, try returning the existing value
if(typeof val === "undefined" && sel.style[prop] !== "undefined") if(val === undefined && sel.style[prop] !== undefined)
{ {
return sel.style[prop]; return sel.style[prop];
} }
else if(typeof val === "undefined" && sel.style[equi[prop]] !== "undefined") else if(val === undefined && sel.style[equi[prop]] !== undefined)
{ {
return sel.style[equi[prop]]; return sel.style[equi[prop]];
} }
//Let's try the easy way first //Let's try the easy way first
if(typeof sel.style[prop] !== "undefined") if(sel.style[prop] !== undefined)
{ {
sel.style[prop] = val; sel.style[prop] = val;
@ -318,7 +153,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
addClass: function (c) addClass: function (c)
{ {
$_.each(function (e){ $_.each(function (e){
e.classList.add(c); this.classList.add(c);
}); });
}, },
/** /**
@ -360,7 +195,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
*/ */
show: function (type) show: function (type)
{ {
if (typeof type === "undefined") if (type === undefined)
{ {
type = "block"; type = "block";
} }
@ -386,11 +221,11 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
var sel = this.el; var sel = this.el;
//Make sure you don't try to get a bunch of elements //Make sure you don't try to get a bunch of elements
if (sel.length > 1 && typeof value === "undefined") if (sel.length > 1 && value === undefined)
{ {
return null; return null;
} }
else if (sel.length > 1 && typeof value !== "undefined") //You can set a bunch, though else if (sel.length > 1 && value !== undefined) //You can set a bunch, though
{ {
$_.each(function (e){ $_.each(function (e){
return _attr(e, name, value); return _attr(e, name, value);
@ -420,7 +255,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
sel = this.el; sel = this.el;
set = (typeof value !== "undefined") ? true : false; set = (value !== undefined) ? true : false;
oldValue = sel.textContent; oldValue = sel.textContent;
@ -452,7 +287,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
css: function (prop, val) css: function (prop, val)
{ {
//Return the current value if a value is not set //Return the current value if a value is not set
if(typeof val === "undefined") if(val === undefined)
{ {
return _css(this.el, prop); return _css(this.el, prop);
} }
@ -472,7 +307,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
*/ */
append: function(htm) append: function(htm)
{ {
if(typeof document.insertAdjacentHTML !== "undefined") if(document.insertAdjacentHTML !== undefined)
{ {
this.el.insertAdjacentHTML('beforeend', htm); this.el.insertAdjacentHTML('beforeend', htm);
} }
@ -491,7 +326,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
*/ */
prepend: function(htm) prepend: function(htm)
{ {
if(typeof document.insertAdjacentHTML !== "undefined") if(document.insertAdjacentHTML !== undefined)
{ {
this.el.insertAdjacentHTML('afterbegin', htm); this.el.insertAdjacentHTML('afterbegin', htm);
} }
@ -513,7 +348,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
html: function(htm) html: function(htm)
{ {
if(typeof htm !== "undefined") if(htm !== undefined)
{ {
this.el.innerHTML = htm; this.el.innerHTML = htm;
} }

10
src/modules/ajax.js Normal file → Executable file
View File

@ -3,12 +3,12 @@
* *
* Module for making ajax requests * Module for making ajax requests
*/ */
(function (){ (function (undefined){
"use strict"; "use strict";
// Don't bother even defining the object if the XMLHttpRequest isn't available // Don't bother even defining the object if the XMLHttpRequest isn't available
if(typeof window.XMLHttpRequest === "undefined") if(window.XMLHttpRequest === undefined)
{ {
return; return;
} }
@ -19,7 +19,7 @@
var type, var type,
request = new XMLHttpRequest(); request = new XMLHttpRequest();
if (typeof success_callback === "undefined") if (success_callback === undefined)
{ {
/** /**
* @private * @private
@ -48,7 +48,7 @@
} }
else else
{ {
if (typeof error_callback !== 'undefined') if (error_callback !== undefined)
{ {
error_callback.call(request.status, request.status); error_callback.call(request.status, request.status);
} }
@ -140,7 +140,7 @@
var source; var source;
// Check for server-sent event support // Check for server-sent event support
if (typeof EventSource !== 'undefined') if (EventSource !== undefined)
{ {
source = new EventSource(url); source = new EventSource(url);

6
src/modules/event.js Normal file → Executable file
View File

@ -4,14 +4,14 @@
* Event api wrapper * Event api wrapper
* @todo Add method for triggering events * @todo Add method for triggering events
*/ */
(function (){ (function (undefined){
"use strict"; "use strict";
var _add_remove, e, _attach_delegate; var _add_remove, e, _attach_delegate;
// Don't bother defining the methods if event api isn't supports // Don't bother defining the methods if event api isn't supports
if (typeof document.addEventListener === "undefined") if (document.addEventListener === undefined)
{ {
return false; return false;
} }
@ -20,7 +20,7 @@
{ {
var i, len; var i, len;
if(typeof sel === "undefined") if(sel === undefined)
{ {
return null; return null;
} }

View File

@ -3,12 +3,12 @@
* *
* Wrapper for local / sessionstorage * Wrapper for local / sessionstorage
*/ */
(function (){ (function (undefined){
"use strict"; "use strict";
//No support for localstorage? Bail out early //No support for localstorage? Bail out early
if(typeof localStorage === "undefined" || typeof JSON === "undefined") if(localStorage === undefined || JSON === undefined)
{ {
return null; return null;
} }

2
src/modules/util.js Normal file → Executable file
View File

@ -4,7 +4,7 @@
* Various object and string manipulation functions * Various object and string manipulation functions
* Note: these are based on similar phpjs functions: http://phpjs.org * Note: these are based on similar phpjs functions: http://phpjs.org
*/ */
(function (){ (function (undefined){
"use strict"; "use strict";