Skip to content
This repository was archived by the owner on Jun 15, 2019. It is now read-only.

Commit 57a1660

Browse files
committedJun 22, 2014
Syntax highlighter, allow selection of theme
Permanent: settings Temp: from the stylesheet page
1 parent 24e7aca commit 57a1660

File tree

3 files changed

+100
-4
lines changed

3 files changed

+100
-4
lines changed
 

‎notifier.js

+89-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@
104104
sortmodqueue = TBUtils.getSetting('QueueTools', 'sortmodqueue', false),
105105
sortunmoderated = TBUtils.getSetting('QueueTools', 'sortunmoderated', false),
106106
linkToQueues = TBUtils.getSetting('QueueTools', 'linktoqueues', false);
107+
108+
// Syntax Highlight settings.
109+
var selectedTheme = TBUtils.getSetting('syntaxHighlighter', 'selectedTheme', 'monokai');
107110

108111
// cache settings.
109112
var shortLength = TBUtils.getSetting('cache', 'shortlength', 15),
@@ -542,6 +545,86 @@
542545
$('<a href="javascript:;" class="tb-window-content-comment">Comments</a>').appendTo('.tb-window-tabs');
543546
}
544547

548+
// Settings for the syntax highlighter
549+
var htmlsyntaxHighlighter = '\
550+
<div class="tb-window-content-syntax">\
551+
<p>\
552+
Syntax highlight theme selection:<br>\
553+
<select id="setting_theme_selector">\
554+
<option value="ambiance">ambiance</option>\
555+
<option value="chaos">chaos</option>\
556+
<option value="chrome">chrome</option>\
557+
<option value="cloud9_day">cloud9_day</option>\
558+
<option value="cloud9_night">cloud9_night</option>\
559+
<option value="cloud9_night_low_color">cloud9_night_low_color</option>\
560+
<option value="clouds">clouds</option>\
561+
<option value="clouds_midnight">clouds_midnight</option>\
562+
<option value="cobalt">cobalt</option>\
563+
<option value="crimson_editor">crimson_editor</option>\
564+
<option value="dawn">dawn</option>\
565+
<option value="dreamweaver">dreamweaver</option>\
566+
<option value="eclipse">eclipse</option>\
567+
<option value="github">github</option>\
568+
<option value="idle_fingers">idle_fingers</option>\
569+
<option value="katzenmilch">katzenmilch</option>\
570+
<option value="kuroir">kuroir</option>\
571+
<option value="merbivore">merbivore</option>\
572+
<option value="merbivore_soft">merbivore_soft</option>\
573+
<option value="monokai">monokai</option>\
574+
<option value="mono_industrial">mono_industrial</option>\
575+
<option value="pastel_on_dark">pastel_on_dark</option>\
576+
<option value="solarized_dark">solarized_dark</option>\
577+
<option value="solarized_light">solarized_light</option>\
578+
<option value="terminal">terminal</option>\
579+
<option value="textmate">textmate</option>\
580+
<option value="tomorrow">tomorrow</option>\
581+
<option value="tomorrow_night">tomorrow_night</option>\
582+
<option value="tomorrow_night_blue">tomorrow_night_blue</option>\
583+
<option value="tomorrow_night_bright">tomorrow_night_bright</option>\
584+
<option value="tomorrow_night_eighties">tomorrow_night_eighties</option>\
585+
<option value="twilight">twilight</option>\
586+
<option value="vibrant_ink">vibrant_ink</option>\
587+
<option value="xcode">xcode</option>\
588+
</select> \
589+
<pre id="syntax_setting_css">\
590+
/* This is just some example code*/\n\
591+
body {\n\
592+
font-family: sans-serif, "Helvetica Neue", Arial;\n\
593+
font-weight: normal;\n\
594+
}\n\
595+
\n\
596+
.md h3, .commentarea h3 {\n\
597+
font-size: 1em;\n\
598+
}\n\
599+
\n\
600+
#header {\n\
601+
border-bottom: 1px solid #9A9A9A; \n\
602+
box-shadow: 0px 1px 3px 1px #B3C2D1;\n\
603+
}\n\
604+
</pre>\
605+
</p>\
606+
<div class="tb-help-main-content">Settings Toolbox Comments.</div>\
607+
</div>\
608+
';
609+
610+
$(htmlsyntaxHighlighter).appendTo('.tb-window-content').hide();
611+
612+
if (syntaxHighlighterEnabled) {
613+
// Syntax highlighter selection stuff
614+
615+
var editorSettings = ace.edit("syntax_setting_css");
616+
editorSettings.setTheme("ace/theme/"+selectedTheme);
617+
editorSettings.getSession().setMode("ace/mode/css");
618+
619+
$('#setting_theme_selector').val(selectedTheme);
620+
$('body').on('change', '#setting_theme_selector', function() {
621+
var themeName = $(this).val();
622+
editorSettings.setTheme("ace/theme/"+themeName);
623+
});
624+
625+
$('<a href="javascript:;" class="tb-window-content-syntax">Syntax Highlighter</a>').appendTo('.tb-window-tabs');
626+
}
627+
545628
// Settings for caching
546629
var htmlcache = '\
547630
<div class="tb-window-content-cache">\
@@ -640,7 +723,7 @@
640723
<a class="tb-remove-shortcuts" href="javascript:void(0)"><img src="data:image/png;base64,' + TBui.iconClose + '" /></a></td></tr>\
641724
').appendTo('.tb-window-content-shortcuts-table');
642725
});
643-
726+
644727
// Save the settings
645728
$('body').on('click', '.tb-save', function () {
646729
var messagenotificationssave = $("input[name=messagenotifications]").is(':checked');
@@ -733,6 +816,11 @@
733816
TBUtils.setSetting('Notifier', 'shortcuts2', shortcuts2);
734817
}
735818

819+
// Save syntax highlighting settings
820+
var newThemeSelection = $('#setting_theme_selector').val();
821+
TBUtils.setSetting('syntaxHighlighter', 'selectedTheme', newThemeSelection);
822+
823+
736824
// Save which modules are enabled.
737825
TBUtils.setSetting('ModMailPro', 'enabled', $("#mmpEnabled").prop('checked'));
738826
TBUtils.setSetting('ModButton', 'enabled', $("#mbEnabled").prop('checked'));

‎syntax.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ if (!location.pathname.match(/\/about\/stylesheet\/?/) || !TBUtils.getSetting('s
44

55
$('.sheets .col').prepend('<div id="stylesheet_contents_div"></div>');
66

7-
var editor = ace.edit("stylesheet_contents_div");
8-
var textarea = $('textarea[name="stylesheet_contents"]').hide();
9-
editor.setTheme("ace/theme/monokai");
7+
var editor = ace.edit("stylesheet_contents_div"),
8+
selectedTheme = TBUtils.getSetting('syntaxHighlighter', 'selectedTheme', 'monokai');
9+
textarea = $('textarea[name="stylesheet_contents"]').hide();
10+
editor.setTheme("ace/theme/"+selectedTheme);
1011

1112
editor.getSession().setMode("ace/mode/css");
1213

@@ -53,6 +54,7 @@ $('#stylesheet_contents_div').before('<select id="theme_selector">\
5354
<option value="xcode">xcode</option>\
5455
</select>');
5556

57+
$('#theme_selector').val(selectedTheme);
5658

5759
$('body').on('change', '#theme_selector', function() {
5860

‎toolbox.css

+6
Original file line numberDiff line numberDiff line change
@@ -1392,4 +1392,10 @@ body.mod-page .thing {
13921392

13931393
.mod-toolbox .ace_print-margin {
13941394
display: none;
1395+
}
1396+
1397+
.mod-toolbox #syntax_setting_css {
1398+
display: block;
1399+
width: 98%;
1400+
height: 300px;
13951401
}

0 commit comments

Comments
 (0)
This repository has been archived.