Skip to content

Commit

Permalink
Fixed bug #77: Sometimes options page MD preview doesn't initially re…
Browse files Browse the repository at this point in the history
…nder. Also copied a bit of code from the css-update branch
  • Loading branch information
adam-p committed Jun 23, 2013
1 parent 069e9fd commit 3c9ed94
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/common/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pre {

pre code {
white-space: pre;
overflow: auto;
overflow: auto; /* fixes issue #70: Firefox/Thunderbird: Code blocks with horizontal scroll would have bad background colour */
border-radius: 3px;
border: 1px solid #CCC;
padding: 0.5em 0.7em;
Expand Down
8 changes: 4 additions & 4 deletions src/common/options.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<!DOCTYPE html>

<!--
Copyright Adam Pritchard 2012
Copyright Adam Pritchard 2013
MIT License : http://adampritchard.mit-license.org/
-->

<!DOCTYPE html>

<html>
<html lang="en">

<head>
<meta charset="utf-8">
Expand Down
21 changes: 16 additions & 5 deletions src/common/options.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright Adam Pritchard 2012
* Copyright Adam Pritchard 2013
* MIT License : http://adampritchard.mit-license.org/
*/

Expand All @@ -12,7 +12,8 @@
*/

var cssEdit, cssSyntaxEdit, cssSyntaxSelect, rawMarkdownIframe, savedMsg,
mathEnable, mathEdit, hotkeyShift, hotkeyCtrl, hotkeyAlt, hotkeyKey;
mathEnable, mathEdit, hotkeyShift, hotkeyCtrl, hotkeyAlt, hotkeyKey,
loaded = false;

function onLoad() {
var xhr;
Expand Down Expand Up @@ -125,15 +126,25 @@ function onLoad() {
}
};
xhr.send();

loaded = true;
}
document.addEventListener('DOMContentLoaded', onLoad, false);


// The Preview <iframe> will let us know when it's loaded, so that we can
// trigger the rendering of it.
document.addEventListener('options-iframe-loaded', function() {
renderMarkdown();
});
function previewIframeLoaded() {
// Even though the IFrame is loaded, the page DOM might not be, so we don't
// yet have a valid state. In that case, set a timer.
if (loaded) {
renderMarkdown();
}
else {
setTimeout(previewIframeLoaded, 100);
}
}
document.addEventListener('options-iframe-loaded', previewIframeLoaded);


// Shows/hide page elements depending on the current platform.
Expand Down
11 changes: 8 additions & 3 deletions src/common/test/index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<!doctype html>
<!DOCTYPE html>

<!--
Copyright Adam Pritchard 2013
MIT License : http://adampritchard.mit-license.org/
-->

<html lang="en" style="height: 100%">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

<title>Markdown Here Autotests</title>
<meta name="description" content="">
Expand All @@ -13,7 +18,7 @@

<link rel="shortcut icon" href="/favicon.ico">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="stylesheet" href="mocha.css" />
<link rel="stylesheet" href="mocha.css">
</head>

<body>
Expand Down

0 comments on commit 3c9ed94

Please sign in to comment.