Skip to content

Commit

Permalink
Attempting to fix clash with popupdictinoary
Browse files Browse the repository at this point in the history
  • Loading branch information
chris360KS committed Jan 8, 2020
1 parent b655fa7 commit 7150eed
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
1 change: 1 addition & 0 deletions README.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@
- Disambiguation pages are not handled well
- Does not work with NightMode due to the way Night-Mode monkeypatches Reviewer.revHtml, see <a
href="https://github.com/krassowski/Anki-Night-Mode/issues/53">this github issue here</a>
- Currently does not play nicely with Popup Dictionary. Currently trying to figure this out!
</ul>
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,5 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
- Clicking on links inside the popup opens the browser, but with the wrong URL
- Disambiguation pages are not handled well
- Does not work with NightMode due to the way Night-Mode monkeypatches Reviewer.revHtml, see [this github issue here](https://github.com/krassowski/Anki-Night-Mode/issues/53)
- Currently does not play nicely with Popup Dictionary. Currently trying to figure this out!

2 changes: 1 addition & 1 deletion popup_wikipedia/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"popup_type": "mobile",
"popup_hotkey": "Ctrl+Shift+W",
"wiki_popup_hotkey": "Ctrl+Shift+W",
"wikipedia_lang": "en",
"exclude_list": "",
"cache_expire_after": 720
Expand Down
2 changes: 1 addition & 1 deletion popup_wikipedia/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Please note that the following settings do not sync and require a restart to apply:
- `popup_type` (string): Type of popup. 'mobile' for mobile, 'extract' for much shorter extract. Default: `"mobile"`
- `popup_hotkey` (string): Hotkey to invoke popup manually. Default: `"Ctrl+Shift+W"`
- `wiki_popup_hotkey` (string): Hotkey to invoke popup manually. Default: `"Ctrl+Shift+W"`
- `wikipedia_lang` (string): (UNUSED CURRENTLY) Language of wikipedia to use. Default `"en"`
- `exclude_list` (string): (Optional) (UNUSED CURRENTLY) Path to list of words to exclude from wikipedia lookups. Default `""` (empty)
- `cache_expire_after` (integer): Number of hours to store a cache of the wikipedia previews. Default: `720` hours (30 days)
2 changes: 1 addition & 1 deletion popup_wikipedia/reviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def wiki_hotkey() -> bool:

# noinspection PyPep8Naming
def setupShortcuts():
QShortcut(QKeySequence(config["local"]["popup_hotkey"]),
QShortcut(QKeySequence(config["local"]["wiki_popup_hotkey"]),
mw, activated=wiki_hotkey)


Expand Down
20 changes: 10 additions & 10 deletions popup_wikipedia/web/wiki_popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ console.log("wiki_popup.js loaded");
// Create the tooltips only when document ready
$(document).ready(function () {

function createTooltip(element) {
function createWikiTooltip(element) {
// Creates tooltip on specified DOM element, sets up mouse click events
// and child tooltips, returns tooltip API object


// create qtip on Anki qa div and assign its api object to 'tooltip'
let tooltip = $(element).qtip({
let wikiTooltip = $(element).qtip({
content: {
text: "Loading..."
},
Expand Down Expand Up @@ -59,15 +59,15 @@ $(document).ready(function () {
// if (clicks === 2) {
// event.stopImmediatePropagation();
// $(document).one("mouseup", function (event) {
// showTooltip(event, tooltip, element);
// showWikiTooltip(event, tooltip, element);
// clicks = 0;
// });
// } else {
// tooltip.hide();
// }
// });

return tooltip;
return wikiTooltip;
}

getSelected = function () {
Expand All @@ -82,15 +82,15 @@ $(document).ready(function () {
let ttBoundElm = $(selElm).closest(".qtip-content");
if (typeof ttBoundElm[0] === "undefined") {
ttBoundElm = document.getElementById("qa");
tooltip = qaTooltip;
tooltip = qaWikiTooltip;
} else {
tooltip = ttBoundElm.qtip("api");
}
showTooltip(event, tooltip, ttBoundElm);
showWikiTooltip(event, tooltip, ttBoundElm);
};

// Look up selected text and show result in provided tooltip
showTooltip = function (event, tooltip, element) {
showWikiTooltip = function (event, tooltip, element) {
/* event: event that triggered function call
tooltip: qtip api object of tooltip to use for showing results
element: element that tooltip is bound to */
Expand Down Expand Up @@ -147,7 +147,7 @@ $(document).ready(function () {
if ($(newdomID).length === 0) {
// Bind new qtip instance to content of current tooltip
console.log("Create new tooltip on ID: " + domID + ". Tooltip will have ID: " + newdomID);
createTooltip(domID + "-content");
createWikiTooltip(domID + "-content");
} else {
// Reuse existing qtip instance
console.log("Found existing tooltip with ID: " + newdomID)
Expand All @@ -162,8 +162,8 @@ $(document).ready(function () {
return;
}
event.stopImmediatePropagation();
qaTooltip.hide();
qaWikiTooltip.hide();
});

qaTooltip = createTooltip("#qa");
qaWikiTooltip = createWikiTooltip("#qa");
});

0 comments on commit 7150eed

Please sign in to comment.