select2.min.js 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. /*
  2. Copyright 2012 Igor Vaynberg
  3. Version: 3.3.0 Timestamp: Tue Feb 5 18:33:54 PST 2013
  4. This software is licensed under the Apache License, Version 2.0 (the "Apache License") or the GNU
  5. General Public License version 2 (the "GPL License"). You may choose either license to govern your
  6. use of this software only upon the condition that you accept all of the terms of either the Apache
  7. License or the GPL License.
  8. You may obtain a copy of the Apache License and the GPL License at:
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. http://www.gnu.org/licenses/gpl-2.0.html
  11. Unless required by applicable law or agreed to in writing, software distributed under the Apache License
  12. or the GPL Licesnse is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
  13. either express or implied. See the Apache License and the GPL License for the specific language governing
  14. permissions and limitations under the Apache License and the GPL License.
  15. LICENSE #1: Apache License, Version 2.0
  16. LICENSE #2: GPL v2
  17. ************************************************************
  18. LICENSE #1:
  19. Apache License
  20. Version 2.0, January 2004
  21. http://www.apache.org/licenses/
  22. TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
  23. 1. Definitions.
  24. "License" shall mean the terms and conditions for use, reproduction,
  25. and distribution as defined by Sections 1 through 9 of this document.
  26. "Licensor" shall mean the copyright owner or entity authorized by
  27. the copyright owner that is granting the License.
  28. "Legal Entity" shall mean the union of the acting entity and all
  29. other entities that control, are controlled by, or are under common
  30. control with that entity. For the purposes of this definition,
  31. "control" means (i) the power, direct or indirect, to cause the
  32. direction or management of such entity, whether by contract or
  33. otherwise, or (ii) ownership of fifty percent (50%) or more of the
  34. outstanding shares, or (iii) beneficial ownership of such entity.
  35. "You" (or "Your") shall mean an individual or Legal Entity
  36. exercising permissions granted by this License.
  37. "Source" form shall mean the preferred form for making modifications,
  38. including but not limited to software source code, documentation
  39. source, and configuration files.
  40. "Object" form shall mean any form resulting from mechanical
  41. transformation or translation of a Source form, including but
  42. not limited to compiled object code, generated documentation,
  43. and conversions to other media types.
  44. "Work" shall mean the work of authorship, whether in Source or
  45. Object form, made available under the License, as indicated by a
  46. copyright notice that is included in or attached to the work
  47. (an example is provided in the Appendix below).
  48. "Derivative Works" shall mean any work, whether in Source or Object
  49. form, that is based on (or derived from) the Work and for which the
  50. editorial revisions, annotations, elaborations, or other modifications
  51. represent, as a whole, an original work of authorship. For the purposes
  52. of this License, Derivative Works shall not include works that remain
  53. separable from, or merely link (or bind by name) to the interfaces of,
  54. the Work and Derivative Works thereof.
  55. "Contribution" shall mean any work of authorship, including
  56. the original version of the Work and any modifications or additions
  57. to that Work or Derivative Works thereof, that is intentionally
  58. submitted to Licensor for inclusion in the Work by the copyright owner
  59. or by an individual or Legal Entity authorized to submit on behalf of
  60. the copyright owner. For the purposes of this definition, "submitted"
  61. means any form of electronic, verbal, or written communication sent
  62. to the Licensor or its representatives, including but not limited to
  63. communication on electronic mailing lists, source code control systems,
  64. and issue tracking systems that are managed by, or on behalf of, the
  65. Licensor for the purpose of discussing and improving the Work, but
  66. excluding communication that is conspicuously marked or otherwise
  67. designated in writing by the copyright owner as "Not a Contribution."
  68. "Contributor" shall mean Licensor and any individual or Legal Entity
  69. on behalf of whom a Contribution has been received by Licensor and
  70. subsequently incorporated within the Work.
  71. 2. Grant of Copyright License. Subject to the terms and conditions of
  72. this License, each Contributor hereby grants to You a perpetual,
  73. worldwide, non-exclusive, no-charge, royalty-free, irrevocable
  74. copyright license to reproduce, prepare Derivative Works of,
  75. publicly display, publicly perform, sublicense, and distribute the
  76. Work and such Derivative Works in Source or Object form.
  77. 3. Grant of Patent License. Subject to the terms and conditions of
  78. this License, each Contributor hereby grants to You a perpetual,
  79. worldwide, non-exclusive, no-charge, royalty-free, irrevocable
  80. (except as stated in this section) patent license to make, have made,
  81. use, offer to sell, sell, import, and otherwise transfer the Work,
  82. where such license applies only to those patent claims licensable
  83. by such Contributor that are necessarily infringed by their
  84. Contribution(s) alone or by combination of their Contribution(s)
  85. with the Work to which such Contribution(s) was submitted. If You
  86. institute patent litigation against any entity (including a
  87. cross-claim or counterclaim in a lawsuit) alleging that the Work
  88. or a Contribution incorporated within the Work constitutes direct
  89. or contributory patent infringement, then any patent licenses
  90. granted to You under this License for that Work shall terminate
  91. as of the date such litigation is filed.
  92. 4. Redistribution. You may reproduce and distribute copies of the
  93. Work or Derivative Works thereof in any medium, with or without
  94. modifications, and in Source or Object form, provided that You
  95. meet the following conditions:
  96. (a) You must give any other recipients of the Work or
  97. Derivative Works a copy of this License; and
  98. (b) You must cause any modified files to carry prominent notices
  99. stating that You changed the files; and
  100. (c) You must retain, in the Source form of any Derivative Works
  101. that You distribute, all copyright, patent, trademark, and
  102. attribution notices from the Source form of the Work,
  103. excluding those notices that do not pertain to any part of
  104. the Derivative Works; and
  105. (d) If the Work includes a "NOTICE" text file as part of its
  106. distribution, then any Derivative Works that You distribute must
  107. include a readable copy of the attribution notices contained
  108. within such NOTICE file, excluding those notices that do not
  109. pertain to any part of the Derivative Works, in at least one
  110. of the following places: within a NOTICE text file distributed
  111. as part of the Derivative Works; within the Source form or
  112. documentation, if provided along with the Derivative Works; or,
  113. within a display generated by the Derivative Works, if and
  114. wherever such third-party notices normally appear. The contents
  115. of the NOTICE file are for informational purposes only and
  116. do not modify the License. You may add Your own attribution
  117. notices within Derivative Works that You distribute, alongside
  118. or as an addendum to the NOTICE text from the Work, provided
  119. that such additional attribution notices cannot be construed
  120. as modifying the License.
  121. You may add Your own copyright statement to Your modifications and
  122. may provide additional or different license terms and conditions
  123. for use, reproduction, or distribution of Your modifications, or
  124. for any such Derivative Works as a whole, provided Your use,
  125. reproduction, and distribution of the Work otherwise complies with
  126. the conditions stated in this License.
  127. 5. Submission of Contributions. Unless You explicitly state otherwise,
  128. any Contribution intentionally submitted for inclusion in the Work
  129. by You to the Licensor shall be under the terms and conditions of
  130. this License, without any additional terms or conditions.
  131. Notwithstanding the above, nothing herein shall supersede or modify
  132. the terms of any separate license agreement you may have executed
  133. with Licensor regarding such Contributions.
  134. 6. Trademarks. This License does not grant permission to use the trade
  135. names, trademarks, service marks, or product names of the Licensor,
  136. except as required for reasonable and customary use in describing the
  137. origin of the Work and reproducing the content of the NOTICE file.
  138. 7. Disclaimer of Warranty. Unless required by applicable law or
  139. agreed to in writing, Licensor provides the Work (and each
  140. Contributor provides its Contributions) on an "AS IS" BASIS,
  141. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  142. implied, including, without limitation, any warranties or conditions
  143. of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
  144. PARTICULAR PURPOSE. You are solely responsible for determining the
  145. appropriateness of using or redistributing the Work and assume any
  146. risks associated with Your exercise of permissions under this License.
  147. 8. Limitation of Liability. In no event and under no legal theory,
  148. whether in tort (including negligence), contract, or otherwise,
  149. unless required by applicable law (such as deliberate and grossly
  150. negligent acts) or agreed to in writing, shall any Contributor be
  151. liable to You for damages, including any direct, indirect, special,
  152. incidental, or consequential damages of any character arising as a
  153. result of this License or out of the use or inability to use the
  154. Work (including but not limited to damages for loss of goodwill,
  155. work stoppage, computer failure or malfunction, or any and all
  156. other commercial damages or losses), even if such Contributor
  157. has been advised of the possibility of such damages.
  158. 9. Accepting Warranty or Additional Liability. While redistributing
  159. the Work or Derivative Works thereof, You may choose to offer,
  160. and charge a fee for, acceptance of support, warranty, indemnity,
  161. or other liability obligations and/or rights consistent with this
  162. License. However, in accepting such obligations, You may act only
  163. on Your own behalf and on Your sole responsibility, not on behalf
  164. of any other Contributor, and only if You agree to indemnify,
  165. defend, and hold each Contributor harmless for any liability
  166. incurred by, or claims asserted against, such Contributor by reason
  167. of your accepting any such warranty or additional liability.
  168. ************************************************************
  169. LICENSE #2:
  170. GNU GENERAL PUBLIC LICENSE
  171. Version 2, June 1991
  172. Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
  173. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  174. Everyone is permitted to copy and distribute verbatim copies
  175. of this license document, but changing it is not allowed.
  176. Preamble
  177. The licenses for most software are designed to take away your
  178. freedom to share and change it. By contrast, the GNU General Public
  179. License is intended to guarantee your freedom to share and change free
  180. software--to make sure the software is free for all its users. This
  181. General Public License applies to most of the Free Software
  182. Foundation's software and to any other program whose authors commit to
  183. using it. (Some other Free Software Foundation software is covered by
  184. the GNU Lesser General Public License instead.) You can apply it to
  185. your programs, too.
  186. When we speak of free software, we are referring to freedom, not
  187. price. Our General Public Licenses are designed to make sure that you
  188. have the freedom to distribute copies of free software (and charge for
  189. this service if you wish), that you receive source code or can get it
  190. if you want it, that you can change the software or use pieces of it
  191. in new free programs; and that you know you can do these things.
  192. To protect your rights, we need to make restrictions that forbid
  193. anyone to deny you these rights or to ask you to surrender the rights.
  194. These restrictions translate to certain responsibilities for you if you
  195. distribute copies of the software, or if you modify it.
  196. For example, if you distribute copies of such a program, whether
  197. gratis or for a fee, you must give the recipients all the rights that
  198. you have. You must make sure that they, too, receive or can get the
  199. source code. And you must show them these terms so they know their
  200. rights.
  201. We protect your rights with two steps: (1) copyright the software, and
  202. (2) offer you this license which gives you legal permission to copy,
  203. distribute and/or modify the software.
  204. Also, for each author's protection and ours, we want to make certain
  205. that everyone understands that there is no warranty for this free
  206. software. If the software is modified by someone else and passed on, we
  207. want its recipients to know that what they have is not the original, so
  208. that any problems introduced by others will not reflect on the original
  209. authors' reputations.
  210. Finally, any free program is threatened constantly by software
  211. patents. We wish to avoid the danger that redistributors of a free
  212. program will individually obtain patent licenses, in effect making the
  213. program proprietary. To prevent this, we have made it clear that any
  214. patent must be licensed for everyone's free use or not licensed at all.
  215. The precise terms and conditions for copying, distribution and
  216. modification follow.
  217. GNU GENERAL PUBLIC LICENSE
  218. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  219. 0. This License applies to any program or other work which contains
  220. a notice placed by the copyright holder saying it may be distributed
  221. under the terms of this General Public License. The "Program", below,
  222. refers to any such program or work, and a "work based on the Program"
  223. means either the Program or any derivative work under copyright law:
  224. that is to say, a work containing the Program or a portion of it,
  225. either verbatim or with modifications and/or translated into another
  226. language. (Hereinafter, translation is included without limitation in
  227. the term "modification".) Each licensee is addressed as "you".
  228. Activities other than copying, distribution and modification are not
  229. covered by this License; they are outside its scope. The act of
  230. running the Program is not restricted, and the output from the Program
  231. is covered only if its contents constitute a work based on the
  232. Program (independent of having been made by running the Program).
  233. Whether that is true depends on what the Program does.
  234. 1. You may copy and distribute verbatim copies of the Program's
  235. source code as you receive it, in any medium, provided that you
  236. conspicuously and appropriately publish on each copy an appropriate
  237. copyright notice and disclaimer of warranty; keep intact all the
  238. notices that refer to this License and to the absence of any warranty;
  239. and give any other recipients of the Program a copy of this License
  240. along with the Program.
  241. You may charge a fee for the physical act of transferring a copy, and
  242. you may at your option offer warranty protection in exchange for a fee.
  243. 2. You may modify your copy or copies of the Program or any portion
  244. of it, thus forming a work based on the Program, and copy and
  245. distribute such modifications or work under the terms of Section 1
  246. above, provided that you also meet all of these conditions:
  247. a) You must cause the modified files to carry prominent notices
  248. stating that you changed the files and the date of any change.
  249. b) You must cause any work that you distribute or publish, that in
  250. whole or in part contains or is derived from the Program or any
  251. part thereof, to be licensed as a whole at no charge to all third
  252. parties under the terms of this License.
  253. c) If the modified program normally reads commands interactively
  254. when run, you must cause it, when started running for such
  255. interactive use in the most ordinary way, to print or display an
  256. announcement including an appropriate copyright notice and a
  257. notice that there is no warranty (or else, saying that you provide
  258. a warranty) and that users may redistribute the program under
  259. these conditions, and telling the user how to view a copy of this
  260. License. (Exception: if the Program itself is interactive but
  261. does not normally print such an announcement, your work based on
  262. the Program is not required to print an announcement.)
  263. These requirements apply to the modified work as a whole. If
  264. identifiable sections of that work are not derived from the Program,
  265. and can be reasonably considered independent and separate works in
  266. themselves, then this License, and its terms, do not apply to those
  267. sections when you distribute them as separate works. But when you
  268. distribute the same sections as part of a whole which is a work based
  269. on the Program, the distribution of the whole must be on the terms of
  270. this License, whose permissions for other licensees extend to the
  271. entire whole, and thus to each and every part regardless of who wrote it.
  272. Thus, it is not the intent of this section to claim rights or contest
  273. your rights to work written entirely by you; rather, the intent is to
  274. exercise the right to control the distribution of derivative or
  275. collective works based on the Program.
  276. In addition, mere aggregation of another work not based on the Program
  277. with the Program (or with a work based on the Program) on a volume of
  278. a storage or distribution medium does not bring the other work under
  279. the scope of this License.
  280. 3. You may copy and distribute the Program (or a work based on it,
  281. under Section 2) in object code or executable form under the terms of
  282. Sections 1 and 2 above provided that you also do one of the following:
  283. a) Accompany it with the complete corresponding machine-readable
  284. source code, which must be distributed under the terms of Sections
  285. 1 and 2 above on a medium customarily used for software interchange; or,
  286. b) Accompany it with a written offer, valid for at least three
  287. years, to give any third party, for a charge no more than your
  288. cost of physically performing source distribution, a complete
  289. machine-readable copy of the corresponding source code, to be
  290. distributed under the terms of Sections 1 and 2 above on a medium
  291. customarily used for software interchange; or,
  292. c) Accompany it with the information you received as to the offer
  293. to distribute corresponding source code. (This alternative is
  294. allowed only for noncommercial distribution and only if you
  295. received the program in object code or executable form with such
  296. an offer, in accord with Subsection b above.)
  297. The source code for a work means the preferred form of the work for
  298. making modifications to it. For an executable work, complete source
  299. code means all the source code for all modules it contains, plus any
  300. associated interface definition files, plus the scripts used to
  301. control compilation and installation of the executable. However, as a
  302. special exception, the source code distributed need not include
  303. anything that is normally distributed (in either source or binary
  304. form) with the major components (compiler, kernel, and so on) of the
  305. operating system on which the executable runs, unless that component
  306. itself accompanies the executable.
  307. If distribution of executable or object code is made by offering
  308. access to copy from a designated place, then offering equivalent
  309. access to copy the source code from the same place counts as
  310. distribution of the source code, even though third parties are not
  311. compelled to copy the source along with the object code.
  312. 4. You may not copy, modify, sublicense, or distribute the Program
  313. except as expressly provided under this License. Any attempt
  314. otherwise to copy, modify, sublicense or distribute the Program is
  315. void, and will automatically terminate your rights under this License.
  316. However, parties who have received copies, or rights, from you under
  317. this License will not have their licenses terminated so long as such
  318. parties remain in full compliance.
  319. 5. You are not required to accept this License, since you have not
  320. signed it. However, nothing else grants you permission to modify or
  321. distribute the Program or its derivative works. These actions are
  322. prohibited by law if you do not accept this License. Therefore, by
  323. modifying or distributing the Program (or any work based on the
  324. Program), you indicate your acceptance of this License to do so, and
  325. all its terms and conditions for copying, distributing or modifying
  326. the Program or works based on it.
  327. 6. Each time you redistribute the Program (or any work based on the
  328. Program), the recipient automatically receives a license from the
  329. original licensor to copy, distribute or modify the Program subject to
  330. these terms and conditions. You may not impose any further
  331. restrictions on the recipients' exercise of the rights granted herein.
  332. You are not responsible for enforcing compliance by third parties to
  333. this License.
  334. 7. If, as a consequence of a court judgment or allegation of patent
  335. infringement or for any other reason (not limited to patent issues),
  336. conditions are imposed on you (whether by court order, agreement or
  337. otherwise) that contradict the conditions of this License, they do not
  338. excuse you from the conditions of this License. If you cannot
  339. distribute so as to satisfy simultaneously your obligations under this
  340. License and any other pertinent obligations, then as a consequence you
  341. may not distribute the Program at all. For example, if a patent
  342. license would not permit royalty-free redistribution of the Program by
  343. all those who receive copies directly or indirectly through you, then
  344. the only way you could satisfy both it and this License would be to
  345. refrain entirely from distribution of the Program.
  346. If any portion of this section is held invalid or unenforceable under
  347. any particular circumstance, the balance of the section is intended to
  348. apply and the section as a whole is intended to apply in other
  349. circumstances.
  350. It is not the purpose of this section to induce you to infringe any
  351. patents or other property right claims or to contest validity of any
  352. such claims; this section has the sole purpose of protecting the
  353. integrity of the free software distribution system, which is
  354. implemented by public license practices. Many people have made
  355. generous contributions to the wide range of software distributed
  356. through that system in reliance on consistent application of that
  357. system; it is up to the author/donor to decide if he or she is willing
  358. to distribute software through any other system and a licensee cannot
  359. impose that choice.
  360. This section is intended to make thoroughly clear what is believed to
  361. be a consequence of the rest of this License.
  362. 8. If the distribution and/or use of the Program is restricted in
  363. certain countries either by patents or by copyrighted interfaces, the
  364. original copyright holder who places the Program under this License
  365. may add an explicit geographical distribution limitation excluding
  366. those countries, so that distribution is permitted only in or among
  367. countries not thus excluded. In such case, this License incorporates
  368. the limitation as if written in the body of this License.
  369. 9. The Free Software Foundation may publish revised and/or new versions
  370. of the General Public License from time to time. Such new versions will
  371. be similar in spirit to the present version, but may differ in detail to
  372. address new problems or concerns.
  373. Each version is given a distinguishing version number. If the Program
  374. specifies a version number of this License which applies to it and "any
  375. later version", you have the option of following the terms and conditions
  376. either of that version or of any later version published by the Free
  377. Software Foundation. If the Program does not specify a version number of
  378. this License, you may choose any version ever published by the Free Software
  379. Foundation.
  380. 10. If you wish to incorporate parts of the Program into other free
  381. programs whose distribution conditions are different, write to the author
  382. to ask for permission. For software which is copyrighted by the Free
  383. Software Foundation, write to the Free Software Foundation; we sometimes
  384. make exceptions for this. Our decision will be guided by the two goals
  385. of preserving the free status of all derivatives of our free software and
  386. of promoting the sharing and reuse of software generally.
  387. NO WARRANTY
  388. 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
  389. FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
  390. OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
  391. PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
  392. OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  393. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
  394. TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
  395. PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
  396. REPAIR OR CORRECTION.
  397. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
  398. WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
  399. REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
  400. INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
  401. OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
  402. TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
  403. YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
  404. PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
  405. POSSIBILITY OF SUCH DAMAGES.
  406. */
  407. (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);
  408. (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());
  409. 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;
  410. 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,
  411. 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");
  412. }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=
  413. !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},
  414. 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();
  415. 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()),
  416. 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",
  417. 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",
  418. 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>=
  419. 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");
  420. " "===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']"))&&
  421. 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(" "),
  422. 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"),
  423. 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
  424. 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")},
  425. 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===
  426. 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")&&
  427. 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),
  428. {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&&
  429. (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,
  430. 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,
  431. 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."+
  432. 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,
  433. 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=
  434. 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=
  435. 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)");
  436. 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());
  437. 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")},
  438. 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+
  439. 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;
  440. 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>
  441. 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),
  442. 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))+
  443. "</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");
  444. 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()?
  445. 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<
  446. 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>")},
  447. 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()&&
  448. (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",
  449. 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",
  450. "-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()?
  451. (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==
  452. 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("");
  453. 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()?
  454. 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())&&
  455. (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"),
  456. 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");
  457. 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");
  458. !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>")},
  459. 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)}})});
  460. 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");
  461. 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");
  462. 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"),
  463. 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,
  464. 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,
  465. 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)});
  466. 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});
  467. (!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)+
  468. "</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"))}));
  469. 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"),
  470. 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();
  471. 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;
  472. 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&&
  473. (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);
  474. 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")))});
  475. 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(" ");
  476. 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: "+
  477. 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 "+
  478. 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())},
  479. 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);