diff media/js/markitup/jquery.markitup.js @ 185:afb65fa947f1

Committing version 1.1.6.1 of the MarkItUp! editor. This is for #57.
author Brian Neal <bgneal@gmail.com>
date Sun, 28 Mar 2010 23:25:10 +0000
parents dbd703f7d63a
children 217119c87a06
line wrap: on
line diff
--- a/media/js/markitup/jquery.markitup.js	Sun Mar 28 22:19:08 2010 +0000
+++ b/media/js/markitup/jquery.markitup.js	Sun Mar 28 23:25:10 2010 +0000
@@ -1,9 +1,9 @@
 // ----------------------------------------------------------------------------
 // markItUp! Universal MarkUp Engine, JQuery plugin
-// v 1.1.5
+// v 1.1.6.1
 // Dual licensed under the MIT and GPL licenses.
 // ----------------------------------------------------------------------------
-// Copyright (C) 2007-2008 Jay Salvat
+// Copyright (C) 2007-2010 Jay Salvat
 // http://markitup.jaysalvat.com/
 // ----------------------------------------------------------------------------
 // Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -421,13 +421,15 @@
 						} else {
 							iFrame.insertBefore(header);
 						}	
-						previewWindow = iFrame[iFrame.length-1].contentWindow || frame[iFrame.length-1];
+						previewWindow = iFrame[iFrame.length - 1].contentWindow || frame[iFrame.length - 1];
 					}
 				} else if (altKey === true) {
+					// Thx Stephen M. Redd for the IE8 fix
 					if (iFrame) {
 						iFrame.remove();
+					} else {
+						previewWindow.close();
 					}
-					previewWindow.close();
 					previewWindow = iFrame = false;
 				}
 				if (!options.previewAutoRefresh) {
@@ -437,14 +439,43 @@
 
 			// refresh Preview window
 			function refreshPreview() {
+ 				renderPreview();
+			}
+
+			function renderPreview() {		
+				var phtml;
+				if (options.previewParserPath !== '') {
+					$.ajax( {
+						type: 'POST',
+						url: options.previewParserPath,
+						data: options.previewParserVar+'='+encodeURIComponent($$.val()),
+						success: function(data) {
+							writeInPreview( localize(data, 1) ); 
+						}
+					} );
+				} else {
+					if (!template) {
+						$.ajax( {
+							url: options.previewTemplatePath,
+							success: function(data) {
+								writeInPreview( localize(data, 1).replace(/<!-- content -->/g, $$.val()) );
+							}
+						} );
+					}
+				}
+				return false;
+			}
+			
+			function writeInPreview(data) {
 				if (previewWindow.document) {			
 					try {
 						sp = previewWindow.document.documentElement.scrollTop
 					} catch(e) {
 						sp = 0;
-					}					
+					}	
+					var h = "test";
 					previewWindow.document.open();
-					previewWindow.document.write(renderPreview());
+					previewWindow.document.write(data);
 					previewWindow.document.close();
 					previewWindow.document.documentElement.scrollTop = sp;
 				}
@@ -452,32 +483,6 @@
 					previewWindow.focus();
 				}
 			}
-
-			function renderPreview() {				
-				if (options.previewParserPath !== '') {
-					$.ajax( {
-						type: 'POST',
-						async: false,
-						url: options.previewParserPath,
-						data: options.previewParserVar+'='+encodeURIComponent($$.val()),
-						success: function(data) {
-							phtml = localize(data, 1); 
-						}
-					} );
-				} else {
-					if (!template) {
-						$.ajax( {
-							async: false,
-							url: options.previewTemplatePath,
-							success: function(data) {
-								template = localize(data, 1); 
-							}
-						} );
-					}
-					phtml = template.replace(/<!-- content -->/g, $$.val());
-				}
-				return phtml;
-			}
 			
 			// set keys pressed
 			function keyPressed(e) {