erikroyall/hilo

View on GitHub
docs/misc.html

Summary

Maintainability
Test Coverage
<!DOCTYPE html>

<html>
<head>
  <title>misc.js</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
  <link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
  <div id="container">
    <div id="background"></div>
    
      <ul id="jump_to">
        <li>
          <a class="large" href="javascript:void(0);">Jump To &hellip;</a>
          <a class="small" href="javascript:void(0);">+</a>
          <div id="jump_wrapper">
          <div id="jump_page">
            
              
              <a class="source" href="ajax.html">
                ajax.js
              </a>
            
              
              <a class="source" href="anim.html">
                anim.js
              </a>
            
              
              <a class="source" href="core.html">
                core.js
              </a>
            
              
              <a class="source" href="detect.html">
                detect.js
              </a>
            
              
              <a class="source" href="dom.html">
                dom.js
              </a>
            
              
              <a class="source" href="end.html">
                end.js
              </a>
            
              
              <a class="source" href="evt.html">
                evt.js
              </a>
            
              
              <a class="source" href="fx.html">
                fx.js
              </a>
            
              
              <a class="source" href="legacy.html">
                legacy.js
              </a>
            
              
              <a class="source" href="misc.html">
                misc.js
              </a>
            
              
              <a class="source" href="more.html">
                more.js
              </a>
            
              
              <a class="source" href="polyfill.html">
                polyfill.js
              </a>
            
              
              <a class="source" href="sizzle.html">
                sizzle.js
              </a>
            
              
              <a class="source" href="start.html">
                start.js
              </a>
            
              
              <a class="source" href="test.html">
                test.js
              </a>
            
              
              <a class="source" href="util.html">
                util.js
              </a>
            
          </div>
        </li>
      </ul>
    
    <ul class="sections">
        
          <li id="title">
              <div class="annotation">
                  <h1>misc.js</h1>
              </div>
          </li>
        
        
        
        <li id="section-1">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-1">&#182;</a>
              </div>
              
            </div>
            
            <div class="content"><div class='highlight'><pre>
  <span class="hljs-comment">/**
   * Attaches classes to &lt;body&gt;
   * 
   * @for hilo
   * @method classify
   * @return {Array} List of classes applied
   * @examples
   * &lt;div class="code"&gt;&lt;pre class="prettyprint"&gt;
   * var classes = Hilo.classify();
   * &lt;/pre&gt;&lt;/div&gt;
   * @since 0.1.0
   */</span>
  hilo.classify = <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-params">()</span> </span>{
    <span class="hljs-keyword">var</span> body = win.Hilo(<span class="hljs-string">"body"</span>)
      , classes = [<span class="hljs-string">"js"</span>]
      , _i;</pre></div></div>
            
        </li>
        
        
        <li id="section-2">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-2">&#182;</a>
              </div>
              <p>Remove the default no-js class</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>    body.removeClass(<span class="hljs-string">"no-js"</span>);

    <span class="hljs-keyword">if</span> (hilo.browser.chrome) {
      classes.push(<span class="hljs-string">"chrome"</span>);
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (hilo.browser.firefox) {
      classes.push(<span class="hljs-string">"firefox"</span>);
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (hilo.browser.safari) {
      classes.push(<span class="hljs-string">"safari"</span>);
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (hilo.browser.ie) {

      <span class="hljs-keyword">for</span> (_i = <span class="hljs-number">6</span>; _i &lt;= <span class="hljs-number">11</span>; _i++) {
        <span class="hljs-keyword">if</span> (hilo.browser.ie &lt;= _i) {
          classes.push(<span class="hljs-string">"lte-ie"</span> + _i);

          <span class="hljs-keyword">if</span> (hilo.browser.ie &lt; _i) {
            classes.push(<span class="hljs-string">"lt-ie"</span> + _i);
          }
        }

        <span class="hljs-keyword">if</span> (hilo.browser.ie &gt;= _i) {
          classes.push(<span class="hljs-string">"gte-ie"</span> + _i);

          <span class="hljs-keyword">if</span> (hilo.browser.ie &gt; _i) {
            classes.push(<span class="hljs-string">"gt-ie"</span> + _i);
          }
        }

        <span class="hljs-keyword">if</span> (hilo.browser.ie === _i) {
          classes.push(<span class="hljs-string">"ie"</span> + _i);
        }
      }

      classes.push(<span class="hljs-string">"ie"</span>);
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (hilo.browser.opera) {
      classes.push(<span class="hljs-string">"opera"</span>);
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (hilo.browser.konq) {
      classes.push(<span class="hljs-string">"konqueror"</span>);
    }

    classes.push((<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-params">()</span> </span>{
      <span class="hljs-keyword">switch</span> (hilo.platform.name) {
        <span class="hljs-keyword">case</span> <span class="hljs-string">"Windows"</span>:
          <span class="hljs-keyword">return</span> <span class="hljs-string">"windows"</span>;
        <span class="hljs-keyword">case</span> <span class="hljs-string">"Mac"</span>:
          <span class="hljs-keyword">return</span> <span class="hljs-string">"mac"</span>;
        <span class="hljs-keyword">case</span> <span class="hljs-string">"Linux"</span>:
          <span class="hljs-keyword">return</span> <span class="hljs-string">"linux"</span>;
      }
    })());

    <span class="hljs-keyword">if</span> (hilo.engine.webkit) {
      classes.push(<span class="hljs-string">"webkit"</span>);
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (hilo.engine.ie) {
      classes.push(<span class="hljs-string">"trident"</span>);
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (hilo.engine.opera) {
      classes.push(<span class="hljs-string">"presto"</span>);
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (hilo.engine.gecko) {
      classes.push(<span class="hljs-string">"gecko"</span>);
    }

    classes.push(hilo.browser.name.toLowerCase() + <span class="hljs-built_in">parseInt</span>(hilo.browser.version, <span class="hljs-number">10</span>));

    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getBrowserVersion</span> <span class="hljs-params">()</span> </span>{
      <span class="hljs-keyword">return</span> <span class="hljs-built_in">String</span>(hilo.browser.version).replace(<span class="hljs-string">"."</span>, <span class="hljs-string">"-"</span>);
    }

    <span class="hljs-keyword">if</span> (getBrowserVersion() !== <span class="hljs-built_in">parseInt</span>(hilo.browser.version, <span class="hljs-number">10</span>)) {
      classes.push(hilo.browser.name.toLowerCase() + getBrowserVersion());
    }

    <span class="hljs-keyword">for</span> (_i <span class="hljs-keyword">in</span> hilo.feature) {
      <span class="hljs-keyword">if</span> (hilo.feature.hasOwnProperty(_i)) {
        <span class="hljs-keyword">if</span> (hilo.feature[_i] === <span class="hljs-literal">true</span>) {
          classes.push(_i.toLowerCase());
        } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (hilo.feature[_i] === <span class="hljs-literal">false</span>) {
          classes.push(<span class="hljs-string">"no-"</span> + _i.toLowerCase());
        }
      }
    }

    body.addClass(classes);

    <span class="hljs-keyword">return</span> classes;
  };</pre></div></div>
            
        </li>
        
    </ul>
  </div>
</body>
</html>