Skip to content

Commit b3711af

Browse files
committed
Editor: ui.js clean up.
1 parent a9d50e7 commit b3711af

File tree

1 file changed

+33
-29
lines changed

1 file changed

+33
-29
lines changed

editor/js/libs/ui.js

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,8 +1025,8 @@ UI.TabbedPanel = function ( ) {
10251025

10261026
UI.Element.call( this );
10271027

1028-
var dom = document.createElement('div');
1029-
1028+
var dom = document.createElement( 'div' );
1029+
10301030
this.dom = dom;
10311031

10321032
this.setClass( 'TabbedPanel' );
@@ -1047,7 +1047,7 @@ UI.TabbedPanel = function ( ) {
10471047

10481048
return this;
10491049

1050-
}
1050+
};
10511051

10521052
UI.TabbedPanel.prototype = Object.create( UI.Element.prototype );
10531053
UI.TabbedPanel.prototype.constructor = UI.TabbedPanel;
@@ -1057,9 +1057,10 @@ UI.TabbedPanel.prototype.select = function ( id ) {
10571057
var tab;
10581058
var panel;
10591059
var scope = this;
1060-
1060+
10611061
// Deselect current selection
10621062
if ( this.selected && this.selected.length ) {
1063+
10631064
tab = this.tabs.find( function ( item ) { return item.dom.id === scope.selected } );
10641065
panel = this.panels.find( function ( item ) { return item.dom.id === scope.selected } );
10651066

@@ -1069,7 +1070,7 @@ UI.TabbedPanel.prototype.select = function ( id ) {
10691070

10701071
}
10711072

1072-
if( panel ) {
1073+
if ( panel ) {
10731074

10741075
panel.setDisplay( 'none' );
10751076

@@ -1079,14 +1080,14 @@ UI.TabbedPanel.prototype.select = function ( id ) {
10791080

10801081
tab = this.tabs.find( function ( item ) { return item.dom.id === id } );
10811082
panel = this.panels.find( function ( item ) { return item.dom.id === id } );
1082-
1083+
10831084
if ( tab ) {
10841085

10851086
tab.addClass( 'selected' );
10861087

10871088
}
10881089

1089-
if( panel ) {
1090+
if ( panel ) {
10901091

10911092
panel.setDisplay( '' );
10921093

@@ -1096,7 +1097,7 @@ UI.TabbedPanel.prototype.select = function ( id ) {
10961097

10971098
return this;
10981099

1099-
}
1100+
};
11001101

11011102
UI.TabbedPanel.prototype.addTab = function ( id, label, items ) {
11021103

@@ -1114,7 +1115,7 @@ UI.TabbedPanel.prototype.addTab = function ( id, label, items ) {
11141115

11151116
this.select( id );
11161117

1117-
}
1118+
};
11181119

11191120
UI.TabbedPanel.Tab = function ( text, parent ) {
11201121

@@ -1124,15 +1125,16 @@ UI.TabbedPanel.Tab = function ( text, parent ) {
11241125
this.setClass( 'Tab' );
11251126

11261127
var scope = this;
1128+
11271129
this.dom.addEventListener( 'click', function ( event ) {
11281130

11291131
scope.parent.select( scope.dom.id );
11301132

1131-
} )
1133+
} );
11321134

11331135
return this;
11341136

1135-
}
1137+
};
11361138

11371139
UI.TabbedPanel.Tab.prototype = Object.create( UI.Text.prototype );
11381140
UI.TabbedPanel.Tab.prototype.constructor = UI.TabbedPanel.Tab;
@@ -1154,7 +1156,7 @@ UI.Listbox = function ( ) {
11541156

11551157
return this;
11561158

1157-
}
1159+
};
11581160

11591161
UI.Listbox.prototype = Object.create( UI.Element.prototype );
11601162
UI.Listbox.prototype.constructor = UI.ListboxItem;
@@ -1169,23 +1171,23 @@ UI.Listbox.prototype.setItems = function ( items ) {
11691171

11701172
this.render( );
11711173

1172-
}
1174+
};
11731175

11741176
UI.Listbox.prototype.render = function ( ) {
11751177

1176-
while( this.listitems.length ) {
1178+
while ( this.listitems.length ) {
11771179

1178-
var item = this.listitems[0];
1180+
var item = this.listitems[ 0 ];
11791181

11801182
item.dom.remove();
11811183

1182-
this.listitems.splice(0, 1);
1184+
this.listitems.splice( 0, 1 );
11831185

11841186
}
11851187

11861188
for ( var i = 0; i < this.items.length; i ++ ) {
11871189

1188-
var item = this.items[i];
1190+
var item = this.items[ i ];
11891191

11901192
var listitem = new UI.Listbox.ListboxItem( this );
11911193
listitem.setId( item.id || `Listbox-${i}` );
@@ -1194,36 +1196,36 @@ UI.Listbox.prototype.render = function ( ) {
11941196

11951197
}
11961198

1197-
}
1199+
};
11981200

11991201
// Assuming user passes valid list items
1200-
UI.Listbox.prototype.add = function ( ) {
1202+
UI.Listbox.prototype.add = function () {
12011203

12021204
var items = Array.from( arguments );
12031205

12041206
this.listitems = this.listitems.concat( items );
12051207

12061208
UI.Element.prototype.add.apply( this, items );
12071209

1208-
}
1210+
};
12091211

12101212
UI.Listbox.prototype.selectIndex = function ( index ) {
12111213

12121214
if ( index >= 0 && index < this.items.length ) {
12131215

1214-
this.setValue( this.listitems[ index ].getId( ) );
1216+
this.setValue( this.listitems[ index ].getId() );
12151217

12161218
}
12171219

12181220
this.selectIndex = index;
12191221

1220-
}
1222+
};
12211223

12221224
UI.Listbox.prototype.getValue = function ( index ) {
12231225

12241226
return this.selectedValue;
12251227

1226-
}
1228+
};
12271229

12281230
UI.Listbox.prototype.setValue = function ( value ) {
12291231

@@ -1236,7 +1238,7 @@ UI.Listbox.prototype.setValue = function ( value ) {
12361238
element.addClass( 'active' );
12371239

12381240
} else {
1239-
1241+
12401242
element.removeClass( 'active' );
12411243

12421244
}
@@ -1249,7 +1251,7 @@ UI.Listbox.prototype.setValue = function ( value ) {
12491251
changeEvent.initEvent( 'change', true, true );
12501252
this.dom.dispatchEvent( changeEvent );
12511253

1252-
}
1254+
};
12531255

12541256
// Listbox Item
12551257
UI.Listbox.ListboxItem = function ( parent ) {
@@ -1264,10 +1266,12 @@ UI.Listbox.ListboxItem = function ( parent ) {
12641266

12651267
var scope = this;
12661268

1267-
function onClick ( ) {
1268-
1269-
if( scope.parent ) {
1269+
function onClick() {
1270+
1271+
if ( scope.parent ) {
1272+
12701273
scope.parent.setValue( scope.getId( ) );
1274+
12711275
}
12721276

12731277
}
@@ -1276,7 +1280,7 @@ UI.Listbox.ListboxItem = function ( parent ) {
12761280

12771281
return this;
12781282

1279-
}
1283+
};
12801284

12811285
UI.Listbox.ListboxItem.prototype = Object.create( UI.Element.prototype );
12821286
UI.Listbox.ListboxItem.prototype.constructor = UI.Listbox.ListboxItem;

0 commit comments

Comments
 (0)