Added viewer

This commit is contained in:
benweet 2013-05-01 00:02:19 +01:00
parent 655e21d308
commit 7b571699d0
8 changed files with 149 additions and 24 deletions

View File

@ -1 +1 @@
CACHE MANIFEST # v19 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 # v19 CACHE: index.html viewer.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: *

22
css/main-min.css vendored
View File

@ -5367,7 +5367,7 @@ div, span, a, ul, li, textarea, input, button {
box-shadow: none !important; box-shadow: none !important;
text-shadow: none !important; text-shadow: none !important;
} }
.btn, .navbar-inner, .ui-layout-east, .ui-layout-south, .add-on { .btn, .navbar-inner, #wmd-preview, .add-on {
border: none !important; border: none !important;
} }
.dropdown-menu { .dropdown-menu {
@ -5428,8 +5428,7 @@ input[disabled], select[disabled], textarea[disabled], input[readonly], select[r
background-color: #888; background-color: #888;
} }
.btn-group { .btn-group {
margin-left: 5px !important; margin-right: 5px;
margin-right: 5px !important;
} }
.btn-group > .btn + .dropdown-toggle { .btn-group > .btn + .dropdown-toggle {
padding-right: 12px; padding-right: 12px;
@ -5470,9 +5469,6 @@ hr {
#wmd-button-bar { #wmd-button-bar {
margin-left: 15px; margin-left: 15px;
} }
#wmd-input,#wmd-preview {
position: absolute;
}
#wmd-input, #md-section-helper { #wmd-input, #md-section-helper {
font-family: "Courier New", Courier, monospace; font-family: "Courier New", Courier, monospace;
resize: none; resize: none;
@ -5678,3 +5674,17 @@ blockquote p {
top: 0; top: 0;
} }
.viewer #navbar {
position: fixed;
}
.viewer .navbar-inner {
background-color:rgba(200,200,200,0.5) !important;
}
.viewer #wmd-preview {
max-width: 1024px;
margin: 50px auto;
}
.viewer .btn-group {
margin-right: 0;
margin-left: 0;
}

View File

@ -2,6 +2,21 @@
@import url("jgrowl.css"); @import url("jgrowl.css");
@import url("prettify.css"); @import url("prettify.css");
@media print {
@page {
margin: 25mm 25mm 25mm 25mm;
}
#wmd-preview {
padding: 0px;
margin: 0px;
}
#navbar {
display: none;
}
}
body { body {
background-color: #f5f5f5; background-color: #f5f5f5;
tab-size: 4; tab-size: 4;
@ -31,7 +46,7 @@ div, span, a, ul, li, textarea, input, button {
text-shadow: none !important; text-shadow: none !important;
} }
.btn, .navbar-inner, .ui-layout-east, .ui-layout-south, .add-on { .btn, .navbar-inner, #wmd-preview, .add-on {
border: none !important; border: none !important;
} }
@ -103,8 +118,7 @@ input[disabled], select[disabled], textarea[disabled], input[readonly], select[r
} }
.btn-group { .btn-group {
margin-left: 5px !important; margin-right: 5px;
margin-right: 5px !important;
} }
.btn-group > .btn + .dropdown-toggle { .btn-group > .btn + .dropdown-toggle {
@ -158,10 +172,6 @@ hr {
margin-left: 15px; margin-left: 15px;
} }
#wmd-input,#wmd-preview {
position: absolute;
}
#wmd-input, #md-section-helper { #wmd-input, #md-section-helper {
font-family: "Courier New", Courier, monospace; font-family: "Courier New", Courier, monospace;
resize: none; resize: none;
@ -410,3 +420,22 @@ blockquote p {
/* Opera needs to have the textarea in the viewport to evaluate size correctly */ /* Opera needs to have the textarea in the viewport to evaluate size correctly */
top: 0; top: 0;
} }
/* Viewer */
.viewer #navbar {
position: fixed;
}
.viewer .navbar-inner {
background-color:rgba(200,200,200,0.5) !important;
}
.viewer #wmd-preview {
max-width: 1024px;
margin: 50px auto;
}
.viewer .btn-group {
margin-right: 0;
margin-left: 0;
}

