forked from MiguelCastillo/Brackets-Themes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththemeApply.js
33 lines (26 loc) · 921 Bytes
/
themeApply.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* Brackets Themse Copyright (c) 2014 Miguel Castillo.
*
* Licensed under MIT
*/
define(function(require) {
"use strict";
var _ = brackets.getModule("thirdparty/lodash");
var ExtensionUtils = brackets.getModule("utils/ExtensionUtils");
/**
* Handles updating codemirror with the current selection of themes.
*/
function themeApply (themeManager, cm) {
var newThemes = themeManager.selected.join(" "),
currentThemes = cm.getOption("theme");
// Check if the editor already has the theme applied...
if (currentThemes === newThemes) {
return;
}
// Setup current and further documents to get the new theme...
CodeMirror.defaults.theme = newThemes;
cm.setOption("theme", newThemes);
$(ExtensionUtils).trigger("Themes.themeChanged", themeManager.getThemes());
}
return themeApply;
});