Permalink
Browse files

Avoid setting focus on the preview window for automatic refreshes and…

… close it when the page containing the editor is unloaded
  • Loading branch information...
1 parent 52a55f5 commit 77e6700d47011f834b3f9c01cc3aafd184260866 DrSlump committed May 30, 2010
Showing with 6 additions and 3 deletions.
  1. +6 −3 markitup/jquery.markitup.js
@@ -414,6 +414,9 @@
if (!previewWindow || previewWindow.closed) {
if (options.previewInWindow) {
previewWindow = window.open('', 'preview', options.previewInWindow);
+ $(window).unload(function(){
+ previewWindow.close();
+ });
} else {
iFrame = $('<iframe class="markItUpPreviewFrame"></iframe>');
if (options.previewPosition == 'after') {
@@ -435,6 +438,9 @@
if (!options.previewAutoRefresh) {
refreshPreview();
}
+ if (options.previewInWindow) {
+ previewWindow.focus();
+ }
}
// refresh Preview window
@@ -478,9 +484,6 @@
previewWindow.document.close();
previewWindow.document.documentElement.scrollTop = sp;
}
- if (options.previewInWindow) {
- previewWindow.focus();
- }
}
// set keys pressed

0 comments on commit 77e6700

Please sign in to comment.