@@ -94,9 +94,17 @@ require([
94
94
} ) ) ;
95
95
}
96
96
97
- function populateConfiguration ( rules , environments ) {
97
+ function populateConfiguration ( rules , environments , ecmaFeatures ) {
98
+ var checkbox ;
99
+
100
+ for ( var feature in ecmaFeatures ) {
101
+ checkbox = $ ( '<div class="checkbox-inline"><label><input class="feature" type="checkbox" />' + feature + '</label></div>' ) ;
102
+ $ ( 'input' , checkbox ) . attr ( 'id' , feature ) . prop ( 'checked' , ecmaFeatures [ feature ] ) ;
103
+ $ ( '.ecmaFeatures .list' ) . append ( checkbox ) ;
104
+ }
105
+
98
106
for ( var env in environments ) {
99
- var checkbox = $ ( '<div class="checkbox-inline"><label><input type="checkbox" />' + env + '</label></div>' ) ;
107
+ checkbox = $ ( '<div class="checkbox-inline"><label><input type="checkbox" />' + env + '</label></div>' ) ;
100
108
$ ( 'input' , checkbox ) . attr ( 'id' , env ) . prop ( 'checked' , environments [ env ] ) ;
101
109
$ ( '.environments .list' ) . append ( checkbox ) ;
102
110
}
@@ -108,7 +116,7 @@ require([
108
116
parent = $ ( '<div class="col-md-4"></div>' ) ;
109
117
$ ( '.rules' ) . append ( parent ) ;
110
118
}
111
- var checkbox = $ ( '<div class="checkbox"><label><input type="checkbox" />' + rule + '</label></div>' ) ;
119
+ checkbox = $ ( '<div class="checkbox"><label><input type="checkbox" />' + rule + '</label></div>' ) ;
112
120
checkbox . popover ( {
113
121
title : rule ,
114
122
content : function ( ) {
@@ -147,8 +155,14 @@ require([
147
155
i = 0 ;
148
156
}
149
157
}
158
+
150
159
$ ( '#configuration .btn' ) . click ( function ( ) {
151
- var environments = { } , rules = { } ;
160
+ var environments = { } , rules = { } , ecmaFeatures = { } ;
161
+ $ ( '.ecmaFeatures input' ) . each ( function ( ) {
162
+ var name = $ ( this ) . attr ( 'id' ) ;
163
+ var value = $ ( this ) . is ( ':checked' ) ;
164
+ ecmaFeatures [ name ] = value ;
165
+ } ) ;
152
166
$ ( '.environments input' ) . each ( function ( ) {
153
167
var name = $ ( this ) . attr ( 'id' ) ;
154
168
var value = $ ( this ) . is ( ':checked' ) ;
@@ -162,7 +176,9 @@ require([
162
176
163
177
OPTIONS . rules = rules ;
164
178
OPTIONS . env = environments ;
179
+ OPTIONS . ecmaFeatures = ecmaFeatures ;
165
180
localStorage . rules = JSON . stringify ( rules ) ;
181
+ localStorage . ecmaFeatures = JSON . stringify ( ecmaFeatures ) ;
166
182
localStorage . env = JSON . stringify ( environments ) ;
167
183
verify ( ) ;
168
184
$ ( "#configuration" ) . collapse ( 'hide' ) ;
@@ -176,7 +192,16 @@ require([
176
192
if ( localStorage . env ) {
177
193
OPTIONS . env = JSON . parse ( localStorage . env ) ;
178
194
}
179
- populateConfiguration ( OPTIONS . rules , OPTIONS . env ) ;
195
+ if ( localStorage . ecmaFeatures ) {
196
+ OPTIONS . ecmaFeatures = JSON . parse ( localStorage . ecmaFeatures ) ;
197
+ }
198
+
199
+ // make sure es6 env & modules features are available
200
+ OPTIONS . env . es6 = OPTIONS . env . es6 || false ;
201
+ OPTIONS . ecmaFeatures = OPTIONS . ecmaFeatures || { } ;
202
+ OPTIONS . ecmaFeatures . modules = OPTIONS . ecmaFeatures . module || false ;
203
+
204
+ populateConfiguration ( OPTIONS . rules , OPTIONS . env , OPTIONS . ecmaFeatures ) ;
180
205
181
206
var editor = edit ( document . getElementById ( 'editor' ) ) ;
182
207
0 commit comments