Slim down library by removing IE 8 support

This commit is contained in:
Timothy Warren 2012-10-04 17:25:09 +00:00
parent 5dc517f24e
commit 8193bbab38
18 changed files with 438 additions and 1012 deletions

View File

@ -9,7 +9,7 @@ src directory, and running the "combine.php" script. This will output a
"kis-custom.js" file. (Be careful, as the script will overwrite any "kis-custom.js"
file that already exists).
Browser support: IE8+, Latest versions of Firefox, Chrome, Safari, Opera
Browser support: IE9+, Latest versions of Firefox, Chrome, Safari, Opera
## Basic Use: ##

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@
<span class='line'> 2</span> Kis JS Keep It Simple JS Library
<span class='line'> 3</span> Copyright Timothy J. Warren
<span class='line'> 4</span> License Public Domain
<span class='line'> 5</span> Version 0.6.0
<span class='line'> 5</span> Version 0.7.0
<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'> 8</span>
@ -42,7 +42,7 @@
<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'> 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="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="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'> 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'> 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">
@ -51,7 +51,7 @@
<span class='line'> 44</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 47</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">s</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"object"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">$</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 47</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="NAME">$</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</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 class='line'> 50</span> </span><span class="WHIT"> </span><span class="COMM">// Add the selector to the prototype</span><span class="WHIT">
@ -177,8 +177,8 @@
<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'>172</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>173</span> </span><span class="WHIT">
<span class='line'>174</span> </span><span class="COMM">// Otherwise, fall back to a for loop</span><span class="WHIT">
<span class='line'>173</span>
<span class='line'>174</span> </span><span class="WHIT"> </span><span class="COMM">// Otherwise, fall back to a for loop</span><span class="WHIT">
<span class='line'>175</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>176</span>
<span class='line'>177</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">

View File

