Remove legacy feature checks and server sent events

This commit is contained in:
Timothy Warren 2013-12-11 21:37:51 -05:00
parent 67991ae40d
commit 517fe203e7
30 changed files with 6341 additions and 1338 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -15,211 +15,140 @@
<span class='line'> 8</span> <span class='line'> 8</span>
<span class='line'> 9</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 9</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 10</span> <span class='line'> 10</span>
<span class='line'> 11</span> </span><span class="WHIT"> </span><span class="COMM">// Most functions rely on a string selector</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">$_</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">$</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 12</span> </span><span class="WHIT"> </span><span class="COMM">// which returns html elements. This requires</span><span class="WHIT"> <span class='line'> 12</span>
<span class='line'> 13</span> </span><span class="WHIT"> </span><span class="COMM">// document.querySelectorAll or a custom</span><span class="WHIT"> <span class='line'> 13</span>
<span class='line'> 14</span> </span><span class="WHIT"> </span><span class="COMM">// selector engine. I choose to just use the</span><span class="WHIT"> <span class='line'> 14</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 15</span> </span><span class="WHIT"> </span><span class="COMM">// browser feature, since it is present in</span><span class="WHIT"> <span class='line'> 15</span> * $_
<span class='line'> 16</span> </span><span class="WHIT"> </span><span class="COMM">// IE 8+, and all other major browsers</span><span class="WHIT"> <span class='line'> 16</span> *
<span class='line'> 17</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">document.querySelector</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 17</span> * Constructor function
<span class='line'> 18</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="KEYW">return</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 19</span> * @constuctor
<span class='line'> 20</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 20</span> * @namespace
<span class='line'> 21</span> <span class='line'> 21</span> * @param string selector
<span class='line'> 22</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">$_</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">$</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">dcopy</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 22</span> * @return object
<span class='line'> 23</span> <span class='line'> 23</span> */</span><span class="WHIT">
<span class='line'> 24</span> <span class='line'> 24</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'> 25</span> </span><span class="WHIT"> </span><span class="COMM">/** <span class='line'> 25</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 26</span> * $_ <span class='line'> 26</span> </span><span class="WHIT"> </span><span class="COMM">// Have documentElement be default selector, just in case</span><span class="WHIT">
<span class='line'> 27</span> * <span class='line'> 27</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 28</span> * Constructor function <span class='line'> 28</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 29</span> * <span class='line'> 29</span> </span><span class="WHIT"> </span><span class="COMM">// Defines a "global" selector for that instance</span><span class="WHIT">
<span class='line'> 30</span> * @constuctor <span class='line'> 30</span> </span><span class="WHIT"> </span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">$_.el</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 31</span> * @namespace <span class='line'> 31</span> </span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">$_.el</span><span class="WHIT">
<span class='line'> 32</span> * @param string selector <span class='line'> 32</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">document.documentElement</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 33</span> * @return object <span class='line'> 33</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 34</span> */</span><span class="WHIT"> <span class='line'> 34</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'> 35</span> </span><span class="WHIT"> </span><span class="NAME">$_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 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="PUNC">{</span><span class="WHIT"> <span class='line'> 36</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'> 37</span> </span><span class="WHIT"> </span><span class="COMM">// Have documentElement be default selector, just in case</span><span class="WHIT"> <span class='line'> 37</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 38</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 38</span>
<span class='line'> 39</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 39</span> </span><span class="WHIT"> </span><span class="COMM">// Add the selector to the prototype</span><span class="WHIT">
<span class='line'> 40</span> </span><span class="WHIT"> </span><span class="COMM">// Defines a "global" selector for that instance</span><span class="WHIT"> <span class='line'> 40</span> </span><span class="WHIT"> </span><span class="NAME">$_.prototype.el</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="WHIT"> </span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">$_.el</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 41</span>
<span class='line'> 42</span> </span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">$_.el</span><span class="WHIT"> <span class='line'> 42</span> </span><span class="WHIT"> </span><span class="COMM">// Use the $_ object as it's own prototype</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">document.documentElement</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 43</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">self</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Object.create</span><span class="PUNC">(</span><span class="NAME">$_</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 44</span>
<span class='line'> 45</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> <span class='line'> 45</span> </span><span class="WHIT"> </span><span class="COMM">// Give sel to each extension.</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 46</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">self</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'> 47</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 48</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 48</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">self</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</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 class='line'> 49</span> <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="COMM">// Add the selector to the prototype</span><span class="WHIT"> <span class='line'> 50</span> </span><span class="WHIT"> </span><span class="NAME">self</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">el</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="WHIT"> </span><span class="NAME">$_.prototype.el</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 51</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 52</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="COMM">// Use the $_ object as it's own prototype</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">self</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dcopy</span><span class="PUNC">(</span><span class="NAME">$_</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 54</span> </span><span class="WHIT"> </span><span class="NAME">self.el</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 55</span> <span class='line'> 55</span>
<span class='line'> 56</span> </span><span class="WHIT"> </span><span class="COMM">// Give sel to each extension.</span><span class="WHIT"> <span class='line'> 56</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">self</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">self</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 57</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT"> </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="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">self</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</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 class='line'> 59</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 60</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 60</span> * Simple DOM selector function
<span class='line'> 61</span> </span><span class="WHIT"> </span><span class="NAME">self</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">el</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 61</span> *
<span class='line'> 62</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 62</span> * @memberOf $_
<span class='line'> 63</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 63</span> * @param string selector
<span class='line'> 64</span> <span class='line'> 64</span> * @param object context
<span class='line'> 65</span> </span><span class="WHIT"> </span><span class="NAME">self.el</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 65</span> * @return object
<span class='line'> 66</span> <span class='line'> 66</span> * @type object
<span class='line'> 67</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">self</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 67</span> */</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 68</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="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">context</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 69</span> <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="COMM">/** <span class='line'> 70</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">c</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 71</span> * Simple DOM selector function <span class='line'> 71</span>
<span class='line'> 72</span> * <span class='line'> 72</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"string"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 73</span> * @memberOf $_ <span class='line'> 73</span>
<span class='line'> 74</span> * @param string selector <span class='line'> 74</span> </span><span class="WHIT"> </span><span class="COMM">//Check for a context of a specific element, otherwise, just run on the document</span><span class="WHIT">
<span class='line'> 75</span> * @param object context <span class='line'> 75</span> </span><span class="WHIT"> </span><span class="NAME">c</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">context</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">context.nodeType</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 76</span> * @return object <span class='line'> 76</span> </span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">context</span><span class="WHIT">
<span class='line'> 77</span> * @type object <span class='line'> 77</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">document</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 78</span> */</span><span class="WHIT"> <span class='line'> 78</span>
<span class='line'> 79</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="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">context</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 79</span> </span><span class="WHIT"> </span><span class="COMM">//Pick the quickest method for each kind of selector</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 80</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a.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'> 81</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">c</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 81</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 82</span> <span class='line'> 82</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">document.getElementById</span><span class="PUNC">(</span><span class="NAME">a.split</span><span class="PUNC">(</span><span class="STRN">'#'</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"string"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 83</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 84</span> <span class='line'> 84</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT"> </span><span class="COMM">//Check for a context of a specific element, otherwise, just run on the document</span><span class="WHIT"> <span class='line'> 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="NAME">c</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">context</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">context.nodeType</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 86</span> </span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">c.querySelectorAll</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">)</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><span class="NAME">context</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="PUNC">:</span><span class="WHIT"> </span><span class="NAME">document</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 88</span>
<span class='line'> 89</span> <span class='line'> 89</span> </span><span class="WHIT"> </span><span class="COMM">//Return the single object if applicable</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT"> </span><span class="COMM">//Pick the quickest method for each kind of selector</span><span class="WHIT"> <span class='line'> 90</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a.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'> 91</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 92</span>
<span class='line'> 93</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">document.getElementById</span><span class="PUNC">(</span><span class="NAME">a.split</span><span class="PUNC">(</span><span class="STRN">'#'</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 93</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 94</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 94</span> * Adds the property `obj` to the $_ object, calling it `name`
<span class='line'> 95</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> <span class='line'> 95</span> *
<span class='line'> 96</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 96</span> * @param string name
<span class='line'> 97</span> </span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">c.querySelectorAll</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 97</span> * @param object obj
<span class='line'> 98</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 98</span> */</span><span class="WHIT">
<span class='line'> 99</span> <span class='line'> 99</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</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">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT"> </span><span class="COMM">//Return the single object if applicable</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><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>101</span> </span><span class="WHIT"> </span><span class="NAME">obj.el</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</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'>102</span> </span><span class="WHIT"> </span><span class="NAME">$_</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>103</span> <span class='line'>103</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT"> </span><span class="COMM">/** <span class='line'>104</span>
<span class='line'>105</span> * Deep copy/prototypical constructor function <span class='line'>105</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>106</span> * <span class='line'>106</span> * Iterates over a $_ object, applying a callback to each item
<span class='line'>107</span> * @param object obj <span class='line'>107</span> *
<span class='line'>108</span> * @private <span class='line'>108</span> * @name $_.each
<span class='line'>109</span> * @return object <span class='line'>109</span> * @function
<span class='line'>110</span> * @type object <span class='line'>110</span> * @param function callback
<span class='line'>111</span> */</span><span class="WHIT"> <span class='line'>111</span> */</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT"> </span><span class="NAME">dcopy</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">obj</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'>112</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'each'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'>113</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">F</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>114</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">sel.length</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">window</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>115</span> <span class='line'>115</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>116</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'>116</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'>117</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'>117</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>118</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'>119</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>120</span> <span class='line'>120</span> </span><span class="WHIT"> </span><span class="NAME">callback.call</span><span class="PUNC">(</span><span class="NAME">sel</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'>121</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">Object.create</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'>121</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'>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><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">Object.create</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>123</span>
<span class='line'>124</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'>124</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>125</span> <span class='line'>125</span> * Retrieves the type of the passed variable
<span class='line'>126</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="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>126</span> *
<span class='line'>127</span> <span class='line'>127</span> * @param mixed obj
<span class='line'>128</span> </span><span class="WHIT"> </span><span class="KEYW">if</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">"object"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"function"</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'>128</span> * @return string
<span class='line'>129</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'>129</span> * @type string
<span class='line'>130</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>130</span> */</span><span class="WHIT">
<span class='line'>131</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="NAME">$_.type</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">obj</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>132</span> <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="COMM">/** <span class='line'>133</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">call</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>134</span> * @private <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 class='line'>135</span> </span><span class="WHIT"> </span><span class="COMM">//fallback on 'typeof' for truthy primitive values</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT"> </span><span class="NAME">F</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>136</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>137</span> <span class='line'>137</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>138</span> </span><span class="WHIT"> </span><span class="NAME">F.prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>138</span>
<span class='line'>139</span> <span class='line'>139</span> </span><span class="WHIT"> </span><span class="COMM">//Strip x from [object x] and return</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">F</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>140</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString.call</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">match</span><span class="PUNC">(</span><span class="REGX">/\s([a-z|A-Z]+)/</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>141</span> <span class='line'>141</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>142</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>142</span>
<span class='line'>143</span> <span class='line'>143</span> </span><span class="WHIT"> </span><span class="COMM">//Set global variables</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT"> </span><span class="COMM">/** <span class='line'>144</span> </span><span class="WHIT"> </span><span class="NAME">$_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.$_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.$_</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">$_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>145</span> * Adds the property `obj` to the $_ object, calling it `name` <span class='line'>145</span> </span><span class="WHIT"> </span><span class="NAME">$_.$</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>146</span> * <span class='line'>146</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>147</span> * @param string name <span class='line'>147</span> </span></pre></body></html>
<span class='line'>148</span> * @param object obj
<span class='line'>149</span> */</span><span class="WHIT">
<span class='line'>150</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</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">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>152</span> </span><span class="WHIT"> </span><span class="NAME">obj.el</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>153</span> </span><span class="WHIT"> </span><span class="NAME">$_</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>154</span> </span><span class="WHIT"> </span><span class="PUNC">}</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">/**
<span class='line'>157</span> * Iterates over a $_ object, applying a callback to each item
<span class='line'>158</span> *
<span class='line'>159</span> * @name $_.each
<span class='line'>160</span> * @function
<span class='line'>161</span> * @param function callback
<span class='line'>162</span> */</span><span class="WHIT">
<span class='line'>163</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'each'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>164</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>165</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">sel.length</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">window</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>166</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>167</span> </span><span class="WHIT"> </span><span class="COMM">// Use the native method, if it exists</span><span class="WHIT">
<span class='line'>168</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">Array.prototype.forEach</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>169</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>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 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">
<span class='line'>178</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>179</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>180</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>181</span>
<span class='line'>182</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">selx</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>183</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">x</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">x</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">x</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>184</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>185</span> </span><span class="WHIT"> </span><span class="NAME">selx</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sel.item</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">sel.item</span><span class="PUNC">(</span><span class="NAME">x</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">x</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>186</span> </span><span class="WHIT"> </span><span class="NAME">callback.call</span><span class="PUNC">(</span><span class="NAME">selx</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">selx</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>187</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>188</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>189</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>190</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>191</span> </span><span class="WHIT"> </span><span class="NAME">callback.call</span><span class="PUNC">(</span><span class="NAME">sel</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'>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="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>194</span>
<span class='line'>195</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>196</span> * Retrieves the type of the passed variable
<span class='line'>197</span> *
<span class='line'>198</span> * @param mixed obj
<span class='line'>199</span> * @return string
<span class='line'>200</span> * @type string
<span class='line'>201</span> */</span><span class="WHIT">
<span class='line'>202</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="KEYW">function</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>203</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>204</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">call</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>205</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>206</span> </span><span class="WHIT"> </span><span class="COMM">//fallback on 'typeof' for truthy primitive values</span><span class="WHIT">
<span class='line'>207</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</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 class='line'>210</span> </span><span class="WHIT"> </span><span class="COMM">//Strip x from [object x] and return</span><span class="WHIT">
<span class='line'>211</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString.call</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">match</span><span class="PUNC">(</span><span class="REGX">/\s([a-z|A-Z]+)/</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">toLowerCase</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 class='line'>214</span> </span><span class="WHIT"> </span><span class="COMM">//Set global variables</span><span class="WHIT">
<span class='line'>215</span> </span><span class="WHIT"> </span><span class="NAME">$_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.$_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.$_</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">$_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>216</span> </span><span class="WHIT"> </span><span class="NAME">$_.$</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>217</span>
<span class='line'>218</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

@ -160,7 +160,7 @@
<span class='line'>153</span> </span><span class="WHIT"> </span><span class="NAME">addClass</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">c</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'>153</span> </span><span class="WHIT"> </span><span class="NAME">addClass</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">c</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>154</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'>154</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>155</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'>155</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'>156</span> </span><span class="WHIT"> </span><span class="NAME">this.classList.add</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>156</span> </span><span class="WHIT"> </span><span class="NAME">e.classList.add</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>157</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>157</span> </span><span class="WHIT"> </span><span class="PUNC">}</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="PUNC">,</span><span class="WHIT"> <span class='line'>158</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>159</span> </span><span class="WHIT"> </span><span class="COMM">/** <span class='line'>159</span> </span><span class="WHIT"> </span><span class="COMM">/**

View File

@ -14,148 +14,113 @@
<span class='line'> 7</span> <span class='line'> 7</span>
<span class='line'> 8</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 8</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 9</span> <span class='line'> 9</span>
<span class='line'> 10</span> </span><span class="WHIT"> </span><span class="COMM">// Don't bother even defining the object if the XMLHttpRequest isn't available</span><span class="WHIT"> <span class='line'> 10</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ajax</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 11</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">window.XMLHttpRequest</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 11</span> </span><span class="WHIT"> </span><span class="NAME">_do</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="WHIT"> </span><span class="NAME">isPost</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 12</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 12</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 13</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 13</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 14</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 14</span> </span><span class="WHIT"> </span><span class="NAME">request</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">XMLHttpRequest</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 15</span> <span class='line'> 15</span>
<span class='line'> 16</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ajax</span><span class="WHIT"> </span><span class="PUNC">=</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">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">success_callback</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 17</span> </span><span class="WHIT"> </span><span class="NAME">_do</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="WHIT"> </span><span class="NAME">isPost</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><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 18</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 19</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> <span class='line'> 19</span> * @private
<span class='line'> 20</span> </span><span class="WHIT"> </span><span class="NAME">request</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">XMLHttpRequest</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 20</span> */</span><span class="WHIT">
<span class='line'> 21</span> <span class='line'> 21</span> </span><span class="WHIT"> </span><span class="NAME">success_callback</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 22</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">success_callback</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 22</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 23</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 23</span>
<span class='line'> 24</span> </span><span class="WHIT"> </span><span class="COMM">/** <span class='line'> 24</span> </span><span class="WHIT"> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">isPost</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"POST"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"GET"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 25</span> * @private <span class='line'> 25</span>
<span class='line'> 26</span> */</span><span class="WHIT"> <span class='line'> 26</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">"GET"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 27</span> </span><span class="WHIT"> </span><span class="NAME">success_callback</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 27</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 28</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 28</span> </span><span class="WHIT"> </span><span class="NAME">url</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">url.match</span><span class="PUNC">(</span><span class="REGX">/\?/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 29</span> <span class='line'> 29</span> </span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">this._serialize</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 30</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="NAME">isPost</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"POST"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"GET"</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><span class="STRN">"?"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this._serialize</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 31</span> <span class='line'> 31</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 32</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">"GET"</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="PUNC">{</span><span class="WHIT"> <span class='line'> 33</span> </span><span class="WHIT"> </span><span class="NAME">request.open</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">url</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 34</span> </span><span class="WHIT"> </span><span class="NAME">url</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">url.match</span><span class="PUNC">(</span><span class="REGX">/\?/</span><span class="PUNC">)</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="PUNC">?</span><span class="WHIT"> </span><span class="NAME">this._serialize</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 35</span> </span><span class="WHIT"> </span><span class="NAME">request.onreadystatechange</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="PUNC">)</span><span class="WHIT">
<span class='line'> 36</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"?"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this._serialize</span><span class="PUNC">(</span><span class="NAME">data</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="PUNC">}</span><span class="WHIT"> <span class='line'> 37</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">request.readyState</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 38</span> <span class='line'> 38</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 39</span> </span><span class="WHIT"> </span><span class="NAME">request.open</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">url</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 39</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">request.status</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">200</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 40</span> <span class='line'> 40</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="WHIT"> </span><span class="NAME">request.onreadystatechange</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="PUNC">)</span><span class="WHIT"> <span class='line'> 41</span> </span><span class="WHIT"> </span><span class="NAME">success_callback.call</span><span class="PUNC">(</span><span class="NAME">request.responseText</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">request.responseText</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 42</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">request.readyState</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 43</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 44</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">request.status</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">200</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 45</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">error_callback</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="WHIT"> </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 class='line'> 47</span> </span><span class="WHIT"> </span><span class="NAME">success_callback.call</span><span class="PUNC">(</span><span class="NAME">request.responseText</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">request.responseText</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 47</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'> 48</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 48</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 49</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> <span class='line'> 49</span> </span><span class="WHIT"> </span><span class="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'> 50</span>
<span class='line'> 51</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">error_callback</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 51</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 52</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 53</span> </span><span class="WHIT"> </span><span class="NAME">error_callback.call</span><span class="PUNC">(</span><span class="NAME">request.status</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">request.status</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 53</span>
<span class='line'> 54</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 54</span> </span><span class="WHIT"> </span><span class="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">
<span class='line'> 55</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 55</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 56</span> <span class='line'> 56</span> </span><span class="WHIT"> </span><span class="NAME">request.setRequestHeader</span><span class="PUNC">(</span><span class="STRN">"Content-Type"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"application/x-www-form-urlencoded"</span><span class="PUNC">)</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'> 57</span> </span><span class="WHIT"> </span><span class="NAME">request.send</span><span class="PUNC">(</span><span class="NAME">this._serialize</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 58</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 59</span> <span class='line'> 59</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'> 60</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"> <span class='line'> 60</span> </span><span class="WHIT"> </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'> 61</span> </span><span class="WHIT"> </span><span class="NAME">request.send</span><span class="PUNC">(</span><span class="KEYW">null</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT"> </span><span class="NAME">request.setRequestHeader</span><span class="PUNC">(</span><span class="STRN">"Content-Type"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"application/x-www-form-urlencoded"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 62</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT"> </span><span class="NAME">request.send</span><span class="PUNC">(</span><span class="NAME">this._serialize</span><span class="PUNC">(</span><span class="NAME">data</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="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'> 64</span> </span><span class="WHIT"> </span><span class="NAME">_serialize</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">data</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> <span class='line'> 65</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 66</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT"> </span><span class="NAME">request.send</span><span class="PUNC">(</span><span class="KEYW">null</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 67</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 68</span> </span><span class="WHIT"> </span><span class="NAME">pairs</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'> 69</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> <span class='line'> 69</span>
<span class='line'> 70</span> </span><span class="WHIT"> </span><span class="NAME">_serialize</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">data</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 70</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">name</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">data</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'> 71</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> <span class='line'> 72</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">data.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"function"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">,</span><span class="WHIT"> <span class='line'> 73</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT"> </span><span class="NAME">pairs</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'> 74</span> </span><span class="WHIT"> </span><span class="KEYW">continue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 75</span> <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">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">name</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 76</span>
<span class='line'> 77</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 77</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">data.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 78</span>
<span class='line'> 79</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 79</span> </span><span class="WHIT"> </span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">encodeURIComponent</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT"> </span><span class="KEYW">continue</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 80</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">encodeURIComponent</span><span class="PUNC">(</span><span class="NAME">value</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'> 81</span>
<span class='line'> 82</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">data</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"function"</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 82</span> </span><span class="WHIT"> </span><span class="NAME">pairs.push</span><span class="PUNC">(</span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"="</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 83</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT"> </span><span class="KEYW">continue</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 84</span>
<span class='line'> 85</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 85</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pairs.join</span><span class="PUNC">(</span><span class="STRN">"&"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 86</span> <span class='line'> 86</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 87</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 88</span> <span class='line'> 88</span>
<span class='line'> 89</span> </span><span class="WHIT"> </span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">encodeURIComponent</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 89</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 90</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">encodeURIComponent</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 90</span> * Sends a GET type ajax request
<span class='line'> 91</span> <span class='line'> 91</span> *
<span class='line'> 92</span> </span><span class="WHIT"> </span><span class="NAME">pairs.push</span><span class="PUNC">(</span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"="</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 92</span> * @name get
<span class='line'> 93</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 93</span> * @function
<span class='line'> 94</span> <span class='line'> 94</span> * @memberOf $_
<span class='line'> 95</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pairs.join</span><span class="PUNC">(</span><span class="STRN">"&"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 95</span> * @param string url
<span class='line'> 96</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 96</span> * @param object data
<span class='line'> 97</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 97</span> * @param function success_callback
<span class='line'> 98</span> <span class='line'> 98</span> * @param function error_callback
<span class='line'> 99</span> </span><span class="WHIT"> </span><span class="COMM">/** <span class='line'> 99</span> */</span><span class="WHIT">
<span class='line'>100</span> * Sends a GET type ajax request <span class='line'>100</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'get'</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'>101</span> * <span class='line'>101</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">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>102</span> * @name get <span class='line'>102</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>103</span> * @function <span class='line'>103</span>
<span class='line'>104</span> * @memberOf $_ <span class='line'>104</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>105</span> * @param string url <span class='line'>105</span> * Sends a POST type ajax request
<span class='line'>106</span> * @param object data <span class='line'>106</span> *
<span class='line'>107</span> * @param function success_callback <span class='line'>107</span> * @name post
<span class='line'>108</span> * @param function error_callback <span class='line'>108</span> * @function
<span class='line'>109</span> */</span><span class="WHIT"> <span class='line'>109</span> * @memberOf $_
<span class='line'>110</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'get'</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'>110</span> * @param string url
<span class='line'>111</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">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>111</span> * @param object data
<span class='line'>112</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>112</span> * @param function success_callback
<span class='line'>113</span> <span class='line'>113</span> * @param function error_callback
<span class='line'>114</span> </span><span class="WHIT"> </span><span class="COMM">/** <span class='line'>114</span> */</span><span class="WHIT">
<span class='line'>115</span> * Sends a POST type ajax request <span class='line'>115</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'>116</span> * <span class='line'>116</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'>117</span> * @name post <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> * @function <span class='line'>118</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>119</span> * @memberOf $_ <span class='line'>119</span> </span></pre></body></html>
<span class='line'>120</span> * @param string url
<span class='line'>121</span> * @param object data
<span class='line'>122</span> * @param function success_callback
<span class='line'>123</span> * @param function error_callback
<span class='line'>124</span> */</span><span class="WHIT">
<span class='line'>125</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'>126</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'>127</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>128</span>
<span class='line'>129</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>130</span> * Watches for server-sent events and applies a callback on message
<span class='line'>131</span> *
<span class='line'>132</span> * @name sse
<span class='line'>133</span> * @function
<span class='line'>134</span> * @memberOf $_
<span class='line'>135</span> * @param string url
<span class='line'>136</span> * @param function callback
<span class='line'>137</span> */</span><span class="WHIT">
<span class='line'>138</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'>139</span>
<span class='line'>140</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">source</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>141</span>
<span class='line'>142</span> </span><span class="WHIT"> </span><span class="COMM">// Check for server-sent event support</span><span class="WHIT">
<span class='line'>143</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">EventSource</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT"> </span><span class="NAME">source</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">EventSource</span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>146</span>
<span class='line'>147</span> </span><span class="WHIT"> </span><span class="COMM">// Apply the callback</span><span class="WHIT">
<span class='line'>148</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'>149</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'>150</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>152</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>153</span>
<span class='line'>154</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

@ -17,146 +17,140 @@
<span class='line'> 10</span> <span class='line'> 10</span>
<span class='line'> 11</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_add_remove</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_attach_delegate</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 11</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_add_remove</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_attach_delegate</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 12</span> <span class='line'> 12</span>
<span class='line'> 13</span> </span><span class="WHIT"> </span><span class="COMM">// Don't bother defining the methods if event api isn't supports</span><span class="WHIT"> <span class='line'> 13</span> </span><span class="WHIT"> </span><span class="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'> 14</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">document.addEventListener</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 14</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 15</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 15</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'> 16</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 16</span>
<span class='line'> 17</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 17</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 18</span> <span class='line'> 18</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 19</span> </span><span class="WHIT"> </span><span class="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'> 19</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'> 20</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 20</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 21</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 21</span>
<span class='line'> 22</span> <span class='line'> 22</span> </span><span class="WHIT"> </span><span class="COMM">// Multiple events? Run recursively!</span><span class="WHIT">
<span class='line'> 23</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 23</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'> 24</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 24</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 25</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 25</span> </span><span class="WHIT"> </span><span class="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'> 26</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 26</span>
<span class='line'> 27</span> <span class='line'> 27</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'> 28</span> </span><span class="WHIT"> </span><span class="COMM">// Multiple events? Run recursively!</span><span class="WHIT"> <span class='line'> 28</span>
<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'> 29</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'> 30</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="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'> 31</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'> 32</span> <span class='line'> 32</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<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'> 33</span>
<span class='line'> 34</span> <span class='line'> 34</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<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'> 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="PUNC">{</span><span class="WHIT"> <span class='line'> 36</span>
<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'> 37</span> </span><span class="WHIT"> </span><span class="COMM">// Bind the event</span><span class="WHIT">
<span class='line'> 38</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="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'> 39</span> <span class='line'> 39</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'> 40</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 40</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'> 41</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 41</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 42</span> <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'> 43</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'> 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'> 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="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'> 45</span> </span><span class="WHIT"> </span><span class="COMM">// attach the listener to the parent object</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'> 46</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'> 47</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 47</span>
<span class='line'> 48</span> <span class='line'> 48</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'> 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'> 49</span>
<span class='line'> 50</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 50</span> </span><span class="WHIT"> </span><span class="COMM">// Get the live version of the target selector</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'> 51</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'> 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'> 52</span>
<span class='line'> 53</span> <span class='line'> 53</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'> 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'> 54</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'> 55</span> <span class='line'> 55</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<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'> 56</span> </span><span class="WHIT"> </span><span class="COMM">// Fire target callback when event bubbles from target</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'> 57</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'> 58</span> <span class='line'> 58</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<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'> 59</span> </span><span class="WHIT"> </span><span class="COMM">// Trigger the event callback</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'> 60</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'> 61</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 61</span>
<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'> 62</span> </span><span class="WHIT"> </span><span class="COMM">// Stop event propegation</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'> 63</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'> 64</span> </span><span class="WHIT"> </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'> 65</span> </span><span class="WHIT"> </span><span class="PUNC">}</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'> 66</span>
<span class='line'> 67</span> <span class='line'> 67</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'> 68</span> </span><span class="WHIT"> </span><span class="COMM">// Stop event propegation</span><span class="WHIT"> <span class='line'> 68</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</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'> 69</span>
<span class='line'> 70</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="COMM">// --------------------------------------------------------------------------</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 71</span>
<span class='line'> 72</span> <span class='line'> 72</span> </span><span class="WHIT"> </span><span class="COMM">/**
<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'> 73</span> * Event Listener module
<span class='line'> 74</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 74</span> *
<span class='line'> 75</span> <span class='line'> 75</span> * @namespace
<span class='line'> 76</span> </span><span class="WHIT"> </span><span class="COMM">// --------------------------------------------------------------------------</span><span class="WHIT"> <span class='line'> 76</span> * @name event
<span class='line'> 77</span> <span class='line'> 77</span> * @memberOf $_
<span class='line'> 78</span> </span><span class="WHIT"> </span><span class="COMM">/** <span class='line'> 78</span> */</span><span class="WHIT">
<span class='line'> 79</span> * Event Listener module <span class='line'> 79</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'> 80</span> * <span class='line'> 80</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 81</span> * @namespace <span class='line'> 81</span> * Adds an event that returns a callback when triggered on the selected
<span class='line'> 82</span> * @name event <span class='line'> 82</span> * event and selector
<span class='line'> 83</span> * @memberOf $_ <span class='line'> 83</span> *
<span class='line'> 84</span> */</span><span class="WHIT"> <span class='line'> 84</span> * @memberOf $_.event
<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'> 85</span> * @name add
<span class='line'> 86</span> </span><span class="WHIT"> </span><span class="COMM">/** <span class='line'> 86</span> * @function
<span class='line'> 87</span> * Adds an event that returns a callback when triggered on the selected <span class='line'> 87</span> * @example Eg. $_("#selector").event.add("click", do_something());
<span class='line'> 88</span> * event and selector <span class='line'> 88</span> * @param string event
<span class='line'> 89</span> * <span class='line'> 89</span> * @param function callback
<span class='line'> 90</span> * @memberOf $_.event <span class='line'> 90</span> */</span><span class="WHIT">
<span class='line'> 91</span> * @name add <span class='line'> 91</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'> 92</span> * @function <span class='line'> 92</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 93</span> * @example Eg. $_("#selector").event.add("click", do_something()); <span class='line'> 93</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'> 94</span> * @param string event <span class='line'> 94</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'> 95</span> * @param function callback <span class='line'> 95</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 96</span> */</span><span class="WHIT"> <span class='line'> 96</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</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'> 97</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 98</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 98</span> * Removes an event bound the the specified selector, event type, and callback
<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'> 99</span> *
<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'>100</span> * @memberOf $_.event
<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'>101</span> * @name remove
<span class='line'>102</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> <span class='line'>102</span> * @function
<span class='line'>103</span> </span><span class="WHIT"> </span><span class="COMM">/** <span class='line'>103</span> * @example Eg. $_("#selector").event.remove("click", do_something());
<span class='line'>104</span> * Removes an event bound the the specified selector, event type, and callback <span class='line'>104</span> * @param string event
<span class='line'>105</span> * <span class='line'>105</span> * @param string callback
<span class='line'>106</span> * @memberOf $_.event <span class='line'>106</span> */</span><span class="WHIT">
<span class='line'>107</span> * @name remove <span class='line'>107</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'>108</span> * @function <span class='line'>108</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>109</span> * @example Eg. $_("#selector").event.remove("click", do_something()); <span class='line'>109</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'>110</span> * @param string event <span class='line'>110</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'>111</span> * @param string callback <span class='line'>111</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>112</span> */</span><span class="WHIT"> <span class='line'>112</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</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'>113</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>114</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'>114</span> * Binds a persistent event to the document
<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'>115</span> *
<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'>116</span> * @memberOf $_.event
<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'>117</span> * @name live
<span class='line'>118</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> <span class='line'>118</span> * @function
<span class='line'>119</span> </span><span class="WHIT"> </span><span class="COMM">/** <span class='line'>119</span> * @example Eg. $_.event.live(".button", "click", do_something());
<span class='line'>120</span> * Binds a persistent event to the document <span class='line'>120</span> * @param string target
<span class='line'>121</span> * <span class='line'>121</span> * @param string event
<span class='line'>122</span> * @memberOf $_.event <span class='line'>122</span> * @param function callback
<span class='line'>123</span> * @name live <span class='line'>123</span> */</span><span class="WHIT">
<span class='line'>124</span> * @function <span class='line'>124</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'>125</span> * @example Eg. $_.event.live(".button", "click", do_something()); <span class='line'>125</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>126</span> * @param string target <span class='line'>126</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'>127</span> * @param string event <span class='line'>127</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>128</span> * @param function callback <span class='line'>128</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>129</span> */</span><span class="WHIT"> <span class='line'>129</span> * Binds an event to a parent object
<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'>130</span> *
<span class='line'>131</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'>131</span> * @memberOf $_.event
<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'>132</span> * @name delegate
<span class='line'>133</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> <span class='line'>133</span> * @function
<span class='line'>134</span> </span><span class="WHIT"> </span><span class="COMM">/** <span class='line'>134</span> * @example Eg. $_("#parent").delegate(".button", "click", do_something());
<span class='line'>135</span> * Binds an event to a parent object <span class='line'>135</span> * @param string target
<span class='line'>136</span> * <span class='line'>136</span> * @param string event_type
<span class='line'>137</span> * @memberOf $_.event <span class='line'>137</span> * @param function callback
<span class='line'>138</span> * @name delegate <span class='line'>138</span> */</span><span class="WHIT">
<span class='line'>139</span> * @function <span class='line'>139</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'>140</span> * @example Eg. $_("#parent").delegate(".button", "click", do_something()); <span class='line'>140</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>141</span> * @param string target <span class='line'>141</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'>142</span> * @param string event_type <span class='line'>142</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'>143</span> * @param function callback <span class='line'>143</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>144</span> */</span><span class="WHIT"> <span class='line'>144</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT"> </span><span class="NAME">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'>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'>146</span>
<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'>147</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'>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'>148</span>
<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'>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>
<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

@ -14,119 +14,113 @@
<span class='line'> 7</span> <span class='line'> 7</span>
<span class='line'> 8</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 8</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 9</span> <span class='line'> 9</span>
<span class='line'> 10</span> </span><span class="WHIT"> </span><span class="COMM">//No support for localstorage? Bail out early</span><span class="WHIT"> <span class='line'> 10</span> </span><span class="WHIT"> </span><span class="COMM">//Shortcuts for wrapper</span><span class="WHIT">
<span class='line'> 11</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">localStorage</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">JSON</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 11</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">localStorage</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 12</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 12</span> </span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sessionStorage</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 13</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 13</span>
<span class='line'> 14</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'> 14</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 15</span> <span class='line'> 15</span> * Wrapper for localstorage / sessionstorage data serialization.
<span class='line'> 16</span> </span><span class="WHIT"> </span><span class="COMM">//Shortcuts for wrapper</span><span class="WHIT"> <span class='line'> 16</span> * Each method has a boolean parameter, that when set as true switches the method
<span class='line'> 17</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">localStorage</span><span class="PUNC">,</span><span class="WHIT"> <span class='line'> 17</span> * to use sessionStorage rather than the default localStorage.
<span class='line'> 18</span> </span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sessionStorage</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 18</span> *
<span class='line'> 19</span> <span class='line'> 19</span> * @name store
<span class='line'> 20</span> </span><span class="WHIT"> </span><span class="COMM">/** <span class='line'> 20</span> * @namespace
<span class='line'> 21</span> * Wrapper for localstorage / sessionstorage data serialization. <span class='line'> 21</span> * @memberOf $_
<span class='line'> 22</span> * Each method has a boolean parameter, that when set as true switches the method <span class='line'> 22</span> */</span><span class="WHIT">
<span class='line'> 23</span> * to use sessionStorage rather than the default localStorage. <span class='line'> 23</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">store</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 24</span> * <span class='line'> 24</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 25</span> * @name store <span class='line'> 25</span> * Retrieves and deserializes a value from localstorage,
<span class='line'> 26</span> * @namespace <span class='line'> 26</span> * based on the specified key
<span class='line'> 27</span> * @memberOf $_ <span class='line'> 27</span> *
<span class='line'> 28</span> */</span><span class="WHIT"> <span class='line'> 28</span> * @param string key
<span class='line'> 29</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">store</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 29</span> * @param bool session
<span class='line'> 30</span> </span><span class="WHIT"> </span><span class="COMM">/** <span class='line'> 30</span> * @name get
<span class='line'> 31</span> * Retrieves and deserializes a value from localstorage, <span class='line'> 31</span> * @memberOf $_.store
<span class='line'> 32</span> * based on the specified key <span class='line'> 32</span> * @function
<span class='line'> 33</span> * <span class='line'> 33</span> * @return object
<span class='line'> 34</span> * @param string key <span class='line'> 34</span> * @type object
<span class='line'> 35</span> * @param bool session <span class='line'> 35</span> */</span><span class="WHIT">
<span class='line'> 36</span> * @name get <span class='line'> 36</span> </span><span class="WHIT"> </span><span class="NAME">get</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">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 37</span> * @memberOf $_.store <span class='line'> 37</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 38</span> * @function <span class='line'> 38</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">s.getItem</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">l.getItem</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 39</span> * @return object <span class='line'> 39</span>
<span class='line'> 40</span> * @type object <span class='line'> 40</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">JSON.parse</span><span class="PUNC">(</span><span class="NAME">val</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 41</span> */</span><span class="WHIT"> <span class='line'> 41</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="WHIT"> </span><span class="NAME">get</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">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 42</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 43</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 43</span> * Puts a value into localstorage at the specified key,
<span class='line'> 44</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">s.getItem</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">l.getItem</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 44</span> * and JSON-encodes the value if not a string
<span class='line'> 45</span> <span class='line'> 45</span> *
<span class='line'> 46</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">JSON.parse</span><span class="PUNC">(</span><span class="NAME">val</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 46</span> * @param string key
<span class='line'> 47</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> <span class='line'> 47</span> * @param mixed value
<span class='line'> 48</span> </span><span class="WHIT"> </span><span class="COMM">/** <span class='line'> 48</span> * @param bool session
<span class='line'> 49</span> * Puts a value into localstorage at the specified key, <span class='line'> 49</span> * @name set
<span class='line'> 50</span> * and JSON-encodes the value if not a string <span class='line'> 50</span> * @memberOf $_.store
<span class='line'> 51</span> * <span class='line'> 51</span> * @function
<span class='line'> 52</span> * @param string key <span class='line'> 52</span> */</span><span class="WHIT">
<span class='line'> 53</span> * @param mixed value <span class='line'> 53</span> </span><span class="WHIT"> </span><span class="NAME">set</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">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 54</span> * @param bool session <span class='line'> 54</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 55</span> * @name set <span class='line'> 55</span> </span><span class="WHIT"> </span><span class="COMM">// Localstorage generally only accepts strings</span><span class="WHIT">
<span class='line'> 56</span> * @memberOf $_.store <span class='line'> 56</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">JSON.stringify</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 57</span> * @function <span class='line'> 57</span>
<span class='line'> 58</span> */</span><span class="WHIT"> <span class='line'> 58</span> </span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">s.setItem</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">l.setItem</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 59</span> </span><span class="WHIT"> </span><span class="NAME">set</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">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 59</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 60</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 61</span> </span><span class="WHIT"> </span><span class="COMM">// Localstorage generally only accepts strings</span><span class="WHIT"> <span class='line'> 61</span> * Removes the specified item from storage
<span class='line'> 62</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">JSON.stringify</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 62</span> *
<span class='line'> 63</span> <span class='line'> 63</span> * @param string key
<span class='line'> 64</span> </span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">s.setItem</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">l.setItem</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 64</span> * @param bool session
<span class='line'> 65</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> <span class='line'> 65</span> * @name remove
<span class='line'> 66</span> </span><span class="WHIT"> </span><span class="COMM">/** <span class='line'> 66</span> * @memberOf $_.store
<span class='line'> 67</span> * Removes the specified item from storage <span class='line'> 67</span> * @function
<span class='line'> 68</span> * <span class='line'> 68</span> */</span><span class="WHIT">
<span class='line'> 69</span> * @param string key <span class='line'> 69</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">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 70</span> * @param bool session <span class='line'> 70</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 71</span> * @name remove <span class='line'> 71</span> </span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">s.removeItem</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">l.removeItem</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 72</span> * @memberOf $_.store <span class='line'> 72</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 73</span> * @function <span class='line'> 73</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 74</span> */</span><span class="WHIT"> <span class='line'> 74</span> * Returns an object of all the raw values in storage
<span class='line'> 75</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">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sess</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="PUNC">{</span><span class="WHIT"> <span class='line'> 76</span> * @param bool session
<span class='line'> 77</span> </span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">s.removeItem</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">l.removeItem</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 77</span> * @name getAll
<span class='line'> 78</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> <span class='line'> 78</span> * @memberOf $_.store
<span class='line'> 79</span> </span><span class="WHIT"> </span><span class="COMM">/** <span class='line'> 79</span> * @function
<span class='line'> 80</span> * Returns an object of all the raw values in storage <span class='line'> 80</span> * @return object
<span class='line'> 81</span> * <span class='line'> 81</span> * @type object
<span class='line'> 82</span> * @param bool session <span class='line'> 82</span> */</span><span class="WHIT">
<span class='line'> 83</span> * @name getAll <span class='line'> 83</span> </span><span class="WHIT"> </span><span class="NAME">getAll</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">sess</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 84</span> * @memberOf $_.store <span class='line'> 84</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 85</span> * @function <span class='line'> 85</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 class='line'> 86</span> * @return object <span class='line'> 86</span> </span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 87</span> * @type object <span class='line'> 87</span> </span><span class="WHIT"> </span><span class="NAME">data</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'> 88</span> */</span><span class="WHIT"> <span class='line'> 88</span> </span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT"> </span><span class="NAME">getAll</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">sess</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'> 89</span> </span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> <span class='line'> 90</span>
<span class='line'> 91</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 class='line'> 91</span> </span><span class="WHIT"> </span><span class="COMM">//Reference to session/localstorage</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">,</span><span class="WHIT"> <span class='line'> 92</span> </span><span class="WHIT"> </span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">l</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'> 93</span> </span><span class="WHIT"> </span><span class="NAME">data</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'> 93</span>
<span class='line'> 94</span> </span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> <span class='line'> 94</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">o.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'> 95</span>
<span class='line'> 96</span> <span class='line'> 96</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'> 97</span> </span><span class="WHIT"> </span><span class="COMM">//Reference to session/localstorage</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="NAME">o</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">l</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'> 98</span> </span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">o.key</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 99</span> <span class='line'> 99</span> </span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">o.getItem</span><span class="PUNC">(</span><span class="NAME">k</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">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">o.length</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'>101</span>
<span class='line'>102</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'>102</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">data</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'>103</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">o.key</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>104</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>105</span> </span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">o.getItem</span><span class="PUNC">(</span><span class="NAME">k</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>105</span> * Removes all values from the same domain storage
<span class='line'>106</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> <span class='line'>106</span> *
<span class='line'>107</span> <span class='line'>107</span> * @param bool session
<span class='line'>108</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">;</span><span class="WHIT"> <span class='line'>108</span> * @name clear
<span class='line'>109</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> <span class='line'>109</span> * @memberOf $_.store
<span class='line'>110</span> </span><span class="WHIT"> </span><span class="COMM">/** <span class='line'>110</span> * @function
<span class='line'>111</span> * Removes all values from the same domain storage <span class='line'>111</span> */</span><span class="WHIT">
<span class='line'>112</span> * <span class='line'>112</span> </span><span class="WHIT"> </span><span class="NAME">clear</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>113</span> * @param bool session <span class='line'>113</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>114</span> * @name clear <span class='line'>114</span> </span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">s.clear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">l.clear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>115</span> * @memberOf $_.store <span class='line'>115</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>116</span> * @function <span class='line'>116</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>117</span> */</span><span class="WHIT"> <span class='line'>117</span>
<span class='line'>118</span> </span><span class="WHIT"> </span><span class="NAME">clear</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT"> <span class='line'>118</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'store'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">store</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'>119</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'>120</span> </span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">s.clear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">l.clear</span><span class="PUNC">(</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><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>123</span>
<span class='line'>124</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'store'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">store</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>125</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

@ -8,18 +8,7 @@
"use strict"; "use strict";
// Most functions rely on a string selector var $_, $, sel;
// which returns html elements. This requires
// document.querySelectorAll or a custom
// selector engine. I choose to just use the
// browser feature, since it is present in
// IE 8+, and all other major browsers
if (document.querySelector === undefined)
{
return;
}
var $_, $, dcopy, sel;
/** /**
@ -51,7 +40,7 @@
$_.prototype.el = sel; $_.prototype.el = sel;
// Use the $_ object as it's own prototype // Use the $_ object as it's own prototype
var self = dcopy($_); var self = Object.create($_);
// Give sel to each extension. // Give sel to each extension.
for(var i in self) for(var i in self)
@ -101,46 +90,6 @@
return (x.length === 1) ? x[0] : x; return (x.length === 1) ? x[0] : x;
}; };
/**
* Deep copy/prototypical constructor function
*
* @param object obj
* @private
* @return object
* @type object
*/
dcopy = function(obj)
{
var type, F;
if(obj === undefined)
{
return;
}
if(Object.create !== undefined)
{
return Object.create(obj);
}
type = typeof obj;
if(type !== "object" && type !== "function")
{
return;
}
/**
* @private
*/
F = function(){};
F.prototype = obj;
return new F();
};
/** /**
* Adds the property `obj` to the $_ object, calling it `name` * Adds the property `obj` to the $_ object, calling it `name`
* *
@ -163,28 +112,8 @@
$_.ext('each', function (callback) $_.ext('each', function (callback)
{ {
if(sel.length !== undefined && sel !== window) if(sel.length !== undefined && sel !== window)
{
// Use the native method, if it exists
if(Array.prototype.forEach !== undefined)
{ {
[].forEach.call(sel, callback); [].forEach.call(sel, callback);
return;
}
// Otherwise, fall back to a for loop
var len = sel.length;
if (len === 0)
{
return;
}
var selx;
for (var x = 0; x < len; x++)
{
selx = (sel.item(x)) ? sel.item(x) : sel[x];
callback.call(selx, selx);
}
} }
else else
{ {
@ -214,9 +143,9 @@
//Set global variables //Set global variables
$_ = window.$_ = window.$_ || $_; $_ = window.$_ = window.$_ || $_;
$_.$ = $; $_.$ = $;
}()); }());
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
@ -414,7 +343,7 @@ if(typeof document!=="undefined"&&!("classList" in document.createElement("a")))
addClass: function (c) addClass: function (c)
{ {
$_.each(function (e){ $_.each(function (e){
this.classList.add(c); e.classList.add(c);
}); });
}, },
/** /**
@ -632,12 +561,6 @@ if(typeof document!=="undefined"&&!("classList" in document.createElement("a")))
*/ */
// Don't bother even defining the object if the XMLHttpRequest isn't available
if(window.XMLHttpRequest === undefined)
{
return;
}
var ajax = { var ajax = {
_do: function (url, data, success_callback, error_callback, isPost) _do: function (url, data, success_callback, error_callback, isPost)
{ {
@ -700,11 +623,7 @@ if(typeof document!=="undefined"&&!("classList" in document.createElement("a")))
for (name in data) for (name in data)
{ {
if (!data.hasOwnProperty(name)) if ( ! data.hasOwnProperty(name) || typeof data[name] === "function")
{
continue;
}
if (typeof data[name] === "function")
{ {
continue; continue;
} }
@ -751,32 +670,6 @@ if(typeof document!=="undefined"&&!("classList" in document.createElement("a")))
ajax._do(url, data, success_callback, error_callback, true); ajax._do(url, data, success_callback, error_callback, true);
}); });
/**
* Watches for server-sent events and applies a callback on message
*
* @name sse
* @function
* @memberOf $_
* @param string url
* @param function callback
*/
$_.ext('sse', function(url, callback){
var source;
// Check for server-sent event support
if (EventSource !== undefined)
{
source = new EventSource(url);
// Apply the callback
source.onmessage = function(event){
callback.call(event.data, event.data);
};
}
});
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@ -790,12 +683,6 @@ if(typeof document!=="undefined"&&!("classList" in document.createElement("a")))
var _add_remove, e, _attach_delegate; var _add_remove, e, _attach_delegate;
// Don't bother defining the methods if event api isn't supports
if (document.addEventListener === undefined)
{
return false;
}
_add_remove = function (sel, event, callback, add) _add_remove = function (sel, event, callback, add)
{ {
var i, len; var i, len;
@ -943,12 +830,6 @@ if(typeof document!=="undefined"&&!("classList" in document.createElement("a")))
*/ */
//No support for localstorage? Bail out early
if(localStorage === undefined || JSON === undefined)
{
return null;
}
//Shortcuts for wrapper //Shortcuts for wrapper
var l = localStorage, var l = localStorage,
s = sessionStorage; s = sessionStorage;

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

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

View File

@ -8,18 +8,7 @@
"use strict"; "use strict";
// Most functions rely on a string selector var $_, $, sel;
// which returns html elements. This requires
// document.querySelectorAll or a custom
// selector engine. I choose to just use the
// browser feature, since it is present in
// IE 8+, and all other major browsers
if (document.querySelector === undefined)
{
return;
}
var $_, $, dcopy, sel;
/** /**
@ -51,7 +40,7 @@
$_.prototype.el = sel; $_.prototype.el = sel;
// Use the $_ object as it's own prototype // Use the $_ object as it's own prototype
var self = dcopy($_); var self = Object.create($_);
// Give sel to each extension. // Give sel to each extension.
for(var i in self) for(var i in self)
@ -101,46 +90,6 @@
return (x.length === 1) ? x[0] : x; return (x.length === 1) ? x[0] : x;
}; };
/**
* Deep copy/prototypical constructor function
*
* @param object obj
* @private
* @return object
* @type object
*/
dcopy = function(obj)
{
var type, F;
if(obj === undefined)
{
return;
}
if(Object.create !== undefined)
{
return Object.create(obj);
}
type = typeof obj;
if(type !== "object" && type !== "function")
{
return;
}
/**
* @private
*/
F = function(){};
F.prototype = obj;
return new F();
};
/** /**
* Adds the property `obj` to the $_ object, calling it `name` * Adds the property `obj` to the $_ object, calling it `name`
* *
@ -163,28 +112,8 @@
$_.ext('each', function (callback) $_.ext('each', function (callback)
{ {
if(sel.length !== undefined && sel !== window) if(sel.length !== undefined && sel !== window)
{
// Use the native method, if it exists
if(Array.prototype.forEach !== undefined)
{ {
[].forEach.call(sel, callback); [].forEach.call(sel, callback);
return;
}
// Otherwise, fall back to a for loop
var len = sel.length;
if (len === 0)
{
return;
}
var selx;
for (var x = 0; x < len; x++)
{
selx = (sel.item(x)) ? sel.item(x) : sel[x];
callback.call(selx, selx);
}
} }
else else
{ {
@ -214,9 +143,9 @@
//Set global variables //Set global variables
$_ = window.$_ = window.$_ || $_; $_ = window.$_ = window.$_ || $_;
$_.$ = $; $_.$ = $;
}()); }());
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
@ -262,12 +191,6 @@ if (typeof Array.isArray === "undefined")
"use strict"; "use strict";
// Don't bother even defining the object if the XMLHttpRequest isn't available
if(window.XMLHttpRequest === undefined)
{
return;
}
var ajax = { var ajax = {
_do: function (url, data, success_callback, error_callback, isPost) _do: function (url, data, success_callback, error_callback, isPost)
{ {
@ -330,11 +253,7 @@ if (typeof Array.isArray === "undefined")
for (name in data) for (name in data)
{ {
if (!data.hasOwnProperty(name)) if ( ! data.hasOwnProperty(name) || typeof data[name] === "function")
{
continue;
}
if (typeof data[name] === "function")
{ {
continue; continue;
} }
@ -380,34 +299,9 @@ if (typeof Array.isArray === "undefined")
$_.ext('post', function (url, data, success_callback, error_callback){ $_.ext('post', function (url, data, success_callback, error_callback){
ajax._do(url, data, success_callback, error_callback, true); ajax._do(url, data, success_callback, error_callback, true);
}); });
/**
* Watches for server-sent events and applies a callback on message
*
* @name sse
* @function
* @memberOf $_
* @param string url
* @param function callback
*/
$_.ext('sse', function(url, callback){
var source;
// Check for server-sent event support
if (EventSource !== undefined)
{
source = new EventSource(url);
// Apply the callback
source.onmessage = function(event){
callback.call(event.data, event.data);
};
}
});
}()); }());
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
@ -422,12 +316,6 @@ if (typeof Array.isArray === "undefined")
var _add_remove, e, _attach_delegate; var _add_remove, e, _attach_delegate;
// Don't bother defining the methods if event api isn't supports
if (document.addEventListener === undefined)
{
return false;
}
_add_remove = function (sel, event, callback, add) _add_remove = function (sel, event, callback, add)
{ {
var i, len; var i, len;
@ -723,7 +611,7 @@ if(typeof document!=="undefined"&&!("classList" in document.createElement("a")))
addClass: function (c) addClass: function (c)
{ {
$_.each(function (e){ $_.each(function (e){
this.classList.add(c); e.classList.add(c);
}); });
}, },
/** /**

13
kis-lite-min.js vendored
View File

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

View File

@ -8,18 +8,7 @@
"use strict"; "use strict";
// Most functions rely on a string selector var $_, $, sel;
// which returns html elements. This requires
// document.querySelectorAll or a custom
// selector engine. I choose to just use the
// browser feature, since it is present in
// IE 8+, and all other major browsers
if (document.querySelector === undefined)
{
return;
}
var $_, $, dcopy, sel;
/** /**
@ -51,7 +40,7 @@
$_.prototype.el = sel; $_.prototype.el = sel;
// Use the $_ object as it's own prototype // Use the $_ object as it's own prototype
var self = dcopy($_); var self = Object.create($_);
// Give sel to each extension. // Give sel to each extension.
for(var i in self) for(var i in self)
@ -101,46 +90,6 @@
return (x.length === 1) ? x[0] : x; return (x.length === 1) ? x[0] : x;
}; };
/**
* Deep copy/prototypical constructor function
*
* @param object obj
* @private
* @return object
* @type object
*/
dcopy = function(obj)
{
var type, F;
if(obj === undefined)
{
return;
}
if(Object.create !== undefined)
{
return Object.create(obj);
}
type = typeof obj;
if(type !== "object" && type !== "function")
{
return;
}
/**
* @private
*/
F = function(){};
F.prototype = obj;
return new F();
};
/** /**
* Adds the property `obj` to the $_ object, calling it `name` * Adds the property `obj` to the $_ object, calling it `name`
* *
@ -163,28 +112,8 @@
$_.ext('each', function (callback) $_.ext('each', function (callback)
{ {
if(sel.length !== undefined && sel !== window) if(sel.length !== undefined && sel !== window)
{
// Use the native method, if it exists
if(Array.prototype.forEach !== undefined)
{ {
[].forEach.call(sel, callback); [].forEach.call(sel, callback);
return;
}
// Otherwise, fall back to a for loop
var len = sel.length;
if (len === 0)
{
return;
}
var selx;
for (var x = 0; x < len; x++)
{
selx = (sel.item(x)) ? sel.item(x) : sel[x];
callback.call(selx, selx);
}
} }
else else
{ {
@ -214,9 +143,9 @@
//Set global variables //Set global variables
$_ = window.$_ = window.$_ || $_; $_ = window.$_ = window.$_ || $_;
$_.$ = $; $_.$ = $;
}()); }());
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
@ -262,12 +191,6 @@ if (typeof Array.isArray === "undefined")
"use strict"; "use strict";
// Don't bother even defining the object if the XMLHttpRequest isn't available
if(window.XMLHttpRequest === undefined)
{
return;
}
var ajax = { var ajax = {
_do: function (url, data, success_callback, error_callback, isPost) _do: function (url, data, success_callback, error_callback, isPost)
{ {
@ -330,11 +253,7 @@ if (typeof Array.isArray === "undefined")
for (name in data) for (name in data)
{ {
if (!data.hasOwnProperty(name)) if ( ! data.hasOwnProperty(name) || typeof data[name] === "function")
{
continue;
}
if (typeof data[name] === "function")
{ {
continue; continue;
} }
@ -380,34 +299,9 @@ if (typeof Array.isArray === "undefined")
$_.ext('post', function (url, data, success_callback, error_callback){ $_.ext('post', function (url, data, success_callback, error_callback){
ajax._do(url, data, success_callback, error_callback, true); ajax._do(url, data, success_callback, error_callback, true);
}); });
/**
* Watches for server-sent events and applies a callback on message
*
* @name sse
* @function
* @memberOf $_
* @param string url
* @param function callback
*/
$_.ext('sse', function(url, callback){
var source;
// Check for server-sent event support
if (EventSource !== undefined)
{
source = new EventSource(url);
// Apply the callback
source.onmessage = function(event){
callback.call(event.data, event.data);
};
}
});
}()); }());
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
@ -422,12 +316,6 @@ if (typeof Array.isArray === "undefined")
var _add_remove, e, _attach_delegate; var _add_remove, e, _attach_delegate;
// Don't bother defining the methods if event api isn't supports
if (document.addEventListener === undefined)
{
return false;
}
_add_remove = function (sel, event, callback, add) _add_remove = function (sel, event, callback, add)
{ {
var i, len; var i, len;

32
kis-min.js vendored
View File

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

View File

@ -8,18 +8,7 @@
"use strict"; "use strict";
// Most functions rely on a string selector var $_, $, sel;
// which returns html elements. This requires
// document.querySelectorAll or a custom
// selector engine. I choose to just use the
// browser feature, since it is present in
// IE 8+, and all other major browsers
if (document.querySelector === undefined)
{
return;
}
var $_, $, dcopy, sel;
/** /**
@ -51,7 +40,7 @@
$_.prototype.el = sel; $_.prototype.el = sel;
// Use the $_ object as it's own prototype // Use the $_ object as it's own prototype
var self = dcopy($_); var self = Object.create($_);
// Give sel to each extension. // Give sel to each extension.
for(var i in self) for(var i in self)
@ -101,46 +90,6 @@
return (x.length === 1) ? x[0] : x; return (x.length === 1) ? x[0] : x;
}; };
/**
* Deep copy/prototypical constructor function
*
* @param object obj
* @private
* @return object
* @type object
*/
dcopy = function(obj)
{
var type, F;
if(obj === undefined)
{
return;
}
if(Object.create !== undefined)
{
return Object.create(obj);
}
type = typeof obj;
if(type !== "object" && type !== "function")
{
return;
}
/**
* @private
*/
F = function(){};
F.prototype = obj;
return new F();
};
/** /**
* Adds the property `obj` to the $_ object, calling it `name` * Adds the property `obj` to the $_ object, calling it `name`
* *
@ -163,28 +112,8 @@
$_.ext('each', function (callback) $_.ext('each', function (callback)
{ {
if(sel.length !== undefined && sel !== window) if(sel.length !== undefined && sel !== window)
{
// Use the native method, if it exists
if(Array.prototype.forEach !== undefined)
{ {
[].forEach.call(sel, callback); [].forEach.call(sel, callback);
return;
}
// Otherwise, fall back to a for loop
var len = sel.length;
if (len === 0)
{
return;
}
var selx;
for (var x = 0; x < len; x++)
{
selx = (sel.item(x)) ? sel.item(x) : sel[x];
callback.call(selx, selx);
}
} }
else else
{ {
@ -214,5 +143,4 @@
//Set global variables //Set global variables
$_ = window.$_ = window.$_ || $_; $_ = window.$_ = window.$_ || $_;
$_.$ = $; $_.$ = $;
}()); }());

View File

@ -153,7 +153,7 @@ if(typeof document!=="undefined"&&!("classList" in document.createElement("a")))
addClass: function (c) addClass: function (c)
{ {
$_.each(function (e){ $_.each(function (e){
this.classList.add(c); e.classList.add(c);
}); });
}, },
/** /**

View File

@ -7,12 +7,6 @@
"use strict"; "use strict";
// Don't bother even defining the object if the XMLHttpRequest isn't available
if(window.XMLHttpRequest === undefined)
{
return;
}
var ajax = { var ajax = {
_do: function (url, data, success_callback, error_callback, isPost) _do: function (url, data, success_callback, error_callback, isPost)
{ {
@ -75,11 +69,7 @@
for (name in data) for (name in data)
{ {
if (!data.hasOwnProperty(name)) if ( ! data.hasOwnProperty(name) || typeof data[name] === "function")
{
continue;
}
if (typeof data[name] === "function")
{ {
continue; continue;
} }
@ -125,30 +115,4 @@
$_.ext('post', function (url, data, success_callback, error_callback){ $_.ext('post', function (url, data, success_callback, error_callback){
ajax._do(url, data, success_callback, error_callback, true); ajax._do(url, data, success_callback, error_callback, true);
}); });
/**
* Watches for server-sent events and applies a callback on message
*
* @name sse
* @function
* @memberOf $_
* @param string url
* @param function callback
*/
$_.ext('sse', function(url, callback){
var source;
// Check for server-sent event support
if (EventSource !== undefined)
{
source = new EventSource(url);
// Apply the callback
source.onmessage = function(event){
callback.call(event.data, event.data);
};
}
});
}()); }());

View File

@ -10,12 +10,6 @@
var _add_remove, e, _attach_delegate; var _add_remove, e, _attach_delegate;
// Don't bother defining the methods if event api isn't supports
if (document.addEventListener === undefined)
{
return false;
}
_add_remove = function (sel, event, callback, add) _add_remove = function (sel, event, callback, add)
{ {
var i, len; var i, len;

View File

@ -7,12 +7,6 @@
"use strict"; "use strict";
//No support for localstorage? Bail out early
if(localStorage === undefined || JSON === undefined)
{
return null;
}
//Shortcuts for wrapper //Shortcuts for wrapper
var l = localStorage, var l = localStorage,
s = sessionStorage; s = sessionStorage;

5430
tests/blanket.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -3,26 +3,13 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" /> <link rel="stylesheet" href="qunit/qunit.css" type="text/css" />
<title>Kis-js test app</title> <title>Kis-js test suite</title>
<!--[if IE 8]>
<script type="text/javascript">
var HTML5 = "article,aside,audio,canvas,details,figcaption,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,summary,time,video".split(",");
for (var i = 0, tagName; tagName = HTML5[i]; i++) document.createElement(tagName);
</script>
<![endif]-->
</head> </head>
<body> <body>
<h1 id="qunit-header">Kis-js Test Suite</h1> <div id="qunit"></div>
<h2 id="qunit-banner"></h2> <div id="qunit-fixture"></div>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">
test markup, will be hidden
<span id="testSpan"></span>
</div>
<section hidden="hidden"> <section hidden="hidden">
<span id="testSpan"></span>
<article id="r14"> <article id="r14">
This is important text! This is important text!
</article> </article>
@ -32,8 +19,14 @@ for (var i = 0, tagName; tagName = HTML5[i]; i++) document.createElement(tagName
<div class="nephew"></div> <div class="nephew"></div>
</aside> </aside>
</section> </section>
<script src="../kis-min.js"></script>
<script src="qunit/qunit.js"></script> <script src="qunit/qunit.js"></script>
<script src='../src/core.js' data-cover></script>
<script src='../src/modules/ajax.js' data-cover></script>
<script src='../src/modules/event.js' data-cover></script>
<script src='../src/modules/DOM.js' data-cover></script>
<script src='../src/modules/store.js' data-cover></script>
<script src='../src/modules/util.js' data-cover></script>
<script src="blanket.js"></script>
<script src="qunit/test_funcs.js"></script> <script src="qunit/test_funcs.js"></script>
<script src="tests/core.js"></script> <script src="tests/core.js"></script>
<script src="tests/ajax.js"></script> <script src="tests/ajax.js"></script>

View File

@ -1,5 +1,5 @@
/** /**
* QUnit v1.11.0pre - A JavaScript Unit Testing Framework * QUnit v1.12.0 - A JavaScript Unit Testing Framework
* *
* http://qunitjs.com * http://qunitjs.com
* *
@ -111,6 +111,11 @@
color: #000; color: #000;
} }
#qunit-tests li .runtime {
float: right;
font-size: smaller;
}
.qunit-assert-list { .qunit-assert-list {
margin-top: 0.5em; margin-top: 0.5em;
padding: 0.5em; padding: 0.5em;

View File

@ -1,11 +1,11 @@
/** /**
* QUnit v1.11.0pre - A JavaScript Unit Testing Framework * QUnit v1.12.0 - A JavaScript Unit Testing Framework
* *
* http://qunitjs.com * http://qunitjs.com
* *
* Copyright 2012 jQuery Foundation and other contributors * Copyright 2013 jQuery Foundation and other contributors
* Released under the MIT license. * Released under the MIT license.
* http://jquery.org/license * https://jquery.org/license/
*/ */
(function( window ) { (function( window ) {
@ -20,6 +20,7 @@ var QUnit,
hasOwn = Object.prototype.hasOwnProperty, hasOwn = Object.prototype.hasOwnProperty,
// Keep a local reference to Date (GH-283) // Keep a local reference to Date (GH-283)
Date = window.Date, Date = window.Date,
setTimeout = window.setTimeout,
defined = { defined = {
setTimeout: typeof window.setTimeout !== "undefined", setTimeout: typeof window.setTimeout !== "undefined",
sessionStorage: (function() { sessionStorage: (function() {
@ -33,6 +34,35 @@ var QUnit,
} }
}()) }())
}, },
/**
* Provides a normalized error string, correcting an issue
* with IE 7 (and prior) where Error.prototype.toString is
* not properly implemented
*
* Based on http://es5.github.com/#x15.11.4.4
*
* @param {String|Error} error
* @return {String} error message
*/
errorString = function( error ) {
var name, message,
errorString = error.toString();
if ( errorString.substring( 0, 7 ) === "[object" ) {
name = error.name ? error.name.toString() : "Error";
message = error.message ? error.message.toString() : "";
if ( name && message ) {
return name + ": " + message;
} else if ( name ) {
return name;
} else if ( message ) {
return message;
} else {
return "Error";
}
} else {
return errorString;
}
},
/** /**
* Makes a clone of an object using only Array or Object as base, * Makes a clone of an object using only Array or Object as base,
* and copies over the own enumerable properties. * and copies over the own enumerable properties.
@ -69,7 +99,7 @@ Test.prototype = {
if ( tests ) { if ( tests ) {
b = document.createElement( "strong" ); b = document.createElement( "strong" );
b.innerHTML = this.name; b.innerHTML = this.nameHtml;
// `a` initialized at top of scope // `a` initialized at top of scope
a = document.createElement( "a" ); a = document.createElement( "a" );
@ -86,8 +116,16 @@ Test.prototype = {
} }
}, },
setup: function() { setup: function() {
if ( this.module !== config.previousModule ) { if (
if ( config.previousModule ) { // Emit moduleStart when we're switching from one module to another
this.module !== config.previousModule ||
// They could be equal (both undefined) but if the previousModule property doesn't
// yet exist it means this is the first test in a suite that isn't wrapped in a
// module, in which case we'll just emit a moduleStart event for 'undefined'.
// Without this, reporters can get testStart before moduleStart which is a problem.
!hasOwn.call( config, "previousModule" )
) {
if ( hasOwn.call( config, "previousModule" ) ) {
runLoggingCallbacks( "moduleDone", QUnit, { runLoggingCallbacks( "moduleDone", QUnit, {
name: config.previousModule, name: config.previousModule,
failed: config.moduleStats.bad, failed: config.moduleStats.bad,
@ -100,10 +138,6 @@ Test.prototype = {
runLoggingCallbacks( "moduleStart", QUnit, { runLoggingCallbacks( "moduleStart", QUnit, {
name: this.module name: this.module
}); });
} else if ( config.autorun ) {
runLoggingCallbacks( "moduleStart", QUnit, {
name: this.module
});
} }
config.current = this; config.current = this;
@ -113,24 +147,33 @@ Test.prototype = {
teardown: function() {} teardown: function() {}
}, this.moduleTestEnvironment ); }, this.moduleTestEnvironment );
this.started = +new Date();
runLoggingCallbacks( "testStart", QUnit, { runLoggingCallbacks( "testStart", QUnit, {
name: this.testName, name: this.testName,
module: this.module module: this.module
}); });
// allow utility functions to access the current test environment /*jshint camelcase:false */
// TODO why??
/**
* Expose the current test environment.
*
* @deprecated since 1.12.0: Use QUnit.config.current.testEnvironment instead.
*/
QUnit.current_testEnvironment = this.testEnvironment; QUnit.current_testEnvironment = this.testEnvironment;
/*jshint camelcase:true */
if ( !config.pollution ) { if ( !config.pollution ) {
saveGlobal(); saveGlobal();
} }
if ( config.notrycatch ) { if ( config.notrycatch ) {
this.testEnvironment.setup.call( this.testEnvironment ); this.testEnvironment.setup.call( this.testEnvironment, QUnit.assert );
return; return;
} }
try { try {
this.testEnvironment.setup.call( this.testEnvironment ); this.testEnvironment.setup.call( this.testEnvironment, QUnit.assert );
} catch( e ) { } catch( e ) {
QUnit.pushFailure( "Setup failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 1 ) ); QUnit.pushFailure( "Setup failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 1 ) );
} }
@ -141,21 +184,27 @@ Test.prototype = {
var running = id( "qunit-testresult" ); var running = id( "qunit-testresult" );
if ( running ) { if ( running ) {
running.innerHTML = "Running: <br/>" + this.name; running.innerHTML = "Running: <br/>" + this.nameHtml;
} }
if ( this.async ) { if ( this.async ) {
QUnit.stop(); QUnit.stop();
} }
this.callbackStarted = +new Date();
if ( config.notrycatch ) { if ( config.notrycatch ) {
this.callback.call( this.testEnvironment, QUnit.assert ); this.callback.call( this.testEnvironment, QUnit.assert );
this.callbackRuntime = +new Date() - this.callbackStarted;
return; return;
} }
try { try {
this.callback.call( this.testEnvironment, QUnit.assert ); this.callback.call( this.testEnvironment, QUnit.assert );
this.callbackRuntime = +new Date() - this.callbackStarted;
} catch( e ) { } catch( e ) {
this.callbackRuntime = +new Date() - this.callbackStarted;
QUnit.pushFailure( "Died on test #" + (this.assertions.length + 1) + " " + this.stack + ": " + ( e.message || e ), extractStacktrace( e, 0 ) ); QUnit.pushFailure( "Died on test #" + (this.assertions.length + 1) + " " + this.stack + ": " + ( e.message || e ), extractStacktrace( e, 0 ) );
// else next test will carry the responsibility // else next test will carry the responsibility
saveGlobal(); saveGlobal();
@ -169,11 +218,14 @@ Test.prototype = {
teardown: function() { teardown: function() {
config.current = this; config.current = this;
if ( config.notrycatch ) { if ( config.notrycatch ) {
this.testEnvironment.teardown.call( this.testEnvironment ); if ( typeof this.callbackRuntime === "undefined" ) {
this.callbackRuntime = +new Date() - this.callbackStarted;
}
this.testEnvironment.teardown.call( this.testEnvironment, QUnit.assert );
return; return;
} else { } else {
try { try {
this.testEnvironment.teardown.call( this.testEnvironment ); this.testEnvironment.teardown.call( this.testEnvironment, QUnit.assert );
} catch( e ) { } catch( e ) {
QUnit.pushFailure( "Teardown failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 1 ) ); QUnit.pushFailure( "Teardown failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 1 ) );
} }
@ -190,12 +242,13 @@ Test.prototype = {
QUnit.pushFailure( "Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.", this.stack ); QUnit.pushFailure( "Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.", this.stack );
} }
var assertion, a, b, i, li, ol, var i, assertion, a, b, time, li, ol,
test = this, test = this,
good = 0, good = 0,
bad = 0, bad = 0,
tests = id( "qunit-tests" ); tests = id( "qunit-tests" );
this.runtime = +new Date() - this.started;
config.stats.all += this.assertions.length; config.stats.all += this.assertions.length;
config.moduleStats.all += this.assertions.length; config.moduleStats.all += this.assertions.length;
@ -235,10 +288,10 @@ Test.prototype = {
// `b` initialized at top of scope // `b` initialized at top of scope
b = document.createElement( "strong" ); b = document.createElement( "strong" );
b.innerHTML = this.name + " <b class='counts'>(<b class='failed'>" + bad + "</b>, <b class='passed'>" + good + "</b>, " + this.assertions.length + ")</b>"; b.innerHTML = this.nameHtml + " <b class='counts'>(<b class='failed'>" + bad + "</b>, <b class='passed'>" + good + "</b>, " + this.assertions.length + ")</b>";
addEvent(b, "click", function() { addEvent(b, "click", function() {
var next = b.nextSibling.nextSibling, var next = b.parentNode.lastChild,
collapsed = hasClass( next, "qunit-collapsed" ); collapsed = hasClass( next, "qunit-collapsed" );
( collapsed ? removeClass : addClass )( next, "qunit-collapsed" ); ( collapsed ? removeClass : addClass )( next, "qunit-collapsed" );
}); });
@ -253,13 +306,19 @@ Test.prototype = {
} }
}); });
// `time` initialized at top of scope
time = document.createElement( "span" );
time.className = "runtime";
time.innerHTML = this.runtime + " ms";
// `li` initialized at top of scope // `li` initialized at top of scope
li = id( this.id ); li = id( this.id );
li.className = bad ? "fail" : "pass"; li.className = bad ? "fail" : "pass";
li.removeChild( li.firstChild ); li.removeChild( li.firstChild );
a = li.firstChild; a = li.firstChild;
li.appendChild( b ); li.appendChild( b );
li.appendChild ( a ); li.appendChild( a );
li.appendChild( time );
li.appendChild( ol ); li.appendChild( ol );
} else { } else {
@ -277,7 +336,8 @@ Test.prototype = {
module: this.module, module: this.module,
failed: bad, failed: bad,
passed: this.assertions.length - bad, passed: this.assertions.length - bad,
total: this.assertions.length total: this.assertions.length,
duration: this.runtime
}); });
QUnit.reset(); QUnit.reset();
@ -343,7 +403,7 @@ QUnit = {
test: function( testName, expected, callback, async ) { test: function( testName, expected, callback, async ) {
var test, var test,
name = "<span class='test-name'>" + escapeInnerText( testName ) + "</span>"; nameHtml = "<span class='test-name'>" + escapeText( testName ) + "</span>";
if ( arguments.length === 2 ) { if ( arguments.length === 2 ) {
callback = expected; callback = expected;
@ -351,11 +411,11 @@ QUnit = {
} }
if ( config.currentModule ) { if ( config.currentModule ) {
name = "<span class='module-name'>" + config.currentModule + "</span>: " + name; nameHtml = "<span class='module-name'>" + escapeText( config.currentModule ) + "</span>: " + nameHtml;
} }
test = new Test({ test = new Test({
name: name, nameHtml: nameHtml,
testName: testName, testName: testName,
expected: expected, expected: expected,
async: async, async: async,
@ -372,7 +432,7 @@ QUnit = {
test.queue(); test.queue();
}, },
// Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through. // Specify the number of expected assertions to guarantee that failed test (no assertions are run at all) don't slip through.
expect: function( asserts ) { expect: function( asserts ) {
if (arguments.length === 1) { if (arguments.length === 1) {
config.current.expected = asserts; config.current.expected = asserts;
@ -382,6 +442,18 @@ QUnit = {
}, },
start: function( count ) { start: function( count ) {
// QUnit hasn't been initialized yet.
// Note: RequireJS (et al) may delay onLoad
if ( config.semaphore === undefined ) {
QUnit.begin(function() {
// This is triggered at the top of QUnit.load, push start() to the event loop, to allow QUnit.load to finish first
setTimeout(function() {
QUnit.start( count );
});
});
return;
}
config.semaphore -= count || 1; config.semaphore -= count || 1;
// don't start until equal number of stop-calls // don't start until equal number of stop-calls
if ( config.semaphore > 0 ) { if ( config.semaphore > 0 ) {
@ -395,7 +467,7 @@ QUnit = {
} }
// A slight delay, to avoid any current callbacks // A slight delay, to avoid any current callbacks
if ( defined.setTimeout ) { if ( defined.setTimeout ) {
window.setTimeout(function() { setTimeout(function() {
if ( config.semaphore > 0 ) { if ( config.semaphore > 0 ) {
return; return;
} }
@ -418,7 +490,7 @@ QUnit = {
if ( config.testTimeout && defined.setTimeout ) { if ( config.testTimeout && defined.setTimeout ) {
clearTimeout( config.timeout ); clearTimeout( config.timeout );
config.timeout = window.setTimeout(function() { config.timeout = setTimeout(function() {
QUnit.ok( false, "Test timed out" ); QUnit.ok( false, "Test timed out" );
config.semaphore = 1; config.semaphore = 1;
QUnit.start(); QUnit.start();
@ -428,7 +500,7 @@ QUnit = {
}; };
// `assert` initialized at top of scope // `assert` initialized at top of scope
// Asssert helpers // Assert helpers
// All of these must either call QUnit.push() or manually do: // All of these must either call QUnit.push() or manually do:
// - runLoggingCallbacks( "log", .. ); // - runLoggingCallbacks( "log", .. );
// - config.current.assertions.push({ .. }); // - config.current.assertions.push({ .. });
@ -446,6 +518,7 @@ assert = {
throw new Error( "ok() assertion outside test context, was " + sourceFromStacktrace(2) ); throw new Error( "ok() assertion outside test context, was " + sourceFromStacktrace(2) );
} }
result = !!result; result = !!result;
msg = msg || (result ? "okay" : "failed" );
var source, var source,
details = { details = {
@ -455,14 +528,13 @@ assert = {
message: msg message: msg
}; };
msg = escapeInnerText( msg || (result ? "okay" : "failed" ) ); msg = "<span class='test-message'>" + escapeText( msg ) + "</span>";
msg = "<span class='test-message'>" + msg + "</span>";
if ( !result ) { if ( !result ) {
source = sourceFromStacktrace( 2 ); source = sourceFromStacktrace( 2 );
if ( source ) { if ( source ) {
details.source = source; details.source = source;
msg += "<table><tr class='test-source'><th>Source: </th><td><pre>" + escapeInnerText( source ) + "</pre></td></tr></table>"; msg += "<table><tr class='test-source'><th>Source: </th><td><pre>" + escapeText( source ) + "</pre></td></tr></table>";
} }
} }
runLoggingCallbacks( "log", QUnit, details ); runLoggingCallbacks( "log", QUnit, details );
@ -571,7 +643,7 @@ assert = {
expectedOutput = null; expectedOutput = null;
// expected is a regexp // expected is a regexp
} else if ( QUnit.objectType( expected ) === "regexp" ) { } else if ( QUnit.objectType( expected ) === "regexp" ) {
ok = expected.test( actual ); ok = expected.test( errorString( actual ) );
// expected is a constructor // expected is a constructor
} else if ( actual instanceof expected ) { } else if ( actual instanceof expected ) {
ok = true; ok = true;
@ -583,13 +655,13 @@ assert = {
QUnit.push( ok, actual, expectedOutput, message ); QUnit.push( ok, actual, expectedOutput, message );
} else { } else {
QUnit.pushFailure( message, null, 'No exception was thrown.' ); QUnit.pushFailure( message, null, "No exception was thrown." );
} }
} }
}; };
/** /**
* @deprecate since 1.8.0 * @deprecated since 1.8.0
* Kept assertion helpers in root for backwards compatibility. * Kept assertion helpers in root for backwards compatibility.
*/ */
extend( QUnit, assert ); extend( QUnit, assert );
@ -678,7 +750,7 @@ config = {
// Export global variables, unless an 'exports' object exists, // Export global variables, unless an 'exports' object exists,
// in that case we assume we're in CommonJS (dealt with on the bottom of the script) // in that case we assume we're in CommonJS (dealt with on the bottom of the script)
if ( typeof exports === "undefined" ) { if ( typeof exports === "undefined" ) {
extend( window, QUnit ); extend( window, QUnit.constructor.prototype );
// Expose QUnit object // Expose QUnit object
window.QUnit = QUnit; window.QUnit = QUnit;
@ -744,7 +816,7 @@ extend( QUnit, {
if ( qunit ) { if ( qunit ) {
qunit.innerHTML = qunit.innerHTML =
"<h1 id='qunit-header'>" + escapeInnerText( document.title ) + "</h1>" + "<h1 id='qunit-header'>" + escapeText( document.title ) + "</h1>" +
"<h2 id='qunit-banner'></h2>" + "<h2 id='qunit-banner'></h2>" +
"<div id='qunit-testrunner-toolbar'></div>" + "<div id='qunit-testrunner-toolbar'></div>" +
"<h2 id='qunit-userAgent'></h2>" + "<h2 id='qunit-userAgent'></h2>" +
@ -777,6 +849,11 @@ extend( QUnit, {
}, },
// Resets the test setup. Useful for tests that modify the DOM. // Resets the test setup. Useful for tests that modify the DOM.
/*
DEPRECATED: Use multiple tests instead of resetting inside a test.
Use testStart or testDone for custom cleanup.
This method will throw an error in 2.0, and will be removed in 2.1
*/
reset: function() { reset: function() {
var fixture = id( "qunit-fixture" ); var fixture = id( "qunit-fixture" );
if ( fixture ) { if ( fixture ) {
@ -850,13 +927,13 @@ extend( QUnit, {
expected: expected expected: expected
}; };
message = escapeInnerText( message ) || ( result ? "okay" : "failed" ); message = escapeText( message ) || ( result ? "okay" : "failed" );
message = "<span class='test-message'>" + message + "</span>"; message = "<span class='test-message'>" + message + "</span>";
output = message; output = message;
if ( !result ) { if ( !result ) {
expected = escapeInnerText( QUnit.jsDump.parse(expected) ); expected = escapeText( QUnit.jsDump.parse(expected) );
actual = escapeInnerText( QUnit.jsDump.parse(actual) ); actual = escapeText( QUnit.jsDump.parse(actual) );
output += "<table><tr class='test-expected'><th>Expected: </th><td><pre>" + expected + "</pre></td></tr>"; output += "<table><tr class='test-expected'><th>Expected: </th><td><pre>" + expected + "</pre></td></tr>";
if ( actual !== expected ) { if ( actual !== expected ) {
@ -868,7 +945,7 @@ extend( QUnit, {
if ( source ) { if ( source ) {
details.source = source; details.source = source;
output += "<tr class='test-source'><th>Source: </th><td><pre>" + escapeInnerText( source ) + "</pre></td></tr>"; output += "<tr class='test-source'><th>Source: </th><td><pre>" + escapeText( source ) + "</pre></td></tr>";
} }
output += "</table>"; output += "</table>";
@ -895,19 +972,19 @@ extend( QUnit, {
message: message message: message
}; };
message = escapeInnerText( message ) || "error"; message = escapeText( message ) || "error";
message = "<span class='test-message'>" + message + "</span>"; message = "<span class='test-message'>" + message + "</span>";
output = message; output = message;
output += "<table>"; output += "<table>";
if ( actual ) { if ( actual ) {
output += "<tr class='test-actual'><th>Result: </th><td><pre>" + escapeInnerText( actual ) + "</pre></td></tr>"; output += "<tr class='test-actual'><th>Result: </th><td><pre>" + escapeText( actual ) + "</pre></td></tr>";
} }
if ( source ) { if ( source ) {
details.source = source; details.source = source;
output += "<tr class='test-source'><th>Source: </th><td><pre>" + escapeInnerText( source ) + "</pre></td></tr>"; output += "<tr class='test-source'><th>Source: </th><td><pre>" + escapeText( source ) + "</pre></td></tr>";
} }
output += "</table>"; output += "</table>";
@ -926,18 +1003,21 @@ extend( QUnit, {
querystring = "?"; querystring = "?";
for ( key in params ) { for ( key in params ) {
if ( !hasOwn.call( params, key ) ) { if ( hasOwn.call( params, key ) ) {
continue;
}
querystring += encodeURIComponent( key ) + "=" + querystring += encodeURIComponent( key ) + "=" +
encodeURIComponent( params[ key ] ) + "&"; encodeURIComponent( params[ key ] ) + "&";
} }
return window.location.pathname + querystring.slice( 0, -1 ); }
return window.location.protocol + "//" + window.location.host +
window.location.pathname + querystring.slice( 0, -1 );
}, },
extend: extend, extend: extend,
id: id, id: id,
addEvent: addEvent addEvent: addEvent,
addClass: addClass,
hasClass: hasClass,
removeClass: removeClass
// load, equiv, jsDump, diff: Attached later // load, equiv, jsDump, diff: Attached later
}); });
@ -963,7 +1043,7 @@ extend( QUnit.constructor.prototype, {
// testStart: { name } // testStart: { name }
testStart: registerLoggingCallback( "testStart" ), testStart: registerLoggingCallback( "testStart" ),
// testDone: { name, failed, passed, total } // testDone: { name, failed, passed, total, duration }
testDone: registerLoggingCallback( "testDone" ), testDone: registerLoggingCallback( "testDone" ),
// moduleStart: { name } // moduleStart: { name }
@ -981,8 +1061,10 @@ QUnit.load = function() {
runLoggingCallbacks( "begin", QUnit, {} ); runLoggingCallbacks( "begin", QUnit, {} );
// Initialize the config, saving the execution queue // Initialize the config, saving the execution queue
var banner, filter, i, label, len, main, ol, toolbar, userAgent, val, urlConfigCheckboxes, moduleFilter, var banner, filter, i, label, len, main, ol, toolbar, userAgent, val,
urlConfigCheckboxesContainer, urlConfigCheckboxes, moduleFilter,
numModules = 0, numModules = 0,
moduleNames = [],
moduleFilterHtml = "", moduleFilterHtml = "",
urlConfigHtml = "", urlConfigHtml = "",
oldconfig = extend( {}, config ); oldconfig = extend( {}, config );
@ -1004,16 +1086,32 @@ QUnit.load = function() {
}; };
} }
config[ val.id ] = QUnit.urlParams[ val.id ]; config[ val.id ] = QUnit.urlParams[ val.id ];
urlConfigHtml += "<input id='qunit-urlconfig-" + val.id + "' name='" + val.id + "' type='checkbox'" + ( config[ val.id ] ? " checked='checked'" : "" ) + " title='" + val.tooltip + "'><label for='qunit-urlconfig-" + val.id + "' title='" + val.tooltip + "'>" + val.label + "</label>"; urlConfigHtml += "<input id='qunit-urlconfig-" + escapeText( val.id ) +
"' name='" + escapeText( val.id ) +
"' type='checkbox'" + ( config[ val.id ] ? " checked='checked'" : "" ) +
" title='" + escapeText( val.tooltip ) +
"'><label for='qunit-urlconfig-" + escapeText( val.id ) +
"' title='" + escapeText( val.tooltip ) + "'>" + val.label + "</label>";
} }
moduleFilterHtml += "<label for='qunit-modulefilter'>Module: </label><select id='qunit-modulefilter' name='modulefilter'><option value='' " + ( config.module === undefined ? "selected" : "" ) + ">< All Modules ></option>";
for ( i in config.modules ) { for ( i in config.modules ) {
if ( config.modules.hasOwnProperty( i ) ) { if ( config.modules.hasOwnProperty( i ) ) {
numModules += 1; moduleNames.push(i);
moduleFilterHtml += "<option value='" + encodeURIComponent(i) + "' " + ( config.module === i ? "selected" : "" ) + ">" + i + "</option>";
} }
} }
numModules = moduleNames.length;
moduleNames.sort( function( a, b ) {
return a.localeCompare( b );
});
moduleFilterHtml += "<label for='qunit-modulefilter'>Module: </label><select id='qunit-modulefilter' name='modulefilter'><option value='' " +
( config.module === undefined ? "selected='selected'" : "" ) +
">< All Modules ></option>";
for ( i = 0; i < numModules; i++) {
moduleFilterHtml += "<option value='" + escapeText( encodeURIComponent(moduleNames[i]) ) + "' " +
( config.module === moduleNames[i] ? "selected='selected'" : "" ) +
">" + escapeText(moduleNames[i]) + "</option>";
}
moduleFilterHtml += "</select>"; moduleFilterHtml += "</select>";
// `userAgent` initialized at top of scope // `userAgent` initialized at top of scope
@ -1066,28 +1164,39 @@ QUnit.load = function() {
// `label` initialized at top of scope // `label` initialized at top of scope
label = document.createElement( "label" ); label = document.createElement( "label" );
label.setAttribute( "for", "qunit-filter-pass" ); label.setAttribute( "for", "qunit-filter-pass" );
label.setAttribute( "title", "Only show tests and assertons that fail. Stored in sessionStorage." ); label.setAttribute( "title", "Only show tests and assertions that fail. Stored in sessionStorage." );
label.innerHTML = "Hide passed tests"; label.innerHTML = "Hide passed tests";
toolbar.appendChild( label ); toolbar.appendChild( label );
urlConfigCheckboxes = document.createElement( 'span' ); urlConfigCheckboxesContainer = document.createElement("span");
urlConfigCheckboxes.innerHTML = urlConfigHtml; urlConfigCheckboxesContainer.innerHTML = urlConfigHtml;
addEvent( urlConfigCheckboxes, "change", function( event ) { urlConfigCheckboxes = urlConfigCheckboxesContainer.getElementsByTagName("input");
var params = {}; // For oldIE support:
params[ event.target.name ] = event.target.checked ? true : undefined; // * Add handlers to the individual elements instead of the container
// * Use "click" instead of "change"
// * Fallback from event.target to event.srcElement
addEvents( urlConfigCheckboxes, "click", function( event ) {
var params = {},
target = event.target || event.srcElement;
params[ target.name ] = target.checked ? true : undefined;
window.location = QUnit.url( params ); window.location = QUnit.url( params );
}); });
toolbar.appendChild( urlConfigCheckboxes ); toolbar.appendChild( urlConfigCheckboxesContainer );
if (numModules > 1) { if (numModules > 1) {
moduleFilter = document.createElement( 'span' ); moduleFilter = document.createElement( "span" );
moduleFilter.setAttribute( 'id', 'qunit-modulefilter-container' ); moduleFilter.setAttribute( "id", "qunit-modulefilter-container" );
moduleFilter.innerHTML = moduleFilterHtml; moduleFilter.innerHTML = moduleFilterHtml;
addEvent( moduleFilter, "change", function() { addEvent( moduleFilter.lastChild, "change", function() {
var selectBox = moduleFilter.getElementsByTagName("select")[0], var selectBox = moduleFilter.getElementsByTagName("select")[0],
selectedModule = decodeURIComponent(selectBox.options[selectBox.selectedIndex].value); selectedModule = decodeURIComponent(selectBox.options[selectBox.selectedIndex].value);
window.location = QUnit.url( { module: ( selectedModule === "" ) ? undefined : selectedModule } ); window.location = QUnit.url({
module: ( selectedModule === "" ) ? undefined : selectedModule,
// Remove any existing filters
filter: undefined,
testNumber: undefined
});
}); });
toolbar.appendChild(moduleFilter); toolbar.appendChild(moduleFilter);
} }
@ -1111,7 +1220,7 @@ addEvent( window, "load", QUnit.load );
onErrorFnPrev = window.onerror; onErrorFnPrev = window.onerror;
// Cover uncaught exceptions // Cover uncaught exceptions
// Returning true will surpress the default browser handler, // Returning true will suppress the default browser handler,
// returning false will let it run. // returning false will let it run.
window.onerror = function ( error, filePath, linerNr ) { window.onerror = function ( error, filePath, linerNr ) {
var ret = false; var ret = false;
@ -1120,7 +1229,7 @@ window.onerror = function ( error, filePath, linerNr ) {
} }
// Treat return value as window.onerror itself does, // Treat return value as window.onerror itself does,
// Only do our handling if not surpressed. // Only do our handling if not suppressed.
if ( ret !== true ) { if ( ret !== true ) {
if ( QUnit.config.current ) { if ( QUnit.config.current ) {
if ( QUnit.config.current.ignoreGlobalErrors ) { if ( QUnit.config.current.ignoreGlobalErrors ) {
@ -1150,6 +1259,7 @@ function done() {
total: config.moduleStats.all total: config.moduleStats.all
}); });
} }
delete config.previousModule;
var i, key, var i, key,
banner = id( "qunit-banner" ), banner = id( "qunit-banner" ),
@ -1255,7 +1365,7 @@ function validTest( test ) {
function extractStacktrace( e, offset ) { function extractStacktrace( e, offset ) {
offset = offset === undefined ? 3 : offset; offset = offset === undefined ? 3 : offset;
var stack, include, i, regex; var stack, include, i;
if ( e.stacktrace ) { if ( e.stacktrace ) {
// Opera // Opera
@ -1298,17 +1408,27 @@ function sourceFromStacktrace( offset ) {
} }
} }
function escapeInnerText( s ) { /**
* Escape text for attribute or text content.
*/
function escapeText( s ) {
if ( !s ) { if ( !s ) {
return ""; return "";
} }
s = s + ""; s = s + "";
return s.replace( /[\&<>]/g, function( s ) { // Both single quotes and double quotes (for attributes)
return s.replace( /['"<>&]/g, function( s ) {
switch( s ) { switch( s ) {
case "&": return "&amp;"; case "'":
case "<": return "&lt;"; return "&#039;";
case ">": return "&gt;"; case "\"":
default: return s; return "&quot;";
case "<":
return "&lt;";
case ">":
return "&gt;";
case "&":
return "&amp;";
} }
}); });
} }
@ -1332,7 +1452,7 @@ function process( last ) {
if ( !defined.setTimeout || config.updateRate <= 0 || ( ( new Date().getTime() - start ) < config.updateRate ) ) { if ( !defined.setTimeout || config.updateRate <= 0 || ( ( new Date().getTime() - start ) < config.updateRate ) ) {
config.queue.shift()(); config.queue.shift()();
} else { } else {
window.setTimeout( next, 13 ); setTimeout( next, 13 );
break; break;
} }
} }
@ -1347,16 +1467,18 @@ function saveGlobal() {
if ( config.noglobals ) { if ( config.noglobals ) {
for ( var key in window ) { for ( var key in window ) {
if ( hasOwn.call( window, key ) ) {
// in Opera sometimes DOM element ids show up here, ignore them // in Opera sometimes DOM element ids show up here, ignore them
if ( !hasOwn.call( window, key ) || /^qunit-test-output/.test( key ) ) { if ( /^qunit-test-output/.test( key ) ) {
continue; continue;
} }
config.pollution.push( key ); config.pollution.push( key );
} }
} }
}
} }
function checkPollution( name ) { function checkPollution() {
var newGlobals, var newGlobals,
deletedGlobals, deletedGlobals,
old = config.pollution; old = config.pollution;
@ -1393,25 +1515,45 @@ function diff( a, b ) {
function extend( a, b ) { function extend( a, b ) {
for ( var prop in b ) { for ( var prop in b ) {
if ( hasOwn.call( b, prop ) ) {
// Avoid "Member not found" error in IE8 caused by messing with window.constructor
if ( !( prop === "constructor" && a === window ) ) {
if ( b[ prop ] === undefined ) { if ( b[ prop ] === undefined ) {
delete a[ prop ]; delete a[ prop ];
} else {
// Avoid "Member not found" error in IE8 caused by setting window.constructor
} else if ( prop !== "constructor" || a !== window ) {
a[ prop ] = b[ prop ]; a[ prop ] = b[ prop ];
} }
} }
}
}
return a; return a;
} }
/**
* @param {HTMLElement} elem
* @param {string} type
* @param {Function} fn
*/
function addEvent( elem, type, fn ) { function addEvent( elem, type, fn ) {
// Standards-based browsers
if ( elem.addEventListener ) { if ( elem.addEventListener ) {
elem.addEventListener( type, fn, false ); elem.addEventListener( type, fn, false );
} else if ( elem.attachEvent ) { // IE
elem.attachEvent( "on" + type, fn );
} else { } else {
fn(); elem.attachEvent( "on" + type, fn );
}
}
/**
* @param {Array|NodeList} elems
* @param {string} type
* @param {Function} fn
*/
function addEvents( elems, type, fn ) {
var i = elems.length;
while ( i-- ) {
addEvent( elems[i], type, fn );
} }
} }
@ -1431,8 +1573,8 @@ function removeClass( elem, name ) {
while ( set.indexOf(" " + name + " ") > -1 ) { while ( set.indexOf(" " + name + " ") > -1 ) {
set = set.replace(" " + name + " " , " "); set = set.replace(" " + name + " " , " ");
} }
// If possible, trim it for prettiness, but not neccecarily // If possible, trim it for prettiness, but not necessarily
elem.className = window.jQuery ? jQuery.trim( set ) : ( set.trim ? set.trim() : set ); elem.className = typeof set.trim === "function" ? set.trim() : set.replace(/^\s+|\s+$/g, "");
} }
function id( name ) { function id( name ) {
@ -1448,7 +1590,6 @@ function registerLoggingCallback( key ) {
// Supports deprecated method of completely overwriting logging callbacks // Supports deprecated method of completely overwriting logging callbacks
function runLoggingCallbacks( key, scope, args ) { function runLoggingCallbacks( key, scope, args ) {
//debugger;
var i, callbacks; var i, callbacks;
if ( QUnit.hasOwnProperty( key ) ) { if ( QUnit.hasOwnProperty( key ) ) {
QUnit[ key ].call(scope, args ); QUnit[ key ].call(scope, args );
@ -1482,8 +1623,10 @@ QUnit.equiv = (function() {
callers = [], callers = [],
// stack to avoiding loops from circular referencing // stack to avoiding loops from circular referencing
parents = [], parents = [],
parentsB = [],
getProto = Object.getPrototypeOf || function ( obj ) { getProto = Object.getPrototypeOf || function ( obj ) {
/*jshint camelcase:false */
return obj.__proto__; return obj.__proto__;
}, },
callbacks = (function () { callbacks = (function () {
@ -1492,7 +1635,7 @@ QUnit.equiv = (function() {
function useStrictEquality( b, a ) { function useStrictEquality( b, a ) {
/*jshint eqeqeq:false */ /*jshint eqeqeq:false */
if ( b instanceof a.constructor || a instanceof b.constructor ) { if ( b instanceof a.constructor || a instanceof b.constructor ) {
// to catch short annotaion VS 'new' annotation of a // to catch short annotation VS 'new' annotation of a
// declaration // declaration
// e.g. var i = 1; // e.g. var i = 1;
// var j = new Number(1); // var j = new Number(1);
@ -1521,7 +1664,7 @@ QUnit.equiv = (function() {
return QUnit.objectType( b ) === "regexp" && return QUnit.objectType( b ) === "regexp" &&
// the regex itself // the regex itself
a.source === b.source && a.source === b.source &&
// and its modifers // and its modifiers
a.global === b.global && a.global === b.global &&
// (gmi) ... // (gmi) ...
a.ignoreCase === b.ignoreCase && a.ignoreCase === b.ignoreCase &&
@ -1538,7 +1681,7 @@ QUnit.equiv = (function() {
}, },
"array": function( b, a ) { "array": function( b, a ) {
var i, j, len, loop; var i, j, len, loop, aCircular, bCircular;
// b could be an object literal here // b could be an object literal here
if ( QUnit.objectType( b ) !== "array" ) { if ( QUnit.objectType( b ) !== "array" ) {
@ -1553,24 +1696,36 @@ QUnit.equiv = (function() {
// track reference to avoid circular references // track reference to avoid circular references
parents.push( a ); parents.push( a );
parentsB.push( b );
for ( i = 0; i < len; i++ ) { for ( i = 0; i < len; i++ ) {
loop = false; loop = false;
for ( j = 0; j < parents.length; j++ ) { for ( j = 0; j < parents.length; j++ ) {
if ( parents[j] === a[i] ) { aCircular = parents[j] === a[i];
loop = true;// dont rewalk array bCircular = parentsB[j] === b[i];
if ( aCircular || bCircular ) {
if ( a[i] === b[i] || aCircular && bCircular ) {
loop = true;
} else {
parents.pop();
parentsB.pop();
return false;
}
} }
} }
if ( !loop && !innerEquiv(a[i], b[i]) ) { if ( !loop && !innerEquiv(a[i], b[i]) ) {
parents.pop(); parents.pop();
parentsB.pop();
return false; return false;
} }
} }
parents.pop(); parents.pop();
parentsB.pop();
return true; return true;
}, },
"object": function( b, a ) { "object": function( b, a ) {
var i, j, loop, /*jshint forin:false */
var i, j, loop, aCircular, bCircular,
// Default to true // Default to true
eq = true, eq = true,
aProperties = [], aProperties = [],
@ -1589,28 +1744,36 @@ QUnit.equiv = (function() {
// stack constructor before traversing properties // stack constructor before traversing properties
callers.push( a.constructor ); callers.push( a.constructor );
// track reference to avoid circular references // track reference to avoid circular references
parents.push( a ); parents.push( a );
parentsB.push( b );
for ( i in a ) { // be strict: don't ensures hasOwnProperty // be strict: don't ensure hasOwnProperty and go deep
// and go deep for ( i in a ) {
loop = false; loop = false;
for ( j = 0; j < parents.length; j++ ) { for ( j = 0; j < parents.length; j++ ) {
if ( parents[j] === a[i] ) { aCircular = parents[j] === a[i];
// don't go down the same path twice bCircular = parentsB[j] === b[i];
if ( aCircular || bCircular ) {
if ( a[i] === b[i] || aCircular && bCircular ) {
loop = true; loop = true;
} else {
eq = false;
break;
} }
} }
aProperties.push(i); // collect a's properties }
aProperties.push(i);
if (!loop && !innerEquiv( a[i], b[i] ) ) { if ( !loop && !innerEquiv(a[i], b[i]) ) {
eq = false; eq = false;
break; break;
} }
} }
callers.pop(); // unstack, we are done
parents.pop(); parents.pop();
parentsB.pop();
callers.pop(); // unstack, we are done
for ( i in b ) { for ( i in b ) {
bProperties.push( i ); // collect b's properties bProperties.push( i ); // collect b's properties
@ -1640,7 +1803,7 @@ QUnit.equiv = (function() {
} }
// apply transition with (1..n) arguments // apply transition with (1..n) arguments
}( args[0], args[1] ) && arguments.callee.apply( this, args.splice(1, args.length - 1 )) ); }( args[0], args[1] ) && innerEquiv.apply( this, args.splice(1, args.length - 1 )) );
}; };
return innerEquiv; return innerEquiv;
@ -1658,7 +1821,7 @@ QUnit.equiv = (function() {
*/ */
QUnit.jsDump = (function() { QUnit.jsDump = (function() {
function quote( str ) { function quote( str ) {
return '"' + str.toString().replace( /"/g, '\\"' ) + '"'; return "\"" + str.toString().replace( /"/g, "\\\"" ) + "\"";
} }
function literal( o ) { function literal( o ) {
return o + ""; return o + "";
@ -1751,13 +1914,13 @@ QUnit.jsDump = (function() {
if ( this.HTML ) { if ( this.HTML ) {
chr = chr.replace( /\t/g, " " ).replace( / /g, "&nbsp;" ); chr = chr.replace( /\t/g, " " ).replace( / /g, "&nbsp;" );
} }
return new Array( this._depth_ + (extra||0) ).join(chr); return new Array( this.depth + ( extra || 0 ) ).join(chr);
}, },
up: function( a ) { up: function( a ) {
this._depth_ += a || 1; this.depth += a || 1;
}, },
down: function( a ) { down: function( a ) {
this._depth_ -= a || 1; this.depth -= a || 1;
}, },
setParser: function( name, parser ) { setParser: function( name, parser ) {
this.parsers[name] = parser; this.parsers[name] = parser;
@ -1767,7 +1930,7 @@ QUnit.jsDump = (function() {
literal: literal, literal: literal,
join: join, join: join,
// //
_depth_: 1, depth: 1,
// This is the list of parsers, to modify them, use jsDump.setParser // This is the list of parsers, to modify them, use jsDump.setParser
parsers: { parsers: {
window: "[Window]", window: "[Window]",
@ -1795,6 +1958,7 @@ QUnit.jsDump = (function() {
nodelist: array, nodelist: array,
"arguments": array, "arguments": array,
object: function( map, stack ) { object: function( map, stack ) {
/*jshint forin:false */
var ret = [ ], keys, key, val, i; var ret = [ ], keys, key, val, i;
QUnit.jsDump.up(); QUnit.jsDump.up();
keys = []; keys = [];
@ -1811,19 +1975,31 @@ QUnit.jsDump = (function() {
return join( "{", ret, "}" ); return join( "{", ret, "}" );
}, },
node: function( node ) { node: function( node ) {
var a, val, var len, i, val,
open = QUnit.jsDump.HTML ? "&lt;" : "<", open = QUnit.jsDump.HTML ? "&lt;" : "<",
close = QUnit.jsDump.HTML ? "&gt;" : ">", close = QUnit.jsDump.HTML ? "&gt;" : ">",
tag = node.nodeName.toLowerCase(), tag = node.nodeName.toLowerCase(),
ret = open + tag; ret = open + tag,
attrs = node.attributes;
for ( a in QUnit.jsDump.DOMAttrs ) { if ( attrs ) {
val = node[ QUnit.jsDump.DOMAttrs[a] ]; for ( i = 0, len = attrs.length; i < len; i++ ) {
if ( val ) { val = attrs[i].nodeValue;
ret += " " + a + "=" + QUnit.jsDump.parse( val, "attribute" ); // IE6 includes all attributes in .attributes, even ones not explicitly set.
// Those have values like undefined, null, 0, false, "" or "inherit".
if ( val && val !== "inherit" ) {
ret += " " + attrs[i].nodeName + "=" + QUnit.jsDump.parse( val, "attribute" );
} }
} }
return ret + close + open + "/" + tag + close; }
ret += close;
// Show content of TextNode or CDATASection
if ( node.nodeType === 3 || node.nodeType === 4 ) {
ret += node.nodeValue;
}
return ret + open + "/" + tag + close;
}, },
// function calls it internally, it's the arguments part of the function // function calls it internally, it's the arguments part of the function
functionArgs: function( fn ) { functionArgs: function( fn ) {
@ -1853,12 +2029,6 @@ QUnit.jsDump = (function() {
number: literal, number: literal,
"boolean": literal "boolean": literal
}, },
DOMAttrs: {
//attributes to dump from nodes, name=>realName
id: "id",
name: "name",
"class": "className"
},
// if true, entities are escaped ( <, >, \t, space and \n ) // if true, entities are escaped ( <, >, \t, space and \n )
HTML: false, HTML: false,
// indentation unit // indentation unit
@ -1870,27 +2040,6 @@ QUnit.jsDump = (function() {
return jsDump; return jsDump;
}()); }());
// from Sizzle.js
function getText( elems ) {
var i, elem,
ret = "";
for ( i = 0; elems[i]; i++ ) {
elem = elems[i];
// Get the text from text nodes and CDATA nodes
if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
ret += elem.nodeValue;
// Traverse everything else, except comment nodes
} else if ( elem.nodeType !== 8 ) {
ret += getText( elem.childNodes );
}
}
return ret;
}
// from jquery.js // from jquery.js
function inArray( elem, array ) { function inArray( elem, array ) {
if ( array.indexOf ) { if ( array.indexOf ) {
@ -1928,7 +2077,7 @@ QUnit.diff = (function() {
os = {}; os = {};
for ( i = 0; i < n.length; i++ ) { for ( i = 0; i < n.length; i++ ) {
if ( ns[ n[i] ] == null ) { if ( !hasOwn.call( ns, n[i] ) ) {
ns[ n[i] ] = { ns[ n[i] ] = {
rows: [], rows: [],
o: null o: null
@ -1938,7 +2087,7 @@ QUnit.diff = (function() {
} }
for ( i = 0; i < o.length; i++ ) { for ( i = 0; i < o.length; i++ ) {
if ( os[ o[i] ] == null ) { if ( !hasOwn.call( os, o[i] ) ) {
os[ o[i] ] = { os[ o[i] ] = {
rows: [], rows: [],
n: null n: null
@ -1948,10 +2097,8 @@ QUnit.diff = (function() {
} }
for ( i in ns ) { for ( i in ns ) {
if ( !hasOwn.call( ns, i ) ) { if ( hasOwn.call( ns, i ) ) {
continue; if ( ns[i].rows.length === 1 && hasOwn.call( os, i ) && os[i].rows.length === 1 ) {
}
if ( ns[i].rows.length === 1 && os[i] !== undefined && os[i].rows.length === 1 ) {
n[ ns[i].rows[0] ] = { n[ ns[i].rows[0] ] = {
text: n[ ns[i].rows[0] ], text: n[ ns[i].rows[0] ],
row: os[i].rows[0] row: os[i].rows[0]
@ -1962,6 +2109,7 @@ QUnit.diff = (function() {
}; };
} }
} }
}
for ( i = 0; i < n.length - 1; i++ ) { for ( i = 0; i < n.length - 1; i++ ) {
if ( n[i].text != null && n[ i + 1 ].text == null && n[i].row + 1 < o.length && o[ n[i].row + 1 ].text == null && if ( n[i].text != null && n[ i + 1 ].text == null && n[i].row + 1 < o.length && o[ n[i].row + 1 ].text == null &&
@ -2055,9 +2203,9 @@ QUnit.diff = (function() {
}; };
}()); }());
// for CommonJS enviroments, export everything // for CommonJS environments, export everything
if ( typeof exports !== "undefined" ) { if ( typeof exports !== "undefined" ) {
extend( exports, QUnit ); extend( exports, QUnit.constructor.prototype );
} }
// get at whatever the global object is, like window in browsers // get at whatever the global object is, like window in browsers

View File

@ -50,7 +50,25 @@
equal(e, $_("div").el[i], ".each function has current selector"); equal(e, $_("div").el[i], ".each function has current selector");
i++; i++;
}); });
equal($_().el, window.document.documentElement, "Empty selector is set to documentElement");
strictEqual($_().el, window.document.documentElement, "Empty selector is set to documentElement");
strictEqual($_('#qunit').el, document.getElementById('qunit'), "Id selector equivalence")
strictEqual(is_clone($_('#qunit').el, $_.$('#qunit')), true, "El attribute is same as direct selector");
strictEqual(is_clone($_('div').el, $_.$('div')), true, "El attribute is same as direct selector");
});
asyncTest("Interator tests", function() {
$_('#qunit').each(function(el) {
equal(el, $_.$('#qunit'));
start();
});
/*$_('foo').each(function(el) {
equal(el, undefined);
start();
});*/
}); });
test("Array.isArray", function(){ test("Array.isArray", function(){

View File

@ -4,21 +4,15 @@
module("events"); module("events");
test("Events defined", function(){ test("Events defined", function(){
expect(2); expect(4);
ok($_.event.add, "Add Method Exists"); ok($_.event.add, "Add Method Exists");
ok($_.event.remove, "Remove Method Exists"); ok($_.event.remove, "Remove Method Exists");
ok($_.event.live, "Live Method Exists");
ok($_.event.delegate, "Delegate Method Exists");
}); });
test("Browser expando support", function() { test("Adding Events", function() {
expect(3); expect(0);
// kis-js events uses expando properties to store event listeners for IE
// If this test fails, the event module will likely fail as well
var ele = document.createElement("div");
ele.expando = {a:5, b:"c", c: function cool(){return ele}};
equal(ele.expando.a, 5);
equal(ele.expando.b, "c");
equal(ele.expando.c(), ele,
"Closure isn't broken by being assigned to an expando property");
}); });
}()); }());