-
Notifications
You must be signed in to change notification settings - Fork 44
/
main.js
67 lines (49 loc) · 1.97 KB
/
main.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Brackets Themes Copyright (c) 2014 Miguel Castillo.
*
* Licensed under MIT
*/
define(function (require, exports, module) {
"use strict";
var EditorManager = brackets.getModule("editor/EditorManager"),
ExtensionUtils = brackets.getModule("utils/ExtensionUtils"),
AppInit = brackets.getModule("utils/AppInit");
// Load up reset.css to override brackground settings from brackets because
// they make the themes look really bad.
ExtensionUtils.loadStyleSheet(module, "reset.css");
ExtensionUtils.loadStyleSheet(module, "views/settings.css");
function init(SettingsManager, ThemeManager, MenuManager, codeMirrorAddons) {
function initMenu() {
var paths = SettingsManager.getValue("paths");
paths.forEach(function(path) {
ThemeManager.loadDirectory(path.path).done(function() {
var themes = Array.prototype.slice.call(arguments);
if (themes.length) {
MenuManager.loadThemes(themes, path.path);
}
});
});
}
function setDocumentType(evt, doc) {
if (!doc) {
return;
}
var cm = doc._codeMirror;
var mode = cm && cm.getDoc().getMode();
var docType = mode && (mode.helperType || mode.name);
$(cm.display.wrapper).attr("doctype", docType || cm.options.mode);
}
function initAll() {
MenuManager.init();
initMenu();
}
$(SettingsManager).on("imported", initMenu);
codeMirrorAddons.ready(initAll);
$(EditorManager).on("activeEditorChange.themes", setDocumentType);
setDocumentType(null, EditorManager.getActiveEditor());
}
// Init when app is ready
AppInit.htmlReady(function () {
require(["SettingsManager","ThemeManager","MenuManager","codeMirrorAddons"], init);
});
});