Added default content

This commit is contained in:
benweet 2013-04-29 22:41:10 +01:00
parent aae18b1bfb
commit 2c0ca1096d
7 changed files with 40 additions and 31 deletions

View File

@ -332,7 +332,8 @@ hr {
} }
#modal-settings textarea { #modal-settings textarea {
height: 180px; height: 80px;
max-width: 206px;
} }
.tooltip-inner { .tooltip-inner {

View File

@ -483,6 +483,15 @@
class="input-mini"><span class="help-inline">px</span> class="input-mini"><span class="help-inline">px</span>
</div> </div>
</div> </div>
<div class="control-group">
<label class="control-label"
for="textarea-settings-default-content">Default content <a
href="#" class="tooltip-default-content">(?)</a>
</label>
<div class="controls">
<textarea id="textarea-settings-default-content"></textarea>
</div>
</div>
</div> </div>
</div> </div>
<div class="tab-pane" id="tabpane-settings-publish"> <div class="tab-pane" id="tabpane-settings-publish">

View File

@ -210,7 +210,8 @@ define(
layoutOrientation : "horizontal", layoutOrientation : "horizontal",
scrollLink : true, scrollLink : true,
editorFontSize : 14, editorFontSize : 14,
commitMsg : "Published by StackEdit", defaultContent: "\n\n\n> Written with [StackEdit](http://benweet.github.io/stackedit/).",
commitMsg : "Published by http://benweet.github.io/stackedit",
template : ['<!DOCTYPE html>\n', template : ['<!DOCTYPE html>\n',
'<html>\n', '<html>\n',
'<head>\n', '<head>\n',
@ -228,19 +229,16 @@ define(
// Layout orientation // Layout orientation
$("input:radio[name=radio-layout-orientation][value=" $("input:radio[name=radio-layout-orientation][value="
+ core.settings.layoutOrientation + "]").prop("checked", true); + core.settings.layoutOrientation + "]").prop("checked", true);
// Scroll Link // Scroll Link
$("#input-settings-scroll-link").prop("checked", core.settings.scrollLink); $("#input-settings-scroll-link").prop("checked", core.settings.scrollLink);
// Converter type // Converter type
$("#input-settings-converter-type").val(core.settings.converterType); $("#input-settings-converter-type").val(core.settings.converterType);
// Editor font size // Editor font size
$("#input-settings-editor-font-size").val(core.settings.editorFontSize); $("#input-settings-editor-font-size").val(core.settings.editorFontSize);
// Default content
$("#textarea-settings-default-content").val(core.settings.defaultContent);
// Commit message // Commit message
$("#input-settings-publish-commit-msg").val(core.settings.commitMsg); $("#input-settings-publish-commit-msg").val(core.settings.commitMsg);
// Template // Template
$("#textarea-settings-publish-template").val(core.settings.template); $("#textarea-settings-publish-template").val(core.settings.template);
}; };
@ -251,19 +249,16 @@ define(
// Layout orientation // Layout orientation
newSettings.layoutOrientation = $( newSettings.layoutOrientation = $(
"input:radio[name=radio-layout-orientation]:checked").prop("value"); "input:radio[name=radio-layout-orientation]:checked").prop("value");
// Converter type // Converter type
newSettings.converterType = $("#input-settings-converter-type").val(); newSettings.converterType = $("#input-settings-converter-type").val();
// Scroll Link // Scroll Link
newSettings.scrollLink = $("#input-settings-scroll-link").prop("checked"); newSettings.scrollLink = $("#input-settings-scroll-link").prop("checked");
// Editor font size // Editor font size
newSettings.editorFontSize = core.getInputIntValue($("#input-settings-editor-font-size"), event, 1, 99); newSettings.editorFontSize = core.getInputIntValue($("#input-settings-editor-font-size"), event, 1, 99);
// Default content
newSettings.defaultContent = $("#textarea-settings-default-content").val();
// Commit message // Commit message
newSettings.commitMsg = core.getInputValue($("#input-settings-publish-commit-msg"), event); newSettings.commitMsg = core.getInputValue($("#input-settings-publish-commit-msg"), event);
// Template // Template
newSettings.template = core.getInputValue($("#textarea-settings-publish-template"), event); newSettings.template = core.getInputValue($("#textarea-settings-publish-template"), event);
@ -917,6 +912,12 @@ define(
'Therefore, if your document does not contain any title, the mapping will be linear and consequently less efficient.', 'Therefore, if your document does not contain any title, the mapping will be linear and consequently less efficient.',
].join("") ].join("")
}); });
$(".tooltip-default-content").tooltip({
html: true,
container: '#modal-settings',
placement: 'right',
title: 'Thanks for supporting StackEdit by adding a backlink in your documents!'
});
$(".tooltip-template").tooltip({ $(".tooltip-template").tooltip({
html: true, html: true,
container: '#modal-settings', container: '#modal-settings',

View File

@ -49,7 +49,7 @@ define(["jquery", "core", "synchronizer", "publisher", "text!../WELCOME.md", "un
}; };
fileManager.createFile = function(title, content, syncIndexes) { fileManager.createFile = function(title, content, syncIndexes) {
content = content || ""; content = content || core.settings.defaultContent;
syncIndexes = syncIndexes || []; syncIndexes = syncIndexes || [];
if (!title) { if (!title) {
// Create a file title // Create a file title
@ -135,13 +135,15 @@ define(["jquery", "core", "synchronizer", "publisher", "text!../WELCOME.md", "un
synchronizer.resetSyncFlags(); synchronizer.resetSyncFlags();
function composeTitle(fileIndex) { function composeTitle(fileIndex) {
var result = " " + localStorage[fileIndex + ".title"]; var result = [];
var providerIdList = synchronizer.getSyncProvidersFromFile(fileIndex); var providerIdList = synchronizer.getSyncProvidersFromFile(fileIndex);
providerIsList = _.extend(providerIdList, publisher.getPublishProvidersFromFile(fileIndex)); providerIdList = providerIdList.concat(publisher.getPublishProvidersFromFile(fileIndex));
_.each(providerIdList, function(providerId) { _.each(providerIdList.sort(), function(providerId) {
result = '<i class="icon-' + providerId + '"></i>' + result; result.push('<i class="icon-' + providerId + '"></i>');
}); });
return result; result.push(" ");
result.push(localStorage[fileIndex + ".title"]);
return result.join("");
} }
// Update the file title // Update the file title
@ -231,7 +233,7 @@ define(["jquery", "core", "synchronizer", "publisher", "text!../WELCOME.md", "un
}); });
$("#file-title").click(function() { $("#file-title").click(function() {
$(this).hide(); $(this).hide();
$("#file-title-input").show().focus(); $("#file-title-input").show().focus().get(0).select();
}); });
function applyTitle(input) { function applyTitle(input) {
var title = $.trim(input.val()); var title = $.trim(input.val());

View File

@ -210,10 +210,10 @@ define(["jquery", "core", "github-provider", "blogger-provider", "dropbox-provid
publisher.getPublishProvidersFromFile = function(fileIndex) { publisher.getPublishProvidersFromFile = function(fileIndex) {
var publishIndexList = _.compact(localStorage[fileIndex + ".publish"].split(";")); var publishIndexList = _.compact(localStorage[fileIndex + ".publish"].split(";"));
var providerIdList = {}; var providerIdList = [];
_.each(publishIndexList, function(publishIndex) { _.each(publishIndexList, function(publishIndex) {
var publishAttributes = JSON.parse(localStorage[publishIndex]); var publishAttributes = JSON.parse(localStorage[publishIndex]);
providerIdList[publishAttributes.provider] = publishAttributes.provider; providerIdList.push(publishAttributes.provider);
}); });
return providerIdList; return providerIdList;
}; };

View File

@ -225,13 +225,12 @@ define(["jquery", "core", "dropbox-provider", "gdrive-provider", "underscore"],
}); });
}; };
synchronizer.getSyncProvidersFromFile = function(fileIndex) { synchronizer.getSyncProvidersFromFile = function(fileIndex) {
var sync = localStorage[fileIndex + ".sync"]; var syncIndexList = _.compact(localStorage[fileIndex + ".sync"].split(";"));
var providerIdList = {}; var providerIdList = [];
_.each(providerMap, function(provider) { _.each(syncIndexList, function(syncIndex) {
if (sync.indexOf(";sync." + provider.providerId + ".") !== -1) { var syncAttributes = JSON.parse(localStorage[syncIndex]);
provider.useSync = true; providerIdList.push(syncAttributes.provider);
providerIdList[provider.providerId] = provider.providerId; providerMap[syncAttributes.provider].useSync = true;
}
}); });
return providerIdList; return providerIdList;
}; };

View File

@ -1,3 +0,0 @@
> Written with [StackEdit](http://benweet.github.io/stackedit/).