fx-compat: Initial fix for Scaffold
Not working: - Web tests (hidden browser is broken) - Test Updated status text - Various platform menu things (code copied from ZP and will use whichever approach we settle on there)
This commit is contained in:
parent
1b324f9bd1
commit
e537018e71
11 changed files with 504 additions and 325 deletions
|
@ -24,12 +24,14 @@
|
|||
*/
|
||||
|
||||
var Scaffold_Load = new function() {
|
||||
this.onLoad = Zotero.Promise.coroutine(function* () {
|
||||
this.onLoad = async function () {
|
||||
document.addEventListener('dialogaccept', () => this.accept());
|
||||
|
||||
var listitem, translator, listcell, set;
|
||||
var listbox = document.getElementById("listbox");
|
||||
|
||||
listbox.addEventListener('dblclick', () => {
|
||||
var translatorID = document.getElementById("listbox").selectedItem.getUserData("zotero-id");
|
||||
var translatorID = document.getElementById("listbox").selectedItem.dataset.zoteroID;
|
||||
if (!translatorID) return;
|
||||
this.accept();
|
||||
window.close();
|
||||
|
@ -42,44 +44,48 @@ var Scaffold_Load = new function() {
|
|||
var url = window.arguments[0].url;
|
||||
var rootUrl = window.arguments[0].rootUrl
|
||||
url = Zotero.Proxies.proxyToProper(url);
|
||||
translators["Matching Translators"] = (yield translatorProvider.getWebTranslatorsForLocation(url, rootUrl))[0];
|
||||
translators["Web Translators"] = (yield translatorProvider.getAllForType("web"))
|
||||
translators["Matching Translators"] = (await translatorProvider.getWebTranslatorsForLocation(url, rootUrl))[0];
|
||||
translators["Web Translators"] = (await translatorProvider.getAllForType("web"))
|
||||
.sort((a, b) => a.label.localeCompare(b.label));
|
||||
translators["Import Translators"] = (yield translatorProvider.getAllForType("import"))
|
||||
translators["Import Translators"] = (await translatorProvider.getAllForType("import"))
|
||||
.sort((a, b) => a.label.localeCompare(b.label));
|
||||
translators["Export Translators"] = (yield translatorProvider.getAllForType("export"))
|
||||
translators["Export Translators"] = (await translatorProvider.getAllForType("export"))
|
||||
.sort((a, b) => a.label.localeCompare(b.label));
|
||||
translators["Search Translators"] = (yield translatorProvider.getAllForType("search"))
|
||||
translators["Search Translators"] = (await translatorProvider.getAllForType("search"))
|
||||
.sort((a, b) => a.label.localeCompare(b.label));
|
||||
|
||||
for (set in translators) {
|
||||
// Make a separator
|
||||
listitem = document.createElement("listitem");
|
||||
listitem = document.createXULElement("richlistitem");
|
||||
listitem.setAttribute("disabled", true);
|
||||
listitem.setAttribute("label", set);
|
||||
// Need to set this to disable up/down keys selecting:
|
||||
listitem.style.MozUserInput = 'none';
|
||||
listitem.append(set);
|
||||
listbox.appendChild(listitem);
|
||||
for (var j=0; j<translators[set].length; j++) {
|
||||
var translator = translators[set][j];
|
||||
listitem = document.createElement("listitem");
|
||||
// set label for type-to-find functionality. This is not displayed.
|
||||
listitem.setAttribute("label", translator.label);
|
||||
listitem = document.createXULElement("richlistitem");
|
||||
// set search label for type-to-find functionality. This is not displayed.
|
||||
listitem.searchLabel = translator.label;
|
||||
// And the ID goes in DOM user data
|
||||
listitem.setUserData("zotero-id", translator.translatorID, null);
|
||||
listitem.dataset.zoteroID = translator.translatorID;
|
||||
|
||||
listcell = document.createElement("listcell");
|
||||
listcell.setAttribute("label", translator.label);
|
||||
listcell = document.createXULElement("hbox");
|
||||
listcell.setAttribute('flex', '1');
|
||||
listcell.append(translator.label);
|
||||
listitem.appendChild(listcell);
|
||||
listcell = document.createElement("listcell");
|
||||
listcell.setAttribute("label", translator.creator);
|
||||
listcell = document.createXULElement("hbox");
|
||||
listcell.setAttribute('width', '130');
|
||||
listcell.append(translator.creator);
|
||||
listitem.appendChild(listcell);
|
||||
|
||||
listbox.appendChild(listitem);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.accept = function () {
|
||||
var translatorID = document.getElementById("listbox").selectedItem.getUserData("zotero-id");
|
||||
var translatorID = document.getElementById("listbox").selectedItem.dataset.zoteroID;
|
||||
var translator = window.arguments[0].translatorProvider.get(translatorID);
|
||||
|
||||
Zotero.debug(translatorID);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue