Skip to content

Commit bf8de9b

Browse files
committed
Editor: Added UI.Modal. (Failed attempt to to fix Publish...)
1 parent 16dfebe commit bf8de9b

File tree

4 files changed

+41
-62
lines changed

4 files changed

+41
-62
lines changed

editor/index.html

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,8 @@
154154
var sidebar = new Sidebar( editor );
155155
document.body.appendChild( sidebar.dom );
156156

157-
/*
158-
var dialog = new UI.Dialog();
159-
document.body.appendChild( dialog.dom );
160-
*/
157+
var modal = new UI.Modal();
158+
document.body.appendChild( modal.dom );
161159

162160
//
163161

@@ -223,18 +221,11 @@
223221
signals.sceneGraphChanged.add( saveState );
224222
signals.scriptChanged.add( saveState );
225223

226-
/*
227-
var showDialog = function ( content ) {
224+
signals.showModal.add( function ( content ) {
228225

229-
dialog.clear();
226+
modal.show( content );
230227

231-
dialog.add( content );
232-
dialog.showModal();
233-
234-
};
235-
236-
signals.showDialog.add( showDialog );
237-
*/
228+
} );
238229

239230
} );
240231

@@ -280,11 +271,11 @@
280271

281272
}, false );
282273

283-
var onWindowResize = function ( event ) {
274+
function onWindowResize( event ) {
284275

285276
editor.signals.windowResize.dispatch();
286277

287-
};
278+
}
288279

289280
window.addEventListener( 'resize', onWindowResize, false );
290281

editor/js/Editor.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var Editor = function () {
1919

2020
// actions
2121

22-
// showDialog: new SIGNALS.Signal(),
22+
showModal: new SIGNALS.Signal(),
2323

2424
// notifications
2525

@@ -102,14 +102,6 @@ Editor.prototype = {
102102

103103
},
104104

105-
/*
106-
showDialog: function ( value ) {
107-
108-
this.signals.showDialog.dispatch( value );
109-
110-
},
111-
*/
112-
113105
//
114106

115107
setScene: function ( scene ) {

editor/js/Menubar.File.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -275,21 +275,6 @@ Menubar.File = function ( editor ) {
275275
} );
276276
options.add( option );
277277

278-
/*
279-
// Test
280-
281-
var option = new UI.Panel();
282-
option.setClass( 'option' );
283-
option.setTextContent( 'Test' );
284-
option.onClick( function () {
285-
286-
var text = new UI.Text( 'blah' );
287-
editor.showDialog( text );
288-
289-
} );
290-
options.add( option );
291-
*/
292-
293278

294279
//
295280

editor/js/libs/ui.js

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,47 +1014,58 @@ UI.Button.prototype.setLabel = function ( value ) {
10141014
};
10151015

10161016

1017-
// Dialog
1017+
// Modal
10181018

1019-
UI.Dialog = function ( value ) {
1019+
UI.Modal = function ( value ) {
10201020

10211021
var scope = this;
10221022

1023-
var dom = document.createElement( 'dialog' );
1023+
var dom = document.createElement( 'div' );
10241024

1025-
if ( dom.showModal === undefined ) {
1025+
dom.style.position = 'absolute';
1026+
dom.style.width = '100%';
1027+
dom.style.height = '100%';
1028+
dom.style.backgroundColor = 'rgba(0,0,0,0.5)';
1029+
dom.style.display = 'none';
1030+
dom.style.alignItems = 'center';
1031+
dom.style.justifyContent = 'center';
1032+
dom.addEventListener( 'click', function ( event ) {
10261033

1027-
// fallback
1034+
scope.hide();
10281035

1029-
dom = document.createElement( 'div' );
1030-
dom.style.display = 'none';
1036+
} );
10311037

1032-
dom.showModal = function () {
1038+
this.dom = dom;
10331039

1034-
dom.style.position = 'absolute';
1035-
dom.style.left = '100px';
1036-
dom.style.top = '100px';
1037-
dom.style.zIndex = 1;
1038-
dom.style.display = '';
1040+
this.container = new UI.Panel();
1041+
this.container.dom.style.width = '200px';
1042+
this.container.dom.style.padding = '20px';
1043+
this.container.dom.style.backgroundColor = '#ffffff';
1044+
this.container.dom.style.boxShadow = '0px 5px 10px rgba(0,0,0,0.5)';
10391045

1040-
};
1046+
this.add( this.container );
10411047

1042-
}
1048+
return this;
10431049

1044-
dom.className = 'Dialog';
1050+
};
10451051

1046-
this.dom = dom;
1052+
UI.Modal.prototype = Object.create( UI.Element.prototype );
1053+
UI.Modal.prototype.constructor = UI.Modal;
1054+
1055+
UI.Modal.prototype.show = function ( content ) {
1056+
1057+
this.container.clear();
1058+
this.container.add( content );
1059+
1060+
this.dom.style.display = 'flex';
10471061

10481062
return this;
10491063

10501064
};
10511065

1052-
UI.Dialog.prototype = Object.create( UI.Panel.prototype );
1053-
UI.Dialog.prototype.constructor = UI.Dialog;
1054-
1055-
UI.Dialog.prototype.showModal = function () {
1066+
UI.Modal.prototype.hide = function () {
10561067

1057-
this.dom.showModal();
1068+
this.dom.style.display = 'none';
10581069

10591070
return this;
10601071

0 commit comments

Comments
 (0)