@ -423,119 +423,113 @@
<span class='line'>416</span> */</span><span class="WHIT">
<span class='line'>417</span> </span><span class="WHIT"> </span><span class="NAME">text</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">value</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>418</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>419</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">oldValue</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">set</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>419</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">oldValue</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">set</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>420</span>
<span class='line'>421</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="NAME">this.el</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>422</span>
<span class='line'>423</span> </span><span class="WHIT"> </span><span class="NAME">set</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">value</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><span class="PUNC">?</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>424</span>
<span class='line'>425</span> </span><span class="WHIT"> </span><span class="NAME">type</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">sel.textContent</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'>426</span> </span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"textContent"</span><span class="WHIT">
<span class='line'>427</span> </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">sel.innerText</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'>428</span> </span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"innerText"</span><span class="WHIT">
<span class='line'>429</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"innerHTML"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>430</span>
<span class='line'>431</span> </span><span class="WHIT"> </span><span class="NAME">oldValue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>432</span>
<span class='line'>433</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">set</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>434</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>435</span> </span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>436</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>437</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>438</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>439</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>440</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">oldValue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>441</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>442</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>443</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>444</span> * Sets or retrieves a css property of the element
<span class='line'>445</span> * specified by the current selector. If a value is
<span class='line'>446</span> * passed, it will set that value on the current element,
<span class='line'>447</span> * otherwise it will return the value of the css property
<span class='line'>448</span> * on the current element
<span class='line'>449</span> *
<span class='line'>450</span> * @name css
<span class='line'>451</span> * @memberOf $_.dom
<span class='line'>452</span> * @function
<span class='line'>453</span> * @param string property
<span class='line'>454</span> * @param [string] value
<span class='line'>455</span> * @return string
<span class='line'>456</span> * @type string
<span class='line'>457</span> */</span><span class="WHIT">
<span class='line'>458</span> </span><span class="WHIT"> </span><span class="NAME">css</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">prop</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>459</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>460</span> </span><span class="WHIT"> </span><span class="COMM">//Return the current value if a value is not set</span><span class="WHIT">
<span class='line'>461</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">val</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'>462</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>463</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_css</span><span class="PUNC">(</span><span class="NAME">this.el</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">prop</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>464</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>465</span>
<span class='line'>466</span> </span><span class="WHIT"> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>467</span> </span><span class="WHIT"> </span><span class="NAME">_css</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">prop</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>468</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>469</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>470</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>471</span> * Adds to the innerHTML of the current element, after the last child.
<span class='line'>472</span> *
<span class='line'>473</span> * @example $_("ul").dom.append("&lt;li&gt;&lt;/li&gt;") adds an li element to the end of the selected ul element
<span class='line'>474</span> * @name append
<span class='line'>475</span> * @memberOf $_.dom
<span class='line'>476</span> * @function
<span class='line'>477</span> * @param string htm
<span class='line'>478</span> */</span><span class="WHIT">
<span class='line'>479</span> </span><span class="WHIT"> </span><span class="NAME">append</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">htm</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>425</span> </span><span class="WHIT"> </span><span class="NAME">oldValue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel.textContent</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>426</span>
<span class='line'>427</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">set</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>428</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>429</span> </span><span class="WHIT"> </span><span class="NAME">sel.textContent</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>430</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>431</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>432</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>433</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>434</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">oldValue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>435</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>436</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>437</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>438</span> * Sets or retrieves a css property of the element
<span class='line'>439</span> * specified by the current selector. If a value is
<span class='line'>440</span> * passed, it will set that value on the current element,
<span class='line'>441</span> * otherwise it will return the value of the css property
<span class='line'>442</span> * on the current element
<span class='line'>443</span> *
<span class='line'>444</span> * @name css
<span class='line'>445</span> * @memberOf $_.dom
<span class='line'>446</span> * @function
<span class='line'>447</span> * @param string property
<span class='line'>448</span> * @param [string] value
<span class='line'>449</span> * @return string
<span class='line'>450</span> * @type string
<span class='line'>451</span> */</span><span class="WHIT">
<span class='line'>452</span> </span><span class="WHIT"> </span><span class="NAME">css</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">prop</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>453</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>454</span> </span><span class="WHIT"> </span><span class="COMM">//Return the current value if a value is not set</span><span class="WHIT">
<span class='line'>455</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">val</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'>456</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>457</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_css</span><span class="PUNC">(</span><span class="NAME">this.el</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">prop</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>458</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>459</span>
<span class='line'>460</span> </span><span class="WHIT"> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>461</span> </span><span class="WHIT"> </span><span class="NAME">_css</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">prop</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>462</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>463</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>464</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>465</span> * Adds to the innerHTML of the current element, after the last child.
<span class='line'>466</span> *
<span class='line'>467</span> * @example $_("ul").dom.append("&lt;li&gt;&lt;/li&gt;") adds an li element to the end of the selected ul element
<span class='line'>468</span> * @name append
<span class='line'>469</span> * @memberOf $_.dom
<span class='line'>470</span> * @function
<span class='line'>471</span> * @param string htm
<span class='line'>472</span> */</span><span class="WHIT">
<span class='line'>473</span> </span><span class="WHIT"> </span><span class="NAME">append</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">htm</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>474</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>475</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">document.insertAdjacentHTML</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'>476</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>477</span> </span><span class="WHIT"> </span><span class="NAME">this.el.insertAdjacentHTML</span><span class="PUNC">(</span><span class="STRN">'beforeend'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">htm</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>478</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>479</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>480</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>481</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">document.insertAdjacentHTML</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'>482</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>483</span> </span><span class="WHIT"> </span><span class="NAME">this.el.insertAdjacentHTML</span><span class="PUNC">(</span><span class="STRN">'beforeend'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">htm</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>484</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>485</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>486</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>487</span> </span><span class="WHIT"> </span><span class="NAME">this.el.innerHTML</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">htm</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>488</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>489</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>490</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>491</span> * Adds to the innerHTML of the selected element, before the current children
<span class='line'>492</span> *
<span class='line'>493</span> * @name prepend
<span class='line'>494</span> * @memberOf $_.dom
<span class='line'>495</span> * @function
<span class='line'>496</span> * @param string htm
<span class='line'>497</span> */</span><span class="WHIT">
<span class='line'>498</span> </span><span class="WHIT"> </span><span class="NAME">prepend</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">htm</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>481</span> </span><span class="WHIT"> </span><span class="NAME">this.el.innerHTML</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">htm</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>482</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>483</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>484</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>485</span> * Adds to the innerHTML of the selected element, before the current children
<span class='line'>486</span> *
<span class='line'>487</span> * @name prepend
<span class='line'>488</span> * @memberOf $_.dom
<span class='line'>489</span> * @function
<span class='line'>490</span> * @param string htm
<span class='line'>491</span> */</span><span class="WHIT">
<span class='line'>492</span> </span><span class="WHIT"> </span><span class="NAME">prepend</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">htm</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>493</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>494</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">document.insertAdjacentHTML</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'>495</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>496</span> </span><span class="WHIT"> </span><span class="NAME">this.el.insertAdjacentHTML</span><span class="PUNC">(</span><span class="STRN">'afterbegin'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">htm</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>497</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>498</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>499</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>500</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">document.insertAdjacentHTML</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'>501</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>502</span> </span><span class="WHIT"> </span><span class="NAME">this.el.insertAdjacentHTML</span><span class="PUNC">(</span><span class="STRN">'afterbegin'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">htm</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>503</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>504</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>505</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>506</span> </span><span class="WHIT"> </span><span class="NAME">this.el.innerHTML</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">htm</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.el.innerHTML</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>507</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>508</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>509</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>510</span> * Sets or gets the innerHTML propery of the element(s) passed
<span class='line'>511</span> *
<span class='line'>512</span> * @name html
<span class='line'>513</span> * @memberOf $_.dom
<span class='line'>514</span> * @function
<span class='line'>515</span> * @param [string] htm
<span class='line'>516</span> * @return string
<span class='line'>517</span> * @type string
<span class='line'>518</span> */</span><span class="WHIT">
<span class='line'>519</span> </span><span class="WHIT"> </span><span class="NAME">html</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">htm</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>520</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>521</span>
<span class='line'>522</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">htm</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'>523</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>524</span> </span><span class="WHIT"> </span><span class="NAME">this.el.innerHTML</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">htm</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>525</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>526</span>
<span class='line'>527</span> </span><span class="WHIT"> </span><span class="COMM">//If the parameter is undefined, just return the current value</span><span class="WHIT">
<span class='line'>528</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.el.innerHTML</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>529</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>530</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>531</span>
<span class='line'>532</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'dom'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">d</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>533</span>
<span class='line'>534</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span></pre></body></html>
<span class='line'>500</span> </span><span class="WHIT"> </span><span class="NAME">this.el.innerHTML</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">htm</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.el.innerHTML</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>501</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>502</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>503</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>504</span> * Sets or gets the innerHTML propery of the element(s) passed
<span class='line'>505</span> *
<span class='line'>506</span> * @name html
<span class='line'>507</span> * @memberOf $_.dom
<span class='line'>508</span> * @function
<span class='line'>509</span> * @param [string] htm
<span class='line'>510</span> * @return string
<span class='line'>511</span> * @type string
<span class='line'>512</span> */</span><span class="WHIT">
<span class='line'>513</span> </span><span class="WHIT"> </span><span class="NAME">html</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">htm</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>514</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>515</span>
<span class='line'>516</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">htm</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'>517</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>518</span> </span><span class="WHIT"> </span><span class="NAME">this.el.innerHTML</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">htm</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>519</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>520</span>
<span class='line'>521</span> </span><span class="WHIT"> </span><span class="COMM">//If the parameter is undefined, just return the current value</span><span class="WHIT">
<span class='line'>522</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.el.innerHTML</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>523</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>524</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>525</span>
<span class='line'>526</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'dom'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">d</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>527</span>
<span class='line'>528</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span></pre></body></html>

View File

@ -55,8 +55,8 @@
<span class='line'> 48</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'> 49</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 class='line'> 52</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 51</span>
<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="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 54</span>
<span class='line'> 55</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"POST"</span><span class="PUNC">)</span><span class="WHIT">
@ -127,8 +127,8 @@
<span class='line'>120</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'post'</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">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">success_callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">error_callback</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>121</span> </span><span class="WHIT"> </span><span class="NAME">ajax._do</span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">success_callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">error_callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">
<span class='line'>124</span> </span><span class="COMM">/**
<span class='line'>123</span>
<span class='line'>124</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>125</span> * Watches for server-sent events and applies a callback on message
<span class='line'>126</span> *
<span class='line'>127</span> * @name sse
@ -137,20 +137,20 @@
<span class='line'>130</span> * @param string url
<span class='line'>131</span> * @param function callback
<span class='line'>132</span> */</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'sse'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">poll_rate</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>134</span> </span><span class="WHIT">
<span class='line'>135</span> </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'>136</span> </span><span class="WHIT">
<span class='line'>137</span> </span><span class="COMM">// Check for server-sent event support</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'sse'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">url</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'>134</span>
<span class='line'>135</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'>136</span>
<span class='line'>137</span> </span><span class="WHIT"> </span><span class="COMM">// Check for server-sent event support</span><span class="WHIT">
<span class='line'>138</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'>139</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>140</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'>141</span> </span><span class="WHIT">
<span class='line'>142</span> </span><span class="COMM">// Apply the callback</span><span class="WHIT">
<span class='line'>141</span>
<span class='line'>142</span> </span><span class="WHIT"> </span><span class="COMM">// Apply the callback</span><span class="WHIT">
<span class='line'>143</span> </span><span class="WHIT"> </span><span class="NAME">source.onmessage</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">event</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT"> </span><span class="NAME">callback.call</span><span class="PUNC">(</span><span class="NAME">event.data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event.data</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>145</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>147</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>148</span> </span><span class="WHIT">
<span class='line'>148</span>
<span class='line'>149</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span></pre></body></html>

View File

@ -15,242 +15,148 @@
<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'> 10</span>
<span class='line'> 11</span> </span><span class="WHIT"> </span><span class="COMM">// Property name for expandos on DOM objects</span><span class="WHIT">
<span class='line'> 12</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">kis_expando</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"KIS_0_6_0"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 13</span>
<span class='line'> 14</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_attach</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_remove</span><span class="PUNC">,</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'> 15</span>
<span class='line'> 16</span> </span><span class="WHIT"> </span><span class="COMM">// Define the proper _attach and _remove functions</span><span class="WHIT">
<span class='line'> 17</span> </span><span class="WHIT"> </span><span class="COMM">// based on browser support</span><span class="WHIT">
<span class='line'> 18</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">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'> 19</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="COMM">/**
<span class='line'> 21</span> * @private
<span class='line'> 22</span> */</span><span class="WHIT">
<span class='line'> 23</span> </span><span class="WHIT"> </span><span class="NAME">_attach</span><span class="WHIT"> </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">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</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'> 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'> 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'> 17</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 18</span>
<span class='line'> 19</span> </span><span class="WHIT"> </span><span class="NAME">_add_remove</span><span class="WHIT"> </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">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">add</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'> 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'> 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">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.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'> 26</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 27</span> </span><span class="WHIT"> </span><span class="COMM">// Duplicated events are dropped, per the specification</span><span class="WHIT">
<span class='line'> 28</span> </span><span class="WHIT"> </span><span class="NAME">sel.addEventListener</span><span class="PUNC">(</span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 29</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 30</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 31</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 32</span> * @private
<span class='line'> 33</span> */</span><span class="WHIT">
<span class='line'> 34</span> </span><span class="WHIT"> </span><span class="NAME">_remove</span><span class="WHIT"> </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">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 35</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="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.removeEventListener</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'> 37</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 38</span> </span><span class="WHIT"> </span><span class="NAME">sel.removeEventListener</span><span class="PUNC">(</span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</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="PUNC">}</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'> 27</span>
<span class='line'> 28</span> </span><span class="WHIT"> </span><span class="COMM">// Multiple events? Run recursively!</span><span class="WHIT">
<span class='line'> 29</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">event.match</span><span class="PUNC">(</span><span class="REGX">/^([\w\-]+)$/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 30</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 31</span> </span><span class="WHIT"> </span><span class="NAME">event</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">event.split</span><span class="PUNC">(</span><span class="STRN">" "</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 32</span>
<span class='line'> 33</span> </span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">event.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 34</span>
<span class='line'> 35</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</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="NAME">_add_remove</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">add</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 38</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 39</span>
<span class='line'> 40</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="WHIT"> </span><span class="COMM">// typeof function doesn't work in IE where attachEvent is available: brute force it</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="WHIT"> </span><span class="KEYW">else</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">document.attachEvent</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'> 44</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 46</span> * @private
<span class='line'> 47</span> */</span><span class="WHIT">
<span class='line'> 48</span> </span><span class="WHIT"> </span><span class="NAME">_attach</span><span class="WHIT"> </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">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 49</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="KEYW">function</span><span class="WHIT"> </span><span class="NAME">_listener</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="WHIT"> </span><span class="COMM">// Internet Explorer fails to correctly set the 'this' object</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT"> </span><span class="COMM">// for event listeners, so we need to set it ourselves.</span><span class="WHIT">
<span class='line'> 53</span> </span><span class="WHIT"> </span><span class="NAME">callback.apply</span><span class="PUNC">(</span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</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'> 42</span>
<span class='line'> 43</span> </span><span class="WHIT"> </span><span class="COMM">// Bind the event</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">add</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">sel.addEventListener</span><span class="PUNC">(</span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">sel.removeEventListener</span><span class="PUNC">(</span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 47</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 48</span>
<span class='line'> 49</span> </span><span class="WHIT"> </span><span class="NAME">_attach_delegate</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">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">target</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</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="COMM">// attach the listener to the parent object</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT"> </span><span class="NAME">_add_remove</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 53</span>
<span class='line'> 54</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">elem</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 55</span>
<span class='line'> 56</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">sel.attachEvent</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'> 57</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT"> </span><span class="NAME">_remove</span><span class="PUNC">(</span><span class="NAME">event</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><span class="COMM">// Make sure we don't have duplicate listeners</span><span class="WHIT">
<span class='line'> 59</span>
<span class='line'> 60</span> </span><span class="WHIT"> </span><span class="NAME">sel.attachEvent</span><span class="PUNC">(</span><span class="STRN">"on"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_listener</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT"> </span><span class="COMM">// Store our listener so we can remove it later</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">expando</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">kis_expando</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">kis_expando</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT"> </span><span class="NAME">expando.listeners</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">expando.listeners</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="WHIT"> </span><span class="NAME">expando.listeners</span><span class="PUNC">[</span><span class="NAME">event</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">expando.listeners</span><span class="PUNC">[</span><span class="NAME">event</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT"> </span><span class="NAME">expando.listeners</span><span class="PUNC">[</span><span class="NAME">event</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT"> </span><span class="NAME">_listener</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">_listener</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 72</span> * @private
<span class='line'> 73</span> */</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT"> </span><span class="NAME">_remove</span><span class="WHIT"> </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">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 76</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.detachEvent</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'> 77</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">expando</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">kis_expando</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">expando</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">expando.listeners</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">expando.listeners</span><span class="PUNC">[</span><span class="NAME">event</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">listeners</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">expando.listeners</span><span class="PUNC">[</span><span class="NAME">event</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">var</span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">listeners.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">&lt;</span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">listeners</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">callback</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT"> </span><span class="NAME">sel.detachEvent</span><span class="PUNC">(</span><span class="STRN">"on"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">listeners</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">_listener</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT"> </span><span class="NAME">listeners.splice</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">listeners.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT"> </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">expando.listeners</span><span class="PUNC">[</span><span class="NAME">event</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 99</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>101</span>
<span class='line'>102</span> </span><span class="WHIT"> </span><span class="NAME">_add_remove</span><span class="WHIT"> </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">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">add</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>104</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'>105</span>
<span class='line'>106</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'>107</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>108</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'>109</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>110</span>
<span class='line'>111</span> </span><span class="WHIT"> </span><span class="COMM">// Multiple events? Run recursively!</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">event.match</span><span class="PUNC">(</span><span class="REGX">/^([\w\-]+)$/</span><span class="PUNC">)</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="NAME">event</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">event.split</span><span class="PUNC">(</span><span class="STRN">" "</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>115</span>
<span class='line'>116</span> </span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">event.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>117</span>
<span class='line'>118</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</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><span class="WHIT"> </span><span class="NAME">_add_remove</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">add</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>121</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>122</span>
<span class='line'>123</span> </span><span class="WHIT"> </span><span class="KEYW">return</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'>125</span>
<span class='line'>126</span>
<span class='line'>127</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">add</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>128</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>129</span> </span><span class="WHIT"> </span><span class="NAME">_attach</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</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'>130</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>131</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>132</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT"> </span><span class="NAME">_remove</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</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'>134</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>135</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>136</span>
<span class='line'>137</span> </span><span class="WHIT"> </span><span class="NAME">_attach_delegate</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">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">target</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>138</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>139</span> </span><span class="WHIT"> </span><span class="COMM">// attach the listener to the parent object</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT"> </span><span class="NAME">_add_remove</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>141</span>
<span class='line'>142</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">elem</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">tar</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>143</span>
<span class='line'>144</span> </span><span class="WHIT"> </span><span class="COMM">// IE 8 doesn't have event bound to element</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">window.event</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>146</span>
<span class='line'>147</span> </span><span class="WHIT"> </span><span class="COMM">// Get the live version of the target selector</span><span class="WHIT">
<span class='line'>148</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$_.$</span><span class="PUNC">(</span><span class="NAME">target</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>149</span>
<span class='line'>150</span> </span><span class="WHIT"> </span><span class="COMM">// Check each element to see if it matches the target</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">elem</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>152</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>153</span> </span><span class="WHIT"> </span><span class="COMM">// IE 8 doesn't have target in the event object</span><span class="WHIT">
<span class='line'>154</span> </span><span class="WHIT"> </span><span class="NAME">tar</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">e.target</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">e.srcElement</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>155</span>
<span class='line'>156</span> </span><span class="WHIT"> </span><span class="COMM">// Fire target callback when event bubbles from target</span><span class="WHIT">
<span class='line'>157</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">tar</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">[</span><span class="NAME">elem</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>158</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>159</span> </span><span class="WHIT"> </span><span class="COMM">// Trigger the event callback</span><span class="WHIT">
<span class='line'>160</span> </span><span class="WHIT"> </span><span class="NAME">callback.call</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">[</span><span class="NAME">elem</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>161</span>
<span class='line'>162</span> </span><span class="WHIT"> </span><span class="COMM">// Stop event propegation</span><span class="WHIT">
<span class='line'>163</span> </span><span class="WHIT"> </span><span class="NAME">e.stopPropagation</span><span class="PUNC">(</span><span class="PUNC">)</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="PUNC">}</span><span class="WHIT">
<span class='line'>166</span>
<span class='line'>167</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>168</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>169</span>
<span class='line'>170</span> </span><span class="WHIT"> </span><span class="COMM">// --------------------------------------------------------------------------</span><span class="WHIT">
<span class='line'>171</span>
<span class='line'>172</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>173</span> * Event Listener module
<span class='line'>174</span> *
<span class='line'>175</span> * @namespace
<span class='line'>176</span> * @name event
<span class='line'>177</span> * @memberOf $_
<span class='line'>178</span> */</span><span class="WHIT">
<span class='line'>179</span> </span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>180</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>181</span> * Adds an event that returns a callback when triggered on the selected
<span class='line'>182</span> * event and selector
<span class='line'>183</span> *
<span class='line'>184</span> * @memberOf $_.event
<span class='line'>185</span> * @name add
<span class='line'>186</span> * @function
<span class='line'>187</span> * @example Eg. $_("#selector").event.add("click", do_something());
<span class='line'>188</span> * @param string event
<span class='line'>189</span> * @param function callback
<span class='line'>190</span> */</span><span class="WHIT">
<span class='line'>191</span> </span><span class="WHIT"> </span><span class="NAME">add</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">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>192</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>193</span> </span><span class="WHIT"> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>194</span> </span><span class="WHIT"> </span><span class="NAME">_add_remove</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>195</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>197</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>198</span> * Removes an event bound the the specified selector, event type, and callback
<span class='line'>199</span> *
<span class='line'>200</span> * @memberOf $_.event
<span class='line'>201</span> * @name remove
<span class='line'>202</span> * @function
<span class='line'>203</span> * @example Eg. $_("#selector").event.remove("click", do_something());
<span class='line'>204</span> * @param string event
<span class='line'>205</span> * @param string callback
<span class='line'>206</span> */</span><span class="WHIT">
<span class='line'>207</span> </span><span class="WHIT"> </span><span class="NAME">remove</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">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>208</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>209</span> </span><span class="WHIT"> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>210</span> </span><span class="WHIT"> </span><span class="NAME">_add_remove</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>211</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>212</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>213</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>214</span> * Binds a persistent event to the document
<span class='line'>215</span> *
<span class='line'>216</span> * @memberOf $_.event
<span class='line'>217</span> * @name live
<span class='line'>218</span> * @function
<span class='line'>219</span> * @example Eg. $_.event.live(".button", "click", do_something());
<span class='line'>220</span> * @param string target
<span class='line'>221</span> * @param string event
<span class='line'>222</span> * @param function callback
<span class='line'>223</span> */</span><span class="WHIT">
<span class='line'>224</span> </span><span class="WHIT"> </span><span class="NAME">live</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">target</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>225</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>226</span> </span><span class="WHIT"> </span><span class="NAME">_attach_delegate</span><span class="PUNC">(</span><span class="NAME">document.documentElement</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">target</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</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'>227</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>228</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>229</span> * Binds an event to a parent object
<span class='line'>230</span> *
<span class='line'>231</span> * @memberOf $_.event
<span class='line'>232</span> * @name delegate
<span class='line'>233</span> * @function
<span class='line'>234</span> * @example Eg. $_("#parent").delegate(".button", "click", do_something());
<span class='line'>235</span> * @param string target
<span class='line'>236</span> * @param string event_type
<span class='line'>237</span> * @param function callback
<span class='line'>238</span> */</span><span class="WHIT">
<span class='line'>239</span> </span><span class="WHIT"> </span><span class="NAME">delegate</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">target</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>240</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>241</span> </span><span class="WHIT"> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>242</span> </span><span class="WHIT"> </span><span class="NAME">_attach_delegate</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">target</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</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'>243</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>244</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>245</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>246</span>
<span class='line'>247</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'event'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>248</span>
<span class='line'>249</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span></pre></body></html>
<span class='line'> 56</span> </span><span class="WHIT"> </span><span class="COMM">// Get the live version of the target selector</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$_.$</span><span class="PUNC">(</span><span class="NAME">target</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 58</span>
<span class='line'> 59</span> </span><span class="WHIT"> </span><span class="COMM">// Check each element to see if it matches the target</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">elem</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT"> </span><span class="COMM">// Fire target callback when event bubbles from target</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">e.target</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">[</span><span class="NAME">elem</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT"> </span><span class="COMM">// Trigger the event callback</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT"> </span><span class="NAME">callback.call</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">[</span><span class="NAME">elem</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 67</span>
<span class='line'> 68</span> </span><span class="WHIT"> </span><span class="COMM">// Stop event propegation</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="WHIT"> </span><span class="NAME">e.stopPropagation</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 72</span>
<span class='line'> 73</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 75</span>
<span class='line'> 76</span> </span><span class="WHIT"> </span><span class="COMM">// --------------------------------------------------------------------------</span><span class="WHIT">
<span class='line'> 77</span>
<span class='line'> 78</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 79</span> * Event Listener module
<span class='line'> 80</span> *
<span class='line'> 81</span> * @namespace
<span class='line'> 82</span> * @name event
<span class='line'> 83</span> * @memberOf $_
<span class='line'> 84</span> */</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 87</span> * Adds an event that returns a callback when triggered on the selected
<span class='line'> 88</span> * event and selector
<span class='line'> 89</span> *
<span class='line'> 90</span> * @memberOf $_.event
<span class='line'> 91</span> * @name add
<span class='line'> 92</span> * @function
<span class='line'> 93</span> * @example Eg. $_("#selector").event.add("click", do_something());
<span class='line'> 94</span> * @param string event
<span class='line'> 95</span> * @param function callback
<span class='line'> 96</span> */</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT"> </span><span class="NAME">add</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">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 99</span> </span><span class="WHIT"> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT"> </span><span class="NAME">_add_remove</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>101</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>102</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>104</span> * Removes an event bound the the specified selector, event type, and callback
<span class='line'>105</span> *
<span class='line'>106</span> * @memberOf $_.event
<span class='line'>107</span> * @name remove
<span class='line'>108</span> * @function
<span class='line'>109</span> * @example Eg. $_("#selector").event.remove("click", do_something());
<span class='line'>110</span> * @param string event
<span class='line'>111</span> * @param string callback
<span class='line'>112</span> */</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT"> </span><span class="NAME">remove</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">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>115</span> </span><span class="WHIT"> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>116</span> </span><span class="WHIT"> </span><span class="NAME">_add_remove</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>120</span> * Binds a persistent event to the document
<span class='line'>121</span> *
<span class='line'>122</span> * @memberOf $_.event
<span class='line'>123</span> * @name live
<span class='line'>124</span> * @function
<span class='line'>125</span> * @example Eg. $_.event.live(".button", "click", do_something());
<span class='line'>126</span> * @param string target
<span class='line'>127</span> * @param string event
<span class='line'>128</span> * @param function callback
<span class='line'>129</span> */</span><span class="WHIT">
<span class='line'>130</span> </span><span class="WHIT"> </span><span class="NAME">live</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">target</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>131</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>132</span> </span><span class="WHIT"> </span><span class="NAME">_attach_delegate</span><span class="PUNC">(</span><span class="NAME">document.documentElement</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">target</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</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'>133</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>134</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>135</span> * Binds an event to a parent object
<span class='line'>136</span> *
<span class='line'>137</span> * @memberOf $_.event
<span class='line'>138</span> * @name delegate
<span class='line'>139</span> * @function
<span class='line'>140</span> * @example Eg. $_("#parent").delegate(".button", "click", do_something());
<span class='line'>141</span> * @param string target
<span class='line'>142</span> * @param string event_type
<span class='line'>143</span> * @param function callback
<span class='line'>144</span> */</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT"> </span><span class="NAME">delegate</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">target</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>147</span> </span><span class="WHIT"> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>148</span> </span><span class="WHIT"> </span><span class="NAME">_attach_delegate</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">target</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</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'>149</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>150</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>152</span>
<span class='line'>153</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'event'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>154</span>
<span class='line'>155</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span></pre></body></html>

View File

@ -2,7 +2,7 @@
Kis JS Keep It Simple JS Library
Copyright Timothy J. Warren
License Public Domain
Version 0.6.0
Version 0.7.0
*/
(function (){
@ -44,7 +44,7 @@
}
else
{
sel = (typeof s !== "object") ? $(s) : s;
sel = $(s);
}
// Add the selector to the prototype
@ -240,24 +240,6 @@ if(typeof String.prototype.trim === "undefined")
// --------------------------------------------------------------------------
/**
* event.preventDefault/e.stopPropagation polyfill
* @private
*/
if(typeof Event.preventDefault === "undefined" && typeof window.event !== "undefined")
{
Event.prototype.preventDefault = function()
{
window.event.returnValue = false;
},
Event.prototype.stopPropagation = function()
{
window.event.cancelBubble = true;
}
}
// --------------------------------------------------------------------------
/**
* Array.isArray polyfill
*/
@ -695,23 +677,17 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
*/
text: function (value)
{
var oldValue, set, type, sel;
var oldValue, set, sel;
sel = this.el;
set = (typeof value !== "undefined") ? true : false;
type = (typeof sel.textContent !== "undefined")
? "textContent"
: (typeof sel.innerText !== "undefined")
? "innerText"
: "innerHTML";
oldValue = sel[type];
oldValue = sel.textContent;
if(set)
{
sel[type] = value;
sel.textContent = value;
return value;
}
else
@ -944,7 +920,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
* @param string url
* @param function callback
*/
$_.ext('sse', function(url, callback, poll_rate){
$_.ext('sse', function(url, callback){
var source;
@ -972,95 +948,12 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
*/
// Property name for expandos on DOM objects
var kis_expando = "KIS_0_6_0";
var _add_remove, e, _attach_delegate;
var _attach, _remove, _add_remove, e, _attach_delegate;
// Define the proper _attach and _remove functions
// based on browser support
if(typeof document.addEventListener !== "undefined")
// Don't bother defining the methods if event api isn't supports
if (typeof document.addEventListener === "undefined")
{
/**
* @private
*/
_attach = function (sel, event, callback)
{
if(typeof sel.addEventListener !== "undefined")
{
// Duplicated events are dropped, per the specification
sel.addEventListener(event, callback, false);
}
};
/**
* @private
*/
_remove = function (sel, event, callback)
{
if(typeof sel.removeEventListener !== "undefined")
{
sel.removeEventListener(event, callback, false);
}
};
}
// typeof function doesn't work in IE where attachEvent is available: brute force it
else if(typeof document.attachEvent !== "undefined")
{
/**
* @private
*/
_attach = function (sel, event, callback)
{
function _listener () {
// Internet Explorer fails to correctly set the 'this' object
// for event listeners, so we need to set it ourselves.
callback.apply(arguments[0]);
}
if (typeof sel.attachEvent !== "undefined")
{
_remove(event, callback); // Make sure we don't have duplicate listeners
sel.attachEvent("on" + event, _listener);
// Store our listener so we can remove it later
var expando = sel[kis_expando] = sel[kis_expando] || {};
expando.listeners = expando.listeners || {};
expando.listeners[event] = expando.listeners[event] || [];
expando.listeners[event].push({
callback: callback,
_listener: _listener
});
}
};
/**
* @private
*/
_remove = function (sel, event, callback)
{
if(typeof sel.detachEvent !== "undefined")
{
var expando = sel[kis_expando];
if (expando && expando.listeners
&& expando.listeners[event])
{
var listeners = expando.listeners[event];
var len = listeners.length;
for (var i=0; i<len; i++)
{
if (listeners[i].callback === callback)
{
sel.detachEvent("on" + event, listeners[i]._listener);
listeners.splice(i, 1);
if(listeners.length === 0)
{
delete expando.listeners[event];
}
return;
}
}
}
}
};
return false;
}
_add_remove = function (sel, event, callback, add)
@ -1087,15 +980,10 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
return;
}
if(add === true)
{
_attach(sel, event, callback);
}
else
{
_remove(sel, event, callback);
}
// Bind the event
(add === true)
? sel.addEventListener(event, callback, false)
: sel.removeEventListener(event, callback, false);
};
_attach_delegate = function(sel, target, event, callback)
@ -1103,10 +991,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
// attach the listener to the parent object
_add_remove(sel, event, function(e){
var elem, t, tar;
// IE 8 doesn't have event bound to element
e = e || window.event;
var elem, t;
// Get the live version of the target selector
t = $_.$(target, sel);
@ -1114,11 +999,8 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
// Check each element to see if it matches the target
for(elem in t)
{
// IE 8 doesn't have target in the event object
tar = e.target || e.srcElement;
// Fire target callback when event bubbles from target
if(tar == t[elem])
if(e.target == t[elem])
{
// Trigger the event callback
callback.call(t[elem], e);

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

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

View File

@ -2,7 +2,7 @@
Kis JS Keep It Simple JS Library
Copyright Timothy J. Warren
License Public Domain
Version 0.6.0
Version 0.7.0
*/
(function (){
@ -44,7 +44,7 @@
}
else
{
sel = (typeof s !== "object") ? $(s) : s;
sel = $(s);
}
// Add the selector to the prototype
@ -240,24 +240,6 @@ if(typeof String.prototype.trim === "undefined")
// --------------------------------------------------------------------------
/**
* event.preventDefault/e.stopPropagation polyfill
* @private
*/
if(typeof Event.preventDefault === "undefined" && typeof window.event !== "undefined")
{
Event.prototype.preventDefault = function()
{
window.event.returnValue = false;
},
Event.prototype.stopPropagation = function()
{
window.event.cancelBubble = true;
}
}
// --------------------------------------------------------------------------
/**
* Array.isArray polyfill
*/
@ -403,7 +385,7 @@ if (typeof Array.isArray === "undefined")
* @param string url
* @param function callback
*/
$_.ext('sse', function(url, callback, poll_rate){
$_.ext('sse', function(url, callback){
var source;
@ -433,95 +415,12 @@ if (typeof Array.isArray === "undefined")
"use strict";
// Property name for expandos on DOM objects
var kis_expando = "KIS_0_6_0";
var _add_remove, e, _attach_delegate;
var _attach, _remove, _add_remove, e, _attach_delegate;
// Define the proper _attach and _remove functions
// based on browser support
if(typeof document.addEventListener !== "undefined")
// Don't bother defining the methods if event api isn't supports
if (typeof document.addEventListener === "undefined")
{
/**
* @private
*/
_attach = function (sel, event, callback)
{
if(typeof sel.addEventListener !== "undefined")
{
// Duplicated events are dropped, per the specification
sel.addEventListener(event, callback, false);
}
};
/**
* @private
*/
_remove = function (sel, event, callback)
{
if(typeof sel.removeEventListener !== "undefined")
{
sel.removeEventListener(event, callback, false);
}
};
}
// typeof function doesn't work in IE where attachEvent is available: brute force it
else if(typeof document.attachEvent !== "undefined")
{
/**
* @private
*/
_attach = function (sel, event, callback)
{
function _listener () {
// Internet Explorer fails to correctly set the 'this' object
// for event listeners, so we need to set it ourselves.
callback.apply(arguments[0]);
}
if (typeof sel.attachEvent !== "undefined")
{
_remove(event, callback); // Make sure we don't have duplicate listeners
sel.attachEvent("on" + event, _listener);
// Store our listener so we can remove it later
var expando = sel[kis_expando] = sel[kis_expando] || {};
expando.listeners = expando.listeners || {};
expando.listeners[event] = expando.listeners[event] || [];
expando.listeners[event].push({
callback: callback,
_listener: _listener
});
}
};
/**
* @private
*/
_remove = function (sel, event, callback)
{
if(typeof sel.detachEvent !== "undefined")
{
var expando = sel[kis_expando];
if (expando && expando.listeners
&& expando.listeners[event])
{
var listeners = expando.listeners[event];
var len = listeners.length;
for (var i=0; i<len; i++)
{
if (listeners[i].callback === callback)
{
sel.detachEvent("on" + event, listeners[i]._listener);
listeners.splice(i, 1);
if(listeners.length === 0)
{
delete expando.listeners[event];
}
return;
}
}
}
}
};
return false;
}
_add_remove = function (sel, event, callback, add)
@ -548,15 +447,10 @@ if (typeof Array.isArray === "undefined")
return;
}
if(add === true)
{
_attach(sel, event, callback);
}
else
{
_remove(sel, event, callback);
}
// Bind the event
(add === true)
? sel.addEventListener(event, callback, false)
: sel.removeEventListener(event, callback, false);
};
_attach_delegate = function(sel, target, event, callback)
@ -564,10 +458,7 @@ if (typeof Array.isArray === "undefined")
// attach the listener to the parent object
_add_remove(sel, event, function(e){
var elem, t, tar;
// IE 8 doesn't have event bound to element
e = e || window.event;
var elem, t;
// Get the live version of the target selector
t = $_.$(target, sel);
@ -575,11 +466,8 @@ if (typeof Array.isArray === "undefined")
// Check each element to see if it matches the target
for(elem in t)
{
// IE 8 doesn't have target in the event object
tar = e.target || e.srcElement;
// Fire target callback when event bubbles from target
if(tar == t[elem])
if(e.target == t[elem])
{
// Trigger the event callback
callback.call(t[elem], e);
@ -1093,23 +981,17 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
*/
text: function (value)
{
var oldValue, set, type, sel;
var oldValue, set, sel;
sel = this.el;
set = (typeof value !== "undefined") ? true : false;
type = (typeof sel.textContent !== "undefined")
? "textContent"
: (typeof sel.innerText !== "undefined")
? "innerText"
: "innerHTML";
oldValue = sel[type];
oldValue = sel.textContent;
if(set)
{
sel[type] = value;
sel.textContent = value;
return value;
}
else

16
kis-lite-min.js vendored
View File

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

View File

@ -2,7 +2,7 @@
Kis JS Keep It Simple JS Library
Copyright Timothy J. Warren
License Public Domain
Version 0.6.0
Version 0.7.0
*/
(function (){
@ -44,7 +44,7 @@
}
else
{
sel = (typeof s !== "object") ? $(s) : s;
sel = $(s);
}
// Add the selector to the prototype
@ -240,24 +240,6 @@ if(typeof String.prototype.trim === "undefined")
// --------------------------------------------------------------------------
/**
* event.preventDefault/e.stopPropagation polyfill
* @private
*/
if(typeof Event.preventDefault === "undefined" && typeof window.event !== "undefined")
{
Event.prototype.preventDefault = function()
{
window.event.returnValue = false;
},
Event.prototype.stopPropagation = function()
{
window.event.cancelBubble = true;
}
}
// --------------------------------------------------------------------------
/**
* Array.isArray polyfill
*/
@ -403,7 +385,7 @@ if (typeof Array.isArray === "undefined")
* @param string url
* @param function callback
*/
$_.ext('sse', function(url, callback, poll_rate){
$_.ext('sse', function(url, callback){
var source;
@ -433,95 +415,12 @@ if (typeof Array.isArray === "undefined")
"use strict";
// Property name for expandos on DOM objects
var kis_expando = "KIS_0_6_0";
var _add_remove, e, _attach_delegate;
var _attach, _remove, _add_remove, e, _attach_delegate;
// Define the proper _attach and _remove functions
// based on browser support
if(typeof document.addEventListener !== "undefined")
// Don't bother defining the methods if event api isn't supports
if (typeof document.addEventListener === "undefined")
{
/**
* @private
*/
_attach = function (sel, event, callback)
{
if(typeof sel.addEventListener !== "undefined")
{
// Duplicated events are dropped, per the specification
sel.addEventListener(event, callback, false);
}
};
/**
* @private
*/
_remove = function (sel, event, callback)
{
if(typeof sel.removeEventListener !== "undefined")
{
sel.removeEventListener(event, callback, false);
}
};
}
// typeof function doesn't work in IE where attachEvent is available: brute force it
else if(typeof document.attachEvent !== "undefined")
{
/**
* @private
*/
_attach = function (sel, event, callback)
{
function _listener () {
// Internet Explorer fails to correctly set the 'this' object
// for event listeners, so we need to set it ourselves.
callback.apply(arguments[0]);
}
if (typeof sel.attachEvent !== "undefined")
{
_remove(event, callback); // Make sure we don't have duplicate listeners
sel.attachEvent("on" + event, _listener);
// Store our listener so we can remove it later
var expando = sel[kis_expando] = sel[kis_expando] || {};
expando.listeners = expando.listeners || {};
expando.listeners[event] = expando.listeners[event] || [];
expando.listeners[event].push({
callback: callback,
_listener: _listener
});
}
};
/**
* @private
*/
_remove = function (sel, event, callback)
{
if(typeof sel.detachEvent !== "undefined")
{
var expando = sel[kis_expando];
if (expando && expando.listeners
&& expando.listeners[event])
{
var listeners = expando.listeners[event];
var len = listeners.length;
for (var i=0; i<len; i++)
{
if (listeners[i].callback === callback)
{
sel.detachEvent("on" + event, listeners[i]._listener);
listeners.splice(i, 1);
if(listeners.length === 0)
{
delete expando.listeners[event];
}
return;
}
}
}
}
};
return false;
}
_add_remove = function (sel, event, callback, add)
@ -548,15 +447,10 @@ if (typeof Array.isArray === "undefined")
return;
}
if(add === true)
{
_attach(sel, event, callback);
}
else
{
_remove(sel, event, callback);
}
// Bind the event
(add === true)
? sel.addEventListener(event, callback, false)
: sel.removeEventListener(event, callback, false);
};
_attach_delegate = function(sel, target, event, callback)
@ -564,10 +458,7 @@ if (typeof Array.isArray === "undefined")
// attach the listener to the parent object
_add_remove(sel, event, function(e){
var elem, t, tar;
// IE 8 doesn't have event bound to element
e = e || window.event;
var elem, t;
// Get the live version of the target selector
t = $_.$(target, sel);
@ -575,11 +466,8 @@ if (typeof Array.isArray === "undefined")
// Check each element to see if it matches the target
for(elem in t)
{
// IE 8 doesn't have target in the event object
tar = e.target || e.srcElement;
// Fire target callback when event bubbles from target
if(tar == t[elem])
if(e.target == t[elem])
{
// Trigger the event callback
callback.call(t[elem], e);

37
kis-min.js vendored
View File

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

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

@ -2,7 +2,7 @@
Kis JS Keep It Simple JS Library
Copyright Timothy J. Warren
License Public Domain
Version 0.6.0
Version 0.7.0
*/
(function (){
@ -44,7 +44,7 @@
}
else
{
sel = (typeof s !== "object") ? $(s) : s;
sel = $(s);
}
// Add the selector to the prototype

View File

@ -416,23 +416,17 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
*/
text: function (value)
{
var oldValue, set, type, sel;
var oldValue, set, sel;
sel = this.el;
set = (typeof value !== "undefined") ? true : false;
type = (typeof sel.textContent !== "undefined")
? "textContent"
: (typeof sel.innerText !== "undefined")
? "innerText"
: "innerHTML";
oldValue = sel[type];
oldValue = sel.textContent;
if(set)
{
sel[type] = value;
sel.textContent = value;
return value;
}
else

View File

@ -130,7 +130,7 @@
* @param string url
* @param function callback
*/
$_.ext('sse', function(url, callback, poll_rate){
$_.ext('sse', function(url, callback){
var source;

View File

@ -8,95 +8,12 @@
"use strict";
// Property name for expandos on DOM objects
var kis_expando = "KIS_0_6_0";
var _add_remove, e, _attach_delegate;
var _attach, _remove, _add_remove, e, _attach_delegate;
// Define the proper _attach and _remove functions
// based on browser support
if(typeof document.addEventListener !== "undefined")
// Don't bother defining the methods if event api isn't supports
if (typeof document.addEventListener === "undefined")
{
/**
* @private
*/
_attach = function (sel, event, callback)
{
if(typeof sel.addEventListener !== "undefined")
{
// Duplicated events are dropped, per the specification
sel.addEventListener(event, callback, false);
}
};
/**
* @private
*/
_remove = function (sel, event, callback)
{
if(typeof sel.removeEventListener !== "undefined")
{
sel.removeEventListener(event, callback, false);
}
};
}
// typeof function doesn't work in IE where attachEvent is available: brute force it
else if(typeof document.attachEvent !== "undefined")
{
/**
* @private
*/
_attach = function (sel, event, callback)
{
function _listener () {
// Internet Explorer fails to correctly set the 'this' object
// for event listeners, so we need to set it ourselves.
callback.apply(arguments[0]);
}
if (typeof sel.attachEvent !== "undefined")
{
_remove(event, callback); // Make sure we don't have duplicate listeners
sel.attachEvent("on" + event, _listener);
// Store our listener so we can remove it later
var expando = sel[kis_expando] = sel[kis_expando] || {};
expando.listeners = expando.listeners || {};
expando.listeners[event] = expando.listeners[event] || [];
expando.listeners[event].push({
callback: callback,
_listener: _listener
});
}
};
/**
* @private
*/
_remove = function (sel, event, callback)
{
if(typeof sel.detachEvent !== "undefined")
{
var expando = sel[kis_expando];
if (expando && expando.listeners
&& expando.listeners[event])
{
var listeners = expando.listeners[event];
var len = listeners.length;
for (var i=0; i<len; i++)
{
if (listeners[i].callback === callback)
{
sel.detachEvent("on" + event, listeners[i]._listener);
listeners.splice(i, 1);
if(listeners.length === 0)
{
delete expando.listeners[event];
}
return;
}
}
}
}
};
return false;
}
_add_remove = function (sel, event, callback, add)
@ -123,15 +40,10 @@
return;
}
if(add === true)
{
_attach(sel, event, callback);
}
else
{
_remove(sel, event, callback);
}
// Bind the event
(add === true)
? sel.addEventListener(event, callback, false)
: sel.removeEventListener(event, callback, false);
};
_attach_delegate = function(sel, target, event, callback)
@ -139,10 +51,7 @@
// attach the listener to the parent object
_add_remove(sel, event, function(e){
var elem, t, tar;
// IE 8 doesn't have event bound to element
e = e || window.event;
var elem, t;
// Get the live version of the target selector
t = $_.$(target, sel);
@ -150,11 +59,8 @@
// Check each element to see if it matches the target
for(elem in t)
{
// IE 8 doesn't have target in the event object
tar = e.target || e.srcElement;
// Fire target callback when event bubbles from target
if(tar == t[elem])
if(e.target == t[elem])
{
// Trigger the event callback
callback.call(t[elem], e);

View File

@ -19,24 +19,6 @@ if(typeof String.prototype.trim === "undefined")
// --------------------------------------------------------------------------
/**
* event.preventDefault/e.stopPropagation polyfill
* @private
*/
if(typeof Event.preventDefault === "undefined" && typeof window.event !== "undefined")
{
Event.prototype.preventDefault = function()
{
window.event.returnValue = false;
},
Event.prototype.stopPropagation = function()
{
window.event.cancelBubble = true;
}
}
// --------------------------------------------------------------------------
/**
* Array.isArray polyfill
*/

0
tests/index.html Executable file → Normal file
View File