Skip to content

Commit 121cdf1

Browse files
authored
Merge pull request #597 from topcoder-platform/issues-530
Issues-530: Viewing in Preview
2 parents d9746e5 + e5ddcf7 commit 121cdf1

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

vanilla/applications/vanilla/js/discussion.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,4 +541,10 @@ jQuery(document).ready(function($) {
541541
}
542542
});
543543
});
544+
545+
$(document).on('PreviewLoaded', function(ev, form, ) {
546+
var previewContainer = $(form).find('.Preview');
547+
$(previewContainer).prepend('<h2 class="H">Preview</h2>');
548+
return false;
549+
});
544550
});

vanilla/applications/vanilla/js/post.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ jQuery(document).ready(function($) {
1717
function resetDiscussionForm(sender) {
1818
var parent = $(sender).parents('.DiscussionForm, .EditDiscussionForm');
1919
$(parent).find('.Preview').remove();
20-
$(parent).find('.bodybox-wrap .TextBoxWrapper').show();
20+
$(parent).find('.PreviewTitle').remove();
21+
$(parent).find('h1.H').show();
22+
$(parent).find('.bodybox-wrap .TextBoxWrapper,.P label[for=Form_Name], #Form_Name').show();
2123
}
2224

2325
// Hijack comment form button clicks
@@ -151,7 +153,7 @@ jQuery(document).ready(function($) {
151153
// Reveal the "Edit" button and hide this one
152154
$(btn).hide();
153155
$(frm).find('.WriteButton').removeClass('Hidden');
154-
156+
$(frm).find('.P label[for=Form_Name], #Form_Name').hide();
155157
$(frm).find('.bodybox-wrap .TextBoxWrapper').hide().after(json.Data);
156158
$(frm).trigger('PreviewLoaded', [frm]);
157159
} else if (!draft) {
@@ -193,4 +195,18 @@ jQuery(document).ready(function($) {
193195
button: btn
194196
});
195197
}
198+
199+
$(document).on('PreviewLoaded', function(ev, form, ) {
200+
var previewContainer = $(form).find('.Preview');
201+
var discussionTitle = $(form).find('#Form_Name').val();
202+
$(previewContainer).prepend('<div class="Title">'+discussionTitle+'</div>');
203+
var title = $(form).closest('.FormTitleWrapper').find('h1');
204+
var currentTitle = $(title).text();
205+
var previewTitle = $(title).clone();
206+
$(previewTitle).text(currentTitle + ' (Preview)');
207+
$(previewTitle).addClass('PreviewTitle');
208+
$(title).after($(previewTitle).prop('outerHTML'));
209+
$(title).hide();
210+
return false;
211+
});
196212
});

0 commit comments

Comments
 (0)