Compare commits

...

No commits in common. "ci" and "electron" have entirely different histories.
ci ... electron

1490 changed files with 317299 additions and 114 deletions

28
.babelrc Normal file
View file

@ -0,0 +1,28 @@
{
"compact": false,
"retainLines": true,
"presets": [],
"ignore": [
"resource/require.js",
"chrome/content/zotero/include.js",
"chrome/content/zotero/xpcom/citeproc.js",
"resource/csl-validator.js",
"resource/jspath.js",
"resource/react.js",
"resource/react-dom.js",
"resource/bluebird.js",
"resource/bluebird/*.js",
"test/resource/*.js"
],
"plugins": [
"syntax-jsx",
"transform-react-jsx",
"transform-react-display-name",
[
"transform-es2015-modules-commonjs",
{
"strictMode": false
}
]
]
}

View file

@ -1,64 +0,0 @@
on:
workflow_dispatch:
inputs:
ref_name:
description: 'Tag or commit'
required: true
type: string
push:
tags:
- '*'
jobs:
build-tarball:
name: Build tarball w/ submodules
runs-on: x86_64
container:
image: alpine:latest
env:
CI_PROJECT_NAME: zotero
steps:
- name: Environment setup
run: apk add nodejs git git-archive-all gzip
- name: Repo pull
uses: actions/checkout@v4
with:
fetch-depth: 500
ref: ${{ inputs.ref_name }}
- name: Package build
run: |
if test $GITHUB_REF_NAME == "ci" ; then
CI_REF_NAME=${{ inputs.ref_name }}
else
CI_REF_NAME=$GITHUB_REF_NAME
fi
echo "building tarball for $CI_REF_NAME"
git-archive-all --force-submodules $CI_PROJECT_NAME-$CI_REF_NAME.tar.gz
echo "Generating sha512sum"
sha512sum $CI_PROJECT_NAME-$CI_REF_NAME.tar.gz > $CI_PROJECT_NAME-$CI_REF_NAME.tar.gz.sha512sum
- name: Package upload
uses: forgejo/upload-artifact@v3
with:
name: tarball
path: zotero-*.tar*
upload-tarball:
name: Upload to generic repo
runs-on: x86_64
needs: [build-tarball]
container:
image: alpine:latest
steps:
- name: Environment setup
run: apk add nodejs curl
- name: Package download
uses: forgejo/download-artifact@v3
- name: Package deployment
run: |
if test $GITHUB_REF_NAME == "ci" ; then
CI_REF_NAME=${{ inputs.ref_name }}
else
CI_REF_NAME=$GITHUB_REF_NAME
fi
curl --user ${{ vars.CODE_FORGEJO_USER }}:${{ secrets.CODE_FORGEJO_TOKEN }} --upload-file ./tarball/zotero-*.tar.gz ${{ github.server_url }}/api/packages/mirrors/generic/zotero/$CI_REF_NAME/zotero-$CI_REF_NAME.tar.gz
curl --user ${{ vars.CODE_FORGEJO_USER }}:${{ secrets.CODE_FORGEJO_TOKEN }} --upload-file ./tarball/zotero-*.tar.gz.sha512sum ${{ github.server_url }}/api/packages/mirrors/generic/zotero/$CI_REF_NAME/zotero-$CI_REF_NAME.tar.gz.sha512sum

View file

@ -1,50 +0,0 @@
on:
workflow_dispatch:
schedule:
- cron: '@hourly'
jobs:
mirror:
name: Pull from upstream
runs-on: x86_64
container:
image: alpine:latest
env:
upstream: https://github.com/zotero/zotero
tags: '7.*'
steps:
- name: Environment setup
run: apk add grep git sed coreutils bash nodejs
- name: Fetch destination
uses: actions/checkout@v4
with:
fetch_depth: 1
ref: ci
token: ${{ secrets.CODE_FORGEJO_TOKEN }}
- name: Missing tag detecting
run: |
git ls-remote $upstream "refs/tags/$tags" | grep -v '{' | sed 's|.*/||' > upstream_tags
git ls-remote ${{ github.server_url}}/${{ github.repository }} "refs/tags/$tags" | grep -v '{' | sed 's|.*/||' > destination_tags
cat upstream_tags destination_tags | tr ' ' '\n' | sort | uniq -u > missing_tags
echo "Missing tags:"
cat missing_tags
- name: Missing tag fetch
run: |
git remote add upstream $upstream
while read tag; do
git fetch upstream tag $tag --no-tags
done < missing_tags
- name: Packaging workflow injection
run: |
while read tag; do
git checkout $tag
git tag -d $tag
git checkout ci -- ./.forgejo
git config user.name "forgejo-actions[bot]"
git config user.email "dev@ayakael.net"
git commit -m 'Inject custom workflow'
git tag -a $tag -m $tag
done < missing_tags
- name: Push to destination
run: git push --force origin refs/tags/*:refs/tags/* --tags

1
.gitattributes vendored Normal file
View file

@ -0,0 +1 @@
*.sql text eol=lf

5
.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
.DS_Store
node_modules
build
.signatures.json
tmp

24
.gitmodules vendored Normal file
View file

@ -0,0 +1,24 @@
[submodule "translators"]
path = translators
url = git://github.com/zotero/translators.git
branch = master
[submodule "chrome/content/zotero/locale/csl"]
path = chrome/content/zotero/locale/csl
url = git://github.com/citation-style-language/locales.git
branch = master
[submodule "styles"]
path = styles
url = git://github.com/zotero/bundled-styles.git
branch = master
[submodule "test/resource/chai"]
path = test/resource/chai
url = https://github.com/chaijs/chai.git
branch = master
[submodule "test/resource/mocha"]
path = test/resource/mocha
url = https://github.com/mochajs/mocha.git
branch = master
[submodule "test/resource/chai-as-promised"]
path = test/resource/chai-as-promised
url = https://github.com/domenic/chai-as-promised.git
branch = master

54
.travis.yml Normal file
View file

@ -0,0 +1,54 @@
sudo: false
language: node_js
node_js:
- "8"
cache:
directories:
- "build"
- "node_modules"
env:
global:
secure: "NxvkbZ7/Op7BTGQRR3C4q8lLoO29f8WtyNN27NSH7AO3H0vBr1Vp5xO8gn+H2qHEug5HvM+YrZ/xAkNXaZVbOInmBmKVMxqVvdpKp9JM1Amf+gzsXWQphfySvs6iqzyP6cwU/jspdvX/WSakgU5v7PWXxtUIaKxdANt6Rw7W+Pc="
matrix:
- FX_VERSION="52.0.3"
matrix:
fast_finish: true
#allow_failures:
# - env: FX_CHANNEL="beta"
notifications:
email: false
addons:
apt:
packages:
- dbus-x11
install:
- if [ $FX_VERSION = "52.0.3" ]; then
wget -O tarball "https://archive.mozilla.org/pub/firefox/tinderbox-builds/mozilla-release-linux64-add-on-devel/1491732920/firefox-52.0.3.en-US.linux-x86_64-add-on-devel.tar.bz2";
fi
- tar xf tarball
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- npm i
- npm run build
- if [[ $TRAVIS_REPO_SLUG = "zotero/zotero" &&
($TRAVIS_BRANCH = "master" || $TRAVIS_BRANCH = *-hotfix) &&
$TRAVIS_PULL_REQUEST = "false" ]]; then
mkdir build-zip;
cd build;
zip -r ../build-zip/$TRAVIS_COMMIT.zip *;
cd ..;
gem install dpl;
dpl --provider=s3
--access-key-id=AKIAJFDVJ54MCAEXPQ5Q
--bucket=zotero-download
--local-dir=build-zip
--upload-dir=ci/client
--acl=public-read
--skip_cleanup=true;
fi
- unset AWS_SECRET_ACCESS_KEY
# Fix warnings in output
- dbus-launch
script:
- test/runtests.sh -x firefox/firefox -f

11
CONTRIBUTING.md Normal file
View file

@ -0,0 +1,11 @@
# Contributing to Zotero
## Bug Reports and Feature Requests
Zotero does not use GitHub Issues for bug reports or feature requests. Please post all such requests to the [Zotero Forums](https://forums.zotero.org), where Zotero developers and many others can help. Keeping product discussions in the Zotero Forums allows the entire Zotero community to participate, including domain experts that can address many questions better than Zotero developers.
For confirmed bugs or agreed-upon changes, Zotero developers will create new issues in the relevant repositories.
## Working with Zotero Code
See [Zotero Source Code](https://www.zotero.org/support/dev/source_code).

681
COPYING Normal file
View file

@ -0,0 +1,681 @@
Zotero is Copyright © 2018 Corporation for Digital Scholarship,
Vienna, Virginia, USA http://digitalscholar.org
Copyright © 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017
Roy Rosenzweig Center for History and New Media, George Mason University,
Fairfax, Virginia, USA http://zotero.org
The Corporation for Digital Scholarship distributes the Zotero source code
under the GNU Affero General Public License, version 3 (AGPLv3). The full text
of this license is given below.
The Zotero name is a registered trademark of the Corporation for Digital Scholarship.
See http://zotero.org/trademark for more information.
Third-party copyright in this distribution is noted where applicable.
All rights not expressly granted are reserved.
=========================================================================
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.

9
README.md Normal file
View file

@ -0,0 +1,9 @@
Zotero
======
[![Build Status](https://travis-ci.org/zotero/zotero.svg?branch=master)](https://travis-ci.org/zotero/zotero)
[Zotero](https://www.zotero.org/) is a free, easy-to-use tool to help you collect, organize, cite, and share your research sources.
Please post feature requests or bug reports to the [Zotero Forums](https://forums.zotero.org/). If you're having trouble with Zotero, see [Getting Help](https://www.zotero.org/support/getting_help).
For more information on how to use this source code, see the [Zotero wiki](https://www.zotero.org/support/dev/source_code).

73
chrome.manifest Normal file
View file

@ -0,0 +1,73 @@
content zotero chrome/content/zotero/
content zotero-platform chrome/content/zotero-platform/mac/ os=Darwin
content zotero-platform chrome/content/zotero-platform/win/ os=WINNT
content zotero-platform chrome/content/zotero-platform/unix/ os=Linux
content zotero-platform chrome/content/zotero-platform/unix/ os=SunOS
content zotero-platform chrome/content/zotero-platform/unix/ os=FreeBSD
content zotero-platform chrome/content/zotero-platform/unix/ os=OpenBSD
resource zotero resource/
locale zotero en-US chrome/locale/en-US/zotero/
#locale zotero af-ZA chrome/locale/af-ZA/zotero/
locale zotero ar chrome/locale/ar/zotero/
locale zotero bg-BG chrome/locale/bg-BG/zotero/
locale zotero ca-AD chrome/locale/ca-AD/zotero/
locale zotero cs-CZ chrome/locale/cs-CZ/zotero/
locale zotero da-DK chrome/locale/da-DK/zotero/
locale zotero de chrome/locale/de/zotero/
#locale zotero el-GR chrome/locale/el-GR/zotero/
locale zotero es-ES chrome/locale/es-ES/zotero/
locale zotero et-EE chrome/locale/et-EE/zotero/
#locale zotero eu-ES chrome/locale/eu-ES/zotero/
locale zotero fa chrome/locale/fa/zotero/
locale zotero fi-FI chrome/locale/fi-FI/zotero/
locale zotero fr-FR chrome/locale/fr-FR/zotero/
locale zotero gl-ES chrome/locale/gl-ES/zotero/
#locale zotero he-IL chrome/locale/he-IL/zotero/
#locale zotero hr-HR chrome/locale/hr-HR/zotero/
locale zotero hu-HU chrome/locale/hu-HU/zotero/
locale zotero id-ID chrome/locale/id-ID/zotero/
locale zotero is-IS chrome/locale/is-IS/zotero/
locale zotero it-IT chrome/locale/it-IT/zotero/
locale zotero ja-JP chrome/locale/ja-JP/zotero/
locale zotero km chrome/locale/km/zotero/
locale zotero ko-KR chrome/locale/ko-KR/zotero/
locale zotero lt-LT chrome/locale/lt-LT/zotero/
#locale zotero mn-MN chrome/locale/mn-MN/zotero/
#locale zotero nb-NO chrome/locale/nb-NO/zotero/
#locale zotero nn-NO chrome/locale/nn-NO/zotero/
locale zotero nl-NL chrome/locale/nl-NL/zotero/
locale zotero pl-PL chrome/locale/pl-PL/zotero/
locale zotero pt-BR chrome/locale/pt-BR/zotero/
locale zotero pt-PT chrome/locale/pt-PT/zotero/
locale zotero ro-RO chrome/locale/ro-RO/zotero/
locale zotero ru-RU chrome/locale/ru-RU/zotero/
locale zotero sk-SK chrome/locale/sk-SK/zotero/
locale zotero sl-SI chrome/locale/sl-SI/zotero/
locale zotero sr-RS chrome/locale/sr-RS/zotero/
locale zotero sv-SE chrome/locale/sv-SE/zotero/
locale zotero th-TH chrome/locale/th-TH/zotero/
locale zotero tr-TR chrome/locale/tr-TR/zotero/
locale zotero uk-UA chrome/locale/uk-UA/zotero/
locale zotero vi-VN chrome/locale/vi-VN/zotero/
locale zotero zh-CN chrome/locale/zh-CN/zotero/
locale zotero zh-TW chrome/locale/zh-TW/zotero/
skin zotero default chrome/skin/default/zotero/
overlay chrome://browser/content/browser.xul chrome://zotero/content/overlay.xul
style chrome://browser/content/browser.xul chrome://zotero/skin/zotero.css
component {e4c61080-ec2d-11da-8ad9-0800200c9a66} components/zotero-service.js
component {531828f8-a16c-46be-b9aa-14845c3b010f} components/zotero-service.js
contract @zotero.org/Zotero;1 {e4c61080-ec2d-11da-8ad9-0800200c9a66}
contract @mozilla.org/commandlinehandler/general-startup;1?type=zotero {531828f8-a16c-46be-b9aa-14845c3b010f}
category command-line-handler m-zotero @mozilla.org/commandlinehandler/general-startup;1?type=zotero
component {06a2ed11-d0a4-4ff0-a56f-a44545eee6ea} components/zotero-autocomplete.js
contract @mozilla.org/autocomplete/search;1?name=zotero {06a2ed11-d0a4-4ff0-a56f-a44545eee6ea}
component {9BC3D762-9038-486A-9D70-C997AF848A7C} components/zotero-protocol-handler.js
contract @mozilla.org/network/protocol;1?name=zotero {9BC3D762-9038-486A-9D70-C997AF848A7C}

View file

@ -0,0 +1,4 @@
row > label:first-child
{
color: #7f7f7f;
}

View file

@ -0,0 +1,106 @@
body {
line-height: 1.45em;
font-size: 15px;
}
body[multiline="true"] {
line-height: 26px;
}
#quick-format-dialog {
background: transparent;
-moz-appearance: none;
padding: 0;
width: 800px;
}
#quick-format-dialog.progress-bar #quick-format-deck {
height: 37px;
}
#quick-format-search {
background: white;
-moz-appearance: searchfield;
}
#quick-format-search[multiline="true"] {
padding: 2px 2px 0 19.5px;
margin: 2.5px 3.5px;
border: 1px solid rgba(0, 0, 0, 0.5);
-moz-appearance: none;
}
#quick-format-search:not([multiline="true"]) {
padding-top: 4.5px;
height: 37px !important;
}
#quick-format-entry {
background: -moz-linear-gradient(-90deg, rgb(243,123,119) 0, rgb(180,47,38) 50%, rgb(156,36,27) 50%);
padding: 12px;
}
#zotero-icon {
margin: -2.5px 0 3px -6px;
}
#quick-format-search[multiline="true"] #zotero-icon {
margin: 0 0 1px -13px;
}
#citation-properties menulist {
-moz-appearance: none; color: #fff;
text-shadow: 0 -1px 0 rgba(0,0,0,.5);
border-radius: 12px;
border: 1px solid rgba(0,0,0,.65);
background: -moz-linear-gradient(rgba(110,110,110,.9), rgba(70,70,70,.9) 49%, rgba(50,50,50,.9) 51%, rgba(40,40,40,.9));
box-shadow: inset 0 1px 0 rgba(255,255,255,.2), inset 0 0 1px rgba(255,255,255,.1), 0 1px 0 rgba(255,255,255,.1);
background-clip: padding-box;
background-origin: padding-box;
padding: 2px 9px;
border-radius: 3px;
min-height: 22px;
-moz-padding-start: 4px;
-moz-padding-end: 0;
}
#citation-properties menulist:-moz-focusring {
box-shadow: 0 0 1px -moz-mac-focusring inset, 0 0 4px 1px -moz-mac-focusring, 0 0 2px 1px -moz-mac-focusring;
}
#citation-properties menulist[open="true"],
#citation-properties menulist:hover:active {
background: -moz-linear-gradient(rgba(40,40,40,.9), rgba(70,70,70,.9));
box-shadow: inset 0 0 3px rgba(0,0,0,.2), inset 0 1px 7px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.1);
}
#citation-properties menulist > .menulist-dropmarker {
-moz-appearance: none;
display: -moz-box;
background-color: transparent;
border: 0;
margin: 0;
padding: 0;
}
#citation-properties menulist > .menulist-dropmarker > .dropmarker-icon {
list-style-image: url("chrome://browser/skin/hud-style-dropmarker-double-arrows.png");
}
panel button {
-moz-appearance: none; color: #fff; text-shadow: 0 -1px 0 rgba(0,0,0,.5); border-radius: 12px; border: 1px solid rgba(0,0,0,.65); background: -moz-linear-gradient(rgba(110,110,110,.9), rgba(70,70,70,.9) 49%, rgba(50,50,50,.9) 51%, rgba(40,40,40,.9)); box-shadow: inset 0 1px 0 rgba(255,255,255,.2), inset 0 0 1px rgba(255,255,255,.1), 0 1px 0 rgba(255,255,255,.1); background-clip: padding-box; background-origin: padding-box; padding: 2px 9px;
margin: 6px;
min-height: 22px;
}
panel button:hover:active {
background: -moz-linear-gradient(rgba(40,40,40,.9), rgba(70,70,70,.9)); box-shadow: inset 0 0 3px rgba(0,0,0,.2), inset 0 1px 7px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.1);
}
panel button:-moz-focusring {
box-shadow: 0 0 1px -moz-mac-focusring inset, 0 0 4px 1px -moz-mac-focusring, 0 0 2px 1px -moz-mac-focusring;
}
.quick-format-bubble {
padding: 1px 6px 1px 6px;
}

View file

@ -0,0 +1,9 @@
#zotero-feed-item-addTo-button {
margin: 5px 6px 3px;
padding-left: 8px;
}
#zotero-feed-item-addTo-button button {
margin: 0;
-moz-appearance: none;
}

View file

@ -0,0 +1,38 @@
scrollbox
{
padding-top: 3px;
}
row > label:first-child, .creator-type-label, #more-creators-label
{
color: #7f7f7f;
}
.zotero-field-toggle .toolbarbutton-text
{
visibility: hidden;
}
.zotero-field-toggle .toolbarbutton-icon
{
margin: 0px !important;
}
.creator-type-label > image {
margin: 1px .2em 1px;
list-style-image: url('chrome://zotero/skin/mac/arrow-down.png');
max-width: 7px;
max-height: 7px;
}
textbox
{
margin: -1px 5px -1px 0;
padding: 0;
}
/* BEGIN 2X BLOCK -- DO NOT EDIT MANUALLY -- USE 2XIZE */
@media (min-resolution: 1.25dppx) {
.creator-type-label > image { list-style-image: url('chrome://zotero/skin/mac/arrow-down@2x.png'); }
}

View file

@ -0,0 +1,8 @@
row > label:first-child
{
color: #7f7f7f;
}
textbox[type="styled"] {
border-style: none;
}

View file

@ -0,0 +1,409 @@
#zotero-splitter
{
border-top: none;
border-bottom: 1px solid #A3A3A3;
min-height: 1px !important;
max-height: 1px !important;
background-image: none;
}
#zotero-items-toolbar[state=collapsed]
{
margin-left: -8px !important;
}
#zotero-pane toolbarseparator {
margin-left: 7px;
}
#zotero-tb-sync-stop .toolbarbutton-icon,
#zotero-tb-sync-error .toolbarbutton-icon {
width: 16px;
}
.zotero-tb-button > .toolbarbutton-icon {
max-width: 31px;
}
.zotero-tb-button,
.zotero-tb-button:first-child,
.zotero-tb-button:last-child {
-moz-margin-start: 0 !important;
-moz-margin-end: 3px !important;
-moz-padding-end: 10px !important;
background: url("chrome://zotero/skin/mac/menubutton-end.png") right center/auto 24px no-repeat;
}
.zotero-tb-button[type=menu] {
-moz-padding-end: 8px !important;
}
.zotero-tb-button > .toolbarbutton-icon {
background: url("chrome://zotero/skin/mac/menubutton-start.png") left center/auto 24px no-repeat;
padding: 4px 4px 4px 11px;
}
/* For menu buttons, decrease left padding by 1px */
.zotero-tb-button[type=menu] > .toolbarbutton-icon {
-moz-padding-start: 9px;
max-width: 29px;
}
#zotero-collections-toolbar {
padding-left: 0;
}
.zotero-tb-button:-moz-window-inactive {
opacity: 0.5;
}
.zotero-tb-button:-moz-window-inactive > .toolbarbutton-icon {
background: url("chrome://zotero/skin/mac/menubutton-start-inactive-window.png") left center/auto 24px no-repeat;
}
/* Use a darker background when inactive so the button itself doesn't get too dark at 50% */
.zotero-tb-button:-moz-window-inactive,
.zotero-tb-button:-moz-window-inactive:first-child,
.zotero-tb-button:-moz-window-inactive:last-child {
background: url("chrome://zotero/skin/mac/menubutton-end-inactive-window.png") right center/auto 24px no-repeat;
}
.zotero-tb-button[open="true"],
.zotero-tb-button:not([disabled="true"]):hover:active {
background: url("chrome://zotero/skin/mac/menubutton-end-pressed.png") right center/auto 24px no-repeat;
}
.zotero-tb-button > menupopup {
-moz-margin-start: 2px;
margin-top: -4px;
}
#zotero-tb-search-menu-button {
margin: -6px 0 -6px -16px;
padding: 6px 0 6px 15px;
}
#zotero-tb-sync > .toolbarbutton-icon {
-moz-padding-start: 8px;
padding-top: 1px;
}
#zotero-tb-sync-error[error=true]
{
margin-bottom: 2px;
}
.zotero-tb-button[open="true"] > .toolbarbutton-icon,
.zotero-tb-button:not([disabled="true"]):hover:active > .toolbarbutton-icon {
background: url("chrome://zotero/skin/mac/menubutton-start-pressed.png") left center/auto 24px no-repeat;
}
.zotero-tb-button > .toolbarbutton-text {
display: none;
}
#zotero-tb-sync > .toolbarbutton-icon {
-moz-binding: none !important;
padding: 2px 0px 2px 8px !important;
}
#zotero-close-button {
margin: 0px !important;
padding: 0px 0px 0px 10px !important;
}
#zotero-tb-sync {
margin: 0;
}
#zotero-view-tabbox {
background-color: #fff;
padding: 0;
}
#zotero-item-pane-content .groupbox-body {
-moz-appearance: none;
background-color: #ffffff;
}
#zotero-item-pane-message-box description {
color: #7f7f7f;
}
#zotero-view-tabbox > tabpanels {
margin: 12px 0 0 0;
padding: 0;
-moz-appearance: none;
}
#zotero-view-tabbox > tabs {
-moz-appearance: none;
background: -moz-linear-gradient(top, #ededed, #cccccc);
border-style: solid;
border-width: 0 0 1px 0;
border-color: #bdbdbd;
padding: 2px 0 2px 0;
}
#zotero-view-tabbox > tabs > tab > hbox {
padding: 0;
}
#zotero-view-tabbox > tabs > tab > hbox > .tab-icon {
display: none;
}
#zotero-pane #zotero-view-tabbox > tabs > tab {
-moz-box-orient: vertical;
-moz-box-align: center;
-moz-appearance: toolbarbutton;
text-align: center;
margin: 0;
padding: 3px 1px 3px 1px;
}
#zotero-pane #zotero-view-tabbox > tabs > tab > hbox .tab-text {
font-size: 11px;
font-weight: bold;
margin: 2px 7px 2px 9px !important;
text-shadow: 0 1px rgba(255, 255, 255, .4);
}
/* This seems to be necessary to center the tabs. Not sure why. */
#zotero-pane #zotero-view-tabbox > tabs > tab:last-of-type > hbox .tab-text {
margin: 2px 9px 2px 9px !important;
}
#zotero-pane #zotero-view-tabbox > tabs > tab[selected=true] > hbox .tab-text {
color: #FFF !important;
text-shadow: rgba(0, 0, 0, 0.4) 0 1px;
}
#zotero-collections-tree {
-moz-appearance: none;
border: none;
margin: 0;
padding: 0;
min-height: 5.2em;
background-color: #d2d8e2;
}
#zotero-collections-tree:-moz-window-inactive {
background-color: rgb(232, 232, 232);
}
#zotero-collections-tree treechildren::-moz-tree-row {
background-color: transparent;
border-color: transparent;
}
#zotero-collections-tree treechildren::-moz-tree-cell(selected) {
background: -moz-linear-gradient(top, #A0B0CF, #7386AB) repeat-x;
border-top: 1px solid #94A1C0;
}
#zotero-collections-tree:-moz-window-inactive treechildren::-moz-tree-cell(selected) {
background: -moz-linear-gradient(top, #B4B4B4, #8A8A8A) repeat-x;
border-top: 1px solid #979797;
}
#zotero-collections-tree treechildren::-moz-tree-cell(selected, focus) {
background: -moz-linear-gradient(top, #6494D4, #2559AC) repeat-x;
border-top: 1px solid #5382C5;
}
#zotero-collections-tree treechildren::-moz-tree-cell-text(selected) {
font-weight: bold !important;
color: #ffffff !important;
}
#zotero-collections-tree treechildren::-moz-tree-twisty(selected) {
list-style-image: url("chrome://zotero/skin/mac/twisty-selected.svg");
}
#zotero-collections-tree treechildren::-moz-tree-twisty(selected, open) {
list-style-image: url("chrome://zotero/skin/mac/twisty-selected-open.svg");
}
#zotero-collections-splitter:not([state=collapsed]),
#zotero-items-splitter:not([state=collapsed])[orient=horizontal]
{
-moz-appearance: none;
border-inline-start: 1px solid #bdbdbd;
margin-inline-end: -4px;
width: 5px !important;
min-width: 5px;
position: relative;
background-image: none;
}
#zotero-items-splitter[orient=vertical]
{
-moz-border-start: none !important;
-moz-border-end: none !important;
background-color: #bdbdbd !important;
max-height: 1px !important;
min-height: 1px !important;
height: 1px !important;
}
#zotero-collections-splitter:not([state=collapsed]) > grippy,
#zotero-items-splitter:not([state=collapsed]) > grippy
{
display: none;
}
#zotero-collections-splitter[state=collapsed], #zotero-items-splitter[state=collapsed] {
border: 0 solid #d6d6d6 !important;
padding: 0;
}
#zotero-collections-splitter[state=collapsed], #zotero-items-splitter[state=collapsed][orient=horizontal]
{
background-image: url("chrome://zotero/skin/mac/vsplitter.png");
background-repeat: repeat-y;
max-width: 8px !important;
min-width: 8px !important;
width: 8px !important;
}
#zotero-items-splitter[state=collapsed][orient=vertical]
{
background-image: url("chrome://zotero/skin/mac/hsplitter.png");
background-repeat: repeat-x;
max-height: 8px !important;
min-height: 8px !important;
height: 8px !important;
}
#zotero-collections-splitter[state=collapsed] {
border-right-width: 1px !important;
}
#zotero-items-splitter[state=collapsed] {
border-left-width: 1px !important;
}
#zotero-collections-splitter[state=collapsed] > grippy, #zotero-items-splitter[state=collapsed] > grippy
{
-moz-appearance: none;
background: url(chrome://zotero/skin/mac/vgrippy.png) center/auto 8px no-repeat;
width: 8px;
}
#zotero-tags-splitter
{
-moz-appearance: none;
border-top: 1px;
border-bottom: 1px;
border-color: #A5A5A5;
height: 8px;
background-image: url("chrome://zotero/skin/mac/hsplitter.png") !important;
background-repeat: repeat-x;
padding: 0;
}
#zotero-tags-splitter > grippy
{
-moz-appearance: none;
background: url(chrome://zotero/skin/mac/hgrippy.png) center/auto 8px no-repeat;
height: 8px;
}
#zotero-tags-splitter > grippy:hover, #zotero-collections-splitter > grippy:hover, #zotero-items-splitter > grippy:hover
{
background-color:transparent;
}
#zotero-items-tree
{
-moz-appearance: none;
border: none;
margin: 0;
padding: 0;
}
#zotero-items-tree treechildren::-moz-tree-cell,
#zotero-items-tree treechildren::-moz-tree-column {
border-right: 1px solid #d7dad7;
}
treechildren::-moz-tree-twisty {
-moz-appearance: none;
width: 16px;
height: 16px;
list-style-image: url("chrome://zotero/skin/mac/twisty.svg");
-moz-padding-start: 5px;
-moz-padding-end: 6px;
}
treechildren::-moz-tree-twisty(open) {
-moz-appearance: none;
width: 16px;
height: 16px;
list-style-image: url("chrome://zotero/skin/mac/twisty-open.svg");
-moz-padding-start: 4px;
-moz-padding-end: 7px;
}
/* How to get active twisty?
treechildren::-moz-tree-twisty(active) {
-moz-appearance: none;
list-style-image: url("chrome://zotero/skin/mac/twisty-active.svg") !important;
}
treechilren::-moz-tree-twisty(active) {
-moz-appearance: none;
list-style-image: url("chrome://zotero/skin/mac/twisty-active-open.svg");
}
*/
tree:focus treechildren::-moz-tree-twisty(selected) {
-moz-appearance: none;
list-style-image: url("chrome://zotero/skin/mac/twisty-selected.svg");
}
tree:focus treechildren::-moz-tree-twisty(selected, open) {
-moz-appearance: none;
list-style-image: url("chrome://zotero/skin/mac/twisty-selected-open.svg");
}
treechildren::-moz-tree-image {
height: 16px;
padding-bottom: 1px;
}
#zotero-tb-advanced-search
{
list-style-image: url('chrome://zotero/skin/mac/toolbar-advanced-search.png');
}
#zotero-tb-note-add
{
list-style-image: url('chrome://zotero/skin/mac/toolbar-note-add.png');
}
#zotero-collectionmenu > .menuitem-iconic, #zotero-itemmenu > .menuitem-iconic, #zotero-collectionmenu > .menu-iconic, #zotero-itemmenu > .menu-iconic {
padding-top: 0px !important;
padding-bottom: 2px !important;
list-style-image: none !important;
}
#zotero-collectionmenu > .menuitem-iconic > .menu-iconic-left, #zotero-itemmenu > .menuitem-iconic > .menu-iconic-left, #zotero-collectionmenu > .menu-iconic > .menu-iconic-left, #zotero-itemmenu > .menu-iconic > .menu-iconic-left {
display: none;
}
/* BEGIN 2X BLOCK -- DO NOT EDIT MANUALLY -- USE 2XIZE */
@media (min-resolution: 1.25dppx) {
.zotero-tb-button,.zotero-tb-button:first-child,.zotero-tb-button:last-child { background: url("chrome://zotero/skin/mac/menubutton-end@2x.png") right center/auto 24px no-repeat; }
.zotero-tb-button > .toolbarbutton-icon { background: url("chrome://zotero/skin/mac/menubutton-start@2x.png") left center/auto 24px no-repeat; }
.zotero-tb-button:-moz-window-inactive > .toolbarbutton-icon { background: url("chrome://zotero/skin/mac/menubutton-start-inactive-window@2x.png") left center/auto 24px no-repeat; }
.zotero-tb-button:-moz-window-inactive,.zotero-tb-button:-moz-window-inactive:first-child,.zotero-tb-button:-moz-window-inactive:last-child { background: url("chrome://zotero/skin/mac/menubutton-end-inactive-window@2x.png") right center/auto 24px no-repeat; }
.zotero-tb-button[open="true"],.zotero-tb-button:not([disabled="true"]):hover:active { background: url("chrome://zotero/skin/mac/menubutton-end-pressed@2x.png") right center/auto 24px no-repeat; }
.zotero-tb-button[open="true"] > .toolbarbutton-icon,.zotero-tb-button:not([disabled="true"]):hover:active > .toolbarbutton-icon { background: url("chrome://zotero/skin/mac/menubutton-start-pressed@2x.png") left center/auto 24px no-repeat; }
#zotero-collections-splitter[state=collapsed] > grippy, #zotero-items-splitter[state=collapsed] > grippy { background: url(chrome://zotero/skin/mac/vgrippy@2x.png) center/auto 8px no-repeat; }
#zotero-tags-splitter > grippy { background: url(chrome://zotero/skin/mac/hgrippy@2x.png) center/auto 8px no-repeat; }
#zotero-tb-advanced-search { list-style-image: url('chrome://zotero/skin/mac/toolbar-advanced-search@2x.png'); }
#zotero-tb-note-add { list-style-image: url('chrome://zotero/skin/mac/toolbar-note-add@2x.png'); }
}

View file

@ -0,0 +1,136 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
The Original Code is Mozilla.org Code.
The Initial Developer of the Original Code is Netscape
Communications Corporation. Portions created by Netscape are
Copyright (C) 1998-2000 Netscape Communications Corporation. All
Rights Reserved.
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
-->
<!DOCTYPE overlay [
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd"> %brandDTD;
<!ENTITY % standaloneDTD SYSTEM "chrome://zotero/locale/standalone.dtd"> %standaloneDTD;
<!ENTITY % browserDTD SYSTEM "chrome://zotero/locale/mozilla/browser.dtd"> %browserDTD;
]>
<overlay id="menuOverlay"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://global/content/macWindowMenu.js"/>
<script>
function openPrefs() {
var Zotero = Components.classes['@zotero.org/Zotero;1']
.getService(Components.interfaces.nsISupports)
.wrappedJSObject;
Zotero.Utilities.Internal.openPreferences();
}
</script>
<commandset id="mainCommandSet">
<command id="minimizeWindow"
label="&minimizeWindow.label;"
oncommand="window.minimize();" />
<command id="zoomWindow"
label="&zoomWindow.label;"
oncommand="zoomWindow();" />
</commandset>
<keyset id="mainKeyset">
<key id="key_minimizeWindow"
command="minimizeWindow"
key="&minimizeWindow.key;"
modifiers="accel"/>
<key id="key_openHelpMac"
oncommand="ZoteroStandalone.openHelp();"
key="&helpMac.commandkey;"
modifiers="accel"/>
<!-- These are used to build the Application menu under Cocoa widgets -->
<key id="key_preferencesCmdMac"
key="&preferencesCmdMac.commandkey;"
modifiers="accel"/>
<key id="key_hideThisAppCmdMac"
key="&hideThisAppCmdMac.commandkey;"
modifiers="accel"/>
<key id="key_hideOtherAppsCmdMac"
key="&hideOtherAppsCmdMac.commandkey;"
modifiers="accel,alt"/>
<key id="key_quitApplication"
key="&quitApplicationCmdMac.key;"
command="cmd_quitApplication"
modifiers="accel"/>
</keyset>
<!-- nsMenuBarX hides these and uses them to build the Application menu. -->
<menupopup id="menu_FilePopup">
<menuitem id="menu_preferences"
label="&preferencesCmdMac.label;"
key="key_preferencesCmdMac"
oncommand="openPrefs()"/>
<menuitem id="menu_mac_services"
label="&servicesMenuMac.label;"/>
<menuitem id="menu_mac_hide_app"
label="&hideThisAppCmdMac.label;"
key="key_hideThisAppCmdMac"/>
<menuitem id="menu_mac_hide_others"
label="&hideOtherAppsCmdMac.label;"
key="key_hideOtherAppsCmdMac"/>
<menuitem id="menu_mac_show_all"
label="&showAllAppsCmdMac.label;"/>
<menuitem id="menu_FileQuitItem"
label="&quitApplicationCmdMac.label;"
key="key_quitApplication"
command="cmd_quitApplication"/>
</menupopup>
<menu id="windowMenu"
label="&windowMenu.label;"
datasources="rdf:window-mediator" ref="NC:WindowMediatorRoot"
onpopupshowing="macWindowMenuDidShow();"
hidden="false">
<template>
<rule>
<menupopup>
<menuitem uri="rdf:*"
label="rdf:http://home.netscape.com/NC-rdf#Name"
type="radio"
name="windowList"
oncommand="ShowWindowFromResource(event.target)"/>
</menupopup>
</rule>
</template>
<menupopup id="menu_windowPopup">
<menuitem command="minimizeWindow" label="&minimizeWindow.label;" key="key_minimizeWindow"/>
<menuitem command="zoomWindow" label="&zoomWindow.label;"/>
<!-- decomment when "BringAllToFront" is implemented
<menuseparator/>
<menuitem label="&bringAllToFront.label;" disabled="true"/> -->
<menuseparator id="sep-window-list"/>
</menupopup>
</menu>
</overlay>

