ui.js 18 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075
  1. var UI = {};
  2. UI.Element = function () {};
  3. UI.Element.prototype = {
  4. setId: function ( id ) {
  5. this.dom.id = id;
  6. return this;
  7. },
  8. setClass: function ( name ) {
  9. this.dom.className = name;
  10. return this;
  11. },
  12. setStyle: function ( style, array ) {
  13. for ( var i = 0; i < array.length; i ++ ) {
  14. this.dom.style[ style ] = array[ i ];
  15. }
  16. },
  17. setDisabled: function ( value ) {
  18. this.dom.disabled = value;
  19. return this;
  20. },
  21. setTextContent: function ( value ) {
  22. this.dom.textContent = value;
  23. return this;
  24. }
  25. }
  26. // properties
  27. var properties = [ 'position', 'left', 'top', 'right', 'bottom', 'width', 'height', 'border', 'borderLeft',
  28. 'borderTop', 'borderRight', 'borderBottom', 'borderColor', 'display', 'overflow', 'margin', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'padding', 'paddingLeft', 'paddingTop', 'paddingRight', 'paddingBottom', 'color',
  29. 'backgroundColor', 'opacity', 'fontSize', 'fontWeight', 'textTransform', 'cursor' ];
  30. properties.forEach( function ( property ) {
  31. var method = 'set' + property.substr( 0, 1 ).toUpperCase() + property.substr( 1, property.length );
  32. UI.Element.prototype[ method ] = function () {
  33. this.setStyle( property, arguments );
  34. return this;
  35. };
  36. } );
  37. // events
  38. var events = [ 'KeyUp', 'KeyDown', 'MouseOver', 'MouseOut', 'Click', 'Change' ];
  39. events.forEach( function ( event ) {
  40. var method = 'on' + event;
  41. UI.Element.prototype[ method ] = function ( callback ) {
  42. this.dom.addEventListener( event.toLowerCase(), callback.bind( this ), false );
  43. return this;
  44. };
  45. } );
  46. // Panel
  47. UI.Panel = function () {
  48. UI.Element.call( this );
  49. var dom = document.createElement( 'div' );
  50. dom.className = 'Panel';
  51. this.dom = dom;
  52. return this;
  53. };
  54. UI.Panel.prototype = Object.create( UI.Element.prototype );
  55. UI.Panel.prototype.add = function () {
  56. for ( var i = 0; i < arguments.length; i ++ ) {
  57. this.dom.appendChild( arguments[ i ].dom );
  58. }
  59. return this;
  60. };
  61. UI.Panel.prototype.remove = function () {
  62. for ( var i = 0; i < arguments.length; i ++ ) {
  63. this.dom.removeChild( arguments[ i ].dom );
  64. }
  65. return this;
  66. };
  67. UI.Panel.prototype.clear = function () {
  68. while ( this.dom.children.length ) {
  69. this.dom.removeChild( this.dom.lastChild );
  70. }
  71. };
  72. // Collapsible Panel
  73. UI.CollapsiblePanel = function () {
  74. UI.Panel.call( this );
  75. this.dom.className = 'Panel CollapsiblePanel';
  76. this.button = document.createElement( 'div' );
  77. this.button.className = 'CollapsiblePanelButton';
  78. this.dom.appendChild( this.button );
  79. var scope = this;
  80. this.button.addEventListener( 'click', function ( event ) {
  81. scope.toggle();
  82. }, false );
  83. this.content = document.createElement( 'div' );
  84. this.content.className = 'CollapsibleContent';
  85. this.dom.appendChild( this.content );
  86. this.isCollapsed = false;
  87. return this;
  88. };
  89. UI.CollapsiblePanel.prototype = Object.create( UI.Panel.prototype );
  90. UI.CollapsiblePanel.prototype.addStatic = function () {
  91. for ( var i = 0; i < arguments.length; i ++ ) {
  92. this.dom.insertBefore( arguments[ i ].dom, this.content );
  93. }
  94. return this;
  95. };
  96. UI.CollapsiblePanel.prototype.removeStatic = UI.Panel.prototype.remove;
  97. UI.CollapsiblePanel.prototype.clearStatic = function () {
  98. this.dom.childNodes.forEach( function ( child ) {
  99. if ( child !== this.content ) {
  100. this.dom.removeChild( child );
  101. }
  102. });
  103. };
  104. UI.CollapsiblePanel.prototype.add = function () {
  105. for ( var i = 0; i < arguments.length; i ++ ) {
  106. this.content.appendChild( arguments[ i ].dom );
  107. }
  108. return this;
  109. };
  110. UI.CollapsiblePanel.prototype.remove = function () {
  111. for ( var i = 0; i < arguments.length; i ++ ) {
  112. this.content.removeChild( arguments[ i ].dom );
  113. }
  114. return this;
  115. };
  116. UI.CollapsiblePanel.prototype.clear = function () {
  117. while ( this.content.children.length ) {
  118. this.content.removeChild( this.content.lastChild );
  119. }
  120. };
  121. UI.CollapsiblePanel.prototype.toggle = function() {
  122. this.setCollapsed( !this.isCollapsed );
  123. };
  124. UI.CollapsiblePanel.prototype.collapse = function() {
  125. this.setCollapsed( true );
  126. };
  127. UI.CollapsiblePanel.prototype.expand = function() {
  128. this.setCollapsed( false );
  129. };
  130. UI.CollapsiblePanel.prototype.setCollapsed = function( setCollapsed ) {
  131. if ( setCollapsed ) {
  132. this.dom.classList.add('collapsed');
  133. } else {
  134. this.dom.classList.remove('collapsed');
  135. }
  136. this.isCollapsed = setCollapsed;
  137. };
  138. // Text
  139. UI.Text = function ( text ) {
  140. UI.Element.call( this );
  141. var dom = document.createElement( 'span' );
  142. dom.className = 'Text';
  143. dom.style.cursor = 'default';
  144. dom.style.display = 'inline-block';
  145. dom.style.verticalAlign = 'middle';
  146. this.dom = dom;
  147. this.setValue( text );
  148. return this;
  149. };
  150. UI.Text.prototype = Object.create( UI.Element.prototype );
  151. UI.Text.prototype.setValue = function ( value ) {
  152. if ( value !== undefined ) {
  153. this.dom.textContent = value;
  154. }
  155. return this;
  156. };
  157. // Input
  158. UI.Input = function () {
  159. UI.Element.call( this );
  160. var scope = this;
  161. var dom = document.createElement( 'input' );
  162. dom.className = 'Input';
  163. dom.style.padding = '2px';
  164. dom.style.border = '1px solid #ccc';
  165. dom.addEventListener( 'keydown', function ( event ) {
  166. event.stopPropagation();
  167. }, false );
  168. this.dom = dom;
  169. return this;
  170. };
  171. UI.Input.prototype = Object.create( UI.Element.prototype );
  172. UI.Input.prototype.getValue = function () {
  173. return this.dom.value;
  174. };
  175. UI.Input.prototype.setValue = function ( value ) {
  176. this.dom.value = value;
  177. return this;
  178. };
  179. // TextArea
  180. UI.TextArea = function () {
  181. UI.Element.call( this );
  182. var scope = this;
  183. var dom = document.createElement( 'textarea' );
  184. dom.className = 'TextArea';
  185. dom.style.padding = '2px';
  186. dom.style.border = '1px solid #ccc';
  187. dom.addEventListener( 'keydown', function ( event ) {
  188. event.stopPropagation();
  189. }, false );
  190. this.dom = dom;
  191. return this;
  192. };
  193. UI.TextArea.prototype = Object.create( UI.Element.prototype );
  194. UI.TextArea.prototype.getValue = function () {
  195. return this.dom.value;
  196. };
  197. UI.TextArea.prototype.setValue = function ( value ) {
  198. this.dom.value = value;
  199. return this;
  200. };
  201. // Select
  202. UI.Select = function () {
  203. UI.Element.call( this );
  204. var scope = this;
  205. var dom = document.createElement( 'select' );
  206. dom.className = 'Select';
  207. dom.style.width = '64px';
  208. dom.style.height = '16px';
  209. dom.style.border = '0px';
  210. dom.style.padding = '0px';
  211. this.dom = dom;
  212. return this;
  213. };
  214. UI.Select.prototype = Object.create( UI.Element.prototype );
  215. UI.Select.prototype.setMultiple = function ( boolean ) {
  216. this.dom.multiple = boolean;
  217. return this;
  218. };
  219. UI.Select.prototype.setOptions = function ( options ) {
  220. var selected = this.dom.value;
  221. while ( this.dom.children.length > 0 ) {
  222. this.dom.removeChild( this.dom.firstChild );
  223. }
  224. for ( var key in options ) {
  225. var option = document.createElement( 'option' );
  226. option.value = key;
  227. option.innerHTML = options[ key ];
  228. this.dom.appendChild( option );
  229. }
  230. this.dom.value = selected;
  231. return this;
  232. };
  233. UI.Select.prototype.getValue = function () {
  234. return this.dom.value;
  235. };
  236. UI.Select.prototype.setValue = function ( value ) {
  237. this.dom.value = value;
  238. return this;
  239. };
  240. // FancySelect
  241. UI.FancySelect = function () {
  242. UI.Element.call( this );
  243. var scope = this;
  244. var dom = document.createElement( 'div' );
  245. dom.className = 'FancySelect';
  246. dom.tabIndex = 0; // keyup event is ignored without setting tabIndex
  247. // Broadcast for object selection after arrow navigation
  248. var changeEvent = document.createEvent('HTMLEvents');
  249. changeEvent.initEvent( 'change', true, true );
  250. // Prevent native scroll behavior
  251. dom.addEventListener( 'keydown', function (event) {
  252. switch ( event.keyCode ) {
  253. case 38: // up
  254. case 40: // down
  255. event.preventDefault();
  256. event.stopPropagation();
  257. break;
  258. }
  259. }, false);
  260. // Keybindings to support arrow navigation
  261. dom.addEventListener( 'keyup', function (event) {
  262. switch ( event.keyCode ) {
  263. case 38: // up
  264. case 40: // down
  265. scope.selectedIndex += ( event.keyCode == 38 ) ? -1 : 1;
  266. if ( scope.selectedIndex >= 0 && scope.selectedIndex < scope.options.length ) {
  267. // Highlight selected dom elem and scroll parent if needed
  268. scope.setValue( scope.options[ scope.selectedIndex ].value );
  269. scope.dom.dispatchEvent( changeEvent );
  270. }
  271. break;
  272. }
  273. }, false);
  274. this.dom = dom;
  275. this.options = [];
  276. this.selectedIndex = -1;
  277. this.selectedValue = null;
  278. return this;
  279. };
  280. UI.FancySelect.prototype = Object.create( UI.Element.prototype );
  281. UI.FancySelect.prototype.setOptions = function ( options ) {
  282. var scope = this;
  283. var changeEvent = document.createEvent( 'HTMLEvents' );
  284. changeEvent.initEvent( 'change', true, true );
  285. while ( scope.dom.children.length > 0 ) {
  286. scope.dom.removeChild( scope.dom.firstChild );
  287. }
  288. scope.options = [];
  289. for ( var i = 0; i < options.length; i ++ ) {
  290. var option = options[ i ];
  291. var div = document.createElement( 'div' );
  292. div.className = 'option';
  293. div.innerHTML = option.html;
  294. div.value = option.value;
  295. scope.dom.appendChild( div );
  296. scope.options.push( div );
  297. div.addEventListener( 'click', function ( event ) {
  298. scope.setValue( this.value );
  299. scope.dom.dispatchEvent( changeEvent );
  300. }, false );
  301. }
  302. return scope;
  303. };
  304. UI.FancySelect.prototype.getValue = function () {
  305. return this.selectedValue;
  306. };
  307. UI.FancySelect.prototype.setValue = function ( value ) {
  308. for ( var i = 0; i < this.options.length; i ++ ) {
  309. var element = this.options[ i ];
  310. if ( element.value === value ) {
  311. element.classList.add( 'active' );
  312. // scroll into view
  313. var y = element.offsetTop - this.dom.offsetTop;
  314. var bottomY = y + element.offsetHeight;
  315. var minScroll = bottomY - this.dom.offsetHeight;
  316. if ( this.dom.scrollTop > y ) {
  317. this.dom.scrollTop = y
  318. } else if ( this.dom.scrollTop < minScroll ) {
  319. this.dom.scrollTop = minScroll;
  320. }
  321. this.selectedIndex = i;
  322. } else {
  323. element.classList.remove( 'active' );
  324. }
  325. }
  326. this.selectedValue = value;
  327. return this;
  328. };
  329. // Checkbox
  330. UI.Checkbox = function ( boolean ) {
  331. UI.Element.call( this );
  332. var scope = this;
  333. var dom = document.createElement( 'input' );
  334. dom.className = 'Checkbox';
  335. dom.type = 'checkbox';
  336. this.dom = dom;
  337. this.setValue( boolean );
  338. return this;
  339. };
  340. UI.Checkbox.prototype = Object.create( UI.Element.prototype );
  341. UI.Checkbox.prototype.getValue = function () {
  342. return this.dom.checked;
  343. };
  344. UI.Checkbox.prototype.setValue = function ( value ) {
  345. if ( value !== undefined ) {
  346. this.dom.checked = value;
  347. }
  348. return this;
  349. };
  350. // Color
  351. UI.Color = function () {
  352. UI.Element.call( this );
  353. var scope = this;
  354. var dom = document.createElement( 'input' );
  355. dom.className = 'Color';
  356. dom.style.width = '64px';
  357. dom.style.height = '16px';
  358. dom.style.border = '0px';
  359. dom.style.padding = '0px';
  360. dom.style.backgroundColor = 'transparent';
  361. try {
  362. dom.type = 'color';
  363. dom.value = '#ffffff';
  364. } catch ( exception ) {}
  365. this.dom = dom;
  366. return this;
  367. };
  368. UI.Color.prototype = Object.create( UI.Element.prototype );
  369. UI.Color.prototype.getValue = function () {
  370. return this.dom.value;
  371. };
  372. UI.Color.prototype.getHexValue = function () {
  373. return parseInt( this.dom.value.substr( 1 ), 16 );
  374. };
  375. UI.Color.prototype.setValue = function ( value ) {
  376. this.dom.value = value;
  377. return this;
  378. };
  379. UI.Color.prototype.setHexValue = function ( hex ) {
  380. this.dom.value = "#" + ( '000000' + hex.toString( 16 ) ).slice( -6 );
  381. return this;
  382. };
  383. // Number
  384. UI.Number = function ( number ) {
  385. UI.Element.call( this );
  386. var scope = this;
  387. var dom = document.createElement( 'input' );
  388. dom.className = 'Number';
  389. dom.value = '0.00';
  390. dom.addEventListener( 'keydown', function ( event ) {
  391. event.stopPropagation();
  392. if ( event.keyCode === 13 ) dom.blur();
  393. }, false );
  394. this.min = - Infinity;
  395. this.max = Infinity;
  396. this.precision = 2;
  397. this.step = 1;
  398. this.dom = dom;
  399. this.setValue( number );
  400. var changeEvent = document.createEvent( 'HTMLEvents' );
  401. changeEvent.initEvent( 'change', true, true );
  402. var distance = 0;
  403. var onMouseDownValue = 0;
  404. var pointer = new THREE.Vector2();
  405. var prevPointer = new THREE.Vector2();
  406. var onMouseDown = function ( event ) {
  407. event.preventDefault();
  408. distance = 0;
  409. onMouseDownValue = parseFloat( dom.value );
  410. prevPointer.set( event.clientX, event.clientY );
  411. document.addEventListener( 'mousemove', onMouseMove, false );
  412. document.addEventListener( 'mouseup', onMouseUp, false );
  413. };
  414. var onMouseMove = function ( event ) {
  415. var currentValue = dom.value;
  416. pointer.set( event.clientX, event.clientY );
  417. distance += ( pointer.x - prevPointer.x ) - ( pointer.y - prevPointer.y );
  418. var number = onMouseDownValue + ( distance / ( event.shiftKey ? 5 : 50 ) ) * scope.step;
  419. dom.value = Math.min( scope.max, Math.max( scope.min, number ) ).toFixed( scope.precision );
  420. if ( currentValue !== dom.value ) dom.dispatchEvent( changeEvent );
  421. prevPointer.set( event.clientX, event.clientY );
  422. };
  423. var onMouseUp = function ( event ) {
  424. document.removeEventListener( 'mousemove', onMouseMove, false );
  425. document.removeEventListener( 'mouseup', onMouseUp, false );
  426. if ( Math.abs( distance ) < 2 ) {
  427. dom.focus();
  428. dom.select();
  429. }
  430. };
  431. var onChange = function ( event ) {
  432. var number = parseFloat( dom.value );
  433. dom.value = isNaN( number ) === false ? number : 0;
  434. };
  435. var onFocus = function ( event ) {
  436. dom.style.backgroundColor = '';
  437. dom.style.borderColor = '#ccc';
  438. dom.style.cursor = '';
  439. };
  440. var onBlur = function ( event ) {
  441. dom.style.backgroundColor = 'transparent';
  442. dom.style.borderColor = 'transparent';
  443. dom.style.cursor = 'col-resize';
  444. };
  445. dom.addEventListener( 'mousedown', onMouseDown, false );
  446. dom.addEventListener( 'change', onChange, false );
  447. dom.addEventListener( 'focus', onFocus, false );
  448. dom.addEventListener( 'blur', onBlur, false );
  449. return this;
  450. };
  451. UI.Number.prototype = Object.create( UI.Element.prototype );
  452. UI.Number.prototype.getValue = function () {
  453. return parseFloat( this.dom.value );
  454. };
  455. UI.Number.prototype.setValue = function ( value ) {
  456. if ( value !== undefined ) {
  457. this.dom.value = value.toFixed( this.precision );
  458. }
  459. return this;
  460. };
  461. UI.Number.prototype.setRange = function ( min, max ) {
  462. this.min = min;
  463. this.max = max;
  464. return this;
  465. };
  466. UI.Number.prototype.setPrecision = function ( precision ) {
  467. this.precision = precision;
  468. return this;
  469. };
  470. // Integer
  471. UI.Integer = function ( number ) {
  472. UI.Element.call( this );
  473. var scope = this;
  474. var dom = document.createElement( 'input' );
  475. dom.className = 'Number';
  476. dom.value = '0.00';
  477. dom.addEventListener( 'keydown', function ( event ) {
  478. event.stopPropagation();
  479. }, false );
  480. this.min = - Infinity;
  481. this.max = Infinity;
  482. this.step = 1;
  483. this.dom = dom;
  484. this.setValue( number );
  485. var changeEvent = document.createEvent( 'HTMLEvents' );
  486. changeEvent.initEvent( 'change', true, true );
  487. var distance = 0;
  488. var onMouseDownValue = 0;
  489. var pointer = new THREE.Vector2();
  490. var prevPointer = new THREE.Vector2();
  491. var onMouseDown = function ( event ) {
  492. event.preventDefault();
  493. distance = 0;
  494. onMouseDownValue = parseFloat( dom.value );
  495. prevPointer.set( event.clientX, event.clientY );
  496. document.addEventListener( 'mousemove', onMouseMove, false );
  497. document.addEventListener( 'mouseup', onMouseUp, false );
  498. };
  499. var onMouseMove = function ( event ) {
  500. var currentValue = dom.value;
  501. pointer.set( event.clientX, event.clientY );
  502. distance += ( pointer.x - prevPointer.x ) - ( pointer.y - prevPointer.y );
  503. var number = onMouseDownValue + ( distance / ( event.shiftKey ? 5 : 50 ) ) * scope.step;
  504. dom.value = Math.min( scope.max, Math.max( scope.min, number ) ) | 0;
  505. if ( currentValue !== dom.value ) dom.dispatchEvent( changeEvent );
  506. prevPointer.set( event.clientX, event.clientY );
  507. };
  508. var onMouseUp = function ( event ) {
  509. document.removeEventListener( 'mousemove', onMouseMove, false );
  510. document.removeEventListener( 'mouseup', onMouseUp, false );
  511. if ( Math.abs( distance ) < 2 ) {
  512. dom.focus();
  513. dom.select();
  514. }
  515. };
  516. var onChange = function ( event ) {
  517. var number = parseInt( dom.value );
  518. if ( isNaN( number ) === false ) {
  519. dom.value = number;
  520. }
  521. };
  522. var onFocus = function ( event ) {
  523. dom.style.backgroundColor = '';
  524. dom.style.borderColor = '#ccc';
  525. dom.style.cursor = '';
  526. };
  527. var onBlur = function ( event ) {
  528. dom.style.backgroundColor = 'transparent';
  529. dom.style.borderColor = 'transparent';
  530. dom.style.cursor = 'col-resize';
  531. };
  532. dom.addEventListener( 'mousedown', onMouseDown, false );
  533. dom.addEventListener( 'change', onChange, false );
  534. dom.addEventListener( 'focus', onFocus, false );
  535. dom.addEventListener( 'blur', onBlur, false );
  536. return this;
  537. };
  538. UI.Integer.prototype = Object.create( UI.Element.prototype );
  539. UI.Integer.prototype.getValue = function () {
  540. return parseInt( this.dom.value );
  541. };
  542. UI.Integer.prototype.setValue = function ( value ) {
  543. if ( value !== undefined ) {
  544. this.dom.value = value | 0;
  545. }
  546. return this;
  547. };
  548. UI.Integer.prototype.setRange = function ( min, max ) {
  549. this.min = min;
  550. this.max = max;
  551. return this;
  552. };
  553. // Break
  554. UI.Break = function () {
  555. UI.Element.call( this );
  556. var dom = document.createElement( 'br' );
  557. dom.className = 'Break';
  558. this.dom = dom;
  559. return this;
  560. };
  561. UI.Break.prototype = Object.create( UI.Element.prototype );
  562. // HorizontalRule
  563. UI.HorizontalRule = function () {
  564. UI.Element.call( this );
  565. var dom = document.createElement( 'hr' );
  566. dom.className = 'HorizontalRule';
  567. this.dom = dom;
  568. return this;
  569. };
  570. UI.HorizontalRule.prototype = Object.create( UI.Element.prototype );
  571. // Button
  572. UI.Button = function ( value ) {
  573. UI.Element.call( this );
  574. var scope = this;
  575. var dom = document.createElement( 'button' );
  576. dom.className = 'Button';
  577. this.dom = dom;
  578. this.dom.textContent = value;
  579. return this;
  580. };
  581. UI.Button.prototype = Object.create( UI.Element.prototype );
  582. UI.Button.prototype.setLabel = function ( value ) {
  583. this.dom.textContent = value;
  584. return this;
  585. };