Akron | ad89483 | 2016-06-08 18:24:48 +0200 | [diff] [blame^] | 1 | define( |
| 2 | ['menu', 'menu/item', 'menu/prefix', 'menu/lengthField'], |
| 3 | function (menuClass, menuItemClass, prefixClass, lengthFieldClass) { |
| 4 | |
| 5 | return { |
| 6 | create : function (element) { |
| 7 | var obj = Object.create(menuClass); |
| 8 | |
| 9 | obj._shadow = element; |
| 10 | |
| 11 | var list = []; |
| 12 | var options = element.getElementsByTagName('option'); |
| 13 | |
| 14 | for (var i = 0; i < options.length; i++) { |
| 15 | |
| 16 | var item = options.item(i); |
| 17 | var opt = [ |
| 18 | item.textContent, |
| 19 | item.getAttribute('value') |
| 20 | ]; |
| 21 | |
| 22 | if (item.hasAttribute('desc')) |
| 23 | opt.push(item.getAttribute('desc')); |
| 24 | |
| 25 | list.push(opt); |
| 26 | }; |
| 27 | |
| 28 | |
| 29 | obj = obj.upgradeTo(this) |
| 30 | ._init(menuItemClass, prefixClass, lengthFieldClass, list); |
| 31 | |
| 32 | obj._firstActive = true; |
| 33 | |
| 34 | element.style.display = 'none'; |
| 35 | |
| 36 | if (element.parentNode) |
| 37 | element.parentNode.appendChild(obj.element()); |
| 38 | |
| 39 | return obj; |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | ); |