forked from MiguelCastillo/Brackets-Themes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generalSettings.js
65 lines (51 loc) · 2.15 KB
/
generalSettings.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
/**
* Brackets Themse Copyright (c) 2014 Miguel Castillo.
*
* Licensed under MIT
*/
define(function (require) {
"use strict";
var settings = require("settings"),
defaults = require("defaults"),
fontSize = settings.getValue("fontSize"),
fontType = settings.getValue("fontType"),
lineHeight = settings.getValue("lineHeight"),
$lineHeight = $("<style type='text/css' id='lineHeight'>").appendTo("head"),
$fontSize = $("<style type='text/css' id='fontSize'>").appendTo("head"),
$fontType = $("<style type='text/css' id='fontType'>").appendTo("head");
if (fontSize === undefined) {
settings.setValue("fontSize", defaults.FONT_SIZE + "px");
}
if (lineHeight === undefined) {
settings.setValue("lineHeight", defaults.LINE_HEIGHT);
}
if (fontType === undefined) {
settings.setValue("fontType", "'SourceCodePro-Medium', MS ゴシック, 'MS Gothic', monospace");
}
function generalSettings() {
generalSettings.update();
}
generalSettings.updateLineHeight = function () {
var value = settings.getValue("lineHeight");
$lineHeight.text(".CodeMirror{" + "line-height: " + value + ";}");
};
generalSettings.updateFontSize = function () {
var value = settings.getValue("fontSize");
$fontSize.text(".CodeMirror{" + "font-size: " + value + " !important; }");
};
generalSettings.updateFontType = function () {
var value = settings.getValue("fontType");
$fontType.text(".CodeMirror{" + "font-family: " + value + " !important; }");
};
generalSettings.update = function () {
// Remove this tag that is intefering with font settings set in this module
$("#codemirror-dynamic-fonts").remove();
generalSettings.updateLineHeight();
generalSettings.updateFontSize();
generalSettings.updateFontType();
};
$(settings).on("change:lineHeight", generalSettings.updateLineHeight);
$(settings).on("change:fontSize", generalSettings.updateFontSize);
$(settings).on("change:fontType", generalSettings.updateFontType);
return generalSettings;
});