View file

@ -0,0 +1,4 @@
#zotero-toolbar {
-moz-appearance: none !important;
background: url("chrome://zotero/skin/mac/toolbar-background.png") left center repeat-x;
}

View file

@ -0,0 +1,30 @@
groupbox
{
background-color: white;
}
groupbox > .groupbox-body
{
-moz-appearance: none;
margin: 0;
padding: 0;
}
#view-settings-menu .toolbarbutton-menu-dropmarker
{
margin-left: -12px !important;
}
#no-tags-box
{
color: #7f7f7f;
}
#tag-controls
{
background-color: rgb(240,240,240);
border-width: 1px 0 0 0;
border-style: solid;
border-color: rgb(220,220,220);
padding: 2px 2px 2px 5px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -0,0 +1,7 @@
.zotero-advanced-options > .zotero-advanced-options-label > dropmarker {
transform: rotate(270deg) translateX(4px);
}
.zotero-advanced-options[state="open"] > .zotero-advanced-options-label > dropmarker {
transform: translateX(4px);
}

View file

@ -0,0 +1,24 @@
body {
line-height: 1.5em;
}
#quick-format-search:not([multiline="true"]) {
height: 29px !important;
}
#quick-format-search {
background: white;
padding: 0 2px 0 0;
border: 1px solid rgba(0, 0, 0, 0.5);
-moz-appearance: textfield;
}
#quick-format-dialog {
-moz-appearance: none;
padding: 5px;
}
#zotero-icon {
margin: 0 0 0 2px;
-moz-appearance: none;
}

View file

@ -0,0 +1,30 @@
/* Some distros have icons disabled by default at the OS level and
* mozilla is a respectful gent.
*/
#zotero-feed-item-addTo-button .button-icon {
display: block;
margin-right: 5px
}
/* Set to hidden in user-agent css for some reason. */
#zotero-feed-item-addTo-button .menu-iconic-left {
visibility: visible;
}
#zotero-item-pane-content {
margin-right: 6px;
}
/* Make the item pane appear white (same colour as treeview), making the UI more consistent */
#zotero-item-pane-content tab, #zotero-item-pane-content tabpanels {
background-color: -moz-Field; /* Same as background colour for treeview */
}
/* Possibly irrelevant if mozilla fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1306425 */
#zotero-view-tabbox tabs tab[visuallyselected=true] {
margin-top: 0px !important; /* Importanter than ./itemPane.css:20 */
margin-bottom: -2px !important; /* Importanter than skin/itemPane.css:12 */
}
#zotero-view-tabbox tabs tab {
margin-top: 2px !important; /* Importanter than skin/itemPane.css:11 */
}

View file

@ -0,0 +1,5 @@
textbox
{
padding: 1px 2px 1px 1px;
margin: -1px 0 -1px 0;
}

View file

@ -0,0 +1,85 @@
/*
Override selected, unfocused tree row highlight color, which is too similar to the alternating
row color by default
*/
#zotero-collections-tree treechildren::-moz-tree-row(selected),
#zotero-items-tree treechildren::-moz-tree-row(selected) {
background-color: #D4D4D4;
}
#zotero-collections-tree treechildren::-moz-tree-row(selected, focus),
#zotero-items-tree treechildren::-moz-tree-row(selected, focus) {
background-color: Highlight;
}
#zotero-collections-tree treechildren::-moz-tree-row {
height: 1.3em;
}
@media (min-resolution: 1.25dppx) {
#zotero-pane .toolbarbutton-icon {
width: 16px;
}
#zotero-tb-sync > .toolbarbutton-icon {
width: 20px;
}
}
/* Dropmarker added automatically on Linux */
.toolbarbutton-menu-dropmarker, #zotero-tb-search-menu-button {
list-style-image: none;
}
.zotero-tb-button:not([type=menu]) {
margin-right: 4px;
}
#zotero-tb-search-menu-button {
-moz-appearance: toolbarbutton-dropdown !important;
width: 12px;
height: 12px;
}
#zotero-tb-search-menu-button .button-menu-dropmarker {
display: none;
}
#zotero-tb-search .textbox-search-icon {
visibility: hidden;
}
/* Fixes tabs missing styling on (GTK 3.20) Ubuntu 16.10. See https://bugzilla.mozilla.org/show_bug.cgi?id=1306425 */
tabpanels {
-moz-appearance: none;
border: 1px solid hsla(0, 0%, 0%, 0.2);
}
tab {
-moz-appearance: none;
border-top: 1px solid hsla(0, 0%, 0%, 0.2);
border-right: 1px solid hsla(0, 0%, 0%, 0.2);
border-left: 1px solid hsla(0, 0%, 0%, 0.2);
-moz-border-top-colors: none;
-moz-border-right-colors: none;
-moz-border-left-colors: none;
}
/* Fixes misc Ubuntu 16.10 rendering issue fixes. */
#zotero-prefs menulist dropmarker{
width: 30px;
}
#zotero-prefs .numberbox-input-box{
-moz-appearance: textfield;
}
#zotero-prefs #noteFontSize {
min-width: 3.8em;
}
#zotero-pane splitter {
border: 0;
width: 6px;
background-color: transparent;
background-image: none;
}

View file

@ -0,0 +1,4 @@
/* There's an ugly horizontal scrollbar on linux in some steps of the wizard, which this fixes */
.wizard-page-box {
margin: 10px 40px;
}

View file

@ -0,0 +1,57 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
The Original Code is Mozilla.org Code.
The Initial Developer of the Original Code is Netscape
Communications Corporation. Portions created by Netscape are
Copyright (C) 1998-2000 Netscape Communications Corporation. All
Rights Reserved.
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
-->
<!DOCTYPE overlay [
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd"> %brandDTD;
<!ENTITY % standaloneDTD SYSTEM "chrome://zotero/locale/standalone.dtd"> %standaloneDTD;
<!ENTITY % browserDTD SYSTEM "chrome://zotero/locale/mozilla/browser.dtd"> %browserDTD;
]>
<overlay id="menuOverlay"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<menupopup id="menu_FilePopup">
<menuseparator/>
<menuitem id="menu_FileQuitItem"
label="&quitApplicationCmd.label;"
key="key_quitApplication"
command="cmd_quitApplication"/>
</menupopup>
<menupopup id="menu_EditPopup">
<menuseparator/>
<menuitem id="menu_preferences"
label="&preferencesCmdUnix.label;"
accesskey="&preferencesCmdUnix.accesskey;"
oncommand="Zotero.Utilities.Internal.openPreferences();"/>
</menupopup>
</overlay>

View file

@ -0,0 +1,3 @@
#view-settings-menu .toolbarbutton-icon {
margin-right: 0; /* dropmarker spacing handled automatically on Linux */
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 761 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -0,0 +1,45 @@
#quick-format-dialog {
background: transparent;
padding: 0;
}
#quick-format-search {
background: white;
padding: 2px 2px 2px 0;
border: 1px solid rgba(0, 0, 0, 0.5);
border-radius: 10px;
-moz-appearance: none;
}
#quick-format-dialog {
background: transparent;
-moz-appearance: none;
padding: 0;
}
#quick-format-search:not([multiline="true"]) {
height: 28px !important;
}
#quick-format-entry {
background: -moz-linear-gradient(-90deg, rgb(243,123,119) 0, rgb(180,47,38) 50%, rgb(156,36,27) 50%);
padding: 10px;
}
#quick-format-entry:not([square="true"]) {
-moz-border-radius: 15px;
border-radius: 15px;
}
#zotero-icon {
margin: -1px 0 0 4px;
-moz-appearance: none;
}
body {
line-height: 1.65em;
}
body[multiline="true"] {
padding-bottom: 2px;
}

View file

@ -0,0 +1,29 @@
row > hbox,
row > vbox
{
margin-top: 0 !important;
margin-bottom: 0 !important;
padding-top: 0 !important;
padding-bottom: 0 !important;
}
row vbox[fieldname]
{
margin-left: 1px;
}
.creator-type-label image {
margin-bottom: 0;
}
textbox
{
padding: 2px 2px 2px 2px;
margin: -1px 0 -1px 1px;
}
#item-type-menu
{
padding: 0 0 0 1px !important;
margin: 0 5px 0 1px !important;
}

View file

@ -0,0 +1,181 @@
:root {
--theme-border-color: #cecece;
}
/* Hide horrible blue effect for menu bar and toolbar */
#navigator-toolbox {
-moz-appearance: none;
}
#zotero-pane #zotero-toolbar {
-moz-appearance: none !important;
margin-top: -3px;
border-bottom-color: var(--theme-border-color);
}
@media (min-resolution: 1.25dppx) {
#zotero-toolbar .toolbarbutton-icon {
width: 16px;
}
#zotero-tb-sync > .toolbarbutton-icon {
width: 20px;
}
}
#zotero-tb-search-menu-button {
margin: 0 -1px 0 -4px;
padding: 5px 0 5px 5px;
border: 0;
background: transparent;
}
#zotero-tb-search-menu-button .button-menu-dropmarker {
display: none;
}
#zotero-tb-search .textbox-search-icon {
visibility: hidden;
}
#zotero-tb-sync-error {
margin-right: 4px;
padding-top: 4px;
}
#zotero-tb-sync {
margin-right: 1px;
padding-top: 4px;
}
#zotero-view-tabbox tab {
padding-left: .7em;
padding-right: .7em;
}
#zotero-toolbar {
-moz-appearance: toolbox !important;
padding-left: 2px;
}
#zotero-collections-splitter:not([state=collapsed]),
#zotero-items-splitter:not([state=collapsed]),
#zotero-tags-splitter:not([state=collapsed]) {
border: 0;
background-color: transparent;
position: relative;
/* Positive z-index positions the splitter on top of its siblings and makes
it clickable on both sides. */
z-index: 1;
}
#zotero-collections-splitter:not([state=collapsed]),
#zotero-items-splitter:not([state=collapsed]):not([orient=vertical]),
#zotero-tags-splitter:not([state=collapsed]) {
border-inline-end: 1px solid var(--theme-border-color);
min-width: 0;
width: 3px;
margin-inline-start: -3px;
}
#zotero-tags-splitter:not([state=collapsed]),
#zotero-items-splitter:not([state=collapsed])[orient=vertical] {
border-block-end: 1px solid var(--theme-border-color);
min-height: 0;
height: 3px;
margin-block-start: -3px;
}
#zotero-collections-splitter > grippy,
#zotero-items-splitter > grippy,
#zotero-tags-splitter > grippy {
border: 0;
}
#zotero-collections-splitter:not([state=collapsed]) > grippy,
#zotero-items-splitter:not([state=collapsed]) > grippy,
#zotero-tags-splitter:not([state=collapsed]) > grippy {
display: none;
}
#zotero-collections-tree, #zotero-items-tree, #zotero-view-item {
-moz-appearance: none;
border-style: solid;
border-color: #818790;
margin: 0;
padding: 0;
-moz-border-top-colors: none;
-moz-border-bottom-colors: none;
-moz-border-right-colors: none;
-moz-border-left-colors: none;
}
treechildren::-moz-tree-twisty {
padding: 0 4px;
}
/* Undo tree row spacing change in Fx25 on Windows */
#zotero-collections-tree treechildren::-moz-tree-row,
#zotero-items-tree treechildren::-moz-tree-row,
#zotero-prefs treechildren::-moz-tree-row {
height: 1.6em;
}
tree {
border-width: 0;
}
/* Restore row highlighting on drag over, though I'm not sure how we're losing it to begin with. */
#zotero-collections-tree treechildren::-moz-tree-row(dropOn) {
background-color: Highlight;
}
#zotero-tag-selector groupbox {
-moz-appearance: none;
padding: 0;
border: 0;
}
#tags-box {
padding-top: 0.1em;
padding-left: 0.05em;
}
#tags-box button {
margin: .04em 0 0 .15em !important;
}
#zotero-editpane-tabs spacer {
border: 0;
}
#zotero-view-item {
padding: 0 !important;
-moz-appearance: none;
background-color: -moz-field;
border-width: 1px 0 0 0;
border-color: var(--theme-border-color);
}
#zotero-view-tabbox > tabs {
margin-top: 2px;
}
#zotero-item-pane-groupbox {
-moz-appearance: none !important;
border-width: 0;
}
#zotero-editpane-item-box > scrollbox, #zotero-view-item > tabpanel > vbox,
#zotero-editpane-tags > scrollbox, #zotero-editpane-related {
padding-top: 5px;
}
#zotero-editpane-tags > scrollbox {
padding-left: 5px;
}
#zotero-view-item > tabpanel > vbox {
padding-left: 5px;
}

View file

@ -0,0 +1,57 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
The Original Code is Mozilla.org Code.
The Initial Developer of the Original Code is Netscape
Communications Corporation. Portions created by Netscape are
Copyright (C) 1998-2000 Netscape Communications Corporation. All
Rights Reserved.
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
-->
<!DOCTYPE overlay [
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd"> %brandDTD;
<!ENTITY % standaloneDTD SYSTEM "chrome://zotero/locale/standalone.dtd"> %standaloneDTD;
<!ENTITY % browserDTD SYSTEM "chrome://zotero/locale/mozilla/browser.dtd"> %browserDTD;
]>
<overlay id="menuOverlay"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<menupopup id="menu_FilePopup">
<menuseparator/>
<menuitem id="menu_FileQuitItem"
label="&quitApplicationCmdWin.label;"
key="key_quitApplication"
command="cmd_quitApplication"/>
</menupopup>
<menupopup id="menu_EditPopup">
<menuseparator/>
<menuitem id="menu_preferences"
label="&preferencesCmdUnix.label;"
accesskey="&preferencesCmdUnix.accesskey;"
oncommand="Zotero.Utilities.Internal.openPreferences();"/>
</menupopup>
</overlay>

View file

@ -0,0 +1,3 @@
button {
font-family: Segoe UI, sans-serif;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 773 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -0,0 +1,90 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/about.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://zotero/locale/about.dtd">
<dialog
id="zotero-about"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
orient="vertical"
buttons="accept"
buttonlabelaccept="&zotero.about.close;"
onload="moveToAlertPosition(); sizeToContent(); document.documentElement.getButton('accept').focus();"
ondialogaccept="return true;">
<script src="include.js"/>
<vbox id="aboutcontent">
<label id="name" value="Zotero"/>
<hbox>
<label id="version"/>
<label id="changelog" class="zotero-text-link" href="https://www.zotero.org/support/changelog" value="&zotero.whatsNew;"/>
</hbox>
<script>
document.getElementById('version').textContent = Zotero.version;
</script>
<hbox>
<vbox id="column1">
<div id="about-text" xmlns="http://www.w3.org/1999/xhtml">
<p id="created-by"></p>
<p id="get-involved"></p>
<script><![CDATA[
// Replace [links] in localized strings with spans with onclick handlers
//
// TODO: Use helper function in common with intro text in itemTreeView.js
document.getElementById('created-by').innerHTML =
Zotero.Utilities.htmlSpecialChars(Zotero.getString('about.createdBy'))
.replace(
/\[([^\]]+)](.+)\[([^\]]+)]/,
`<span data-href="https://rrchnm.org/">$1</span>`
+ '$2'
+ `<span data-href="https://www.zotero.org/support/credits_and_acknowledgments">$3</span>`
);
document.getElementById('get-involved').innerHTML =
Zotero.Utilities.htmlSpecialChars(Zotero.getString('about.getInvolved'))
.replace(
/\[([^\]]+)]/,
`<span data-href="https://www.zotero.org/getinvolved/">$1</span>`
);
// Activate text links
for (let span of document.getElementById('about-text').getElementsByTagName('span')) {
span.className = 'text-link';
span.onclick = function () {
Zotero.launchURL(this.getAttribute('data-href'));
};
}
]]></script>
</div>
<label class="subhead" value="&zotero.thanks;"/>
<vbox class="subcontent">
<label class="zotero-text-link" href="http://www.mellon.org/" value="Andrew W. Mellon Foundation"/>
<label class="zotero-text-link" href="http://www.imls.gov/" value="Institute of Museum and Library Services"/>
<label class="zotero-text-link" href="http://www.sloan.org/" value="Alfred P. Sloan Foundation"/>
</vbox>
</vbox>
<vbox id="column2">
<label class="subhead" value="&zotero.citationProcessing;"/>
<vbox class="subcontent">
<label class="zotero-text-link" href="http://citationstyles.org/" value="Citation Style Language"/>
<label class="zotero-text-link" href="https://github.com/Juris-M/citeproc-js" value="citeproc-js (Frank Bennett)"/>
</vbox>
<label class="subhead" value="&zotero.about.additionalSoftware;"/>
<vbox class="subcontent">
<label class="zotero-text-link" href="http://bluebirdjs.com/" value="Bluebird"/>
<label class="zotero-text-link" href="http://p.yusukekamiyamane.com/" value="Fugue icons (by Yusuke Kamiyamane)"/>
<label class="zotero-text-link" href="http://www.davidashen.net/rnv.html" value="RNV (CSL validation)"/>
<label class="zotero-text-link" href="https://codefisher.org/pastel-svg/" value="Pastel SVG icons (by Michael Buckley)"/>
<label class="zotero-text-link" href="http://www.famfamfam.com/lab/icons/silk/" value="Silk icons (by Mark James)"/>
<label class="zotero-text-link" href="http://simile.mit.edu/timeline/" value="SIMILE Project (Timeline)"/>
<label class="zotero-text-link" href="http://www.w3.org/2005/ajar/tab" value="Tabulator (RDF parser)"/>
<label class="zotero-text-link" href="http://tango.freedesktop.org/Tango_Desktop_Project" value="Tango Desktop Project (pref icons)"/>
<label class="zotero-text-link" href="https://www.tinymce.com/" value="TinyMCE (rich-text editing)"/>
<label class="zotero-text-link" href="http://www.foolabs.com/xpdf/" value="Xpdf (pdftotext)"/>
</vbox>
</vbox>
</hbox>
</vbox>
</dialog>

View file

@ -0,0 +1,190 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
var ZoteroAdvancedSearch = new function() {
this.onLoad = onLoad;
this.search = search;
this.clear = clear;
this.onDblClick = onDblClick;
this.onUnload = onUnload;
this.itemsView = false;
var _searchBox;
var _libraryID;
function onLoad() {
_searchBox = document.getElementById('zotero-search-box');
// Set font size from pref
var sbc = document.getElementById('zotero-search-box-container');
Zotero.setFontSize(sbc);
_searchBox.onLibraryChange = this.onLibraryChange;
var io = window.arguments[0];
io.dataIn.search.loadPrimaryData()
.then(function () {
_searchBox.search = io.dataIn.search;
});
}
function search() {
_searchBox.updateSearch();
_searchBox.active = true;
// A minimal implementation of Zotero.CollectionTreeRow
var collectionTreeRow = {
view: {},
ref: _searchBox.search,
isSearchMode: function() { return true; },
getItems: Zotero.Promise.coroutine(function* () {
var search = _searchBox.search.clone();
search.libraryID = _libraryID;
var ids = yield search.search();
return Zotero.Items.get(ids);
}),
isLibrary: function () { return false; },
isCollection: function () { return false; },
isSearch: function () { return true; },
isPublications: () => false,
isFeed: () => false,
isShare: function () { return false; },
isTrash: function () { return false; }
}
if (this.itemsView) {
this.itemsView.unregister();
}
this.itemsView = new Zotero.ItemTreeView(collectionTreeRow, false);
document.getElementById('zotero-items-tree').view = this.itemsView;
}
function clear() {
if (this.itemsView) {
this.itemsView.unregister();
}
document.getElementById('zotero-items-tree').view = null;
var s = new Zotero.Search();
// Don't clear the selected library
s.libraryID = _searchBox.search.libraryID;
s.addCondition('title', 'contains', '')
_searchBox.search = s;
_searchBox.active = false;
}
this.save = Zotero.Promise.coroutine(function* () {
_searchBox.updateSearch();
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var untitled = yield Zotero.DB.getNextName(
_searchBox.search.libraryID,
'savedSearches',
'savedSearchName',
Zotero.getString('pane.collections.untitled')
);
var name = { value: untitled };
var result = promptService.prompt(window,
Zotero.getString('pane.collections.newSavedSeach'),
Zotero.getString('pane.collections.savedSearchName'), name, "", {});
if (!result)
{
return;
}
if (!name.value)
{
name.value = untitled;
}
var s = _searchBox.search.clone();
s.name = name.value;
yield s.save();
window.close()
});
this.onLibraryChange = function (libraryID) {
_libraryID = libraryID;
var library = Zotero.Libraries.get(libraryID);
var isEditable = library.editable && library.libraryType != 'publications';
document.getElementById('zotero-search-save').disabled = !isEditable;
}
// Adapted from: http://www.xulplanet.com/references/elemref/ref_tree.html#cmnote-9
function onDblClick(event, tree)
{
if (event && tree && event.type == "dblclick")
{
var row = {}, col = {}, obj = {};
tree.treeBoxObject.getCellAt(event.clientX, event.clientY, row, col, obj);
// obj.value == cell/text/image
// TODO: handle collection double-click
if (obj.value && this.itemsView && this.itemsView.selection.currentIndex > -1)
{
var item = this.itemsView.getSelectedItems()[0];
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var lastWin = wm.getMostRecentWindow("navigator:browser");
if (!lastWin) {
window.open();
var newWindow = wm.getMostRecentWindow("navigator:browser");
var b = newWindow.getBrowser();
return;
}
if (lastWin.ZoteroOverlay) {
lastWin.ZoteroOverlay.toggleDisplay(true);
}
lastWin.ZoteroPane.selectItem(item.getID(), false, true);
lastWin.focus();
}
}
}
function onUnload() {
// Unregister search from Notifier
if (this.itemsView) {
this.itemsView.unregister();
}
}
}

View file

@ -0,0 +1,60 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/"?>
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/overlay.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero-platform/content/overlay.css"?>
<!DOCTYPE window [
<!ENTITY % zoteroDTD SYSTEM "chrome://zotero/locale/zotero.dtd">
%zoteroDTD;
<!ENTITY % searchboxDTD SYSTEM "chrome://zotero/locale/searchbox.dtd">
%searchboxDTD;
]>
<window
id="zotero-advanced-search-dialog"
title="&zotero.toolbar.advancedSearch;"
orient="vertical"
persist="screenX screenY width height"
onload="ZoteroAdvancedSearch.onLoad()"
onunload="ZoteroAdvancedSearch.onUnload()"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
windowtype="zotero:search">
<script src="include.js"/>
<script src="advancedSearch.js"/>
<vbox id="zotero-search-box-container" flex="1">
<vbox id="zotero-search-box-controls">
<zoterosearch id="zotero-search-box" oncommand="if (this.active) { ZoteroAdvancedSearch.search(); }" flex="1"/>
<hbox id="zotero-search-buttons">
<button label="&zotero.search.search;" default="true" oncommand="ZoteroAdvancedSearch.search()"/>
<button label="&zotero.search.clear;" oncommand="ZoteroAdvancedSearch.clear()"/>
<button id="zotero-search-save" label="&zotero.search.saveSearch;" oncommand="ZoteroAdvancedSearch.save()"/>
</hbox>
</vbox>
<tree id="zotero-items-tree" flex="1" hidecolumnpicker="true" seltype="multiple"
ondblclick="ZoteroAdvancedSearch.onDblClick(event, this)"
ondragstart="if (event.target.localName == 'treechildren') { ZoteroAdvancedSearch.itemsView.onDragStart(event); }">
<treecols>
<treecol
id="zotero-items-column-title" primary="true"
label="&zotero.items.title_column;"
flex="4" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-firstCreator"
label="&zotero.items.creator_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
</treecols>
<treechildren alternatingbackground="true"/>
</tree>
</vbox>
<keyset>
<key id="key_close" key="W" modifiers="accel" oncommand="window.close()"/>
</keyset>
</window>

View file

@ -0,0 +1,60 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2014 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
var Zotero_AttachLink = new function() {
function getAttachFileLabel() {
return window.opener.document
.getElementById('zotero-tb-attachment-add-file-link')
.label;
};
this.submit = function() {
var link = document.getElementById('zotero-attach-uri-input').value;
var message = document.getElementById('zotero-attach-uri-message');
var cleanURI = Zotero.Attachments.cleanAttachmentURI(link, true);
if (!cleanURI) {
message.textContent = Zotero.getString('pane.items.attach.link.uri.unrecognized');
window.sizeToContent();
document.getElementById('zotero-attach-uri-input').select();
return false;
}
// Don't allow "file:" links, because using "Attach link to file" is the right way
else if (cleanURI.toLowerCase().indexOf('file:') == 0) {
message.textContent = Zotero.getString('pane.items.attach.link.uri.file',
[getAttachFileLabel()]);
window.sizeToContent();
document.getElementById('zotero-attach-uri-input').select();
return false;
}
else {
window.arguments[0].out = {
link: cleanURI,
title: document.getElementById('zotero-attach-uri-title').value
};
return true;
}
};
}

View file

@ -0,0 +1,32 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<dialog
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
buttons="accept,cancel"
ondialogaccept="return Zotero_AttachLink.submit();"
id="zotero-attach-uri-dialog"
title="&zotero.attachLink.title;"
>
<script src="include.js"/>
<script src="attachLink.js"/>
<vbox id="zotero-attach-uri-container">
<hbox>
<description id="zotero-attach-uri-message" class="zotero-message-error"></description>
</hbox>
<hbox align="center">
<label id="zotero-attach-uri-label-input" value="&zotero.attachLink.label.link;" control="zotero-attach-uri-input"></label>
<textbox id="zotero-attach-uri-input" flex="1"/>
</hbox>
<hbox align="center">
<label id="zotero-attach-uri-label-title" value="&zotero.attachLink.label.title;" control="zotero-attach-uri-title"></label>
<textbox id="zotero-attach-uri-title" flex="1" placeholder="&zotero.general.optional;"/>
</hbox>
</vbox>
</dialog>

View file

@ -0,0 +1,302 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
//////////////////////////////////////////////////////////////////////////////
//
// Zotero_File_Interface_Bibliography
//
//////////////////////////////////////////////////////////////////////////////
// Class to provide options for bibliography
// Used by rtfScan.xul, integrationDocPrefs.xul, and bibliography.xul
var Zotero_File_Interface_Bibliography = new function() {
var _io;
// Only changes when explicitly selected
var lastSelectedStyle,
lastSelectedLocale;
var isDocPrefs = false;
/*
* Initialize some variables and prepare event listeners for when chrome is done
* loading
*/
this.init = Zotero.Promise.coroutine(function* () {
// Set font size from pref
// Affects bibliography.xul and integrationDocPrefs.xul
var bibContainer = document.getElementById("zotero-bibliography-container");
if(bibContainer) {
Zotero.setFontSize(document.getElementById("zotero-bibliography-container"));
}
if(window.arguments && window.arguments.length) {
_io = window.arguments[0];
if(_io.wrappedJSObject) _io = _io.wrappedJSObject;
} else {
_io = {};
}
var listbox = document.getElementById("style-listbox");
// if no style is requested, get the last style used
if(!_io.style) {
_io.style = Zotero.Prefs.get("export.lastStyle");
}
// See note in style.js
if (!Zotero.Styles.initialized) {
// Initialize styles
yield Zotero.Styles.init();
}
// add styles to list
var styles = Zotero.Styles.getVisible();
var selectIndex = null;
for (let i=0; i < styles.length; i++) {
var itemNode = document.createElement("listitem");
itemNode.setAttribute("value", styles[i].styleID);
itemNode.setAttribute("label", styles[i].title);
listbox.appendChild(itemNode);
if(styles[i].styleID == _io.style) {
selectIndex = i;
}
}
let requestedLocale;
if (selectIndex === null) {
// Requested style not found in list, pre-select first style
selectIndex = 0;
} else {
requestedLocale = _io.locale;
}
let style = styles[selectIndex];
lastSelectedLocale = Zotero.Prefs.get("export.lastLocale");
if (requestedLocale && style && !style.locale) {
// pre-select supplied locale
lastSelectedLocale = requestedLocale;
}
// add locales to list
Zotero.Styles.populateLocaleList(document.getElementById("locale-menu"));
// Has to be async to work properly
window.setTimeout(function () {
listbox.ensureIndexIsVisible(selectIndex);
listbox.selectedIndex = selectIndex;
if (listbox.selectedIndex == -1) {
// This can happen in tests if styles aren't loaded
Zotero.debug("No styles to select", 2);
return;
}
Zotero_File_Interface_Bibliography.styleChanged();
}, 0);
// ONLY FOR bibliography.xul: export options
if(document.getElementById("save-as-rtf")) {
var settings = Zotero.Prefs.get("export.bibliographySettings");
try {
settings = JSON.parse(settings);
var mode = settings.mode;
var method = settings.method;
}
// If not JSON, assume it's the previous format-as-a-string
catch (e) {
method = settings;
}
if (!mode) mode = "bibliography";
if (!method) method = "save-as-rtf";
// restore saved bibliographic settings
document.getElementById('output-mode-radio').selectedItem =
document.getElementById(mode);
document.getElementById('output-method-radio').selectedItem =
document.getElementById(method);
}
// ONLY FOR integrationDocPrefs.xul: set selected endnotes/footnotes
isDocPrefs = !!document.getElementById("displayAs");
if (isDocPrefs) {
if(_io.useEndnotes && _io.useEndnotes == 1) document.getElementById("displayAs").selectedIndex = 1;
let dialog = document.getElementById("zotero-doc-prefs-dialog");
dialog.setAttribute('title', `${Zotero.clientName} - ${dialog.getAttribute('title')}`);
if (document.getElementById("formatUsing-groupbox")) {
if (["Field", "ReferenceMark"].includes(_io.primaryFieldType)) {
if(_io.fieldType == "Bookmark") document.getElementById("formatUsing").selectedIndex = 1;
var formatOption = (_io.primaryFieldType == "ReferenceMark" ? "referenceMarks" : "fields");
document.getElementById("fields").label =
Zotero.getString("integration."+formatOption+".label");
document.getElementById("fields-caption").textContent =
Zotero.getString("integration."+formatOption+".caption");
document.getElementById("fields-file-format-notice").textContent =
Zotero.getString("integration."+formatOption+".fileFormatNotice");
document.getElementById("bookmarks-file-format-notice").textContent =
Zotero.getString("integration.fields.fileFormatNotice");
} else {
document.getElementById("formatUsing-groupbox").style.display = "none";
_io.fieldType = _io.primaryFieldType;
}
}
if(document.getElementById("automaticJournalAbbreviations-checkbox")) {
if(_io.automaticJournalAbbreviations === undefined) {
_io.automaticJournalAbbreviations = Zotero.Prefs.get("cite.automaticJournalAbbreviations");
}
if(_io.automaticJournalAbbreviations) {
document.getElementById("automaticJournalAbbreviations-checkbox").checked = true;
}
document.getElementById("automaticCitationUpdates-checkbox").checked = !_io.delayCitationUpdates;
}
}
// set style to false, in case this is cancelled
_io.style = false;
});
this.openHelpLink = function() {
var url = "https://www.zotero.org/support/word_processor_plugin_usage";
var win = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator)
.getMostRecentWindow("navigator:browser");
Zotero.launchURL(url);
};
/*
* Called when locale is changed
*/
this.localeChanged = function (selectedValue) {
lastSelectedLocale = selectedValue;
};
/*
* Called when style is changed
*/
this.styleChanged = function () {
var selectedItem = document.getElementById("style-listbox").selectedItem;
lastSelectedStyle = selectedItem.getAttribute('value');
var selectedStyleObj = Zotero.Styles.get(lastSelectedStyle);
updateLocaleMenu(selectedStyleObj);
//
// For integrationDocPrefs.xul
//
if (isDocPrefs) {
// update status of displayAs box based on style class
var isNote = selectedStyleObj.class == "note";
var multipleNotesSupported = _io.supportedNotes.length > 1;
document.getElementById("displayAs-groupbox").hidden = !isNote || !multipleNotesSupported;
// update status of formatUsing box based on style class
if(isNote) document.getElementById("formatUsing").selectedIndex = 0;
document.getElementById("bookmarks").disabled = isNote;
document.getElementById("bookmarks-caption").disabled = isNote;
// update status of displayAs box based on style class
document.getElementById("automaticJournalAbbreviations-vbox").hidden =
!selectedStyleObj.usesAbbreviation;
}
//
// For bibliography.xul
//
// Change label to "Citation" or "Note" depending on style class
if(document.getElementById("citations")) {
let label = "";
if(Zotero.Styles.get(lastSelectedStyle).class == "note") {
label = Zotero.getString('citation.notes');
} else {
label = Zotero.getString('citation.citations');
}
document.getElementById("citations").label = label;
}
window.sizeToContent();
};
/*
* Update locale menulist when style is changed
*/
function updateLocaleMenu(selectedStyle) {
Zotero.Styles.updateLocaleList(
document.getElementById("locale-menu"),
selectedStyle,
lastSelectedLocale
);
}
this.acceptSelection = function () {
// collect code
_io.style = document.getElementById("style-listbox").value;
let localeMenu = document.getElementById("locale-menu");
_io.locale = localeMenu.disabled ? undefined : localeMenu.value;
if(document.getElementById("output-method-radio")) {
// collect settings
_io.mode = document.getElementById("output-mode-radio").selectedItem.id;
_io.method = document.getElementById("output-method-radio").selectedItem.id;
// save settings
Zotero.Prefs.set("export.bibliographySettings",
JSON.stringify({ mode: _io.mode, method: _io.method }));
}
// ONLY FOR integrationDocPrefs.xul:
if(isDocPrefs) {
var automaticJournalAbbreviationsEl = document.getElementById("automaticJournalAbbreviations-checkbox");
_io.automaticJournalAbbreviations = automaticJournalAbbreviationsEl.checked;
if(!automaticJournalAbbreviationsEl.hidden && lastSelectedStyle) {
Zotero.Prefs.set("cite.automaticJournalAbbreviations", _io.automaticJournalAbbreviations);
}
_io.useEndnotes = document.getElementById("displayAs").selectedIndex;
_io.fieldType = (document.getElementById("formatUsing").selectedIndex == 0 ? _io.primaryFieldType : _io.secondaryFieldType);
_io.delayCitationUpdates = !document.getElementById("automaticCitationUpdates-checkbox").checked;
}
// remember style and locale if user selected these explicitly
if(lastSelectedStyle) {
Zotero.Prefs.set("export.lastStyle", _io.style);
}
if (lastSelectedLocale) {
Zotero.Prefs.set("export.lastLocale", lastSelectedLocale);
}
};
this.manageStyles = function () {
document.documentElement.getButton('cancel').click();
var win = Zotero.Utilities.Internal.openPreferences('zotero-prefpane-cite', { tab: 'styles-tab' });
if (isDocPrefs) {
Zotero.Utilities.Internal.activate(win);
}
};
}

View file

@ -0,0 +1,46 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/bibliography.css"?>
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&zotero.bibliography.title;" buttons="cancel,accept"
ondialogaccept="Zotero_File_Interface_Bibliography.acceptSelection()"
id="zotero-bibliography"
onload="Zotero_File_Interface_Bibliography.init()">
<script src="include.js"/>
<script src="bibliography.js"/>
<vbox id="zotero-bibliography-container">
<groupbox>
<caption label="&zotero.bibliography.style.label;"/>
<listbox id="style-listbox" onselect="Zotero_File_Interface_Bibliography.styleChanged()"/>
<hbox align="right">
<label id="manage-styles" class="text-link"
onclick="Zotero_File_Interface_Bibliography.manageStyles()">&zotero.bibliography.manageStyles;</label>
</hbox>
</groupbox>
<groupbox>
<hbox align="center">
<caption label="&zotero.bibliography.locale.label;"/>
<menulist id="locale-menu" oncommand="Zotero_File_Interface_Bibliography.localeChanged(this.selectedItem.value)"/>
</hbox>
</groupbox>
<groupbox>
<caption label="&zotero.bibliography.outputMode;"/>
<radiogroup id="output-mode-radio">
<radio id="citations"/>
<radio id="bibliography" label="&zotero.bibliography.bibliography;"/>
</radiogroup>
</groupbox>
<groupbox>
<caption label="&zotero.bibliography.outputMethod;"/>
<radiogroup id="output-method-radio">
<radio id="save-as-rtf" label="&zotero.bibliography.saveAsRTF.label;"/>
<radio id="save-as-html" label="&zotero.bibliography.saveAsHTML.label;"/>
<radio id="copy-to-clipboard" label="&zotero.bibliography.copyToClipboard.label;"/>
<radio id="print" label="&zotero.bibliography.print.label;"/>
</radiogroup>
</groupbox>
</vbox>
</dialog>

