lib/gollum/frontend/public/gollum/livepreview/js/livepreview.js in gollum-2.3.3 vs lib/gollum/frontend/public/gollum/livepreview/js/livepreview.js in gollum-2.3.4
- old
+ new
@@ -85,10 +85,22 @@
}
// Set comment using the default commit message.
commentEditorSession.setValue( defaultCommitMessage() );
+$.preview = function( previewWindow ) {
+ jQuery.ajax( {
+ type: 'POST',
+ url: baseUrl + '/preview',
+ data: { page: 'Preview: ' + pageName, format: 'markdown', content: editorSession.getValue() },
+ success: function( html ) {
+ previewWindow.document.write( html );
+ previewWindow.focus();
+ }
+ });
+}
+
$.save = function( commitMessage ) {
win.onbeforeunload = null;
var POST = 'POST';
var markdown = 'markdown';
@@ -375,11 +387,19 @@
editorSession.setValue( data );
}
});
}
+ $( '#preview' ).click( function() {
+ $(this).target = "_blank";
+ // pass window into preview
+ $.preview( window.open() );
+ return false;
+ });
+
$( '#save' ).click( function() {
$.save();
+ return false;
});
// Hide dimmer, comment tool panel, and comment.
$( '#commentcancel' ).click( function() {
// Restore focus on commentcancel but not on