(object, property, opts)
| 28 | */ |
| 29 | class OptionController extends Controller { |
| 30 | constructor(object, property, opts) { |
| 31 | super(object, property); |
| 32 | |
| 33 | let options = opts; |
| 34 | |
| 35 | const _this = this; |
| 36 | |
| 37 | /** |
| 38 | * The drop down menu |
| 39 | * @ignore |
| 40 | */ |
| 41 | this.__select = document.createElement('select'); |
| 42 | |
| 43 | if (common.isArray(options)) { |
| 44 | const map = {}; |
| 45 | common.each(options, function(element) { |
| 46 | map[element] = element; |
| 47 | }); |
| 48 | options = map; |
| 49 | } |
| 50 | |
| 51 | common.each(options, function(value, key) { |
| 52 | const opt = document.createElement('option'); |
| 53 | opt.innerHTML = key; |
| 54 | opt.setAttribute('value', value); |
| 55 | _this.__select.appendChild(opt); |
| 56 | }); |
| 57 | |
| 58 | // Acknowledge original value |
| 59 | this.updateDisplay(); |
| 60 | |
| 61 | dom.bind(this.__select, 'change', function() { |
| 62 | const desiredValue = this.options[this.selectedIndex].value; |
| 63 | _this.setValue(desiredValue); |
| 64 | }); |
| 65 | |
| 66 | this.domElement.appendChild(this.__select); |
| 67 | } |
| 68 | |
| 69 | setValue(v) { |
| 70 | const toReturn = super.setValue(v); |
nothing calls this directly
no test coverage detected