From 2c8b5ed0e4405670ca6c7767bf897c18510637b7 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Thu, 9 May 2024 15:55:42 +0200 Subject: [PATCH 1/2] expiration time selection for bootstrap template, fixes #1309 --- CHANGELOG.md | 1 + js/privatebin.js | 8 ++++++-- tpl/bootstrap.php | 2 +- tpl/bootstrap5.php | 2 +- tpl/page.php | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56c758fd..ad21e86a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # PrivateBin version history ## 1.7.3 (not yet released) +* FIXED: Selected expiration not being applied, when using bootstrap template (#1309) ## 1.7.2 (2024-05-05) * ADDED: Allow use of `shortenviayourls` in query parameters (#1267) diff --git a/js/privatebin.js b/js/privatebin.js index 0f9096d9..dbe74e7c 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -4371,7 +4371,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { */ me.getExpiration = function() { - return Model.getExpirationDefault() || pasteExpiration; + return pasteExpiration; }; /** @@ -4554,6 +4554,10 @@ jQuery.PrivateBin = (function($, RawDeflate) { // bootstrap template drop downs $('ul.dropdown-menu li a', $('#expiration').parent()).click(updateExpiration); $('ul.dropdown-menu li a', $('#formatter').parent()).click(updateFormat); + // bootstrap5 & page drop downs + $('#pasteExpiration').on('change', function() { + pasteExpiration = Model.getExpirationDefault(); + }); $('#pasteFormatter').on('change', function() { PasteViewer.setFormat(Model.getFormatDefault()); }); @@ -4565,7 +4569,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { // get default values from template or fall back to set value burnAfterReadingDefault = me.getBurnAfterReading(); openDiscussionDefault = me.getOpenDiscussion(); - pasteExpiration = Model.getExpirationDefault() || pasteExpiration; + pasteExpiration = Model.getExpirationDefault(); createButtonsDisplayed = false; viewButtonsDisplayed = false; diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index 4c5ee23a..e9adc435 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -73,7 +73,7 @@ endif; ?> - + diff --git a/tpl/bootstrap5.php b/tpl/bootstrap5.php index dee10744..84ac6aa9 100644 --- a/tpl/bootstrap5.php +++ b/tpl/bootstrap5.php @@ -57,7 +57,7 @@ endif; ?> - + diff --git a/tpl/page.php b/tpl/page.php index 88953d3f..82805f83 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -51,7 +51,7 @@ endif; ?> - + From 81ad352c8c936c17e30ef34b05ce88cf9a634c14 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Thu, 9 May 2024 16:11:15 +0200 Subject: [PATCH 2/2] improve TopNav.getExpiration test --- js/test/TopNav.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/js/test/TopNav.js b/js/test/TopNav.js index 2743bf60..d5571888 100644 --- a/js/test/TopNav.js +++ b/js/test/TopNav.js @@ -456,8 +456,14 @@ describe('TopNav', function () { it( 'returns the currently selected expiration date', function () { + $('body').html( + '' + ); $.PrivateBin.TopNav.init(); - assert.ok($.PrivateBin.TopNav.getExpiration() === null); + assert.ok($.PrivateBin.TopNav.getExpiration() === '1day'); + cleanup(); } ); });