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`
* *
@ -164,27 +113,7 @@
{ {
if(sel.length !== undefined && sel !== window) if(sel.length !== undefined && sel !== window)
{ {
// Use the native method, if it exists [].forEach.call(sel, callback);
if(Array.prototype.forEach !== undefined)
{
[].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`
* *
@ -164,27 +113,7 @@
{ {
if(sel.length !== undefined && sel !== window) if(sel.length !== undefined && sel !== window)
{ {
// Use the native method, if it exists [].forEach.call(sel, callback);
if(Array.prototype.forEach !== undefined)
{
[].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`
* *
@ -164,27 +113,7 @@
{ {
if(sel.length !== undefined && sel !== window) if(sel.length !== undefined && sel !== window)
{ {
// Use the native method, if it exists [].forEach.call(sel, callback);
if(Array.prototype.forEach !== undefined)
{
[].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`
* *
@ -164,27 +113,7 @@
{ {
if(sel.length !== undefined && sel !== window) if(sel.length !== undefined && sel !== window)
{ {
// Use the native method, if it exists [].forEach.call(sel, callback);
if(Array.prototype.forEach !== undefined)
{
[].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;

File diff suppressed because it is too large Load Diff

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");
}); });
}()); }());