From 5ece4d2632f3001ff252cfed73518425c10d70c6 Mon Sep 17 00:00:00 2001 From: rugk Date: Thu, 23 Apr 2020 11:25:24 +0200 Subject: [PATCH 1/3] Reset attachment when clicking new paste --- js/privatebin.js | 56 +++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index 6ed9325..86e4071 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -18,14 +18,14 @@ jQuery.fn.draghover = function() { return this.each(function() { let collection = $(), self = $(this); - + self.on('dragenter', function(e) { if (collection.length === 0) { self.trigger('draghoverstart'); } collection = collection.add(e.target); }); - + self.on('dragleave drop', function(e) { collection = collection.not(e.target); if (collection.length === 0) { @@ -519,7 +519,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { /** * calculate expiration date given initial date and expiration period - * + * * @name Helper.calculateExpirationDate * @function * @param {Date} initialDate - may not be empty @@ -532,7 +532,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { if (typeof expirationDisplayStringOrSecondsToExpire === 'string') { secondsToExpiration = me.durationToSeconds(expirationDisplayStringOrSecondsToExpire); } - + if (typeof secondsToExpiration !== 'number') { throw new Error('Cannot calculate expiration date.'); } @@ -3695,9 +3695,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { // in any case, remove saved attachment data AttachmentViewer.removeAttachmentData(); - // hide UI for selected files - // our up-to-date jQuery can handle it :) - $fileWrap.find('input').val(''); + me.clearAttachmentInput(); AttachmentViewer.clearDragAndDrop(); // pevent '#' from appearing in the URL @@ -3722,11 +3720,11 @@ jQuery.PrivateBin = (function($, RawDeflate) { /** * Template Email body. - * + * * @name TopNav.templateEmailBody - * @private - * @param {string} expirationDateString - * @param {bool} isBurnafterreading + * @private + * @param {string} expirationDateString + * @param {bool} isBurnafterreading */ function templateEmailBody(expirationDateString, isBurnafterreading) { @@ -3764,10 +3762,10 @@ jQuery.PrivateBin = (function($, RawDeflate) { /** * Trigger Email send. - * + * * @name TopNav.triggerEmailSend - * @private - * @param {string} emailBody + * @private + * @param {string} emailBody */ function triggerEmailSend(emailBody) { @@ -3980,7 +3978,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { /** * show the "email" button - * + * * @name TopNav.showEmailbutton * @function * @param {int|undefined} optionalRemainingTimeInSeconds @@ -4008,7 +4006,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { /** * hide the "email" button - * + * * @name TopNav.hideEmailButton * @function */ @@ -4042,7 +4040,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { /** * only hides the qr code button - * + * * @name TopNav.hideQrCodeButton * @function */ @@ -4053,7 +4051,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { /** * hide all irrelevant buttons when viewing burn after reading paste - * + * * @name TopNav.hideBurnAfterReadingButtons * @function */ @@ -4089,7 +4087,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { /** * hides the custom attachment - * + * * @name TopNav.hideCustomAttachment * @function */ @@ -4112,6 +4110,19 @@ jQuery.PrivateBin = (function($, RawDeflate) { } }; + /** + * Clear the attachment input in the top navigation. + * + * @name TopNav.clearAttachmentInput + * @function + */ + me.clearAttachmentInput = function() + { + // hide UI for selected files + // our up-to-date jQuery can handle it :) + $fileWrap.find('input').val(''); + }; + /** * returns the currently set expiration time * @@ -4213,7 +4224,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { /** * Highlight file upload - * + * * @name TopNav.highlightFileupload * @function */ @@ -4232,7 +4243,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { /** * set the format on bootstrap templates in dropdown programmatically - * + * * @name TopNav.setFormat * @function */ @@ -4243,7 +4254,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { /** * returns if attachment dropdown is readonly, not editable - * + * * @name TopNav.isAttachmentReadonly * @function * @return {bool} @@ -5133,6 +5144,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { Editor.show(); Editor.focusInput(); AttachmentViewer.removeAttachment(); + TopNav.clearAttachmentInput(); TopNav.showCreateButtons(); From d3ba7eeb13a889d694dc78731a240f6cc86a055b Mon Sep 17 00:00:00 2001 From: rugk Date: Thu, 23 Apr 2020 12:07:08 +0200 Subject: [PATCH 2/3] Reset checkboxes on new paste --- js/privatebin.js | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index 86e4071..23344dd 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -3601,6 +3601,20 @@ jQuery.PrivateBin = (function($, RawDeflate) { } } + + /** + * Clear the attachment input in the top navigation. + * + * @name TopNav.clearAttachmentInput + * @function + */ + function clearAttachmentInput() + { + // hide UI for selected files + // our up-to-date jQuery can handle it :) + $fileWrap.find('input').val(''); + } + /** * return raw text * @@ -3695,7 +3709,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { // in any case, remove saved attachment data AttachmentViewer.removeAttachmentData(); - me.clearAttachmentInput(); + clearAttachmentInput(); AttachmentViewer.clearDragAndDrop(); // pevent '#' from appearing in the URL @@ -4111,16 +4125,21 @@ jQuery.PrivateBin = (function($, RawDeflate) { }; /** - * Clear the attachment input in the top navigation. + * Reset the top navigation back to it's default values. * - * @name TopNav.clearAttachmentInput + * @name TopNav.resetInput * @function */ - me.clearAttachmentInput = function() + me.resetInput = function() { - // hide UI for selected files - // our up-to-date jQuery can handle it :) - $fileWrap.find('input').val(''); + clearAttachmentInput(); + + $openDiscussion.prop('checked', false); + $burnAfterReading.prop('checked', false); + $openDiscussionOption.removeClass('buttondisabled'); + $burnAfterReadingOption.removeClass('buttondisabled'); + + // TODO: reset expiration time }; /** @@ -5144,7 +5163,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { Editor.show(); Editor.focusInput(); AttachmentViewer.removeAttachment(); - TopNav.clearAttachmentInput(); + TopNav.resetInput(); TopNav.showCreateButtons(); From 38a1726e2229c752e049984b316933697e86158a Mon Sep 17 00:00:00 2001 From: rugk Date: Thu, 23 Apr 2020 12:07:38 +0200 Subject: [PATCH 3/3] Regenerate SRI --- tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index 275b027..0b2d95a 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -72,7 +72,7 @@ endif; ?> - + diff --git a/tpl/page.php b/tpl/page.php index 44e9545..947850e 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -50,7 +50,7 @@ endif; ?> - +