Skip to content

Commit

Permalink
Add settings option to toggle the delete button.
Browse files Browse the repository at this point in the history
Uses dynamic stylesheet shenanigans.
  • Loading branch information
sz3 committed May 14, 2020
1 parent d49e4a2 commit 232e613
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -20,6 +20,7 @@ on linux:
```
pip install pogui[qt]
```
(if the PyQt5 dependency fails, you may need to upgrade pip: `pip install -U pip`)

From source,
```
Expand Down
2 changes: 1 addition & 1 deletion pogui/web/filebrowser/fb.js
Expand Up @@ -389,7 +389,7 @@ return {
{
if (actions['delete'])
{
var deleteArchive = $('<a href="javascript:;" title="Delete"><i class="gg-close-r"></i></a>');
var deleteArchive = $('<a href="javascript:;" title="Delete" class="archive-delete-option"><i class="gg-close-r"></i></a>');
deleteArchive.click(function() {
Api.deleteArchive(id).then(function(res) {
if (res)
Expand Down
8 changes: 8 additions & 0 deletions pogui/web/index.html
Expand Up @@ -81,6 +81,14 @@ <h2 class="content-subhead">Zoom</h2>
<button class="zoom-setting-current pure-button" href="javascript:;" onclick="Settings.zoomReset()">100%</button>
<button class="pure-button" href="javascript:;" onclick="Settings.zoomIn()">+</button>
</div>

<h2 class="content-subhead">Allow Deletes</h2>
<form class="pure-form">
<div class="pure-button-group settings-storage-choice" role="group" aria-label="...">
<button class="pure-button" onclick="Settings.allowDeletes(true)">Yes</button>
<button class="pure-button pure-button-active" onclick="Settings.allowDeletes(false)">No</button>
</div>
</form>
</div>

<div id="create-archive" class="page create-archive">
Expand Down
4 changes: 4 additions & 0 deletions pogui/web/main.css
Expand Up @@ -129,6 +129,10 @@ Download, reload Links
box-shadow: 0px 0px 1.5px black;
}

.filemanager-actions .archive-delete-option {
display: none;
}

/*-------------------------
create archive page
----*/
Expand Down
18 changes: 18 additions & 0 deletions pogui/web/settings.js
@@ -1,5 +1,7 @@
var Settings = function() {

var _deletesAllowed = false;

// private functions

function addRemoteStorageClick()
Expand Down Expand Up @@ -81,6 +83,22 @@ return {
zoomReset : function()
{
Api.zoomReset().then(Settings.zoom);
},

allowDeletes : function(allow)
{
if (allow && !_deletesAllowed)
{
var style = '<style type="text/css" id="allowDeletesStyle">' +
'.filemanager-actions .archive-delete-option { display: inline; }' +
'</style>';
$('head').append(style);
}
if (!allow)
{
$('#allowDeletesStyle').remove();
}
_deletesAllowed = allow;
}
}
}();

0 comments on commit 232e613

Please sign in to comment.