Skip to content

Commit

Permalink
Fix: Some errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ollm authored Oct 4, 2024
1 parent 18c3dca commit a90c387
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
36 changes: 35 additions & 1 deletion scripts/reading/context-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
function show(gamepad = false)
{
const saveImages = (reading.isCanvas() || reading.isEbook()) ? false : true;
dom.queryAll('.separator-save-images, .reading-context-menu-save-image, .reading-context-menu-save-all-images').css({display: saveImages ? '' : 'none'});
dom.queryAll('.separator-save-images, .reading-context-menu-save-image, .reading-context-menu-save-all-images, .reading-context-menu-set-as-poster, .reading-context-menu-set-as-poster-folders').css({display: saveImages ? '' : 'none'});

if(gamepad)
events.activeMenu('#reading-context-menu', false, 'gamepad');
Expand Down Expand Up @@ -39,6 +39,38 @@ function aboutFile()
dom.fileInfo.show(vars.pathIsFolder ? vars.currentPath : fileManager.lastCompressedFile(vars.currentPath));
}

function getCurrentImage()
{
const currentIndex = reading.currentIndex() - 1;

const images = reading.images();
const imagesData = reading.imagesData();

for(let key in images)
{
if(currentIndex == imagesData[key].position)
return images[key].path;
}

return false;
}

function setAsPoster()
{
const image = getCurrentImage();
if(!image) return;

dom.poster.setAsPoster(image);
}

function setAsPosterFolders()
{
const image = getCurrentImage();
if(!image) return;

dom.poster.setAsPosterFolders(image, dom.indexMainPathA());
}

function saveImage()
{
const currentIndex = reading.currentIndex();
Expand Down Expand Up @@ -102,6 +134,8 @@ module.exports = {
show: show,
openFileLocation: openFileLocation,
aboutFile: aboutFile,
setAsPoster: setAsPoster,
setAsPosterFolders: setAsPosterFolders,
saveImage: saveImage,
saveAllImages: saveAllImages,
};
2 changes: 1 addition & 1 deletion templates/dialog.poster.folders.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{#each posterFolders}}
<div class="menu-simple-element menu-simple-element-medium menu-simple-element-dialog rounded gamepad-item menu-simple-element-icons-1"{{#if @last}} style="margin-bottom: 14px;"{{/if}} onclick="dom.poster.setAsPosterFolders('{{image}}', false, '{{path}}', true);">
<div class="menu-simple-element menu-simple-element-medium menu-simple-element-dialog rounded gamepad-item menu-simple-element-icons-1"{{#if @last}} style="margin-bottom: 14px;"{{/if}} onclick="dom.poster.setAsPosterFolders('{{chain 'escapeBackSlash' 'escapeQuotesSimples' image}}', false, '{{chain 'escapeBackSlash' 'escapeQuotesSimples' path}}', true);">
<i class="material-icon menu-simple-icon-first">folder</i>
<span>{{name}}</span>
</div>
Expand Down
11 changes: 11 additions & 0 deletions templates/reading.elements.menus.html
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,17 @@
<div class="menu-simple-content">
<div>

<div class="menu-simple-element menu-simple-element-little reading-context-menu-set-as-poster gamepad-item" onclick="reading.contextMenu.setAsPoster();">
<i class="material-icon menu-simple-icon-first">add_photo_alternate</i>
{{language.global.contextMenu.setAsPoster}}
</div>

<div class="menu-simple-element menu-simple-element-little reading-context-menu-set-as-poster-folders gamepad-item" onclick="reading.contextMenu.setAsPosterFolders();">
<i class="material-icon menu-simple-icon-first">perm_media</i>
{{language.global.contextMenu.setAsPosterFolders}}
</div>

<div class="menu-simple-separator separator-save-images"></div>

<div class="menu-simple-element menu-simple-element-little reading-context-menu-save-image gamepad-item" onclick="reading.contextMenu.saveImage();">
<i class="material-icon menu-simple-icon-first">image</i>
Expand Down

0 comments on commit a90c387

Please sign in to comment.