<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Class: Utils</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Class: Utils</h1>

    




<section>

<header>
    
        <h2>Utils</h2>
        
    
</header>

<article>
    <div class="container-overview">
    
        

    

    <h4 class="name" id="Utils"><span class="type-signature"></span>new Utils<span class="signature">()</span><span class="type-signature"></span></h4>

    



<div class="description">
    This contains various utility like loading, image preload, resizeEnd or scrollEnd watcher
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line21">line 21</a>
    </li></ul></dd>
    

    

    

    
</dl>















    <h5>Example</h5>
    
    <pre class="prettyprint"><code>var Utils = require('./path/to/utils.js');
var utils = new Utils();</code></pre>



    
    </div>

    

    

    

     

    

    

    
        <h3 class="subsection-title">Methods</h3>

        
            

    

    <h4 class="name" id="loading"><span class="type-signature"></span>loading<span class="signature">(action)</span><span class="type-signature"></span></h4>

    



<div class="description">
    This add/remove hidden class to $('.js-loading') DOM element
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>action</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last">hide/show to add/remove hidden class to $('.js-loading') DOM element</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line33">line 33</a>
    </li></ul></dd>
    

    

    

    
</dl>















    <h5>Example</h5>
    
    <pre class="prettyprint"><code>utils.loading('show');
utils.loading('hide');</code></pre>



        
            

    

    <h4 class="name" id="preloadImages"><span class="type-signature"></span>preloadImages<span class="signature">(images, allCallback, singleCallback)</span><span class="type-signature"></span></h4>

    



<div class="description">
    Preload array of images
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>images</code></td>
            

            <td class="type">
            
                
<span class="param-type">array</span>


            
            </td>

            

            

            <td class="description last">array of images to preload</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>allCallback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            

            

            <td class="description last">function called when all images has been loaded</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>singleCallback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            

            

            <td class="description last">function called when single image has been loaded</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line63">line 63</a>
    </li></ul></dd>
    

    

    

    
</dl>















    <h5>Example</h5>
    
    <pre class="prettyprint"><code>var imagesArray = ['a.jpg','b.png','c.gif'];
function allCallback() {
 console.log('all images has been loaded');
}
function singleCallback(res) {
 console.log('index of image just loaded ' + res.index);
 console.log('url of image just loaded ' + res.src);
}
utils.preloadImages(imagesArray, allCallback, singleCallback);</code></pre>



        
            

    

    <h4 class="name" id="resizeEnd"><span class="type-signature"></span>resizeEnd<span class="signature">(endCallback, time)</span><span class="type-signature"></span></h4>

    



<div class="description">
    This detects the end of the resize of window
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>endCallback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            

            

            <td class="description last">function called when resize finish</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>time</code></td>
            

            <td class="type">
            
                
<span class="param-type">number</span>


            
            </td>

            

            

            <td class="description last">delay in millisecond</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line101">line 101</a>
    </li></ul></dd>
    

    

    

    
</dl>















    <h5>Example</h5>
    
    <pre class="prettyprint"><code>var time = 500;
function endCallback(res) {
 console.log('window width and height when resize action start ' + res.old.width + ' - ' + res.old.height);
 console.log('window width and height when resize action finish ' + res.new.width + ' - ' + res.new.height);
}
utils.resizeEnd(endCallback, time);</code></pre>



        
            

    

    <h4 class="name" id="scrollEnd"><span class="type-signature"></span>scrollEnd<span class="signature">(endCallback, element, time)</span><span class="type-signature"></span></h4>

    



<div class="description">
    This detects the end of the resize of window by default or user defined element
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>endCallback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            

            

            <td class="description last">function called when resize finish</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>element</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last">jQuery element selector</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>time</code></td>
            

            <td class="type">
            
                
<span class="param-type">number</span>


            
            </td>

            

            

            <td class="description last">delay in millisecond</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line155">line 155</a>
    </li></ul></dd>
    

    

    

    
</dl>















    <h5>Example</h5>
    
    <pre class="prettyprint"><code>var time = 500;
var element = '.my-element';
function endCallback(res) {
 console.log('scroll position when event start ' + res.old);
 console.log('scroll position when event finish ' + res.new);
}
utils.scrollEnd(endCallback, element, time);</code></pre>



        
    

    

    
</article>

</section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Cookies.html">Cookies</a></li><li><a href="module-Customselect.html">Customselect</a></li><li><a href="module-Device.html">Device</a></li><li><a href="module-Utils.html">Utils</a></li></ul><h3>Classes</h3><ul><li><a href="Cookies.html">Cookies</a></li><li><a href="Customselect.html">Customselect</a></li><li><a href="Device.html">Device</a></li><li><a href="Utils.html">Utils</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Thu Mar 30 2017 11:16:24 GMT+0200 (CEST)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>