View file

@ -0,0 +1,633 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
-->
<!DOCTYPE bindings SYSTEM "chrome://zotero/locale/zotero.dtd">
<!-- <!DOCTYPE bindings SYSTEM "chrome://zotero/locale/attachmentbox.dtd"> -->
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="attachment-box">
<resources>
<stylesheet src="chrome://zotero/skin/bindings/attachmentbox.css"/>
<stylesheet src="chrome://zotero-platform/content/attachmentbox.css"/>
</resources>
<implementation>
<!--
Public properties
-->
<field name="editable">false</field>
<field name="clickableLink">false</field>
<field name="displayButton">false</field>
<field name="displayNote">false</field>
<field name="buttonCaption"/>
<field name="clickHandler"/>
<!-- Modes are predefined settings groups for particular tasks -->
<field name="_mode">"view"</field>
<property name="mode" onget="return this._mode;">
<setter>
<![CDATA[
Zotero.debug("Setting mode to '" + val + "'");
this.editable = false;
this.synchronous = false;
this.displayURL = false;
this.displayFileName = false;
this.clickableLink = false;
this.displayAccessed = false;
this.displayPages = false;
this.displayDateModified = false;
this.displayIndexed = false;
this.displayNote = false;
this.displayNoteIfEmpty = false;
switch (val) {
case 'view':
this.displayURL = true;
this.displayFileName = true;
this.clickableLink = true;
this.displayAccessed = true;
this.displayPages = true;
this.displayIndexed = true;
this.displayNote = true;
this.displayDateModified = true;
break;
case 'edit':
this.editable = true;
this.displayURL = true;
this.displayFileName = true;
this.clickableLink = true;
this.displayAccessed = true;
this.displayPages = true;
this.displayIndexed = true;
this.displayNote = true;
this.displayNoteIfEmpty = true;
this.displayDateModified = true;
break;
case 'merge':
this.synchronous = true;
this.displayURL = true;
this.displayFileName = true;
this.displayAccessed = true;
this.displayNote = true;
this.displayDateModified = true;
break;
case 'mergeedit':
this.synchronous = true;
this.editable = true;
this.displayURL = true;
this.displayFileName = true;
this.displayAccessed = true;
this.displayNote = true;
// Notes aren't currently editable in mergeedit pane
this.displayNoteIfEmpty = false;
this.displayDateModified = true;
break;
case 'filemerge':
this.synchronous = true;
this.displayURL = true;
this.displayFileName = true;
this.displayDateModified = true;
break;
default:
throw ("Invalid mode '" + val + "' in attachmentbox.xml");
}
this._mode = val;
document.getAnonymousNodes(this)[0].setAttribute('mode', val);
]]>
</setter>
</property>
<field name="_item"/>
<property name="item" onget="return this._item;">
<setter><![CDATA[
if (!(val instanceof Zotero.Item)) {
throw new Error("'item' must be a Zotero.Item");
}
this._item = val;
this.refresh();
]]></setter>
</property>
<!-- Methods -->
<constructor>
<![CDATA[
this._notifierID = Zotero.Notifier.registerObserver(this, ['item'], 'attachmentbox');
]]>
</constructor>
<destructor>
<![CDATA[
Zotero.Notifier.unregisterObserver(this._notifierID);
]]>
</destructor>
<method name="notify">
<parameter name="event"/>
<parameter name="type"/>
<parameter name="ids"/>
<parameter name="extraData"/>
<body><![CDATA[
if (event != 'modify' || !this.item || !this.item.id) return;
for (let id of ids) {
if (id != this.item.id) {
continue;
}
var noteEditor = this._id('attachment-note-editor')
if (extraData && extraData[id]
&& extraData[id].noteEditorID == noteEditor.instanceID) {
//Zotero.debug("Skipping notification from current attachment note field");
continue;
}
this.refresh();
break;
}
]]></body>
</method>
<method name="refresh">
<body><![CDATA[
Zotero.debug('Refreshing attachment box');
var attachmentBox = document.getAnonymousNodes(this)[0];
var title = this._id('title');
var fileNameRow = this._id('fileNameRow');
var urlField = this._id('url');
var accessed = this._id('accessedRow');
var pagesRow = this._id('pagesRow');
var dateModifiedRow = this._id('dateModifiedRow');
var indexStatusRow = this._id('indexStatusRow');
var selectButton = this._id('select-button');
// DEBUG: this is annoying -- we really want to use an abstracted
// version of createValueElement() from itemPane.js
// (ideally in an XBL binding)
// Wrap title to multiple lines if necessary
while (title.hasChildNodes()) {
title.removeChild(title.firstChild);
}
var val = this.item.getField('title');
if (typeof val != 'string') {
val += "";
}
var firstSpace = val.indexOf(" ");
// Crop long uninterrupted text, and use value attribute for empty field
if ((firstSpace == -1 && val.length > 29 ) || firstSpace > 29 || val === "") {
title.setAttribute('crop', 'end');
title.setAttribute('value', val);
}
// Create a <description> element, essentially
else {
title.removeAttribute('value');
title.appendChild(document.createTextNode(val));
}
if (this.editable) {
title.className = 'zotero-clicky';
// For the time being, use a silly little popup
title.addEventListener('click', this.editTitle, false);
}
var isImportedURL = this.item.attachmentLinkMode ==
Zotero.Attachments.LINK_MODE_IMPORTED_URL;
// Metadata for URL's
if (this.item.attachmentLinkMode == Zotero.Attachments.LINK_MODE_LINKED_URL
|| isImportedURL) {
// URL
if (this.displayURL) {
var urlSpec = this.item.getField('url');
urlField.setAttribute('value', urlSpec);
urlField.setAttribute('tooltiptext', urlSpec);
urlField.setAttribute('hidden', false);
if (this.clickableLink) {
urlField.onclick = function (event) {
ZoteroPane_Local.loadURI(this.value, event)
};
urlField.className = 'zotero-text-link';
}
else {
urlField.className = '';
}
urlField.hidden = false;
}
else {
urlField.hidden = true;
}
// Access date
if (this.displayAccessed) {
this._id("accessed-label").value = Zotero.getString('itemFields.accessDate')
+ Zotero.getString('punctuation.colon');
let val = this.item.getField('accessDate');
if (val) {
val = Zotero.Date.sqlToDate(val, true);
}
if (val) {
this._id("accessed").value = val.toLocaleString();
accessed.hidden = false;
}
else {
accessed.hidden = true;
}
}
else {
accessed.hidden = true;
}
}
// Metadata for files
else {
urlField.hidden = true;
accessed.hidden = true;
}
if (this.item.attachmentLinkMode
!= Zotero.Attachments.LINK_MODE_LINKED_URL
&& this.displayFileName) {
var fileName = this.item.attachmentFilename;
if (fileName) {
this._id("fileName-label").value = Zotero.getString('pane.item.attachments.filename')
+ Zotero.getString('punctuation.colon');
this._id("fileName").value = fileName;
fileNameRow.hidden = false;
}
else {
fileNameRow.hidden = true;
}
}
else {
fileNameRow.hidden = true;
}
// Page count
if (this.displayPages) {
Zotero.Fulltext.getPages(this.item.id)
.tap(() => Zotero.Promise.check(this.item))
.then(function (pages) {
pages = pages ? pages.total : null;
if (pages) {
this._id("pages-label").value = Zotero.getString('itemFields.pages')
+ Zotero.getString('punctuation.colon');
this._id("pages").value = pages;
pagesRow.hidden = false;
}
else {
pagesRow.hidden = true;
}
}.bind(this));
}
else {
pagesRow.hidden = true;
}
if (this.displayDateModified) {
this._id("dateModified-label").value = Zotero.getString('itemFields.dateModified')
+ Zotero.getString('punctuation.colon');
// Conflict resolution uses a modal window, so promises won't work, but
// the sync process passes in the file mod time as dateModified
if (this.synchronous) {
this._id("dateModified").value = Zotero.Date.sqlToDate(
this.item.getField('dateModified'), true
).toLocaleString();
dateModifiedRow.hidden = false;
}
else {
this.item.attachmentModificationTime
.tap(() => Zotero.Promise.check(this._id))
.then(function (mtime) {
if (mtime) {
this._id("dateModified").value = new Date(mtime).toLocaleString();
}
dateModifiedRow.hidden = !mtime;
}.bind(this));
}
}
else {
dateModifiedRow.hidden = true;
}
// Full-text index information
if (this.displayIndexed) {
this.updateItemIndexedState()
.tap(() => Zotero.Promise.check(this.item))
.then(function () {
indexStatusRow.hidden = false;
});
}
else {
indexStatusRow.hidden = true;
}
// Note editor
var noteEditor = this._id('attachment-note-editor');
if (this.displayNote && (this.displayNoteIfEmpty || this.item.getNote() != '')) {
noteEditor.linksOnTop = true;
noteEditor.hidden = false;
// Don't make note editable (at least for now)
if (this.mode == 'merge' || this.mode == 'mergeedit') {
noteEditor.mode = 'merge';
noteEditor.displayButton = false;
}
else {
noteEditor.mode = this.mode;
}
noteEditor.parent = null;
noteEditor.item = this.item;
}
else {
noteEditor.hidden = true;
}
if (this.displayButton) {
selectButton.label = this.buttonCaption;
selectButton.hidden = false;
selectButton.setAttribute('oncommand',
'document.getBindingParent(this).clickHandler(this)');
}
else {
selectButton.hidden = true;
}
]]></body>
</method>
<method name="editTitle">
<body>
<![CDATA[
return Zotero.spawn(function* () {
var item = document.getBindingParent(this).item;
var oldTitle = item.getField('title');
var nsIPS = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var newTitle = { value: oldTitle };
var checkState = { value: Zotero.Prefs.get('lastRenameAssociatedFile') };
while (true) {
// Don't show "Rename associated file" option for
// linked URLs
if (item.attachmentLinkMode ==
Zotero.Attachments.LINK_MODE_LINKED_URL) {
var result = nsIPS.prompt(
window,
'',
Zotero.getString('pane.item.attachments.rename.title'),
newTitle,
null,
{}
);
// If they hit cancel or left it blank
if (!result || !newTitle.value) {
return;
}
break;
}
var result = nsIPS.prompt(
window,
'',
Zotero.getString('pane.item.attachments.rename.title'),
newTitle,
Zotero.getString('pane.item.attachments.rename.renameAssociatedFile'),
checkState
);
// If they hit cancel or left it blank
if (!result || !newTitle.value) {
return;
}
Zotero.Prefs.set('lastRenameAssociatedFile', checkState.value);
// Rename associated file
if (checkState.value) {
var newFilename = newTitle.value.trim();
if (newFilename.search(/\.\w{1,10}$/) == -1) {
// User did not specify extension. Use current
var oldExt = item.getFilename().match(/\.\w{1,10}$/);
if (oldExt) newFilename += oldExt[0];
}
var renamed = yield item.renameAttachmentFile(newFilename);
if (renamed == -1) {
var confirmed = nsIPS.confirm(
window,
'',
newFilename + ' exists. Overwrite existing file?'
);
if (!confirmed) {
// If they said not to overwrite existing file,
// start again
continue;
}
// Force overwrite, but make sure we check that this doesn't fail
renamed = yield item.renameAttachmentFile(newFilename, true);
}
if (renamed == -2) {
nsIPS.alert(
window,
Zotero.getString('general.error'),
Zotero.getString('pane.item.attachments.rename.error')
);
return;
}
else if (!renamed) {
nsIPS.alert(
window,
Zotero.getString('pane.item.attachments.fileNotFound.title'),
Zotero.getString('pane.item.attachments.fileNotFound.text')
);
}
}
break;
}
if (newTitle.value != oldTitle) {
item.setField('title', newTitle.value);
yield item.saveTx();
}
}.bind(this));
]]>
</body>
</method>
<method name="onViewClick">
<parameter name="event"/>
<body>
<![CDATA[
ZoteroPane_Local.viewAttachment(this.item.id, event, !this.editable);
]]>
</body>
</method>
<method name="onShowClick">
<parameter name="event"/>
<body>
<![CDATA[
ZoteroPane_Local.showAttachmentInFilesystem(this.item.id, event.originalTarget, !this.editable);
]]>
</body>
</method>
<!--
Update Indexed: (Yes|No|Partial) line
-->
<method name="updateItemIndexedState">
<body><![CDATA[
return Zotero.spawn(function* () {
var indexStatus = this._id('index-status');
var reindexButton = this._id('reindex');
var status = yield Zotero.Fulltext.getIndexedState(this.item)
.tap(() => Zotero.Promise.check(this.item));
var str = 'fulltext.indexState.';
switch (status) {
case Zotero.Fulltext.INDEX_STATE_UNAVAILABLE:
str += 'unavailable';
break;
case Zotero.Fulltext.INDEX_STATE_UNINDEXED:
str = 'general.no';
break;
case Zotero.Fulltext.INDEX_STATE_PARTIAL:
str += 'partial';
break;
case Zotero.Fulltext.INDEX_STATE_QUEUED:
str += 'queued';
break;
case Zotero.Fulltext.INDEX_STATE_INDEXED:
str = 'general.yes';
break;
}
this._id("index-status-label").value = Zotero.getString('fulltext.indexState.indexed')
+ Zotero.getString('punctuation.colon');
indexStatus.value = Zotero.getString(str);
// Reindex button tooltip (string stored in zotero.properties)
var str = Zotero.getString('pane.items.menu.reindexItem');
reindexButton.setAttribute('tooltiptext', str);
var show = false;
if (this.editable) {
show = yield Zotero.Fulltext.canReindex(this.item)
.tap(() => Zotero.Promise.check(this.item));
}
if (show) {
reindexButton.setAttribute('hidden', false);
}
else {
reindexButton.setAttribute('hidden', true);
}
}, this);
]]></body>
</method>
<method name="_id">
<parameter name="id"/>
<body>
<![CDATA[
return document.getAnonymousNodes(this)[0].getElementsByAttribute('id', id)[0];
]]>
</body>
</method>
</implementation>
<content>
<vbox id="attachment-box" flex="1" orient="vertical"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<vbox id="metadata">
<label id="title"/>
<label id="url" crop="end"
ondragstart="var dt = event.dataTransfer; dt.setData('text/x-moz-url', this.value); dt.setData('text/uri-list', this.value); dt.setData('text/plain', this.value);"/>
<grid>
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row id="fileNameRow">
<label id="fileName-label"/>
<label id="fileName" crop="end"/>
</row>
<row id="accessedRow">
<label id="accessed-label"/>
<label id="accessed"/>
</row>
<row id="pagesRow">
<label id="pages-label"/>
<label id="pages"/>
</row>
<row id="dateModifiedRow" hidden="true">
<label id="dateModified-label"/>
<label id="dateModified"/>
</row>
<row id="indexStatusRow">
<label id="index-status-label"/>
<hbox>
<label id="index-status"/>
<image id="reindex" onclick="this.hidden = true; setTimeout(function () { ZoteroPane_Local.reindexItem(); }, 50)"/>
</hbox>
</row>
</rows>
</grid>
</vbox>
<zoteronoteeditor id="attachment-note-editor" notitle="1" flex="1"/>
<button id="select-button" hidden="true"/>
</vbox>
</content>
</binding>
</bindings>

View file

@ -0,0 +1,140 @@
<?xml version="1.0"?>
<!--
An extension of the Mozilla colorpicker that allows for a custom set of colors
-->
<bindings id="colorpickerBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="custom-colorpicker" extends="chrome://global/content/bindings/colorpicker.xml#colorpicker">
<resources>
<stylesheet src="chrome://zotero/skin/bindings/customcolorpicker.css"/>
</resources>
<content>
<vbox anonid="tiles" flex="1" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<hbox>
<image class="colorpickertile" color="#000000"/>
</hbox>
</vbox>
</content>
<implementation implements="nsIDOMEventListener">
<constructor><![CDATA[
this.initialize();
this._colors = this.getAttribute('colors');
if (this._colors) {
this._cols = this.getAttribute('cols');
}
this.redraw();
]]></constructor>
<!-- Defaults from the Mozilla colorpicker -->
<field name="_defaultColors">
[
'L#FFFFFF','L#FFCCCC','L#FFCC99','L#FFFF99','L#FFFFCC','L#99FF99','L#99FFFF','L#CCFFFF','L#CCCCFF','L#FFCCFF',
'#CCCCCC','#FF6666','#FF9966','L#FFFF66','L#FFFF33','L#66FF99','L#33FFFF','L#66FFFF','#9999FF','#FF99FF',
'#C0C0C0','#FF0000','#FF9900','#FFCC66','L#FFFF00','L#33FF33','#66CCCC','#33CCFF','#6666CC','#CC66CC',
'#999999','#CC0000','#FF6600','#FFCC33','#FFCC00','#33CC00','#00CCCC','#3366FF','#6633FF','#CC33CC',
'#666666','#990000','#CC6600','#CC9933','#999900','#009900','#339999','#3333FF','#6600CC','#993399',
'#333333','#660000','#993300','#996633','#666600','#006600','#336666','#000099','#333399','#663366',
'#000000','#330000','#663300','#663333','#333300','#003300','#003333','#000066','#330099','#330033'
]
</field>
<field name="_defaultCols">10</field>
<property name="colors" onget="return this._colors ? this._colors : []">
<setter><![CDATA[
if (typeof val == 'string') {
val = val ? val.split(',') : null;
}
this._colors = val;
this.redraw();
]]></setter>
</property>
<property name="cols" onget="return this.getAttribute('cols')">
<setter><![CDATA[
this.setAttribute('cols', val);
this.redraw();
]]></setter>
</property>
<method name="redraw">
<body><![CDATA[
//Zotero.debug("Redrawing color picker");
var tiles = document.getAnonymousNodes(this)[0];
var cols = this.getAttribute('cols') || this._defaultCols;
var colors = this._colors.concat() || this._defaultColors.concat();
while (tiles.hasChildNodes()) {
tiles.removeChild(tiles.firstChild);
}
var rows = Math.ceil(colors.length / cols);
var tileWidth = this.getAttribute('tileWidth');
var tileHeight = this.getAttribute('tileHeight');
for (let i=0; i<rows; i++) {
var hbox = document.createElement('hbox');
for (let j=0; j<cols; j++) {
let color = colors.shift();
if (!color) {
break;
}
let light = color.charAt(0) == 'L';
color = light ? color.substr(1) : color;
let image = document.createElement('image');
image.className = 'colorpickertile' + (light ? ' cp-light' : '');
image.setAttribute('color', color);
let dataURI = "data:image/svg+xml,<svg style='background-color: "
+ encodeURIComponent(color) + "' xmlns='http://www.w3.org/2000/svg' />";
image.setAttribute('src', dataURI);
if (tileWidth) {
image.width = tileWidth;
}
if (tileHeight) {
image.height = tileHeight;
}
hbox.appendChild(image);
}
tiles.appendChild(hbox);
}
]]></body>
</method>
</implementation>
</binding>
<!-- The content of the Mozilla colorpicker-button, but with a customcolorpicker
with some extra inherited attributes instead -->
<binding id="custom-colorpicker-button" display="xul:menu"
extends="chrome://global/content/bindings/colorpicker.xml#colorpicker-button">
<resources>
<stylesheet src="chrome://zotero/skin/bindings/customcolorpicker.css"/>
</resources>
<content>
<xul:image class="colorpicker-button-colorbox" anonid="colorbox" flex="1" xbl:inherits="disabled"/>
<xul:panel class="colorpicker-button-menupopup"
anonid="colorpopup" noautofocus="true" level="top"
onmousedown="event.stopPropagation()"
onpopupshowing="this._colorPicker.onPopupShowing()"
onpopuphiding="this._colorPicker.onPopupHiding()"
onselect="this._colorPicker.pickerChange()">
<xul:customcolorpicker xbl:inherits="palettename,disabled,cols,columns,tileWidth,tileHeight" allowevents="true" anonid="colorpicker"/>
</xul:panel>
</content>
<implementation>
<property name="colors" onget="return this.mPicker.colors" onset="this.mPicker.colors = val"/>
</implementation>
</binding>
</bindings>

View file

@ -0,0 +1,183 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Copyright © 2012 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
-->
<?xml-stylesheet href="chrome://zotero/skin/overlay.css" type="text/css"?>
<!DOCTYPE bindings SYSTEM "chrome://zotero/locale/zotero.dtd">
<bindings xmlns="http://www.mozilla.org/xbl">
<binding id="file-sync-status">
<implementation>
<property name="data"
onget="return this._data;"
onset="this._data = val; this.refresh();">
</property>
<field name="_libraries">[]</field>
<method name="refresh">
<body>
<![CDATA[
var rows = this._id('rows');
// Get libraries with active downloads or uploads
var newLibraries = [];
for (var libraryID in this._data) {
if ((this._data[libraryID].download
&& !this._data[libraryID].download.finished)
||
(this._data[libraryID].upload
&& !this._data[libraryID].upload.finished)) {
newLibraries.push(parseInt(libraryID));
}
}
// If set of libraries is different, clear and recreate
var toRemove = Zotero.Utilities.arrayDiff(this._libraries, newLibraries);
var toAdd = Zotero.Utilities.arrayDiff(newLibraries, this._libraries);
if (toRemove.length || toAdd.length) {
while (rows.hasChildNodes()) {
rows.removeChild(rows.firstChild);
}
}
this._libraries = newLibraries;
// Update
if (rows.hasChildNodes()) {
for (var libraryID in this._data) {
var libraryStatus = this._data[libraryID];
// Library is finished
if (newLibraries.indexOf(parseInt(libraryID)) == -1) {
continue;
}
var libraryNameRow = this._id('library-name-row-' + libraryID);
var downloadsRow = this._id('downloads-row-' + libraryID);
var uploadsRow = this._id('uploads-row-' + libraryID);
downloadsRow.lastChild.setAttribute('value',
libraryStatus.download
? libraryStatus.download.statusString
: Zotero.getString('sync.storage.none'));
uploadsRow.lastChild.setAttribute('value',
libraryStatus.upload
? libraryStatus.upload.statusString
: Zotero.getString('sync.storage.none'));
}
}
// Build from scratch
else {
// Get ordered list of library names
var libraryNames = [];
for (let libraryID of newLibraries) {
libraryNames.push({
libraryID: libraryID,
name: Zotero.Libraries.getName(libraryID)
});
}
var collation = Zotero.getLocaleCollation();
let userLibraryID = Zotero.Libraries.userLibraryID;
libraryNames.sort(function (a, b) {
if (a.libraryID == userLibraryID) {
return -1;
}
if (b.libraryID == userLibraryID) {
return 1;
}
return collation.compareString(1, a.name, b.name);
});
for (var i in libraryNames) {
var libraryID = libraryNames[i].libraryID;
var libraryStatus = this._data[libraryID];
var label = document.createElement('label');
label.id = 'library-name-row-' + libraryID;
label.setAttribute('value', libraryNames[i].name);
rows.appendChild(label);
var row = this._createRow('download',
libraryStatus.download
? libraryStatus.download.statusString
: false);
row.id = 'downloads-row-' + libraryID;
rows.appendChild(row);
var row = this._createRow('upload',
libraryStatus.upload
? libraryStatus.upload.statusString
: false);
row.id = 'uploads-row-' + libraryID;
rows.appendChild(row);
}
}
]]>
</body>
</method>
<method name="_createRow">
<parameter name="type"/>
<parameter name="value"/>
<body>
<![CDATA[
var row = document.createElement('row');
var label = document.createElement('label');
label.setAttribute('value', Zotero.getString('sync.storage.' + type + 's'));
row.appendChild(label);
label = document.createElement('label');
label.setAttribute('value',
value ? value : Zotero.getString('sync.storage.none'));
row.appendChild(label);
return row;
]]>
</body>
</method>
<method name="_id">
<parameter name="id"/>
<body>
<![CDATA[
return document.getAnonymousNodes(this)[0].getElementsByAttribute('id', id)[0];
]]>
</body>
</method>
</implementation>
<content>
<grid xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1">
<columns>
<column/>
<column/>
</columns>
<rows id="rows"/>
</grid>
</content>
</binding>
</bindings>

View file

@ -0,0 +1,242 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Copyright © 2011 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
-->
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="guidancepanel">
<resources>
<stylesheet src="chrome://zotero/skin/bindings/guidancepanel.css"/>
</resources>
<implementation>
<property name="panel" onget="return document.getAnonymousNodes(this)[0]"/>
<!--
@param {Object} [options]
@param {String} [options.text] - Text to use in place of firstRunGuidance.<about>
@param {DOMElement} [options.forEl] - Anchor node
@param {Boolean} [options.force] - Show even if already shown, and don't update
firstRunGuidanceShown.<about> pref
-->
<method name="show">
<parameter name="options"/>
<body>
<![CDATA[
Components.utils.import("resource://gre/modules/Services.jsm");
if(!Zotero.Prefs.get("firstRunGuidance")) return;
options = options || {};
let text = options.text;
let useLastText = options.useLastText || false;
let forEl = options.forEl || document.getElementById(this.getAttribute("for"));
let force = options.force || false;
if (!forEl) return;
// Don't show two panels at once
if (Zotero.guidanceBeingShown) {
return;
}
var about = this.getAttribute("about");
var pref = false;
if (about) {
pref = "firstRunGuidanceShown." + about;
let shown = false;
try {
shown = Zotero.Prefs.get(pref);
} catch(e) {};
if (shown && !force) {
return;
}
}
Zotero.guidanceBeingShown = true;
var x = this.getAttribute("x"),
y = this.getAttribute("y"),
position = this.getAttribute("position");
if (!useLastText) {
if (!text) {
text = Zotero.getString("firstRunGuidance." + about);
}
text = text.split("\n");
var descriptionNode = this.id('panel-description');
while (descriptionNode.hasChildNodes()) {
descriptionNode.removeChild(descriptionNode.firstChild);
}
while(text.length) {
var textLine = text.shift();
descriptionNode.appendChild(document.createTextNode(textLine));
if(text.length) descriptionNode.appendChild(document.createElementNS(
"http://www.w3.org/1999/xhtml", "br"));
}
}
this.setAttribute(
"onpopuphidden",
"this.hidden = true; "
+ "Zotero.guidanceBeingShown = false; "
+ (this.getAttribute("onpopuphidden") || "")
);
this._initNavButton('back', options.back);
this._initNavButton('forward', options.forward);
var self = this;
var f = function() {
if (self.hasAttribute("foregroundonly") && Services.ww.activeWindow != window) return;
// Hide panel if content page changes
if (self.getAttribute('hideonpagechange') == "true") {
let popupShownListener = function () {
self.removeEventListener("popupshown", popupShownListener);
let appcontent = document.getElementById('appcontent');
let pageHideListener = function (event) {
var doc = event.originalTarget;
if(!(doc instanceof HTMLDocument)) return;
var rootDoc = doc.defaultView.top.document;
// Don't hide when frames and special URLs are unloaded
if (rootDoc != doc || !rootDoc.location.href.startsWith('http')) {
return;
}
appcontent.removeEventListener("pagehide", pageHideListener);
self.hide();
};
appcontent.addEventListener("pagehide", pageHideListener);
};
self.addEventListener("popupshown", popupShownListener);
}
self.hidden = false;
self.panel.openPopup(forEl, position ? position : "after_start",
x ? parseInt(x, 10) : 0, y ? parseInt(y, 10) : 0, false, false, null);
if (pref) {
Zotero.Prefs.set(pref, true);
}
};
if(this.hasAttribute("delay") && !force) {
window.setTimeout(f, this.getAttribute("delay"));
} else {
f();
}
if (this.getAttribute("noautohide") == 'true'
&& !this.hasAttribute('forward')) {
let listener = function () {
this.panel.removeEventListener("click", listener);
this.panel.hidePopup();
}.bind(this);
this.panel.addEventListener("click", listener);
}
]]>
</body>
</method>
<method name="hide">
<body>
<![CDATA[
document.getAnonymousNodes(this)[0].hidePopup();
]]>
</body>
</method>
<method name="_initNavButton">
<parameter name="dir"/>
<parameter name="nextID"/>
<body><![CDATA[
if (!nextID) {
nextID = this.getAttribute(dir);
}
if (!nextID) {
return;
}
var nextElem = document.getElementById(nextID);
button = this.id(dir + '-button');
button.hidden = false;
var target;
// If there's a forward action and no back action, the whole panel triggers
// the forward in noautohide mode
if (dir == 'forward' && !this.hasAttribute('back')
&& this.getAttribute('noautohide') == 'true') {
target = this.panel;
}
else {
target = button;
}
var listener = function (event) {
target.removeEventListener("click", listener);
this.hide();
var data = {
force: true
};
// Point the next panel back to this one
data[dir == 'back' ? 'forward' : 'back'] = this.getAttribute('id');
// When going backwards, don't regenerate text
if (dir == 'back') {
data.useLastText = true;
}
nextElem.show(data);
event.stopPropagation();
}.bind(this);
target.addEventListener("click", listener);
]]></body>
</method>
<method name="id">
<parameter name="id"/>
<body><![CDATA[
return document.getAnonymousNodes(this)[0].getElementsByAttribute('anonid', id)[0];
]]></body>
</method>
</implementation>
<content>
<xul:panel type="arrow" align="top" xbl:inherits="noautohide">
<xul:stack>
<xul:hbox align="center">
<xul:image src="chrome://zotero/skin/zotero-new-z-48px.png" style="margin-right: 10px; width: 48px; height: 48px;"/>
<xul:description anonid="panel-description" flex="1"></xul:description>
</xul:hbox>
<xul:hbox anonid="close-button-box">
<xul:toolbarbutton anonid="close-button" class="close-icon" hidden="true"/>
</xul:hbox>
<xul:hbox anonid="nav-buttons">
<xul:toolbarbutton anonid="back-button" oncommand="hide()" hidden="true"/>
<xul:toolbarbutton anonid="forward-button" oncommand="hide()" hidden="true"/>
</xul:hbox>
</xul:stack>
</xul:panel>
</content>
</binding>
</bindings>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,430 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
-->
<!DOCTYPE bindings SYSTEM "chrome://zotero/locale/zotero.dtd">
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<binding id="merge-group">
<resources>
<stylesheet src="chrome://zotero/skin/merge.css"/>
</resources>
<implementation>
<constructor>
<![CDATA[
this._leftpane = this._id('leftpane');
this._rightpane = this._id('rightpane');
this._mergepane = this._id('mergepane');
]]>
</constructor>
<field name="libraryID"/>
<field name="_data"/>
<property name="data" onget="return this._data;">
<setter>
<![CDATA[
this._data = val;
this.refresh();
]]>
</setter>
</property>
<property name="merged" onget="return this._mergepane.data"/>
<field name="_type"/>
<property name="type" onget="return this._type;">
<setter>
<![CDATA[
switch (val) {
case 'item':
case 'attachment':
case 'note':
case 'file':
break;
default:
throw new Error(`Unsupported merge object type '${type}'`);
}
this._type = val;
var hbox = document.getAnonymousNodes(this)[0];
hbox.setAttribute('mergetype', val);
]]>
</setter>
</property>
<property name="leftCaption" onset="this._leftpane.caption.label = val"/>
<property name="rightCaption" onset="this._rightpane.caption.label = val"/>
<property name="mergeCaption" onset="this._mergepane.caption.label = val"/>
<field name="_leftpane"/>
<property name="leftpane" onget="return this._leftpane"/>
<field name="_rightpane"/>
<property name="rightpane" onget="return this._rightpane"/>
<field name="_mergepane"/>
<property name="mergepane" onget="return this._mergepane"/>
<property name="onSelectionChange"/>
<method name="refresh">
<body>
<![CDATA[
if (this._data.left.deleted && this._data.right.deleted) {
throw new Error("'left' and 'right' cannot both be deleted");
}
// Check for note or attachment
if (!this.type) {
this.type = this._getTypeFromObject(
this._data.left.deleted ? this._data.right : this._data.left
);
}
var showButton = this.type != 'item';
this._leftpane.showButton = showButton;
this._rightpane.showButton = showButton;
this._leftpane.libraryID = this.libraryID;
this._rightpane.libraryID = this.libraryID;
this._mergepane.libraryID = this.libraryID;
this._leftpane.data = this._data.left;
this._rightpane.data = this._data.right;
this._mergepane.data = this._data.merge;
if (this._data.selected == 'left') {
this.choosePane(this._leftpane);
}
else {
this.choosePane(this._rightpane);
}
/*
Code to display only the different values -- not used
var diff = this._leftpane.ref.diff(this._rightpane.ref, true);
var fields = [];
var diffFields = [];
for (var field in diff[0].primary) {
fields.push(field);
if (diff[0].primary[field] != diff[1].primary[field]) {
diffFields.push(field);
}
}
for (var field in diff[0].fields) {
fields.push(field);
if (diff[0].fields[field] != diff[1].fields[field]) {
diffFields.push(field);
}
}
this._leftpane.objectbox.fieldOrder = fields;
this._rightpane.objectbox.fieldOrder = fields;
// Display merge pane if item types match
if (this._leftpane.ref.itemTypeID == this._rightpane.ref.itemTypeID) {
this._leftpane.objectbox.visibleFields = fields;
this._rightpane.objectbox.visibleFields = fields;
this._leftpane.objectbox.clickable = false;
this._rightpane.objectbox.clickable = false;
this._leftpane.objectbox.clickableFields = diffFields;
this._rightpane.objectbox.clickableFields = diffFields;
var mergeItem = new Zotero.Item(this._leftpane.ref.itemTypeID);
this._mergepane.ref = mergeItem;
this._mergepane.objectbox.visibleFields = fields;
}
// Otherwise only allow clicking on item types
else {
this._leftpane.objectbox.clickableFields = ['itemType'];
this._rightpane.objectbox.clickableFields = ['itemType'];
}
*/
this._mergepane.objectbox.editable = true;
/*
No need to refresh if not comparing fields
this._leftpane.objectbox.refresh();
this._rightpane.objectbox.refresh();
*/
]]>
</body>
</method>
<method name="choosePane">
<parameter name="pane"/>
<body>
<![CDATA[
if (pane.getAttribute('anonid') == 'leftpane') {
var position = 'left';
var otherPane = this._rightpane;
}
else {
var position = 'right';
var otherPane = this._leftpane;
}
pane.removeAttribute("selected");
otherPane.removeAttribute("selected");
pane.setAttribute("selected", "true");
if (pane.deleted) {
this._mergepane.deleted = true;
}
else {
this._mergepane.data = pane.data;
}
if (this.onSelectionChange) {
this.onSelectionChange();
}
]]>
</body>
</method>
<method name="_getTypeFromObject">
<parameter name="obj"/>
<body>
<![CDATA[
if (!obj.itemType) {
Zotero.debug(obj, 1);
throw new Error("obj is not item JSON");
}
if (obj.itemType == 'attachment' || obj.itemType == 'note') {
return obj.itemType;
}
return 'item';
]]>
</body>
</method>
<method name="_id">
<parameter name="id"/>
<body>
<![CDATA[
return document.getAnonymousNodes(this)[0].getElementsByAttribute('anonid',id)[0];
]]>
</body>
</method>
</implementation>
<content>
<xul:hbox id="merge-group" flex="1">
<xul:zoteromergepane anonid="leftpane" flex="1"/>
<xul:zoteromergepane anonid="rightpane" flex="1"/>
<xul:zoteromergepane anonid="mergepane" flex="1"/>
</xul:hbox>
</content>
</binding>
<binding id="merge-pane">
<resources>
<stylesheet src="chrome://zotero/skin/bindings/merge.css"/>
</resources>
<implementation>
<constructor>
<![CDATA[
this.parent = document.getBindingParent(this.parentNode);
this.isMergePane = this.getAttribute('anonid') == 'mergepane';
if (!this.isMergePane) {
this.pane.onclick = function () {
this.parent.choosePane(this);
}.bind(this);
}
]]>
</constructor>
<property name="type" onget="return this.parent.type" readonly="true"/>
<property name="caption" onget="return this._id('caption')" readonly="true"/>
<field name="showButton"/>
<property name="pane" onget="return document.getAnonymousNodes(this)[0]"/>
<property name="objectbox" onget="return this._id('objectbox')" readonly="true"/>
<field name="_deleted"/>
<property name="deleted">
<setter>
<![CDATA[
this._deleted = !!val;
var placeholder = this._id('object-placeholder');
if (placeholder) {
placeholder.hidden = !!val;
}
else {
this._id('objectbox').hidden = true;
}
var deleteBox = this._id('delete-box');
deleteBox.hidden = !val;
]]>
</setter>
</property>
<field name="libraryID"/>
<field name="_data"/>
<property name="data" onget="return this._data">
<setter>
<![CDATA[
this._data = val;
var button = this._id('choose-button');
button.label = Zotero.getString('sync.conflict.chooseThisVersion');
if (this.showButton) {
button.onclick = () => this.parent.choosePane(this);
button.style.visibility = 'visible';
}
else {
button.style.visibility = 'hidden';
}
if (val.deleted) {
this.deleted = true;
return;
}
this.deleted = false;
// Replace XUL placeholder with XUL object box of given type
var elementName;
switch (this.type) {
case 'item':
elementName = 'zoteroitembox';
break;
case 'attachment':
case 'file':
elementName = 'zoteroattachmentbox';
break;
case 'note':
elementName = 'zoteronoteeditor';
break;
default:
throw new Error("Object type '" + this.type + "' not supported");
}
var objbox = document.createElement(elementName);
var parentRow = this._id('parent-row');
if (val.parentItem) {
parentRow.textContent = '';
let label = document.createElement('span');
label.textContent = Zotero.getString('pane.item.parentItem');
parentRow.appendChild(label);
let parentItem = Zotero.Items.getByLibraryAndKey(this.libraryID, val.parentItem);
let text = document.createTextNode(" " + parentItem.getDisplayTitle(true));
parentRow.appendChild(text);
parentRow.hidden = false;
}
else {
parentRow.hidden = true;
}
if (this._id('object-placeholder')) {
var placeholder = this._id('object-placeholder');
placeholder.parentNode.replaceChild(objbox, placeholder);
}
else {
var oldObjBox = this._id('objectbox');
oldObjBox.parentNode.replaceChild(objbox, oldObjBox);
}
objbox.setAttribute("anonid", "objectbox");
objbox.setAttribute("flex", "1");
objbox.mode = this.type == 'file' ? 'filemerge' : 'merge';
// Store JSON
this._data = val;
// Create a copy of the JSON that we can clean for display, since the remote object
// might reference things that don't exist locally
var displayJSON = Object.assign({}, val);
displayJSON.collections = [];
// Create item from JSON for metadata box
var item = new Zotero.Item(val.itemType);
item.libraryID = this.libraryID;
item.fromJSON(displayJSON);
objbox.item = item;
]]>
</setter>
</property>
<field name="parent"/>
<method name="click">
<body><![CDATA[
this.pane.click();
]]></body>
</method>
<method name="_id">
<parameter name="id"/>
<body>
<![CDATA[
var elems = document.getAnonymousNodes(this)[0].getElementsByAttribute('anonid', id);
return elems.length ? elems[0] : false;
]]>
</body>
</method>
</implementation>
<content>
<xul:vbox flex="1">
<xul:groupbox anonid="merge-pane" flex="1">
<xul:caption anonid="caption"/>
<html:div anonid="parent-row" hidden="true"/>
<xul:box anonid="object-placeholder"/>
<xul:hbox anonid="delete-box" hidden="true" flex="1">
<xul:label value="&zotero.merge.deleted;"/>
</xul:hbox>
</xul:groupbox>
<xul:button anonid="choose-button"/>
</xul:vbox>
</content>
</binding>
</bindings>

