ui.js 18 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072
  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. var onMouseDown = function ( 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. var onMouseMove = function ( 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. var onMouseUp = function ( 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. var onChange = function ( 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. var onFocus = function ( event ) {
  397. dom.style.backgroundColor = '';
  398. dom.style.borderColor = '#ccc';
  399. dom.style.cursor = '';
  400. };
  401. var onBlur = function ( 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. var onMouseDown = function ( 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. var onMouseMove = function ( 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. var onMouseUp = function ( 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. var onChange = function ( 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. var onFocus = function ( event ) {
  488. dom.style.backgroundColor = '';
  489. dom.style.borderColor = '#ccc';
  490. dom.style.cursor = '';
  491. };
  492. var onBlur = function ( 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. };