2017-05-31 15:28:47 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var require = (function() {
|
2021-12-15 22:28:41 +00:00
|
|
|
var win, cons, Zotero;
|
2018-02-24 09:54:53 +00:00
|
|
|
Components.utils.import('resource://zotero/loader.jsm');
|
2017-05-31 15:28:47 +00:00
|
|
|
var requirer = Module('/', '/');
|
|
|
|
var _runningTimers = {};
|
2019-01-21 09:01:04 +00:00
|
|
|
if (typeof window != 'undefined') {
|
|
|
|
win = window;
|
|
|
|
} else {
|
|
|
|
win = {};
|
2017-05-31 15:32:39 +00:00
|
|
|
|
2019-01-21 09:01:04 +00:00
|
|
|
win.setTimeout = function (func, ms) {
|
|
|
|
var id = Math.floor(Math.random() * (1000000000000 - 1)) + 1
|
|
|
|
var useMethodjit = Components.utils.methodjit;
|
|
|
|
var timer = Components.classes["@mozilla.org/timer;1"]
|
|
|
|
.createInstance(Components.interfaces.nsITimer);
|
|
|
|
timer.initWithCallback({"notify":function() {
|
|
|
|
// Remove timer from object so it can be garbage collected
|
|
|
|
delete _runningTimers[id];
|
|
|
|
|
|
|
|
// Execute callback function
|
|
|
|
try {
|
|
|
|
func();
|
|
|
|
} catch(err) {
|
|
|
|
// Rethrow errors that occur so that they appear in the error
|
|
|
|
// console with the appropriate name and line numbers. While the
|
|
|
|
// the errors appear without this, the line numbers get eaten.
|
|
|
|
var scriptError = Components.classes["@mozilla.org/scripterror;1"]
|
|
|
|
.createInstance(Components.interfaces.nsIScriptError);
|
|
|
|
scriptError.init(
|
|
|
|
err.message || err.toString(),
|
|
|
|
err.fileName || err.filename || null,
|
|
|
|
null,
|
|
|
|
err.lineNumber || null,
|
|
|
|
null,
|
|
|
|
scriptError.errorFlag,
|
|
|
|
'component javascript'
|
|
|
|
);
|
|
|
|
Components.classes["@mozilla.org/consoleservice;1"]
|
|
|
|
.getService(Components.interfaces.nsIConsoleService)
|
|
|
|
.logMessage(scriptError);
|
|
|
|
typeof Zotero !== 'undefined' && Zotero.debug(err.stack, 1);
|
|
|
|
}
|
|
|
|
}}, ms, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
|
|
|
|
_runningTimers[id] = timer;
|
|
|
|
return id;
|
|
|
|
};
|
|
|
|
|
|
|
|
win.clearTimeout = function (id) {
|
|
|
|
var timer = _runningTimers[id];
|
|
|
|
if (timer) {
|
|
|
|
timer.cancel();
|
2017-05-31 15:32:39 +00:00
|
|
|
}
|
2019-01-21 09:01:04 +00:00
|
|
|
delete _runningTimers[id];
|
|
|
|
};
|
2017-05-31 15:32:39 +00:00
|
|
|
|
2019-01-21 09:01:04 +00:00
|
|
|
win.debug = function (msg) {
|
|
|
|
dump(msg + "\n\n");
|
|
|
|
};
|
|
|
|
}
|
2017-05-22 23:10:03 +00:00
|
|
|
|
|
|
|
function getZotero() {
|
XUL -> JS tree megacommit
- Just a single huge commit. This has been developed over too long a
time, required many tiny changes across too many files and has seen too
many iterations to be separated into separate commits.
The original branch with all the messy commits will be kept around for
posterity
https://github.com/zotero/zotero/compare/bb220ad0f2d6bf0eca6df6d225d3d358cb50a27b...adomasven:feature/react-item-tree
- Replaces XUL <tree> element across the whole zotero client codebase
with a custom supermegafast virtualized-table inspired by
react-virtualized yet mimicking old XUL treeview API. The
virtualized-table sits on top on a raw-to-the-metal,
interpreted-at-runtime JS based windowing solution inspired by
react-window. React-based solutions could not be used because they were
slow and Zotero UI needs to be responsive and be able to
display thousands of rows in a treeview without any slowdowns.
- Attempts were made at making this screen-reader friendly, but yet to
be tested with something like JAWS
- RTL-friendly
- Styling and behaviour across all platforms was copied as closely as
possible to the original XUL tree
- Instead of row-based scroll snapping this has smooth-scrolling. If
you're using arrow keys to browse through the tree then it effectively
snap-scrolls. Current CSS snap scroll attributes do not seem to work in
the way we would require even on up-to-date browsers, yet alone the ESR
version of FX that Zotero is on. JS solutions are either terrible for
performance or produce inexcusable jitter.
- When dragging-and-dropping items the initial drag freezes the UI for
a fairly jarring amount of time. Does not seem to be fixable due to
the synchronous code that needs to be run in the dragstart handler.
Used to be possible to run that code async with the XUL tree.
- Item tree column picker no longer has a dedicated button. Just
right-click the columns. The column preferences (width, order, etc) are
no longer handled by XUL, which required a custom serialization and
storage solution that throws warnings in the developer console due to
the amount of data being stored. Might cause temporary freezing on HDDs
upon column resize/reorder/visibility toggling.
- Context menu handling code basically unchanged, but any UI changes
that plugins may have wanted to do (including adding new columns) will
have to be redone by them. No serious thought has gone into how plugin
developers would achieve that yet.
- Opens up the possibility for awesome alternative ways to render the
tree items, including things like multiple-row view for the item tree,
which has been requested for a long while especially by users switching
from other referencing software
2020-06-03 07:29:46 +00:00
|
|
|
if (win.Zotero) Zotero = win.Zotero;
|
|
|
|
|
2017-05-22 23:10:03 +00:00
|
|
|
if (typeof Zotero === 'undefined') {
|
|
|
|
try {
|
|
|
|
Zotero = Components.classes["@zotero.org/Zotero;1"]
|
|
|
|
.getService(Components.interfaces.nsISupports).wrappedJSObject;
|
|
|
|
} catch (e) {}
|
|
|
|
}
|
XUL -> JS tree megacommit
- Just a single huge commit. This has been developed over too long a
time, required many tiny changes across too many files and has seen too
many iterations to be separated into separate commits.
The original branch with all the messy commits will be kept around for
posterity
https://github.com/zotero/zotero/compare/bb220ad0f2d6bf0eca6df6d225d3d358cb50a27b...adomasven:feature/react-item-tree
- Replaces XUL <tree> element across the whole zotero client codebase
with a custom supermegafast virtualized-table inspired by
react-virtualized yet mimicking old XUL treeview API. The
virtualized-table sits on top on a raw-to-the-metal,
interpreted-at-runtime JS based windowing solution inspired by
react-window. React-based solutions could not be used because they were
slow and Zotero UI needs to be responsive and be able to
display thousands of rows in a treeview without any slowdowns.
- Attempts were made at making this screen-reader friendly, but yet to
be tested with something like JAWS
- RTL-friendly
- Styling and behaviour across all platforms was copied as closely as
possible to the original XUL tree
- Instead of row-based scroll snapping this has smooth-scrolling. If
you're using arrow keys to browse through the tree then it effectively
snap-scrolls. Current CSS snap scroll attributes do not seem to work in
the way we would require even on up-to-date browsers, yet alone the ESR
version of FX that Zotero is on. JS solutions are either terrible for
performance or produce inexcusable jitter.
- When dragging-and-dropping items the initial drag freezes the UI for
a fairly jarring amount of time. Does not seem to be fixable due to
the synchronous code that needs to be run in the dragstart handler.
Used to be possible to run that code async with the XUL tree.
- Item tree column picker no longer has a dedicated button. Just
right-click the columns. The column preferences (width, order, etc) are
no longer handled by XUL, which required a custom serialization and
storage solution that throws warnings in the developer console due to
the amount of data being stored. Might cause temporary freezing on HDDs
upon column resize/reorder/visibility toggling.
- Context menu handling code basically unchanged, but any UI changes
that plugins may have wanted to do (including adding new columns) will
have to be redone by them. No serious thought has gone into how plugin
developers would achieve that yet.
- Opens up the possibility for awesome alternative ways to render the
tree items, including things like multiple-row view for the item tree,
which has been requested for a long while especially by users switching
from other referencing software
2020-06-03 07:29:46 +00:00
|
|
|
return Zotero || {};
|
2017-05-22 23:10:03 +00:00
|
|
|
}
|
2017-05-31 15:28:47 +00:00
|
|
|
|
2019-01-21 09:01:04 +00:00
|
|
|
if (typeof win.console !== 'undefined') {
|
2017-05-22 23:10:03 +00:00
|
|
|
cons = console;
|
|
|
|
}
|
|
|
|
if (!cons) {
|
|
|
|
cons = {};
|
|
|
|
for (let key of ['log', 'warn', 'error']) {
|
|
|
|
cons[key] = text => {getZotero(); typeof Zotero !== 'undefined' && false && Zotero.debug(`console.${key}: ${text}`)};
|
|
|
|
}
|
|
|
|
}
|
2021-12-15 22:28:41 +00:00
|
|
|
if (!win.console) {
|
|
|
|
win.console = cons;
|
|
|
|
}
|
2017-05-22 23:10:03 +00:00
|
|
|
let globals = {
|
2019-01-21 09:01:04 +00:00
|
|
|
window: win,
|
|
|
|
document: typeof win.document !== 'undefined' && win.document || {},
|
2017-05-22 23:10:03 +00:00
|
|
|
console: cons,
|
2019-01-21 09:01:04 +00:00
|
|
|
navigator: typeof win.navigator !== 'undefined' && win.navigator || {},
|
2018-12-12 10:34:39 +00:00
|
|
|
setTimeout: win.setTimeout,
|
|
|
|
clearTimeout: win.clearTimeout,
|
XUL -> JS tree megacommit
- Just a single huge commit. This has been developed over too long a
time, required many tiny changes across too many files and has seen too
many iterations to be separated into separate commits.
The original branch with all the messy commits will be kept around for
posterity
https://github.com/zotero/zotero/compare/bb220ad0f2d6bf0eca6df6d225d3d358cb50a27b...adomasven:feature/react-item-tree
- Replaces XUL <tree> element across the whole zotero client codebase
with a custom supermegafast virtualized-table inspired by
react-virtualized yet mimicking old XUL treeview API. The
virtualized-table sits on top on a raw-to-the-metal,
interpreted-at-runtime JS based windowing solution inspired by
react-window. React-based solutions could not be used because they were
slow and Zotero UI needs to be responsive and be able to
display thousands of rows in a treeview without any slowdowns.
- Attempts were made at making this screen-reader friendly, but yet to
be tested with something like JAWS
- RTL-friendly
- Styling and behaviour across all platforms was copied as closely as
possible to the original XUL tree
- Instead of row-based scroll snapping this has smooth-scrolling. If
you're using arrow keys to browse through the tree then it effectively
snap-scrolls. Current CSS snap scroll attributes do not seem to work in
the way we would require even on up-to-date browsers, yet alone the ESR
version of FX that Zotero is on. JS solutions are either terrible for
performance or produce inexcusable jitter.
- When dragging-and-dropping items the initial drag freezes the UI for
a fairly jarring amount of time. Does not seem to be fixable due to
the synchronous code that needs to be run in the dragstart handler.
Used to be possible to run that code async with the XUL tree.
- Item tree column picker no longer has a dedicated button. Just
right-click the columns. The column preferences (width, order, etc) are
no longer handled by XUL, which required a custom serialization and
storage solution that throws warnings in the developer console due to
the amount of data being stored. Might cause temporary freezing on HDDs
upon column resize/reorder/visibility toggling.
- Context menu handling code basically unchanged, but any UI changes
that plugins may have wanted to do (including adding new columns) will
have to be redone by them. No serious thought has gone into how plugin
developers would achieve that yet.
- Opens up the possibility for awesome alternative ways to render the
tree items, including things like multiple-row view for the item tree,
which has been requested for a long while especially by users switching
from other referencing software
2020-06-03 07:29:46 +00:00
|
|
|
requestAnimationFrame: win.setTimeout,
|
2021-12-15 22:28:41 +00:00
|
|
|
cancelAnimationFrame: win.clearTimeout,
|
2024-03-30 11:18:57 +00:00
|
|
|
IOUtils: IOUtils,
|
|
|
|
PathUtils: PathUtils,
|
2021-12-15 22:28:41 +00:00
|
|
|
TextEncoder: TextEncoder,
|
|
|
|
TextDecoder: TextDecoder,
|
2017-05-22 23:10:03 +00:00
|
|
|
};
|
|
|
|
Object.defineProperty(globals, 'Zotero', { get: getZotero });
|
2017-05-31 15:28:47 +00:00
|
|
|
var loader = Loader({
|
|
|
|
id: 'zotero/require',
|
|
|
|
paths: {
|
|
|
|
'': 'resource://zotero/',
|
2019-11-08 08:40:20 +00:00
|
|
|
'containers/': 'chrome://zotero/content/containers/',
|
2019-08-24 08:23:43 +00:00
|
|
|
'components/': 'chrome://zotero/content/components/',
|
2021-04-14 07:15:44 +00:00
|
|
|
'zotero/': 'chrome://zotero/content/',
|
2017-05-31 15:28:47 +00:00
|
|
|
},
|
2017-05-22 23:10:03 +00:00
|
|
|
globals
|
2017-05-31 15:28:47 +00:00
|
|
|
});
|
2019-02-25 09:45:42 +00:00
|
|
|
let require = Require(loader, requirer);
|
XUL -> JS tree megacommit
- Just a single huge commit. This has been developed over too long a
time, required many tiny changes across too many files and has seen too
many iterations to be separated into separate commits.
The original branch with all the messy commits will be kept around for
posterity
https://github.com/zotero/zotero/compare/bb220ad0f2d6bf0eca6df6d225d3d358cb50a27b...adomasven:feature/react-item-tree
- Replaces XUL <tree> element across the whole zotero client codebase
with a custom supermegafast virtualized-table inspired by
react-virtualized yet mimicking old XUL treeview API. The
virtualized-table sits on top on a raw-to-the-metal,
interpreted-at-runtime JS based windowing solution inspired by
react-window. React-based solutions could not be used because they were
slow and Zotero UI needs to be responsive and be able to
display thousands of rows in a treeview without any slowdowns.
- Attempts were made at making this screen-reader friendly, but yet to
be tested with something like JAWS
- RTL-friendly
- Styling and behaviour across all platforms was copied as closely as
possible to the original XUL tree
- Instead of row-based scroll snapping this has smooth-scrolling. If
you're using arrow keys to browse through the tree then it effectively
snap-scrolls. Current CSS snap scroll attributes do not seem to work in
the way we would require even on up-to-date browsers, yet alone the ESR
version of FX that Zotero is on. JS solutions are either terrible for
performance or produce inexcusable jitter.
- When dragging-and-dropping items the initial drag freezes the UI for
a fairly jarring amount of time. Does not seem to be fixable due to
the synchronous code that needs to be run in the dragstart handler.
Used to be possible to run that code async with the XUL tree.
- Item tree column picker no longer has a dedicated button. Just
right-click the columns. The column preferences (width, order, etc) are
no longer handled by XUL, which required a custom serialization and
storage solution that throws warnings in the developer console due to
the amount of data being stored. Might cause temporary freezing on HDDs
upon column resize/reorder/visibility toggling.
- Context menu handling code basically unchanged, but any UI changes
that plugins may have wanted to do (including adding new columns) will
have to be redone by them. No serious thought has gone into how plugin
developers would achieve that yet.
- Opens up the possibility for awesome alternative ways to render the
tree items, including things like multiple-row view for the item tree,
which has been requested for a long while especially by users switching
from other referencing software
2020-06-03 07:29:46 +00:00
|
|
|
return require;
|
2019-01-21 09:01:04 +00:00
|
|
|
})();
|