Configurable font family. Fixes #24

This commit is contained in:
benweet 2013-06-28 00:10:04 +01:00
parent 0b180a0981
commit cc5ffbd7ef
12 changed files with 46 additions and 33 deletions

View File

@ -343,7 +343,6 @@ hr {
}
#wmd-input,#md-section-helper {
font-family: "Courier New", Courier, monospace;
resize: none;
border: none !important;
}

View File

@ -447,6 +447,13 @@
placeholder="repository-name">
</div>
</div>
<div class="control-group modal-publish-github">
<label class="control-label" for="input-publish-github-username">Username (optional)</label>
<div class="controls">
<input type="text" id="input-publish-github-username"
placeholder="username">
</div>
</div>
<div class="control-group modal-publish-github">
<label class="control-label" for="input-publish-github-branch">Branch</label>
<div class="controls">
@ -660,10 +667,11 @@
</div>
<div class="control-group">
<label class="control-label"
for="input-settings-editor-font-size">Editor font size</label>
<div class="controls">
<input type="text" id="input-settings-editor-font-size"
class="input-mini"><span class="help-inline">px</span>
for="input-settings-editor-font-family">Editor font</label>
<div class="controls form-inline">
<input type="text" id="input-settings-editor-font-family"
class="span2"> <input type="text" id="input-settings-editor-font-size"
class="input-mini"><span class="help-inline">px</span>
</div>
</div>
<div class="control-group">

View File

