21
21
*
22
22
*/
23
23
24
- /*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
24
+ /*jslint vars: true, plusplus: true, devel: true, regexp: true, nomen: true, indent: 4, maxerr: 50 */
25
25
/*global $, define, require, less */
26
26
27
27
define ( function ( require , exports , module ) {
@@ -43,7 +43,7 @@ define(function (require, exports, module) {
43
43
styleNode = $ ( ExtensionUtils . addEmbeddedStyleSheet ( "" ) ) ,
44
44
defaultTheme = "thor-light-theme" ,
45
45
commentRegex = / \/ \* ( [ \s \S ] * ?) \* \/ / mg,
46
- scrollbarsRegex = / : : - w e b k i t - s c r o l l b a r (?: [ \s \S ] * ? ) \{ (?: [ \s \S ] * ?) \} / mg ,
46
+ scrollbarsRegex = / ( (?: [ ^ } | , ] * ) : : - w e b k i t - s c r o l l b a r (?: [ ^ { ] * ) [ { ] (?: [ ^ } ] * ?) [ } ] ) / mgi ,
47
47
stylesPath = FileUtils . getNativeBracketsDirectoryPath ( ) + "/styles/" ,
48
48
validExtensions = [ "css" , "less" ] ;
49
49
@@ -87,7 +87,7 @@ define(function (require, exports, module) {
87
87
this . file = file ;
88
88
this . name = options . name || ( options . title || fileName ) . toLocaleLowerCase ( ) . replace ( / [ \W ] / g, '-' ) ;
89
89
this . displayName = options . title || toDisplayName ( fileName ) ;
90
- this . dark = options . theme && options . theme . dark === true ;
90
+ this . dark = options . theme !== undefined && options . theme . dark === true ;
91
91
}
92
92
93
93
@@ -107,7 +107,6 @@ define(function (require, exports, module) {
107
107
// Go through and extract out scrollbar customizations so that we can
108
108
// enable/disable via settings.
109
109
content = content
110
- . replace ( commentRegex , "" )
111
110
. replace ( scrollbarsRegex , function ( match ) {
112
111
scrollbar . push ( match ) ;
113
112
return "" ;
@@ -231,15 +230,16 @@ define(function (require, exports, module) {
231
230
var theme = getCurrentTheme ( ) ;
232
231
233
232
var pending = theme && FileUtils . readAsText ( theme . file )
233
+ . then ( function ( lessContent ) {
234
+ return lessifyTheme ( lessContent . replace ( commentRegex , "" ) , theme ) ;
235
+ } )
234
236
. then ( function ( content ) {
235
237
var result = extractScrollbars ( content ) ;
236
238
theme . scrollbar = result . scrollbar ;
237
239
return result . content ;
238
240
} )
239
- . then ( function ( lessContent ) {
240
- return lessifyTheme ( lessContent , theme ) ;
241
- } )
242
241
. then ( function ( cssContent ) {
242
+ $ ( "body" ) . toggleClass ( "dark" , theme . dark ) ;
243
243
styleNode . text ( cssContent ) ;
244
244
return theme ;
245
245
} ) ;
0 commit comments