1
0
mirror of synced 2024-11-25 06:16:08 +03:00
select2/select2-3.3.0/select2.min.js
2013-02-05 18:41:52 -08:00

561 lines
63 KiB
JavaScript
Executable File

/*
Copyright 2012 Igor Vaynberg
Version: 3.3.0 Timestamp: Tue Feb 5 18:33:54 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(f){"undefined"==typeof f.fn.each2&&f.fn.extend({each2:function(g){for(var j=f([0]),m=-1,v=this.length;++m<v&&(j.context=j[0]=this[m])&&!1!==g.call(j[0],m,j););return this}})})(jQuery);
(function(f,g){function j(a,b){for(var c=0,d=b.length;c<d;c+=1)if(a===b[c])return c;return-1}function m(a,b){return a===b}function v(a,b){var c,d,h;if(null===a||1>a.length)return[];c=a.split(b);d=0;for(h=c.length;d<h;d+=1)c[d]=f.trim(c[d]);return c}function C(a,b,c){c=c||g;var d;return function(){var h=arguments;window.clearTimeout(d);d=window.setTimeout(function(){b.apply(c,h)},a)}}function n(a){a.preventDefault();a.stopPropagation()}function D(a,b,c,d){var h=a.toUpperCase().indexOf(b.toUpperCase());
b=b.length;0>h?c.push(d(a)):(c.push(d(a.substring(0,h))),c.push("<span class='select2-match'>"),c.push(d(a.substring(h,h+b))),c.push("</span>"),c.push(d(a.substring(h+b,a.length))))}function E(a){var b,c=0,d=null,h=a.quietMillis||100;return function(q){window.clearTimeout(b);b=window.setTimeout(function(){var b=c+=1,h=a.data,l=a.url,p=a.transport||f.ajax,e=a.traditional||!1,g=a.type||"GET",h=h?h.call(this,q.term,q.page,q.context):null,l="function"===typeof l?l.call(this,q.term,q.page,q.context):l;
null!==d&&d.abort();d=p.call(null,{url:l,dataType:a.dataType,data:h,type:g,traditional:e,success:function(d){b<c||(d=a.results(d,q.page),q.callback(d))}})},h)}}function F(a){var b=a,c,d=function(a){return""+a.text};f.isArray(b)||(d=b.text,f.isFunction(d)||(c=b.text,d=function(a){return a[c]}),b=b.results);return function(a){var c=a.term,k={results:[]},e;""===c?a.callback({results:b}):(e=function(b,k){var g,x;b=b[0];if(b.children){g={};for(x in b)b.hasOwnProperty(x)&&(g[x]=b[x]);g.children=[];f(b.children).each2(function(a,
b){e(b,g.children)});(g.children.length||a.matcher(c,d(g),b))&&k.push(g)}else a.matcher(c,d(b),b)&&k.push(b)},f(b).each2(function(a,b){e(b,k.results)}),a.callback(k))}}function G(a){var b=f.isFunction(a);return function(c){var d=c.term,h={results:[]};f(b?a():a).each(function(){var a=this.text!==g,b=a?this.text:this;if(""===d||c.matcher(d,b))h.results.push(a?this:{id:this,text:this})});c.callback(h)}}function w(a){if(f.isFunction(a))return!0;if(!a)return!1;throw Error("formatterName must be a function or a falsy value");
}function y(a){return f.isFunction(a)?a():a}function H(a){var b=0;f.each(a,function(a,d){d.children?b+=H(d.children):b++});return b}function L(a,b,c,d){var h=a,f=!1,k,e,l,p;if(!d.createSearchChoice||!d.tokenSeparators||1>d.tokenSeparators.length)return g;for(;;){f=-1;e=0;for(l=d.tokenSeparators.length;e<l&&!(p=d.tokenSeparators[e],f=a.indexOf(p),0<=f);e++);if(0>f)break;k=a.substring(0,f);a=a.substring(f+p.length);if(0<k.length&&(k=d.createSearchChoice(k,b),k!==g&&null!==k&&d.id(k)!==g&&null!==d.id(k))){f=
!1;e=0;for(l=b.length;e<l;e++)if(m(d.id(k),d.id(b[e]))){f=!0;break}f||c(k)}}if(h!==a)return a}function z(a,b){var c=function(){};c.prototype=new a;c.prototype.constructor=c;c.prototype.parent=a.prototype;c.prototype=f.extend(c.prototype,b);return c}if(window.Select2===g){var e,r,A,B,I,u,J;e={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 e.LEFT:case e.RIGHT:case e.UP:case e.DOWN:return!0}return!1},
isControl:function(a){switch(a.which){case e.SHIFT:case e.CTRL:case e.ALT:return!0}return a.metaKey?!0:!1},isFunctionKey:function(a){a=a.which?a.which:a;return 112<=a&&123>=a}};r=f(document);var M=1;I=function(){return M++};r.bind("mousemove",function(a){J={x:a.pageX,y:a.pageY}});r=z(Object,{bind:function(a){var b=this;return function(){a.apply(b,arguments)}},init:function(a){var b,c,d;this.opts=a=this.prepareOpts(a);this.id=a.id;a.element.data("select2")!==g&&null!==a.element.data("select2")&&this.destroy();
this.enabled=!0;this.container=this.createContainer();this.containerId="s2id_"+(a.element.attr("id")||"autogen"+I());this.containerSelector="#"+this.containerId.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\\$1");this.container.attr("id",this.containerId);var h=!1,q;this.body=function(){!1===h&&(q=a.element.closest("body"),h=!0);return q};d=f("#select2-drop-mask");0==d.length&&(d=f(document.createElement("div")),d.attr("id","select2-drop-mask").attr("class","select2-drop-mask"),d.hide(),d.appendTo(this.body()),
d.bind("mousedown touchstart",function(){var a=f("#select2-drop");0<a.length&&(a=a.data("select2"),a.opts.selectOnBlur&&a.selectHighlighted({noFocus:!0}),a.close())}));a.element.attr("class")!==g&&this.container.addClass(a.element.attr("class").replace(/validate\[[\S ]+] ?/,""));this.container.css(y(a.containerCss));this.container.addClass(y(a.containerCssClass));this.elementTabIndex=this.opts.element.attr("tabIndex");this.opts.element.data("select2",this).addClass("select2-offscreen").bind("focus.select2",
function(){f(this).select2("focus")}).attr("tabIndex","-1").before(this.container);this.container.data("select2",this);this.dropdown=this.container.find(".select2-drop");this.dropdown.addClass(y(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.initContainerWidth();this.results.bind("mousemove",
function(a){var b=J;(b===g||b.x!==a.pageX||b.y!==a.pageY)&&f(a.target).trigger("mousemove-filtered",a)});this.dropdown.delegate(".select2-results","mousemove-filtered",this.bind(this.highlightUnderEvent));var e=this.results,K=C(80,function(a){e.trigger("scroll-debounced",a)});e.bind("scroll",function(a){0<=j(a.target,e.get())&&K(a)});this.dropdown.delegate(".select2-results","scroll-debounced",this.bind(this.loadMoreIfNeeded));f.fn.mousewheel&&b.mousewheel(function(a,c,d,h){c=b.scrollTop();0<h&&0>=
c-h?(b.scrollTop(0),n(a)):0>h&&b.get(0).scrollHeight-b.scrollTop()+h<=b.height()&&(b.scrollTop(b.get(0).scrollHeight-b.height()),n(a))});c.bind("keydown",function(){f.data(c,"keyup-change-value")===g&&f.data(c,"keyup-change-value",c.val())});c.bind("keyup",function(){var a=f.data(c,"keyup-change-value");a!==g&&c.val()!==a&&(f.removeData(c,"keyup-change-value"),c.trigger("keyup-change"))});c.bind("keyup-change",this.bind(this.updateResults));c.bind("focus",function(){c.addClass("select2-focused");
" "===c.val()&&c.val("")});c.bind("blur",function(){c.removeClass("select2-focused")});this.dropdown.delegate(".select2-results","mouseup",this.bind(function(a){0<f(a.target).closest(".select2-result-selectable").length?(this.highlightUnderEvent(a),this.selectHighlighted(a)):this.focusSearch();n(a)}));this.dropdown.bind("click mouseup mousedown",function(a){a.stopPropagation()});f.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!==g&&(a.container.remove(),a.dropdown.remove(),a.opts.element.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&&f.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=f.extend({},{populateResults:function(b,c,d){var e,l=this.opts.id,p=this;e=function(b,c,h){var q,n,j,m,r,t,s;b=a.sortResults(b,c,d);q=0;for(n=b.length;q<n;q+=1)j=b[q],r=!0===j.disabled,m=!r&&l(j)!==g,t=j.children&&0<j.children.length,s=f("<li></li>"),s.addClass("select2-results-dept-"+h),s.addClass("select2-result"),s.addClass(m?"select2-result-selectable":"select2-result-unselectable"),
r&&s.addClass("select2-disabled"),t&&s.addClass("select2-result-with-children"),s.addClass(p.opts.formatResultCssClass(j)),m=f(document.createElement("div")),m.addClass("select2-result-label"),r=a.formatResult(j,m,d,p.opts.escapeMarkup),r!==g&&m.html(r),s.append(m),t&&(t=f("<ul></ul>"),t.addClass("select2-result-sub"),e(j.children,t,h+1),s.append(t)),s.data("select2-data",j),c.append(s)};e(c,b,0)}},f.fn.select2.defaults,a);"function"!==typeof a.id&&(d=a.id,a.id=function(a){return a[d]});if(f.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,e,l,p;p=function(b,c){var f;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")&&(f={text:b.attr("label"),children:[],element:b.get(),css:b.attr("class")},
b.children().each2(function(a,b){p(b,f.children)}),0<f.children.length&&c.push(f))};e=b.children();this.getPlaceholder()!==g&&0<e.length&&(l=e[0],""===f(l).text()&&(e=e.not(l)));e.each2(function(a,b){p(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=E(a.ajax)}else"data"in a?a.query=F(a.data):"tags"in a&&(a.query=G(a.tags),a.createSearchChoice===
g&&(a.createSearchChoice=function(a){return{id:a,text:a}}),a.initSelection=function(b,c){var d=[];f(v(b.val(),a.separator)).each(function(){var b=this,c=this,h=a.tags;f.isFunction(h)&&(h=h());f(h).each(function(){if(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="disabled"!==this.opts.element.attr("disabled"),b="readonly"===this.opts.element.attr("readonly"),a=a&&!b;this.enabled!==a&&(a?this.enable():this.disable())});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=f.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),h=f(window).scrollLeft()+document.documentElement.clientWidth,e=f(window).scrollTop()+document.documentElement.clientHeight,b=a.top+b,g=a.left,
e=b+d<=e,j=a.top-d>=this.body().scrollTop(),l=this.dropdown.outerWidth(!1),h=g+l<=h,p=this.dropdown.hasClass("select2-drop-above"),m;"static"!==this.body().css("position")&&(m=this.body().offset(),b-=m.top,g-=m.left);p?(p=!0,!j&&e&&(p=!1)):(p=!1,!e&&j&&(p=!0));h||(g=a.left+c-l);p?(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=f.extend({top:b,
left:g,width:c},y(this.opts.dropdownCss));this.dropdown.css(a)},shouldOpen:function(){var a;if(this.opened())return!1;a=f.Event("open");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.search.val()&&this.search.val("");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=f("#select2-drop-mask");this.dropdown.prev()[0]!==a[0]&&this.dropdown.before(a);f("#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();this.container.parents().add(window).each(function(){f(this).bind(c+" "+b+" "+d,function(){f("#select2-drop-mask").css({width:document.documentElement.scrollWidth,height:document.documentElement.scrollHeight});f("#select2-drop").data("select2").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(){f(this).unbind(b).unbind(c).unbind(d)});this.clearDropdownAlignmentPreference();f("#select2-drop-mask").hide();this.dropdown.removeAttr("id");this.dropdown.hide();this.container.removeClass("select2-dropdown-open").removeClass("select2-container-active");this.results.empty();this.clearSearch();this.opts.element.trigger(f.Event("close"))}},clearSearch:function(){},ensureHighlightVisible:function(){var a=
this.results,b,c,d,h;c=this.highlight();0>c||(0==c?a.scrollTop(0):(b=this.findHighlightableChoices(),d=f(b[c]),h=d.offset().top+d.outerHeight(!0),c===b.length-1&&(b=a.find("li.select2-more-results"),0<b.length&&(h=b.offset().top+b.outerHeight(!0))),b=a.offset().top+a.outerHeight(!0),h>b&&a.scrollTop(a.scrollTop()+(h-b)),h=d.offset().top-a.offset().top,0>h&&"none"!=d.css("display")&&a.scrollTop(a.scrollTop()+h)))},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=f(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 j(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");f(b[a]).addClass("select2-highlighted");this.ensureHighlightVisible()},countSelectableResults:function(){return this.findHighlightableChoices().length},highlightUnderEvent:function(a){a=f(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,f=this,e=this.search.val(),g=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({term:e,page:d,context:g,matcher:this.opts.matcher,callback:this.bind(function(c){f.opened()&&(f.opts.populateResults.call(this,a,c.results,{term:e,page:d,context:g}),!0===c.more?(b.detach().appendTo(a).text(f.opts.formatLoadMore(d+
1)),window.setTimeout(function(){f.loadMoreIfNeeded()},10)):b.remove(),f.positionDropdown(),f.resultsPage=d)})})))},tokenize:function(){},updateResults:function(a){function b(){h.scrollTop(0);d.removeClass("select2-active");j.positionDropdown()}function c(a){h.html(a);b()}var d=this.search,h=this.results,e=this.opts,k,j=this;if(!(!0!==a&&(!1===this.showSearchInput||!this.opened()))){d.addClass("select2-active");var l=f.isFunction(e.maximumSelectionSize)?e.maximumSelectionSize():e.maximumSelectionSize;
if(1<=l&&(k=this.data(),f.isArray(k)&&k.length>=l&&w(e.formatSelectionTooBig,"formatSelectionTooBig"))){c("<li class='select2-selection-limit'>"+e.formatSelectionTooBig(l)+"</li>");return}d.val().length<e.minimumInputLength?w(e.formatInputTooShort,"formatInputTooShort")?c("<li class='select2-no-results'>"+e.formatInputTooShort(d.val(),e.minimumInputLength)+"</li>"):c(""):(e.formatSearching()&&!0===a&&c("<li class='select2-searching'>"+e.formatSearching()+"</li>"),e.maximumInputLength&&d.val().length>
e.maximumInputLength?w(e.formatInputTooLong,"formatInputTooLong")?c("<li class='select2-no-results'>"+e.formatInputTooLong(d.val(),e.maximumInputLength)+"</li>"):c(""):(k=this.tokenize(),k!=g&&null!=k&&d.val(k),this.resultsPage=1,e.query({term:d.val(),page:this.resultsPage,context:null,matcher:e.matcher,callback:this.bind(function(k){var l;this.opened()&&(this.context=k.context===g?null:k.context,this.opts.createSearchChoice&&""!==d.val()&&(l=this.opts.createSearchChoice.call(null,d.val(),k.results),
l!==g&&null!==l&&j.id(l)!==g&&null!==j.id(l)&&0===f(k.results).filter(function(){return m(j.id(this),j.id(l))}).length&&k.results.unshift(l)),0===k.results.length&&w(e.formatNoMatches,"formatNoMatches")?c("<li class='select2-no-results'>"+e.formatNoMatches(d.val())+"</li>"):(h.empty(),j.opts.populateResults.call(this,h,k.results,{term:d.val(),page:this.resultsPage,context:null}),!0===k.more&&w(e.formatLoadMore,"formatLoadMore")&&(h.append("<li class='select2-more-results'>"+j.opts.escapeMarkup(e.formatLoadMore(this.resultsPage))+
"</li>"),window.setTimeout(function(){j.loadMoreIfNeeded()},10)),this.postprocessResults(k,a),b()))})})))}},cancel:function(){this.close()},blur:function(){this.opts.selectOnBlur&&this.selectHighlighted({noFocus:!0});this.close();this.container.removeClass("select2-container-active");this.dropdown.removeClass("select2-drop-active");this.search[0]===document.activeElement&&this.search.blur();this.clearSearch();this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");
this.opts.element.triggerHandler("blur")},focusSearch:function(){this.search.show();this.search.focus();window.setTimeout(this.bind(function(){this.search.show();this.search.focus();this.search.val(this.search.val())}),10)},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.select&&""!==this.select.find("option").first().text()?
g: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,e;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!==g){a=a.split(";");d=0;for(e=a.length;d<
e;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 f.isFunction(this.opts.width)?this.opts.width():this.opts.width}.call(this);null!==a&&this.container.attr("style","width: "+a)}});A=z(r,{createContainer:function(){return f(document.createElement("div")).attr({"class":"select2-container"}).html(" <a href='javascript:void(0)' onclick='return false;' class='select2-choice'> <span></span><abbr class='select2-search-choice-close' style='display:none;'></abbr> <div><b></b></div></a> <div class='select2-drop select2-offscreen'> <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.selection.attr("tabIndex","-1"),this.search.attr("tabIndex","-1"))},enable:function(){this.enabled||(this.parent.enable.apply(this,arguments),this.elementTabIndex?this.selection.attr("tabIndex",this.elementTabIndex):this.selection.removeAttr("tabIndex"),this.search.removeAttr("tabIndex"))},opening:function(){this.search.show();this.parent.opening.apply(this,arguments);this.dropdown.removeClass("select2-offscreen")},close:function(){this.opened()&&
(this.parent.close.apply(this,arguments),this.dropdown.removeAttr("style").addClass("select2-offscreen").insertAfter(this.selection).show())},focus:function(){this.close();this.selection.focus();this.opts.element.triggerHandler("focus")},isFocused:function(){return this.selection[0]===document.activeElement},cancel:function(){this.parent.cancel.apply(this,arguments);this.selection.focus()},initContainer:function(){var a,b=this.dropdown;this.selection=a=this.container.find(".select2-choice");this.search.bind("keydown",
this.bind(function(a){if(this.enabled)if(a.which===e.PAGE_UP||a.which===e.PAGE_DOWN)n(a);else if(this.opened())switch(a.which){case e.UP:case e.DOWN:this.moveHighlight(a.which===e.UP?-1:1);n(a);break;case e.TAB:case e.ENTER:this.selectHighlighted();n(a);break;case e.ESC:this.cancel(a),n(a)}else a.which===e.TAB||e.isControl(a)||e.isFunctionKey(a)||a.which===e.ESC||!1===this.opts.openOnEnter&&a.which===e.ENTER||this.open()}));this.search.bind("focus",this.bind(function(){this.selection.attr("tabIndex",
"-1")}));this.search.bind("blur",this.bind(function(){this.opened()||this.container.removeClass("select2-container-active");window.setTimeout(this.bind(function(){var a=this.elementTabIndex||0;a?this.selection.attr("tabIndex",a):this.selection.removeAttr("tabIndex")}),10)}));a.delegate("abbr","mousedown",this.bind(function(a){this.enabled&&(this.clear(),a.preventDefault(),a.stopImmediatePropagation(),this.close(),this.triggerChange(),this.selection.focus())}));a.bind("mousedown",this.bind(function(){this.opened()?
(this.close(),this.selection.focus()):this.enabled&&this.open()}));b.bind("mousedown",this.bind(function(){this.search.focus()}));a.bind("focus",this.bind(function(){this.enabled&&(this.container.addClass("select2-container-active"),this.search.attr("tabIndex","-1"))}));a.bind("blur",this.bind(function(){this.opened()||this.container.removeClass("select2-container-active");window.setTimeout(this.bind(function(){this.search.attr("tabIndex",this.elementTabIndex||0)}),10)}));a.bind("keydown",this.bind(function(a){if(this.enabled)if(a.which==
e.DOWN||a.which==e.UP||a.which==e.ENTER&&this.opts.openOnEnter)this.open(),n(a);else if(a.which==e.DELETE||a.which==e.BACKSPACE)this.opts.allowClear&&this.clear(),n(a)}));a.bind("keypress",this.bind(function(a){a.which==e.DELETE||(a.which==e.BACKSPACE||a.which==e.TAB||a.which==e.ENTER||0==a.which)||(a=String.fromCharCode(a.which),this.search.val(a),this.open())}));this.setPlaceholder();this.search.bind("focus",this.bind(function(){this.container.addClass("select2-container-active")}))},clear:function(){this.opts.element.val("");
this.selection.find("span").empty();this.selection.removeData("select2-data");this.setPlaceholder()},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!==g&&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");f.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,f){return m(d,a.id(f))},callback:!f.isFunction(c)?f.noop:function(a){c(a.results.length?a.results[0]:null)}})});return a},setPlaceholder:function(){var a=this.getPlaceholder();""===this.opts.element.val()&&a!==g&&!(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.showSearchInput=H(a.results)>=this.opts.minimumResultsForSearch,this.dropdown.find(".select2-search")[e?"removeClass":"addClass"]("select2-search-hidden"),
f(this.dropdown,this.container)[e?"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.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!==g&&b.append(this.opts.escapeMarkup(a));this.selection.removeClass("select2-default");
this.opts.allowClear&&this.getPlaceholder()!==g&&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===g)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();d.triggerChange()}))}},clearSearch:function(){this.search.val("")},data:function(a){var b;if(0===arguments.length)return b=this.selection.data("select2-data"),b==g&&(b=null),b;!a||""===a?this.clear():(this.opts.element.val(!a?"":this.id(a)),this.updateSelection(a))}});B=z(r,{createContainer:function(){return f(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})});f.isFunction(c)&&c(d)}:"data"in a&&(a.initSelection=a.initSelection||function(b,c){var d=v(b.val(),a.separator);a.query({matcher:function(b,c,e){return f.grep(d,function(b){return m(b,a.id(e))}).length},callback:!f.isFunction(c)?f.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("keydown",this.bind(function(b){if(this.enabled){if(b.which===e.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);n(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 e.UP:case e.DOWN:this.moveHighlight(b.which===e.UP?-1:1);n(b);return;case e.ENTER:case e.TAB:this.selectHighlighted();n(b);return;case e.ESC:this.cancel(b);n(b);return}if(!(b.which===e.TAB||e.isControl(b)||e.isFunctionKey(b)||b.which===e.BACKSPACE||b.which===e.ESC)&&!(!1===this.opts.openOnEnter&&b.which===e.ENTER))this.open(),(b.which===e.PAGE_UP||b.which===e.PAGE_DOWN)&&n(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<f(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.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!==g&&null!==b&&(a.updateSelection(b),a.close(),a.clearSearch())})}},clearSearch:function(){var a=this.getPlaceholder();a!==g&&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"):" "===this.search.val()&&this.search.val("")},opening:function(){this.parent.opening.apply(this,
arguments);this.clearPlaceholder();this.resizeSearch();this.focusSearch()},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;f(a).each(function(){0>j(d.id(this),b)&&(b.push(d.id(this)),c.push(this))});a=c;this.selection.find(".select2-search-choice").remove();f(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!=g&&(this.search.val(a),0<a.length&&this.open())},onSelect:function(a,b){this.addSelectedChoice(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.positionDropdown()):this.close();this.triggerChange({added:a});
(!b||!b.noFocus)&&this.focusSearch()},cancel:function(){this.close();this.focusSearch()},addSelectedChoice:function(a){var b=!a.locked,c=f("<li class='select2-search-choice'> <div></div> <a href='#' onclick='return false;' class='select2-search-choice-close' tabindex='-1'></a></li>"),d=f("<li class='select2-search-choice select2-locked'><div></div></li>"),c=b?c:d,d=this.id(a),e=this.getVal(),j;j=this.opts.formatSelection(a,c.find("div"));j!=g&&c.find("div").replaceWith("<div>"+this.opts.escapeMarkup(j)+
"</div>");b&&c.find(".select2-search-choice-close").bind("mousedown",n).bind("click dblclick",this.bind(function(a){this.enabled&&(f(a.target).closest(".select2-search-choice").fadeOut("fast",this.bind(function(){this.unselect(f(a.target));this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");this.close();this.focusSearch()})).dequeue(),n(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);e.push(d);this.setVal(e)},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=j(this.id(c),b),0<=d&&(b.splice(d,1),this.setVal(b),this.select&&this.postprocessResults()),a.remove(),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<=j(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,e=this.search.outerWidth(!1)-this.search.width();
a=this.search;u||(c=a[0].currentStyle||window.getComputedStyle(a[0],null),u=f(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"}),u.attr("class","select2-sizer"),f("body").append(u));u.text(a.val());a=u.width()+10;b=this.search.offset().left;c=this.selection.width();d=this.selection.offset().left;
b=c-(b-d)-e;b<a&&(b=c-e);40>b&&(b=c-e);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 v(a,this.opts.separator)},setVal:function(a){var b;this.select?this.select.val(a):(b=[],f(a).each(function(){0>j(this,b)&&b.push(this)}),this.opts.element.val(0===b.length?"":b.join(this.opts.separator)))},val:function(){var a,b=!1,c=[],d=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.select.find(":selected").each(function(){c.push({id:f(this).attr("value"),text:f(this).text()})}),this.updateSelection(c),b&&this.triggerChange();else{if(this.opts.initSelection===g)throw Error("val() cannot be called if initSelection() is not defined");this.opts.initSelection(this.opts.element,function(a){var c=f(a).map(d.id);d.setVal(c);
d.updateSelection(a);d.clearSearch();b&&d.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(f(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 f(this).data("select2-data")}).get();a||(a=[]);c=f.map(a,function(a){return b.opts.id(a)});this.setVal(c);this.updateSelection(a);this.clearSearch()}});f.fn.select2=function(){var a=Array.prototype.slice.call(arguments,0),b,c,d,e,m="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?{}:f.extend({},a[0]),b.element=f(this),"select"===b.element.get(0).tagName.toLowerCase()?e=b.element.attr("multiple"):(e=b.multiple||!1,"tags"in b&&(b.multiple=e=!0)),c=e?new B:new A,c.init(b);else if("string"===typeof a[0]){if(0>j(a[0],m))throw"Unknown method: "+a[0];d=g;c=f(this).data("select2");if(c!==g&&(d="container"===a[0]?c.container:c[a[0]].apply(c,a.slice(1)),d!==g))return!1}else throw"Invalid arguments to select2 plugin: "+
a;});return d===g?this:d};f.fn.select2.defaults={width:"copy",loadMorePadding:0,closeOnSelect:!0,openOnEnter:!0,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(a,b,c,d){b=[];D(a.text,c.term,b,d);return b.join("")},formatSelection:function(a){return a?a.text:g},sortResults:function(a){return a},formatResultCssClass:function(){return g},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:L,escapeMarkup:function(a){var b={"\\":"&#92;","&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;","/":"&#47;"};return String(a).replace(/[&<>"'/\\]/g,function(a){return b[a[0]]})},blurOnChange:!1,selectOnBlur:!1};window.Select2={query:{ajax:E,local:F,tags:G},util:{debounce:C,markMatch:D},"class":{"abstract":r,single:A,multi:B}}}})(jQuery);