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;
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;
}
.dropdown-menu {
@ -5428,8 +5428,7 @@ input[disabled], select[disabled], textarea[disabled], input[readonly], select[r
background-color: #888;
}
.btn-group {
margin-left: 5px !important;
margin-right: 5px !important;
margin-right: 5px;
}
.btn-group > .btn + .dropdown-toggle {
padding-right: 12px;
@ -5470,9 +5469,6 @@ hr {
#wmd-button-bar {
margin-left: 15px;
}
#wmd-input,#wmd-preview {
position: absolute;
}
#wmd-input, #md-section-helper {
font-family: "Courier New", Courier, monospace;
resize: none;
@ -5677,4 +5673,18 @@ blockquote p {
.opera #md-section-helper {
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("prettify.css");
@media print {
@page {
margin: 25mm 25mm 25mm 25mm;
}
#wmd-preview {
padding: 0px;
margin: 0px;
}
#navbar {
display: none;
}
}
body {
background-color: #f5f5f5;
tab-size: 4;
@ -31,7 +46,7 @@ div, span, a, ul, li, textarea, input, button {
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;
}
@ -103,8 +118,7 @@ input[disabled], select[disabled], textarea[disabled], input[readonly], select[r
}
.btn-group {
margin-left: 5px !important;
margin-right: 5px !important;
margin-right: 5px;
}
.btn-group > .btn + .dropdown-toggle {
@ -158,10 +172,6 @@ hr {
margin-left: 15px;
}
#wmd-input,#wmd-preview {
position: absolute;
}
#wmd-input, #md-section-helper {
font-family: "Courier New", Courier, monospace;
resize: none;
@ -409,4 +419,23 @@ blockquote p {
.opera #md-section-helper {
/* Opera needs to have the textarea in the viewport to evaluate size correctly */
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";
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 viewerMode = false;
</script>
<script src="js/require.js"></script>
</head>
@ -32,7 +33,8 @@
<li><div id="wmd-button-bar"></div></li>
</ul>
<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">
<i class="icon-refresh"></i>
</button>
@ -57,6 +59,8 @@
data-toggle="dropdown" href="#" title="Menu"><i
class="icon-stackedit"></i>&nbsp;&nbsp;<b class="caret"></b></a>
<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
class="icon-download-alt"></i> Save as Markdown</a></li>
<li><a class="action-download-html" href="#"><i

View File

@ -402,6 +402,9 @@ define(
// Create the layout
var layout = undefined;
core.createLayout = function() {
if(viewerMode === true) {
return;
}
var layoutGlobalConfig = {
closable : true,
resizable : false,
@ -412,7 +415,9 @@ define(
spacing_closed : 15,
togglerLength_open : 90,
togglerLength_closed : 90,
stateManagement__enabled : false
stateManagement__enabled : false,
center__minWidth : 200,
center__minHeight : 200
};
if(core.settings.scrollLink === true) {
layoutGlobalConfig.onresize = buildSections;
@ -481,8 +486,14 @@ define(
}
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);
if(core.settings.scrollLink === true) {
if(viewerMode === false && core.settings.scrollLink === true) {
editor.hooks.chain("onPreviewRefresh", function() {
// Modify scroll position of the preview not the editor
lastEditorScrollTop = -9;
@ -494,6 +505,10 @@ define(
});
});
}
// Prettify
if(core.settings.converterType == "markdown-extra-prettify") {
editor.hooks.chain("onPreviewRefresh", prettyPrint);
}
// Custom insert link dialog
editor.hooks.set("insertLinkDialog", function (callback) {
insertLinkCallback = callback;
@ -508,9 +523,6 @@ define(
$("#modal-insert-image").modal();
return true;
});
if(core.settings.converterType == "markdown-extra-prettify") {
editor.hooks.chain("onPreviewRefresh", prettyPrint);
}
editor.run();
firstChange = false;
@ -962,7 +974,7 @@ define(
intervalId = window.setInterval(function() {
updateCurrentTime();
core.checkWindowUnique();
if(isUserActive() === true) {
if(viewerMode === false && isUserActive() === true) {
_.each(periodicCallbacks, function(callback) {
callback();
});

View File

@ -232,6 +232,9 @@ define(["jquery", "core", "synchronizer", "publisher", "text!../WELCOME.md", "un
fileManager.selectFile();
});
$("#file-title").click(function() {
if(viewerMode === true) {
return;
}
$(this).hide();
$("#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>