@ -104,6 +104,8 @@ define([
utils.setInputValue("#input-settings-theme", localStorage.theme);
// Lazy rendering
utils.setInputChecked("#input-settings-lazy-rendering", settings.lazyRendering);
// Editor font family
utils.setInputValue("#input-settings-editor-font-family", settings.editorFontFamily);
// Editor font size
utils.setInputValue("#input-settings-editor-font-size", settings.editorFontSize);
// Default content
@ -129,6 +131,8 @@ define([
var theme = utils.getInputValue("#input-settings-theme");
// Lazy Rendering
newSettings.lazyRendering = utils.getInputChecked("#input-settings-lazy-rendering");
// Editor font family
newSettings.editorFontFamily = utils.getInputTextValue("#input-settings-editor-font-family", event);
// Editor font size
newSettings.editorFontSize = utils.getInputIntValue("#input-settings-editor-font-size", event, 1, 99);
// Default content
@ -440,7 +444,8 @@ define([
// Editor's textarea
$("#wmd-input, #md-section-helper").css({
// Apply editor font size
// Apply editor font
"font-family": settings.editorFontFamily,
"font-size": settings.editorFontSize + "px",
"line-height": Math.round(settings.editorFontSize * (20 / 14)) + "px"
});

View File

@ -173,21 +173,9 @@ define([
// Create extension preview buttons
logger.log("onCreatePreviewButton");
function showDropdown(btnGroup) {
$("#extension-preview-buttons .open").removeClass("open").find(".dropdown-menu").addClass("hide");
if(btnGroup !== undefined) {
btnGroup.addClass("open").find(".dropdown-menu").removeClass("hide");
}
}
var onCreatePreviewButtonCallbackList = getExtensionCallbackList("onCreatePreviewButton");
_.each(onCreatePreviewButtonCallbackList, function(callback) {
$("#extension-preview-buttons").append($('<div class="btn-group">').append(callback()).each(function() {
// Toggle dropdown manually
var btnGroup = $(this);
btnGroup.find(".dropdown-toggle").click(function() {
showDropdown(btnGroup.is(".open") ? undefined : btnGroup);
});
}));
$("#extension-preview-buttons").append($('<div class="btn-group">').append(callback()));
});
// Call extensions onReady callbacks

View File

@ -67,9 +67,15 @@ define([
_gaq.push([
'_trackEvent',
"Settings",
'editorFontSize',
"" + settings.editorFontSize
'editorFontFamily',
"" + settings.editorFontFamily
]);
_gaq.push([
'_trackEvent',
"Settings",
'editorFontSize',
"" + settings.editorFontSize
]);
// Check if user has removed back links
_gaq.push([
'_trackEvent',

View File

@ -110,25 +110,24 @@ define([
});
}
githubHelper.upload = function(reponame, branch, path, content, commitMsg, callback) {
githubHelper.upload = function(reponame, username, branch, path, content, commitMsg, callback) {
var task = new AsyncTask();
connect(task);
authenticate(task);
task.onRun(function() {
var userLogin = undefined;
function getUserLogin() {
function getUsername() {
var user = github.getUser();
user.show(undefined, function(err, result) {
if(err) {
handleError(err, task);
return;
}
userLogin = result.login;
username = result.login;
task.chain(write);
});
}
function write() {
var repo = github.getRepo(userLogin, reponame);
var repo = github.getRepo(username, reponame);
repo.write(branch, path, content, commitMsg, function(err) {
if(err) {
handleError(err, task);
@ -137,7 +136,12 @@ define([
task.chain();
});
}
task.chain(getUserLogin);
if(username) {
task.chain(write);
}
else {
task.chain(getUsername);
}
});
task.onSuccess(function() {
callback();

View File

@ -1,4 +1,4 @@
<button class="btn dropdown-toggle action-html-code" title="HTML code">
<button class="btn dropdown-toggle action-html-code" title="HTML code" data-toggle="dropdown">
<i class="icon-code"></i>
</button>
<div class="dropdown-menu pull-right">

View File

@ -1,4 +1,4 @@
<button class="btn dropdown-toggle" title="Markdown syntax">
<button class="btn dropdown-toggle" title="Markdown syntax" data-toggle="dropdown">
<i class="icon-question-sign"></i>
</button>
<div class="dropdown-menu pull-right">

View File

@ -1,4 +1,4 @@
<button class="btn dropdown-toggle" title="Document statistics">
<button class="btn dropdown-toggle" title="Document statistics" data-toggle="dropdown">
<i class="icon-stat"></i>
</button>
<div class="dropdown-menu pull-right">

View File

@ -1,5 +1,5 @@
<button class="btn dropdown-toggle" title="Table of contents">
<i class="icon-th-list"></i>
<button class="btn dropdown-toggle" title="Table of contents" data-toggle="dropdown">
<i class="icon-list"></i>
</button>
<div class="dropdown-menu pull-right">
<h3>Table of contents</h3>

View File

@ -8,17 +8,19 @@ define([
var githubProvider = new Provider("github", "GitHub");
githubProvider.publishPreferencesInputIds = [
"github-reponame",
"github-username",
"github-branch"
];
githubProvider.publish = function(publishAttributes, title, content, callback) {
var commitMsg = settings.commitMsg;
githubHelper.upload(publishAttributes.repository, publishAttributes.branch, publishAttributes.path, content, commitMsg, callback);
githubHelper.upload(publishAttributes.repository, publishAttributes.username, publishAttributes.branch, publishAttributes.path, content, commitMsg, callback);
};
githubProvider.newPublishAttributes = function(event) {
var publishAttributes = {};
publishAttributes.repository = utils.getInputTextValue("#input-publish-github-reponame", event);
publishAttributes.username = utils.getInputTextValue("#input-publish-github-username");
publishAttributes.branch = utils.getInputTextValue("#input-publish-github-branch", event);
publishAttributes.path = utils.getInputTextValue("#input-publish-file-path", event);
if(event.isPropagationStopped()) {

View File

@ -6,6 +6,7 @@ define([
var settings = {
layoutOrientation: "horizontal",
lazyRendering: true,
editorFontFamily: "Courier New, Courier, monospace",
editorFontSize: 14,
defaultContent: "\n\n\n> Written with [StackEdit](" + MAIN_URL + ").",
commitMsg: "Published with " + MAIN_URL,