<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Source: customselect.js</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">Source: customselect.js</h1>

    



    
    <section>
        <article>
            <pre class="prettyprint source linenums"><code>'use strict';

/**
 * Custom select js module
 * @module Customselect
 * @requires jquery
 */

var $ = require('jquery');

var Customselect = (function () {
	
	/**
	 * This initialize new Customselect for each $('.js-customselect') element
	 * @memberof Customselect
	 * @inner
	 */
	function canStart() {
		$('.js-customselect').each(function () {
			new Customselect(this);
		});
	}
	
	/**
	 * This initialize new Customselect
	 * @exports Customselect
	 * @class
	 * @param {jQuery} el - jQuery select $('.js-customselect')
	 * @example
	 * &lt;select class="js-customselect">
	 *     &lt;option value="0">0&lt;/option>
	 *     &lt;option value="1">1&lt;/option>
	 *     ...
	 *     &lt;option value="x">x&lt;/option>
	 * &lt;/select>
	 */
	function Customselect(el) {
		this.el = $(el);
		this.init();
	}
	
	/**
	 * This create new tag and append it to the DOM, then wrap original select into it
	 * @memberof Customselect
	 */
	Customselect.prototype.init = function () {
		var _parentClass = this.el.attr('data-class') || '';
		var _showArrow = this.el.attr('data-arrow') || 'true';
		var _arrowBlock = (_showArrow === 'true') ? '&lt;i class="fa fa-chevron-down" style="float:right;">&lt;/i>' : '';
		this.el.css({
			display: 'block',
			opacity: 0,
			position: 'absolute',
			width: '100%',
			height: '100%',
			top: 0,
			left: 0
		});
		this.el.wrap('&lt;div class="form__customselect ' + _parentClass + '" style="position:relative;">&lt;/div>');
		this.el.before('&lt;span class="form__customselect__text js-cutomselect--text">&lt;/span>' + _arrowBlock);
		this.el.siblings('.js-cutomselect--text').html(this.el.find('option:selected').text());
		this.el.on('change', function () {
			$(this).siblings('.js-cutomselect--text').html($(this).find('option:selected').text());
		});
	};
	
	canStart();
	
	return Customselect;
	
})();

module.exports = Customselect;</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>
