UNPKG

mapbox-gl-draw

Version:

A drawing component for Mapbox GL JS

189 lines (188 loc) 6.49 kB
<!doctype html> <html lang="en"> <head> <title>Code coverage report for mapbox-gl-draw/src/lib/create_control_button.js</title> <meta charset="utf-8" /> <link rel="stylesheet" href="../../../prettify.css" /> <link rel="stylesheet" href="../../../base.css" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <style type='text/css'> .coverage-summary .sorter { background-image: url(../../../sort-arrow-sprite.png); } </style> </head> <body> <div class='wrapper'> <div class='pad1'> <h1> <a href="../../../index.html">all files</a> / <a href="index.html">mapbox-gl-draw/src/lib/</a> create_control_button.js </h1> <div class='clearfix'> <div class='fl pad1y space-right2'> <span class="strong">50% </span> <span class="quiet">Statements</span> <span class='fraction'>9/18</span> </div> <div class='fl pad1y space-right2'> <span class="strong">25% </span> <span class="quiet">Branches</span> <span class='fraction'>1/4</span> </div> <div class='fl pad1y space-right2'> <span class="strong">50% </span> <span class="quiet">Functions</span> <span class='fraction'>1/2</span> </div> <div class='fl pad1y space-right2'> <span class="strong">52.94% </span> <span class="quiet">Lines</span> <span class='fraction'>9/17</span> </div> </div> </div> <div class='status-line medium'></div> <pre><table class="coverage"> <tr><td class="line-count quiet">1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42</td><td class="line-coverage quiet"><span class="cline-any cline-yes"></span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">20×</span> <span class="cline-any cline-yes">20×</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">20×</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">20×</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">20×</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">20×</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">const domUtils = require('./dom_utils'); const Constants = require('../constants'); &nbsp; /** * Creates a control button; adds click listeners to it; and returns it. * * @param {Object} options * @param {HTMLElement} options.container - Element to which the button will be appended. * @param {string} options.title - A title attribute value for the button. * @param {string} options.onActivate - A function to call when the button is activated. * @param {string} [options.id] - An id attribute value for the button. * @return {HTMLElement} The control button */ function createControlButton(options) { const attributes = { title: options.title }; <span class="missing-if-branch" title="if path not taken" >I</span>if (options.id) <span class="cstat-no" title="statement not covered" >attributes.id = options.id;</span> &nbsp; attributes.class = `${Constants.CONTROL_BUTTON_CLASS} ${options.className}`; &nbsp; const button = domUtils.create('button', options.container, attributes); &nbsp; button.addEventListener('click', <span class="fstat-no" title="function not covered" >(e) =&gt; {</span> <span class="cstat-no" title="statement not covered" > e.preventDefault();</span> <span class="cstat-no" title="statement not covered" > e.stopPropagation();</span> &nbsp; const el = <span class="cstat-no" title="statement not covered" >e.target;</span> &nbsp; <span class="cstat-no" title="statement not covered" > if (el.classList.contains('active')) {</span> <span class="cstat-no" title="statement not covered" > el.classList.remove('active');</span> } else { <span class="cstat-no" title="statement not covered" > domUtils.removeClass(document.querySelectorAll(`.${Constants.CONTROL_BUTTON_CLASS}`), 'active');</span> <span class="cstat-no" title="statement not covered" > el.classList.add('active');</span> <span class="cstat-no" title="statement not covered" > options.onActivate();</span> } &nbsp; }, true); &nbsp; return button; } &nbsp; module.exports = createControlButton; &nbsp;</pre></td></tr> </table></pre> <div class='push'></div><!-- for sticky footer --> </div><!-- /wrapper --> <div class='footer quiet pad2 space-top1 center small'> Code coverage generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Wed Jun 22 2016 11:34:16 GMT-0400 (EDT) </div> </div> <script src="../../../prettify.js"></script> <script> window.onload = function () { if (typeof prettyPrint === 'function') { prettyPrint(); } }; </script> <script src="../../../sorter.js"></script> </body> </html>