View file

@ -0,0 +1,602 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
-->
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="note-editor">
<resources>
<stylesheet src="chrome://zotero/skin/bindings/noteeditor.css"/>
<stylesheet src="chrome://zotero-platform/content/noteeditor.css"/>
</resources>
<implementation>
<!--
Public properties
-->
<field name="editable">false</field>
<field name="saveOnEdit">false</field>
<field name="displayTags">false</field>
<field name="displayRelated">false</field>
<field name="displayButton">false</field>
<field name="buttonCaption"/>
<field name="parentClickHandler"/>
<field name="keyDownHandler"/>
<field name="commandHandler"/>
<field name="clickHandler"/>
<!-- Modes are predefined settings groups for particular tasks -->
<field name="_mode">"view"</field>
<property name="mode" onget="return this._mode;">
<setter>
<![CDATA[
// Duplicate default property settings here
this.editable = false;
this.saveOnEdit = false;
this.displayTags = false;
this.displayRelated = false;
this.displayButton = false;
switch (val) {
case 'view':
case 'merge':
// If there's an existing editor, mark it as read-only. This allows for
// disabling an existing editable note (e.g., if there's a save error).
if (this.noteField) {
this.noteField.onInit(ed => ed.setMode('readonly'));
}
break;
case 'edit':
this.editable = true;
this.saveOnEdit = true;
this.parentClickHandler = this.selectParent;
this.keyDownHandler = this.handleKeyDown;
this.commandHandler = this.save;
this.displayTags = true;
this.displayRelated = true;
break;
default:
throw ("Invalid mode '" + val + "' in noteeditor.xml");
}
this._mode = val;
document.getAnonymousNodes(this)[0].setAttribute('mode', val);
this._id('links-box').mode = val;
]]>
</setter>
</property>
<field name="_parentItem"/>
<property name="parentItem" onget="return this._parentItem;">
<setter>
<![CDATA[
this._parentItem = this._id('links-box').parentItem = val;
]]>
</setter>
</property>
<field name="_mtime"/>
<field name="_item"/>
<property name="item" onget="return this._item;">
<setter><![CDATA[
this._item = val;
// TODO: use clientDateModified instead
this._mtime = val.getField('dateModified');
var parentKey = this.item.parentKey;
if (parentKey) {
this.parentItem = Zotero.Items.getByLibraryAndKey(this.item.libraryID, parentKey);
}
this._id('links-box').item = this.item;
this.refresh();
]]></setter>
</property>
<property name="linksOnTop">
<setter>
<![CDATA[
if(val) {
var container = this._id('links-container');
var parent = container.parentNode;
var sib = container.nextSibling;
while (parent.firstChild !== container) {
parent.insertBefore(parent.removeChild(parent.firstChild), sib);
}
}
]]>
</setter>
</property>
<property name="note"
onget="Zotero.debug('Getting note with .note deprecated -- use .item in zoteronoteeditor'); return this._item"
onset="Zotero.debug('Setting note with .note deprecated -- use .item in zoteronoteeditor'); this.item = val"/>
<property name="ref" onget="return this._item" onset="this.item = val"/>
<field name="collection"/>
<property name="noteField" onget="return this._id('noteField')" readonly="true"/>
<property name="value" onget="return this._id('noteField').value;" onset="this._id('noteField').value = val;"/>
<constructor>
<![CDATA[
this.instanceID = Zotero.Utilities.randomString();
this._notifierID = Zotero.Notifier.registerObserver(this, ['item'], 'noteeditor');
]]>
</constructor>
<destructor>
<![CDATA[
Zotero.Notifier.unregisterObserver(this._notifierID);
]]>
</destructor>
<method name="notify">
<parameter name="event"/>
<parameter name="type"/>
<parameter name="ids"/>
<parameter name="extraData"/>
<body><![CDATA[
if (event != 'modify' || !this.item || !this.item.id) return;
for (let i = 0; i < ids.length; i++) {
let id = ids[i];
if (id != this.item.id) {
continue;
}
if (extraData && extraData[id] && extraData[id].noteEditorID == this.instanceID) {
//Zotero.debug("Skipping notification from current note field");
continue;
}
if (this.noteField.changed) {
//Zotero.debug("Note has changed since last save -- skipping refresh");
return;
}
this.refresh();
break;
}
]]></body>
</method>
<method name="refresh">
<body><![CDATA[
Zotero.debug('Refreshing note editor');
var textbox = this.noteField;
var textboxReadOnly = this._id('noteFieldReadOnly');
var button = this._id('goButton');
if (this.editable) {
textbox.hidden = false;
textboxReadOnly.hidden = true;
}
else {
textbox.hidden = true;
textboxReadOnly.hidden = false;
textbox = textboxReadOnly;
}
//var scrollPos = textbox.inputField.scrollTop;
if (this.item) {
// For sanity check in save()
textbox.setAttribute('itemID', this.item.id);
textbox.value = this.item.getNote();
}
else {
textbox.value = '';
textbox.removeAttribute('itemID');
}
//textbox.inputField.scrollTop = scrollPos;
this._id('links-container').hidden = !(this.displayTags && this.displayRelated);
this._id('links-box').refresh();
if (this.keyDownHandler) {
textbox.setAttribute('onkeydown',
'document.getBindingParent(this).handleKeyDown(event)');
}
else {
textbox.removeAttribute('onkeydown');
}
if (this.commandHandler) {
textbox.setAttribute('oncommand',
'document.getBindingParent(this).commandHandler()');
}
else {
textbox.removeAttribute('oncommand');
}
if (this.displayButton) {
button.label = this.buttonCaption;
button.hidden = false;
button.setAttribute('oncommand',
'document.getBindingParent(this).clickHandler(this)');
}
else {
button.hidden = true;
}
]]></body>
</method>
<method name="save">
<body><![CDATA[
return Zotero.spawn(function* () {
try {
if (this._mode == 'view') {
Zotero.debug("Not saving read-only note");
return;
}
var noteField = this._id('noteField');
var value = noteField.value;
if (value === null) {
Zotero.debug("Note value not available -- not saving", 2);
return;
}
// Update note
if (this.item) {
// If note field doesn't match item, abort save and run error handler
if (noteField.getAttribute('itemID') != this.item.id) {
throw new Error("Note field doesn't match current item");
}
let changed = this.item.setNote(value);
if (changed && this.saveOnEdit) {
this.noteField.changed = false;
yield this.item.saveTx({
notifierData: {
noteEditorID: this.instanceID
}
});
}
return;
}
// Create new note
var item = new Zotero.Item('note');
if (this.parentItem) {
item.libraryID = this.parentItem.libraryID;
}
item.setNote(value);
if (this.parentItem) {
item.parentKey = this.parentItem.key;
}
if (this.saveOnEdit) {
var id = yield item.saveTx();
if (!this.parentItem && this.collection) {
this.collection.addItem(id);
}
}
this.item = item;
}
catch (e) {
Zotero.logError(e);
if (this.hasAttribute('onerror')) {
let fn = new Function("", this.getAttribute('onerror'));
fn.call(this)
}
if (this.onError) {
this.onError(e);
}
}
}.bind(this));
]]></body>
</method>
<!-- Used to insert a tab manually -->
<method name="handleKeyDown">
<parameter name="event"/>
<body>
<![CDATA[
switch (event.keyCode) {
case 9:
if (event.ctrlKey || event.altKey) {
return;
}
event.stopPropagation();
event.preventDefault();
// On shift-tab, focus the element specified in
// the 'previousfocus' attribute
if (event.shiftKey) {
let id = this.getAttribute('previousfocus');
if (id) {
setTimeout(function () {
document.getElementById(id).focus();
}, 0);
}
return;
}
// Insert tab manually
//
// From http://kb.mozillazine.org/Inserting_text_at_cursor
try {
var command = "cmd_insertText";
var controller = document.commandDispatcher.getControllerForCommand(command);
if (controller && controller.isCommandEnabled(command)) {
controller = controller.QueryInterface(Components.interfaces.nsICommandController);
var params = Components.classes["@mozilla.org/embedcomp/command-params;1"]
.createInstance(Components.interfaces.nsICommandParams);
params.setStringValue("state_data", "\t");
controller.doCommandWithParams(command, params);
}
}
catch (e) {
Zotero.debug("Can't do cmd_insertText!\n" + e, 1);
}
// DEBUG: is there a better way to prevent blur()?
setTimeout(function() { event.target.focus(); }, 1);
break;
}
]]>
</body>
</method>
<method name="focus">
<body>
<![CDATA[
this._id('noteField').focus();
]]>
</body>
</method>
<method name="clearUndo">
<body>
<![CDATA[
this._id('noteField').clearUndo();
]]>
</body>
</method>
<method name="_id">
<parameter name="id"/>
<body>
<![CDATA[
return document.getAnonymousNodes(this)[0].getElementsByAttribute('id',id)[0];
]]>
</body>
</method>
</implementation>
<content>
<xul:vbox xbl:inherits="flex">
<xul:textbox id="noteField" type="styled" mode="note"
timeout="1000" flex="1" hidden="true"/>
<xul:textbox id="noteFieldReadOnly" type="styled" mode="note"
readonly="true" flex="1" hidden="true"/>
<xul:hbox id="links-container" hidden="true">
<xul:linksbox id="links-box" flex="1" xbl:inherits="notitle"/>
</xul:hbox>
<xul:button id="goButton" hidden="true"/>
</xul:vbox>
</content>
</binding>
<binding id="links-box">
<implementation>
<field name="itemRef"/>
<property name="item" onget="return this.itemRef;">
<setter>
<![CDATA[
this.itemRef = val;
this.id('tags').item = this.item;
this.id('related').item = this.item;
this.refresh();
]]>
</setter>
</property>
<property name="mode">
<setter>
<![CDATA[
this.id('related').mode = val;
this.id('tags').mode = val;
]]>
</setter>
</property>
<field name="_parentItem"/>
<property name="parentItem" onget="return this._parentItem;">
<setter>
<![CDATA[
this._parentItem = val;
var parentText = this.id('parentText');
if (parentText.firstChild) {
parentText.removeChild(parentText.firstChild);
}
if (this._parentItem && this.getAttribute('notitle') != '1') {
this.id('parent-row').hidden = undefined;
this.id('parentLabel').value = Zotero.getString('pane.item.parentItem');
parentText.appendChild(document.createTextNode(this._parentItem.getDisplayTitle(true)));
}
]]>
</setter>
</property>
<method name="tagsClick">
<body><![CDATA[
this.id('tags').reload();
var x = this.boxObject.screenX;
var y = this.boxObject.screenY;
this.id('tagsPopup').openPopupAtScreen(x, y, false);
// If editable and no existing tags, open new empty row
var tagsBox = this.id('tags');
if (tagsBox.mode == 'edit' && tagsBox.count == 0) {
this.id('tags').newTag();
}
]]></body>
</method>
<method name="refresh">
<body><![CDATA[
this.updateTagsSummary();
this.updateRelatedSummary();
]]></body>
</method>
<method name="updateTagsSummary">
<body><![CDATA[
var v = this.id('tags').summary;
if (!v || v == "") {
v = "[" + Zotero.getString('pane.item.noteEditor.clickHere') + "]";
}
this.id('tagsLabel').value = Zotero.getString('itemFields.tags')
+ Zotero.getString('punctuation.colon');
this.id('tagsClick').value = v;
]]></body>
</method>
<method name="relatedClick">
<body><![CDATA[
var relatedList = this.item.relatedItems;
if (relatedList.length > 0) {
var x = this.boxObject.screenX;
var y = this.boxObject.screenY;
this.id('relatedPopup').openPopupAtScreen(x, y, false);
}
else {
this.id('related').add();
}
]]></body>
</method>
<method name="updateRelatedSummary">
<body><![CDATA[
var v = this.id('related').summary;
if (!v || v == "") {
v = "[" + Zotero.getString('pane.item.noteEditor.clickHere') + "]";
}
this.id('relatedLabel').value = Zotero.getString('itemFields.related')
+ Zotero.getString('punctuation.colon');
this.id('relatedClick').value = v;
]]></body>
</method>
<method name="parentClick">
<body>
<![CDATA[
if (!this.item || !this.item.id) {
return;
}
if (document.getElementById('zotero-pane')) {
var zp = ZoteroPane;
}
else {
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var lastWin = wm.getMostRecentWindow("navigator:browser");
if (!lastWin) {
var lastWin = window.open();
}
if (lastWin.ZoteroOverlay && !lastWin.ZoteroPane.isShowing()) {
lastWin.ZoteroOverlay.toggleDisplay(true);
}
var zp = lastWin.ZoteroPane;
}
Zotero.spawn(function* () {
var parentID = this.item.parentID;
yield zp.clearQuicksearch();
zp.selectItem(parentID);
}, this);
]]>
</body>
</method>
<method name="id">
<parameter name="id"/>
<body>
<![CDATA[
return document.getAnonymousNodes(this)[0].getElementsByAttribute('id',id)[0];
]]>
</body>
</method>
</implementation>
<content>
<xul:vbox xbl:inherits="flex">
<xul:grid>
<xul:columns>
<xul:column/>
<xul:column flex="1"/>
</xul:columns>
<xul:rows>
<xul:row id="parent-row" hidden="true">
<xul:label id="parentLabel"/>
<xul:label id="parentText" class="zotero-clicky" crop="end" onclick="document.getBindingParent(this).parentClick();"/>
</xul:row>
<xul:row>
<xul:label id="relatedLabel"/>
<xul:label id="relatedClick" class="zotero-clicky" crop="end" onclick="document.getBindingParent(this).relatedClick();"/>
</xul:row>
<xul:row>
<xul:label id="tagsLabel"/>
<xul:label id="tagsClick" class="zotero-clicky" crop="end" onclick="document.getBindingParent(this).tagsClick();"/>
</xul:row>
</xul:rows>
</xul:grid>
<xul:popupset>
<xul:menupopup id="relatedPopup" width="300" onpopupshowing="this.firstChild.refresh();">
<xul:relatedbox id="related" flex="1"/>
</xul:menupopup>
<!-- The onpopup* stuff is an ugly hack to keep track of when the
popup is open (and not the descendent autocomplete popup, which also
seems to get triggered by these events for reasons that are less than
clear) so that we can manually refresh the popup if it's open after
autocomplete is used to prevent it from becoming unresponsive
Note: Code in tagsbox.xml is dependent on the DOM path between the
tagsbox and tagsLabel above, so be sure to update fixPopup() if it changes
-->
<xul:menupopup id="tagsPopup" ignorekeys="true"
onpopupshown="if (!document.commandDispatcher.focusedElement || document.commandDispatcher.focusedElement.tagName=='xul:label'){ /* DEBUG: it would be nice to make this work -- if (this.firstChild.count==0){ this.firstChild.newTag(); } */ this.setAttribute('showing', 'true'); }"
onpopuphidden="if (!document.commandDispatcher.focusedElement || document.commandDispatcher.focusedElement.tagName=='xul:label'){ this.setAttribute('showing', 'false'); }">
<xul:tagsbox id="tags" flex="1" mode="edit"/>
</xul:menupopup>
</xul:popupset>
</xul:vbox>
</content>
</binding>
</bindings>

View file

@ -0,0 +1,338 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
-->
<!DOCTYPE bindings SYSTEM "chrome://zotero/locale/zotero.dtd">
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="related-box">
<implementation>
<!-- Modes are predefined settings groups for particular tasks -->
<field name="_mode">"view"</field>
<property name="mode" onget="return this._mode;">
<setter>
<![CDATA[
this.clickable = false;
this.editable = false;
switch (val) {
case 'view':
case 'merge':
case 'mergeedit':
break;
case 'edit':
this.clickable = true;
this.editable = true;
//this.clickHandler = this.showEditor;
//this.blurHandler = this.hideEditor;
break;
default:
throw ("Invalid mode '" + val + "' in relatedbox.xml");
}
this._mode = val;
document.getAnonymousNodes(this)[0].setAttribute('mode', val);
]]>
</setter>
</property>
<field name="itemRef"/>
<property name="item" onget="return this.itemRef;">
<setter>
<![CDATA[
this.itemRef = val;
this.refresh();
]]>
</setter>
</property>
<property name="summary">
<getter>
<![CDATA[
var r = "";
if (this.item) {
var keys = this.item.relatedItems;
if (keys.length) {
for (let key of keys) {
let item = Zotero.Items.getByLibraryAndKey(this.item.libraryID, key);
if (!item) {
Zotero.debug(`Related item ${this.item.libraryID}/${key} not found `
+ `for item ${this.item.libraryKey}`, 2);
continue;
}
r = r + item.getDisplayTitle() + ", ";
}
r = r.substr(0,r.length-2);
}
}
return r;
]]>
</getter>
</property>
<constructor>
<![CDATA[
this._notifierID = Zotero.Notifier.registerObserver(this, ['item'], 'relatedbox');
]]>
</constructor>
<destructor>
<![CDATA[
Zotero.Notifier.unregisterObserver(this._notifierID);
]]>
</destructor>
<!-- TODO: Asyncify -->
<method name="notify">
<parameter name="event"/>
<parameter name="type"/>
<parameter name="ids"/>
<parameter name="extraData"/>
<body><![CDATA[
if (event != 'modify' || !this.item || !this.item.id) return;
for (let i = 0; i < ids.length; i++) {
let id = ids[i];
if (id != this.item.id) {
continue;
}
this.refresh();
break;
}
]]></body>
</method>
<method name="refresh">
<body><![CDATA[
var addButton = this.id('addButton');
addButton.hidden = !this.editable;
var rows = this.id('relatedRows');
while(rows.hasChildNodes())
rows.removeChild(rows.firstChild);
if (this.item) {
var relatedKeys = this.item.relatedItems;
for (var i = 0; i < relatedKeys.length; i++) {
let key = relatedKeys[i];
let relatedItem = Zotero.Items.getByLibraryAndKey(
this.item.libraryID, key
);
if (!relatedItem) {
Zotero.debug(`Related item ${this.item.libraryID}/${key} not found `
+ `for item ${this.item.libraryKey}`, 2);
continue;
}
let id = relatedItem.id;
let icon = document.createElement("image");
icon.className = "zotero-box-icon";
icon.setAttribute('src', relatedItem.getImageSrc());
var label = document.createElement("label");
label.className = "zotero-box-label";
label.setAttribute('value', relatedItem.getDisplayTitle());
label.setAttribute('crop','end');
label.setAttribute('flex','1');
var box = document.createElement('box');
box.setAttribute('onclick',
"document.getBindingParent(this).showItem(" + id + ")");
box.setAttribute('class','zotero-clicky');
box.setAttribute('flex','1');
box.appendChild(icon);
box.appendChild(label);
if (this.editable) {
var remove = document.createElement("label");
remove.setAttribute('value','-');
remove.setAttribute('onclick',
"document.getBindingParent(this).remove(" + id + ");");
remove.setAttribute('class','zotero-clicky zotero-clicky-minus');
}
var row = document.createElement("row");
row.appendChild(box);
if (this.editable) {
row.appendChild(remove);
}
rows.appendChild(row);
}
this.updateCount(rows.childNodes.length);
}
]]></body>
</method>
<method name="add">
<body><![CDATA[
return Zotero.spawn(function* () {
var io = {dataIn: null, dataOut: null};
window.openDialog('chrome://zotero/content/selectItemsDialog.xul', '',
'chrome,dialog=no,modal,centerscreen,resizable=yes', io);
if (!io.dataOut || !io.dataOut.length) {
return;
}
var relItems = yield Zotero.Items.getAsync(io.dataOut);
if (!relItems.length) {
return;
}
if (relItems[0].libraryID != this.item.libraryID) {
// FIXME
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
ps.alert(null, "", "You cannot relate items in different libraries.");
return;
}
yield Zotero.DB.executeTransaction(function* () {
for (let relItem of relItems) {
if (this.item.addRelatedItem(relItem)) {
yield this.item.save({
skipDateModifiedUpdate: true
});
}
if (relItem.addRelatedItem(this.item)) {
yield relItem.save({
skipDateModifiedUpdate: true
});
}
}
}.bind(this));
}, this);
]]></body>
</method>
<method name="remove">
<parameter name="id"/>
<body><![CDATA[
return Zotero.spawn(function* () {
var item = yield Zotero.Items.getAsync(id);
if (item) {
yield Zotero.DB.executeTransaction(function* () {
if (this.item.removeRelatedItem(item)) {
yield this.item.save({
skipDateModifiedUpdate: true
});
}
if (item.removeRelatedItem(this.item)) {
yield item.save({
skipDateModifiedUpdate: true
});
}
}.bind(this));
}
}, this);
]]></body>
</method>
<method name="showItem">
<parameter name="id"/>
<body>
<![CDATA[
if(id)
{
var p;
if(window.ZoteroPane_Local)
{
p = window.ZoteroPane_Local;
}
else
{
var win;
if(window.opener && window.opener.ZoteroPane)
{
win = window.opener;
}
else
{
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
win = wm.getMostRecentWindow('navigator:browser');
if(!win)
return;
}
p = win.ZoteroPane;
}
p.selectItem(id);
}
]]>
</body>
</method>
<method name="updateCount">
<parameter name="count"/>
<body>
<![CDATA[
if (count == null) {
var count = this.item.relatedItems.length;
}
var str = 'pane.item.related.count.';
switch (count){
case 0:
str += 'zero';
break;
case 1:
str += 'singular';
break;
default:
str += 'plural';
break;
}
this.id('relatedNum').value = Zotero.getString(str, [count]);
]]>
</body>
</method>
<method name="id">
<parameter name="id"/>
<body>
<![CDATA[
return document.getAnonymousNodes(this)[0].getElementsByAttribute('id',id)[0];
]]>
</body>
</method>
</implementation>
<content>
<xul:vbox xbl:inherits="flex" class="zotero-box">
<xul:hbox align="center">
<xul:label id="relatedNum"/>
<xul:button id="addButton" label="&zotero.item.add;"
oncommand="this.parentNode.parentNode.parentNode.add();"/>
</xul:hbox>
<xul:grid flex="1">
<xul:columns>
<xul:column flex="1"/>
<xul:column/>
</xul:columns>
<xul:rows id="relatedRows"/>
</xul:grid>
</xul:vbox>
</content>
</binding>
</bindings>

View file

@ -0,0 +1,54 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
-->
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="resizabledialog" extends="chrome://global/content/bindings/dialog.xml#dialog">
<content style="padding: 0">
<xul:vbox class="box-inherit dialog-content-box" flex="1" style="padding:14px 14px 0 14px">
<children/>
</xul:vbox>
<xul:stack>
<xul:hbox align="end" pack="end">
<xul:resizer dir="bottomright" style="-moz-appearance: resizer"/>
</xul:hbox>
<xul:hbox class="dialog-button-box" anonid="buttons"
xbl:inherits="pack=buttonpack,align=buttonalign,dir=buttondir,orient=buttonorient"
flex="1" style="padding: 10px 14px 14px 14px; margin: 0">
<xul:button dlgtype="disclosure" class="dialog-button" hidden="true"/>
<xul:button dlgtype="help" class="dialog-button" hidden="true"/>
<xul:button dlgtype="extra2" class="dialog-button" hidden="true"/>
<xul:button dlgtype="extra1" class="dialog-button" hidden="true"/>
<xul:spacer anonid="spacer" flex="1"/>
<xul:button dlgtype="cancel" class="dialog-button"/>
<xul:button dlgtype="accept" class="dialog-button" xbl:inherits="disabled=buttondisabledaccept"/>
</xul:hbox>
</xul:stack>
</content>
</binding>
</bindings>

View file

@ -0,0 +1,70 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
-->
<!DOCTYPE bindings SYSTEM "chrome://zotero/locale/zotero.dtd">
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="storage-file-box"
extends="chrome://zotero/content/bindings/attachmentbox.xml#attachment-box">
<implementation>
<property name="mode" onget="return this._mode;">
<setter>
<![CDATA[
this.editable = false;
this.displayGoButtons = false;
this.clickableLink = false;
this.displayIndexed = false;
this.displayPages = false;
this.displayNote = false;
switch (val) {
case 'merge':
this.displayFileName = true;
this.displayButton = true;
this.displayDateModified = true;
break;
case 'mergeedit':
this.displayFileName = true;
this.displayDateModified = true;
break;
default:
throw ("Invalid mode '" + val + "' in storagefilebox.xml");
}
this._mode = val;
document.getAnonymousNodes(this)[0].setAttribute('mode', val);
]]>
</setter>
</property>
</implementation>
</binding>
</bindings>

View file

