forked from Vhornets/brackets-builder
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpreferences.js
More file actions
53 lines (43 loc) · 1.99 KB
/
preferences.js
File metadata and controls
53 lines (43 loc) · 1.99 KB
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
/*jslint plusplus: true, vars: true, nomen: true */
/*global define, brackets, console, setTimeout, $, document, alert */
define(function (require, exports, module) {
"use strict";
var _runCompile;
var prefs;
var DocumentManager = brackets.getModule("document/DocumentManager");
var ProjectManager = brackets.getModule("project/ProjectManager");
var basefile,
basefiletype;
function run() {
if (prefs.get("autocompile") && prefs.get("basefile") && prefs.get("basefiletype")) {
basefile = prefs.get("basefile");
basefiletype = prefs.get("basefiletype");
var root = ProjectManager.getProjectRoot()._path,
fullFilePath = root + basefile;
//var doc = DocumentManager.getDocumentForPath(fullFilePath);
_runCompile(fullFilePath, root, basefiletype);
} else { _runCompile(); }
console.log("auto compiling");
}
function setupPrefs() {
$(DocumentManager).off("currentDocumentChange documentSaved", run);
if (prefs.get("autocompile") && prefs.get("basefile") && prefs.get("basefiletype")) {
basefile = prefs.get("basefile");
basefiletype = prefs.get("basefiletype");
$(DocumentManager).on("documentSaved", run);
} else if (prefs.get("autocompile")) {
$(DocumentManager).on("currentDocumentChange documentSaved", run);
}
}
module.exports = function (runCompile) {
_runCompile = runCompile;
var PreferencesManager = brackets.getModule("preferences/PreferencesManager");
prefs = PreferencesManager.getExtensionPrefs("IDE");
prefs.definePreference("autocompile", "boolean", false).on("change", function (e, data) {
setupPrefs();
});
//$(DocumentManager).on("currentDocumentChange", handleDocumentChange);
console.log("000" + prefs.get("autocompile"));
setupPrefs();
};
});