565 lines
65 KiB
JavaScript
565 lines
65 KiB
JavaScript
|
/*
|
||
|
Copyright 2012 Igor Vaynberg
|
||
|
|
||
|
Version: 3.3.1 Timestamp: Wed Feb 20 09:57:22 PST 2013
|
||
|
|
||
|
This software is licensed under the Apache License, Version 2.0 (the "Apache License") or the GNU
|
||
|
General Public License version 2 (the "GPL License"). You may choose either license to govern your
|
||
|
use of this software only upon the condition that you accept all of the terms of either the Apache
|
||
|
License or the GPL License.
|
||
|
|
||
|
You may obtain a copy of the Apache License and the GPL License at:
|
||
|
|
||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||
|
http://www.gnu.org/licenses/gpl-2.0.html
|
||
|
|
||
|
Unless required by applicable law or agreed to in writing, software distributed under the Apache License
|
||
|
or the GPL Licesnse is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||
|
either express or implied. See the Apache License and the GPL License for the specific language governing
|
||
|
permissions and limitations under the Apache License and the GPL License.
|
||
|
|
||
|
LICENSE #1: Apache License, Version 2.0
|
||
|
|
||
|
LICENSE #2: GPL v2
|
||
|
|
||
|
************************************************************
|
||
|
|
||
|
LICENSE #1:
|
||
|
|
||
|
Apache License
|
||
|
Version 2.0, January 2004
|
||
|
http://www.apache.org/licenses/
|
||
|
|
||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||
|
|
||
|
1. Definitions.
|
||
|
|
||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||
|
|
||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||
|
the copyright owner that is granting the License.
|
||
|
|
||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||
|
other entities that control, are controlled by, or are under common
|
||
|
control with that entity. For the purposes of this definition,
|
||
|
"control" means (i) the power, direct or indirect, to cause the
|
||
|
direction or management of such entity, whether by contract or
|
||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||
|
|
||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||
|
exercising permissions granted by this License.
|
||
|
|
||
|
"Source" form shall mean the preferred form for making modifications,
|
||
|
including but not limited to software source code, documentation
|
||
|
source, and configuration files.
|
||
|
|
||
|
"Object" form shall mean any form resulting from mechanical
|
||
|
transformation or translation of a Source form, including but
|
||
|
not limited to compiled object code, generated documentation,
|
||
|
and conversions to other media types.
|
||
|
|
||
|
"Work" shall mean the work of authorship, whether in Source or
|
||
|
Object form, made available under the License, as indicated by a
|
||
|
copyright notice that is included in or attached to the work
|
||
|
(an example is provided in the Appendix below).
|
||
|
|
||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||
|
form, that is based on (or derived from) the Work and for which the
|
||
|
editorial revisions, annotations, elaborations, or other modifications
|
||
|
represent, as a whole, an original work of authorship. For the purposes
|
||
|
of this License, Derivative Works shall not include works that remain
|
||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||
|
the Work and Derivative Works thereof.
|
||
|
|
||
|
"Contribution" shall mean any work of authorship, including
|
||
|
the original version of the Work and any modifications or additions
|
||
|
to that Work or Derivative Works thereof, that is intentionally
|
||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||
|
means any form of electronic, verbal, or written communication sent
|
||
|
to the Licensor or its representatives, including but not limited to
|
||
|
communication on electronic mailing lists, source code control systems,
|
||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||
|
Licensor for the purpose of discussing and improving the Work, but
|
||
|
excluding communication that is conspicuously marked or otherwise
|
||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||
|
|
||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||
|
on behalf of whom a Contribution has been received by Licensor and
|
||
|
subsequently incorporated within the Work.
|
||
|
|
||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||
|
this License, each Contributor hereby grants to You a perpetual,
|
||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||
|
copyright license to reproduce, prepare Derivative Works of,
|
||
|
publicly display, publicly perform, sublicense, and distribute the
|
||
|
Work and such Derivative Works in Source or Object form.
|
||
|
|
||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||
|
this License, each Contributor hereby grants to You a perpetual,
|
||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||
|
(except as stated in this section) patent license to make, have made,
|
||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||
|
where such license applies only to those patent claims licensable
|
||
|
by such Contributor that are necessarily infringed by their
|
||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||
|
with the Work to which such Contribution(s) was submitted. If You
|
||
|
institute patent litigation against any entity (including a
|
||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||
|
or a Contribution incorporated within the Work constitutes direct
|
||
|
or contributory patent infringement, then any patent licenses
|
||
|
granted to You under this License for that Work shall terminate
|
||
|
as of the date such litigation is filed.
|
||
|
|
||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||
|
Work or Derivative Works thereof in any medium, with or without
|
||
|
modifications, and in Source or Object form, provided that You
|
||
|
meet the following conditions:
|
||
|
|
||
|
(a) You must give any other recipients of the Work or
|
||
|
Derivative Works a copy of this License; and
|
||
|
|
||
|
(b) You must cause any modified files to carry prominent notices
|
||
|
stating that You changed the files; and
|
||
|
|
||
|
(c) You must retain, in the Source form of any Derivative Works
|
||
|
that You distribute, all copyright, patent, trademark, and
|
||
|
attribution notices from the Source form of the Work,
|
||
|
excluding those notices that do not pertain to any part of
|
||
|
the Derivative Works; and
|
||
|
|
||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||
|
distribution, then any Derivative Works that You distribute must
|
||
|
include a readable copy of the attribution notices contained
|
||
|
within such NOTICE file, excluding those notices that do not
|
||
|
pertain to any part of the Derivative Works, in at least one
|
||
|
of the following places: within a NOTICE text file distributed
|
||
|
as part of the Derivative Works; within the Source form or
|
||
|
documentation, if provided along with the Derivative Works; or,
|
||
|
within a display generated by the Derivative Works, if and
|
||
|
wherever such third-party notices normally appear. The contents
|
||
|
of the NOTICE file are for informational purposes only and
|
||
|
do not modify the License. You may add Your own attribution
|
||
|
notices within Derivative Works that You distribute, alongside
|
||
|
or as an addendum to the NOTICE text from the Work, provided
|
||
|
that such additional attribution notices cannot be construed
|
||
|
as modifying the License.
|
||
|
|
||
|
You may add Your own copyright statement to Your modifications and
|
||
|
may provide additional or different license terms and conditions
|
||
|
for use, reproduction, or distribution of Your modifications, or
|
||
|
for any such Derivative Works as a whole, provided Your use,
|
||
|
reproduction, and distribution of the Work otherwise complies with
|
||
|
the conditions stated in this License.
|
||
|
|
||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||
|
any Contribution intentionally submitted for inclusion in the Work
|
||
|
by You to the Licensor shall be under the terms and conditions of
|
||
|
this License, without any additional terms or conditions.
|
||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||
|
the terms of any separate license agreement you may have executed
|
||
|
with Licensor regarding such Contributions.
|
||
|
|
||
|
6. Trademarks. This License does not grant permission to use the trade
|
||
|
names, trademarks, service marks, or product names of the Licensor,
|
||
|
except as required for reasonable and customary use in describing the
|
||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||
|
|
||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||
|
agreed to in writing, Licensor provides the Work (and each
|
||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||
|
implied, including, without limitation, any warranties or conditions
|
||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||
|
appropriateness of using or redistributing the Work and assume any
|
||
|
risks associated with Your exercise of permissions under this License.
|
||
|
|
||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||
|
whether in tort (including negligence), contract, or otherwise,
|
||
|
unless required by applicable law (such as deliberate and grossly
|
||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||
|
liable to You for damages, including any direct, indirect, special,
|
||
|
incidental, or consequential damages of any character arising as a
|
||
|
result of this License or out of the use or inability to use the
|
||
|
Work (including but not limited to damages for loss of goodwill,
|
||
|
work stoppage, computer failure or malfunction, or any and all
|
||
|
other commercial damages or losses), even if such Contributor
|
||
|
has been advised of the possibility of such damages.
|
||
|
|
||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||
|
or other liability obligations and/or rights consistent with this
|
||
|
License. However, in accepting such obligations, You may act only
|
||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||
|
of any other Contributor, and only if You agree to indemnify,
|
||
|
defend, and hold each Contributor harmless for any liability
|
||
|
incurred by, or claims asserted against, such Contributor by reason
|
||
|
of your accepting any such warranty or additional liability.
|
||
|
|
||
|
************************************************************
|
||
|
|
||
|
LICENSE #2:
|
||
|
|
||
|
GNU GENERAL PUBLIC LICENSE
|
||
|
Version 2, June 1991
|
||
|
|
||
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||
|
Everyone is permitted to copy and distribute verbatim copies
|
||
|
of this license document, but changing it is not allowed.
|
||
|
|
||
|
Preamble
|
||
|
|
||
|
The licenses for most software are designed to take away your
|
||
|
freedom to share and change it. By contrast, the GNU General Public
|
||
|
License is intended to guarantee your freedom to share and change free
|
||
|
software--to make sure the software is free for all its users. This
|
||
|
General Public License applies to most of the Free Software
|
||
|
Foundation's software and to any other program whose authors commit to
|
||
|
using it. (Some other Free Software Foundation software is covered by
|
||
|
the GNU Lesser General Public License instead.) You can apply it to
|
||
|
your programs, too.
|
||
|
|
||
|
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
|
||
|
this service 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.
|
||
|
|
||
|
To protect your rights, we need to make restrictions that forbid
|
||
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||
|
These restrictions translate to certain responsibilities for you if you
|
||
|
distribute copies of the software, or if you modify it.
|
||
|
|
||
|
For example, if you distribute copies of such a program, whether
|
||
|
gratis or for a fee, you must give the recipients all the rights that
|
||
|
you have. You must make sure that they, too, receive or can get the
|
||
|
source code. And you must show them these terms so they know their
|
||
|
rights.
|
||
|
|
||
|
We protect your rights with two steps: (1) copyright the software, and
|
||
|
(2) offer you this license which gives you legal permission to copy,
|
||
|
distribute and/or modify the software.
|
||
|
|
||
|
Also, for each author's protection and ours, we want to make certain
|
||
|
that everyone understands that there is no warranty for this free
|
||
|
software. If the software is modified by someone else and passed on, we
|
||
|
want its recipients to know that what they have is not the original, so
|
||
|
that any problems introduced by others will not reflect on the original
|
||
|
authors' reputations.
|
||
|
|
||
|
Finally, any free program is threatened constantly by software
|
||
|
patents. We wish to avoid the danger that redistributors of a free
|
||
|
program will individually obtain patent licenses, in effect making the
|
||
|
program proprietary. To prevent this, we have made it clear that any
|
||
|
patent must be licensed for everyone's free use or not licensed at all.
|
||
|
|
||
|
The precise terms and conditions for copying, distribution and
|
||
|
modification follow.
|
||
|
|
||
|
GNU GENERAL PUBLIC LICENSE
|
||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||
|
|
||
|
0. This License applies to any program or other work which contains
|
||
|
a notice placed by the copyright holder saying it may be distributed
|
||
|
under the terms of this General Public License. The "Program", below,
|
||
|
refers to any such program or work, and a "work based on the Program"
|
||
|
means either the Program or any derivative work under copyright law:
|
||
|
that is to say, a work containing the Program or a portion of it,
|
||
|
either verbatim or with modifications and/or translated into another
|
||
|
language. (Hereinafter, translation is included without limitation in
|
||
|
the term "modification".) Each licensee is addressed as "you".
|
||
|
|
||
|
Activities other than copying, distribution and modification are not
|
||
|
covered by this License; they are outside its scope. The act of
|
||
|
running the Program is not restricted, and the output from the Program
|
||
|
is covered only if its contents constitute a work based on the
|
||
|
Program (independent of having been made by running the Program).
|
||
|
Whether that is true depends on what the Program does.
|
||
|
|
||
|
1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the
|
||
|
notices that refer to this License and to the absence of any warranty;
|
||
|
and give any other recipients of the Program a copy of this License
|
||
|
along with the Program.
|
||
|
|
||
|
You may charge a fee for the physical act of transferring a copy, and
|
||
|
you may at your option offer warranty protection in exchange for a fee.
|
||
|
|
||
|
2. You may modify your copy or copies of the Program or any portion
|
||
|
of it, thus forming a work based on the Program, and copy and
|
||
|
distribute such modifications or work under the terms of Section 1
|
||
|
above, provided that you also meet all of these conditions:
|
||
|
|
||
|
a) You must cause the modified files to carry prominent notices
|
||
|
stating that you changed the files and the date of any change.
|
||
|
|
||
|
b) You must cause any work that you distribute or publish, that in
|
||
|
whole or in part contains or is derived from the Program or any
|
||
|
part thereof, to be licensed as a whole at no charge to all third
|
||
|
parties under the terms of this License.
|
||
|
|
||
|
c) If the modified program normally reads commands interactively
|
||
|
when run, you must cause it, when started running for such
|
||
|
interactive use in the most ordinary way, to print or display an
|
||
|
announcement including an appropriate copyright notice and a
|
||
|
notice that there is no warranty (or else, saying that you provide
|
||
|
a warranty) and that users may redistribute the program under
|
||
|
these conditions, and telling the user how to view a copy of this
|
||
|
License. (Exception: if the Program itself is interactive but
|
||
|
does not normally print such an announcement, your work based on
|
||
|
the Program is not required to print an announcement.)
|
||
|
|
||
|
These requirements apply to the modified work as a whole. If
|
||
|
identifiable sections of that work are not derived from the Program,
|
||
|
and can be reasonably considered independent and separate works in
|
||
|
themselves, then this License, and its terms, do not apply to those
|
||
|
sections when you distribute them as separate works. But when you
|
||
|
distribute the same sections as part of a whole which is a work based
|
||
|
on the Program, the distribution of the whole must be on the terms of
|
||
|
this License, whose permissions for other licensees extend to the
|
||
|
entire whole, and thus to each and every part regardless of who wrote it.
|
||
|
|
||
|
Thus, it is not the intent of this section to claim rights or contest
|
||
|
your rights to work written entirely by you; rather, the intent is to
|
||
|
exercise the right to control the distribution of derivative or
|
||
|
collective works based on the Program.
|
||
|
|
||
|
In addition, mere aggregation of another work not based on the Program
|
||
|
with the Program (or with a work based on the Program) on a volume of
|
||
|
a storage or distribution medium does not bring the other work under
|
||
|
the scope of this License.
|
||
|
|
||
|
3. You may copy and distribute the Program (or a work based on it,
|
||
|
under Section 2) in object code or executable form under the terms of
|
||
|
Sections 1 and 2 above provided that you also do one of the following:
|
||
|
|
||
|
a) Accompany it with the complete corresponding machine-readable
|
||
|
source code, which must be distributed under the terms of Sections
|
||
|
1 and 2 above on a medium customarily used for software interchange; or,
|
||
|
|
||
|
b) Accompany it with a written offer, valid for at least three
|
||
|
years, to give any third party, for a charge no more than your
|
||
|
cost of physically performing source distribution, a complete
|
||
|
machine-readable copy of the corresponding source code, to be
|
||
|
distributed under the terms of Sections 1 and 2 above on a medium
|
||
|
customarily used for software interchange; or,
|
||
|
|
||
|
c) Accompany it with the information you received as to the offer
|
||
|
to distribute corresponding source code. (This alternative is
|
||
|
allowed only for noncommercial distribution and only if you
|
||
|
received the program in object code or executable form with such
|
||
|
an offer, in accord with Subsection b above.)
|
||
|
|
||
|
The source code for a work means the preferred form of the work for
|
||
|
making modifications to it. For an executable work, complete source
|
||
|
code means all the source code for all modules it contains, plus any
|
||
|
associated interface definition files, plus the scripts used to
|
||
|
control compilation and installation of the executable. However, as a
|
||
|
special exception, the source code distributed need not include
|
||
|
anything that is normally distributed (in either source or binary
|
||
|
form) with the major components (compiler, kernel, and so on) of the
|
||
|
operating system on which the executable runs, unless that component
|
||
|
itself accompanies the executable.
|
||
|
|
||
|
If distribution of executable or object code is made by offering
|
||
|
access to copy from a designated place, then offering equivalent
|
||
|
access to copy the source code from the same place counts as
|
||
|
distribution of the source code, even though third parties are not
|
||
|
compelled to copy the source along with the object code.
|
||
|
|
||
|
4. You may not copy, modify, sublicense, or distribute the Program
|
||
|
except as expressly provided under this License. Any attempt
|
||
|
otherwise to copy, modify, sublicense or distribute the Program is
|
||
|
void, and will automatically terminate your rights under this License.
|
||
|
However, parties who have received copies, or rights, from you under
|
||
|
this License will not have their licenses terminated so long as such
|
||
|
parties remain in full compliance.
|
||
|
|
||
|
5. You are not required to accept this License, since you have not
|
||
|
signed it. However, nothing else grants you permission to modify or
|
||
|
distribute the Program or its derivative works. These actions are
|
||
|
prohibited by law if you do not accept this License. Therefore, by
|
||
|
modifying or distributing the Program (or any work based on the
|
||
|
Program), you indicate your acceptance of this License to do so, and
|
||
|
all its terms and conditions for copying, distributing or modifying
|
||
|
the Program or works based on it.
|
||
|
|
||
|
6. Each time you redistribute the Program (or any work based on the
|
||
|
Program), the recipient automatically receives a license from the
|
||
|
original licensor to copy, distribute or modify the Program subject to
|
||
|
these terms and conditions. You may not impose any further
|
||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||
|
You are not responsible for enforcing compliance by third parties to
|
||
|
this License.
|
||
|
|
||
|
7. If, as a consequence of a court judgment or allegation of patent
|
||
|
infringement or for any other reason (not limited to patent issues),
|
||
|
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
|
||
|
distribute so as to satisfy simultaneously your obligations under this
|
||
|
License and any other pertinent obligations, then as a consequence you
|
||
|
may not distribute the Program at all. For example, if a patent
|
||
|
license would not permit royalty-free redistribution of the Program by
|
||
|
all those who receive copies directly or indirectly through you, then
|
||
|
the only way you could satisfy both it and this License would be to
|
||
|
refrain entirely from distribution of the Program.
|
||
|
|
||
|
If any portion of this section is held invalid or unenforceable under
|
||
|
any particular circumstance, the balance of the section is intended to
|
||
|
apply and the section as a whole is intended to apply in other
|
||
|
circumstances.
|
||
|
|
||
|
It is not the purpose of this section to induce you to infringe any
|
||
|
patents or other property right claims or to contest validity of any
|
||
|
such claims; this section has the sole purpose of protecting the
|
||
|
integrity of the free software distribution system, which is
|
||
|
implemented by public license practices. Many people have made
|
||
|
generous contributions to the wide range of software distributed
|
||
|
through that system in reliance on consistent application of that
|
||
|
system; it is up to the author/donor to decide if he or she is willing
|
||
|
to distribute software through any other system and a licensee cannot
|
||
|
impose that choice.
|
||
|
|
||
|
This section is intended to make thoroughly clear what is believed to
|
||
|
be a consequence of the rest of this License.
|
||
|
|
||
|
8. If the distribution and/or use of the Program is restricted in
|
||
|
certain countries either by patents or by copyrighted interfaces, the
|
||
|
original copyright holder who places the Program under this License
|
||
|
may add an explicit geographical distribution limitation excluding
|
||
|
those countries, so that distribution is permitted only in or among
|
||
|
countries not thus excluded. In such case, this License incorporates
|
||
|
the limitation as if written in the body of this License.
|
||
|
|
||
|
9. The Free Software Foundation may publish revised and/or new versions
|
||
|
of the 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 a version number of this License which applies to it and "any
|
||
|
later version", you have the option of following the terms and conditions
|
||
|
either of that version or of any later version published by the Free
|
||
|
Software Foundation. If the Program does not specify a version number of
|
||
|
this License, you may choose any version ever published by the Free Software
|
||
|
Foundation.
|
||
|
|
||
|
10. If you wish to incorporate parts of the Program into other free
|
||
|
programs whose distribution conditions are different, write to the author
|
||
|
to ask for permission. For software which is copyrighted by the Free
|
||
|
Software Foundation, write to the Free Software Foundation; we sometimes
|
||
|
make exceptions for this. Our decision will be guided by the two goals
|
||
|
of preserving the free status of all derivatives of our free software and
|
||
|
of promoting the sharing and reuse of software generally.
|
||
|
|
||
|
NO WARRANTY
|
||
|
|
||
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
|
||
|
|
||
|
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||
|
REDISTRIBUTE 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.
|
||
|
|
||
|
*/
|
||
|
(function(e){"undefined"==typeof e.fn.each2&&e.fn.extend({each2:function(h){for(var n=e([0]),m=-1,w=this.length;++m<w&&(n.context=n[0]=this[m])&&!1!==h.call(n[0],m,n););return this}})})(jQuery);
|
||
|
(function(e,h){function n(a,b){for(var c=0,d=b.length;c<d;c+=1)if(m(a,b[c]))return c;return-1}function m(a,b){return a===b?!0:a===h||b===h||null===a||null===b?!1:a.constructor===String?a===b+"":b.constructor===String?b===a+"":!1}function w(a,b){var c,d,g;if(null===a||1>a.length)return[];c=a.split(b);d=0;for(g=c.length;d<g;d+=1)c[d]=e.trim(c[d]);return c}function D(a){a.bind("keydown",function(){e.data(a,"keyup-change-value")===h&&e.data(a,"keyup-change-value",a.val())});a.bind("keyup",function(){var b=
|
||
|
e.data(a,"keyup-change-value");b!==h&&a.val()!==b&&(e.removeData(a,"keyup-change-value"),a.trigger("keyup-change"))})}function E(a,b,c){c=c||h;var d;return function(){var g=arguments;window.clearTimeout(d);d=window.setTimeout(function(){b.apply(c,g)},a)}}function F(a){a[0]!==document.activeElement&&window.setTimeout(function(){var b=a[0],c=a.val().length;a.focus();b.setSelectionRange?b.setSelectionRange(c,c):b.createTextRange&&(b=b.createTextRange(),b.collapse(!0),b.moveEnd("character",c),b.moveStart("character",
|
||
|
c),b.select())},0)}function k(a){a.preventDefault();a.stopPropagation()}function z(a,b,c){var d,g=[],p;d=a.attr("class");"string"===typeof d&&e(d.split(" ")).each2(function(){0===this.indexOf("select2-")&&g.push(this)});d=b.attr("class");"string"===typeof d&&e(d.split(" ")).each2(function(){0!==this.indexOf("select2-")&&(p=c(this),"string"===typeof p&&0<p.length&&g.push(this))});a.attr("class",g.join(" "))}function G(a,b,c,d){var g=a.toUpperCase().indexOf(b.toUpperCase());b=b.length;0>g?c.push(d(a)):
|
||
|
(c.push(d(a.substring(0,g))),c.push("<span class='select2-match'>"),c.push(d(a.substring(g,g+b))),c.push("</span>"),c.push(d(a.substring(g+b,a.length))))}function H(a){var b,c=0,d=null,g=a.quietMillis||100,p=a.url,l=this;return function(j){window.clearTimeout(b);b=window.setTimeout(function(){var b=c+=1,g=a.data,x=p,h=a.transport||e.ajax,f=a.type||"GET",k={},g=g?g.call(l,j.term,j.page,j.context):null,x="function"===typeof x?x.call(l,j.term,j.page,j.context):x;null!==d&&d.abort();a.params&&(e.isFunction(a.params)?
|
||
|
e.extend(k,a.params.call(l)):e.extend(k,a.params));e.extend(k,{url:x,dataType:a.dataType,data:g,type:f,cache:!1,success:function(d){b<c||(d=a.results(d,j.page),j.callback(d))}});d=h.call(l,k)},g)}}function I(a){var b=a,c,d,g=function(a){return""+a.text};e.isArray(b)&&(d=b,b={results:d});!1===e.isFunction(b)&&(d=b,b=function(){return d});a=b();a.text&&(g=a.text,e.isFunction(g)||(c=b.text,g=function(a){return a[c]}));return function(a){var c=a.term,d={results:[]},h;""===c?a.callback(b()):(h=function(b,
|
||
|
d){var j,f;b=b[0];if(b.children){j={};for(f in b)b.hasOwnProperty(f)&&(j[f]=b[f]);j.children=[];e(b.children).each2(function(a,b){h(b,j.children)});(j.children.length||a.matcher(c,g(j),b))&&d.push(j)}else a.matcher(c,g(b),b)&&d.push(b)},e(b().results).each2(function(a,b){h(b,d.results)}),a.callback(d))}}function J(a){var b=e.isFunction(a);return function(c){var d=c.term,g={results:[]};e(b?a():a).each(function(){var a=this.text!==h,b=a?this.text:this;if(""===d||c.matcher(d,b))g.results.push(a?this:
|
||
|
{id:this,text:this})});c.callback(g)}}function y(a){if(e.isFunction(a))return!0;if(!a)return!1;throw Error("formatterName must be a function or a falsy value");}function r(a){return e.isFunction(a)?a():a}function K(a){var b=0;e.each(a,function(a,d){d.children?b+=K(d.children):b++});return b}function N(a,b,c,d){var g=a,e=!1,l,j,f,q;if(!d.createSearchChoice||!d.tokenSeparators||1>d.tokenSeparators.length)return h;for(;;){e=-1;j=0;for(f=d.tokenSeparators.length;j<f&&!(q=d.tokenSeparators[j],e=a.indexOf(q),
|
||
|
0<=e);j++);if(0>e)break;l=a.substring(0,e);a=a.substring(e+q.length);if(0<l.length&&(l=d.createSearchChoice(l,b),l!==h&&null!==l&&d.id(l)!==h&&null!==d.id(l))){e=!1;j=0;for(f=b.length;j<f;j++)if(m(d.id(l),d.id(b[j]))){e=!0;break}e||c(l)}}if(g!==a)return a}function A(a,b){var c=function(){};c.prototype=new a;c.prototype.constructor=c;c.prototype.parent=a.prototype;c.prototype=e.extend(c.prototype,b);return c}if(window.Select2===h){var f,u,B,C,L,v,M;f={TAB:9,ENTER:13,ESC:27,SPACE:32,LEFT:37,UP:38,RIGHT:39,
|
||
|
DOWN:40,SHIFT:16,CTRL:17,ALT:18,PAGE_UP:33,PAGE_DOWN:34,HOME:36,END:35,BACKSPACE:8,DELETE:46,isArrow:function(a){a=a.which?a.which:a;switch(a){case f.LEFT:case f.RIGHT:case f.UP:case f.DOWN:return!0}return!1},isControl:function(a){switch(a.which){case f.SHIFT:case f.CTRL:case f.ALT:return!0}return a.metaKey?!0:!1},isFunctionKey:function(a){a=a.which?a.which:a;return 112<=a&&123>=a}};u=e(document);var O=1;L=function(){return O++};u.bind("mousemove",function(a){M={x:a.pageX,y:a.pageY}});u=A(Object,
|
||
|
{bind:function(a){var b=this;return function(){a.apply(b,arguments)}},init:function(a){var b,c;this.opts=a=this.prepareOpts(a);this.id=a.id;a.element.data("select2")!==h&&null!==a.element.data("select2")&&this.destroy();this.enabled=!0;this.container=this.createContainer();this.containerId="s2id_"+(a.element.attr("id")||"autogen"+L());this.containerSelector="#"+this.containerId.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\\$1");this.container.attr("id",this.containerId);var d=!1,g;this.body=
|
||
|
function(){!1===d&&(g=a.element.closest("body"),d=!0);return g};z(this.container,this.opts.element,this.opts.adaptContainerCssClass);this.container.css(r(a.containerCss));this.container.addClass(r(a.containerCssClass));this.elementTabIndex=this.opts.element.attr("tabIndex");this.opts.element.data("select2",this).addClass("select2-offscreen").bind("focus.select2",function(){e(this).select2("focus")}).attr("tabIndex","-1").before(this.container);this.container.data("select2",this);this.dropdown=this.container.find(".select2-drop");
|
||
|
this.dropdown.addClass(r(a.dropdownCssClass));this.dropdown.data("select2",this);this.results=b=this.container.find(".select2-results");this.search=c=this.container.find("input.select2-input");c.attr("tabIndex",this.elementTabIndex);this.resultsPage=0;this.context=null;this.initContainer();this.results.bind("mousemove",function(a){var b=M;(b===h||b.x!==a.pageX||b.y!==a.pageY)&&e(a.target).trigger("mousemove-filtered",a)});this.dropdown.delegate(".select2-results","mousemove-filtered touchstart touchmove touchend",
|
||
|
this.bind(this.highlightUnderEvent));var p=this.results,l=E(80,function(a){p.trigger("scroll-debounced",a)});p.bind("scroll",function(a){0<=n(a.target,p.get())&&l(a)});this.dropdown.delegate(".select2-results","scroll-debounced",this.bind(this.loadMoreIfNeeded));e.fn.mousewheel&&b.mousewheel(function(a,c,d,g){c=b.scrollTop();0<g&&0>=c-g?(b.scrollTop(0),k(a)):0>g&&b.get(0).scrollHeight-b.scrollTop()+g<=b.height()&&(b.scrollTop(b.get(0).scrollHeight-b.height()),k(a))});D(c);c.bind("keyup-change input paste",
|
||
|
this.bind(this.updateResults));c.bind("focus",function(){c.addClass("select2-focused")});c.bind("blur",function(){c.removeClass("select2-focused")});this.dropdown.delegate(".select2-results","mouseup",this.bind(function(a){0<e(a.target).closest(".select2-result-selectable").length&&(this.highlightUnderEvent(a),this.selectHighlighted(a))}));this.dropdown.bind("click mouseup mousedown",function(a){a.stopPropagation()});e.isFunction(this.opts.initSelection)&&(this.initSelection(),this.monitorSource());
|
||
|
(a.element.is(":disabled")||a.element.is("[readonly='readonly']"))&&this.disable()},destroy:function(){var a=this.opts.element.data("select2");this.propertyObserver&&(delete this.propertyObserver,this.propertyObserver=null);a!==h&&(a.container.remove(),a.dropdown.remove(),a.opts.element.removeClass("select2-offscreen").removeData("select2").unbind(".select2").attr({tabIndex:this.elementTabIndex}).show())},prepareOpts:function(a){var b,c,d;b=a.element;"select"===b.get(0).tagName.toLowerCase()&&(this.select=
|
||
|
c=a.element);c&&e.each("id multiple ajax query createSearchChoice initSelection data tags".split(" "),function(){if(this in a)throw Error("Option '"+this+"' is not allowed for Select2 when attached to a <select> element.");});a=e.extend({},{populateResults:function(b,c,d){var j,f=this.opts.id,q=this;j=function(b,c,g){var p,k,m,n,r,t,s;b=a.sortResults(b,c,d);p=0;for(k=b.length;p<k;p+=1)m=b[p],r=!0===m.disabled,n=!r&&f(m)!==h,t=m.children&&0<m.children.length,s=e("<li></li>"),s.addClass("select2-results-dept-"+
|
||
|
g),s.addClass("select2-result"),s.addClass(n?"select2-result-selectable":"select2-result-unselectable"),r&&s.addClass("select2-disabled"),t&&s.addClass("select2-result-with-children"),s.addClass(q.opts.formatResultCssClass(m)),n=e(document.createElement("div")),n.addClass("select2-result-label"),r=a.formatResult(m,n,d,q.opts.escapeMarkup),r!==h&&n.html(r),s.append(n),t&&(t=e("<ul></ul>"),t.addClass("select2-result-sub"),j(m.children,t,g+1),s.append(t)),s.data("select2-data",m),c.append(s)};j(c,b,
|
||
|
0)}},e.fn.select2.defaults,a);"function"!==typeof a.id&&(d=a.id,a.id=function(a){return a[d]});if(e.isArray(a.element.data("select2Tags"))){if("tags"in a)throw"tags specified as both an attribute 'data-select2-tags' and in options of Select2 "+a.element.attr("id");a.tags=a.element.attr("data-select2-tags")}if(c)a.query=this.bind(function(a){var c={results:[],more:!1},d=a.term,j,f,q;q=function(b,c){var e;b.is("option")?a.matcher(d,b.text(),b)&&c.push({id:b.attr("value"),text:b.text(),element:b.get(),
|
||
|
css:b.attr("class"),disabled:m(b.attr("disabled"),"disabled")}):b.is("optgroup")&&(e={text:b.attr("label"),children:[],element:b.get(),css:b.attr("class")},b.children().each2(function(a,b){q(b,e.children)}),0<e.children.length&&c.push(e))};j=b.children();this.getPlaceholder()!==h&&0<j.length&&(f=j[0],""===e(f).text()&&(j=j.not(f)));j.each2(function(a,b){q(b,c.results)});a.callback(c)}),a.id=function(a){return a.id},a.formatResultCssClass=function(a){return a.css};else if(!("query"in a))if("ajax"in
|
||
|
a){if((c=a.element.data("ajax-url"))&&0<c.length)a.ajax.url=c;a.query=H.call(a.element,a.ajax)}else"data"in a?a.query=I(a.data):"tags"in a&&(a.query=J(a.tags),a.createSearchChoice===h&&(a.createSearchChoice=function(a){return{id:a,text:a}}),a.initSelection===h&&(a.initSelection=function(b,c){var d=[];e(w(b.val(),a.separator)).each(function(){var b=this,c=this,g=a.tags;e.isFunction(g)&&(g=g());e(g).each(function(){if(m(this.id,b))return c=this.text,!1});d.push({id:b,text:c})});c(d)}));if("function"!==
|
||
|
typeof a.query)throw"query function not defined for Select2 "+a.element.attr("id");return a},monitorSource:function(){var a=this.opts.element,b;a.bind("change.select2",this.bind(function(){!0!==this.opts.element.data("select2-change-triggered")&&this.initSelection()}));b=this.bind(function(){var a,b;a="disabled"!==this.opts.element.attr("disabled");b="readonly"===this.opts.element.attr("readonly");a=a&&!b;this.enabled!==a&&(a?this.enable():this.disable());z(this.container,this.opts.element,this.opts.adaptContainerCssClass);
|
||
|
this.container.addClass(r(this.opts.containerCssClass));z(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass);this.dropdown.addClass(r(this.opts.dropdownCssClass))});a.bind("propertychange.select2 DOMAttrModified.select2",b);"undefined"!==typeof WebKitMutationObserver&&(this.propertyObserver&&(delete this.propertyObserver,this.propertyObserver=null),this.propertyObserver=new WebKitMutationObserver(function(a){a.forEach(b)}),this.propertyObserver.observe(a.get(0),{attributes:!0,subtree:!1}))},
|
||
|
triggerChange:function(a){a=a||{};a=e.extend({},a,{type:"change",val:this.val()});this.opts.element.data("select2-change-triggered",!0);this.opts.element.trigger(a);this.opts.element.data("select2-change-triggered",!1);this.opts.element.click();this.opts.blurOnChange&&this.opts.element.blur()},enable:function(){this.enabled||(this.enabled=!0,this.container.removeClass("select2-container-disabled"),this.opts.element.removeAttr("disabled"))},disable:function(){this.enabled&&(this.close(),this.enabled=
|
||
|
!1,this.container.addClass("select2-container-disabled"),this.opts.element.attr("disabled","disabled"))},opened:function(){return this.container.hasClass("select2-dropdown-open")},positionDropdown:function(){var a=this.container.offset(),b=this.container.outerHeight(!1),c=this.container.outerWidth(!1),d=this.dropdown.outerHeight(!1),g=e(window).scrollLeft()+e(window).width(),p=e(window).scrollTop()+e(window).height(),b=a.top+b,f=a.left,p=b+d<=p,j=a.top-d>=this.body().scrollTop(),h=this.dropdown.outerWidth(!1),
|
||
|
g=f+h<=g,q=this.dropdown.hasClass("select2-drop-above"),k;"static"!==this.body().css("position")&&(k=this.body().offset(),b-=k.top,f-=k.left);q?(q=!0,!j&&p&&(q=!1)):(q=!1,!p&&j&&(q=!0));g||(f=a.left+c-h);q?(b=a.top-d,this.container.addClass("select2-drop-above"),this.dropdown.addClass("select2-drop-above")):(this.container.removeClass("select2-drop-above"),this.dropdown.removeClass("select2-drop-above"));a=e.extend({top:b,left:f,width:c},r(this.opts.dropdownCss));this.dropdown.css(a)},shouldOpen:function(){var a;
|
||
|
if(this.opened())return!1;a=e.Event("opening");this.opts.element.trigger(a);return!a.isDefaultPrevented()},clearDropdownAlignmentPreference:function(){this.container.removeClass("select2-drop-above");this.dropdown.removeClass("select2-drop-above")},open:function(){if(!this.shouldOpen())return!1;window.setTimeout(this.bind(this.opening),1);return!0},opening:function(){var a=this.containerId,b="scroll."+a,c="resize."+a,d="orientationchange."+a;this.clearDropdownAlignmentPreference();this.container.addClass("select2-dropdown-open").addClass("select2-container-active");
|
||
|
this.dropdown[0]!==this.body().children().last()[0]&&this.dropdown.detach().appendTo(this.body());this.updateResults(!0);a=e("#select2-drop-mask");0==a.length&&(a=e(document.createElement("div")),a.attr("id","select2-drop-mask").attr("class","select2-drop-mask"),a.hide(),a.appendTo(this.body()),a.bind("mousedown touchstart",function(){var a=e("#select2-drop");0<a.length&&(a=a.data("select2"),a.opts.selectOnBlur&&a.selectHighlighted({noFocus:!0}),a.close())}));this.dropdown.prev()[0]!==a[0]&&this.dropdown.before(a);
|
||
|
e("#select2-drop").removeAttr("id");this.dropdown.attr("id","select2-drop");a.css({width:document.documentElement.scrollWidth,height:document.documentElement.scrollHeight});a.show();this.dropdown.show();this.positionDropdown();this.dropdown.addClass("select2-drop-active");this.ensureHighlightVisible();var g=this;this.container.parents().add(window).each(function(){e(this).bind(c+" "+b+" "+d,function(){e("#select2-drop-mask").css({width:document.documentElement.scrollWidth,height:document.documentElement.scrollHeight});
|
||
|
g.positionDropdown()})});this.focusSearch()},close:function(){if(this.opened()){var a=this.containerId,b="scroll."+a,c="resize."+a,d="orientationchange."+a;this.container.parents().add(window).each(function(){e(this).unbind(b).unbind(c).unbind(d)});this.clearDropdownAlignmentPreference();e("#select2-drop-mask").hide();this.dropdown.removeAttr("id");this.dropdown.hide();this.container.removeClass("select2-dropdown-open");this.results.empty();this.clearSearch();this.opts.element.trigger(e.Event("close"))}},
|
||
|
clearSearch:function(){},getMaximumSelectionSize:function(){return r(this.opts.maximumSelectionSize)},ensureHighlightVisible:function(){var a=this.results,b,c,d,g;c=this.highlight();0>c||(0==c?a.scrollTop(0):(b=this.findHighlightableChoices(),d=e(b[c]),g=d.offset().top+d.outerHeight(!0),c===b.length-1&&(b=a.find("li.select2-more-results"),0<b.length&&(g=b.offset().top+b.outerHeight(!0))),b=a.offset().top+a.outerHeight(!0),g>b&&a.scrollTop(a.scrollTop()+(g-b)),g=d.offset().top-a.offset().top,0>g&&
|
||
|
"none"!=d.css("display")&&a.scrollTop(a.scrollTop()+g)))},findHighlightableChoices:function(){this.results.find(".select2-result-selectable:not(.select2-selected):not(.select2-disabled)");return this.results.find(".select2-result-selectable:not(.select2-selected):not(.select2-disabled)")},moveHighlight:function(a){for(var b=this.findHighlightableChoices(),c=this.highlight();-1<c&&c<b.length;){var c=c+a,d=e(b[c]);if(d.hasClass("select2-result-selectable")&&!d.hasClass("select2-disabled")&&!d.hasClass("select2-selected")){this.highlight(c);
|
||
|
break}}},highlight:function(a){var b=this.findHighlightableChoices();if(0===arguments.length)return n(b.filter(".select2-highlighted")[0],b.get());a>=b.length&&(a=b.length-1);0>a&&(a=0);this.results.find(".select2-highlighted").removeClass("select2-highlighted");b=e(b[a]);b.addClass("select2-highlighted");this.ensureHighlightVisible();(b=b.data("select2-data"))&&this.opts.element.trigger({type:"highlight",val:this.id(b),choice:b})},countSelectableResults:function(){return this.findHighlightableChoices().length},
|
||
|
highlightUnderEvent:function(a){a=e(a.target).closest(".select2-result-selectable");if(0<a.length&&!a.is(".select2-highlighted")){var b=this.findHighlightableChoices();this.highlight(b.index(a))}else 0==a.length&&this.results.find(".select2-highlighted").removeClass("select2-highlighted")},loadMoreIfNeeded:function(){var a=this.results,b=a.find("li.select2-more-results"),c,d=this.resultsPage+1,g=this,e=this.search.val(),f=this.context;0!==b.length&&(c=b.offset().top-a.offset().top-a.height(),c<=this.opts.loadMorePadding&&
|
||
|
(b.addClass("select2-active"),this.opts.query({element:this.opts.element,term:e,page:d,context:f,matcher:this.opts.matcher,callback:this.bind(function(c){g.opened()&&(g.opts.populateResults.call(this,a,c.results,{term:e,page:d,context:f}),!0===c.more?(b.detach().appendTo(a).text(g.opts.formatLoadMore(d+1)),window.setTimeout(function(){g.loadMoreIfNeeded()},10)):b.remove(),g.positionDropdown(),g.resultsPage=d,g.context=c.context)})})))},tokenize:function(){},updateResults:function(a){function b(){g.scrollTop(0);
|
||
|
d.removeClass("select2-active");j.positionDropdown()}function c(a){g.html(a);b()}var d=this.search,g=this.results,f=this.opts,l,j=this;if(!(!0!==a&&(!1===this.showSearchInput||!this.opened()))){d.addClass("select2-active");var k=this.getMaximumSelectionSize();if(1<=k&&(l=this.data(),e.isArray(l)&&l.length>=k&&y(f.formatSelectionTooBig,"formatSelectionTooBig"))){c("<li class='select2-selection-limit'>"+f.formatSelectionTooBig(k)+"</li>");return}d.val().length<f.minimumInputLength?y(f.formatInputTooShort,
|
||
|
"formatInputTooShort")?c("<li class='select2-no-results'>"+f.formatInputTooShort(d.val(),f.minimumInputLength)+"</li>"):c(""):(f.formatSearching()&&!0===a&&c("<li class='select2-searching'>"+f.formatSearching()+"</li>"),f.maximumInputLength&&d.val().length>f.maximumInputLength?y(f.formatInputTooLong,"formatInputTooLong")?c("<li class='select2-no-results'>"+f.formatInputTooLong(d.val(),f.maximumInputLength)+"</li>"):c(""):(l=this.tokenize(),l!=h&&null!=l&&d.val(l),this.resultsPage=1,f.query({element:f.element,
|
||
|
term:d.val(),page:this.resultsPage,context:null,matcher:f.matcher,callback:this.bind(function(l){var k;this.opened()&&(this.context=l.context===h?null:l.context,this.opts.createSearchChoice&&""!==d.val()&&(k=this.opts.createSearchChoice.call(null,d.val(),l.results),k!==h&&null!==k&&j.id(k)!==h&&null!==j.id(k)&&0===e(l.results).filter(function(){return m(j.id(this),j.id(k))}).length&&l.results.unshift(k)),0===l.results.length&&y(f.formatNoMatches,"formatNoMatches")?c("<li class='select2-no-results'>"+
|
||
|
f.formatNoMatches(d.val())+"</li>"):(g.empty(),j.opts.populateResults.call(this,g,l.results,{term:d.val(),page:this.resultsPage,context:null}),!0===l.more&&y(f.formatLoadMore,"formatLoadMore")&&(g.append("<li class='select2-more-results'>"+j.opts.escapeMarkup(f.formatLoadMore(this.resultsPage))+"</li>"),window.setTimeout(function(){j.loadMoreIfNeeded()},10)),this.postprocessResults(l,a),b()))})})))}},cancel:function(){this.close()},blur:function(){this.opts.selectOnBlur&&this.selectHighlighted({noFocus:!0});
|
||
|
this.close();this.container.removeClass("select2-container-active");this.search[0]===document.activeElement&&this.search.blur();this.clearSearch();this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus")},focusSearch:function(){F(this.search)},selectHighlighted:function(a){var b=this.highlight(),c=this.results.find(".select2-highlighted").closest(".select2-result").data("select2-data");c&&(this.highlight(b),this.onSelect(c,a))},getPlaceholder:function(){return this.opts.element.attr("placeholder")||
|
||
|
this.opts.element.attr("data-placeholder")||this.opts.element.data("placeholder")||this.opts.placeholder},initContainerWidth:function(){var a=function(){var a,c,d,g;if("off"===this.opts.width)return null;if("element"===this.opts.width)return 0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px";if("copy"===this.opts.width||"resolve"===this.opts.width){a=this.opts.element.attr("style");if(a!==h){a=a.split(";");d=0;for(g=a.length;d<g;d+=1)if(c=a[d].replace(/\s/g,"").match(/width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/),
|
||
|
null!==c&&1<=c.length)return c[1]}return"resolve"===this.opts.width?(a=this.opts.element.css("width"),0<a.indexOf("%")?a:0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px"):null}return e.isFunction(this.opts.width)?this.opts.width():this.opts.width}.call(this);null!==a&&this.container.css("width",a)}});B=A(u,{createContainer:function(){return e(document.createElement("div")).attr({"class":"select2-container"}).html("<a href='javascript:void(0)' onclick='return false;' class='select2-choice' tabindex='-1'> <span></span><abbr class='select2-search-choice-close' style='display:none;'></abbr> <div><b></b></div></a><input class='select2-focusser select2-offscreen' type='text'/><div class='select2-drop' style='display:none'> <div class='select2-search'> <input type='text' autocomplete='off' class='select2-input'/> </div> <ul class='select2-results'> </ul></div>")},
|
||
|
disable:function(){this.enabled&&(this.parent.disable.apply(this,arguments),this.focusser.attr("disabled","disabled"))},enable:function(){this.enabled||(this.parent.enable.apply(this,arguments),this.focusser.removeAttr("disabled"))},opening:function(){this.parent.opening.apply(this,arguments);this.focusser.attr("disabled","disabled");this.opts.element.trigger(e.Event("open"))},close:function(){this.opened()&&(this.parent.close.apply(this,arguments),this.focusser.removeAttr("disabled"),F(this.focusser))},
|
||
|
focus:function(){this.opened()?this.close():(this.focusser.removeAttr("disabled"),this.focusser.focus())},isFocused:function(){return this.container.hasClass("select2-container-active")},cancel:function(){this.parent.cancel.apply(this,arguments);this.focusser.removeAttr("disabled");this.focusser.focus()},initContainer:function(){var a,b=this.container,c=this.dropdown;this.showSearch(0<=this.opts.minimumResultsForSearch);this.selection=a=b.find(".select2-choice");this.focusser=b.find(".select2-focusser");
|
||
|
this.search.bind("keydown",this.bind(function(a){if(this.enabled)if(a.which===f.PAGE_UP||a.which===f.PAGE_DOWN)k(a);else switch(a.which){case f.UP:case f.DOWN:this.moveHighlight(a.which===f.UP?-1:1);k(a);break;case f.TAB:case f.ENTER:this.selectHighlighted();k(a);break;case f.ESC:this.cancel(a),k(a)}}));this.focusser.bind("keydown",this.bind(function(a){if(this.enabled&&!(a.which===f.TAB||f.isControl(a)||f.isFunctionKey(a)||a.which===f.ESC))if(!1===this.opts.openOnEnter&&a.which===f.ENTER)k(a);else if(a.which==
|
||
|
f.DOWN||a.which==f.UP||a.which==f.ENTER&&this.opts.openOnEnter)this.open(),k(a);else if(a.which==f.DELETE||a.which==f.BACKSPACE)this.opts.allowClear&&this.clear(),k(a)}));D(this.focusser);this.focusser.bind("keyup-change input",this.bind(function(a){this.opened()||(this.open(),!1!==this.showSearchInput&&this.search.val(this.focusser.val()),this.focusser.val(""),k(a))}));a.delegate("abbr","mousedown",this.bind(function(a){this.enabled&&(this.clear(),a.preventDefault(),a.stopImmediatePropagation(),
|
||
|
this.close(),this.selection.focus())}));a.bind("mousedown",this.bind(function(a){this.opened()?this.close():this.enabled&&this.open();k(a)}));c.bind("mousedown",this.bind(function(){this.search.focus()}));a.bind("focus",this.bind(function(a){k(a)}));this.focusser.bind("focus",this.bind(function(){this.container.addClass("select2-container-active")})).bind("blur",this.bind(function(){this.opened()||this.container.removeClass("select2-container-active")}));this.search.bind("focus",this.bind(function(){this.container.addClass("select2-container-active")}));
|
||
|
this.initContainerWidth();this.setPlaceholder()},clear:function(){var a=this.selection.data("select2-data");this.opts.element.val("");this.selection.find("span").empty();this.selection.removeData("select2-data");this.setPlaceholder();this.opts.element.trigger({type:"removed",val:this.id(a),choice:a});this.triggerChange({removed:a})},initSelection:function(){if(""===this.opts.element.val()&&""===this.opts.element.text())this.close(),this.setPlaceholder();else{var a=this;this.opts.initSelection.call(null,
|
||
|
this.opts.element,function(b){b!==h&&null!==b&&(a.updateSelection(b),a.close(),a.setPlaceholder())})}},prepareOpts:function(){var a=this.parent.prepareOpts.apply(this,arguments);"select"===a.element.get(0).tagName.toLowerCase()?a.initSelection=function(a,c){var d=a.find(":selected");e.isFunction(c)&&c({id:d.attr("value"),text:d.text(),element:d})}:"data"in a&&(a.initSelection=a.initSelection||function(b,c){var d=b.val();a.query({matcher:function(b,c,e){return m(d,a.id(e))},callback:!e.isFunction(c)?
|
||
|
e.noop:function(a){c(a.results.length?a.results[0]:null)}})});return a},getPlaceholder:function(){return this.select&&""!==this.select.find("option").first().text()?h:this.parent.getPlaceholder.apply(this,arguments)},setPlaceholder:function(){var a=this.getPlaceholder();""===this.opts.element.val()&&a!==h&&!(this.select&&""!==this.select.find("option:first").text())&&(this.selection.find("span").html(this.opts.escapeMarkup(a)),this.selection.addClass("select2-default"),this.selection.find("abbr").hide())},
|
||
|
postprocessResults:function(a,b){var c=0,d=this,e=!0;this.findHighlightableChoices().each2(function(a,b){if(m(d.id(b.data("select2-data")),d.opts.element.val()))return c=a,!1});this.highlight(c);!0===b&&(e=this.opts.minimumResultsForSearch,e=0>e?!1:K(a.results)>=e,this.showSearch(e))},showSearch:function(a){this.showSearchInput=a;this.dropdown.find(".select2-search")[a?"removeClass":"addClass"]("select2-search-hidden");e(this.dropdown,this.container)[a?"addClass":"removeClass"]("select2-with-searchbox")},
|
||
|
onSelect:function(a,b){var c=this.opts.element.val();this.opts.element.val(this.id(a));this.updateSelection(a);this.opts.element.trigger({type:"selected",val:this.id(a),choice:a});this.close();(!b||!b.noFocus)&&this.selection.focus();m(c,this.id(a))||this.triggerChange()},updateSelection:function(a){var b=this.selection.find("span");this.selection.data("select2-data",a);b.empty();a=this.opts.formatSelection(a,b);a!==h&&b.append(this.opts.escapeMarkup(a));this.selection.removeClass("select2-default");
|
||
|
this.opts.allowClear&&this.getPlaceholder()!==h&&this.selection.find("abbr").show()},val:function(){var a,b=!1,c=null,d=this;if(0===arguments.length)return this.opts.element.val();a=arguments[0];1<arguments.length&&(b=arguments[1]);if(this.select)this.select.val(a).find(":selected").each2(function(a,b){c={id:b.attr("value"),text:b.text()};return!1}),this.updateSelection(c),this.setPlaceholder(),b&&this.triggerChange();else{if(this.opts.initSelection===h)throw Error("cannot call val() if initSelection() is not defined");
|
||
|
!a&&0!==a?(this.clear(),b&&this.triggerChange()):(this.opts.element.val(a),this.opts.initSelection(this.opts.element,function(a){d.opts.element.val(!a?"":d.id(a));d.updateSelection(a);d.setPlaceholder();b&&d.triggerChange()}))}},clearSearch:function(){this.search.val("");this.focusser.val("")},data:function(a){var b;if(0===arguments.length)return b=this.selection.data("select2-data"),b==h&&(b=null),b;!a||""===a?this.clear():(this.opts.element.val(!a?"":this.id(a)),this.updateSelection(a))}});C=A(u,
|
||
|
{createContainer:function(){return e(document.createElement("div")).attr({"class":"select2-container select2-container-multi"}).html(" <ul class='select2-choices'> <li class='select2-search-field'> <input type='text' autocomplete='off' class='select2-input'> </li></ul><div class='select2-drop select2-drop-multi' style='display:none;'> <ul class='select2-results'> </ul></div>")},prepareOpts:function(){var a=this.parent.prepareOpts.apply(this,arguments);"select"===a.element.get(0).tagName.toLowerCase()?
|
||
|
a.initSelection=function(a,c){var d=[];a.find(":selected").each2(function(a,b){d.push({id:b.attr("value"),text:b.text(),element:b[0]})});c(d)}:"data"in a&&(a.initSelection=a.initSelection||function(b,c){var d=w(b.val(),a.separator);a.query({matcher:function(b,c,f){return e.grep(d,function(b){return m(b,a.id(f))}).length},callback:!e.isFunction(c)?e.noop:function(a){c(a.results)}})});return a},initContainer:function(){var a;this.searchContainer=this.container.find(".select2-search-field");this.selection=
|
||
|
a=this.container.find(".select2-choices");this.search.bind("input paste",this.bind(function(){this.enabled&&(this.opened()||this.open())}));this.search.bind("keydown",this.bind(function(b){if(this.enabled){if(b.which===f.BACKSPACE&&""===this.search.val()){this.close();var c;c=a.find(".select2-search-choice-focus");if(0<c.length){this.unselect(c.first());this.search.width(10);k(b);return}c=a.find(".select2-search-choice:not(.select2-locked)");0<c.length&&c.last().addClass("select2-search-choice-focus")}else a.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");
|
||
|
if(this.opened())switch(b.which){case f.UP:case f.DOWN:this.moveHighlight(b.which===f.UP?-1:1);k(b);return;case f.ENTER:case f.TAB:this.selectHighlighted();k(b);return;case f.ESC:this.cancel(b);k(b);return}b.which===f.TAB||f.isControl(b)||f.isFunctionKey(b)||b.which===f.BACKSPACE||b.which===f.ESC||b.which===f.ENTER&&(!1===this.opts.openOnEnter||b.altKey||b.ctrlKey||b.shiftKey||b.metaKey)||(this.open(),(b.which===f.PAGE_UP||b.which===f.PAGE_DOWN)&&k(b))}}));this.search.bind("keyup",this.bind(this.resizeSearch));
|
||
|
this.search.bind("blur",this.bind(function(a){this.container.removeClass("select2-container-active");this.search.removeClass("select2-focused");this.opened()||this.clearSearch();a.stopImmediatePropagation()}));this.container.delegate(".select2-choices","mousedown",this.bind(function(a){this.enabled&&!(0<e(a.target).closest(".select2-search-choice").length)&&(this.clearPlaceholder(),this.open(),this.focusSearch(),a.preventDefault())}));this.container.delegate(".select2-choices","focus",this.bind(function(){this.enabled&&
|
||
|
(this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"),this.clearPlaceholder())}));this.initContainerWidth();this.clearSearch()},enable:function(){this.enabled||(this.parent.enable.apply(this,arguments),this.search.removeAttr("disabled"))},disable:function(){this.enabled&&(this.parent.disable.apply(this,arguments),this.search.attr("disabled",!0))},initSelection:function(){""===this.opts.element.val()&&""===this.opts.element.text()&&(this.updateSelection([]),
|
||
|
this.close(),this.clearSearch());if(this.select||""!==this.opts.element.val()){var a=this;this.opts.initSelection.call(null,this.opts.element,function(b){b!==h&&null!==b&&(a.updateSelection(b),a.close(),a.clearSearch())})}},clearSearch:function(){var a=this.getPlaceholder();a!==h&&0===this.getVal().length&&!1===this.search.hasClass("select2-focused")?(this.search.val(a).addClass("select2-default"),this.resizeSearch()):this.search.val("").width(10)},clearPlaceholder:function(){this.search.hasClass("select2-default")&&
|
||
|
this.search.val("").removeClass("select2-default")},opening:function(){this.parent.opening.apply(this,arguments);this.clearPlaceholder();this.resizeSearch();this.focusSearch();this.opts.element.trigger(e.Event("open"))},close:function(){this.opened()&&this.parent.close.apply(this,arguments)},focus:function(){this.close();this.search.focus();this.opts.element.triggerHandler("focus")},isFocused:function(){return this.search.hasClass("select2-focused")},updateSelection:function(a){var b=[],c=[],d=this;
|
||
|
e(a).each(function(){0>n(d.id(this),b)&&(b.push(d.id(this)),c.push(this))});a=c;this.selection.find(".select2-search-choice").remove();e(a).each(function(){d.addSelectedChoice(this)});d.postprocessResults()},tokenize:function(){var a=this.search.val(),a=this.opts.tokenizer(a,this.data(),this.bind(this.onSelect),this.opts);null!=a&&a!=h&&(this.search.val(a),0<a.length&&this.open())},onSelect:function(a,b){this.addSelectedChoice(a);this.opts.element.trigger({type:"selected",val:this.id(a),choice:a});
|
||
|
(this.select||!this.opts.closeOnSelect)&&this.postprocessResults();this.opts.closeOnSelect?(this.close(),this.search.width(10)):0<this.countSelectableResults()?(this.search.width(10),this.resizeSearch(),this.val().length>=this.getMaximumSelectionSize()&&this.updateResults(!0),this.positionDropdown()):(this.close(),this.search.width(10));this.triggerChange({added:a});(!b||!b.noFocus)&&this.focusSearch()},cancel:function(){this.close();this.focusSearch()},addSelectedChoice:function(a){var b=!a.locked,
|
||
|
c=e("<li class='select2-search-choice'> <div></div> <a href='#' onclick='return false;' class='select2-search-choice-close' tabindex='-1'></a></li>"),d=e("<li class='select2-search-choice select2-locked'><div></div></li>"),c=b?c:d,d=this.id(a),g=this.getVal(),f;f=this.opts.formatSelection(a,c.find("div"));f!=h&&c.find("div").replaceWith("<div>"+this.opts.escapeMarkup(f)+"</div>");b&&c.find(".select2-search-choice-close").bind("mousedown",k).bind("click dblclick",this.bind(function(a){this.enabled&&
|
||
|
(e(a.target).closest(".select2-search-choice").fadeOut("fast",this.bind(function(){this.unselect(e(a.target));this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");this.close();this.focusSearch()})).dequeue(),k(a))})).bind("focus",this.bind(function(){this.enabled&&(this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"))}));c.data("select2-data",a);c.insertBefore(this.searchContainer);g.push(d);this.setVal(g)},unselect:function(a){var b=
|
||
|
this.getVal(),c,d;a=a.closest(".select2-search-choice");if(0===a.length)throw"Invalid argument: "+a+". Must be .select2-search-choice";if(c=a.data("select2-data"))d=n(this.id(c),b),0<=d&&(b.splice(d,1),this.setVal(b),this.select&&this.postprocessResults()),a.remove(),this.opts.element.trigger({type:"removed",val:this.id(c),choice:c}),this.triggerChange({removed:c})},postprocessResults:function(){var a=this.getVal(),b=this.results.find(".select2-result"),c=this.results.find(".select2-result-with-children"),
|
||
|
d=this;b.each2(function(b,c){var e=d.id(c.data("select2-data"));0<=n(e,a)&&(c.addClass("select2-selected"),c.find(".select2-result-selectable").addClass("select2-selected"))});c.each2(function(a,b){!b.is(".select2-result-selectable")&&0===b.find(".select2-result-selectable:not(.select2-selected)").length&&b.addClass("select2-selected")});-1==this.highlight()&&d.highlight(0)},resizeSearch:function(){var a,b,c,d,f=this.search.outerWidth(!1)-this.search.width();a=this.search;v||(c=a[0].currentStyle||
|
||
|
window.getComputedStyle(a[0],null),v=e(document.createElement("div")).css({position:"absolute",left:"-10000px",top:"-10000px",display:"none",fontSize:c.fontSize,fontFamily:c.fontFamily,fontStyle:c.fontStyle,fontWeight:c.fontWeight,letterSpacing:c.letterSpacing,textTransform:c.textTransform,whiteSpace:"nowrap"}),v.attr("class","select2-sizer"),e("body").append(v));v.text(a.val());a=v.width()+10;b=this.search.offset().left;c=this.selection.width();d=this.selection.offset().left;b=c-(b-d)-f;b<a&&(b=
|
||
|
c-f);40>b&&(b=c-f);0>=b&&(b=a);this.search.width(b)},getVal:function(){var a;if(this.select)return a=this.select.val(),null===a?[]:a;a=this.opts.element.val();return w(a,this.opts.separator)},setVal:function(a){var b;this.select?this.select.val(a):(b=[],e(a).each(function(){0>n(this,b)&&b.push(this)}),this.opts.element.val(0===b.length?"":b.join(this.opts.separator)))},val:function(){var a,b=!1,c=this;if(0===arguments.length)return this.getVal();a=arguments[0];1<arguments.length&&(b=arguments[1]);
|
||
|
if(!a&&0!==a)this.opts.element.val(""),this.updateSelection([]),this.clearSearch(),b&&this.triggerChange();else{this.setVal(a);if(this.select)this.opts.initSelection(this.select,this.bind(this.updateSelection)),b&&this.triggerChange();else{if(this.opts.initSelection===h)throw Error("val() cannot be called if initSelection() is not defined");this.opts.initSelection(this.opts.element,function(a){var f=e(a).map(c.id);c.setVal(f);c.updateSelection(a);c.clearSearch();b&&c.triggerChange()})}this.clearSearch()}},
|
||
|
onSortStart:function(){if(this.select)throw Error("Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.");this.search.width(0);this.searchContainer.hide()},onSortEnd:function(){var a=[],b=this;this.searchContainer.show();this.searchContainer.appendTo(this.searchContainer.parent());this.resizeSearch();this.selection.find(".select2-search-choice").each(function(){a.push(b.opts.id(e(this).data("select2-data")))});this.setVal(a);this.triggerChange()},
|
||
|
data:function(a){var b=this,c;if(0===arguments.length)return this.selection.find(".select2-search-choice").map(function(){return e(this).data("select2-data")}).get();a||(a=[]);c=e.map(a,function(a){return b.opts.id(a)});this.setVal(c);this.updateSelection(a);this.clearSearch()}});e.fn.select2=function(){var a=Array.prototype.slice.call(arguments,0),b,c,d,f,k="val destroy opened open close focus isFocused container onSortStart onSortEnd enable disable positionDropdown data".split(" ");this.each(function(){if(0===
|
||
|
a.length||"object"===typeof a[0])b=0===a.length?{}:e.extend({},a[0]),b.element=e(this),"select"===b.element.get(0).tagName.toLowerCase()?f=b.element.attr("multiple"):(f=b.multiple||!1,"tags"in b&&(b.multiple=f=!0)),c=f?new C:new B,c.init(b);else if("string"===typeof a[0]){if(0>n(a[0],k))throw"Unknown method: "+a[0];d=h;c=e(this).data("select2");if(c!==h&&(d="container"===a[0]?c.container:c[a[0]].apply(c,a.slice(1)),d!==h))return!1}else throw"Invalid arguments to select2 plugin: "+a;});return d===
|
||
|
h?this:d};e.fn.select2.defaults={width:"copy",loadMorePadding:0,closeOnSelect:!0,openOnEnter:!0,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(a,b,c,d){b=[];G(a.text,c.term,b,d);return b.join("")},formatSelection:function(a){return a?a.text:h},sortResults:function(a){return a},formatResultCssClass:function(){return h},formatNoMatches:function(){return"No matches found"},formatInputTooShort:function(a,b){var c=b-a.length;return"Please enter "+c+" more character"+
|
||
|
(1==c?"":"s")},formatInputTooLong:function(a,b){var c=a.length-b;return"Please enter "+c+" less character"+(1==c?"":"s")},formatSelectionTooBig:function(a){return"You can only select "+a+" item"+(1==a?"":"s")},formatLoadMore:function(){return"Loading more results..."},formatSearching:function(){return"Searching..."},minimumResultsForSearch:0,minimumInputLength:0,maximumInputLength:null,maximumSelectionSize:0,id:function(a){return a.id},matcher:function(a,b){return 0<=b.toUpperCase().indexOf(a.toUpperCase())},
|
||
|
separator:",",tokenSeparators:[],tokenizer:N,escapeMarkup:function(a){var b={"\\":"\","&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return String(a).replace(/[&<>"'/\\]/g,function(a){return b[a[0]]})},blurOnChange:!1,selectOnBlur:!1,adaptContainerCssClass:function(a){return a},adaptDropdownCssClass:function(){return null}};window.Select2={query:{ajax:H,local:I,tags:J},util:{debounce:E,markMatch:G},"class":{"abstract":u,single:B,multi:C}}}})(jQuery);
|