@ -0,0 +1,785 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
-->
<!DOCTYPE bindings SYSTEM "chrome://zotero/locale/zotero.dtd">
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="styled-textbox">
<implementation>
<field name="_editable"/>
<field name="_mode"/>
<field name="_format"/>
<field name="_changed"/>
<field name="_loadHandler"/>
<field name="_commandString"/>
<field name="_eventHandler"/>
<field name="_editor"/>
<field name="_value"/>
<field name="_timer"/>
<field name="_focus"/>
<field name="_constructed"/>
<field name="_loadOnConstruct"/>
<constructor><![CDATA[
this.mode = this.getAttribute('mode');
this._iframe = document.getAnonymousElementByAttribute(this, "anonid", "rt-view");
// Atomic units, HTML -> RTF (cleanup)
//[/<\/p>(?!\s*$)/g, "\\par{}"],
//[/ /g, "&nbsp;"],
//[/\u00A0/g, " "],
this._htmlRTFmap = [
[/<br \/>/g, "\x0B"],
[/<span class=\"tab\">&nbsp;<\/span>/g, "\\tab{}"],
[/&lsquo;/g, ""],
[/&rsquo;/g, ""],
[/&ldquo;/g, "“"],
[/&rdquo;/g, "”"],
[/&nbsp;/g, "\u00A0"],
[/"(\w)/g, "“$1"],
[/([\w,.?!])"/g, "$1”"],
[/<p>/g, ""],
[/<\/?div[^>]*>/g, ""]
];
// Atomic units, RTF -> HTML (cleanup)
this._rtfHTMLmap = [
[/\\uc0\{?\\u([0-9]+)\}?(?:{}| )?/g, function(wholeStr, aCode) { return String.fromCharCode(aCode) }],
[/\\tab(?:\{\}| )/g, '<span class="tab">&nbsp;</span>'],
[/(?:\\par{}|\\\r?\n)/g, "</p><p>"]
];
this.prepare = function() {
// DEBUG: Does this actually happen?
if (this.prepared) return;
// Tag data
var _rexData = [
[
[
["<span +style=\"font-variant: *small-caps;\">"],
["{\\scaps ", "{\\scaps{}"]
],
[
["<\/span>"],
["}"]
]
],
[
[
["<span +style=\"text-decoration: *underline;\">"],
["{\\ul{}", "{\\ul "]
],
[
["<\/span>"],
["}"]
]
],
[
[
["<sup>"],
["\\super ", "\\super{}"]
],
[
["</sup>"],
["\\nosupersub{}", "\\nosupersub "]
]
],
[
[
["<sub>"],
["\\sub ", "\\sub{}"]
],
[
["</sub>"],
["\\nosupersub{}", "\\nosupersub "]
]
],
[
[
["<em>"],
["{\\i{}", "{\\i "]
],
[
["</em>"],
["}"]
]
],
[
[
["<i>"],
["{\\i{}", "{\\i "]
],
[
["</i>"],
["}"]
]
],
[
[
["<b>"],
["{\\b{}", "{\\b "]
],
[
["</b>"],
["}"]
]
],
[
[
["<strong>"],
["{\\b{}", "{\\b "]
],
[
["</strong>"],
["}"]
]
],
[
[
["<span +style=\"font-variant: *normal;\">"],
["{\\scaps0{}", "{\\scaps0 "]
],
[
["</span>"],
["}"]
]
],
[
[
["<span +style=\"font-style: *normal;\">"],
["{\\i0{}", "{\\i0 "]
],
[
["</span>"],
["}"]
]
],
[
[
["<span +style=\"font-weight: *normal;\">"],
["{\\b0{}", "{\\b0 "]
],
[
["</span>"],
["}"]
]
]
];
function longestFirst(a, b) {
if (a.length < b.length) {
return 1;
} else if (a.length > b.length) {
return -1;
} else {
return 0;
}
}
function normalizeRegExpString(str) {
if (!str) return str;
return str.replace(/\s+/g, " ")
.replace(/(?:[\+]|\s[\*])/g, "")
.replace(/[\']/g, '\"')
.replace(/:\s/g, ":");
}
this.normalizeRegExpString = normalizeRegExpString;
function composeRex(rexes, noGlobal) {
var lst = [];
for (var rex in rexes) {
lst.push(rex);
}
lst.sort(longestFirst);
var rexStr = "(?:" + lst.join("|") + ")";
return new RegExp(rexStr, "g");
}
// Create splitting regexps
function splitRexMaker(segment) {
var rexes = {};
for (var i=0,ilen=_rexData.length; i < ilen; i++) {
for (var j=0,jlen=_rexData[i].length; j < jlen; j++) {
for (var k=0,klen=_rexData[i][j][segment].length; k < klen; k++) {
rexes[_rexData[i][j][segment][k].replace("\\", "\\\\")] = true;
}
}
}
var ret = composeRex(rexes, true);
return ret;
}
this.rtfHTMLsplitRex = splitRexMaker(1);
this.htmlRTFsplitRex = splitRexMaker(0);
// Create open-tag sniffing regexp
function openSniffRexMaker(segment) {
var rexes = {};
for (var i=0,ilen=_rexData.length; i < ilen; i++) {
for (var j=0,jlen=_rexData[i][0][segment].length; j < jlen; j++) {
rexes[_rexData[i][0][segment][j].replace("\\", "\\\\")] = true;
}
}
return composeRex(rexes);
}
this.rtfHTMLopenSniffRex = openSniffRexMaker(1);
this.htmlRTFopenSniffRex = openSniffRexMaker(0);
// Create open-tag remapper
function openTagRemapMaker(segment) {
var ret = {};
for (var i=0,ilen=_rexData.length; i < ilen; i++) {
var primaryVal = normalizeRegExpString(_rexData[i][0][segment][0]);
for (var j=0,jlen=_rexData[i][0][segment].length; j < jlen; j++) {
var key = normalizeRegExpString(_rexData[i][0][segment][j]);
ret[key] = primaryVal;
}
}
return ret;
}
this.rtfHTMLopenTagRemap = openTagRemapMaker(1);
this.htmlRTFopenTagRemap = openTagRemapMaker(0);
// Create open-tag-keyed close-tag sniffing regexps
function closeTagRexMaker(segment) {
var ret = {};
var rexes = {};
for (var i=0,ilen=_rexData.length; i < ilen; i++) {
var primaryVal = _rexData[i][0][segment][0];
for (var j=0,jlen=_rexData[i][1][segment].length; j < jlen; j++) {
rexes[_rexData[i][1][segment][j]] = true;
}
ret[primaryVal] = composeRex(rexes);
}
return ret;
}
this.rtfHTMLcloseTagRex = closeTagRexMaker(1);
this.htmlRTFcloseTagRex = closeTagRexMaker(0);
// Create open-tag-keyed open/close tag registry
function tagRegistryMaker(segment) {
var antisegment = 1;
if (segment == 1) {
antisegment = 0;
}
var ret = {};
for (var i=0,ilen=_rexData.length; i < ilen; i++) {
var primaryVal = normalizeRegExpString(_rexData[i][0][segment][0]);
ret[primaryVal] = {
open: normalizeRegExpString(_rexData[i][0][antisegment][0]),
close: _rexData[i][1][antisegment][0]
}
}
return ret;
}
this.rtfHTMLtagRegistry = tagRegistryMaker(1);
this.htmlRTFtagRegistry = tagRegistryMaker(0);
this.prepared = true;
}
this.prepare();
this.getSplit = function(mode, txt) {
if (!txt) return [];
var splt = txt.split(this[mode + "splitRex"]);
var mtch = txt.match(this[mode + "splitRex"]);
var lst = [splt[0]];
for (var i=1,ilen=splt.length; i < ilen; i++) {
lst.push(mtch[i-1]);
lst.push(splt[i]);
}
return lst;
}
this.getOpenTag = function(mode, str) {
var m = str.match(this[mode + "openSniffRex"]);
if (m) {
m = this[mode + "openTagRemap"][this.normalizeRegExpString(m[0])];
}
return m;
}
this.convert = function(mode, txt) {
var lst = this.getSplit(mode, txt);
var sdepth = 0;
var depth = 0;
for (var i=1,ilen=lst.length; i < ilen; i += 2) {
var openTag = this.getOpenTag(mode, lst[i]);
if (openTag) {
sdepth++;
depth = sdepth;
for (var j=(i+2),jlen=lst.length; j < jlen; j += 2) {
var closeTag = !this.getOpenTag(mode, lst[j]);
if (closeTag) {
if (depth === sdepth && lst[j].match(this[mode + "closeTagRex"][openTag])) {
lst[i] = this[mode + "tagRegistry"][openTag].open;
lst[j] = this[mode + "tagRegistry"][openTag].close;
break;
}
depth--;
} else {
depth++;
}
}
} else {
sdepth--;
}
}
return lst.join("");
}
this.htmlToRTF = function(txt) {
txt = this.convert("htmlRTF", txt);
for (var i=0,ilen=this._htmlRTFmap.length; i < ilen; i++) {
var entry = this._htmlRTFmap[i];
txt = txt.replace(entry[0], entry[1]);
}
txt = Zotero.Utilities.unescapeHTML(txt);
txt = txt.replace(/[\x7F-\uFFFF]/g, function(aChar) { return "\\uc0\\u"+aChar.charCodeAt(0).toString()+"{}"});
return txt.trim();
}
this.rtfToHTML = function(txt) {
for (var i=0,ilen=this._rtfHTMLmap.length; i < ilen; i++) {
var entry = this._rtfHTMLmap[i];
txt = txt.replace(entry[0], entry[1]);
}
txt = this.convert("rtfHTML", txt);
return txt.trim();
}
this._constructed = true;
// Don't load if a value hasn't yet been set
if (this._loadOnConstruct) {
this._load();
}
]]></constructor>
<property name="mode">
<getter><![CDATA[
if (!this._mode) {
throw ("mode is not defined in styled-textbox.xml");
}
return this._mode;
]]></getter>
<setter><![CDATA[
Zotero.debug("Setting mode to " + val);
switch (val) {
case 'note':
this._eventHandler = function (event) {
// Necessary in Fx32+
if (event.wrappedJSObject) {
event = event.wrappedJSObject;
}
var commandEvent = false;
if (Zotero.Prefs.get('debugNoteEvents')) {
Zotero.debug(event.type);
Zotero.debug(event.which);
}
switch (event.type) {
case 'keydown':
// Handle forward-delete, which doesn't register as a keypress
// when a selection is cleared
if (event.which == event.DOM_VK_DELETE) {
this._changed = true;
commandEvent = true;
}
break;
case 'keypress':
// Ignore keypresses that don't change
// any text
//Zotero.debug(event.which);
if (!event.which &&
event.keyCode != event.DOM_VK_DELETE &&
event.keyCode != event.DOM_VK_BACK_SPACE) {
//Zotero.debug("Not a char");
return;
}
this._changed = true;
commandEvent = true;
break;
// 'change' includes text added via drag-and-drop
case 'change':
case 'undo':
case 'redo':
this._changed = true;
commandEvent = true;
break;
case 'ZoteroLinkClick':
var zp = typeof ZoteroPane != 'undefined'
? ZoteroPane
: window.opener.ZoteroPane;
zp.loadURI(event.value);
break;
default:
return;
}
// Trigger command on change
if (commandEvent && this.timeout) {
if (this._timer) {
clearTimeout(this._timer);
}
this._timer = setTimeout(function () {
var attr = this.getAttribute('oncommand');
attr = attr.replace('this', 'thisObj');
var func = new Function('thisObj', 'event', attr);
func(this, event);
}.bind(this), this.timeout);
}
return true;
}.bind(this);
break;
case 'integration':
break;
default:
throw ("Invalid mode '" + val + "' in styled-textbox.xml");
}
return this._mode = val;
]]></setter>
</property>
<!-- Sets or returns formatting (currently, HTML or Integration) of rich text box -->
<property name="initialized">
<getter><![CDATA[
return !!this._editor;
]]></getter>
</property>
<!-- Sets or returns formatting (currently, HTML or Integration) of rich text box -->
<property name="format">
<getter><![CDATA[
return this._format;
]]></getter>
<setter><![CDATA[
return this._format = val;
]]></setter>
</property>
<!-- Sets or returns contents of rich text box -->
<property name="value">
<getter><![CDATA[
if (!this._editor) {
return null;
}
var output = this._editor.getContent().trim();
if(this._format == "RTF") {
// strip divs
if(output.substr(0, 5) == "<div>" && output.substr(-6) == "</div>") {
output = output.slice(0, output.length-6).slice(5).trim();
}
output = this.htmlToRTF(output)
}
return output;
]]></getter>
<setter><![CDATA[
if (self._timer) {
clearTimeout(self._timer);
}
if(!this._editor) {
Zotero.debug('No editor yet');
this._value = val;
if (!this._constructed) {
Zotero.debug('Styled textbox not yet constructed', 2);
this._loadOnConstruct = true;
}
else if (!this._loaded) {
this._load();
}
return ;
}
if (this.value == val) {
Zotero.debug("Textbox value hasn't changed");
this._changed = false;
return;
}
var html = val;
if(this._format == "RTF") {
var bodyStyle = "";
if(html.substr(0, 3) == "\\li") {
// try to show paragraph formatting
var returnIndex = html.indexOf("\r\n");
var tags = html.substr(1, returnIndex).split("\\");
html = html.substr(returnIndex+2);
for(var i=0; i<tags.length; i++) {
var tagName = tags[i].substr(0, 2);
var tagValue = tags[i].substring(2, tags[i].length-1);
if(tagName == "li") {
var li = parseInt(tagValue, 10);
} else if(tagName == "fi") {
var fi = parseInt(tagValue, 10);
}
}
// don't negatively indent
if(fi < 0 && li == 0) li = -fi;
bodyStyle = "margin-left:"+(li/20+6)+"pt;text-indent:"+(fi/20)+"pt;";
}
html = this.rtfToHTML(html);
html = '<div style="'+bodyStyle+'"><p>'+html+"</p></div>";
}
Zotero.debug("Setting content to " + html);
this._editor.setContent(html);
this._changed = false;
return val;
]]></setter>
</property>
<property name="timeout"
onset="this.setAttribute('timeout', val); return val;"
onget="return parseInt(this.getAttribute('timeout')) || 0;"/>
<property name="changed" onget="return this._changed;" onset="this._changed = !!val;"/>
<method name="focus">
<body>
<![CDATA[
if (this._editor) {
this._iframe.focus();
this._editor.focus();
this._focus = false;
}
else {
this._focus = true;
}
]]>
</body>
</method>
<method name="clearUndo">
<body>
<![CDATA[
if (this._editor) {
this._editor.undoManager.clear();
this._editor.undoManager.add();
}
]]>
</body>
</method>
<method name="onInit">
<parameter name="callback"/>
<body><![CDATA[
if (this.initialized) {
callback(this._editor);
}
else {
if (!this._onInitCallbacks) {
this._onInitCallbacks = [];
}
this._onInitCallbacks.push(callback);
}
]]></body>
</method>
<field name="_loaded"/>
<method name="_load">
<body>
<![CDATA[
this._loaded = true;
// Unless we find a better way, use a separate HTML file
// for read-only mode
var htmlFile = this.mode + (this.getAttribute('readonly') != 'true' ? "" : "view");
var ios = Components.classes["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService);
var uri = ios.newURI("resource://zotero/tinymce/" + htmlFile + ".html", null, null);
// Pass directionality (LTR/RTL) and locale in URL
uri.spec += "?locale=" + encodeURIComponent(Zotero.locale)
+ "&dir=" + Zotero.dir;
Zotero.debug("Loading " + uri.spec);
// Register handler for deferred setting of content
var self = this;
var matchTo = null;
var listener = function(e) {
var win = self._iframe.contentWindow;
var SJOW = win.wrappedJSObject;
// only fire if the target matches, or _zoteroMatchTo, which we set last
// time the target matched, matches
if(e.target !== self._iframe.contentDocument
&& (!SJOW._zoteroMatchTo || SJOW._zoteroMatchTo !== matchTo)) return;
if (!SJOW.tinyMCE) {
Zotero.getInstalledExtensions().then(function(exts) {
for (let ext of exts) {
if (ext.indexOf('NoScript') != -1 && ext.indexOf('disabled') == -1) {
var doc = win.document;
var div = doc.getElementById('tinymce');
var warning = doc.createElement('div');
warning.id = 'noScriptWarning';
var str = "The NoScript extension is preventing Zotero "
+ "from displaying notes. To use NoScript and Zotero together, "
+ "whitelist the 'file:' scheme in the NoScript preferences "
+ "and restart " + Zotero.appName + ".";
warning.appendChild(document.createTextNode(str));
div.appendChild(warning);
break;
}
}
});
return;
}
if (!SJOW.zoteroInit) {
SJOW.zoteroInit = function(editor) {
// Necessary in Fx32+
if (editor.wrappedJSObject) {
self._editor = editor.wrappedJSObject;
}
else {
self._editor = editor;
}
if (self._value) {
self.value = self._value;
// Prevent undoing to empty note after initialization
self._editor.undoManager.clear();
self._editor.undoManager.add();
}
if (self._focus) {
setTimeout(function () {
self._iframe.focus();
self._editor.focus();
});
self._focus = false;
}
// Add CSS rules to notes
if (self.mode == 'note') {
let fontSize = Zotero.Prefs.get('note.fontSize');
// Fix empty old font prefs before a value was enforced
if (fontSize < 6) {
fontSize = 11;
}
var css = "body#zotero-tinymce-note, "
+ "body#zotero-tinymce-note p, "
+ "body#zotero-tinymce-note th, "
+ "body#zotero-tinymce-note td, "
+ "body#zotero-tinymce-note pre { "
+ "font-size: " + fontSize + "px; "
+ "} "
+ "body#zotero-tinymce-note, "
+ "body#zotero-tinymce-note p { "
+ "font-family: "
+ Zotero.Prefs.get('note.fontFamily') + "; "
+ "}"
+ Zotero.Prefs.get('note.css');
var doc = editor.contentDocument;
var head = doc.getElementsByTagName("head")[0];
var style = doc.createElement("style");
style.innerHTML = css;
head.appendChild(style);
}
let cb;
if (this._onInitCallbacks) {
while (cb = this._onInitCallbacks.shift()) {
cb(this._editor);
}
}
}.bind(this);
}
var editor = SJOW.tinyMCE.get("tinymce");
if (!editor) {
Zotero.debug("editor not ready");
// this is a hack; I'm not sure why we can't identify the event target
// next time without it, but apparently we can't
matchTo = Zotero.randomString();
SJOW._zoteroMatchTo = matchTo;
// Not ready yet
return;
}
self._iframe.removeEventListener("DOMContentLoaded", listener, false);
if (self._eventHandler) {
win.wrappedJSObject.zoteroHandleEvent = self._eventHandler;
}
// Run Cut/Copy/Paste with chrome privileges
win.wrappedJSObject.zoteroExecCommand = function (doc, command, ui, value) {
return doc.execCommand(command, ui, value);
}
}.bind(this);
this._iframe.addEventListener("DOMContentLoaded", listener, false);
this._iframe.webNavigation.loadURI(uri.spec,
Components.interfaces.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY, null, null, null);
]]>
</body>
</method>
</implementation>
<content>
<xul:iframe flex="1" anonid="rt-view" class="rt-view" type="content"
xbl:inherits="onfocus,onblur,flex,width,height,hidden"
style="overflow: hidden"/>
</content>
</binding>
</bindings>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,129 @@
<?xml version="1.0"?>
<!-- ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Toolkit.
*
* The Initial Developer of the Original Code is
* the Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** -->
<bindings id="textBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<binding id="text-link" extends="chrome://global/content/bindings/text.xml#text-label">
<implementation implements="nsIAccessibleProvider">
<property name="accessibleType" readonly="true">
<getter>
<![CDATA[
return Components.interfaces.nsIAccessibleProvider.XULLink;
]]>
</getter>
</property>
<property name="href" onget="return this.getAttribute('href');"
onset="this.setAttribute('href', val); return val;" />
<method name="open">
<parameter name="aEvent"/>
<body>
<![CDATA[
var href = this.href;
if (!href || this.disabled || aEvent.getPreventDefault())
return;
var uri = null;
try {
const nsISSM = Components.interfaces.nsIScriptSecurityManager;
const secMan =
Components.classes["@mozilla.org/scriptsecuritymanager;1"]
.getService(nsISSM);
const ioService =
Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
uri = ioService.newURI(href, null, null);
var nullPrincipal =
Components.classes["@mozilla.org/nullprincipal;1"]
.createInstance(Components.interfaces.nsIPrincipal);
try {
secMan.checkLoadURIWithPrincipal(nullPrincipal, uri,
nsISSM.DISALLOW_INHERIT_PRINCIPAL)
}
catch (ex) {
var msg = "Error: Cannot open a " + uri.scheme + ": link using \
the text-link binding.";
Components.utils.reportError(msg);
return;
}
const cID = "@mozilla.org/uriloader/external-protocol-service;1";
const nsIEPS = Components.interfaces.nsIExternalProtocolService;
var protocolSvc = Components.classes[cID].getService(nsIEPS);
// if the scheme is not an exposed protocol, then opening this link
// should be deferred to the system's external protocol handler
if (!protocolSvc.isExposedProtocol(uri.scheme)
|| (window.Zotero && window.Zotero.isStandalone && ["http", "https"].indexOf(uri.scheme) !== -1)) {
protocolSvc.loadUrl(uri);
aEvent.preventDefault()
return;
}
}
catch (ex) {
Components.utils.reportError(ex);
}
// otherwise, fall back to opening the anchor directly
var win = window;
if (window instanceof Components.interfaces.nsIDOMChromeWindow) {
while (win.opener && !win.opener.closed)
win = win.opener;
}
if (uri)
win.open(uri.spec);
else
win.open(href);
aEvent.preventDefault();
]]>
</body>
</method>
</implementation>
<handlers>
<handler event="click" phase="capturing" button="0" action="this.open(event)"/>
<handler event="keypress" preventdefault="true" keycode="VK_ENTER" action="this.click()" />
<handler event="keypress" preventdefault="true" keycode="VK_RETURN" action="this.click()" />
</handlers>
</binding>
</bindings>

View file

@ -0,0 +1,293 @@
<?xml version="1.0"?>
<!--
A combination of Mozilla's textarea, timed-textbox, input-box, and
input-box-spell bindings, with the timed-textbox's Return key
event handler removed
Note: It would be much nicer if a) Mozilla offered this natively or
b) we just extended the timed-textbox binding directly, but since it's based
on html:input rather than html:textarea, doing so breaks things in various
ways (though it may be possible with some tweaking)
Also note: spellcheck code here is a slightly adjusted version
of a patch by Neil Deakin on Bugzilla that wasn't approved in time for
Firefox 2.0 (https://bugzilla.mozilla.org/show_bug.cgi?id=346787).
When there's native support for spellcheck="true" in XUL, we'll hopefully be
able to use that, though it'll still need to work as a timed textarea...
-->
<!DOCTYPE bindings [
<!ENTITY % textcontextDTD SYSTEM "chrome://global/locale/textcontext.dtd" >
%textcontextDTD;
<!-- These aren't yet included in textcontext.dtd in Minefield, so we reproduce them here
(rather than including the massive browser.dtd) -->
<!ENTITY spellAddToDictionary.label "Add to dictionary">
<!ENTITY spellAddToDictionary.accesskey "o">
<!ENTITY spellEnable.label "Spell check this field">
<!ENTITY spellEnable.accesskey "S">
<!ENTITY spellNoSuggestions.label "(No spelling suggestions)">
<!ENTITY spellDictionaries.label "Languages">
<!ENTITY spellDictionaries.accesskey "l">
<!ENTITY spellAddDictionaries.label "Add dictionaries...">
<!ENTITY spellAddDictionaries.accesskey "A">
]>
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="timed-textarea" extends="chrome://global/content/bindings/textbox.xml#textbox">
<implementation>
<field name="mInputField">null</field>
<property name="inputField" readonly="true">
<getter><![CDATA[
if (!this.mInputField)
this.mInputField = document.getAnonymousElementByAttribute(this, "anonid", "input");
return this.mInputField;
]]></getter>
</property>
<field name="_timer">null</field>
<property name="timeout"
onset="this.setAttribute('timeout', val); return val;"
onget="return parseInt(this.getAttribute('timeout')) || 0;"/>
<property name="value">
<getter>
return this.inputField.value;
</getter>
<setter>
<![CDATA[
this.inputField.value = val;
if (this._timer)
clearTimeout(this._timer);
return val;
]]>
</setter>
</property>
<method name="_fireCommand">
<parameter name="me"/>
<body>
<![CDATA[
me._timer = null;
me.doCommand();
]]>
</body>
</method>
<!-- Spellcheck code -->
<field name="_spellCheckInitialized">false</field>
<property name="spellCheckerUI" readonly="true">
<getter><![CDATA[
if (!this._spellCheckInitialized) {
this._spellCheckInitialized = true;
const CI = Components.interfaces;
if (!document instanceof CI.nsIDOMXULDocument)
return null;
var textbox = this;
if (!textbox || !textbox instanceof CI.nsIDOMXULTextBoxElement)
return null;
try {
var loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].
getService(CI.mozIJSSubScriptLoader);
loader.loadSubScript("chrome://global/content/inlineSpellCheckUI.js", this);
if ("InlineSpellCheckerUI" in this)
this.InlineSpellCheckerUI.init(
textbox.inputField.QueryInterface(CI.nsIDOMNSEditableElement).editor
);
} catch(ex) {
// this throws an error on window open...
}
}
return this.InlineSpellCheckerUI;
]]></getter>
</property>
<constructor>
<![CDATA[
// can't initialize the spell checker in the constructor as not
// everything is initialized and the editor will fail to create the
// inline spell checker object
setTimeout(this._delayedInitSpellCheck, 0, this)
// oninput doesn't seem to fire on text drag
this.inputField.addEventListener('dragdrop', function(event) {
document.getBindingParent(event.target).doInput();
}, false);
]]>
</constructor>
<method name="_delayedInitSpellCheck">
<parameter name="me"/>
<body><![CDATA[
var spellui = me.spellCheckerUI;
if (spellui)
spellui.enabled = true;
]]></body>
</method>
<method name="_doPopupItemEnabling">
<parameter name="popupNode"/>
<body>
<![CDATA[
var children = popupNode.childNodes;
for (var i = 0; i < children.length; i++) {
var command = children[i].getAttribute("cmd");
if (command) {
var controller = document.commandDispatcher.getControllerForCommand(command);
var enabled = controller.isCommandEnabled(command);
if (enabled) {
children[i].removeAttribute("disabled");
}
else {
children[i].setAttribute("disabled", "true");
}
}
}
]]>
</body>
</method>
<method name="_doPopupItemEnablingSpell">
<parameter name="popupNode"/>
<body>
<![CDATA[
var spellui = this.spellCheckerUI;
if (!spellui || !spellui.canSpellCheck) {
this._setMenuItemVisibility("spell-no-suggestions", false);
this._setMenuItemVisibility("spell-check-enabled", false);
this._setMenuItemVisibility("spell-check-separator", false);
this._setMenuItemVisibility("spell-add-to-dictionary", false);
this._setMenuItemVisibility("spell-suggestions-separator", false);
this._setMenuItemVisibility("spell-dictionaries", false);
return;
}
spellui.initFromEvent(document.popupRangeParent,
document.popupRangeOffset);
var enabled = spellui.enabled;
document.getAnonymousElementByAttribute(this, "anonid",
"spell-check-enabled").setAttribute("checked", enabled);
var overMisspelling = spellui.overMisspelling;
this._setMenuItemVisibility("spell-add-to-dictionary", overMisspelling);
this._setMenuItemVisibility("spell-suggestions-separator", overMisspelling);
// suggestion list
var suggestionsSeparator = document.getAnonymousElementByAttribute(this,
"anonid", "spell-add-to-dictionary");
var numsug = spellui.addSuggestionsToMenu(popupNode, suggestionsSeparator, 5);
this._setMenuItemVisibility("spell-no-suggestions", overMisspelling && numsug == 0);
// dictionary list
var dictmenu = document.getAnonymousElementByAttribute(this, "anonid",
"spell-dictionaries-menu");
var addsep = document.getAnonymousElementByAttribute(this, "anonid",
"spell-language-separator");
var numdicts = spellui.addDictionaryListToMenu(dictmenu, addsep);
this._setMenuItemVisibility("spell-dictionaries", enabled);
this._doPopupItemEnabling(popupNode);
]]>
</body>
</method>
<method name="_doPopupItemDisabling">
<body><![CDATA[
if (this.spellCheckerUI) {
this.spellCheckerUI.clearSuggestionsFromMenu();
this.spellCheckerUI.clearDictionaryListFromMenu();
}
]]></body>
</method>
<method name="_setMenuItemVisibility">
<parameter name="anonid"/>
<parameter name="visible"/>
<body><![CDATA[
document.getAnonymousElementByAttribute(this, "anonid", anonid).
hidden = ! visible;
]]></body>
</method>
<method name="doTextCommand">
<parameter name="command"/>
<body>
<![CDATA[
var controller = document.commandDispatcher.getControllerForCommand(command);
controller.doCommand(command);
]]>
</body>
</method>
<method name="doInput">
<body>
<![CDATA[
if (this._timer) {
clearTimeout(this._timer);
}
this._timer = this.timeout && setTimeout(this._fireCommand, this.timeout, this);
]]>
</body>
</method>
</implementation>
<handlers>
<handler event="input">
<![CDATA[
this.doInput();
]]>
</handler>
</handlers>
<content context="_child">
<xul:hbox class="textbox-input-box" flex="1">
<html:textarea class="textbox-textarea" flex="1" anonid="input"
xbl:inherits="onfocus,onblur,xbl:text=value,disabled,tabindex,rows,cols,readonly,wrap"><children/></html:textarea>
<xul:menupopup anonid="input-box-contextmenu"
onpopupshowing="if (document.commandDispatcher.focusedElement != this.parentNode.firstChild) { this.parentNode.firstChild.focus(); } this.parentNode.parentNode._doPopupItemEnablingSpell(this);"
onpopuphiding="this.parentNode.parentNode._doPopupItemDisabling(this);"
oncommand="var cmd = event.originalTarget.getAttribute('cmd'); if(cmd) { this.parentNode.parentNode.doTextCommand(cmd); event.stopPropagation(); }">
<xul:menuitem label="&spellNoSuggestions.label;" anonid="spell-no-suggestions" disabled="true"/>
<xul:menuitem label="&spellAddToDictionary.label;" accesskey="&spellAddToDictionary.accesskey;" anonid="spell-add-to-dictionary"
oncommand="this.parentNode.parentNode.parentNode.spellCheckerUI.addToDictionary();"/>
<xul:menuseparator anonid="spell-suggestions-separator"/>
<xul:menuitem label="&undoCmd.label;" accesskey="&undoCmd.accesskey;" cmd="cmd_undo"/>
<xul:menuseparator/>
<xul:menuitem label="&cutCmd.label;" accesskey="&cutCmd.accesskey;" cmd="cmd_cut"/>
<xul:menuitem label="&copyCmd.label;" accesskey="&copyCmd.accesskey;" cmd="cmd_copy"/>
<xul:menuitem label="&pasteCmd.label;" accesskey="&pasteCmd.accesskey;" cmd="cmd_paste"/>
<xul:menuitem label="&deleteCmd.label;" accesskey="&deleteCmd.accesskey;" cmd="cmd_delete"/>
<xul:menuseparator/>
<xul:menuitem label="&selectAllCmd.label;" accesskey="&selectAllCmd.accesskey;" cmd="cmd_selectAll"/>
<xul:menuseparator anonid="spell-check-separator"/>
<xul:menuitem label="&spellEnable.label;" type="checkbox" accesskey="&spellEnable.accesskey;" anonid="spell-check-enabled"
oncommand="this.parentNode.parentNode.parentNode.spellCheckerUI.toggleEnabled();"/>
<xul:menu label="&spellDictionaries.label;" accesskey="&spellDictionaries.accesskey;" anonid="spell-dictionaries">
<xul:menupopup anonid="spell-dictionaries-menu"
onpopupshowing="event.stopPropagation();"
onpopuphiding="event.stopPropagation();">
<xul:menuseparator anonid="spell-language-separator"/>
<xul:menuitem anonid="spell-add-dictionaries-main" label="&spellAddDictionaries.label;"
accesskey="&spellAddDictionaries.accesskey;"
oncommand="nsContextMenu.prototype.addDictionaries();"/>
</xul:menupopup>
</xul:menu>
</xul:menupopup>
</xul:hbox>
</content>
</binding>
</bindings>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,73 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
var Zotero_Captcha = new function() {
this._io;
this.onLoad = function() {
this._io = window.arguments[0];
var description = document.getElementById('zotero-captcha-description'),
errorMsg = document.getElementById('zotero-captcha-error');
if(this._io.dataIn.title) {
document.title = this._io.dataIn.title;
}
if(this._io.dataIn.description) {
description.textContent = this._io.dataIn.description;
description.hidden = false;
} else {
description.hidden = true;
}
if(this._io.dataIn.error) {
errorMsg.textContent = this._io.dataIn.error;
errorMsg.hidden = false;
} else {
errorMsg.hidden = true;
}
document.getElementById('zotero-captcha-image').src = this._io.dataIn.imgUrl;
document.getElementById('zotero-captcha-input').focus();
}
this.imageOnLoad = function() {
window.sizeToContent();
}
this.resolve = function() {
var result = document.getElementById('zotero-captcha-input');
if(!result.value) return;
this._io.dataOut = {
captcha: result.value
};
window.close();
}
this.cancel = function() {
window.close();
}
}

View file

@ -0,0 +1,27 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="Zotero_Captcha.onLoad();"
id="zotero-captcha"
onkeypress="if(event.keyCode === KeyEvent.DOM_VK_ESCAPE) Zotero_Captcha.cancel();">
<script src="include.js"/>
<script src="captcha.js"/>
<vbox style="padding:10px" align="center" flex="1">
<description id="zotero-captcha-description"></description>
<image id="zotero-captcha-image" onload="Zotero_Captcha.imageOnLoad();" />
<description id="zotero-captcha-error"></description>
<textbox id="zotero-captcha-input"
onkeypress="if(event.keyCode === KeyEvent.DOM_VK_RETURN) Zotero_Captcha.resolve();" />
<hbox>
<button label="&zotero.general.ok;" default="true" oncommand="Zotero_Captcha.resolve();" />
<button label="&zotero.general.cancel;" oncommand="Zotero_Captcha.cancel();" />
</hbox>
</vbox>
</window>

View file

@ -0,0 +1,121 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
var Zotero_Charset_Menu = new function() {
this.populate = populate;
/**
* Populate a character set menu, placing more commonly used character sets
* closer to the top
*
* @param {DOMElement} charsetMenu The menu to populate
* @param {Boolean} exportMenu Whether the menu is to be used for export
**/
function populate(charsetMenu, exportMenu) {
var charsetMap = {};
// get charset popup and charset RDF
var charsetPopup = document.createElement("menupopup");
charsetMenu.appendChild(charsetPopup);
var charsets = [];
// Only list UTF-8 and Western for export
if (exportMenu) {
charsets.push(
{ label: "Unicode (UTF-8)", value: "UTF-8" },
{ label: Zotero.getString("charset.UTF8withoutBOM"), value: "UTF-8xBOM" },
{ label: "Western", value: "windows-1252" }
);
for (let charset of charsets) {
let { label, value } = charset;
let itemNode = document.createElement("menuitem");
itemNode.setAttribute("label", label);
itemNode.setAttribute("value", value);
charsetMap[value] = itemNode;
charsetPopup.appendChild(itemNode);
}
}
else {
var charsetSeparator = document.createElement("menuseparator");
charsetPopup.appendChild(charsetSeparator);
Components.utils.import("resource://gre/modules/CharsetMenu.jsm");
var cmData = CharsetMenu.getData();
for (let charsetList of [cmData.pinnedCharsets, cmData.otherCharsets]) {
for (let charsetInfo of charsetList) {
if(charsetInfo.value == "UTF-8") {
charsets.push({
"label":"Unicode (UTF-8)",
"value":"UTF-8"
});
} else {
charsets.push({
"label":charsetInfo.label,
"value":charsetInfo.value
});
}
}
}
charsets = charsets.concat([
{"label":"UTF-16LE", "value":"UTF-16LE"},
{"label":"UTF-16BE", "value":"UTF-16BE"},
{"label":"Western (IBM-850)", "value":"IBM850"},
{"label":"Western (MacRoman)", "value":"macintosh"}
]);
for(var i=0; i<charsets.length; i++) {
var charset = charsets[i].value,
label = charsets[i].label;
// add element
var itemNode = document.createElement("menuitem");
itemNode.setAttribute("label", label);
itemNode.setAttribute("value", charset);
charsetMap[charset] = itemNode;
if (label.length >= 7 && label.substr(0, 7) == "Western") {
charsetPopup.insertBefore(itemNode, charsetSeparator);
} else if(charset == "UTF-8") {
var oldFirst = (charsetPopup.firstChild ? charsetPopup.firstChild : null);
charsetPopup.insertBefore(itemNode, oldFirst);
} else {
charsetPopup.appendChild(itemNode);
}
}
var itemNode = document.createElement("menuitem");
itemNode.setAttribute("label", Zotero.getString("charset.autoDetect"));
itemNode.setAttribute("value", "auto");
charsetMap["auto"] = itemNode;
charsetPopup.insertBefore(itemNode, charsetPopup.firstChild);
}
return charsetMap;
}
}

View file

@ -0,0 +1,139 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Debug Output</title>
<script src="include.js"></script>
<script src="debugViewer.js"></script>
<style>
body {
margin: 0;
}
header {
position: fixed;
top: 0;
background: lightgrey;
display: flex;
align-items: center;
width: calc(100% - 20px);
height: 18px;
padding: 10px;
margin-bottom: 10px;
font-family: sans-serif;
font-size: 11pt;
}
header > * {
margin-right: 10px;
}
progress {
width: 125px;
}
#debug-id {
font-weight: bold;
}
#submit-result {
line-height: 1.25em;
}
#submit-result-copy-id {
cursor: pointer;
padding-left: 2px;
}
#submit-error {
font-weight: bold;
color: red;
}
#content {
margin-top: 38px;
padding: 10px 9px;
font-family: Monaco, Consolas, Inconsolata, monospace;
font-size: 8pt;
}
#errors {
padding-bottom: 12px;
border-bottom: 1px lightgray solid;
white-space: pre-wrap;
}
/*
CSS tooltip, adapted from http://stackoverflow.com/a/25836471
*/
[data-tooltip] {
display: inline-block;
position: relative;
cursor: pointer;
padding: 2px;
}
[data-tooltip]:before {
content: attr(data-tooltip);
display: none;
position: absolute;
background: #000;
color: #fff;
padding: 4px 8px;
font-size: 12px;
font-family: sans-serif;
line-height: 1.4;
text-align: center;
border-radius: 4px;
left: 50%;
transform: translateX(-50%);
top: 100%;
margin-top: 6px;
white-space: nowrap;
}
[data-tooltip]:after {
content: '';
display: none;
position: absolute;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
left: 50%;
margin-left: -6px;
top: 100%;
border-width: 0 6px 6px;
border-bottom-color: #000;
}
/* Show the tooltip when hovering */
[data-tooltip]:hover:before,
[data-tooltip]:hover:after {
display: block;
z-index: 50;
}
</style>
</head>
<body>
<header>
<button id="submit-button" onclick="submit(this)" disabled>Submit…</button>
<button id="clear-button" onclick="clearOutput(this)" disabled>Clear</button>
<progress id="submit-progress" hidden></progress>
<p id="submit-result" hidden>
Submitted with Debug ID <span id="debug-id"></span>
<span id="submit-result-copy-id" onclick="copyIDToClipboard(this)">&#128203;</span>
</p>
<p id="submit-error" hidden></p>
</header>
<div id="content">
<div id="errors"></div>
<div id="output"></div>
</div>
</body>
</html>

View file

@ -0,0 +1,195 @@
"use strict";
var interval = 1000;
var intervalID;
var stopping = false;
var scrolling = false;
var autoscroll = true;
function start() {
// If scrolled to the bottom of the page, stay there
document.body.onscroll = function (event) {
if (!scrolling) {
autoscroll = atPageBottom();
}
scrolling = false;
};
updateErrors().then(function () {
if (stopping) return;
addInitialOutput();
Zotero.Debug.addConsoleViewerListener(addLine)
intervalID = setInterval(() => updateErrors(), interval);
});
}
function stop() {
stopping = true;
if (intervalID) {
clearInterval(intervalID);
intervalID = null;
}
Zotero.Debug.removeConsoleViewerListener()
}
function updateErrors() {
return Zotero.getSystemInfo()
.then(function (sysInfo) {
if (stopping) return;
var errors = Zotero.getErrors(true);
var errorStr = errors.length ? errors.join('\n\n') + '\n\n' : '';
document.getElementById('errors').textContent = errorStr + sysInfo;
if (autoscroll) {
scrollToPageBottom();
}
});
}
function addInitialOutput() {
Zotero.Debug.getConsoleViewerOutput().forEach(function (line) {
addLine(line);
});
}
function addLine(line) {
var p = document.createElement('p');
p.textContent = line;
var output = document.getElementById('output');
output.appendChild(p);
if (autoscroll) {
scrollToPageBottom();
}
document.getElementById('submit-button').removeAttribute('disabled');
document.getElementById('clear-button').removeAttribute('disabled');
}
function atPageBottom() {
return (window.innerHeight + window.scrollY) >= document.body.offsetHeight - 100;
}
function scrollToPageBottom() {
// Set a flag when auto-scrolling to differentiate from manual scrolls
scrolling = true;
window.scrollTo(0, document.body.scrollHeight);
}
function submit(button) {
button.setAttribute('disabled', '');
clearSubmitStatus();
Components.utils.import("resource://zotero/config.js");
var url = ZOTERO_CONFIG.REPOSITORY_URL + "report?debug=1";
var output = document.getElementById('errors').textContent
+ "\n\n" + "=========================================================\n\n"
+ Array.from(document.getElementById('output').childNodes).map(p => p.textContent).join("\n\n");
var pm = document.getElementById('submit-progress');
pm.removeAttribute('hidden');
Zotero.HTTP.request(
"POST",
url,
{
compressBody: true,
body: output,
logBodyLength: 30,
timeout: 30000,
// Update progress meter
requestObserver: function (req) {
req.channel.notificationCallbacks = {
onProgress: function (request, context, progress, progressMax) {
if (!pm.value || progress > pm.value) {
pm.value = progress;
}
if (!pm.max || progressMax > pm.max) {
pm.max = progressMax;
}
},
// nsIInterfaceRequestor
getInterface: function (iid) {
try {
return this.QueryInterface(iid);
}
catch (e) {
throw Components.results.NS_NOINTERFACE;
}
},
QueryInterface: function(iid) {
if (iid.equals(Components.interfaces.nsISupports) ||
iid.equals(Components.interfaces.nsIInterfaceRequestor) ||
iid.equals(Components.interfaces.nsIProgressEventSink)) {
return this;
}
throw Components.results.NS_NOINTERFACE;
},
}
}
}
)
.then(function (xmlhttp) {
var reported = xmlhttp.responseXML.getElementsByTagName('reported');
if (reported.length != 1) {
showSubmitError(e);
return false;
}
showSubmitResult(reported[0].getAttribute('reportID'));
})
.catch(function (e) {
showSubmitError(e);
return false;
})
.finally(function () {
pm.setAttribute('hidden', '');
button.removeAttribute('disabled');
});
}
function showSubmitResult(id) {
var elem = document.getElementById('submit-result');
elem.removeAttribute('hidden');
document.getElementById('debug-id').textContent = "D" + id;
var copyID = document.getElementById('submit-result-copy-id');
copyID.style.visibility = 'visible';
copyID.setAttribute('data-tooltip', 'Copy ID to Clipboard');
}
function copyIDToClipboard(elem) {
var id = document.getElementById('debug-id').textContent;
Components.classes["@mozilla.org/widget/clipboardhelper;1"]
.getService(Components.interfaces.nsIClipboardHelper)
.copyString(id);
elem.setAttribute('data-tooltip', 'Copied');
setTimeout(() => elem.style.visibility = 'hidden', 750);
}
function showSubmitError(e) {
var elem = document.getElementById('submit-error');
elem.removeAttribute('hidden');
elem.textContent = "Error submitting output";
Components.utils.reportError(e);
Zotero.debug(e, 1);
}
function clearSubmitStatus() {
document.getElementById('submit-result').setAttribute('hidden', '');
document.getElementById('submit-error').setAttribute('hidden', '');
}
function clearOutput(button) {
document.getElementById('submit-button').setAttribute('disabled', '');
button.setAttribute('disabled', '');
document.getElementById('output').textContent = '';
clearSubmitStatus();
}
window.addEventListener('load', start);
window.addEventListener("unload", stop);

View file