View File

@ -19,8 +19,9 @@
dep = "main"; dep = "main";
css = "css/main.css"; css = "css/main.css";
} }
document.write('<link href="' + css + '" rel="stylesheet" media="screen">'); document.write('<link href="' + css + '" rel="stylesheet">');
var require = { baseUrl : "js", deps : [ dep ] }; var require = { baseUrl : "js", deps : [ dep ] };
var viewerMode = false;
</script> </script>
<script src="js/require.js"></script> <script src="js/require.js"></script>
</head> </head>
@ -32,7 +33,8 @@
<li><div id="wmd-button-bar"></div></li> <li><div id="wmd-button-bar"></div></li>
</ul> </ul>
<ul class="pull-right hide" id="menu-bar"> <ul class="pull-right hide" id="menu-bar">
<li class="btn-group"><button class="btn action-force-sync" <li class="btn-group">
<button class="btn action-force-sync"
title="Synchronize"> title="Synchronize">
<i class="icon-refresh"></i> <i class="icon-refresh"></i>
</button> </button>
@ -57,6 +59,8 @@
data-toggle="dropdown" href="#" title="Menu"><i data-toggle="dropdown" href="#" title="Menu"><i
class="icon-stackedit"></i>&nbsp;&nbsp;<b class="caret"></b></a> class="icon-stackedit"></i>&nbsp;&nbsp;<b class="caret"></b></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href="viewer.html"><i
class="icon-fullscreen"></i> Open in viewer</a></li>
<li><a class="action-download-md" href="#"><i <li><a class="action-download-md" href="#"><i
class="icon-download-alt"></i> Save as Markdown</a></li> class="icon-download-alt"></i> Save as Markdown</a></li>
<li><a class="action-download-html" href="#"><i <li><a class="action-download-html" href="#"><i

View File

