mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-10-01 01:26:10 -04:00
found and fixed a bug in TopNav.collapseBar() while writing test for it
This commit is contained in:
parent
ce6764e97d
commit
76debde85b
@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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(
|
||||
'<nav><div class="navbar-header"><button type="button" ' +
|
||||
'class="navbar-toggle collapsed" data-toggle="collapse" ' +
|
||||
'data-target="#navbar" aria-expanded="false" aria-controls' +
|
||||
'="navbar">Toggle navigation</button><a class="reloadlink ' +
|
||||
'navbar-brand" href=""><img alt="PrivateBin" ' +
|
||||
'src="img/icon.svg" width="38" /></a></div><div ' +
|
||||
'id="navbar"><ul><li><button id="newbutton" type=' +
|
||||
'"button" class="hidden">New</button></li></ul></div></nav>'
|
||||
);
|
||||
$.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));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -75,7 +75,7 @@ if ($MARKDOWN):
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-Z3SG68lkzr8/Hg8goFersCg5T8qrI2dUKDCRnlA6uZanWLiKRCBBX8gNHgjSdPp/+XC3fFFTGL3KCZFgCXXdtQ==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-4UWESerlTU/BJPR9ew+ILaiLunjhQa+9asT2/1MY2zQ2dSxnJ3orDUFOq4CU+KrnkK/9sWwmUobshOUGkVMygQ==" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
|
@ -54,7 +54,7 @@ if ($QRCODE):
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-Z3SG68lkzr8/Hg8goFersCg5T8qrI2dUKDCRnlA6uZanWLiKRCBBX8gNHgjSdPp/+XC3fFFTGL3KCZFgCXXdtQ==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-4UWESerlTU/BJPR9ew+ILaiLunjhQa+9asT2/1MY2zQ2dSxnJ3orDUFOq4CU+KrnkK/9sWwmUobshOUGkVMygQ==" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
|
Loading…
Reference in New Issue
Block a user