@ -0,0 +1,155 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
"use strict";
var Zotero_Duplicates_Pane = new function () {
var _masterItem;
var _items = [];
var _otherItems = [];
var _ignoreFields = ['dateAdded', 'dateModified', 'accessDate'];
this.setItems = function (items, displayNumItemsOnTypeError) {
var itemTypeID, oldestItem, otherItems = [];
for (let item of items) {
// Find the oldest item
if (!oldestItem) {
oldestItem = item;
}
else if (item.dateAdded < oldestItem.dateAdded) {
otherItems.push(oldestItem);
oldestItem = item;
}
else {
otherItems.push(item);
}
if (!item.isRegularItem() || [1,14].indexOf(item.itemTypeID) != -1) {
var msg = Zotero.getString('pane.item.duplicates.onlyTopLevel');
ZoteroPane_Local.setItemPaneMessage(msg);
return false;
}
// Make sure all items are of the same type
if (itemTypeID) {
if (itemTypeID != item.itemTypeID) {
if (displayNumItemsOnTypeError) {
var msg = Zotero.getString('pane.item.selected.multiple', items.length);
}
else {
var msg = Zotero.getString('pane.item.duplicates.onlySameItemType');
}
ZoteroPane_Local.setItemPaneMessage(msg);
return false;
}
}
else {
itemTypeID = item.itemTypeID;
}
}
_items = items;
_items.sort(function (a, b) {
return a.dateAdded > b.dateAdded ? 1 : a.dateAdded == b.dateAdded ? 0 : -1;
});
//
// Update the UI
//
var button = document.getElementById('zotero-duplicates-merge-button');
var versionSelect = document.getElementById('zotero-duplicates-merge-version-select');
var itembox = document.getElementById('zotero-duplicates-merge-item-box');
var fieldSelect = document.getElementById('zotero-duplicates-merge-field-select');
var alternatives = oldestItem.multiDiff(otherItems, _ignoreFields);
if (alternatives) {
// Populate menulist with Date Added values from all items
var dateList = document.getElementById('zotero-duplicates-merge-original-date');
while (dateList.itemCount) {
dateList.removeItemAt(0);
}
var numRows = 0;
for (let item of items) {
var date = Zotero.Date.sqlToDate(item.dateAdded, true);
dateList.appendItem(date.toLocaleString());
numRows++;
}
dateList.setAttribute('rows', numRows);
// If we set this inline, the selection doesn't take on the first
// selection after unhiding versionSelect (when clicking
// from a set with no differences) -- tested in Fx5.0.1
setTimeout(function () {
dateList.selectedIndex = 0;
}, 0);
}
button.label = Zotero.getString('pane.item.duplicates.mergeItems', (otherItems.length + 1));
versionSelect.hidden = fieldSelect.hidden = !alternatives;
itembox.hiddenFields = alternatives ? [] : ['dateAdded', 'dateModified'];
this.setMaster(0);
return true;
}
this.setMaster = function (pos) {
var itembox = document.getElementById('zotero-duplicates-merge-item-box');
itembox.mode = 'fieldmerge';
_otherItems = _items.concat();
var item = _otherItems.splice(pos, 1)[0];
// Add master item's values to the beginning of each set of
// alternative values so that they're still available if the item box
// modifies the item
var alternatives = item.multiDiff(_otherItems, _ignoreFields);
if (alternatives) {
let itemValues = item.toJSON();
for (let i in alternatives) {
alternatives[i].unshift(itemValues[i] !== undefined ? itemValues[i] : '');
}
itembox.fieldAlternatives = alternatives;
}
_masterItem = item;
itembox.item = item.clone(null, { includeCollections: true });
}
this.merge = Zotero.Promise.coroutine(function* () {
var itembox = document.getElementById('zotero-duplicates-merge-item-box');
Zotero.CollectionTreeCache.clear();
// Update master item with any field alternatives from the item box
_masterItem.fromJSON(itembox.item.toJSON());
Zotero.Items.merge(_masterItem, _otherItems);
});
}

View file

@ -0,0 +1,166 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/errorReport.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<wizard xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="zotero-error-report" title="&zotero.errorReport.title;"
width="550" height="450">
<script>
<![CDATA[
Components.utils.import("resource://zotero/config.js");
var Zotero_Error_Report = new function() {
var obj = window.arguments[0].wrappedJSObject;
var Zotero = obj.Zotero;
var data = obj.data;
var msg = data.msg;
var errorData = data.errorData;
var extraData = data.extraData ? data.extraData : '';
var diagnosticInfo = false;
this.init = Zotero.Promise.coroutine(function* () {
var wizard = document.getElementById('zotero-error-report');
var continueButton = wizard.getButton('next');
continueButton.disabled = true;
diagnosticInfo = yield Zotero.getSystemInfo();
var errorDataText = errorData.length
? data.errorData.join('\n\n')
: Zotero.getString('errorReport.noErrorsLogged', Zotero.appName);
var logText = errorDataText + '\n\n'
+ (extraData !== '' ? extraData + '\n\n' : '')
+ diagnosticInfo;
if (document.getElementById('zotero-failure-message').hasChildNodes()) {
var textNode = document.getElementById('zotero-failure-message').firstChild;
document.getElementById('zotero-failure-message').removeChild(textNode);
}
document.getElementById('zotero-failure-message').appendChild(document.createTextNode(msg));
document.getElementById('zotero-error-message').value = logText;
continueButton.disabled = false;
continueButton.focus();
var str = Zotero.getString(
'errorReport.advanceMessage', continueButton.getAttribute('label')
);
document.getElementById('zotero-advance-message').setAttribute('value', str);
});
this.sendErrorReport = Zotero.Promise.coroutine(function* () {
var wizard = document.getElementById('zotero-error-report');
var continueButton = wizard.getButton('next');
continueButton.disabled = true;
var parts = {
error: "true",
errorData: errorData.join('\n'),
extraData: extraData,
diagnostic: diagnosticInfo
};
var body = '';
for (var key in parts) {
body += key + '=' + encodeURIComponent(parts[key]) + '&';
}
body = body.substr(0, body.length - 1);
var req = yield Zotero.HTTP.request(
"POST",
ZOTERO_CONFIG.REPOSITORY_URL + "report",
{
body,
successCodes: false,
foreground: true
}
);
_sendErrorReportCallback(req);
});
function _sendErrorReportCallback(xmlhttp) {
var wizard = document.getElementById('zotero-error-report');
if (!wizard) {
return;
}
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
if (!xmlhttp.responseXML){
try {
if (xmlhttp.status>1000){
ps.alert(
null,
Zotero.getString('general.error'),
Zotero.getString('errorReport.noNetworkConnection')
);
}
else {
ps.alert(
null,
Zotero.getString('general.error'),
Zotero.getString('errorReport.invalidResponseRepository')
);
}
}
catch (e){
ps.alert(
null,
Zotero.getString('general.error'),
Zotero.getString('errorReport.repoCannotBeContacted')
);
}
wizard.rewind();
return;
}
var reported = xmlhttp.responseXML.getElementsByTagName('reported');
if (reported.length != 1) {
ps.alert(
null,
Zotero.getString('general.error'),
Zotero.getString('errorReport.invalidResponseRepository')
);
wizard.rewind();
return;
}
wizard.advance();
wizard.getButton('cancel').disabled = true;;
wizard.canRewind = false;
var reportID = reported[0].getAttribute('reportID');
document.getElementById('zotero-report-id').setAttribute('value', reportID);
document.getElementById('zotero-report-result').hidden = false;
}
}
]]>
</script>
<wizardpage onpageshow="Zotero_Error_Report.init()" label=" ">
<description id="zotero-failure-message"/>
<textbox id="zotero-error-message" class="plain" readonly="true" multiline="true" flex="1"/>
<description id="zotero-advance-message"/>
</wizardpage>
<wizardpage onpageshow="Zotero_Error_Report.sendErrorReport()" label=" ">
<description>&zotero.errorReport.submissionInProgress;</description>
</wizardpage>
<wizardpage label=" ">
<description>&zotero.errorReport.submitted;</description>
<description id="zotero-report-result" hidden="true">
&zotero.errorReport.reportID;
<textbox id="zotero-report-id" class="plain" readonly="true"/>
</description>
<description>&zotero.errorReport.postToForums;</description>
<description>&zotero.errorReport.notReviewed;</description>
</wizardpage>
</wizard>

View file

@ -0,0 +1,224 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
//////////////////////////////////////////////////////////////////////////////
//
// Zotero_File_Interface_Export
//
//////////////////////////////////////////////////////////////////////////////
const OPTION_PREFIX = "export-option-";
// Class to provide options for export
var Zotero_File_Interface_Export = new function() {
this.init = init;
this.updateOptions = updateOptions;
this.accept = accept;
this.cancel = cancel;
var _charsets = false;
/*
* add options to export
*/
function init() {
// Set font size from pref
var sbc = document.getElementById('zotero-export-options-container');
Zotero.setFontSize(sbc);
var addedOptions = new Object();
var translators = window.arguments[0].translators;
translators.sort(function(a, b) { return a.label.localeCompare(b.label) });
// get format popup
var formatPopup = document.getElementById("format-popup");
var formatMenu = document.getElementById("format-menu");
var optionsBox = document.getElementById("translator-options");
var charsetBox = document.getElementById("charset-box");
var selectedTranslator = Zotero.Prefs.get("export.lastTranslator");
// add styles to format popup
for(var i in translators) {
var itemNode = document.createElement("menuitem");
itemNode.setAttribute("label", translators[i].label);
formatPopup.appendChild(itemNode);
// add options
for(var option in translators[i].displayOptions) {
if(!addedOptions[option]) { // if this option is not already
// presented to the user
// get readable name for option
try {
var optionLabel = Zotero.getString("exportOptions."+option);
} catch(e) {
var optionLabel = option;
}
// right now, option interface supports only boolean values, which
// it interprets as checkboxes
if(typeof(translators[i].displayOptions[option]) == "boolean") {
var checkbox = document.createElement("checkbox");
checkbox.setAttribute("id", OPTION_PREFIX+option);
checkbox.setAttribute("label", optionLabel);
optionsBox.insertBefore(checkbox, charsetBox);
}
addedOptions[option] = true;
}
}
// select last selected translator
if(translators[i].translatorID == selectedTranslator) {
formatMenu.selectedIndex = i;
}
}
// select first item by default
if(formatMenu.selectedIndex == -1) {
formatMenu.selectedIndex = 0;
}
// from charsetMenu.js
if(Zotero.Prefs.get("export.displayCharsetOption")) {
_charsets = Zotero_Charset_Menu.populate(document.getElementById(OPTION_PREFIX+"exportCharset"), true);
}
updateOptions(Zotero.Prefs.get("export.translatorSettings"));
}
/*
* update translator-specific options
*/
function updateOptions(optionString) {
// get selected translator
var index = document.getElementById("format-menu").selectedIndex;
var translatorOptions = window.arguments[0].translators[index].displayOptions;
if(optionString) {
try {
var options = JSON.parse(optionString);
} catch(e) {}
}
var optionsBox = document.getElementById("translator-options");
optionsBox.hidden = true;
var haveOption = false;
for(var i=0; i<optionsBox.childNodes.length; i++) {
// loop through options to see which should be enabled
var node = optionsBox.childNodes[i];
// skip non-options
if(node.id.length <= OPTION_PREFIX.length
|| node.id.substr(0, OPTION_PREFIX.length) != OPTION_PREFIX) {
continue;
}
var optionName = node.id.substr(OPTION_PREFIX.length);
if (translatorOptions && translatorOptions[optionName] != undefined) {
// option should be enabled
optionsBox.hidden = undefined;
node.hidden = undefined;
var defValue = translatorOptions[optionName];
if(typeof(defValue) == "boolean") {
if(options && options[optionName] !== undefined) {
// if there's a saved prefs string, use it
var isChecked = options[optionName];
} else {
// use defaults
var isChecked = (defValue ? "true" : "false");
}
node.setAttribute("checked", isChecked);
}
} else {
// option should be disabled and unchecked to prevent confusion
node.hidden = true;
node.checked = false;
}
}
// handle charset popup
if(_charsets && translatorOptions && translatorOptions.exportCharset) {
optionsBox.hidden = undefined;
document.getElementById("charset-box").hidden = undefined;
var charsetMenu = document.getElementById(OPTION_PREFIX+"exportCharset");
var charset = "UTF-8";
if(options && options.exportCharset && _charsets[options.exportCharset]) {
charset = options.exportCharset;
} else if(translatorOptions.exportCharset && _charsets[translatorOptions.exportCharset]) {
charset = translatorOptions.exportCharset;
}
charsetMenu.selectedItem = _charsets[charset];
} else {
document.getElementById("charset-box").hidden = true;
}
window.sizeToContent();
}
/*
* make option array reflect status
*/
function accept() {
// set selected translator
var index = document.getElementById("format-menu").selectedIndex;
window.arguments[0].selectedTranslator = window.arguments[0].translators[index];
// save selected translator
Zotero.Prefs.set("export.lastTranslator", window.arguments[0].translators[index].translatorID);
// set options on selected translator and generate optionString
var optionsAvailable = window.arguments[0].selectedTranslator.displayOptions;
var displayOptions = window.arguments[0].displayOptions = {};
for(var option in optionsAvailable) {
var defValue = optionsAvailable[option];
var element = document.getElementById(OPTION_PREFIX+option);
if(option == "exportCharset") {
if(_charsets) {
displayOptions[option] = element.selectedItem.value;
} else {
displayOptions[option] = optionsAvailable[option];
}
} else if(typeof(defValue) == "boolean") {
displayOptions[option] = !!element.checked;
}
}
// save options
var optionString = JSON.stringify(displayOptions);
Zotero.Prefs.set("export.translatorSettings", optionString);
}
/*
* make option array reflect status
*/
function cancel() {
window.arguments[0].selectedTranslator = false;
}
}

View file

@ -0,0 +1,43 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<!DOCTYPE window [
<!ENTITY % zoteroDTD SYSTEM "chrome://zotero/locale/zotero.dtd" >
%zoteroDTD;
]>
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
title="&zotero.exportOptions.title;" buttons="cancel,accept"
ondialogaccept="Zotero_File_Interface_Export.accept()"
ondialogcancel="Zotero_File_Interface_Export.cancel()"
id="zotero-export-options"
onload="Zotero_File_Interface_Export.init()">
<script src="include.js"/>
<script src="charsetMenu.js"/>
<script src="exportOptions.js"/>
<script type="application/javascript">
<![CDATA[
var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
observerService.notifyObservers(null, "charsetmenu-selected", "other");
]]>
</script>
<vbox id="zotero-export-options-container" flex="1">
<hbox align="center">
<label value="&zotero.exportOptions.format.label;" control="format-menu"/>
<menulist id="format-menu" oncommand="Zotero_File_Interface_Export.updateOptions()">
<menupopup id="format-popup"/>
</menulist>
</hbox>
<groupbox id="translator-options">
<caption id="translator-options-label" label="&zotero.exportOptions.translatorOptions.label;"/>
<vbox id="charset-box" hidden="true">
<separator class="thin"/>
<label value="&zotero.charset.label;:" control="charset-menu"/>
<menulist id="export-option-exportCharset"/>
</vbox>
</groupbox>
</vbox>
</dialog>

View file

@ -0,0 +1,176 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2015 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
//////////////////////////////////////////////////////////////////////////////
//
// Zotero_Feed_Settings
//
//////////////////////////////////////////////////////////////////////////////
var Zotero_Feed_Settings = new function() {
let urlIsValid = true,
data = null,
feedReader = null,
urlTainted = false;
let cleanURL = function(url) {
let cleanURL = Zotero.Utilities.cleanURL(url, true);
if (cleanURL) {
if (/^https?:\/\/[^\/\s]+\/\S/.test(cleanURL)) {
return cleanURL;
} else {
Zotero.debug(url + " has an unsupported protocol for feeds");
}
}
};
this.init = Zotero.Promise.coroutine(function* () {
this.toggleAdvancedOptions(false);
data = window.arguments[0];
if (data.url) {
document.getElementById('feed-url').value = data.url;
// Do not allow to change URL for existing feed
document.getElementById('feed-url').readOnly = true;
} else {
this.invalidateURL();
}
if (data.title) {
document.getElementById('feed-title').value = data.title;
}
let ttl;
if (data.ttl !== undefined) {
ttl = Math.floor(data.ttl / 60);
} else {
ttl = Zotero.Prefs.get('feeds.defaultTTL');
}
document.getElementById('feed-ttl').value = ttl;
let cleanupReadAfter = data.cleanupReadAfter;
if (cleanupReadAfter === undefined) cleanupReadAfter = Zotero.Prefs.get('feeds.defaultCleanupReadAfter');
document.getElementById('feed-cleanupReadAfter').value = cleanupReadAfter;
let cleanupUnreadAfter = data.cleanupUnreadAfter;
if (cleanupUnreadAfter === undefined) cleanupUnreadAfter = Zotero.Prefs.get('feeds.defaultCleanupUnreadAfter');
document.getElementById('feed-cleanupUnreadAfter').value = cleanupUnreadAfter;
if (data.url && !data.urlIsValid) {
yield this.validateURL();
}
});
this.invalidateURL = function() {
urlTainted = true;
if (feedReader) {
feedReader.terminate();
feedReader = null;
}
if (!urlIsValid) return;
urlIsValid = false;
document.getElementById('feed-title').disabled = true;
document.getElementById('feed-ttl').disabled = true;
document.getElementById('feed-cleanupReadAfter').disabled = true;
document.getElementById('feed-cleanupUnreadAfter').disabled = true;
document.documentElement.getButton('accept').disabled = true;
};
this.validateURL = Zotero.Promise.coroutine(function* () {
if (feedReader) {
feedReader.terminate();
feedReader = null;
}
let url = cleanURL(document.getElementById('feed-url').value);
urlTainted = false;
if (!url) return;
try {
var fr = feedReader = new Zotero.FeedReader(url);
yield fr.process();
let feed = fr.feedProperties;
// Prevent progress if textbox changes triggered another call to
// validateURL / invalidateURL (old session)
if (feedReader !== fr || urlTainted) return;
let title = document.getElementById('feed-title');
if (feed.title && (!data.url || data.unsaved)) {
title.value = feed.title;
}
let ttl = document.getElementById('feed-ttl');
if (feed.ttl && (!data.url || data.unsaved)) {
ttl.value = Math.floor(feed.ttl / 60) || 1;
}
document.getElementById('feed-url').value = url;
urlIsValid = true;
title.disabled = false;
ttl.disabled = false;
document.getElementById('feed-cleanupReadAfter').disabled = false;
document.getElementById('feed-cleanupUnreadAfter').disabled = false;
document.documentElement.getButton('accept').disabled = false;
}
catch (e) {
Zotero.debug(e);
}
finally {
if (feedReader === fr) feedReader = null;
}
});
this.accept = function() {
data.url = document.getElementById('feed-url').value;
data.title = document.getElementById('feed-title').value;
data.ttl = document.getElementById('feed-ttl').value * 60;
data.cleanupReadAfter = document.getElementById('feed-cleanupReadAfter').value * 1;
data.cleanupUnreadAfter = document.getElementById('feed-cleanupUnreadAfter').value * 1;
return true;
};
this.cancel = function() {
data.cancelled = true;
return true;
};
/*
* Show/hide advanced options
* @param {Boolean} [show] If set, indicates whether the advanced
* options should be shown or not. If omitted, the options toggle
*/
this.toggleAdvancedOptions = function(show) {
var opts = document.getElementById("advanced-options-togglable");
opts.hidden = show !== undefined ? !show : !opts.hidden;
document.getElementById("advanced-options")
.setAttribute("state", opts.hidden ? "closed" : "open");
window.sizeToContent();
};
}

View file

@ -0,0 +1,68 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero-platform/content/zotero.css" type="text/css"?>
<!DOCTYPE window [
<!ENTITY % zoteroDTD SYSTEM "chrome://zotero/locale/zotero.dtd" > %zoteroDTD;
]>
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&zotero.feedSettings.title;" buttons="cancel,accept"
buttonlabelaccept="&zotero.feedSettings.saveButton.label;"
ondialogaccept="return Zotero_Feed_Settings.accept()"
ondialogcancel="return Zotero_Feed_Settings.cancel()"
id="zotero-feed-settings"
onload="Zotero_Feed_Settings.init()">
<script src="include.js"/>
<script src="feedSettings.js"/>
<grid>
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row>
<hbox align="center">
<label value="&zotero.feedSettings.url.label;" control="feed-url"/>
</hbox>
<textbox id="feed-url" flex="1" size="2"
oninput="Zotero_Feed_Settings.invalidateURL();Zotero_Feed_Settings.validateURL()"
focused="true" newlines="stripsurroundingwhitespace"
style="width: 30em; max-width: 30em"/>
</row>
<row>
<hbox align="center">
<label value="&zotero.feedSettings.title.label;" control="feed-url"/>
</hbox>
<textbox id="feed-title" flex="1" newlines="replacewithspaces"/>
</row>
</rows>
</grid>
<vbox id="advanced-options" class="zotero-advanced-options">
<hbox onclick="Zotero_Feed_Settings.toggleAdvancedOptions()" class="zotero-advanced-options-label">
<dropmarker/>
<hbox align="center">
<label value="&zotero.general.advancedOptions.label;"/>
</hbox>
</hbox>
<vbox id="advanced-options-togglable">
<hbox align="center">
<label value="&zotero.feedSettings.refresh.label1;" control="feed-ttl"/>
<textbox id="feed-ttl" type="number" min="1" increment="1" size="3"/>
<label value="&zotero.feedSettings.refresh.label2;" control="feed-ttl"/>
</hbox>
<hbox align="center">
<label value="&zotero.feedSettings.cleanupReadAfter.label1;" control="feed-cleanupReadAfter"/>
<textbox id="feed-cleanupReadAfter" type="number" min="1" increment="1" size="2"/>
<label value="&zotero.feedSettings.cleanupReadAfter.label2;" control="feed-cleanupReadAfter"/>
</hbox>
<hbox align="center">
<label value="&zotero.feedSettings.cleanupUnreadAfter.label1;" control="feed-cleanupUnreadAfter"/>
<textbox id="feed-cleanupUnreadAfter" type="number" min="1" increment="1" size="2"/>
<label value="&zotero.feedSettings.cleanupUnreadAfter.label2;" control="feed-cleanupUnreadAfter"/>
</hbox>
</vbox>
</vbox>
</dialog>

View file

@ -0,0 +1,857 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
Components.utils.import("resource://gre/modules/osfile.jsm")
/****Zotero_File_Exporter****
**
* A class to handle exporting of items, collections, or the entire library
**/
/**
* Constructs a new Zotero_File_Exporter with defaults
**/
var Zotero_File_Exporter = function() {
this.name = Zotero.getString("fileInterface.exportedItems");
this.collection = false;
this.items = false;
}
/**
* Performs the actual export operation
*
* @return {Promise}
**/
Zotero_File_Exporter.prototype.save = Zotero.Promise.coroutine(function* () {
var translation = new Zotero.Translate.Export();
var translators = yield translation.getTranslators();
// present options dialog
var io = {translators:translators}
window.openDialog("chrome://zotero/content/exportOptions.xul",
"_blank", "chrome,modal,centerscreen,resizable=no", io);
if(!io.selectedTranslator) {
return false;
}
const nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(nsIFilePicker);
fp.init(window, Zotero.getString("fileInterface.export"), nsIFilePicker.modeSave);
// set file name and extension
if(io.displayOptions.exportFileData) {
// if the result will be a folder, don't append any extension or use
// filters
fp.defaultString = this.name;
fp.appendFilters(Components.interfaces.nsIFilePicker.filterAll);
} else {
// if the result will be a file, append an extension and use filters
fp.defaultString = this.name+(io.selectedTranslator.target ? "."+io.selectedTranslator.target : "");
fp.defaultExtension = io.selectedTranslator.target;
fp.appendFilter(io.selectedTranslator.label, "*."+(io.selectedTranslator.target ? io.selectedTranslator.target : "*"));
}
var rv = fp.show();
if (rv != nsIFilePicker.returnOK && rv != nsIFilePicker.returnReplace) {
return;
}
if(this.collection) {
translation.setCollection(this.collection);
} else if(this.items) {
translation.setItems(this.items);
} else if(this.libraryID === undefined) {
throw new Error('No export configured');
} else {
translation.setLibraryID(this.libraryID);
}
translation.setLocation(fp.file);
translation.setTranslator(io.selectedTranslator);
translation.setDisplayOptions(io.displayOptions);
translation.setHandler("itemDone", function () {
Zotero.updateZoteroPaneProgressMeter(translation.getProgress());
});
translation.setHandler("done", this._exportDone);
Zotero_File_Interface.Progress.show(
Zotero.getString("fileInterface.itemsExported")
);
translation.translate()
});
/*
* Closes the items exported indicator
*/
Zotero_File_Exporter.prototype._exportDone = function(obj, worked) {
Zotero_File_Interface.Progress.close();
if(!worked) {
Zotero.alert(
null,
Zotero.getString('general.error'),
Zotero.getString("fileInterface.exportError")
);
}
}
/****Zotero_File_Interface****
**
* A singleton to interface with ZoteroPane to provide export/bibliography
* capabilities
**/
var Zotero_File_Interface = new function() {
var _unlock;
this.exportCollection = exportCollection;
this.exportItemsToClipboard = exportItemsToClipboard;
this.exportItems = exportItems;
this.bibliographyFromItems = bibliographyFromItems;
/**
* Creates Zotero.Translate instance and shows file picker for file export
*
* @return {Promise}
*/
this.exportFile = Zotero.Promise.method(function () {
var exporter = new Zotero_File_Exporter();
exporter.libraryID = ZoteroPane_Local.getSelectedLibraryID();
if (exporter.libraryID === false) {
throw new Error('No library selected');
}
exporter.name = Zotero.Libraries.getName(exporter.libraryID);
return exporter.save();
});
/*
* exports a collection or saved search
*/
function exportCollection() {
var exporter = new Zotero_File_Exporter();
var collection = ZoteroPane_Local.getSelectedCollection();
if(collection) {
exporter.name = collection.getName();
exporter.collection = collection;
} else {
// find sorted items
exporter.items = ZoteroPane_Local.getSortedItems();
if(!exporter.items) throw ("No items to save");
// find name
var search = ZoteroPane_Local.getSelectedSavedSearch();
if(search) {
exporter.name = search.name;
}
}
exporter.save();
}
/*
* exports items
*/
function exportItems() {
var exporter = new Zotero_File_Exporter();
exporter.items = ZoteroPane_Local.getSelectedItems();
if(!exporter.items || !exporter.items.length) throw("no items currently selected");
exporter.save();
}
/*
* exports items to clipboard
*/
function exportItemsToClipboard(items, translatorID) {
var translation = new Zotero.Translate.Export();
translation.setItems(items);
translation.setTranslator(translatorID);
translation.setHandler("done", _copyToClipboard);
translation.translate();
}
/*
* handler when done exporting items to clipboard
*/
function _copyToClipboard(obj, worked) {
if(!worked) {
Zotero.alert(
null, Zotero.getString('general.error'), Zotero.getString("fileInterface.exportError")
);
} else {
Components.classes["@mozilla.org/widget/clipboardhelper;1"]
.getService(Components.interfaces.nsIClipboardHelper)
.copyString(obj.string.replace(/\r\n/g, "\n"));
}
}
this.getMendeleyDirectory = function () {
Components.classes["@mozilla.org/net/osfileconstantsservice;1"]
.getService(Components.interfaces.nsIOSFileConstantsService)
.init();
var path = OS.Constants.Path.homeDir;
if (Zotero.isMac) {
path = OS.Path.join(path, 'Library', 'Application Support', 'Mendeley Desktop');
}
else if (Zotero.isWin) {
path = OS.Path.join(path, 'AppData', 'Local', 'Mendeley Ltd', 'Mendeley Desktop');
}
else if (Zotero.isLinux) {
path = OS.Path.join(path, '.local', 'share', 'data', 'Mendeley Ltd.', 'Mendeley Desktop');
}
else {
throw new Error("Invalid platform");
}
return path;
};
this.findMendeleyDatabases = async function () {
var dbs = [];
try {
var dir = this.getMendeleyDirectory();
if (!await OS.File.exists(dir)) {
Zotero.debug(`${dir} does not exist`);
return dbs;
}
await Zotero.File.iterateDirectory(dir, function* (iterator) {
while (true) {
let entry = yield iterator.next();
if (entry.isDir) continue;
// online.sqlite, counterintuitively, is the default database before you sign in
if (entry.name == 'online.sqlite' || entry.name.endsWith('@www.mendeley.com.sqlite')) {
dbs.push({
name: entry.name,
path: entry.path,
lastModified: null,
size: null
});
}
}
});
for (let i = 0; i < dbs.length; i++) {
let dbPath = OS.Path.join(dir, dbs[i].name);
let info = await OS.File.stat(dbPath);
dbs[i].size = info.size;
dbs[i].lastModified = info.lastModificationDate;
}
dbs.sort((a, b) => {
return b.lastModified - a.lastModified;
});
}
catch (e) {
Zotero.logError(e);
}
return dbs;
};
this.showImportWizard = function () {
var libraryID = Zotero.Libraries.userLibraryID;
try {
let zp = Zotero.getActiveZoteroPane();
libraryID = zp.getSelectedLibraryID();
}
catch (e) {
Zotero.logError(e);
}
var args = {
libraryID
};
args.wrappedJSObject = args;
Services.ww.openWindow(null, "chrome://zotero/content/import/importWizard.xul",
"importFile", "chrome,dialog=yes,centerscreen,width=600,height=400", args);
};
/**
* Creates Zotero.Translate instance and shows file picker for file import
*
* @param {Object} options
* @param {nsIFile|string|null} [options.file=null] - File to import, or none to show a filepicker
* @param {Boolean} [options.addToLibraryRoot=false]
* @param {Boolean} [options.createNewCollection=true] - Put items in a new collection
* @param {Function} [options.onBeforeImport] - Callback to receive translation object, useful
* for displaying progress in a different way. This also causes an error to be throw
* instead of shown in the main window.
*/
this.importFile = Zotero.Promise.coroutine(function* (options = {}) {
if (!options) {
options = {};
}
if (typeof options == 'string' || options instanceof Components.interfaces.nsIFile) {
Zotero.debug("WARNING: importFile() now takes a single options object -- update your code");
options = {
file: options,
createNewCollection: arguments[1]
};
}
var file = options.file ? Zotero.File.pathToFile(options.file) : null;
var createNewCollection = options.createNewCollection;
var addToLibraryRoot = options.addToLibraryRoot;
var onBeforeImport = options.onBeforeImport;
if (createNewCollection === undefined && !addToLibraryRoot) {
createNewCollection = true;
}
else if (!createNewCollection) {
try {
if (!ZoteroPane.collectionsView.editable) {
ZoteroPane.collectionsView.selectLibrary(null);
}
} catch(e) {}
}
var defaultNewCollectionPrefix = Zotero.getString("fileInterface.imported");
var translation;
// Check if the file is an SQLite database
var sample = yield Zotero.File.getSample(file.path);
if (file.path == Zotero.DataDirectory.getDatabase()) {
// Blacklist the current Zotero database, which would cause a hang
}
else if (Zotero.MIME.sniffForMIMEType(sample) == 'application/x-sqlite3') {
// Mendeley import doesn't use the real translation architecture, but we create a
// translation object with the same interface
translation = yield _getMendeleyTranslation();
translation.createNewCollection = createNewCollection;
defaultNewCollectionPrefix = Zotero.getString(
'fileInterface.appImportCollection', 'Mendeley'
);
}
else if (file.path.endsWith('@www.mendeley.com.sqlite')
|| file.path.endsWith('online.sqlite')) {
// Keep in sync with importWizard.js
throw new Error('Encrypted Mendeley database');
}
if (!translation) {
translation = new Zotero.Translate.Import();
}
translation.setLocation(file);
return _finishImport({
translation,
createNewCollection,
addToLibraryRoot,
defaultNewCollectionPrefix,
onBeforeImport
});
});
/**
* Imports from clipboard
*/
this.importFromClipboard = Zotero.Promise.coroutine(function* () {
var str = Zotero.Utilities.Internal.getClipboard("text/unicode");
if(!str) {
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
ps.alert(
null,
Zotero.getString('general.error'),
Zotero.getString('fileInterface.importClipboardNoDataError')
);
}
var translation = new Zotero.Translate.Import();
translation.setString(str);
try {
if (!ZoteroPane.collectionsView.editable) {
yield ZoteroPane.collectionsView.selectLibrary();
}
} catch(e) {}
yield _finishImport({
translation,
createNewCollection: false
});
// Select imported items
try {
if (translation.newItems) {
ZoteroPane.itemsView.selectItems(translation.newItems.map(item => item.id));
}
}
catch (e) {
Zotero.logError(e, 2);
}
});
var _finishImport = Zotero.Promise.coroutine(function* (options) {
var t = performance.now();
var translation = options.translation;
var addToLibraryRoot = options.addToLibraryRoot;
var createNewCollection = options.createNewCollection;
var defaultNewCollectionPrefix = options.defaultNewCollectionPrefix;
var onBeforeImport = options.onBeforeImport;
if (addToLibraryRoot && createNewCollection) {
throw new Error("Can't add to library root and create new collection");
}
var showProgressWindow = !onBeforeImport;
let translators = yield translation.getTranslators();
// Unrecognized file
if (!translators.length) {
if (onBeforeImport) {
yield onBeforeImport(false);
}
let ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
let buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_OK
+ ps.BUTTON_POS_1 * ps.BUTTON_TITLE_IS_STRING;
let index = ps.confirmEx(
null,
Zotero.getString('general.error'),
Zotero.getString("fileInterface.unsupportedFormat"),
buttonFlags,
null,
Zotero.getString("fileInterface.viewSupportedFormats"),
null, null, {}
);
if (index == 1) {
Zotero.launchURL("https://www.zotero.org/support/kb/importing_standardized_formats");
}
return false;
}
var libraryID = Zotero.Libraries.userLibraryID;
var importCollection = null;
try {
let zp = Zotero.getActiveZoteroPane();
libraryID = zp.getSelectedLibraryID();
if (addToLibraryRoot) {
yield zp.collectionsView.selectLibrary(libraryID);
}
else if (!createNewCollection) {
importCollection = zp.getSelectedCollection();
}
}
catch (e) {
Zotero.logError(e);
}
if(createNewCollection) {
// Create a new collection to take imported items
let collectionName;
if(translation.location instanceof Components.interfaces.nsIFile) {
let leafName = translation.location.leafName;
collectionName = (translation.location.isDirectory() || leafName.indexOf(".") === -1 ? leafName
: leafName.substr(0, leafName.lastIndexOf(".")));
let allCollections = Zotero.Collections.getByLibrary(libraryID);
for(var i=0; i<allCollections.length; i++) {
if(allCollections[i].name == collectionName) {
collectionName += " "+(new Date()).toLocaleString();
break;
}
}
}
else {
collectionName = defaultNewCollectionPrefix + " " + (new Date()).toLocaleString();
}
importCollection = new Zotero.Collection;
importCollection.libraryID = libraryID;
importCollection.name = collectionName;
yield importCollection.saveTx();
}
translation.setTranslator(translators[0]);
// Show progress popup
var progressWin;
var progress;
if (showProgressWindow) {
progressWin = new Zotero.ProgressWindow({
closeOnClick: false
});
progressWin.changeHeadline(Zotero.getString('fileInterface.importing'));
let icon = 'chrome://zotero/skin/treesource-unfiled' + (Zotero.hiDPI ? "@2x" : "") + '.png';
progress = new progressWin.ItemProgress(
icon, translation.path ? OS.Path.basename(translation.path) : translators[0].label
);
progressWin.show();
translation.setHandler("itemDone", function () {
progress.setProgress(translation.getProgress());
});
yield Zotero.Promise.delay(0);
}
else {
yield onBeforeImport(translation);
}
let failed = false;
try {
yield translation.translate({
libraryID,
collections: importCollection ? [importCollection.id] : null
});
} catch(e) {
if (!showProgressWindow) {
throw e;
}
progressWin.close();
Zotero.logError(e);
Zotero.alert(
null,
Zotero.getString('general.error'),
Zotero.getString("fileInterface.importError")
);
return false;
}
var numItems = translation.newItems.length;
// Show popup on completion
if (showProgressWindow) {
progressWin.changeHeadline(Zotero.getString('fileInterface.importComplete'));
let icon;
if (numItems == 1) {
icon = translation.newItems[0].getImageSrc();
}
else {
icon = 'chrome://zotero/skin/treesource-unfiled' + (Zotero.hiDPI ? "@2x" : "") + '.png';
}
let text = Zotero.getString(`fileInterface.itemsWereImported`, numItems, numItems);
progress.setIcon(icon);
progress.setText(text);
// For synchronous translators, which don't update progress
progress.setProgress(100);
progressWin.startCloseTimer(5000);
}
Zotero.debug(`Imported ${numItems} item(s) in ${performance.now() - t} ms`);
return true;
});
var _getMendeleyTranslation = async function () {
if (true) {
Components.utils.import("chrome://zotero/content/import/mendeley/mendeleyImport.js");
}
// TEMP: Load uncached from ~/zotero-client for development
else {
Components.utils.import("resource://gre/modules/FileUtils.jsm");
let file = FileUtils.getDir("Home", []);
file = OS.Path.join(
file.path,
'zotero-client', 'chrome', 'content', 'zotero', 'import', 'mendeley', 'mendeleyImport.js'
);
let fileURI = OS.Path.toFileURI(file);
let xmlhttp = await Zotero.HTTP.request(
'GET',
fileURI,
{
dontCache: true,
responseType: 'text'
}
);
eval(xmlhttp.response);
}
return new Zotero_Import_Mendeley();
}
/**
* Creates a bibliography from a collection or saved search
*/
this.bibliographyFromCollection = function () {
var items = ZoteroPane.getSortedItems();
// Find collection name
var name = false;
var collection = ZoteroPane.getSelectedCollection();
if (collection) {
name = collection.name;
}
else {
let search = ZoteroPane.getSelectedSavedSearch();
if (search) {
name = search.name;
}
}
_doBibliographyOptions(name, items);
}
/*
* Creates a bibliography from a items
*/
function bibliographyFromItems() {
var items = ZoteroPane_Local.getSelectedItems();
if(!items || !items.length) throw("no items currently selected");
_doBibliographyOptions(Zotero.getString("fileInterface.untitledBibliography"), items);
}
/**
* Copies HTML and text citations or bibliography entries for passed items in given style
*
* Does not check that items are actual references (and not notes or attachments)
*
* @param {Zotero.Item[]} items
* @param {String} style - Style id string (e.g., 'http://www.zotero.org/styles/apa')
* @param {String} locale - Locale (e.g., 'en-US')
* @param {Boolean} [asHTML=false] - Use HTML source for plain-text data
* @param {Boolean} [asCitations=false] - Copy citation cluster instead of bibliography
*/
this.copyItemsToClipboard = function (items, style, locale, asHTML, asCitations) {
// copy to clipboard
var transferable = Components.classes["@mozilla.org/widget/transferable;1"].
createInstance(Components.interfaces.nsITransferable);
var clipboardService = Components.classes["@mozilla.org/widget/clipboard;1"].
getService(Components.interfaces.nsIClipboard);
style = Zotero.Styles.get(style);
var cslEngine = style.getCiteProc(locale);
if (asCitations) {
cslEngine.updateItems(items.map(item => item.id));
var citation = {
citationItems: items.map(item => ({ id: item.id })),
properties: {}
};
var output = cslEngine.previewCitationCluster(citation, [], [], "html");
}
else {
var output = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, items, "html");
}
// add HTML
var str = Components.classes["@mozilla.org/supports-string;1"].
createInstance(Components.interfaces.nsISupportsString);
str.data = output;
transferable.addDataFlavor("text/html");
transferable.setTransferData("text/html", str, output.length * 2);
// If not "Copy as HTML", add plaintext; otherwise use HTML from above and just mark as text
if(!asHTML) {
if (asCitations) {
output = cslEngine.previewCitationCluster(citation, [], [], "text");
}
else {
// Generate engine again to work around citeproc-js problem:
// https://github.com/zotero/zotero/commit/4a475ff3
cslEngine = style.getCiteProc(locale);
output = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, items, "text");
}
}
var str = Components.classes["@mozilla.org/supports-string;1"].
createInstance(Components.interfaces.nsISupportsString);
str.data = output;
transferable.addDataFlavor("text/unicode");
transferable.setTransferData("text/unicode", str, output.length * 2);
clipboardService.setData(transferable, null, Components.interfaces.nsIClipboard.kGlobalClipboard);
}
/*
* Shows bibliography options and creates a bibliography
*/
function _doBibliographyOptions(name, items) {
// make sure at least one item is not a standalone note or attachment
var haveRegularItem = false;
for (let item of items) {
if (item.isRegularItem()) {
haveRegularItem = true;
break;
}
}
if (!haveRegularItem) {
Zotero.alert(
null,
Zotero.getString('general.error'),
Zotero.getString("fileInterface.noReferencesError")
);
return;
}
var io = new Object();
var newDialog = window.openDialog("chrome://zotero/content/bibliography.xul",
"_blank","chrome,modal,centerscreen", io);
if(!io.method) return;
// determine output format
var format = "html";
if(io.method == "save-as-rtf") {
format = "rtf";
}
// determine locale preference
var locale = io.locale;
// generate bibliography
try {
if(io.method == 'copy-to-clipboard') {
Zotero_File_Interface.copyItemsToClipboard(items, io.style, locale, false, io.mode === "citations");
}
else {
var style = Zotero.Styles.get(io.style);
var cslEngine = style.getCiteProc(locale);
var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine,
items, format, io.mode === "citations");
}
} catch(e) {
Zotero.alert(
null,
Zotero.getString('general.error'),
Zotero.getString("fileInterface.bibliographyGenerationError")
);
throw(e);
}
if(io.method == "print") {
// printable bibliography, using a hidden browser
var browser = Zotero.Browser.createHiddenBrowser(window);
var listener = function() {
if(browser.contentDocument.location.href == "about:blank") return;
browser.removeEventListener("pageshow", listener, false);
// this is kinda nasty, but we have to temporarily modify the user's
// settings to eliminate the header and footer. the other way to do
// this would be to attempt to print with an embedded browser, but
// it's not even clear how to attempt to create one
var prefService = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefBranch);
var prefsToClear = ["print.print_headerleft", "print.print_headercenter",
"print.print_headerright", "print.print_footerleft",
"print.print_footercenter", "print.print_footerright"];
var oldPrefs = [];
for(var i in prefsToClear) {
oldPrefs[i] = prefService.getCharPref(prefsToClear[i]);
prefService.setCharPref(prefsToClear[i], "");
}
// print
browser.contentWindow.print();
// set the prefs back
for(var i in prefsToClear) {
prefService.setCharPref(prefsToClear[i], oldPrefs[i]);
}
// TODO can't delete hidden browser object here or else print will fail...
}
browser.addEventListener("pageshow", listener, false);
browser.loadURIWithFlags("data:text/html;charset=utf-8,"+encodeURI(bibliography),
Components.interfaces.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY, null, "utf-8", null);
} else if(io.method == "save-as-html") {
var fStream = _saveBibliography(name, "HTML");
if(fStream !== false) {
var html = "";
html +='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n';
html +='<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\n';
html +='<head>\n';
html +='<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>\n';
html +='<title>'+Zotero.getString("fileInterface.bibliographyHTMLTitle")+'</title>\n';
html +='</head>\n';
html +='<body>\n';
html += bibliography;
html +='</body>\n';
html +='</html>\n';
// create UTF-8 output stream
var os = Components.classes["@mozilla.org/intl/converter-output-stream;1"].
createInstance(Components.interfaces.nsIConverterOutputStream);
os.init(fStream, "UTF-8", 0, "?".charCodeAt(0));
os.writeString(html);
os.close();
fStream.close();
}
} else if(io.method == "save-as-rtf") {
var fStream = _saveBibliography(name, "RTF");
if(fStream !== false) {
fStream.write(bibliography, bibliography.length);
fStream.close();
}
}
}
function _saveBibliography(name, format) {
// savable bibliography, using a file stream
const nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(nsIFilePicker);
fp.init(window, "Save Bibliography", nsIFilePicker.modeSave);
if(format == "RTF") {
var extension = "rtf";
fp.appendFilter("RTF", "*.rtf");
} else {
var extension = "html";
fp.appendFilters(nsIFilePicker.filterHTML);
}
fp.defaultString = name+"."+extension;
var rv = fp.show();
if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) {
// open file
var fStream = Components.classes["@mozilla.org/network/file-output-stream;1"].
createInstance(Components.interfaces.nsIFileOutputStream);
fStream.init(fp.file, 0x02 | 0x08 | 0x20, 0o664, 0); // write, create, truncate
return fStream;
} else {
return false;
}
}
}
// Handles the display of a progress indicator
Zotero_File_Interface.Progress = new function() {
this.show = show;
this.close = close;
function show(headline) {
Zotero.showZoteroPaneProgressMeter(headline);
}
function close() {
Zotero.hideZoteroPaneOverlays();
}
}

