2
0

ui.js 18 KB

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