diff --git a/js/privatebin.js b/js/privatebin.js index 395ac0ee..a7c22075 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -2557,6 +2557,7 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) { * Shows the QR code of the current paste (URL). * * @name TopNav.displayQrCode + * @private * @function */ function displayQrCode() @@ -2736,12 +2737,9 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) { */ me.collapseBar = function() { - var $bar = $('.navbar-toggle'); - - // check if bar is expanded - if ($bar.hasClass('collapse in')) { + if ($('#navbar').attr('aria-expanded')) { // if so, toggle it - $bar.click(); + $('.navbar-toggle').click(); } }; diff --git a/js/test/TopNav.js b/js/test/TopNav.js index ba7ffad3..5068376e 100644 --- a/js/test/TopNav.js +++ b/js/test/TopNav.js @@ -271,5 +271,50 @@ describe('TopNav', function () { } ); }); + + describe('collapseBar', function () { + before(function () { + cleanup(); + }); + + it( + 'collapses the navigation when displayed on a small screen', + function () { + var results = []; + $('body').html( + '' + ); + $.PrivateBin.TopNav.init(); + results.push( + $('.navbar-toggle').hasClass('collapsed') && + $('#navbar').attr('aria-expanded') != 'true' + ); + $.PrivateBin.TopNav.collapseBar(); + results.push( + $('.navbar-toggle').hasClass('collapsed') && + $('#navbar').attr('aria-expanded') != 'true' + ); + $('.navbar-toggle').click(); + results.push( + !$('.navbar-toggle').hasClass('collapsed') && + $('#navbar').attr('aria-expanded') == 'true' + ); + $.PrivateBin.TopNav.collapseBar(); + results.push( + $('.navbar-toggle').hasClass('collapsed') && + $('#navbar').attr('aria-expanded') == 'false' + ); + cleanup(); + assert.ok(results.every(element => element)); + } + ); + }); }); diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index ee078fa4..19f9e27e 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -75,7 +75,7 @@ if ($MARKDOWN): - + diff --git a/tpl/page.php b/tpl/page.php index ac94a65b..356c82ab 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -54,7 +54,7 @@ if ($QRCODE): - +