View file

@ -0,0 +1,78 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2016 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
Zotero.HardConfirmationDialog = {
init: function() {
var label, content;
this.io = window.arguments[0];
var vbox = document.getElementById('infoContainer');
var sep = vbox.firstChild;
for (let text of this.io.text) {
label = document.createElement('label');
content = document.createTextNode(text);
label.appendChild(content);
vbox.insertBefore(label, sep);
}
if (this.io.checkboxLabel) {
var checkbox = document.getElementById('zotero-hardConfirmationDialog-checkbox');
checkbox.hidden = false;
checkbox.setAttribute('label', this.io.checkboxLabel);
this.onCheckbox();
}
if (this.io.confirmationText) {
document.getElementById('zotero-hardConfirmationDialog-textbox').hidden = false;
this.onKeyUp();
}
if (this.io.extra1Label) {
document.documentElement.buttons = document.documentElement.buttons + ',extra1';
document.documentElement.getButton('extra1').label = this.io.extra1Label
} if (this.io.acceptLabel) {
document.documentElement.getButton('accept').label = this.io.acceptLabel
}
document.documentElement.setAttribute('title', this.io.title);
},
onCheckbox: function(event) {
document.documentElement.getButton('accept').disabled =
!document.getElementById('zotero-hardConfirmationDialog-checkbox').checked;
},
onKeyUp: function(event) {
document.documentElement.getButton('accept').disabled =
document.getElementById('zotero-hardConfirmationDialog-textbox').value != this.io.confirmationText;
},
onAccept: function() {
this.io.accept = true;
},
onExtra1: function() {
this.io.extra1 = true;
document.documentElement.cancelDialog();
}
};

View file

@ -0,0 +1,62 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Copyright © 2016 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
-->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://global/content/commonDialog.css" type="text/css"?>
<?xml-stylesheet href="chrome://global/skin/commonDialog.css" type="text/css"?>
<!DOCTYPE overlay [ <!ENTITY % zoteroDTD SYSTEM "chrome://zotero/locale/zotero.dtd"> %zoteroDTD; ]>
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="" buttons="cancel,accept"
id="zotero-hardConfirmationDialog"
onload="Zotero.HardConfirmationDialog.init(); sizeToContent();"
ondialogaccept="Zotero.HardConfirmationDialog.onAccept();"
ondialogextra1="Zotero.HardConfirmationDialog.onExtra1();">
<script src="chrome://zotero/content/include.js"/>
<script src="hardConfirmationDialog.js"/>
<grid>
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row>
<hbox id="iconContainer" align="start"><image id="info.icon" class="spaced alert-icon"/></hbox>
<vbox id="infoContainer">
<separator class="thin"/>
<checkbox id="zotero-hardConfirmationDialog-checkbox" hidden="true" oncommand="Zotero.HardConfirmationDialog.onCheckbox(event)"/>
<textbox id="zotero-hardConfirmationDialog-textbox" hidden="true" onkeyup="Zotero.HardConfirmationDialog.onKeyUp(event)"/>
</vbox>
</row>
</rows>
</grid>
</dialog>

View file

@ -0,0 +1,332 @@
var Zotero_Import_Wizard = {
_wizard: null,
_dbs: null,
_file: null,
_translation: null,
init: async function () {
this._wizard = document.getElementById('import-wizard');
var dbs = await Zotero_File_Interface.findMendeleyDatabases();
if (dbs.length) {
document.getElementById('radio-import-source-mendeley').hidden = false;
}
// If no existing collections or non-trash items in the library, don't create a new
// collection by default
var args = window.arguments[0].wrappedJSObject;
if (args && args.libraryID) {
let sql = "SELECT ROWID FROM collections WHERE libraryID=?1 "
+ "UNION "
+ "SELECT ROWID FROM items WHERE libraryID=?1 "
// Not in trash
+ "AND itemID NOT IN (SELECT itemID FROM deletedItems) "
// And not a child item (which doesn't necessarily show up in the trash)
+ "AND itemID NOT IN (SELECT itemID FROM itemNotes WHERE parentItemID IS NOT NULL) "
+ "AND itemID NOT IN (SELECT itemID FROM itemAttachments WHERE parentItemID IS NOT NULL) "
+ "LIMIT 1";
if (!await Zotero.DB.valueQueryAsync(sql, args.libraryID)) {
document.getElementById('create-collection-checkbox').removeAttribute('checked');
}
}
Zotero.Translators.init(); // async
},
onModeChosen: async function () {
var wizard = this._wizard;
var mode = document.getElementById('import-source').selectedItem.id;
try {
switch (mode) {
case 'radio-import-source-file':
await this.chooseFile();
break;
case 'radio-import-source-mendeley':
this._dbs = await Zotero_File_Interface.findMendeleyDatabases();
// This shouldn't happen, because we only show the wizard if there are databases
if (!this._dbs.length) {
throw new Error("No databases found");
}
this._populateFileList(this._dbs);
document.getElementById('file-options-header').textContent
= Zotero.getString('fileInterface.chooseAppDatabaseToImport', 'Mendeley')
wizard.goTo('page-file-list');
wizard.canRewind = true;
this._enableCancel();
break;
default:
throw new Error(`Unknown mode ${mode}`);
}
}
catch (e) {
this._onDone(
Zotero.getString('general.error'),
Zotero.getString('fileInterface.importError'),
true
);
throw e;
}
},
goToStart: function () {
this._wizard.goTo('page-start');
this._wizard.canAdvance = true;
return false;
},
chooseFile: async function (translation) {
var translation = new Zotero.Translate.Import();
var translators = await translation.getTranslators();
const nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(nsIFilePicker);
fp.init(window, Zotero.getString("fileInterface.import"), nsIFilePicker.modeOpen);
fp.appendFilters(nsIFilePicker.filterAll);
var collation = Zotero.getLocaleCollation();
// Add Mendeley DB, which isn't a translator
var mendeleyFilter = {
label: "Mendeley Database", // TODO: Localize
target: "*.sqlite"
};
var filters = [...translators];
filters.push(mendeleyFilter);
filters.sort((a, b) => collation.compareString(1, a.label, b.label));
for (let filter of filters) {
fp.appendFilter(filter.label, "*." + filter.target);
}
var rv = fp.show();
if (rv !== nsIFilePicker.returnOK && rv !== nsIFilePicker.returnReplace) {
return false;
}
Zotero.debug(`File is ${fp.file.path}`);
this._file = fp.file.path;
this._wizard.canAdvance = true;
this._wizard.goTo('page-options');
},
/**
* When a file is clicked on in the file list
*/
onFileSelected: async function () {
var index = document.getElementById('file-list').selectedIndex;
if (index != -1) {
this._file = this._dbs[index].path;
this._wizard.canAdvance = true;
}
else {
this._file = null;
this._wizard.canAdvance = false;
}
},
/**
* When the user clicks "Other…" to choose a file not in the list
*/
chooseMendeleyDB: async function () {
document.getElementById('file-list').selectedIndex = -1;
const nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(nsIFilePicker);
fp.init(window, Zotero.getString('fileInterface.import'), nsIFilePicker.modeOpen);
fp.appendFilter("Mendeley Database", "*.sqlite"); // TODO: Localize
var rv = fp.show();
if (rv != nsIFilePicker.returnOK) {
return false;
}
this._file = fp.file.path;
this._wizard.canAdvance = true;
this._wizard.advance();
},
onOptionsShown: function () {
},
onImportStart: async function () {
if (!this._file) {
let index = document.getElementById('file-list').selectedIndex;
this._file = this._dbs[index].path;
}
this._disableCancel();
this._wizard.canRewind = false;
this._wizard.canAdvance = false;
await this.doImport({
createNewCollection: document.getElementById('create-collection-checkbox').hasAttribute('checked')
});
},
onBeforeImport: async function (translation) {
// Unrecognized translator
if (!translation) {
// Allow error dialog to be displayed, and then close window
setTimeout(function () {
window.close();
});
return;
}
this._translation = translation;
// Switch to progress pane
this._wizard.goTo('page-progress');
var pm = document.getElementById('import-progressmeter');
translation.setHandler('itemDone', function () {
pm.value = translation.getProgress();
});
},
doImport: async function (options) {
try {
let result = await Zotero_File_Interface.importFile({
file: this._file,
onBeforeImport: this.onBeforeImport.bind(this),
addToLibraryRoot: !options.createNewCollection
});
// Cancelled by user or due to error
if (!result) {
window.close();
return;
}
let numItems = this._translation.newItems.length;
this._onDone(
Zotero.getString('fileInterface.importComplete'),
Zotero.getString(`fileInterface.itemsWereImported`, numItems, numItems)
);
}
catch (e) {
if (e.message == 'Encrypted Mendeley database') {
let url = 'https://www.zotero.org/support/kb/mendeley_import';
this._onDone(
Zotero.getString('general.error'),
// TODO: Localize
`The selected Mendeley database cannot be read, likely because it is encrypted. `
+ `See <a href="${url}" class="text-link">How do I import a Mendeley library `
+ `into Zotero?</a> for more information.`
);
}
else {
this._onDone(
Zotero.getString('general.error'),
Zotero.getString('fileInterface.importError'),
true
);
}
throw e;
}
},
reportError: function () {
Zotero.getActiveZoteroPane().reportErrors();
window.close();
},
_populateFileList: async function (files) {
var listbox = document.getElementById('file-list');
// Remove existing entries
var items = listbox.getElementsByTagName('listitem');
for (let item of items) {
listbox.removeChild(item);
}
for (let file of files) {
let li = document.createElement('listitem');
let name = document.createElement('listcell');
// Simply filenames
let nameStr = file.name
.replace(/\.sqlite$/, '')
.replace(/@www\.mendeley\.com$/, '');
if (nameStr == 'online') {
nameStr = Zotero.getString('dataDir.default', 'online.sqlite');
}
name.setAttribute('label', nameStr + ' ');
li.appendChild(name);
let lastModified = document.createElement('listcell');
lastModified.setAttribute('label', file.lastModified.toLocaleString() + ' ');
li.appendChild(lastModified);
let size = document.createElement('listcell');
size.setAttribute(
'label',
Zotero.getString('general.nMegabytes', (file.size / 1024 / 1024).toFixed(1)) + ' '
);
li.appendChild(size);
listbox.appendChild(li);
}
if (files.length == 1) {
listbox.selectedIndex = 0;
}
},
_enableCancel: function () {
this._wizard.getButton('cancel').disabled = false;
},
_disableCancel: function () {
this._wizard.getButton('cancel').disabled = true;
},
_onDone: function (label, description, showReportErrorButton) {
var wizard = this._wizard;
wizard.getPageById('page-done').setAttribute('label', label);
var xulElem = document.getElementById('result-description');
var htmlElem = document.getElementById('result-description-html');
if (description.includes('href')) {
htmlElem.innerHTML = description;
Zotero.Utilities.Internal.updateHTMLInXUL(htmlElem);
xulElem.hidden = true;
htmlElem.setAttribute('display', 'block');
}
else {
xulElem.textContent = description;
xulElem.hidden = false;
htmlElem.setAttribute('display', 'none');
}
document.getElementById('result-description')
if (showReportErrorButton) {
let button = document.getElementById('result-report-error');
button.setAttribute('label', Zotero.getString('errorReport.reportError'));
button.hidden = false;
}
// When done, move to last page and allow closing
wizard.canAdvance = true;
wizard.goTo('page-done');
wizard.canRewind = false;
}
};

View file

@ -0,0 +1,75 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/importWizard.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<wizard id="import-wizard"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="&zotero.import;"
onload="Zotero_Import_Wizard.init()">
<script src="../include.js"/>
<script src="../fileInterface.js"/>
<script src="importWizard.js"/>
<wizardpage pageid="page-start"
label="&zotero.import.whereToImportFrom;"
next="page-options"
onpageadvanced="Zotero_Import_Wizard.onModeChosen(); return false;">
<radiogroup id="import-source">
<radio id="radio-import-source-file" label="&zotero.import.source.file;"/>
<radio id="radio-import-source-mendeley" label="Mendeley" hidden="true"/>
</radiogroup>
</wizardpage>
<wizardpage pageid="page-file-list"
next="page-options"
onpagerewound="return Zotero_Import_Wizard.goToStart()">
<description id="file-options-header"/>
<listbox id="file-list" onselect="Zotero_Import_Wizard.onFileSelected()">
<listhead>
<listheader label="&zotero.import.database;"/>
<listheader label="&zotero.import.lastModified;"/>
<listheader label="&zotero.import.size;"/>
</listhead>
<listcols>
<listcol flex="1"/>
<listcol/>
<listcol/>
</listcols>
</listbox>
<hbox>
<button label="&zotero.general.other;" oncommand="Zotero_Import_Wizard.chooseMendeleyDB()"/>
</hbox>
</wizardpage>
<wizardpage pageid="page-options"
label="&zotero.general.options;"
next="page-progress"
onpageshow="Zotero_Import_Wizard.onOptionsShown()"
onpagerewound="return Zotero_Import_Wizard.goToStart()"
onpageadvanced="Zotero_Import_Wizard.onImportStart()">
<checkbox id="create-collection-checkbox" label="&zotero.import.createCollection;" checked="true" />
</wizardpage>
<wizardpage pageid="page-progress"
label="&zotero.import.importing;"
onpageshow="document.getElementById('import-wizard').canRewind = false;"
next="page-done">
<progressmeter id="import-progressmeter" mode="determined"/>
</wizardpage>
<wizardpage pageid="page-done">
<description id="result-description"/>
<html:div id="result-description-html"/>
<hbox>
<button id="result-report-error"
oncommand="Zotero_Import_Wizard.reportError()"
hidden="true"/>
</hbox>
</wizardpage>
</wizard>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,102 @@
var map = {
83: {
itemTypes: {
Bill: "bill",
Book: "book",
BookSection: "bookSection",
Case: "case",
ComputerProgram: "computerProgram",
ConferenceProceedings: "conferencePaper",
EncyclopediaArticle: "encyclopediaArticle",
Film: "film",
Generic: "document",
JournalArticle: "journalArticle",
MagazineArticle: "magazineArticle",
NewspaperArticle: "newspaperArticle",
Patent: "patent",
Report: "report",
Statute: "statute",
TelevisionBroadcast: "tvBroadcast",
Thesis: "thesis",
WebPage: "webpage",
WorkingPaper: "report"
},
fields: {
id: "",
uuid: "",
reviewedArticle: "",
revisionNumber: "",
publisher: "publisher",
reprintEdition: "",
series: "seriesTitle",
seriesNumber: "seriesNumber",
sections: "section",
seriesEditor: "creator[seriesEditor]", // falls back to editor if necessary
owner: "",
pages: "func[pages]",
month: "", // handled explicitly
originalPublication: "",
publication: "publicationTitle",
publicLawNumber: "publicLawNumber",
pmid: "extra[PMID]",
sourceType: "",
session: "session",
shortTitle: "shortTitle",
volume: "volume",
year: "", // handled explicitly
userType: "type",
country: "place[country]",
dateAccessed: "accessDate",
committee: "committee",
counsel: "creator[counsel]",
doi: "DOI",
edition: "edition",
day: "", // handled explicitly
department: "",
citationKey: "citationKey", // put in Extra
city: "place[city]",
chapter: "",
codeSection: "section",
codeVolume: "codeVolume",
code: "code",
codeNumber: "codeNumber",
issue: "issue",
language: "language",
isbn: "ISBN",
issn: "ISSN",
length: "",
medium: "medium",
lastUpdate: "",
legalStatus: "legalStatus",
hideFromMendeleyWebIndex: "",
institution: "publisher",
genre: "genre",
internationalTitle: "",
internationalUserType: "",
internationalAuthor: "",
internationalNumber: "",
deletionPending: "",
favourite: "", // tag?
confirmed: "", // tag?
deduplicated: "",
read: "", // tag?
type: "", // item type handled separately
title: "title",
privacy: "",
applicationNumber: "applicationNumber",
arxivId: "extra[arXiv]",
advisor: "",
articleColumn: "",
modified: "func[fromUnixtime:dateModified]",
abstract: "abstractNote",
added: "func[fromUnixtime:dateAdded]",
note: "func[note]",
importer: ""
},
creatorTypes: {
DocumentAuthor: "author",
DocumentEditor: "editor",
DocumentTranslator: "translator"
}
}
};

View file

@ -0,0 +1,10 @@
/* global Components:false */
/* eslint-disable no-unused-vars */
var Zotero = Components.classes['@zotero.org/Zotero;1']
// Currently uses only nsISupports
//.getService(Components.interfaces.chnmIZoteroService).
.getService(Components.interfaces.nsISupports)
.wrappedJSObject;
Components.utils.import('resource://zotero/require.js');

View file

@ -0,0 +1,104 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
/**
* @namespace Singleton to interface with the browser when ingesting data
*/
var Zotero_Ingester_Interface_SelectItems = function() {}
//////////////////////////////////////////////////////////////////////////////
//
// Public Zotero_Ingester_Interface_SelectItems methods
//
//////////////////////////////////////////////////////////////////////////////
/**
* Presents items to select in the select box. Assumes window.arguments[0].dataIn is an object with
* URLs as keys and descriptions as values
*/
Zotero_Ingester_Interface_SelectItems.init = function() {
// Set font size from pref
var sbc = document.getElementById('zotero-select-items-container');
Zotero.setFontSize(sbc);
this.io = window.arguments[0];
var listbox = document.getElementById("zotero-selectitems-links");
for(var i in this.io.dataIn) { // we could use a tree for this if we wanted to
var item = this.io.dataIn[i];
var title, checked = false;
if(item && typeof(item) == "object" && item.title !== undefined) {
title = item.title;
checked = !!item.checked;
} else {
title = item;
}
var itemNode = document.createElement("listitem");
itemNode.setAttribute("type", "checkbox");
itemNode.setAttribute("value", i);
itemNode.setAttribute("label", title);
itemNode.setAttribute("checked", checked);
listbox.appendChild(itemNode);
}
// Check item if there is only one
if (listbox.itemCount === 1) {
listbox.getItemAtIndex(0).setAttribute("checked", true);
}
}
/**
* Selects or deselects all items
* @param {Boolean} deselect If true, deselect all items instead of selecting all items
*/
Zotero_Ingester_Interface_SelectItems.selectAll = function(deselect) {
var listbox = document.getElementById("zotero-selectitems-links");
for (var i=0; i<listbox.childNodes.length; i++){
listbox.childNodes[i].setAttribute('checked', !deselect);
}
}
/**
* Called when "OK" button is pressed to populate window.arguments[0].dataOut with selected items
*/
Zotero_Ingester_Interface_SelectItems.acceptSelection = function() {
var listbox = document.getElementById("zotero-selectitems-links");
var returnObject = false;
this.io.dataOut = new Object();
// collect scrapeURLList from listbox
for(var i=0; i<listbox.childNodes.length; i++) {
var itemNode = listbox.childNodes[i];
if(itemNode.getAttribute("checked") == "true") {
this.io.dataOut[itemNode.getAttribute("value")] = itemNode.getAttribute("label");
returnObject = true;
}
}
if(!returnObject) this.io.dataOut = null;
}

View file

@ -0,0 +1,51 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
-->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<dialog xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&zotero.selectitems.title;" width="400" height="330"
persist="width height screenX screenY"
buttons="cancel,accept"
ondialogaccept="Zotero_Ingester_Interface_SelectItems.acceptSelection()"
id="zotero-selectitems"
onload="Zotero_Ingester_Interface_SelectItems.init()">
<script src="../include.js"/>
<script src="selectitems.js"/>
<vbox id="zotero-select-items-container" flex="1">
<caption label="&zotero.selectitems.intro.label;" id="zotero-selectitems-intro"/>
<box flex="1">
<listbox id="zotero-selectitems-links" flex="1" context="zoteroSelectContext"></listbox>
</box>
<hbox>
<button label="Select All" oncommand="Zotero_Ingester_Interface_SelectItems.selectAll()"/>
<button label="Deselect All" oncommand="Zotero_Ingester_Interface_SelectItems.selectAll(true)"/>
</hbox>
</vbox>
</dialog>

View file

