ui.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  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. // Invoke object/helper/mesh selection logic
  270. scope.dom.dispatchEvent( changeEvent );
  271. }
  272. break;
  273. }
  274. }, false);
  275. this.dom = dom;
  276. this.options = [];
  277. this.selectedIndex = -1;
  278. this.selectedValue = null;
  279. return this;
  280. };
  281. UI.FancySelect.prototype = Object.create( UI.Element.prototype );
  282. UI.FancySelect.prototype.setOptions = function ( options ) {
  283. var scope = this;
  284. var changeEvent = document.createEvent( 'HTMLEvents' );
  285. changeEvent.initEvent( 'change', true, true );
  286. while ( scope.dom.children.length > 0 ) {
  287. scope.dom.removeChild( scope.dom.firstChild );
  288. }
  289. scope.options = [];
  290. for ( var i = 0; i < options.length; i ++ ) {
  291. var option = options[ i ];
  292. var div = document.createElement( 'div' );
  293. div.className = 'option';
  294. div.innerHTML = option.html;
  295. div.value = option.value;
  296. scope.dom.appendChild( div );
  297. scope.options.push( div );
  298. div.addEventListener( 'click', function ( event ) {
  299. scope.setValue( this.value );
  300. scope.dom.dispatchEvent( changeEvent );
  301. }, false );
  302. }
  303. return scope;
  304. };
  305. UI.FancySelect.prototype.getValue = function () {
  306. return this.selectedValue;
  307. };
  308. UI.FancySelect.prototype.setValue = function ( value ) {
  309. for ( var i = 0; i < this.options.length; i ++ ) {
  310. var element = this.options[ i ];
  311. if ( element.value === value ) {
  312. element.classList.add( 'active' );
  313. // scroll into view
  314. var y = element.offsetTop - this.dom.offsetTop;
  315. var bottomY = y + element.offsetHeight;
  316. var minScroll = bottomY - this.dom.offsetHeight;
  317. if ( this.dom.scrollTop > y ) {
  318. this.dom.scrollTop = y
  319. } else if ( this.dom.scrollTop < minScroll ) {
  320. this.dom.scrollTop = minScroll;
  321. }
  322. this.selectedIndex = i;
  323. } else {
  324. element.classList.remove( 'active' );
  325. }
  326. }
  327. this.selectedValue = value;
  328. return this;
  329. };
  330. // Checkbox
  331. UI.Checkbox = function ( boolean ) {
  332. UI.Element.call( this );
  333. var scope = this;
  334. var dom = document.createElement( 'input' );
  335. dom.className = 'Checkbox';
  336. dom.type = 'checkbox';
  337. this.dom = dom;
  338. this.setValue( boolean );
  339. return this;
  340. };
  341. UI.Checkbox.prototype = Object.create( UI.Element.prototype );
  342. UI.Checkbox.prototype.getValue = function () {
  343. return this.dom.checked;
  344. };
  345. UI.Checkbox.prototype.setValue = function ( value ) {
  346. if ( value !== undefined ) {
  347. this.dom.checked = value;
  348. }
  349. return this;
  350. };
  351. // Color
  352. UI.Color = function () {
  353. UI.Element.call( this );
  354. var scope = this;
  355. var dom = document.createElement( 'input' );
  356. dom.className = 'Color';
  357. dom.style.width = '64px';
  358. dom.style.height = '16px';
  359. dom.style.border = '0px';
  360. dom.style.padding = '0px';
  361. dom.style.backgroundColor = 'transparent';
  362. try {
  363. dom.type = 'color';
  364. dom.value = '#ffffff';
  365. } catch ( exception ) {}
  366. this.dom = dom;
  367. return this;
  368. };
  369. UI.Color.prototype = Object.create( UI.Element.prototype );
  370. UI.Color.prototype.getValue = function () {
  371. return this.dom.value;
  372. };
  373. UI.Color.prototype.getHexValue = function () {
  374. return parseInt( this.dom.value.substr( 1 ), 16 );
  375. };
  376. UI.Color.prototype.setValue = function ( value ) {
  377. this.dom.value = value;
  378. return this;
  379. };
  380. UI.Color.prototype.setHexValue = function ( hex ) {
  381. this.dom.value = "#" + ( '000000' + hex.toString( 16 ) ).slice( -6 );
  382. return this;
  383. };
  384. // Number
  385. UI.Number = function ( number ) {
  386. UI.Element.call( this );
  387. var scope = this;
  388. var dom = document.createElement( 'input' );
  389. dom.className = 'Number';
  390. dom.value = '0.00';
  391. dom.addEventListener( 'keydown', function ( event ) {
  392. event.stopPropagation();
  393. if ( event.keyCode === 13 ) dom.blur();
  394. }, false );
  395. this.min = - Infinity;
  396. this.max = Infinity;
  397. this.precision = 2;
  398. this.step = 1;
  399. this.dom = dom;
  400. this.setValue( number );
  401. var changeEvent = document.createEvent( 'HTMLEvents' );
  402. changeEvent.initEvent( 'change', true, true );
  403. var distance = 0;
  404. var onMouseDownValue = 0;
  405. var pointer = new THREE.Vector2();
  406. var prevPointer = new THREE.Vector2();
  407. var onMouseDown = function ( event ) {
  408. event.preventDefault();
  409. distance = 0;
  410. onMouseDownValue = parseFloat( dom.value );
  411. prevPointer.set( event.clientX, event.clientY );
  412. document.addEventListener( 'mousemove', onMouseMove, false );
  413. document.addEventListener( 'mouseup', onMouseUp, false );
  414. };
  415. var onMouseMove = function ( event ) {
  416. var currentValue = dom.value;
  417. pointer.set( event.clientX, event.clientY );
  418. distance += ( pointer.x - prevPointer.x ) - ( pointer.y - prevPointer.y );
  419. var number = onMouseDownValue + ( distance / ( event.shiftKey ? 5 : 50 ) ) * scope.step;
  420. dom.value = Math.min( scope.max, Math.max( scope.min, number ) ).toFixed( scope.precision );
  421. if ( currentValue !== dom.value ) dom.dispatchEvent( changeEvent );
  422. prevPointer.set( event.clientX, event.clientY );
  423. };
  424. var onMouseUp = function ( event ) {
  425. document.removeEventListener( 'mousemove', onMouseMove, false );
  426. document.removeEventListener( 'mouseup', onMouseUp, false );
  427. if ( Math.abs( distance ) < 2 ) {
  428. dom.focus();
  429. dom.select();
  430. }
  431. };
  432. var onChange = function ( event ) {
  433. var number = parseFloat( dom.value );
  434. dom.value = isNaN( number ) === false ? number : 0;
  435. };
  436. var onFocus = function ( event ) {
  437. dom.style.backgroundColor = '';
  438. dom.style.borderColor = '#ccc';
  439. dom.style.cursor = '';
  440. };
  441. var onBlur = function ( event ) {
  442. dom.style.backgroundColor = 'transparent';
  443. dom.style.borderColor = 'transparent';
  444. dom.style.cursor = 'col-resize';
  445. };
  446. dom.addEventListener( 'mousedown', onMouseDown, false );
  447. dom.addEventListener( 'change', onChange, false );
  448. dom.addEventListener( 'focus', onFocus, false );
  449. dom.addEventListener( 'blur', onBlur, false );
  450. return this;
  451. };
  452. UI.Number.prototype = Object.create( UI.Element.prototype );
  453. UI.Number.prototype.getValue = function () {
  454. return parseFloat( this.dom.value );
  455. };
  456. UI.Number.prototype.setValue = function ( value ) {
  457. if ( value !== undefined ) {
  458. this.dom.value = value.toFixed( this.precision );
  459. }
  460. return this;
  461. };
  462. UI.Number.prototype.setRange = function ( min, max ) {
  463. this.min = min;
  464. this.max = max;
  465. return this;
  466. };
  467. UI.Number.prototype.setPrecision = function ( precision ) {
  468. this.precision = precision;
  469. return this;
  470. };
  471. // Integer
  472. UI.Integer = function ( number ) {
  473. UI.Element.call( this );
  474. var scope = this;
  475. var dom = document.createElement( 'input' );
  476. dom.className = 'Number';
  477. dom.value = '0.00';
  478. dom.addEventListener( 'keydown', function ( event ) {
  479. event.stopPropagation();
  480. }, false );
  481. this.min = - Infinity;
  482. this.max = Infinity;
  483. this.step = 1;
  484. this.dom = dom;
  485. this.setValue( number );
  486. var changeEvent = document.createEvent( 'HTMLEvents' );
  487. changeEvent.initEvent( 'change', true, true );
  488. var distance = 0;
  489. var onMouseDownValue = 0;
  490. var pointer = new THREE.Vector2();
  491. var prevPointer = new THREE.Vector2();
  492. var onMouseDown = function ( event ) {
  493. event.preventDefault();
  494. distance = 0;
  495. onMouseDownValue = parseFloat( dom.value );
  496. prevPointer.set( event.clientX, event.clientY );
  497. document.addEventListener( 'mousemove', onMouseMove, false );
  498. document.addEventListener( 'mouseup', onMouseUp, false );
  499. };
  500. var onMouseMove = function ( event ) {
  501. var currentValue = dom.value;
  502. pointer.set( event.clientX, event.clientY );
  503. distance += ( pointer.x - prevPointer.x ) - ( pointer.y - prevPointer.y );
  504. var number = onMouseDownValue + ( distance / ( event.shiftKey ? 5 : 50 ) ) * scope.step;
  505. dom.value = Math.min( scope.max, Math.max( scope.min, number ) ) | 0;
  506. if ( currentValue !== dom.value ) dom.dispatchEvent( changeEvent );
  507. prevPointer.set( event.clientX, event.clientY );
  508. };
  509. var onMouseUp = function ( event ) {
  510. document.removeEventListener( 'mousemove', onMouseMove, false );
  511. document.removeEventListener( 'mouseup', onMouseUp, false );
  512. if ( Math.abs( distance ) < 2 ) {
  513. dom.focus();
  514. dom.select();
  515. }
  516. };
  517. var onChange = function ( event ) {
  518. var number = parseInt( dom.value );
  519. if ( isNaN( number ) === false ) {
  520. dom.value = number;
  521. }
  522. };
  523. var onFocus = function ( event ) {
  524. dom.style.backgroundColor = '';
  525. dom.style.borderColor = '#ccc';
  526. dom.style.cursor = '';
  527. };
  528. var onBlur = function ( event ) {
  529. dom.style.backgroundColor = 'transparent';
  530. dom.style.borderColor = 'transparent';
  531. dom.style.cursor = 'col-resize';
  532. };
  533. dom.addEventListener( 'mousedown', onMouseDown, false );
  534. dom.addEventListener( 'change', onChange, false );
  535. dom.addEventListener( 'focus', onFocus, false );
  536. dom.addEventListener( 'blur', onBlur, false );
  537. return this;
  538. };
  539. UI.Integer.prototype = Object.create( UI.Element.prototype );
  540. UI.Integer.prototype.getValue = function () {
  541. return parseInt( this.dom.value );
  542. };
  543. UI.Integer.prototype.setValue = function ( value ) {
  544. if ( value !== undefined ) {
  545. this.dom.value = value | 0;
  546. }
  547. return this;
  548. };
  549. UI.Integer.prototype.setRange = function ( min, max ) {
  550. this.min = min;
  551. this.max = max;
  552. return this;
  553. };
  554. // Break
  555. UI.Break = function () {
  556. UI.Element.call( this );
  557. var dom = document.createElement( 'br' );
  558. dom.className = 'Break';
  559. this.dom = dom;
  560. return this;
  561. };
  562. UI.Break.prototype = Object.create( UI.Element.prototype );
  563. // HorizontalRule
  564. UI.HorizontalRule = function () {
  565. UI.Element.call( this );
  566. var dom = document.createElement( 'hr' );
  567. dom.className = 'HorizontalRule';
  568. this.dom = dom;
  569. return this;
  570. };
  571. UI.HorizontalRule.prototype = Object.create( UI.Element.prototype );
  572. // Button
  573. UI.Button = function ( value ) {
  574. UI.Element.call( this );
  575. var scope = this;
  576. var dom = document.createElement( 'button' );
  577. dom.className = 'Button';
  578. this.dom = dom;
  579. this.dom.textContent = value;
  580. return this;
  581. };
  582. UI.Button.prototype = Object.create( UI.Element.prototype );
  583. UI.Button.prototype.setLabel = function ( value ) {
  584. this.dom.textContent = value;
  585. return this;
  586. };