From 52d1be1b5442884ccd17a7963ddec86ed1593060 Mon Sep 17 00:00:00 2001 From: rugk Date: Fri, 17 Feb 2017 22:26:39 +0100 Subject: [PATCH] Fix https://github.com/PrivateBin/PrivateBin/issues/187 --- js/privatebin.js | 35 ++++++++++++++++++++++++++--------- tpl/bootstrap.php | 2 +- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index 55350af..bffb978 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -2560,6 +2560,8 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { */ function rawText(event) { + TopNav.hideAllButtons(); + Alert.showLoading('Showing raw text…', 0, 'time'); var paste = PasteViewer.getText(); // push a new state to allow back navigation with browser back button @@ -2573,11 +2575,14 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { // we use text/html instead of text/plain to avoid a bug when // reloading the raw text view (it reverts to type text/html) + var $head = $('head').children().not('noscript, script, link[type="text/css"]'); var newDoc = document.open('text/html', 'replace'); - newDoc.write('
' + Helper.htmlEntities(paste) + '
'); + newDoc.write(''); + for (var i = 0; i < $head.length; i++) { + newDoc.write($head[i].outerHTML); + } + newDoc.write('
' + Helper.htmlEntities(paste) + '
'); newDoc.close(); - - event.preventDefault(); } /** @@ -2643,7 +2648,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { /** * Shows all elements belonging to viwing an existing pastes * - * @name TopNav.hideAllElem + * @name TopNav.showViewButtons * @function */ me.showViewButtons = function() @@ -2663,7 +2668,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { /** * Hides all elements belonging to existing pastes * - * @name TopNav.hideAllElem + * @name TopNav.hideViewButtons * @function */ me.hideViewButtons = function() @@ -2680,6 +2685,18 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { viewButtonsDisplayed = false; }; + /** + * Hides all elements belonging to existing pastes + * + * @name TopNav.hideAllButtons + * @function + */ + me.hideAllButtons = function() + { + me.hideViewButtons(); + me.hideCreateButtons(); + }; + /** * shows all elements needed when creating a new paste * @@ -3393,7 +3410,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { Alert.setCustomHandler(DiscussionViewer.handleNotification); // UI loading state - TopNav.hideViewButtons(); + TopNav.hideAllButtons(); Alert.showLoading('Sending comment…', 0, 'cloud-upload'); // get data @@ -3467,7 +3484,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { Controller.hideStatusMessages(); // UI loading state - TopNav.hideCreateButtons(); + TopNav.hideAllButtons(); Alert.showLoading('Sending paste…', 0, 'cloud-upload'); TopNav.collapseBar(); @@ -3826,7 +3843,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { { // Important: This *must not* run Alert.hideMessages() as previous // errors from viewing a paste should be shown. - TopNav.hideViewButtons(); + TopNav.hideAllButtons(); Alert.showLoading('Preparing new paste…', 0, 'time'); PasteStatus.hideMessages(); @@ -3911,7 +3928,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { me.clonePaste = function(event) { TopNav.collapseBar(); - TopNav.hideViewButtons(); + TopNav.hideAllButtons(); Alert.showLoading('Cloning paste…', 0, 'transfer'); // hide messages from previous paste diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index 7f07bcb..9b9f9eb 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -4,7 +4,7 @@ $isCpct = substr($template, 9, 8) === '-compact'; $isDark = substr($template, 9, 5) === '-dark'; $isPage = substr($template, -5) === '-page'; ?> - +