summaryrefslogtreecommitdiff
path: root/src/static/js/pad_editor.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/static/js/pad_editor.js')
-rw-r--r--src/static/js/pad_editor.js72
1 files changed, 60 insertions, 12 deletions
diff --git a/src/static/js/pad_editor.js b/src/static/js/pad_editor.js
index b73409ff..b1ea09f7 100644
--- a/src/static/js/pad_editor.js
+++ b/src/static/js/pad_editor.js
@@ -28,6 +28,13 @@ var padeditor = (function()
var Ace2Editor = undefined;
var pad = undefined;
var settings = undefined;
+
+ // Array of available fonts
+ var fonts = ['useMonospaceFont', 'useOpenDyslexicFont', 'useComicSansFont', 'useCourierNewFont', 'useGeorgiaFont', 'useImpactFont',
+ 'useLucidaFont', 'useLucidaSansFont', 'usePalatinoFont', 'useTahomaFont', 'useTimesNewRomanFont',
+ 'useTrebuchetFont', 'useVerdanaFont', 'useSymbolFont', 'useWebdingsFont', 'useWingDingsFont', 'useSansSerifFont',
+ 'useSerifFont'];
+
var self = {
ace: null,
// this is accessed directly from other files
@@ -85,10 +92,15 @@ var padeditor = (function()
padutils.setCheckbox($("#options-rtlcheck"), ('rtl' == html10n.getDirection()));
})
- // font face
+ // font family change
$("#viewfontmenu").change(function()
{
- pad.changeViewOption('useMonospaceFont', $("#viewfontmenu").val() == 'monospace');
+ $.each(fonts, function(i, font){
+ var sfont = font.replace("use","");
+ sfont = sfont.replace("Font","");
+ sfont = sfont.toLowerCase();
+ pad.changeViewOption(font, $("#viewfontmenu").val() == sfont);
+ });
});
// Language
@@ -98,12 +110,12 @@ var padeditor = (function()
// this does not interfere with html10n's normal value-setting because html10n just ingores <input>s
// also, a value which has been set by the user will be not overwritten since a user-edited <input>
// does *not* have the editempty-class
- $('input[data-l10n-id]').each(function(key, input)
- {
- input = $(input);
- if(input.hasClass("editempty"))
- input.val(html10n.get(input.attr("data-l10n-id")));
- });
+ $('input[data-l10n-id]').each(function(key, input){
+ input = $(input);
+ if(input.hasClass("editempty")){
+ input.val(html10n.get(input.attr("data-l10n-id")));
+ }
+ });
})
$("#languagemenu").val(html10n.getLanguage());
$("#languagemenu").change(function() {
@@ -136,13 +148,49 @@ var padeditor = (function()
v = getOption('showAuthorColors', true);
self.ace.setProperty("showsauthorcolors", v);
padutils.setCheckbox($("#options-colorscheck"), v);
+
// Override from parameters if true
- if (settings.noColors !== false)
+ if (settings.noColors !== false){
self.ace.setProperty("showsauthorcolors", !settings.noColors);
+ }
+
+ var normalFont = true;
+ // Go through each font and see if the option is set..
+ $.each(fonts, function(i, font){
+ var isEnabled = getOption(font, false);
+ if(isEnabled){
+ font = font.replace("use","");
+ font = font.replace("Font","");
+ font = font.toLowerCase();
+ if(font === "monospace") self.ace.setProperty("textface", "Courier new");
+ if(font === "opendyslexic") self.ace.setProperty("textface", "OpenDyslexic");
+ if(font === "comicsans") self.ace.setProperty("textface", "Comic Sans MS");
+ if(font === "georgia") self.ace.setProperty("textface", "Georgia");
+ if(font === "impact") self.ace.setProperty("textface", "Impact");
+ if(font === "lucida") self.ace.setProperty("textface", "Lucida");
+ if(font === "lucidasans") self.ace.setProperty("textface", "Lucida Sans Unicode");
+ if(font === "palatino") self.ace.setProperty("textface", "Palatino Linotype");
+ if(font === "tahoma") self.ace.setProperty("textface", "Tahoma");
+ if(font === "timesnewroman") self.ace.setProperty("textface", "Times New Roman");
+ if(font === "trebuchet") self.ace.setProperty("textface", "Trebuchet MS");
+ if(font === "verdana") self.ace.setProperty("textface", "Verdana");
+ if(font === "symbol") self.ace.setProperty("textface", "Symbol");
+ if(font === "webdings") self.ace.setProperty("textface", "Webdings");
+ if(font === "wingdings") self.ace.setProperty("textface", "Wingdings");
+ if(font === "sansserif") self.ace.setProperty("textface", "MS Sans Serif");
+ if(font === "serif") self.ace.setProperty("textface", "MS Serif");
+
+ // $("#viewfontmenu").val(font);
+ normalFont = false;
+ }
+ });
+
+ // No font has been previously selected so use the Normal font
+ if(normalFont){
+ self.ace.setProperty("textface", "Arial, sans-serif");
+ // $("#viewfontmenu").val("normal");
+ }
- v = getOption('useMonospaceFont', false);
- self.ace.setProperty("textface", (v ? "monospace" : "Arial, sans-serif"));
- $("#viewfontmenu").val(v ? "monospace" : "normal");
},
dispose: function()
{