Skip to content

Commit 2e50f3b

Browse files
committed
more settings
1 parent 8b2c7f6 commit 2e50f3b

4 files changed

Lines changed: 77 additions & 10 deletions

File tree

index.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,25 @@ <h6>
141141
<select id="font-select" onchange="settings.fontChange()">
142142
</select>
143143
</div>
144+
145+
<div class="select-box">
146+
<p>Indent Size</p>
147+
<span><i class="fa fa-caret-down"></i></span>
148+
<select id="indent-size-select" onchange="settings.indentUnitChange()">
149+
<option value="1">1 char</option>
150+
<option value="2">2 chars</option>
151+
<option value="4">4 chars</option>
152+
<option value="8">8 chars</option>
153+
</select>
154+
</div>
155+
156+
<div class="select-box select-box-small">
157+
<p>Indent With Tabs</p>
158+
<label class="check-switch" id="side-indent-tabs-label">
159+
<input type="checkbox" id="side-indent-tabs" checked>
160+
<span onclick="settings.indentWithTabsChange()"></span>
161+
</label>
162+
</div>
144163

145164
<div class="select-box select-box-small">
146165
<p>Line Numbers</p>

js/broadcast.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ broadcast.init = function(){
1818
};
1919

2020
broadcast.show = function(){
21-
$("#broadcast").css("opacity",0).css("display","block");
22-
window.setTimeout(function(){
23-
$("#broadcast").velocity("transition.bounceUpIn");
24-
}, 500);
21+
if($("#broadcast").css("display") === "none"){
22+
$("#broadcast").css("opacity",0).css("display","block");
23+
window.setTimeout(function(){
24+
$("#broadcast").velocity("transition.bounceUpIn");
25+
}, 500);
26+
}
27+
else{
28+
$("#broadcast").velocity("callout.bounce");
29+
}
2530
};
2631

2732
broadcast.close = function(){
@@ -32,6 +37,14 @@ broadcast.close = function(){
3237
});
3338
};
3439

40+
broadcast.minimapWarn = function(){
41+
42+
}
43+
44+
broadcast.reset = function(){
45+
$("#broadcast > div").css("display","none");
46+
}
47+
3548
broadcast.ad_ok = function(){
3649
connection.send(JSON.stringify({type:"survey",vote:"yes"}));
3750
}

js/editor.js

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ for(var j = 0; j < themes.length; j++){
244244

245245
//populates the font select
246246
for(var k = 2; k <= 30; k++){
247-
$("#font-select").html($("#font-select").html() + "<option value='" + k + "'>" + k + "</option>");
247+
$("#font-select").html($("#font-select").html() + "<option value='" + k + "'>" + k + "px</option>");
248248
}
249249

250250
//sets default settings
@@ -317,6 +317,30 @@ settings.font = function(size){
317317
$(".CodeMirror").css("fontSize", size +"px");
318318
}
319319

320+
settings.indentUnitChange = function(){
321+
settings.indentUnit(parseInt($("#indent-size-select").val()));
322+
settings.change();
323+
}
324+
325+
settings.indentUnit = function(size){
326+
for(var i = 0; i < editors.length; i++){
327+
editors[i].editor.setOption("indentUnit",size);
328+
}
329+
this.state.indentUnit = size;
330+
}
331+
332+
settings.indentWithTabsChange = function(){
333+
settings.indentWithTabs();
334+
settings.change();
335+
}
336+
337+
settings.indentWithTabs = function(){
338+
this.state.indentWithTabs = !this.state.indentWithTabs;
339+
for(var i = 0; i < editors.length; i++){
340+
editors[i].editor.setOption("indentWithTabs", this.state.indentWithTabs);
341+
}
342+
}
343+
320344
settings.init = function(){
321345
connect.settings.getSettings(function(prefs){
322346
//theme
@@ -326,12 +350,21 @@ settings.init = function(){
326350
$("#font-select").val(prefs.fontSize);
327351
settings.font(prefs.fontSize);
328352
//
353+
$("#indent-size-select").val(prefs.indentUnit);
354+
settings.indentUnit(prefs.indentUnit);
355+
//
356+
if(prefs.indentWithTabs !== settings.state.indentWithTabs){
357+
$("#side-indent-tabs").prop("checked", !$("#side-indent-tabs").prop("checked"));
358+
}
359+
//
329360
if(prefs.minimap !== settings.state.minimap){
330361
$("#side-minimap").prop("checked", !$("#side-minimap").prop("checked"));
331362
}
363+
//
332364
if(prefs.lineNumbers !== settings.state.lineNumbers){
333365
$("#side-nums").prop("checked", !$("#side-nums").prop("checked"));
334366
}
367+
//
335368
if(prefs.lineWrap !== settings.state.lineWrap){
336369
$("#side-wrap").prop("checked", !$("#side-wrap").prop("checked"));
337370
}
@@ -358,7 +391,9 @@ settings.state = {
358391
lineWrap: true,
359392
minimap: false,
360393
fontSize: 12,
361-
theme: "monokai"
394+
theme: "monokai",
395+
indentUnit: 4,
396+
indentWithTabs: true
362397
};
363398

364399
/**

js/ready.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ $(document).ready(function(){
1313
mode: "text",
1414
theme: settings.state.theme,
1515
lineWrapping: settings.state.lineWrap,
16-
indentUnit: 4,
17-
indentWithTabs: true,
16+
indentUnit: settings.state.indentUnit,
17+
indentWithTabs: settings.state.indentWithTabs,
1818
foldGutter: true,
19-
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
20-
minimap: settings.state.minimap
19+
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
20+
minimap: settings.state.minimap
2121
});
2222
//sets the introduction text
2323
var txtFile = new XMLHttpRequest();

0 commit comments

Comments
 (0)