@ -402,6 +402,9 @@ define(
// Create the layout // Create the layout
var layout = undefined; var layout = undefined;
core.createLayout = function() { core.createLayout = function() {
if(viewerMode === true) {
return;
}
var layoutGlobalConfig = { var layoutGlobalConfig = {
closable : true, closable : true,
resizable : false, resizable : false,
@ -412,7 +415,9 @@ define(
spacing_closed : 15, spacing_closed : 15,
togglerLength_open : 90, togglerLength_open : 90,
togglerLength_closed : 90, togglerLength_closed : 90,
stateManagement__enabled : false stateManagement__enabled : false,
center__minWidth : 200,
center__minHeight : 200
}; };
if(core.settings.scrollLink === true) { if(core.settings.scrollLink === true) {
layoutGlobalConfig.onresize = buildSections; layoutGlobalConfig.onresize = buildSections;
@ -481,8 +486,14 @@ define(
} }
return text; return text;
}); });
// Convert email addresses (not managed by pagedown)
converter.hooks.chain("postConversion", function(text) {
return text.replace(/<(mailto\:)?([^\s>]+@[^\s>]+\.\S+?)>/g, function(match, mailto, email) {
return '<a href="mailto:' + email + '">' + email + '</a>';
});
});
var editor = new Markdown.Editor(converter); var editor = new Markdown.Editor(converter);
if(core.settings.scrollLink === true) { if(viewerMode === false && core.settings.scrollLink === true) {
editor.hooks.chain("onPreviewRefresh", function() { editor.hooks.chain("onPreviewRefresh", function() {
// Modify scroll position of the preview not the editor // Modify scroll position of the preview not the editor
lastEditorScrollTop = -9; lastEditorScrollTop = -9;
@ -494,6 +505,10 @@ define(
}); });
}); });
} }
// Prettify
if(core.settings.converterType == "markdown-extra-prettify") {
editor.hooks.chain("onPreviewRefresh", prettyPrint);
}
// Custom insert link dialog // Custom insert link dialog
editor.hooks.set("insertLinkDialog", function (callback) { editor.hooks.set("insertLinkDialog", function (callback) {
insertLinkCallback = callback; insertLinkCallback = callback;
@ -508,9 +523,6 @@ define(
$("#modal-insert-image").modal(); $("#modal-insert-image").modal();
return true; return true;
}); });
if(core.settings.converterType == "markdown-extra-prettify") {
editor.hooks.chain("onPreviewRefresh", prettyPrint);
}
editor.run(); editor.run();
firstChange = false; firstChange = false;
@ -962,7 +974,7 @@ define(
intervalId = window.setInterval(function() { intervalId = window.setInterval(function() {
updateCurrentTime(); updateCurrentTime();
core.checkWindowUnique(); core.checkWindowUnique();
if(isUserActive() === true) { if(viewerMode === false && isUserActive() === true) {
_.each(periodicCallbacks, function(callback) { _.each(periodicCallbacks, function(callback) {
callback(); callback();
}); });

View File

@ -232,6 +232,9 @@ define(["jquery", "core", "synchronizer", "publisher", "text!../WELCOME.md", "un
fileManager.selectFile(); fileManager.selectFile();
}); });
$("#file-title").click(function() { $("#file-title").click(function() {
if(viewerMode === true) {
return;
}
$(this).hide(); $(this).hide();
$("#file-title-input").show().focus().get(0).select(); $("#file-title-input").show().focus().get(0).select();
}); });

2
js/main-min.js vendored

File diff suppressed because one or more lines are too long

67
viewer.html Normal file
View File

@ -0,0 +1,67 @@
<!DOCTYPE html>
<html manifest="cache.manifest">
<head>
<title>StackEdit Viewer</title>
<link rel="icon" href="img/stackedit-32.ico" type="image/x-icon">
<link rel="shortcut icon" href="img/stackedit-32.ico"
type="image/x-icon">
<meta name="keywords"
content="Markdown, Editor, PageDown, Stack Overflow, Stack Exchange">
<meta name="description"
content="StackEdit is a free, open-source Markdown editor based on PageDown, the Markdown library used by Stack Overflow and the other Stack Exchange sites.">
<meta name="author" content="Benoit Schweblin">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
// http://.../?debug to serve original CSS/JavaScript files for debug
var dep = "main-min";
var css = "css/main-min.css";
if (location.search.indexOf("debug") !== -1) {
dep = "main";
css = "css/main.css";
}
document.write('<link href="' + css + '" rel="stylesheet">');
var require = { baseUrl : "js", deps : [ dep ] };
var viewerMode = true;
</script>
<script src="js/require.js"></script>
</head>
<body class="viewer">
<div id="navbar" class="navbar navbar-fixed-top ui-layout-north">
<div class="navbar-inner">
<ul class="pull-right hide" id="menu-bar">
<li class="btn-group">
<button class="btn dropdown-toggle" data-toggle="dropdown"
title="Save document">
<i class="icon-download-alt"></i>
</button>
<ul class="dropdown-menu">
<li><a class="action-download-md" href="#"><i
class="icon-download-alt"></i> Save as Markdown</a></li>
<li><a class="action-download-html" href="#"><i
class="icon-download-alt"></i> Save as HTML</a></li>
<li><a class="action-download-template" href="#"><i
class="icon-download-alt"></i> Save using template</a></li>
</ul></li>
<li class="btn-group">
<button class="btn dropdown-toggle" data-toggle="dropdown"
title="Open local document">
<i class="icon-folder-open"></i>
</button>
<ul id="file-selector" class="dropdown-menu">
</ul></li>
<li class="btn-group"><a class="btn"
href="." title="Open StackEdit"><i
class="icon-stackedit"></i></a></li>
</ul>
<ul class="nav pull-right">
<li><i class="working-indicator icon-none"></i></li>
<li><span class="brand" id="file-title"></span></li>
</ul>
</div>
</div>
<div id="wmd-button-bar" class="hide"></div>
<textarea id="wmd-input" class="hide"></textarea>
<div id="wmd-preview" class="well"></div>
</body>
</html>