mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-12-25 15:29:23 -05:00
initial memory boilerplate, move sidebar toggle into it's init, test it behaves as it should
This commit is contained in:
parent
283d85c7cf
commit
daae0d0dca
@ -4356,6 +4356,58 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
||||
return me;
|
||||
})(window, document);
|
||||
|
||||
/**
|
||||
* (view) Handles the memory, storing paste URLs in the browser
|
||||
*
|
||||
* @name Memory
|
||||
* @class
|
||||
*/
|
||||
const Memory = (function () {
|
||||
const me = {};
|
||||
|
||||
/**
|
||||
* adds a paste URL to the memory
|
||||
*
|
||||
* @name Memory.add
|
||||
* @function
|
||||
* @param {string} pasteUrl
|
||||
* @return {bool}
|
||||
*/
|
||||
me.add = function(pasteUrl)
|
||||
{
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* refresh the displayed list from memory
|
||||
*
|
||||
* @name Memory.refreshList
|
||||
* @function
|
||||
*/
|
||||
me.refreshList = function()
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* initiate
|
||||
*
|
||||
* attaches click event to toggle memory sidepanel
|
||||
*
|
||||
* @name Memory.init
|
||||
* @function
|
||||
*/
|
||||
me.init = function()
|
||||
{
|
||||
$("#menu-toggle").on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$("main").toggleClass("toggled");
|
||||
$("#menu-toggle .glyphicon").toggleClass("glyphicon glyphicon-menu-down glyphicon glyphicon-menu-up")
|
||||
});
|
||||
};
|
||||
|
||||
return me;
|
||||
})();
|
||||
|
||||
/**
|
||||
* Responsible for AJAX requests, transparently handles encryption…
|
||||
*
|
||||
@ -5361,13 +5413,6 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
||||
});
|
||||
});
|
||||
|
||||
// attach memory sidebar toggle
|
||||
$("#menu-toggle").on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$("#menu-toggle .glyphicon").toggleClass("glyphicon glyphicon-menu-down glyphicon glyphicon-menu-up")
|
||||
$("main").toggleClass("toggled");
|
||||
});
|
||||
|
||||
// initialize other modules/"classes"
|
||||
Alert.init();
|
||||
Model.init();
|
||||
@ -5379,6 +5424,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
||||
Prompt.init();
|
||||
TopNav.init();
|
||||
UiHelper.init();
|
||||
Memory.init();
|
||||
|
||||
// check for legacy browsers before going any further
|
||||
if (!Legacy.Check.getInit()) {
|
||||
@ -5432,6 +5478,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
||||
AttachmentViewer: AttachmentViewer,
|
||||
DiscussionViewer: DiscussionViewer,
|
||||
TopNav: TopNav,
|
||||
Memory: Memory,
|
||||
ServerInteraction: ServerInteraction,
|
||||
PasteEncrypter: PasteEncrypter,
|
||||
PasteDecrypter: PasteDecrypter,
|
||||
|
29
js/test/Memory.js
Normal file
29
js/test/Memory.js
Normal file
@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
require('../common');
|
||||
|
||||
describe('Memory', function () {
|
||||
describe('init', function () {
|
||||
it(
|
||||
'enables toggling the memory sidebar',
|
||||
function() {
|
||||
$('body').html(
|
||||
'<main><div id="sidebar-wrapper"></div>' +
|
||||
'<button id="menu-toggle"></button></main>'
|
||||
);
|
||||
assert.ok(!$('main').hasClass('toggled'));
|
||||
|
||||
$('#menu-toggle').click();
|
||||
assert.ok(!$('main').hasClass('toggled'));
|
||||
|
||||
$.PrivateBin.Memory.init();
|
||||
assert.ok(!$('main').hasClass('toggled'));
|
||||
|
||||
$('#menu-toggle').click();
|
||||
assert.ok($('main').hasClass('toggled'));
|
||||
|
||||
$('#menu-toggle').click();
|
||||
assert.ok(!$('main').hasClass('toggled'));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
@ -72,7 +72,7 @@ endif;
|
||||
?>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/purify-2.0.8.js" integrity="sha512-QwcEKGuEmKtMguCO9pqNtUtZqq9b/tJ8gNr5qhY8hykq3zKTlDOvpZAmf6Rs8yH35Bz1ZdctUjj2qEWxT5aXCg==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/legacy.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LYos+qXHIRqFf5ZPNphvtTB0cgzHUizu2wwcOwcwz/VIpRv9lpcBgPYz4uq6jx0INwCAj6Fbnl5HoKiLufS2jg==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-xXyscWa4PKPNa2wyjP3k1es3nGNnjvupAqpJNdjzOECQU1WWIFzajsdhVE325t5X4BHpKF5M9ash4ubmW2BsVQ==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-0dH2jwB9G3WPKEuSqYz5//MbCKQObNZx+rmQwmH3PKnVsTFrUG8EqV88U2iy0qj2rlNBNiytbJZ1CmRGJJ6YbQ==" crossorigin="anonymous"></script>
|
||||
<!-- icon -->
|
||||
<link rel="apple-touch-icon" href="img/apple-touch-icon.png?<?php echo rawurlencode($VERSION); ?>" sizes="180x180" />
|
||||
<link rel="icon" type="image/png" href="img/favicon-32x32.png?<?php echo rawurlencode($VERSION); ?>" sizes="32x32" />
|
||||
|
@ -50,7 +50,7 @@ endif;
|
||||
?>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/purify-2.0.8.js" integrity="sha512-QwcEKGuEmKtMguCO9pqNtUtZqq9b/tJ8gNr5qhY8hykq3zKTlDOvpZAmf6Rs8yH35Bz1ZdctUjj2qEWxT5aXCg==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/legacy.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LYos+qXHIRqFf5ZPNphvtTB0cgzHUizu2wwcOwcwz/VIpRv9lpcBgPYz4uq6jx0INwCAj6Fbnl5HoKiLufS2jg==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-xXyscWa4PKPNa2wyjP3k1es3nGNnjvupAqpJNdjzOECQU1WWIFzajsdhVE325t5X4BHpKF5M9ash4ubmW2BsVQ==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-0dH2jwB9G3WPKEuSqYz5//MbCKQObNZx+rmQwmH3PKnVsTFrUG8EqV88U2iy0qj2rlNBNiytbJZ1CmRGJJ6YbQ==" crossorigin="anonymous"></script>
|
||||
<!-- icon -->
|
||||
<link rel="apple-touch-icon" href="img/apple-touch-icon.png?<?php echo rawurlencode($VERSION); ?>" sizes="180x180" />
|
||||
<link rel="icon" type="image/png" href="img/favicon-32x32.png?<?php echo rawurlencode($VERSION); ?>" sizes="32x32" />
|
||||
|
Loading…
Reference in New Issue
Block a user