@ -0,0 +1,803 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
var Zotero_Citation_Dialog = new function () {
// Array value [0] is property name.
// Array value [1] is default value of property.
var _preserveData = {
"prefix":["value", ""],
"suffix":["value", ""],
"label":["selectedIndex", 0],
"locator":["value", ""],
"suppress-author":["checked", false]
};
var _accepted = false;
var _itemData = new Object();
var _multipleSourcesOn = false;
var _lastSelected = null;
var _previewShown = false;
var _suppressNextTreeSelect = false;
var _suppressNextListSelect = false;
var _customHTML = false;
var _locatorIndexArray = {};
var _locatorNameArray = {};
var _autoRegeneratePref;
var _acceptButton;
var _multipleSourceButton;
var _sortCheckbox;
var _citationList;
var _originalHTML;
var serial_number;
var io;
this.toggleMultipleSources = toggleMultipleSources;
this.toggleEditor = toggleEditor;
this.treeItemSelected = treeItemSelected;
this.listItemSelected = listItemSelected;
this.up = up;
this.down = down;
this.remove = remove;
this.setSortToggle = setSortToggle;
this.confirmRegenerate = confirmRegenerate;
this.accept = accept;
this.cancel = cancel;
/*
* initialize add citation dialog
*/
this.load = Zotero.Promise.coroutine(function* () {
// make sure we are visible
window.setTimeout(function() {
var screenX = window.screenX;
var screenY = window.screenY;
var xRange = [window.screen.availLeft, window.screen.width-window.outerWidth];
var yRange = [window.screen.availTop, window.screen.height-window.outerHeight];
if(screenX < xRange[0] || screenX > xRange[1] || screenY < yRange[0] || screenY > yRange[1]) {
var targetX = Math.max(Math.min(screenX, xRange[1]), xRange[0]);
var targetY = Math.max(Math.min(screenY, yRange[1]), yRange[0]);
Zotero.debug("Moving window to "+targetX+", "+targetY);
window.moveTo(targetX, targetY);
}
}, 0);
document.documentElement.getButton("extra1").label = Zotero.getString("citation.multipleSources");
document.documentElement.getButton("extra2").label = Zotero.getString("citation.showEditor");
io = window.arguments[0].wrappedJSObject;
// find accept button
_acceptButton = document.getElementById("zotero-add-citation-dialog").getButton("accept");
_multipleSourceButton = document.documentElement.getButton("extra1");
_autoRegeneratePref = Zotero.Prefs.get("integration.autoRegenerate");
_citationList = document.getElementById("citation-list");
// Manipulated by _addItem(). Discriminates between cite instances
// based on the same item in the same citation. Internal throwaway variable,
// reset each time _multipleSourcesOn is set to true.
serial_number = 0;
// if a style with sortable citations, present checkbox
if(io.sortable) {
_sortCheckbox = document.getElementById("keepSorted");
_sortCheckbox.hidden = false;
_sortCheckbox.checked = !io.citation.properties.unsorted;
}
// load locators
var locators = Zotero.Cite.labels;
var menu = document.getElementById("label");
var label_list = document.getElementById("locator-type-popup");
var i = 0;
for(var value in locators) {
var locator = locators[value];
var locatorLabel = Zotero.getString('citation.locator.'+locator.replace(/\s/g,''));
// add to list of labels
var child = document.createElement("menuitem");
child.setAttribute("value", value);
child.setAttribute("label", locatorLabel);
label_list.appendChild(child);
// add to array
_locatorIndexArray[locator] = i;
_locatorNameArray[i] = locator;
i++;
}
menu.selectedIndex = 0;
// load (from selectItemsDialog.js)
yield doLoad();
// if we already have a citation, load data from it
document.getElementById('editor').format = "RTF";
if(io.citation.citationItems.length) {
if(io.citation.citationItems.length === 1) {
// single citation
toggleMultipleSources(false);
_suppressNextTreeSelect = true;
// DEBUG: When editing a citation before the library data has been loaded (i.e., in
// Firefox before the pane has been opened), this is the citation id, not the item id,
// and this fails. It works on subsequent attempts. Since this won't happen in
// Standalone, we can ignore.
var id = io.citation.citationItems[0].id;
let selected = yield collectionsView.selectItem(id);
for(var box in _preserveData) {
var property = _preserveData[box][0];
if(io.citation.citationItems[0][box]) {
if(box === "label") {
document.getElementById(box)[property] = _locatorIndexArray[io.citation.citationItems[0][box]];
} else {
document.getElementById(box)[property] = io.citation.citationItems[0][box];
}
}
}
} else {
// multiple citations
toggleMultipleSources(true);
var _itemData = {};
// There is a little thrashing here, with repeated writes and
// overwrites of node content. But sticking to the same
// workflow for all updates (node -> array -> io.citation) makes
// debugging a little less painful.
for(var i=0; i<io.citation.citationItems.length; i++) {
var item = Zotero.Items.get(io.citation.citationItems[i].id);
if(item) {
var itemNode = _addItem(item);
var itemDataID = itemNode.getAttribute("value");
_itemData[itemDataID] = {};
for(var box in _preserveData) {
var domBox = document.getElementById(box);
var property = _preserveData[box][0];
if("undefined" !== typeof io.citation.citationItems[i][box]) {
if(box === "label") {
domBox[property] = _locatorIndexArray[io.citation.citationItems[i][box]];
} else {
domBox[property] = io.citation.citationItems[i][box];
}
} else {
domBox[property] = _preserveData[box][1];
}
}
_itemSelected(itemDataID, true);
}
}
for (var box in _preserveData) {
document.getElementById(box).disabled = true;
}
}
// show user-editable edited citation
if(io.citation.properties.custom) {
toggleEditor(io.citation.properties.custom);
delete io.citation.properties.custom;
}
_updateAccept();
} else {
toggleMultipleSources(false);
}
});
/*
* turn on/off multiple sources item list
*/
function toggleMultipleSources(mode) {
if (mode === false || mode === true) {
_multipleSourcesOn = !mode;
}
_multipleSourcesOn = !_multipleSourcesOn;
var popup = document.defaultView;
var dialog = document.getElementById("zotero-add-citation-dialog");
if (dialog.getAttribute("height") == 1) {
popup.sizeToContent();
}
if(_multipleSourcesOn) {
_multipleSourceButton.label = Zotero.getString("citation.singleSource");
document.getElementById("multiple-sources").setAttribute("hidden", false);
if(dialog.getAttribute("width") <= 600) {
popup.resizeTo(750, dialog.getAttribute("height"));
}
//popup.moveBy((600 - 750)/2, 0);
serial_number = 0;
// The mode is forced only when run from load(), in which case
// the adding of items is done separately.
if (mode !== true) {
this.add(true);
}
} else {
_multipleSourceButton.label = Zotero.getString("citation.multipleSources");
document.getElementById("multiple-sources").setAttribute("hidden", true);
//popup.resizeTo(600, dialog.getAttribute("height"));
//popup.moveBy((750 - 600)/2, 0);
// enable all fields
for(var box in _preserveData) {
document.getElementById(box).disabled = false;
}
var itemID = false;
if (_citationList.selectedIndex > -1) {
var itemDataID = _citationList.getSelectedItem(0).getAttribute("value");
itemID = itemDataID.slice(0, itemDataID.indexOf(":"));
}
// delete item list
_itemData = new Object();
// delete all items
_clearCitationList();
// refresh
if (itemID) {
collectionsView.selectItem(itemID);
}
_updateAccept();
_updatePreview();
}
}
/*
* called when an item in the item selection tree is clicked
*/
function treeItemSelected() {
if(_suppressNextTreeSelect) {
_suppressNextTreeSelect = false;
_updateAccept();
return;
}
var items = itemsView.getSelectedItems(true); // treeview from xpcom/itemTreeView.js
var itemID = (items.length ? items[0] : false);
if(_multipleSourcesOn) {
// We can safely use itemID here, because none of these operations
// affect selected items; this is all about the tree and navigation.
// turn off highlight in selected item list
_suppressNextListSelect = true;
document.getElementById("citation-list").selectedIndex = -1;
// disable all fields
for(var box in _preserveData) {
document.getElementById(box).disabled = true;
}
// disable adding nothing
document.getElementById("add").disabled = !itemID;
document.getElementById("remove").disabled = true;
document.getElementById("up").disabled = true;
document.getElementById("down").disabled = true;
} else {
for(var box in _preserveData) {
document.getElementById(box).disabled = !itemID;
}
_updateAccept();
_updatePreview();
}
}
/*
* called when an item in the selected items list is clicked
*/
function listItemSelected() {
if(_suppressNextListSelect) {
_suppressNextListSelect = false;
_updateAccept();
return;
}
var selectedListItem = _citationList.getSelectedItem(0);
var selectedListIndex = _citationList.selectedIndex;
var itemDataID = (selectedListItem ? selectedListItem.getAttribute("value") : false);
_itemSelected(itemDataID);
// turn off highlight in item tree
_suppressNextTreeSelect = true;
document.getElementById("zotero-items-tree").view.selection.clearSelection();
document.getElementById("remove").disabled = !itemDataID;
document.getElementById("add").disabled = true;
_configListPosition(!itemDataID, selectedListIndex);
}
function _configListPosition(flag, selectedListIndex) {
if (selectedListIndex > 0) {
document.getElementById("up").disabled = flag;
} else {
document.getElementById("up").disabled = true;
}
if (-1 < selectedListIndex && selectedListIndex < (_citationList.getRowCount() - 1)) {
document.getElementById("down").disabled = flag;
} else {
document.getElementById("down").disabled = true;
}
}
function _move(direction) {
// automatically uncheck sorted checkbox if user is rearranging citation
if(_sortCheckbox && _sortCheckbox.checked) {
_sortCheckbox.checked = false;
setSortToggle();
}
var insertBeforeItem;
var selectedListItem = _citationList.getSelectedItem(0);
var selectedListIndex = _citationList.selectedIndex;
var itemDataID = selectedListItem.getAttribute("value");
if (direction === -1) {
insertBeforeItem = selectedListItem.previousSibling;
} else {
insertBeforeItem = selectedListItem.nextSibling.nextSibling;
}
var listItem = _citationList.removeChild(selectedListItem);
_citationList.insertBefore(listItem, insertBeforeItem);
_citationList.selectedIndex = (selectedListIndex + direction);
_itemSelected(itemDataID);
_updatePreview();
_configListPosition(false, (selectedListIndex + direction));
}
function up() {
_move(-1);
}
function down() {
_move(1);
}
/*
* Adds an item to the multipleSources list
*/
this.add = Zotero.Promise.coroutine(function* (first_item) {
var pos, len;
var item = itemsView.getSelectedItems()[0]; // treeview from xpcom/itemTreeView.js
if (!item) {
yield sortCitation();
_updateAccept();
_updatePreview();
return;
}
// Add to selection list and generate a new itemDataID for this cite.
var selectionNode = _addItem(item);
var itemDataID = selectionNode.getAttribute("value");
document.getElementById("add").disabled = !itemDataID;
// Save existing locator and affix field content, if any.
if (first_item) {
_itemSelected(itemDataID, true);
} else {
_itemSelected();
// set to defaults
for(var box in _preserveData) {
var property = _preserveData[box][0];
var default_value = _preserveData[box][1];
document.getElementById(box)[property] = default_value;
}
// Save default locator and affix element values to this multi-item.
_itemSelected(itemDataID, true);
}
for(var box in _preserveData) {
document.getElementById(box).disabled = true;
}
_citationList.ensureElementIsVisible(selectionNode);
// allow user to press OK
selectionNode = yield sortCitation(selectionNode);
_citationList.selectItem(selectionNode);
_updateAccept();
_updatePreview();
});
/*
* Deletes a citation from the multipleSources list
*/
function remove() {
var selectedListItem = _citationList.getSelectedItem(0);
var selectedListIndex = _citationList.selectedIndex;
var itemDataID = selectedListItem.getAttribute("value");
// remove from _itemData
delete _itemData[itemDataID];
_itemData[itemDataID] = undefined;
_lastSelected = null;
// remove from list
_citationList.removeChild(selectedListItem);
if (selectedListIndex >= _citationList.getRowCount()) {
selectedListIndex = _citationList.getRowCount() - 1;
}
_citationList.selectedIndex = selectedListIndex;
_updateAccept();
_updatePreview();
}
/*
* Sorts preview citations, if preview is open.
*/
this.citationSortUnsort = Zotero.Promise.coroutine(function* () {
setSortToggle();
yield sortCitation();
_updatePreview();
});
/*
* Sets the current sort toggle state persistently on the citation.
*/
function setSortToggle() {
if(!_sortCheckbox) return;
if(!_sortCheckbox.checked) {
io.citation.properties.unsorted = true;
} else {
io.citation.properties.unsorted = false;
}
return;
}
/*
* Sorts the list of citations
*/
var sortCitation = Zotero.Promise.coroutine(function* (scrollToItem) {
if(!_sortCheckbox) return scrollToItem;
if(!_sortCheckbox.checked) {
io.citation.properties.unsorted = true;
return scrollToItem;
}
var scrollToItemID = false;
if (scrollToItem) {
scrollToItemID = scrollToItem.getAttribute("value");
}
_getCitation();
// delete all existing items from list
_clearCitationList();
// run preview function to re-sort, if it hasn't already been
// run
yield io.sort();
// add items back to list
scrollToItem = null;
for(var i=0; i<io.citation.sortedItems.length; i++) {
var itemID = io.citation.sortedItems[i][0].id;
var itemDataID = io.citation.sortedItems[i][1].tmpItemDataID;
var item = Zotero.Items.get(itemID);
// Don't increment serial_number, and use the
// existing itemDataID stored on the item in sortedItems
var itemNode = _addItem(item, itemDataID);
if(itemDataID == scrollToItemID) _citationList.selectedIndex = i;
if(scrollToItemID && itemDataID == scrollToItemID) scrollToItem = itemNode;
}
if(scrollToItem) _citationList.ensureElementIsVisible(scrollToItem);
return scrollToItem;
});
/*
* Ask whether to modifiy the preview
*/
function confirmRegenerate(focusShifted) {
if(document.getElementById('editor').value == _originalHTML || _originalHTML === undefined) {
// no changes; just update without asking
_updatePreview();
return;
}
if(_autoRegeneratePref == -1) {
if(focusShifted) { // only ask after onchange event; oninput is too
// frequent for this to be worthwhile
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var saveBehavior = { value: false };
var regenerate = promptService.confirmEx(
this.window,
Zotero.getString('integration.regenerate.title'),
Zotero.getString('integration.regenerate.body'),
promptService.STD_YES_NO_BUTTONS,
null, null, null,
Zotero.getString('integration.regenerate.saveBehavior'),
saveBehavior
);
if(saveBehavior.value) {
_autoRegeneratePref = (regenerate == 0 ? 1 : 0);
Zotero.Prefs.set("integration.autoRegenerate", _autoRegeneratePref);
}
if(regenerate == 0) {
_updatePreview();
}
}
} else if(_autoRegeneratePref == 1) {
_updatePreview();
}
}
/*
* Shows the edit pane
*/
function toggleEditor(text) {
var warning = document.getElementById('zotero-editor-warning');
var editor = document.getElementById('editor');
warning.hidden = _previewShown;
editor.hidden = _previewShown;
_previewShown = !_previewShown;
if(_previewShown) {
document.documentElement.getButton("extra2").label = Zotero.getString("citation.hideEditor");
if (!text && _customHTML) {
text = _customHTML;
}
if(text) {
io.preview().then(function(preview) {
_originalHTML = preview;
editor.value = text;
}).done();
} else {
_updatePreview();
}
} else {
if (editor.initialized) {
if (editor.value) {
_customHTML = editor.value;
}
}
document.documentElement.getButton("extra2").label = Zotero.getString("citation.showEditor");
}
}
/*
* called when accept button is clicked
*/
function accept() {
if(_accepted) return true;
_getCitation();
var isCustom = _previewShown && io.citation.citationItems.length // if a citation is selected
&& _originalHTML
&& document.getElementById('editor').value != _originalHTML // and citation has been edited
if(isCustom) {
var citation = document.getElementById('editor').value;
if(Zotero.Utilities.trim(citation) == "") {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var insert = promptService.confirm(window,
Zotero.getString("integration.emptyCitationWarning.title"),
Zotero.getString("integration.emptyCitationWarning.body"));
if(!insert) return false;
}
io.citation.properties.custom = citation;
}
io.accept();
_accepted = true;
return true;
}
/*
* called when cancel button is clicked
*/
function cancel() {
if(_accepted) return true;
io.citation.citationItems = new Array();
io.accept();
_accepted = true;
return true;
}
/*
* Updates the contents of the preview pane
*/
function _updatePreview() {
if(_previewShown) {
var editor = document.getElementById('editor');
_getCitation();
editor.readonly = !io.citation.citationItems.length;
if(io.citation.citationItems.length) {
io.preview().then(function(preview) {
editor.value = preview;
if (editor.initialized) {
_originalHTML = editor.value;
}
else {
editor.onInit(() => _originalHTML = editor.value);
}
});
} else {
editor.value = "";
_originalHTML = "";
}
}
}
/*
* Controls whether the accept (OK) button should be enabled
*/
function _updateAccept() {
if(_multipleSourcesOn) {
_acceptButton.disabled = !_citationList.getRowCount();
// To prevent accidental data loss, do not allow change to
// single citation mode if multiple items are in selection
// list.
if (_citationList.getRowCount() > 1) {
_multipleSourceButton.disabled = true;
} else {
_multipleSourceButton.disabled = false;
}
} else {
collectionsView.onLoad.addListener(Zotero.Promise.coroutine(function* () {
if (itemsView) {
yield itemsView.waitForLoad();
_acceptButton.disabled = !itemsView.getSelectedItems().length;
}
}));
}
}
/*
* called when an item is selected; if itemDataID is false, disables fields; if
* itemDataID is undefined, only updates _itemData array
*
* Note: This function no longer disables fields. That operation is
* now performed separately by explicit code.
*/
function _itemSelected(itemDataID, forceSave) {
if (forceSave) {
_lastSelected = itemDataID;
}
if(_lastSelected && !_itemData[_lastSelected]) {
_itemData[_lastSelected] = new Object();
}
for(var box in _preserveData) {
var domBox = document.getElementById(box);
var property = _preserveData[box][0];
// save property
if(_lastSelected) {
if(property == "label") {
_itemData[_lastSelected][box] = _locatorNameArray[domBox.selectedIndex];
} else {
_itemData[_lastSelected][box] = domBox[property];
}
}
// restore previous property
if(itemDataID) {
domBox.disabled = false;
if(_itemData[itemDataID] && _itemData[itemDataID][box] !== undefined) {
if(property == "label") {
domBox[property] = _locatorIndexArray[_itemData[itemDataID][box]];
} else {
domBox[property] = _itemData[itemDataID][box];
}
}
}
}
if(itemDataID !== undefined) _lastSelected = itemDataID;
}
/*
* updates io.citation to reflect selected items
*/
function _getCitation() {
var key;
io.citation.citationItems = new Array();
// use to map selectedIndexes back to page/paragraph/line
var locatorTypeElements = document.getElementById("label").getElementsByTagName("menuitem");
if(_multipleSourcesOn) {
_itemSelected(); // store locator info
var listLength = _citationList.getRowCount();
if(listLength) {
// generate citationItems
for(var i=0; i<listLength; i++) {
var itemDataID = _citationList.getItemAtIndex(i).getAttribute("value");
var citationItem = {};
for (key in _itemData[itemDataID]) {
// label is special everywhere
if (key === "label") {
citationItem.label = _locatorNameArray[_itemData[itemDataID].label];
} else if (_itemData[itemDataID][key]) {
citationItem[key] = _itemData[itemDataID][key];
}
}
citationItem["tmpItemDataID"] = itemDataID;
var itemID = itemDataID.slice(0, itemDataID.indexOf(":"));
citationItem.id = itemID;
io.citation.citationItems.push(citationItem);
}
}
} else {
var items = itemsView.getSelectedItems(true); // treeview from xpcom/itemTreeView.js
if(items.length) {
var citationItem = {};
citationItem.id = items[0];
for(var box in _preserveData) {
var property = _preserveData[box][0];
if(box == "label") {
citationItem[box] = _locatorNameArray[document.getElementById(box).selectedIndex];
} else {
var prop = document.getElementById(box)[property];
if(prop !== "" && prop !== false) citationItem[box] = prop;
}
}
if(!citationItem["locator"]) {
delete citationItem["locator"];
delete citationItem["label"];
}
io.citation.citationItems = [citationItem];
} else {
io.citation.citationItems = [];
}
}
}
/*
* Add an item to the item list (multiple sources only)
*/
function _addItem(item, forceID) {
var itemNode = document.createElement("listitem");
var itemDataID;
if (!forceID) {
serial_number += 1;
itemDataID = item.id + ":" + serial_number;
} else {
itemDataID = forceID;
}
itemNode.setAttribute("value", itemDataID);
itemNode.setAttribute("label", item.getDisplayTitle());
itemNode.setAttribute("class", "listitem-iconic");
itemNode.setAttribute("image", item.getImageSrc());
_citationList.appendChild(itemNode);
return itemNode;
}
/*
* Removes all items from the multiple sources list
*/
function _clearCitationList() {
while(_citationList.firstChild) _citationList.removeChild(_citationList.firstChild);
}
}

View file

@ -0,0 +1,297 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
-->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://global/skin/dialog.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/overlay.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero-platform/content/overlay.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/integration.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<dialog
id="zotero-add-citation-dialog"
windowtype="zotero:item-selector"
orient="vertical"
title="&zotero.integration.addEditCitation.title;"
width="600" height="450"
onload="Zotero_Citation_Dialog.load();"
onunload="doUnload();"
ondialogaccept="return Zotero_Citation_Dialog.accept();"
ondialogcancel="Zotero_Citation_Dialog.cancel();"
onclose="Zotero_Citation_Dialog.cancel();"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
persist="screenX screenY width height"
resizable="true"
buttons="extra1,extra2,accept,cancel"
ondialogextra2="Zotero_Citation_Dialog.toggleEditor()"
ondialogextra1="Zotero_Citation_Dialog.toggleMultipleSources()">
<script src="../include.js"/>
<script src="../selectItemsDialog.js"/>
<script src="addCitationDialog.js"/>
<vbox id="zotero-select-items-container" flex="1">
<vbox flex="1">
<hbox flex="1">
<vbox align="stretch" flex="1">
<hbox align="center" pack="end">
<textbox id="zotero-tb-search" type="search" timeout="250" oncommand="onSearch()" tabindex="1"
onkeypress="if(event.keyCode == event.DOM_VK_ESCAPE) { if (this.value == '') { cancelDialog(); return false; } this.value = ''; onSearch(); return false; } return true;"/>
</hbox>
<hbox flex="1" style="margin-top: 5px">
<tree id="zotero-collections-tree"
style="width: 200px;" hidecolumnpicker="true" seltype="cell"
onselect="onCollectionSelected();">
<treecols>
<treecol
id="zotero-collections-name-column"
flex="1"
primary="true"
hideheader="true"/>
</treecols>
<treechildren/>
</tree>
<deck id="zotero-items-pane-content" selectedIndex="0" flex="1">
<tree id="zotero-items-tree"
enableColumnDrag="true" flex="1" seltype="single"
onselect="onItemSelected(); Zotero_Citation_Dialog.treeItemSelected();">
<treecols id="zotero-items-columns-header">
<treecol
id="zotero-items-column-title" primary="true"
label="&zotero.items.title_column;"
flex="4" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-firstCreator"
label="&zotero.items.creator_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-itemType" hidden="true"
label="&zotero.items.type_column;"
width="40" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-date" hidden="true"
label="&zotero.items.date_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-year" hidden="true"
label="&zotero.items.year_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-publisher" hidden="true"
label="&zotero.items.publisher_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-publicationTitle" hidden="true"
label="&zotero.items.publication_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-journalAbbreviation" hidden="true"
label="&zotero.items.journalAbbr_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-language" hidden="true"
label="&zotero.items.language_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-accessDate" hidden="true"
label="&zotero.items.accessDate_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-libraryCatalog" hidden="true"
label="&zotero.items.libraryCatalog_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-callNumber" hidden="true"
submenu="true"
label="&zotero.items.callNumber_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-rights" hidden="true"
submenu="true"
label="&zotero.items.rights_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-dateAdded" hidden="true"
label="&zotero.items.dateAdded_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-dateModified" hidden="true"
label="&zotero.items.dateModified_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-archive" hidden="true"
submenu="true"
label="&zotero.items.archive_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-archiveLocation" hidden="true"
submenu="true"
label="&zotero.items.archiveLocation_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-place" hidden="true"
submenu="true"
label="&zotero.items.place_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-volume" hidden="true"
submenu="true"
label="&zotero.items.volume_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-edition" hidden="true"
submenu="true"
label="&zotero.items.edition_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-pages" hidden="true"
submenu="true"
label="&zotero.items.pages_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-issue" hidden="true"
submenu="true"
label="&zotero.items.issue_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-series" hidden="true"
submenu="true"
label="&zotero.items.series_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-seriesTitle" hidden="true"
submenu="true"
label="&zotero.items.seriesTitle_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-court" hidden="true"
submenu="true"
label="&zotero.items.court_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-medium" hidden="true"
submenu="true"
label="&zotero.items.medium_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-genre" hidden="true"
submenu="true"
label="&zotero.items.genre_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-system" hidden="true"
submenu="true"
label="&zotero.items.system_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-extra" hidden="true"
label="&zotero.items.extra_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
</treecols>
<treechildren/>
</tree>
<!-- Label for displaying messages when items pane is hidden
(e.g. "Advanced search mode — press Enter to search.")-->
<vbox id="zotero-items-pane-message-box" pack="center" align="center"/>
</deck>
</hbox>
</vbox>
<hbox hidden="true" id="multiple-sources" align="stretch">
<vbox align="center" pack="center" id="citation-buttons">
<toolbarbutton id="up" oncommand="Zotero_Citation_Dialog.up()" disabled="true"/>
<toolbarbutton id="add" oncommand="Zotero_Citation_Dialog.add()" disabled="true"/>
<toolbarbutton id="remove" oncommand="Zotero_Citation_Dialog.remove()" disabled="true"/>
<toolbarbutton id="down" oncommand="Zotero_Citation_Dialog.down()" disabled="true"/>
</vbox>
<vbox align="left">
<checkbox id="keepSorted" hidden="true" checked="false" oncommand="Zotero_Citation_Dialog.citationSortUnsort()" label="&zotero.citation.keepSorted.label;"/>
<listbox id="citation-list" flex="1" align="stretch" seltype="single"
onselect="Zotero_Citation_Dialog.listItemSelected();"/>
</vbox>
</hbox>
</hbox>
<hbox align="stretch" style="margin-top: 8px">
<vbox flex="1">
<hbox align="center">
<label value="&zotero.citation.prefix.label;"/>
<textbox oninput="Zotero_Citation_Dialog.confirmRegenerate(false)" onchange="Zotero_Citation_Dialog.confirmRegenerate(true)" class="fix" id="prefix" align="stretch" flex="1" tabindex="3"/>
</hbox>
<hbox align="center">
<label value="&zotero.citation.suffix.label;"/>
<textbox oninput="Zotero_Citation_Dialog.confirmRegenerate(false)" onchange="Zotero_Citation_Dialog.confirmRegenerate(true)" class="fix" id="suffix" align="stretch" flex="1" tabindex="4"/>
</hbox>
<spacer flex="1"/>
</vbox>
<separator flex="4"/>
<vbox flex="1">
<hbox align="stretch">
<menulist onchange="Zotero_Citation_Dialog.confirmRegenerate(true)" id="label" tabindex="5">
<menupopup id="locator-type-popup"/>
</menulist>
<textbox oninput="Zotero_Citation_Dialog.confirmRegenerate(false)" onchange="Zotero_Citation_Dialog.confirmRegenerate(true)" id="locator" tabindex="2" flex="1"/>
</hbox>
<separator style="height: 2px" flex="1"/>
<checkbox oncommand="Zotero_Citation_Dialog.confirmRegenerate(true)" id="suppress-author" label="&zotero.citation.suppressAuthor.label;" tabindex="6"/>
</vbox>
</hbox>
</vbox>
<textbox id="editor" type="styled" mode="integration" hidden="true" flex="1"/>
<description id="zotero-editor-warning" style="margin: 9px 1px 0" hidden="true">&zotero.citation.editorWarning.label;</description>
</vbox>
</dialog>

View file

@ -0,0 +1,328 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
var Zotero_Bibliography_Dialog = new function () {
var bibEditInterface;
var _lastSelectedItemID = false;
var _lastSelectedIndex = false;
var _lastSelectedValue = false;
var _accepted = false;
var _revertButton, _revertAllButton, _addButton, _removeButton;
var _itemList;
var _suppressAllSelectEvents = false;
/**
* Initializes add citation dialog
*/
this.load = function() {
bibEditInterface = window.arguments[0].wrappedJSObject;
_revertAllButton = document.documentElement.getButton("extra2");
_revertButton = document.documentElement.getButton("extra1");
_addButton = document.getElementById("add");
_removeButton = document.getElementById("remove");
_itemList = document.getElementById("item-list");
_itemTree = document.getElementById("zotero-items-tree");
_revertAllButton.label = Zotero.getString("integration.revertAll.button");
_revertAllButton.disabled = bibEditInterface.isAnyEdited();
_revertButton.label = Zotero.getString("integration.revert.button");
_revertButton.disabled = true;
document.getElementById('editor').format = "RTF";
// load (from selectItemsDialog.js)
doLoad();
// load bibliography entires
_loadItems();
}
/**
* Called when an item in the item selection tree is clicked
*/
this.treeItemSelected = function() {
if(_suppressAllSelectEvents) return;
var selectedItemIDs = itemsView.getSelectedItems(true); // treeview from selectItemsDialog.js
// if all selected items are available in the list box on the right, select them there
// otherwise, clear the list box selection
var clearListItems = false;
var itemsToSelect = [];
if(selectedItemIDs.length) {
for (let itemID of selectedItemIDs) {
var itemIndexToSelect = false;
for(var i in bibEditInterface.bib[0].entry_ids) {
if(bibEditInterface.bib[0].entry_ids[i].indexOf(itemID) !== -1) {
itemIndexToSelect = i;
continue;
}
}
if(itemIndexToSelect !== false) {
itemsToSelect.push(_itemList.getItemAtIndex(itemIndexToSelect));
} else {
clearListItems = true;
break;
}
}
}
_suppressAllSelectEvents = true;
_itemList.clearSelection();
if(clearListItems) {
_addButton.disabled = (itemsToSelect.length > 0);
_revertButton.disabled = _removeButton.disabled = true;
} else {
_addButton.disabled = true;
_removeButton.disabled = false;
_updateRevertButtonStatus();
itemsToSelect.forEach(item => _itemList.toggleItemSelection(item));
_itemList.ensureIndexIsVisible(itemsToSelect[0]);
}
_suppressAllSelectEvents = false;
_updatePreview();
}
/**
* Called when an item in the reference list is clicked
*/
this.listItemSelected = function() {
if(_suppressAllSelectEvents) return;
// enable remove if at least one item is selected
_addButton.disabled = true;
_removeButton.disabled = !_itemList.selectedItems.length;
if(_itemList.selectedItems.length) {
_suppressAllSelectEvents = true;
_itemTree.view.selection.clearSelection();
_suppressAllSelectEvents = false;
// only show revert button if at least one selected item has been edited
_updateRevertButtonStatus();
}
// update preview to blank if no items or multiple items are selected; otherwise show
// preview for selected items
_updatePreview();
}
/**
* Adds references to the reference list
*/
this.add = function() {
for (let itemID of itemsView.getSelectedItems(true)) {
bibEditInterface.add(itemID);
}
document.getElementById("add").disabled = true;
_loadItems();
}
/**
* Clears all customizations
*/
this.revertAll = function() {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var out = {};
var regenerate = promptService.confirmEx(
window,
Zotero.getString('integration.revertAll.title'),
Zotero.getString('integration.revertAll.body'),
promptService.STD_OK_CANCEL_BUTTONS+promptService.BUTTON_POS_1_DEFAULT,
null, null, null, null, out
);
if(regenerate != 0) return;
bibEditInterface.revertAll();
_loadItems();
_updatePreview(true);
}
/**
* Clears customizations to selected entry
*/
this.revert = function() {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var out = {};
var regenerate = promptService.confirmEx(
window,
Zotero.getString('integration.revert.title'),
Zotero.getString('integration.revert.body'),
promptService.STD_OK_CANCEL_BUTTONS+promptService.BUTTON_POS_1_DEFAULT,
null, null, null, null, out
);
if(regenerate != 0) return;
for (let itemID of _getSelectedListItemIDs()) {
bibEditInterface.revert(itemID);
}
_updatePreview();
}
/**
* Deletes selected references from the reference list
*/
this.remove = function() {
var selectedListItemIDs = _getSelectedListItemIDs();
// if cited in bibliography, warn before removing
var isCited = false;
for (let itemID of selectedListItemIDs) {
isCited |= bibEditInterface.isCited(itemID);
}
if(isCited) {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var out = {};
var regenerate = promptService.confirmEx(
window,
Zotero.getString('integration.removeBibEntry.title'),
Zotero.getString('integration.removeBibEntry.body'),
promptService.STD_OK_CANCEL_BUTTONS+promptService.BUTTON_POS_1_DEFAULT,
null, null, null, null, out
);
if(regenerate != 0) return;
}
// remove
for (let itemID of selectedListItemIDs) {
bibEditInterface.remove(itemID);
}
_loadItems();
}
/**
* Called when the user edits the currently selected bibliography entry
*/
this.textChanged = function() {
_revertButton.disabled = _revertAllButton.disabled = false;
}
/**
* Called when OK button is pressed
*/
this.accept = function() {
if(_accepted) return;
_updatePreview(true);
_accepted = true;
}
/**
* Called when Cancel button is pressed
*/
this.close = function() {
if(_accepted) return;
bibEditInterface.cancel();
_accepted = true;
}
/**
* Gets selected item IDs from list box on right
*/
function _getSelectedListItemIDs() {
return Array.from(_itemList.selectedItems)
.map(item => bibEditInterface.bib[0].entry_ids[item.value][0]);
}
/**
* Update status of "Revert" button to match modification status of current item
*/
function _updateRevertButtonStatus() {
_revertButton.disabled = true;
var selectedListItemIDs = _getSelectedListItemIDs();
for (let itemID of selectedListItemIDs) {
if(bibEditInterface.isEdited(itemID)) {
_revertButton.disabled = false;
break;
}
}
}
/**
* Updates the contents of the preview pane
*/
function _updatePreview(ignoreSelection) {
var index = !ignoreSelection && _itemList.selectedItems.length == 1 ? _itemList.selectedIndex : undefined;
var editor = document.getElementById('editor');
if(_lastSelectedItemID) {
var newValue = editor.value;
if(_lastSelectedValue != newValue) {
bibEditInterface.setCustomText(_lastSelectedItemID, newValue);
}
}
editor.readonly = index === undefined;
if(index !== undefined) {
var itemID = bibEditInterface.bib[0].entry_ids[index];
editor.value = bibEditInterface.bib[1][index];
_lastSelectedIndex = index;
_lastSelectedItemID = itemID;
_lastSelectedValue = editor.value;
} else {
editor.value = "";
_lastSelectedIndex = _lastSelectedItemID = _lastSelectedValue = false;
}
_revertAllButton.disabled = !bibEditInterface.isAnyEdited();
}
/*
* loads items from itemSet
*/
function _loadItems() {
var itemIDs = bibEditInterface.bib[0].entry_ids;
var items = itemIDs.map(itemID => Zotero.Cite.getItem(itemID[0]));
// delete all existing items from list
var itemList = document.getElementById("item-list");
while(itemList.firstChild) {
itemList.removeChild(itemList.firstChild);
}
// add new items
for(var i=0; i<items.length; i++) {
var itemNode = document.createElement("listitem");
itemNode.setAttribute("value", i);
itemNode.setAttribute("label", items[i].getDisplayTitle());
itemNode.setAttribute("class", "listitem-iconic");
itemNode.setAttribute("image", items[i].getImageSrc());
itemList.appendChild(itemNode);
}
_updatePreview();
}
}

View file

@ -0,0 +1,129 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
-->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/overlay.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero-platform/content/overlay.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/integration.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<dialog
id="zotero-edit-bibliography-dialog"
orient="vertical"
title="&zotero.integration.editBibliography.title;"
width="750" height="450"
onload="Zotero_Bibliography_Dialog.load();"
ondialogaccept="Zotero_Bibliography_Dialog.accept();"
ondialogcancel="Zotero_Bibliography_Dialog.close();"
onclose="Zotero_Bibliography_Dialog.close();"
onunload="doUnload();"
buttons="extra1,extra2,accept,cancel" buttonpack="end"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
persist="screenX screenY width height"
resizable="true"
ondialogextra1="Zotero_Bibliography_Dialog.revert()"
ondialogextra2="Zotero_Bibliography_Dialog.revertAll()">
<script src="../include.js"/>
<script src="../selectItemsDialog.js"/>
<script src="editBibliographyDialog.js"/>
<vbox id="zotero-select-items-container" flex="1">
<vbox flex="1">
<hbox flex="1">
<vbox align="stretch" flex="1">
<hbox align="center" pack="end">
<textbox id="zotero-tb-search" type="search" timeout="250" oncommand="onSearch()" dir="reverse" onkeypress="if(event.keyCode == event.DOM_VK_ESCAPE) { this.value = ''; this.doCommand('cmd_zotero_search'); return false; } return true;"/>
</hbox>
<hbox flex="1" style="margin-top: 5px">
<tree id="zotero-collections-tree"
style="width: 150px;" hidecolumnpicker="true" seltype="single"
onselect="onCollectionSelected();">
<treecols>
<treecol
id="zotero-collections-name-column"
flex="1"
primary="true"
hideheader="true"/>
</treecols>
<treechildren/>
</tree>
<deck id="zotero-items-pane-content" selectedIndex="0" flex="1">
<tree id="zotero-items-tree"
flex="1" hidecolumnpicker="true" seltype="multiple"
onselect="Zotero_Bibliography_Dialog.treeItemSelected();">
<treecols>
<treecol
id="zotero-items-column-title" primary="true"
label="&zotero.items.title_column;"
flex="4" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-firstCreator"
label="&zotero.items.creator_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-dateAdded" hidden="true"
label="&zotero.items.dateAdded_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-dateModified" hidden="true"
label="&zotero.items.dateModified_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
</treecols>
<treechildren/>
</tree>
<!-- Label for displaying messages when items pane is hidden
(e.g. "Advanced search mode — press Enter to search.")-->
<vbox id="zotero-items-pane-message-box" pack="center" align="center"/>
</deck>
</hbox>
</vbox>
<hbox id="source-list">
<vbox align="center" pack="center" id="citation-buttons">
<toolbarbutton id="add" oncommand="Zotero_Bibliography_Dialog.add()" disabled="true"/>
<toolbarbutton id="remove" oncommand="Zotero_Bibliography_Dialog.remove()" disabled="true"/>
</vbox>
<vbox>
<label value="&zotero.integration.references.label;"/>
<listbox id="item-list" flex="1" align="stretch" seltype="multiple"
style="width: 250px;" onselect="Zotero_Bibliography_Dialog.listItemSelected();"
onchanged="Zotero_Bibliography_Dialog.textChanged()"/>
</vbox>
</hbox>
</hbox>
</vbox>
<textbox id="editor" type="styled" mode="integration" flex="1"/>
<description id="zotero-editor-warning" style="margin: 9px 1px 0">&zotero.citation.editorWarning.label;</description>
</vbox>
</dialog>

View file

@ -0,0 +1,94 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
-->
<?xml-stylesheet href="chrome://global/skin/global.css"?>
<?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css"?>
<?xml-stylesheet href="chrome://zotero/skin/bibliography.css"?>
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<dialog
id="zotero-doc-prefs-dialog"
orient="vertical"
buttons="accept,cancel,help"
title="&zotero.integration.docPrefs.title;"
onload="Zotero_File_Interface_Bibliography.init();"
ondialogaccept="Zotero_File_Interface_Bibliography.acceptSelection();"
ondialoghelp="Zotero_File_Interface_Bibliography.openHelpLink();"
onclose="document.documentElement.cancelDialog(); event.preventDefault(); event.stopPropagation();"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
persist="screenX screenY"
style="width: 600px">
<script src="../include.js"/>
<script src="../bibliography.js"/>
<vbox id="zotero-bibliography-container">
<groupbox>
<caption label="&zotero.bibliography.style.label;"/>
<listbox id="style-listbox" onselect="Zotero_File_Interface_Bibliography.styleChanged()"/>
<hbox align="right">
<label id="manage-styles" class="text-link"
onclick="Zotero_File_Interface_Bibliography.manageStyles()">&zotero.bibliography.manageStyles;</label>
</hbox>
</groupbox>
<groupbox id="locale-box">
<hbox align="center">
<caption label="&zotero.bibliography.locale.label;"/>
<menulist id="locale-menu" oncommand="Zotero_File_Interface_Bibliography.localeChanged(this.selectedItem.value)"/>
</hbox>
</groupbox>
<groupbox id="displayAs-groupbox">
<caption label="&zotero.integration.prefs.displayAs.label;"/>
<radiogroup id="displayAs" orient="horizontal">
<radio id="footnotes" label="&zotero.integration.prefs.footnotes.label;" selected="true"/>
<radio id="endnotes" label="&zotero.integration.prefs.endnotes.label;"/>
</radiogroup>
</groupbox>
<groupbox id="formatUsing-groupbox">
<caption label="&zotero.integration.prefs.formatUsing.label;"/>
<radiogroup id="formatUsing" orient="vertical">
<radio id="fields" selected="true"/>
<label class="radioDescription" id="fields-caption"/>
<label class="radioDescription" id="fields-file-format-notice"/>
<radio id="bookmarks" label="&zotero.integration.prefs.bookmarks.label;"/>
<description class="radioDescription" id="bookmarks-caption">&zotero.integration.prefs.bookmarks.caption;</description>
<description class="radioDescription" id="bookmarks-file-format-notice"/>
</radiogroup>
</groupbox>
<vbox id="automaticJournalAbbreviations-vbox">
<checkbox id="automaticJournalAbbreviations-checkbox" label="&zotero.integration.prefs.automaticJournalAbbeviations.label;"/>
<description class="radioDescription">&zotero.integration.prefs.automaticJournalAbbeviations.caption;</description>
</vbox>
<vbox id="automaticCitationUpdates-vbox">
<checkbox id="automaticCitationUpdates-checkbox" label="&zotero.integration.prefs.automaticCitationUpdates.label;" tooltiptext="&zotero.integration.prefs.automaticCitationUpdates.tooltip;"/>
<description class="radioDescription">&zotero.integration.prefs.automaticCitationUpdates.description;</description>
</vbox>
</vbox>
</dialog>

View file

@ -0,0 +1,121 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2018 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
Components.utils.import("resource://gre/modules/Services.jsm");
var Zotero_ProgressBar = new function () {
var initialized, io;
/**
* Pre-initialization, when the dialog has loaded but has not yet appeared
*/
this.onDOMContentLoaded = function(event) {
if(event.target === document) {
initialized = true;
io = window.arguments[0].wrappedJSObject;
if (io.onLoad) {
io.onLoad(_onProgress);
}
// Only hide chrome on Windows or Mac
if(Zotero.isMac) {
document.documentElement.setAttribute("drawintitlebar", true);
} else if(Zotero.isWin) {
document.documentElement.setAttribute("hidechrome", true);
}
new WindowDraggingElement(document.getElementById("quick-format-dialog"), window);
}
};
/**
* Center the window
*/
this.onLoad = function(event) {
if(event.target !== document) return;
// make sure we are visible
window.focus();
window.setTimeout(function() {
var targetX = Math.floor(-window.outerWidth/2 + (window.screen.width / 2));
var targetY = Math.floor(-window.outerHeight/2 + (window.screen.height / 2));
Zotero.debug("Moving window to "+targetX+", "+targetY);
window.moveTo(targetX, targetY);
}, 0);
};
/**
* Called when progress changes
*/
function _onProgress(percent) {
var meter = document.getElementById("quick-format-progress-meter");
if(percent === null) {
meter.mode = "undetermined";
} else {
meter.mode = "determined";
meter.value = Math.round(percent);
}
}
/**
* Resizes windows
* @constructor
*/
var Resizer = function(panel, targetWidth, targetHeight, pixelsPerStep, stepsPerSecond) {
this.panel = panel;
this.curWidth = panel.clientWidth;
this.curHeight = panel.clientHeight;
this.difX = (targetWidth ? targetWidth - this.curWidth : 0);
this.difY = (targetHeight ? targetHeight - this.curHeight : 0);
this.step = 0;
this.steps = Math.ceil(Math.max(Math.abs(this.difX), Math.abs(this.difY))/pixelsPerStep);
this.timeout = (1000/stepsPerSecond);
var me = this;
this._animateCallback = function() { me.animate() };
};
/**
* Performs a step of the animation
*/
Resizer.prototype.animate = function() {
if(this.stopped) return;
this.step++;
this.panel.sizeTo(this.curWidth+Math.round(this.step*this.difX/this.steps),
this.curHeight+Math.round(this.step*this.difY/this.steps));
if(this.step !== this.steps) {
window.setTimeout(this._animateCallback, this.timeout);
}
};
/**
* Halts resizing
*/
Resizer.prototype.stop = function() {
this.stopped = true;
};
}
window.addEventListener("DOMContentLoaded", Zotero_ProgressBar.onDOMContentLoaded, false);
window.addEventListener("load", Zotero_ProgressBar.onLoad, false);

Some files were not shown because too many files have changed in this diff Show more