mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -04:00
font picker: improve the font picker (closes #3451)
Preparatory work for introducing colibris skin
This commit is contained in:
parent
c5a07e6827
commit
63ec2d8cc2
3 changed files with 45 additions and 84 deletions
|
@ -314,7 +314,7 @@ function handshake()
|
||||||
// If the Monospacefont value is set to true then change it to monospace.
|
// If the Monospacefont value is set to true then change it to monospace.
|
||||||
if (settings.useMonospaceFontGlobal == true)
|
if (settings.useMonospaceFontGlobal == true)
|
||||||
{
|
{
|
||||||
pad.changeViewOption('useMonospaceFont', true);
|
pad.changeViewOption('padFontFamily', 'monospace');
|
||||||
}
|
}
|
||||||
// if the globalUserName value is set we need to tell the server and the client about the new authorname
|
// if the globalUserName value is set we need to tell the server and the client about the new authorname
|
||||||
if (settings.globalUserName !== false)
|
if (settings.globalUserName !== false)
|
||||||
|
@ -560,19 +560,7 @@ var pad = {
|
||||||
if(padcookie.getPref("rtlIsTrue") == true){
|
if(padcookie.getPref("rtlIsTrue") == true){
|
||||||
pad.changeViewOption('rtlIsTrue', true);
|
pad.changeViewOption('rtlIsTrue', true);
|
||||||
}
|
}
|
||||||
|
pad.changeViewOption('padFontFamily', padcookie.getPref("padFontFamily"));
|
||||||
|
|
||||||
var fonts = ['useMonospaceFont', 'useMontserratFont', 'useOpenDyslexicFont', 'useComicSansFont', 'useCourierNewFont',
|
|
||||||
'useGeorgiaFont', 'useImpactFont', 'useLucidaFont', 'useLucidaSansFont', 'usePalatinoFont', 'useRobotoMonoFont',
|
|
||||||
'useTahomaFont', 'useTimesNewRomanFont', 'useTrebuchetFont', 'useVerdanaFont', 'useSymbolFont', 'useWebdingsFont',
|
|
||||||
'useWingDingsFont', 'useSansSerifFont', 'useSerifFont'];
|
|
||||||
|
|
||||||
|
|
||||||
$.each(fonts, function(i, font){
|
|
||||||
if(padcookie.getPref(font) == true){
|
|
||||||
pad.changeViewOption(font, true);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
hooks.aCallAll("postAceInit", {ace: padeditor.ace, pad: pad});
|
hooks.aCallAll("postAceInit", {ace: padeditor.ace, pad: pad});
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,14 +29,6 @@ var padeditor = (function()
|
||||||
var pad = undefined;
|
var pad = undefined;
|
||||||
var settings = undefined;
|
var settings = undefined;
|
||||||
|
|
||||||
// Array of available fonts
|
|
||||||
|
|
||||||
var fonts = ['useMonospaceFont', 'useMontserratFont', 'useOpenDyslexicFont', 'useComicSansFont', 'useCourierNewFont',
|
|
||||||
'useGeorgiaFont', 'useImpactFont', 'useLucidaFont', 'useLucidaSansFont', 'usePalatinoFont', 'useRobotoMonoFont',
|
|
||||||
'useTahomaFont', 'useTimesNewRomanFont', 'useTrebuchetFont', 'useVerdanaFont', 'useSymbolFont', 'useWebdingsFont',
|
|
||||||
'useWingDingsFont', 'useSansSerifFont', 'useSerifFont'];
|
|
||||||
|
|
||||||
|
|
||||||
var self = {
|
var self = {
|
||||||
ace: null,
|
ace: null,
|
||||||
// this is accessed directly from other files
|
// this is accessed directly from other files
|
||||||
|
@ -97,12 +89,7 @@ var padeditor = (function()
|
||||||
// font family change
|
// font family change
|
||||||
$("#viewfontmenu").change(function()
|
$("#viewfontmenu").change(function()
|
||||||
{
|
{
|
||||||
$.each(fonts, function(i, font){
|
pad.changeViewOption('padFontFamily', $("#viewfontmenu").val());
|
||||||
var sfont = font.replace("use","");
|
|
||||||
sfont = sfont.replace("Font","");
|
|
||||||
sfont = sfont.toLowerCase();
|
|
||||||
pad.changeViewOption(font, $("#viewfontmenu").val() == sfont);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Language
|
// Language
|
||||||
|
@ -154,45 +141,29 @@ var padeditor = (function()
|
||||||
self.ace.setProperty("showsauthorcolors", !settings.noColors);
|
self.ace.setProperty("showsauthorcolors", !settings.noColors);
|
||||||
}
|
}
|
||||||
|
|
||||||
var normalFont = true;
|
var fontFamily = newOptions['padFontFamily'];
|
||||||
// Go through each font and see if the option is set..
|
switch (fontFamily) {
|
||||||
$.each(fonts, function(i, font){
|
case "monospace": self.ace.setProperty("textface", "monospace"); break;
|
||||||
var isEnabled = getOption(font, false);
|
case "montserrat": self.ace.setProperty("textface", "Montserrat"); break;
|
||||||
if(isEnabled){
|
case "opendyslexic": self.ace.setProperty("textface", "OpenDyslexic"); break;
|
||||||
font = font.replace("use","");
|
case "comicsans": self.ace.setProperty("textface", "'Comic Sans MS','Comic Sans',cursive"); break;
|
||||||
font = font.replace("Font","");
|
case "georgia": self.ace.setProperty("textface", "Georgia,'Bitstream Charter',serif"); break;
|
||||||
font = font.toLowerCase();
|
case "impact": self.ace.setProperty("textface", "Impact,Haettenschweiler,'Arial Black',sans-serif"); break;
|
||||||
if(font === "monospace") self.ace.setProperty("textface", "monospace");
|
case "lucida": self.ace.setProperty("textface", "Lucida,'Lucida Serif','Lucida Bright',serif"); break;
|
||||||
if(font === "montserrat") self.ace.setProperty("textface", "Montserrat");
|
case "lucidasans": self.ace.setProperty("textface", "'Lucida Sans','Lucida Grande','Lucida Sans Unicode','Luxi Sans',sans-serif"); break;
|
||||||
if(font === "opendyslexic") self.ace.setProperty("textface", "OpenDyslexic");
|
case "palatino": self.ace.setProperty("textface", "Palatino,'Palatino Linotype','URW Palladio L',Georgia,serif"); break;
|
||||||
if(font === "comicsans") self.ace.setProperty("textface", "'Comic Sans MS','Comic Sans',cursive");
|
case "robotomono": self.ace.setProperty("textface", "RobotoMono"); break;
|
||||||
if(font === "georgia") self.ace.setProperty("textface", "Georgia,'Bitstream Charter',serif");
|
case "tahoma": self.ace.setProperty("textface", "Tahoma,sans-serif"); break;
|
||||||
if(font === "impact") self.ace.setProperty("textface", "Impact,Haettenschweiler,'Arial Black',sans-serif");
|
case "timesnewroman": self.ace.setProperty("textface", "'Times New Roman',Times,serif"); break;
|
||||||
if(font === "lucida") self.ace.setProperty("textface", "Lucida,'Lucida Serif','Lucida Bright',serif");
|
case "trebuchet": self.ace.setProperty("textface", "'Trebuchet MS',sans-serif"); break;
|
||||||
if(font === "lucidasans") self.ace.setProperty("textface", "'Lucida Sans','Lucida Grande','Lucida Sans Unicode','Luxi Sans',sans-serif");
|
case "verdana": self.ace.setProperty("textface", "Verdana,'DejaVu Sans',sans-serif"); break;
|
||||||
if(font === "palatino") self.ace.setProperty("textface", "Palatino,'Palatino Linotype','URW Palladio L',Georgia,serif");
|
case "symbol": self.ace.setProperty("textface", "Symbol"); break;
|
||||||
if(font === "robotomono") self.ace.setProperty("textface", "RobotoMono");
|
case "webdings": self.ace.setProperty("textface", "Webdings"); break;
|
||||||
if(font === "tahoma") self.ace.setProperty("textface", "Tahoma,sans-serif");
|
case "wingdings": self.ace.setProperty("textface", "Wingdings"); break;
|
||||||
if(font === "timesnewroman") self.ace.setProperty("textface", "'Times New Roman',Times,serif");
|
case "sansserif": self.ace.setProperty("textface", "sans-serif"); break;
|
||||||
if(font === "trebuchet") self.ace.setProperty("textface", "'Trebuchet MS',sans-serif");
|
case "serif": self.ace.setProperty("textface", "serif"); break;
|
||||||
if(font === "verdana") self.ace.setProperty("textface", "Verdana,'DejaVu Sans',sans-serif");
|
default: self.ace.setProperty("textface", ""); break;
|
||||||
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", "sans-serif");
|
|
||||||
if(font === "serif") self.ace.setProperty("textface", "serif");
|
|
||||||
|
|
||||||
// $("#viewfontmenu").val(font);
|
|
||||||
normalFont = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// No font has been previously selected so use the Normal font
|
|
||||||
if(normalFont){
|
|
||||||
self.ace.setProperty("textface", "'Helvetica Neue',Arial, sans-serif");
|
|
||||||
// $("#viewfontmenu").val("normal");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
dispose: function()
|
dispose: function()
|
||||||
{
|
{
|
||||||
|
|
|
@ -166,25 +166,27 @@ function handleClientVars(message)
|
||||||
// font family change
|
// font family change
|
||||||
$("#viewfontmenu").change(function(){
|
$("#viewfontmenu").change(function(){
|
||||||
var font = $("#viewfontmenu").val();
|
var font = $("#viewfontmenu").val();
|
||||||
if(font === "monospace") setFont("Courier new");
|
switch (font) {
|
||||||
if(font === "opendyslexic") setFont("OpenDyslexic");
|
case "monospace": setFont("Courier new");break;
|
||||||
if(font === "comicsans") setFont("Comic Sans MS");
|
case "opendyslexic": setFont("OpenDyslexic");break;
|
||||||
if(font === "georgia") setFont("Georgia");
|
case "comicsans": setFont("Comic Sans MS");break;
|
||||||
if(font === "impact") setFont("Impact");
|
case "georgia": setFont("Georgia");break;
|
||||||
if(font === "lucida") setFont("Lucida");
|
case "impact": setFont("Impact");break;
|
||||||
if(font === "lucidasans") setFont("Lucida Sans Unicode");
|
case "lucida": setFont("Lucida");break;
|
||||||
if(font === "palatino") setFont("Palatino Linotype");
|
case "lucidasans": setFont("Lucida Sans Unicode");break;
|
||||||
if(font === "tahoma") setFont("Tahoma");
|
case "palatino": setFont("Palatino Linotype");break;
|
||||||
if(font === "timesnewroman") setFont("Times New Roman");
|
case "tahoma": setFont("Tahoma");break;
|
||||||
if(font === "trebuchet") setFont("Trebuchet MS");
|
case "timesnewroman": setFont("Times New Roman");break;
|
||||||
if(font === "verdana") setFont("Verdana");
|
case "trebuchet": setFont("Trebuchet MS");break;
|
||||||
if(font === "symbol") setFont("Symbol");
|
case "verdana": setFont("Verdana");break;
|
||||||
if(font === "webdings") setFont("Webdings");
|
case "symbol": setFont("Symbol");break;
|
||||||
if(font === "wingdings") setFont("Wingdings");
|
case "webdings": setFont("Webdings");break;
|
||||||
if(font === "sansserif") setFont("MS Sans Serif");
|
case "wingdings": setFont("Wingdings");break;
|
||||||
if(font === "serif") setFont("MS Serif");
|
case "sansserif": setFont("MS Sans Serif");break;
|
||||||
|
case "serif": setFont("MS Serif");break;
|
||||||
|
default: setFont("");break;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setFont(font){
|
function setFont(font){
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue