Support for tab key

This commit is contained in:
benweet 2013-04-21 19:41:10 +01:00
parent 301c51f6ac
commit c50e53f193
3 changed files with 41 additions and 30 deletions

View File

@ -1 +1 @@
CACHE MANIFEST # v3 CACHE: index.html css/main-min.css js/main-min.js js/require.js img/ajax-loader.gif img/glyphicons-halflings.png img/glyphicons-halflings-white.png img/icons.png img/stackedit-32.ico img/stackedit-promo.png NETWORK: * CACHE MANIFEST # v4 CACHE: index.html css/main-min.css js/main-min.js js/require.js img/ajax-loader.gif img/glyphicons-halflings.png img/glyphicons-halflings-white.png img/icons.png img/stackedit-32.ico img/stackedit-promo.png NETWORK: *

View File

@ -188,7 +188,7 @@ define(
converterType : "markdown-extra-prettify", converterType : "markdown-extra-prettify",
layoutOrientation : "horizontal", layoutOrientation : "horizontal",
editorFontSize : 14, editorFontSize : 14,
commitMsg : "Published by StackEdit.", commitMsg : "Published by StackEdit",
template : ['<!DOCTYPE html>\n', template : ['<!DOCTYPE html>\n',
'<html>\n', '<html>\n',
'<head>\n', '<head>\n',
@ -298,6 +298,7 @@ define(
$("#wmd-button-bar").empty(); $("#wmd-button-bar").empty();
var converter = Markdown.getSanitizingConverter(); var converter = Markdown.getSanitizingConverter();
if(core.settings.converterType.indexOf("markdown-extra") === 0) { if(core.settings.converterType.indexOf("markdown-extra") === 0) {
// Markdown extra customized converter
var options = {}; var options = {};
if(core.settings.converterType == "markdown-extra-prettify") { if(core.settings.converterType == "markdown-extra-prettify") {
options.highlighter = "prettify"; options.highlighter = "prettify";
@ -306,18 +307,21 @@ define(
} }
var firstChange = true; var firstChange = true;
converter.hooks.chain("preConversion", function(text) { converter.hooks.chain("preConversion", function(text) {
// Used to save changes when typing
if (!firstChange) { if (!firstChange) {
onTextChange(); onTextChange();
} }
return text; return text;
}); });
var editor = new Markdown.Editor(converter); var editor = new Markdown.Editor(converter);
// Custom insert link dialog
editor.hooks.set("insertLinkDialog", function (callback) { editor.hooks.set("insertLinkDialog", function (callback) {
insertLinkCallback = callback; insertLinkCallback = callback;
core.resetModalInputs(); core.resetModalInputs();
$("#modal-insert-link").modal(); $("#modal-insert-link").modal();
return true; return true;
}); });
// Custom insert image dialog
editor.hooks.set("insertImageDialog", function (callback) { editor.hooks.set("insertImageDialog", function (callback) {
insertLinkCallback = callback; insertLinkCallback = callback;
core.resetModalInputs(); core.resetModalInputs();
@ -331,8 +335,11 @@ define(
editor.run(); editor.run();
firstChange = false; firstChange = false;
// Hide default buttons
$(".wmd-button-row").addClass("btn-group").find("li:not(.wmd-spacer)") $(".wmd-button-row").addClass("btn-group").find("li:not(.wmd-spacer)")
.addClass("btn").css("left", 0).find("span").hide(); .addClass("btn").css("left", 0).find("span").hide();
// Add customized buttons
$("#wmd-bold-button").append($("<i>").addClass("icon-bold")); $("#wmd-bold-button").append($("<i>").addClass("icon-bold"));
$("#wmd-italic-button").append($("<i>").addClass("icon-italic")); $("#wmd-italic-button").append($("<i>").addClass("icon-italic"));
$("#wmd-link-button").append($("<i>").addClass("icon-globe")); $("#wmd-link-button").append($("<i>").addClass("icon-globe"));
@ -473,18 +480,18 @@ define(
return _.random(4294967296).toString(36); return _.random(4294967296).toString(36);
}; };
// Used to setup an empty localStorage // Used to setup an empty localStorage or to upgrade an existing one
function setupLocalStorage() { function setupLocalStorage() {
// Create the file system if not exist
if (localStorage["file.list"] === undefined) { if (localStorage["file.list"] === undefined) {
localStorage["file.list"] = ";"; localStorage["file.list"] = ";";
} }
}
// Used to upgrade an existing localStorage // localStorage versioning
function upgradeLocalStorage() {
var version = localStorage["version"]; var version = localStorage["version"];
// from v0 to v1 // Upgrade from v0 to v1
if(version === undefined) { if(version === undefined) {
// Not used anymore // Not used anymore
@ -507,7 +514,7 @@ define(
version = "v1"; version = "v1";
} }
// from v1 to v2 // Upgrade from v1 to v2
if(version == "v1") { if(version == "v1") {
var gdriveLastChangeId = localStorage["sync.gdrive.lastChangeId"]; var gdriveLastChangeId = localStorage["sync.gdrive.lastChangeId"];
if(gdriveLastChangeId) { if(gdriveLastChangeId) {
@ -551,6 +558,8 @@ define(
} }
localStorage["version"] = version; localStorage["version"] = version;
} }
// Setup the localStorage when starting
setupLocalStorage();
// Create an centered popup window // Create an centered popup window
core.popupWindow = function(url, title, w, h) { core.popupWindow = function(url, title, w, h) {
@ -571,8 +580,6 @@ define(
}; };
$(function() { $(function() {
setupLocalStorage();
upgradeLocalStorage();
// jGrowl configuration // jGrowl configuration
$.jGrowl.defaults.life = 5000; $.jGrowl.defaults.life = 5000;
@ -591,7 +598,7 @@ define(
$(document).mousemove(setUserActive).keypress(setUserActive); $(document).mousemove(setUserActive).keypress(setUserActive);
// Avoid dropdown to close when clicking on submenu // Avoid dropdown to close when clicking on submenu
$('.dropdown-submenu > a').click(function(e) { $(".dropdown-submenu > a").click(function(e) {
e.stopPropagation(); e.stopPropagation();
}); });
@ -612,12 +619,26 @@ define(
insertLinkCallback(null); insertLinkCallback(null);
}); });
$("#menu-bar, .ui-layout-center, .ui-layout-east, .ui-layout-south").removeClass("hide"); // Settings loading/saving
core.loadSettings(); core.loadSettings();
$(".action-load-settings").click(function() {
core.loadSettings();
});
$(".action-apply-settings").click(function(e) {
core.saveSettings(e);
if(!e.isPropagationStopped()) {
window.location.reload();
}
});
// UI layout
$("#menu-bar, .ui-layout-center, .ui-layout-east, .ui-layout-south").removeClass("hide");
core.createLayout(); core.createLayout();
// Apply editor font size // Editor's textarea
$("#wmd-input").css({ $("#wmd-input").css({
// Apply editor font size
"font-size": core.settings.editorFontSize + "px", "font-size": core.settings.editorFontSize + "px",
"line-height": Math.round(core.settings.editorFontSize * (20/14)) + "px" "line-height": Math.round(core.settings.editorFontSize * (20/14)) + "px"
}).keydown(function(e) { }).keydown(function(e) {
@ -636,17 +657,7 @@ define(
} }
}); });
$(".action-load-settings").click(function() { // Reset inputs
core.loadSettings();
});
$(".action-apply-settings").click(function(e) {
core.saveSettings(e);
if(!e.isPropagationStopped()) {
window.location.reload();
}
});
$(".action-reset-input").click(function() { $(".action-reset-input").click(function() {
core.resetModalInputs(); core.resetModalInputs();
}); });

2
js/main-min.js vendored

File diff suppressed because one or more lines are too long