Commit 4dbd02ca authored by Duhoux Pierre-Louis's avatar Duhoux Pierre-Louis

Add context menu to bookmark a scan

parent ef994a00
......@@ -550,7 +550,11 @@
"message": "Note : $1",
"description": "Text to display the note for a bookmark. $1 is the note"
},
"background_bookmark_menu": {
"message": "Bookmark this scan",
"description": "Context menu when right click on a scan"
},
"bookmark_popup_title": {
"message": "Bookmark",
"description": "Title of the bookmark popup"
......
import store from '../store';
import * as utils from '../amr/utils';
import i18n from '../amr/i18n';
import browser from "webextension-polyfill";
class HandleBookmarks {
constructor() {
this.context_ids = [];
}
handle(message, sender) {
switch (message.action) {
case "getBookmarkNote":
......@@ -17,7 +22,21 @@ class HandleBookmarks {
case "addUpdateBookmark":
this.addBookmark(message);
return Promise.resolve({});
case "createContextMenu": //TODO
case "createContextMenu":
let url = message.lstUrls[0];
if (this.context_ids.indexOf(url) < 0) {
this.context_ids.push(url);
let id = browser.contextMenus.create({
title: i18n("background_bookmark_menu"),
contexts: ["image"],
onclick: function (info, tab) {
browser.tabs.executeScript(tab.id, {
code: "clickOnBM(\"" + info.srcUrl + "\")"
});
},
targetUrlPatterns: [encodeURI(url), url]
});
}
return Promise.resolve({});
}
}
......
......@@ -15,7 +15,7 @@ import HandleKeys from './handlekeys';
/**
* Every mirror implementation ends by a call to registerMangaObject
* This function is defined here.
* This script is injected by background script if the default content script (testcontent.js)
* This script is injected by background script if the default content script (testcontent.js)
* found that the page could be a manga page.
* Once loaded, the mirror implementation is called and results in this function call
*/
......@@ -64,7 +64,32 @@ window["registerMangaObject"] = async function (mirrorName, object) {
HandleKeys.init();
}
// TODO stats perso
// TODO context menu for bookmarks and bookmarks
// TODO stats perso --> v2.0.3
});
}
/** Function called through executeScript when context menu button invoked */
window["clickOnBM"] = function(src) {
let imgScan = $(".spanForImg img[src='" + src + "']");
if (imgScan.size() === 0) {
imgScan = $(".spanForImg img[src='" + decodeURI(src) + "']");
}
pageData.curbookmark.type = "scan";
pageData.curbookmark.scanUrl = src;
pageData.curbookmark.scanName = imgScan.data("idScan");
if (imgScan.data("note") !== undefined) {
$("#noteAMR").val(imgScan.data("note"));
} else {
$("#noteAMR").val("");
}
if (imgScan.data("booked")) {
$("#delBtnAMR").show();
} else {
$("#delBtnAMR").hide();
}
navigation.showDialog();
}
\ No newline at end of file
......@@ -66,9 +66,44 @@ a.buttonAMR:active {
font-family:Verdana!important;
}
#bookmarkPop {
display:none;
z-index:10000001;
.amr-modal {
display: none;
vertical-align: middle;
position: relative;
z-index: 10000001;
max-width: 500px;
box-sizing: border-box;
width: 90%;
background: #fff;
padding: 15px 30px;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
-o-border-radius: 8px;
-ms-border-radius: 8px;
border-radius: 8px;
-webkit-box-shadow: 0 0 10px #000;
-moz-box-shadow: 0 0 10px #000;
-o-box-shadow: 0 0 10px #000;
-ms-box-shadow: 0 0 10px #000;
box-shadow: 0 0 10px #000;
text-align: left;
color: black;
}
.amr-modal td {
color: black;
}
.amr-modal a.close-modal {
position: absolute;
top: -12.5px;
right: -12.5px;
display: block;
width: 30px;
height: 30px;
text-indent: -9999px;
background-size: contain;
background-repeat: no-repeat;
background-position: center center;
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAA3hJREFUaAXlm8+K00Acx7MiCIJH/yw+gA9g25O49SL4AO3Bp1jw5NvktC+wF88qevK4BU97EmzxUBCEolK/n5gp3W6TTJPfpNPNF37MNsl85/vN/DaTmU6PknC4K+pniqeKJ3k8UnkvDxXJzzy+q/yaxxeVHxW/FNHjgRSeKt4rFoplzaAuHHDBGR2eS9G54reirsmienDCTRt7xwsp+KAoEmt9nLaGitZxrBbPFNaGfPloGw2t4JVamSt8xYW6Dg1oCYo3Yv+rCGViV160oMkcd8SYKnYV1Nb1aEOjCe6L5ZOiLfF120EjWhuBu3YIZt1NQmujnk5F4MgOpURzLfAwOBSTmzp3fpDxuI/pabxpqOoz2r2HLAb0GMbZKlNV5/Hg9XJypguryA7lPF5KMdTZQzHjqxNPhWhzIuAruOl1eNqKEx1tSh5rfbxdw7mOxCq4qS68ZTjKS1YVvilu559vWvFHhh4rZrdyZ69Vmpgdj8fJbDZLJpNJ0uv1cnr/gjrUhQMuI+ANjyuwftQ0bbL6Erp0mM/ny8Fg4M3LtdRxgMtKl3jwmIHVxYXChFy94/Rmpa/pTbNUhstKV+4Rr8lLQ9KlUvJKLyG8yvQ2s9SBy1Jb7jV5a0yapfF6apaZLjLLcWtd4sNrmJUMHyM+1xibTjH82Zh01TNlhsrOhdKTe00uAzZQmN6+KW+sDa/JD2PSVQ873m29yf+1Q9VDzfEYlHi1G5LKBBWZbtEsHbFwb1oYDwr1ZiF/2bnCSg1OBE/pfr9/bWx26UxJL3ONPISOLKUvQza0LZUxSKyjpdTGa/vDEr25rddbMM0Q3O6Lx3rqFvU+x6UrRKQY7tyrZecmD9FODy8uLizTmilwNj0kraNcAJhOp5aGVwsAGD5VmJBrWWbJSgWT9zrzWepQF47RaGSiKfeGx6Szi3gzmX/HHbihwBser4B9UJYpFBNX4R6vTn3VQnez0SymnrHQMsRYGTr1dSk34ljRqS/EMd2pLQ8YBp3a1PLfcqCpo8gtHkZFHKkTX6fs3MY0blKnth66rKCnU0VRGu37ONrQaA4eZDFtWAu2fXj9zjFkxTBOo8F7t926gTp/83Kyzzcy2kZD6xiqxTYnHLRFm3vHiRSwNSjkz3hoIzo8lCKWUlg/YtGs7tObunDAZfpDLbfEI15zsEIY3U/x/gHHc/G1zltnAgAAAABJRU5ErkJggg==');
}
#simplemodal-overlay {
......
......@@ -237,7 +237,7 @@ class Navigation {
*/
async writeNavigation(where, select) {
//create bookmark popup
let div = $("<div id='bookmarkPop' style='display:none;position: static;padding: 20px!important;'></div>"),
let div = $("<div id='bookmarkPop' style='display:none;'></div>"),
btn = $("<a id='saveBtnAMR' class='buttonAMR'>" + i18n("button_save") + "</a>");
$("<h3>" + i18n("bookmark_popup_title") + "</h3>").appendTo(div);
$("<div id='descEltAMR'></div>").appendTo(div);
......@@ -480,7 +480,9 @@ class Navigation {
mirrorImpl.get().mirrorName);
}
$("#bookmarkPop #descEltAMR").text(textDesc);
$("#bookmarkPop").modal();
$("#bookmarkPop").modal({
modalClass: "amr-modal"
});
}
}
export default (new Navigation) // singleton
\ No newline at end of file
......@@ -238,31 +238,6 @@ class Reading {
divNum.appendTo($(img).closest(".spanForImg"));
}
clickOnBM(src) {
let imgScan = $(".spanForImg img[src='" + src + "']");
if (imgScan.size() === 0) {
imgScan = $(".spanForImg img[src='" + decodeURI(src) + "']");
}
pageData.curbookmark.type = "scan";
pageData.curbookmark.scanUrl = src;
pageData.curbookmark.scanName = imgScan.data("idScan");
if (imgScan.data("note") !== undefined) {
$("#noteAMR").val(imgScan.data("note"));
} else {
$("#noteAMR").val("");
}
if (imgScan.data("booked")) {
$("#delBtnAMR").show();
} else {
$("#delBtnAMR").hide();
}
$("#bookmarkPop").modal({ focus: false, onShow: this.showDialog, zIndex: 10000000 });
}
onErrorImage(img) {
let reading = this;
$(img).css("margin-bottom", "50px");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment