(c, thisId = this.id, currentColorName, index)
| 21 | import {createDetailOutputColors} from './createOutputColors'; |
| 22 | |
| 23 | function addKeyColorInput(c, thisId = this.id, currentColorName, index) { |
| 24 | let parent = thisId.replace('_addKeyColor', ''); |
| 25 | let destId = parent.concat('_keyColors'); |
| 26 | let dest = document.getElementById(destId); |
| 27 | let div = document.createElement('div'); |
| 28 | |
| 29 | let randId = randomId(); |
| 30 | div.className = 'keyColor'; |
| 31 | div.id = randId + '-item'; |
| 32 | let sw = document.createElement('input'); |
| 33 | sw.type = 'color'; |
| 34 | sw.value = c; |
| 35 | |
| 36 | const currentColorIndex = _theme.colors.map((e) => e.name).indexOf(currentColorName); |
| 37 | const chartsModeSelect = document.getElementById('chartsMode'); |
| 38 | const currentColor = _theme.colors[currentColorIndex]; |
| 39 | |
| 40 | sw.oninput = (e) => { |
| 41 | // Replace current indexed value from color keys with new value from color input field |
| 42 | let currentKeys = currentColor.colorKeys; |
| 43 | let currentColorName = _theme.colors[currentColorIndex].name; |
| 44 | currentKeys.splice(index, 1, e.target.value); |
| 45 | |
| 46 | _theme.updateColor = {color: currentColorName, colorKeys: currentKeys}; |
| 47 | |
| 48 | throttle(updateRamps(currentColor, parent), 10); |
| 49 | throttle(createDetailOutputColors(currentColorName), 10); |
| 50 | |
| 51 | setTimeout(function () { |
| 52 | updateColorDots(chartsModeSelect.value, 'colorScale', currentKeys, parent); |
| 53 | }, 500); |
| 54 | }; |
| 55 | |
| 56 | const updateModel = () => { |
| 57 | create3dModel('tabModelContent', [currentColor], chartsModeSelect.value); |
| 58 | }; |
| 59 | |
| 60 | sw.addEventListener('input', throttle(updateModel, 50)); |
| 61 | |
| 62 | sw.className = 'keyColor-Item'; |
| 63 | sw.id = randId + '-sw'; |
| 64 | sw.style.backgroundColor = c; |
| 65 | |
| 66 | let button = document.createElement('button'); |
| 67 | button.className = 'spectrum-ActionButton spectrum-ActionButton--sizeM'; |
| 68 | button.innerHTML = ` |
| 69 | <svg class="spectrum-Icon spectrum-Icon--sizeS" focusable="false" aria-hidden="true" aria-label="Delete"> |
| 70 | <use xlink:href="#spectrum-icon-18-Delete" /> |
| 71 | </svg>`; |
| 72 | |
| 73 | button.addEventListener('click', function (e) { |
| 74 | // Remove current indexed value from color keys |
| 75 | let currentColor = _theme.colors[currentColorIndex]; |
| 76 | let currentKeys = currentColor.colorKeys; |
| 77 | currentKeys.splice(index, 1); |
| 78 | _theme.updateColor = {color: currentColorName, colorKeys: currentKeys}; |
| 79 | |
| 80 | updateRamps(currentColor, parent); |
no test coverage detected