sunspot_solr 2.2.2 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (256) hide show
  1. checksums.yaml +4 -4
  2. data/bin/sunspot-solr +2 -6
  3. data/lib/sunspot/solr/server.rb +2 -3
  4. data/solr/README.txt +181 -181
  5. data/solr/bin/post +29 -19
  6. data/solr/bin/solr +247 -428
  7. data/solr/bin/solr.cmd +102 -256
  8. data/solr/bin/solr.in.cmd +15 -7
  9. data/solr/bin/solr.in.sh +26 -12
  10. data/solr/server/README.txt +110 -113
  11. data/solr/server/contexts/solr-jetty-context.xml +8 -8
  12. data/solr/server/etc/jetty-http.xml +47 -0
  13. data/solr/server/etc/jetty-https-ssl.xml +175 -159
  14. data/solr/server/etc/jetty-https.xml +53 -0
  15. data/solr/server/etc/jetty-ssl.xml +46 -0
  16. data/solr/server/etc/jetty.xml +189 -167
  17. data/solr/server/etc/webdefault.xml +527 -527
  18. data/solr/server/lib/javax.servlet-api-3.1.0.jar +0 -0
  19. data/solr/server/lib/jetty-continuation-9.2.11.v20150529.jar +0 -0
  20. data/solr/server/lib/jetty-deploy-9.2.11.v20150529.jar +0 -0
  21. data/solr/server/lib/jetty-http-9.2.11.v20150529.jar +0 -0
  22. data/solr/server/lib/jetty-io-9.2.11.v20150529.jar +0 -0
  23. data/solr/server/lib/jetty-jmx-9.2.11.v20150529.jar +0 -0
  24. data/solr/server/lib/jetty-rewrite-9.2.11.v20150529.jar +0 -0
  25. data/solr/server/lib/jetty-security-9.2.11.v20150529.jar +0 -0
  26. data/solr/server/lib/jetty-server-9.2.11.v20150529.jar +0 -0
  27. data/solr/server/lib/jetty-servlet-9.2.11.v20150529.jar +0 -0
  28. data/solr/server/lib/jetty-servlets-9.2.11.v20150529.jar +0 -0
  29. data/solr/server/lib/jetty-util-9.2.11.v20150529.jar +0 -0
  30. data/solr/server/lib/jetty-webapp-9.2.11.v20150529.jar +0 -0
  31. data/solr/server/lib/jetty-xml-9.2.11.v20150529.jar +0 -0
  32. data/solr/server/modules/http.mod +9 -0
  33. data/solr/server/modules/https.mod +9 -0
  34. data/solr/server/modules/server.mod +11 -0
  35. data/solr/server/modules/ssl.mod +9 -0
  36. data/solr/server/resources/jetty-logging.properties +1 -0
  37. data/solr/server/resources/log4j.properties +24 -24
  38. data/solr/server/solr-webapp/webapp/WEB-INF/lib/commons-exec-1.3.jar +0 -0
  39. data/solr/server/solr-webapp/webapp/WEB-INF/lib/{hadoop-annotations-2.3.0.jar → hadoop-annotations-2.6.0.jar} +0 -0
  40. data/solr/server/solr-webapp/webapp/WEB-INF/lib/hadoop-auth-2.6.0.jar +0 -0
  41. data/solr/server/solr-webapp/webapp/WEB-INF/lib/hadoop-common-2.6.0.jar +0 -0
  42. data/solr/server/solr-webapp/webapp/WEB-INF/lib/hadoop-hdfs-2.6.0.jar +0 -0
  43. data/solr/server/solr-webapp/webapp/WEB-INF/lib/htrace-core-3.0.4.jar +0 -0
  44. data/solr/server/solr-webapp/webapp/WEB-INF/lib/httpclient-4.4.1.jar +0 -0
  45. data/solr/server/solr-webapp/webapp/WEB-INF/lib/httpcore-4.4.1.jar +0 -0
  46. data/solr/server/solr-webapp/webapp/WEB-INF/lib/httpmime-4.4.1.jar +0 -0
  47. data/solr/server/solr-webapp/webapp/WEB-INF/lib/jackson-core-2.5.4.jar +0 -0
  48. data/solr/server/solr-webapp/webapp/WEB-INF/lib/jackson-dataformat-smile-2.5.4.jar +0 -0
  49. data/solr/server/solr-webapp/webapp/WEB-INF/lib/{lucene-analyzers-common-5.0.0.jar → lucene-analyzers-common-5.3.1.jar} +0 -0
  50. data/solr/server/solr-webapp/webapp/WEB-INF/lib/{lucene-analyzers-kuromoji-5.0.0.jar → lucene-analyzers-kuromoji-5.3.1.jar} +0 -0
  51. data/solr/server/solr-webapp/webapp/WEB-INF/lib/{lucene-analyzers-phonetic-5.0.0.jar → lucene-analyzers-phonetic-5.3.1.jar} +0 -0
  52. data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-backward-codecs-5.3.1.jar +0 -0
  53. data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-codecs-5.3.1.jar +0 -0
  54. data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-core-5.3.1.jar +0 -0
  55. data/solr/server/solr-webapp/webapp/WEB-INF/lib/{lucene-expressions-5.0.0.jar → lucene-expressions-5.3.1.jar} +0 -0
  56. data/solr/server/solr-webapp/webapp/WEB-INF/lib/{lucene-grouping-5.0.0.jar → lucene-grouping-5.3.1.jar} +0 -0
  57. data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-highlighter-5.3.1.jar +0 -0
  58. data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-join-5.3.1.jar +0 -0
  59. data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-memory-5.3.1.jar +0 -0
  60. data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-misc-5.3.1.jar +0 -0
  61. data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-queries-5.3.1.jar +0 -0
  62. data/solr/server/solr-webapp/webapp/WEB-INF/lib/{lucene-queryparser-5.0.0.jar → lucene-queryparser-5.3.1.jar} +0 -0
  63. data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-sandbox-5.3.1.jar +0 -0
  64. data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-spatial-5.3.1.jar +0 -0
  65. data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-suggest-5.3.1.jar +0 -0
  66. data/solr/server/solr-webapp/webapp/WEB-INF/lib/org.restlet-2.3.0.jar +0 -0
  67. data/solr/server/solr-webapp/webapp/WEB-INF/lib/org.restlet.ext.servlet-2.3.0.jar +0 -0
  68. data/solr/server/solr-webapp/webapp/WEB-INF/lib/solr-core-5.3.1.jar +0 -0
  69. data/solr/server/solr-webapp/webapp/WEB-INF/lib/solr-solrj-5.3.1.jar +0 -0
  70. data/solr/server/solr-webapp/webapp/WEB-INF/lib/t-digest-3.1.jar +0 -0
  71. data/solr/server/solr-webapp/webapp/WEB-INF/web.xml +169 -181
  72. data/solr/server/solr-webapp/webapp/WEB-INF/weblogic.xml +28 -28
  73. data/solr/server/solr-webapp/webapp/admin.html +164 -163
  74. data/solr/server/solr-webapp/webapp/css/angular/analysis.css +304 -0
  75. data/solr/server/solr-webapp/webapp/css/angular/chosen.css +465 -0
  76. data/solr/server/solr-webapp/webapp/css/angular/cloud.css +398 -0
  77. data/solr/server/solr-webapp/webapp/css/angular/common.css +724 -0
  78. data/solr/server/solr-webapp/webapp/css/angular/cores.css +233 -0
  79. data/solr/server/solr-webapp/webapp/css/angular/dataimport.css +370 -0
  80. data/solr/server/solr-webapp/webapp/css/angular/documents.css +179 -0
  81. data/solr/server/solr-webapp/webapp/css/angular/files.css +53 -0
  82. data/solr/server/solr-webapp/webapp/css/angular/index.css +206 -0
  83. data/solr/server/solr-webapp/webapp/css/angular/logging.css +376 -0
  84. data/solr/server/solr-webapp/webapp/css/angular/menu.css +321 -0
  85. data/solr/server/solr-webapp/webapp/css/angular/plugins.css +212 -0
  86. data/solr/server/solr-webapp/webapp/css/angular/query.css +162 -0
  87. data/solr/server/solr-webapp/webapp/css/angular/replication.css +500 -0
  88. data/solr/server/solr-webapp/webapp/css/angular/schema-browser.css +567 -0
  89. data/solr/server/solr-webapp/webapp/css/angular/segments.css +173 -0
  90. data/solr/server/solr-webapp/webapp/css/angular/threads.css +161 -0
  91. data/solr/server/solr-webapp/webapp/css/chosen.css +421 -421
  92. data/solr/server/solr-webapp/webapp/css/styles/analysis.css +311 -311
  93. data/solr/server/solr-webapp/webapp/css/styles/cloud.css +410 -410
  94. data/solr/server/solr-webapp/webapp/css/styles/common.css +701 -701
  95. data/solr/server/solr-webapp/webapp/css/styles/cores.css +244 -244
  96. data/solr/server/solr-webapp/webapp/css/styles/dashboard.css +155 -155
  97. data/solr/server/solr-webapp/webapp/css/styles/dataimport.css +403 -403
  98. data/solr/server/solr-webapp/webapp/css/styles/documents.css +197 -197
  99. data/solr/server/solr-webapp/webapp/css/styles/files.css +54 -54
  100. data/solr/server/solr-webapp/webapp/css/styles/index.css +207 -207
  101. data/solr/server/solr-webapp/webapp/css/styles/java-properties.css +52 -52
  102. data/solr/server/solr-webapp/webapp/css/styles/logging.css +391 -391
  103. data/solr/server/solr-webapp/webapp/css/styles/menu.css +329 -328
  104. data/solr/server/solr-webapp/webapp/css/styles/plugins.css +195 -195
  105. data/solr/server/solr-webapp/webapp/css/styles/query.css +173 -173
  106. data/solr/server/solr-webapp/webapp/css/styles/replication.css +515 -515
  107. data/solr/server/solr-webapp/webapp/css/styles/schema-browser.css +578 -578
  108. data/solr/server/solr-webapp/webapp/css/styles/segments.css +145 -0
  109. data/solr/server/solr-webapp/webapp/css/styles/threads.css +172 -172
  110. data/solr/server/solr-webapp/webapp/img/chosen-sprite-2x.png +0 -0
  111. data/solr/server/solr-webapp/webapp/img/filetypes/README +27 -27
  112. data/solr/server/solr-webapp/webapp/img/solr.svg +39 -39
  113. data/solr/server/solr-webapp/webapp/index.html +208 -0
  114. data/solr/server/solr-webapp/webapp/js/angular/app.js +713 -0
  115. data/solr/server/solr-webapp/webapp/js/angular/controllers/analysis.js +199 -0
  116. data/solr/server/solr-webapp/webapp/js/angular/controllers/cloud.js +528 -0
  117. data/solr/server/solr-webapp/webapp/js/angular/controllers/core-overview.js +225 -0
  118. data/solr/server/solr-webapp/webapp/js/angular/controllers/cores.js +465 -0
  119. data/solr/server/solr-webapp/webapp/js/angular/controllers/dataimport.js +284 -0
  120. data/solr/server/solr-webapp/webapp/js/angular/controllers/documents.js +139 -0
  121. data/solr/server/solr-webapp/webapp/js/angular/controllers/files.js +92 -0
  122. data/solr/server/solr-webapp/webapp/js/angular/controllers/index.js +95 -0
  123. data/solr/server/solr-webapp/webapp/js/angular/controllers/java-properties.js +45 -0
  124. data/solr/server/solr-webapp/webapp/js/angular/controllers/logging.js +146 -0
  125. data/solr/server/solr-webapp/webapp/js/angular/controllers/plugins.js +166 -0
  126. data/solr/server/solr-webapp/webapp/js/angular/controllers/query.js +99 -0
  127. data/solr/server/solr-webapp/webapp/js/angular/controllers/replication.js +227 -0
  128. data/solr/server/solr-webapp/webapp/js/angular/controllers/schema-browser.js +432 -0
  129. data/solr/server/solr-webapp/webapp/js/angular/controllers/segments.js +94 -0
  130. data/solr/server/solr-webapp/webapp/js/angular/controllers/threads.js +51 -0
  131. data/solr/server/solr-webapp/webapp/js/angular/services.js +214 -0
  132. data/solr/server/solr-webapp/webapp/js/lib/ZeroClipboard.js +342 -342
  133. data/solr/server/solr-webapp/webapp/js/lib/chosen.js +982 -982
  134. data/solr/server/solr-webapp/webapp/js/lib/console.js +29 -29
  135. data/solr/server/solr-webapp/webapp/js/lib/d3.js +9373 -9373
  136. data/solr/server/solr-webapp/webapp/js/lib/highlight.js +31 -31
  137. data/solr/server/solr-webapp/webapp/js/lib/jquery-1.7.2.min.js +30 -30
  138. data/solr/server/solr-webapp/webapp/js/lib/jquery.ajaxfileupload.js +184 -184
  139. data/solr/server/solr-webapp/webapp/js/lib/jquery.blockUI.js +523 -523
  140. data/solr/server/solr-webapp/webapp/js/lib/jquery.cookie.js +71 -71
  141. data/solr/server/solr-webapp/webapp/js/lib/jquery.form.js +806 -806
  142. data/solr/server/solr-webapp/webapp/js/lib/jquery.jstree.js +3534 -3534
  143. data/solr/server/solr-webapp/webapp/js/lib/jquery.sammy.js +1863 -1863
  144. data/solr/server/solr-webapp/webapp/js/lib/jquery.timeago.js +189 -189
  145. data/solr/server/solr-webapp/webapp/js/lib/linker.js +48 -48
  146. data/solr/server/solr-webapp/webapp/js/lib/naturalSort.js +82 -0
  147. data/solr/server/solr-webapp/webapp/js/lib/order.js +216 -216
  148. data/solr/server/solr-webapp/webapp/js/main.js +60 -58
  149. data/solr/server/solr-webapp/webapp/js/require.js +11349 -11349
  150. data/solr/server/solr-webapp/webapp/js/scripts/analysis.js +545 -545
  151. data/solr/server/solr-webapp/webapp/js/scripts/app.js +680 -679
  152. data/solr/server/solr-webapp/webapp/js/scripts/cloud.js +877 -877
  153. data/solr/server/solr-webapp/webapp/js/scripts/cores.js +719 -719
  154. data/solr/server/solr-webapp/webapp/js/scripts/dashboard.js +562 -562
  155. data/solr/server/solr-webapp/webapp/js/scripts/dataimport.js +812 -812
  156. data/solr/server/solr-webapp/webapp/js/scripts/documents.js +370 -370
  157. data/solr/server/solr-webapp/webapp/js/scripts/files.js +265 -265
  158. data/solr/server/solr-webapp/webapp/js/scripts/index.js +340 -340
  159. data/solr/server/solr-webapp/webapp/js/scripts/java-properties.js +106 -106
  160. data/solr/server/solr-webapp/webapp/js/scripts/logging.js +578 -576
  161. data/solr/server/solr-webapp/webapp/js/scripts/ping.js +72 -72
  162. data/solr/server/solr-webapp/webapp/js/scripts/plugins.js +462 -462
  163. data/solr/server/solr-webapp/webapp/js/scripts/query.js +229 -229
  164. data/solr/server/solr-webapp/webapp/js/scripts/replication.js +527 -527
  165. data/solr/server/solr-webapp/webapp/js/scripts/schema-browser.js +1229 -1229
  166. data/solr/server/solr-webapp/webapp/js/scripts/segments.js +206 -0
  167. data/solr/server/solr-webapp/webapp/js/scripts/threads.js +158 -158
  168. data/solr/server/solr-webapp/webapp/libs/angular-chosen.js +139 -0
  169. data/solr/server/solr-webapp/webapp/libs/angular-cookies.js +229 -0
  170. data/solr/server/solr-webapp/webapp/libs/angular-cookies.min.js +31 -0
  171. data/solr/server/solr-webapp/webapp/libs/angular-resource.min.js +36 -0
  172. data/solr/server/solr-webapp/webapp/libs/angular-route.js +1018 -0
  173. data/solr/server/solr-webapp/webapp/libs/angular-route.min.js +38 -0
  174. data/solr/server/solr-webapp/webapp/libs/angular-sanitize.js +703 -0
  175. data/solr/server/solr-webapp/webapp/libs/angular-sanitize.min.js +39 -0
  176. data/solr/server/solr-webapp/webapp/libs/angular.js +26093 -0
  177. data/solr/server/solr-webapp/webapp/libs/angular.min.js +273 -0
  178. data/solr/server/solr-webapp/webapp/libs/chosen.jquery.js +1194 -0
  179. data/solr/server/solr-webapp/webapp/libs/chosen.jquery.min.js +30 -0
  180. data/solr/server/solr-webapp/webapp/libs/d3.js +9373 -0
  181. data/solr/server/solr-webapp/webapp/libs/highlight.js +31 -0
  182. data/solr/server/solr-webapp/webapp/libs/jquery-2.1.3.min.js +29 -0
  183. data/solr/server/solr-webapp/webapp/libs/jquery.jstree.js +3534 -0
  184. data/solr/server/solr-webapp/webapp/libs/ngtimeago.js +102 -0
  185. data/solr/server/solr-webapp/webapp/partials/analysis.html +128 -0
  186. data/solr/server/solr-webapp/webapp/partials/cloud.html +104 -0
  187. data/solr/server/solr-webapp/webapp/partials/core_overview.html +227 -0
  188. data/solr/server/solr-webapp/webapp/partials/cores.html +231 -0
  189. data/solr/server/solr-webapp/webapp/partials/dataimport.html +209 -0
  190. data/solr/server/solr-webapp/webapp/partials/documents.html +118 -0
  191. data/solr/server/solr-webapp/webapp/partials/files.html +47 -0
  192. data/solr/server/solr-webapp/webapp/partials/index.html +261 -0
  193. data/solr/server/solr-webapp/webapp/partials/java-properties.html +27 -0
  194. data/solr/server/solr-webapp/webapp/partials/logging-levels.html +56 -0
  195. data/solr/server/solr-webapp/webapp/partials/logging.html +56 -0
  196. data/solr/server/solr-webapp/webapp/partials/plugins.html +72 -0
  197. data/solr/server/solr-webapp/webapp/partials/query.html +356 -0
  198. data/solr/server/solr-webapp/webapp/partials/replication.html +239 -0
  199. data/solr/server/solr-webapp/webapp/partials/schema-browser.html +206 -0
  200. data/solr/server/solr-webapp/webapp/partials/segments.html +99 -0
  201. data/solr/server/solr-webapp/webapp/partials/threads.html +65 -0
  202. data/solr/server/solr-webapp/webapp/tpl/analysis.html +83 -83
  203. data/solr/server/solr-webapp/webapp/tpl/cloud.html +87 -87
  204. data/solr/server/solr-webapp/webapp/tpl/cores.html +226 -226
  205. data/solr/server/solr-webapp/webapp/tpl/dashboard.html +201 -201
  206. data/solr/server/solr-webapp/webapp/tpl/dataimport.html +183 -183
  207. data/solr/server/solr-webapp/webapp/tpl/documents.html +107 -107
  208. data/solr/server/solr-webapp/webapp/tpl/files.html +44 -44
  209. data/solr/server/solr-webapp/webapp/tpl/index.html +250 -250
  210. data/solr/server/solr-webapp/webapp/tpl/logging.html +23 -23
  211. data/solr/server/solr-webapp/webapp/tpl/plugins.html +39 -39
  212. data/solr/server/solr-webapp/webapp/tpl/query.html +361 -361
  213. data/solr/server/solr-webapp/webapp/tpl/replication.html +216 -216
  214. data/solr/server/solr-webapp/webapp/tpl/schema-browser.html +192 -192
  215. data/solr/server/solr-webapp/webapp/tpl/segments.html +49 -0
  216. data/solr/server/solr-webapp/webapp/tpl/threads.html +56 -56
  217. data/solr/server/solr/README.txt +77 -77
  218. data/solr/server/solr/solr.xml +51 -51
  219. data/solr/server/solr/zoo.cfg +17 -17
  220. data/solr/server/start.jar +0 -0
  221. data/spec/server_spec.rb +3 -8
  222. metadata +132 -43
  223. data/solr/server/lib/jetty-continuation-8.1.10.v20130312.jar +0 -0
  224. data/solr/server/lib/jetty-deploy-8.1.10.v20130312.jar +0 -0
  225. data/solr/server/lib/jetty-http-8.1.10.v20130312.jar +0 -0
  226. data/solr/server/lib/jetty-io-8.1.10.v20130312.jar +0 -0
  227. data/solr/server/lib/jetty-jmx-8.1.10.v20130312.jar +0 -0
  228. data/solr/server/lib/jetty-security-8.1.10.v20130312.jar +0 -0
  229. data/solr/server/lib/jetty-server-8.1.10.v20130312.jar +0 -0
  230. data/solr/server/lib/jetty-servlet-8.1.10.v20130312.jar +0 -0
  231. data/solr/server/lib/jetty-util-8.1.10.v20130312.jar +0 -0
  232. data/solr/server/lib/jetty-webapp-8.1.10.v20130312.jar +0 -0
  233. data/solr/server/lib/jetty-xml-8.1.10.v20130312.jar +0 -0
  234. data/solr/server/lib/servlet-api-3.0.jar +0 -0
  235. data/solr/server/solr-webapp/webapp/.gitignore +0 -1
  236. data/solr/server/solr-webapp/webapp/WEB-INF/lib/hadoop-auth-2.3.0.jar +0 -0
  237. data/solr/server/solr-webapp/webapp/WEB-INF/lib/hadoop-common-2.3.0.jar +0 -0
  238. data/solr/server/solr-webapp/webapp/WEB-INF/lib/hadoop-hdfs-2.3.0.jar +0 -0
  239. data/solr/server/solr-webapp/webapp/WEB-INF/lib/httpclient-4.3.1.jar +0 -0
  240. data/solr/server/solr-webapp/webapp/WEB-INF/lib/httpcore-4.3.jar +0 -0
  241. data/solr/server/solr-webapp/webapp/WEB-INF/lib/httpmime-4.3.1.jar +0 -0
  242. data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-backward-codecs-5.0.0.jar +0 -0
  243. data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-codecs-5.0.0.jar +0 -0
  244. data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-core-5.0.0.jar +0 -0
  245. data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-highlighter-5.0.0.jar +0 -0
  246. data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-join-5.0.0.jar +0 -0
  247. data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-memory-5.0.0.jar +0 -0
  248. data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-misc-5.0.0.jar +0 -0
  249. data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-queries-5.0.0.jar +0 -0
  250. data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-spatial-5.0.0.jar +0 -0
  251. data/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-suggest-5.0.0.jar +0 -0
  252. data/solr/server/solr-webapp/webapp/WEB-INF/lib/org.restlet-2.1.1.jar +0 -0
  253. data/solr/server/solr-webapp/webapp/WEB-INF/lib/org.restlet.ext.servlet-2.1.1.jar +0 -0
  254. data/solr/server/solr-webapp/webapp/WEB-INF/lib/solr-core-5.0.0.jar +0 -0
  255. data/solr/server/solr-webapp/webapp/WEB-INF/lib/solr-solrj-5.0.0.jar +0 -0
  256. data/solr/server/webapps/solr.war +0 -0
@@ -1,982 +1,982 @@
1
- /*
2
-
3
- Chosen
4
-
5
- - by Patrick Filler for Harvest http://getharvest.com
6
- - Copyright (c) 2011-2013 by Harvest
7
-
8
- Available for use under the MIT License
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in
18
- all copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
- THE SOFTWARE.
27
-
28
- */
29
-
30
- // Chosen, a Select Box Enhancer for jQuery and Protoype
31
- // by Patrick Filler for Harvest, http://getharvest.com
32
- //
33
- // Version 0.9.8
34
- // Full source at https://github.com/harvesthq/chosen
35
- // Copyright (c) 2011 Harvest http://getharvest.com
36
-
37
- // MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
38
- // This file is generated by `cake build`, do not edit it by hand.
39
- (function() {
40
- var SelectParser;
41
-
42
- SelectParser = (function() {
43
-
44
- function SelectParser() {
45
- this.options_index = 0;
46
- this.parsed = [];
47
- }
48
-
49
- SelectParser.prototype.add_node = function(child) {
50
- if (child.nodeName === "OPTGROUP") {
51
- return this.add_group(child);
52
- } else {
53
- return this.add_option(child);
54
- }
55
- };
56
-
57
- SelectParser.prototype.add_group = function(group) {
58
- var group_position, option, _i, _len, _ref, _results;
59
- group_position = this.parsed.length;
60
- this.parsed.push({
61
- array_index: group_position,
62
- group: true,
63
- label: group.label,
64
- children: 0,
65
- disabled: group.disabled
66
- });
67
- _ref = group.childNodes;
68
- _results = [];
69
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
70
- option = _ref[_i];
71
- _results.push(this.add_option(option, group_position, group.disabled));
72
- }
73
- return _results;
74
- };
75
-
76
- SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
77
- if (option.nodeName === "OPTION") {
78
- if (option.text !== "") {
79
- if (group_position != null) this.parsed[group_position].children += 1;
80
- this.parsed.push({
81
- array_index: this.parsed.length,
82
- options_index: this.options_index,
83
- value: option.value,
84
- text: option.text,
85
- html: option.innerHTML,
86
- selected: option.selected,
87
- disabled: group_disabled === true ? group_disabled : option.disabled,
88
- group_array_index: group_position,
89
- classes: option.className,
90
- style: option.style.cssText
91
- });
92
- } else {
93
- this.parsed.push({
94
- array_index: this.parsed.length,
95
- options_index: this.options_index,
96
- empty: true
97
- });
98
- }
99
- return this.options_index += 1;
100
- }
101
- };
102
-
103
- return SelectParser;
104
-
105
- })();
106
-
107
- SelectParser.select_to_array = function(select) {
108
- var child, parser, _i, _len, _ref;
109
- parser = new SelectParser();
110
- _ref = select.childNodes;
111
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
112
- child = _ref[_i];
113
- parser.add_node(child);
114
- }
115
- return parser.parsed;
116
- };
117
-
118
- this.SelectParser = SelectParser;
119
-
120
- }).call(this);
121
-
122
- /*
123
- Chosen source: generate output using 'cake build'
124
- Copyright (c) 2011 by Harvest
125
- */
126
-
127
- (function() {
128
- var AbstractChosen, root;
129
-
130
- root = this;
131
-
132
- AbstractChosen = (function() {
133
-
134
- function AbstractChosen(form_field, options) {
135
- this.form_field = form_field;
136
- this.options = options != null ? options : {};
137
- this.set_default_values();
138
- this.is_multiple = this.form_field.multiple;
139
- this.default_text_default = this.is_multiple ? "Select Some Options" : "Select an Option";
140
- this.setup();
141
- this.set_up_html();
142
- this.register_observers();
143
- this.finish_setup();
144
- }
145
-
146
- AbstractChosen.prototype.set_default_values = function() {
147
- var _this = this;
148
- this.click_test_action = function(evt) {
149
- return _this.test_active_click(evt);
150
- };
151
- this.activate_action = function(evt) {
152
- return _this.activate_field(evt);
153
- };
154
- this.active_field = false;
155
- this.mouse_on_container = false;
156
- this.results_showing = false;
157
- this.result_highlighted = null;
158
- this.result_single_selected = null;
159
- this.allow_single_deselect = (this.options.allow_single_deselect != null) && (this.form_field.options[0] != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
160
- this.disable_search_threshold = this.options.disable_search_threshold || 0;
161
- this.search_contains = this.options.search_contains || false;
162
- this.choices = 0;
163
- return this.results_none_found = this.options.no_results_text || "No results match";
164
- };
165
-
166
- AbstractChosen.prototype.mouse_enter = function() {
167
- return this.mouse_on_container = true;
168
- };
169
-
170
- AbstractChosen.prototype.mouse_leave = function() {
171
- return this.mouse_on_container = false;
172
- };
173
-
174
- AbstractChosen.prototype.input_focus = function(evt) {
175
- var _this = this;
176
- if (!this.active_field) {
177
- return setTimeout((function() {
178
- return _this.container_mousedown();
179
- }), 50);
180
- }
181
- };
182
-
183
- AbstractChosen.prototype.input_blur = function(evt) {
184
- var _this = this;
185
- if (!this.mouse_on_container) {
186
- this.active_field = false;
187
- return setTimeout((function() {
188
- return _this.blur_test();
189
- }), 100);
190
- }
191
- };
192
-
193
- AbstractChosen.prototype.result_add_option = function(option) {
194
- var classes, style;
195
- if (!option.disabled) {
196
- option.dom_id = this.container_id + "_o_" + option.array_index;
197
- classes = option.selected && this.is_multiple ? [] : ["active-result"];
198
- if (option.selected) classes.push("result-selected");
199
- if (option.group_array_index != null) classes.push("group-option");
200
- if (option.classes !== "") classes.push(option.classes);
201
- style = option.style.cssText !== "" ? " style=\"" + option.style + "\"" : "";
202
- return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"' + style + '>' + option.html + '</li>';
203
- } else {
204
- return "";
205
- }
206
- };
207
-
208
- AbstractChosen.prototype.results_update_field = function() {
209
- this.result_clear_highlight();
210
- this.result_single_selected = null;
211
- return this.results_build();
212
- };
213
-
214
- AbstractChosen.prototype.results_toggle = function() {
215
- if (this.results_showing) {
216
- return this.results_hide();
217
- } else {
218
- return this.results_show();
219
- }
220
- };
221
-
222
- AbstractChosen.prototype.results_search = function(evt) {
223
- if (this.results_showing) {
224
- return this.winnow_results();
225
- } else {
226
- return this.results_show();
227
- }
228
- };
229
-
230
- AbstractChosen.prototype.keyup_checker = function(evt) {
231
- var stroke, _ref;
232
- stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
233
- this.search_field_scale();
234
- switch (stroke) {
235
- case 8:
236
- if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) {
237
- return this.keydown_backstroke();
238
- } else if (!this.pending_backstroke) {
239
- this.result_clear_highlight();
240
- return this.results_search();
241
- }
242
- break;
243
- case 13:
244
- evt.preventDefault();
245
- if (this.results_showing) return this.result_select(evt);
246
- break;
247
- case 27:
248
- if (this.results_showing) this.results_hide();
249
- return true;
250
- case 9:
251
- case 38:
252
- case 40:
253
- case 16:
254
- case 91:
255
- case 17:
256
- break;
257
- default:
258
- return this.results_search();
259
- }
260
- };
261
-
262
- AbstractChosen.prototype.generate_field_id = function() {
263
- var new_id;
264
- new_id = this.generate_random_id();
265
- this.form_field.id = new_id;
266
- return new_id;
267
- };
268
-
269
- AbstractChosen.prototype.generate_random_char = function() {
270
- var chars, newchar, rand;
271
- chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ";
272
- rand = Math.floor(Math.random() * chars.length);
273
- return newchar = chars.substring(rand, rand + 1);
274
- };
275
-
276
- return AbstractChosen;
277
-
278
- })();
279
-
280
- root.AbstractChosen = AbstractChosen;
281
-
282
- }).call(this);
283
-
284
- /*
285
- Chosen source: generate output using 'cake build'
286
- Copyright (c) 2011 by Harvest
287
- */
288
-
289
- (function() {
290
- var $, Chosen, get_side_border_padding, root,
291
- __hasProp = Object.prototype.hasOwnProperty,
292
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
293
-
294
- root = this;
295
-
296
- $ = jQuery;
297
-
298
- $.fn.extend({
299
- chosen: function(options) {
300
- if ($.browser.msie && ($.browser.version === "6.0" || $.browser.version === "7.0")) {
301
- return this;
302
- }
303
- return $(this).each(function(input_field) {
304
- if (!($(this)).hasClass("chzn-done")) return new Chosen(this, options);
305
- });
306
- }
307
- });
308
-
309
- Chosen = (function(_super) {
310
-
311
- __extends(Chosen, _super);
312
-
313
- function Chosen() {
314
- Chosen.__super__.constructor.apply(this, arguments);
315
- }
316
-
317
- Chosen.prototype.setup = function() {
318
- this.form_field_jq = $(this.form_field);
319
- return this.is_rtl = this.form_field_jq.hasClass("chzn-rtl");
320
- };
321
-
322
- Chosen.prototype.finish_setup = function() {
323
- return this.form_field_jq.addClass("chzn-done");
324
- };
325
-
326
- Chosen.prototype.set_up_html = function() {
327
- var container_div, dd_top, dd_width, sf_width;
328
- this.container_id = this.form_field.id.length ? this.form_field.id.replace(/(:|\.)/g, '_') : this.generate_field_id();
329
- this.container_id += "_chzn";
330
- this.f_width = this.form_field_jq.outerWidth();
331
- this.default_text = this.form_field_jq.data('placeholder') ? this.form_field_jq.data('placeholder') : this.default_text_default;
332
- container_div = $("<div />", {
333
- id: this.container_id,
334
- "class": "chzn-container" + (this.is_rtl ? ' chzn-rtl' : ''),
335
- style: 'width: ' + this.f_width + 'px;'
336
- });
337
- if (this.is_multiple) {
338
- container_div.html('<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + this.default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>');
339
- } else {
340
- container_div.html('<a href="javascript:void(0)" class="chzn-single chzn-default"><span>' + this.default_text + '</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="search" autocomplete="off" /></div><ul class="chzn-results"></ul></div>');
341
- }
342
- this.form_field_jq.hide().after(container_div);
343
- this.container = $('#' + this.container_id);
344
- this.container.addClass("chzn-container-" + (this.is_multiple ? "multi" : "single"));
345
- this.dropdown = this.container.find('div.chzn-drop').first();
346
- dd_top = this.container.height();
347
- dd_width = this.f_width - get_side_border_padding(this.dropdown);
348
- this.dropdown.css({
349
- "width": dd_width + "px",
350
- "top": dd_top + "px"
351
- });
352
- this.search_field = this.container.find('input').first();
353
- this.search_results = this.container.find('ul.chzn-results').first();
354
- this.search_field_scale();
355
- this.search_no_results = this.container.find('li.no-results').first();
356
- if (this.is_multiple) {
357
- this.search_choices = this.container.find('ul.chzn-choices').first();
358
- this.search_container = this.container.find('li.search-field').first();
359
- } else {
360
- this.search_container = this.container.find('div.chzn-search').first();
361
- this.selected_item = this.container.find('.chzn-single').first();
362
- sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field);
363
- sf_width = dd_width - get_side_border_padding(this.search_container);
364
- this.search_field.css({
365
- "width": sf_width + "px"
366
- });
367
- }
368
- this.results_build();
369
- this.set_tab_index();
370
- return this.form_field_jq.trigger("liszt:ready", {
371
- chosen: this
372
- });
373
- };
374
-
375
- Chosen.prototype.register_observers = function() {
376
- var _this = this;
377
- this.container.mousedown(function(evt) {
378
- return _this.container_mousedown(evt);
379
- });
380
- this.container.mouseup(function(evt) {
381
- return _this.container_mouseup(evt);
382
- });
383
- this.container.mouseenter(function(evt) {
384
- return _this.mouse_enter(evt);
385
- });
386
- this.container.mouseleave(function(evt) {
387
- return _this.mouse_leave(evt);
388
- });
389
- this.search_results.mouseup(function(evt) {
390
- return _this.search_results_mouseup(evt);
391
- });
392
- this.search_results.mouseover(function(evt) {
393
- return _this.search_results_mouseover(evt);
394
- });
395
- this.search_results.mouseout(function(evt) {
396
- return _this.search_results_mouseout(evt);
397
- });
398
- this.form_field_jq.bind("liszt:updated", function(evt) {
399
- return _this.results_update_field(evt);
400
- });
401
- this.search_field.blur(function(evt) {
402
- return _this.input_blur(evt);
403
- });
404
- this.search_field.keyup(function(evt) {
405
- return _this.keyup_checker(evt);
406
- });
407
- this.search_field.keydown(function(evt) {
408
- return _this.keydown_checker(evt);
409
- });
410
- if (this.is_multiple) {
411
- this.search_choices.click(function(evt) {
412
- return _this.choices_click(evt);
413
- });
414
- return this.search_field.focus(function(evt) {
415
- return _this.input_focus(evt);
416
- });
417
- } else {
418
- return this.container.click(function(evt) {
419
- return evt.preventDefault();
420
- });
421
- }
422
- };
423
-
424
- Chosen.prototype.search_field_disabled = function() {
425
- this.is_disabled = this.form_field_jq[0].disabled;
426
- if (this.is_disabled) {
427
- this.container.addClass('chzn-disabled');
428
- this.search_field[0].disabled = true;
429
- if (!this.is_multiple) {
430
- this.selected_item.unbind("focus", this.activate_action);
431
- }
432
- return this.close_field();
433
- } else {
434
- this.container.removeClass('chzn-disabled');
435
- this.search_field[0].disabled = false;
436
- if (!this.is_multiple) {
437
- return this.selected_item.bind("focus", this.activate_action);
438
- }
439
- }
440
- };
441
-
442
- Chosen.prototype.container_mousedown = function(evt) {
443
- var target_closelink;
444
- if (!this.is_disabled) {
445
- target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false;
446
- if (evt && evt.type === "mousedown" && !this.results_showing) {
447
- evt.stopPropagation();
448
- }
449
- if (!this.pending_destroy_click && !target_closelink) {
450
- if (!this.active_field) {
451
- if (this.is_multiple) this.search_field.val("");
452
- $(document).click(this.click_test_action);
453
- this.results_show();
454
- } else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chzn-single").length)) {
455
- evt.preventDefault();
456
- this.results_toggle();
457
- }
458
- return this.activate_field();
459
- } else {
460
- return this.pending_destroy_click = false;
461
- }
462
- }
463
- };
464
-
465
- Chosen.prototype.container_mouseup = function(evt) {
466
- if (evt.target.nodeName === "ABBR") return this.results_reset(evt);
467
- };
468
-
469
- Chosen.prototype.blur_test = function(evt) {
470
- if (!this.active_field && this.container.hasClass("chzn-container-active")) {
471
- return this.close_field();
472
- }
473
- };
474
-
475
- Chosen.prototype.close_field = function() {
476
- $(document).unbind("click", this.click_test_action);
477
- if (!this.is_multiple) {
478
- this.selected_item.attr("tabindex", this.search_field.attr("tabindex"));
479
- this.search_field.attr("tabindex", -1);
480
- }
481
- this.active_field = false;
482
- this.results_hide();
483
- this.container.removeClass("chzn-container-active");
484
- this.winnow_results_clear();
485
- this.clear_backstroke();
486
- this.show_search_field_default();
487
- return this.search_field_scale();
488
- };
489
-
490
- Chosen.prototype.activate_field = function() {
491
- if (!this.is_multiple && !this.active_field) {
492
- this.search_field.attr("tabindex", this.selected_item.attr("tabindex"));
493
- this.selected_item.attr("tabindex", -1);
494
- }
495
- this.container.addClass("chzn-container-active");
496
- this.active_field = true;
497
- this.search_field.val(this.search_field.val());
498
- return this.search_field.focus();
499
- };
500
-
501
- Chosen.prototype.test_active_click = function(evt) {
502
- if ($(evt.target).parents('#' + this.container_id).length) {
503
- return this.active_field = true;
504
- } else {
505
- return this.close_field();
506
- }
507
- };
508
-
509
- Chosen.prototype.results_build = function() {
510
- var content, data, _i, _len, _ref;
511
- this.parsing = true;
512
- this.results_data = root.SelectParser.select_to_array(this.form_field);
513
- if (this.is_multiple && this.choices > 0) {
514
- this.search_choices.find("li.search-choice").remove();
515
- this.choices = 0;
516
- } else if (!this.is_multiple) {
517
- this.selected_item.find("span").text(this.default_text);
518
- if (this.form_field.options.length <= this.disable_search_threshold) {
519
- this.container.addClass("chzn-container-single-nosearch");
520
- } else {
521
- this.container.removeClass("chzn-container-single-nosearch");
522
- }
523
- }
524
- content = '';
525
- _ref = this.results_data;
526
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
527
- data = _ref[_i];
528
- if (data.group) {
529
- content += this.result_add_group(data);
530
- } else if (!data.empty) {
531
- content += this.result_add_option(data);
532
- if (data.selected && this.is_multiple) {
533
- this.choice_build(data);
534
- } else if (data.selected && !this.is_multiple) {
535
- this.selected_item.removeClass("chzn-default").find("span").text(data.text);
536
- if (this.allow_single_deselect) this.single_deselect_control_build();
537
- }
538
- }
539
- }
540
- this.search_field_disabled();
541
- this.show_search_field_default();
542
- this.search_field_scale();
543
- this.search_results.html(content);
544
- return this.parsing = false;
545
- };
546
-
547
- Chosen.prototype.result_add_group = function(group) {
548
- if (!group.disabled) {
549
- group.dom_id = this.container_id + "_g_" + group.array_index;
550
- return '<li id="' + group.dom_id + '" class="group-result">' + $("<div />").text(group.label).html() + '</li>';
551
- } else {
552
- return "";
553
- }
554
- };
555
-
556
- Chosen.prototype.result_do_highlight = function(el) {
557
- var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
558
- if (el.length) {
559
- this.result_clear_highlight();
560
- this.result_highlight = el;
561
- this.result_highlight.addClass("highlighted");
562
- maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
563
- visible_top = this.search_results.scrollTop();
564
- visible_bottom = maxHeight + visible_top;
565
- high_top = this.result_highlight.position().top + this.search_results.scrollTop();
566
- high_bottom = high_top + this.result_highlight.outerHeight();
567
- if (high_bottom >= visible_bottom) {
568
- return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0);
569
- } else if (high_top < visible_top) {
570
- return this.search_results.scrollTop(high_top);
571
- }
572
- }
573
- };
574
-
575
- Chosen.prototype.result_clear_highlight = function() {
576
- if (this.result_highlight) this.result_highlight.removeClass("highlighted");
577
- return this.result_highlight = null;
578
- };
579
-
580
- Chosen.prototype.results_show = function() {
581
- var dd_top;
582
- if (!this.is_multiple) {
583
- this.selected_item.addClass("chzn-single-with-drop");
584
- if (this.result_single_selected) {
585
- this.result_do_highlight(this.result_single_selected);
586
- }
587
- }
588
- dd_top = this.is_multiple ? this.container.height() : this.container.height() - 1;
589
- this.dropdown.css({
590
- "top": dd_top + "px",
591
- "left": 0
592
- });
593
- this.results_showing = true;
594
- this.search_field.focus();
595
- this.search_field.val(this.search_field.val());
596
- return this.winnow_results();
597
- };
598
-
599
- Chosen.prototype.results_hide = function() {
600
- if (!this.is_multiple) {
601
- this.selected_item.removeClass("chzn-single-with-drop");
602
- }
603
- this.result_clear_highlight();
604
- this.dropdown.css({
605
- "left": "-9000px"
606
- });
607
- return this.results_showing = false;
608
- };
609
-
610
- Chosen.prototype.set_tab_index = function(el) {
611
- var ti;
612
- if (this.form_field_jq.attr("tabindex")) {
613
- ti = this.form_field_jq.attr("tabindex");
614
- this.form_field_jq.attr("tabindex", -1);
615
- if (this.is_multiple) {
616
- return this.search_field.attr("tabindex", ti);
617
- } else {
618
- this.selected_item.attr("tabindex", ti);
619
- return this.search_field.attr("tabindex", -1);
620
- }
621
- }
622
- };
623
-
624
- Chosen.prototype.show_search_field_default = function() {
625
- if (this.is_multiple && this.choices < 1 && !this.active_field) {
626
- this.search_field.val(this.default_text);
627
- return this.search_field.addClass("default");
628
- } else {
629
- this.search_field.val("");
630
- return this.search_field.removeClass("default");
631
- }
632
- };
633
-
634
- Chosen.prototype.search_results_mouseup = function(evt) {
635
- var target;
636
- target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
637
- if (target.length) {
638
- this.result_highlight = target;
639
- return this.result_select(evt);
640
- }
641
- };
642
-
643
- Chosen.prototype.search_results_mouseover = function(evt) {
644
- var target;
645
- target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
646
- if (target) return this.result_do_highlight(target);
647
- };
648
-
649
- Chosen.prototype.search_results_mouseout = function(evt) {
650
- if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
651
- return this.result_clear_highlight();
652
- }
653
- };
654
-
655
- Chosen.prototype.choices_click = function(evt) {
656
- evt.preventDefault();
657
- if (this.active_field && !($(evt.target).hasClass("search-choice" || $(evt.target).parents('.search-choice').first)) && !this.results_showing) {
658
- return this.results_show();
659
- }
660
- };
661
-
662
- Chosen.prototype.choice_build = function(item) {
663
- var choice_id, link,
664
- _this = this;
665
- choice_id = this.container_id + "_c_" + item.array_index;
666
- this.choices += 1;
667
- this.search_container.before('<li class="search-choice" id="' + choice_id + '"><span>' + item.html + '</span><a href="javascript:void(0)" class="search-choice-close" rel="' + item.array_index + '"></a></li>');
668
- link = $('#' + choice_id).find("a").first();
669
- return link.click(function(evt) {
670
- return _this.choice_destroy_link_click(evt);
671
- });
672
- };
673
-
674
- Chosen.prototype.choice_destroy_link_click = function(evt) {
675
- evt.preventDefault();
676
- if (!this.is_disabled) {
677
- this.pending_destroy_click = true;
678
- return this.choice_destroy($(evt.target));
679
- } else {
680
- return evt.stopPropagation;
681
- }
682
- };
683
-
684
- Chosen.prototype.choice_destroy = function(link) {
685
- this.choices -= 1;
686
- this.show_search_field_default();
687
- if (this.is_multiple && this.choices > 0 && this.search_field.val().length < 1) {
688
- this.results_hide();
689
- }
690
- this.result_deselect(link.attr("rel"));
691
- return link.parents('li').first().remove();
692
- };
693
-
694
- Chosen.prototype.results_reset = function(evt) {
695
- this.form_field.options[0].selected = true;
696
- this.selected_item.find("span").text(this.default_text);
697
- if (!this.is_multiple) this.selected_item.addClass("chzn-default");
698
- this.show_search_field_default();
699
- $(evt.target).remove();
700
- this.form_field_jq.trigger("change");
701
- if (this.active_field) return this.results_hide();
702
- };
703
-
704
- Chosen.prototype.result_select = function(evt) {
705
- var high, high_id, item, position;
706
- if (this.result_highlight) {
707
- high = this.result_highlight;
708
- high_id = high.attr("id");
709
- this.result_clear_highlight();
710
- if (this.is_multiple) {
711
- this.result_deactivate(high);
712
- } else {
713
- this.search_results.find(".result-selected").removeClass("result-selected");
714
- this.result_single_selected = high;
715
- this.selected_item.removeClass("chzn-default");
716
- }
717
- high.addClass("result-selected");
718
- position = high_id.substr(high_id.lastIndexOf("_") + 1);
719
- item = this.results_data[position];
720
- item.selected = true;
721
- this.form_field.options[item.options_index].selected = true;
722
- if (this.is_multiple) {
723
- this.choice_build(item);
724
- } else {
725
- this.selected_item.find("span").first().text(item.text);
726
- if (this.allow_single_deselect) this.single_deselect_control_build();
727
- }
728
- if (!(evt.metaKey && this.is_multiple)) this.results_hide();
729
- this.search_field.val("");
730
- this.form_field_jq.trigger("change");
731
- return this.search_field_scale();
732
- }
733
- };
734
-
735
- Chosen.prototype.result_activate = function(el) {
736
- return el.addClass("active-result");
737
- };
738
-
739
- Chosen.prototype.result_deactivate = function(el) {
740
- return el.removeClass("active-result");
741
- };
742
-
743
- Chosen.prototype.result_deselect = function(pos) {
744
- var result, result_data;
745
- result_data = this.results_data[pos];
746
- result_data.selected = false;
747
- this.form_field.options[result_data.options_index].selected = false;
748
- result = $("#" + this.container_id + "_o_" + pos);
749
- result.removeClass("result-selected").addClass("active-result").show();
750
- this.result_clear_highlight();
751
- this.winnow_results();
752
- this.form_field_jq.trigger("change");
753
- return this.search_field_scale();
754
- };
755
-
756
- Chosen.prototype.single_deselect_control_build = function() {
757
- if (this.allow_single_deselect && this.selected_item.find("abbr").length < 1) {
758
- return this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
759
- }
760
- };
761
-
762
- Chosen.prototype.winnow_results = function() {
763
- var found, option, part, parts, regex, regexAnchor, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref;
764
- this.no_results_clear();
765
- results = 0;
766
- searchText = this.search_field.val() === this.default_text ? "" : $('<div/>').text($.trim(this.search_field.val())).html();
767
- regexAnchor = this.search_contains ? "" : "^";
768
- regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
769
- zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
770
- _ref = this.results_data;
771
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
772
- option = _ref[_i];
773
- if (!option.disabled && !option.empty) {
774
- if (option.group) {
775
- $('#' + option.dom_id).css('display', 'none');
776
- } else if (!(this.is_multiple && option.selected)) {
777
- found = false;
778
- result_id = option.dom_id;
779
- result = $("#" + result_id);
780
- if (regex.test(option.html)) {
781
- found = true;
782
- results += 1;
783
- } else if (option.html.indexOf(" ") >= 0 || option.html.indexOf("[") === 0) {
784
- parts = option.html.replace(/\[|\]/g, "").split(" ");
785
- if (parts.length) {
786
- for (_j = 0, _len2 = parts.length; _j < _len2; _j++) {
787
- part = parts[_j];
788
- if (regex.test(part)) {
789
- found = true;
790
- results += 1;
791
- }
792
- }
793
- }
794
- }
795
- if (found) {
796
- if (searchText.length) {
797
- startpos = option.html.search(zregex);
798
- text = option.html.substr(0, startpos + searchText.length) + '</em>' + option.html.substr(startpos + searchText.length);
799
- text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
800
- } else {
801
- text = option.html;
802
- }
803
- result.html(text);
804
- this.result_activate(result);
805
- if (option.group_array_index != null) {
806
- $("#" + this.results_data[option.group_array_index].dom_id).css('display', 'list-item');
807
- }
808
- } else {
809
- if (this.result_highlight && result_id === this.result_highlight.attr('id')) {
810
- this.result_clear_highlight();
811
- }
812
- this.result_deactivate(result);
813
- }
814
- }
815
- }
816
- }
817
- if (results < 1 && searchText.length) {
818
- return this.no_results(searchText);
819
- } else {
820
- return this.winnow_results_set_highlight();
821
- }
822
- };
823
-
824
- Chosen.prototype.winnow_results_clear = function() {
825
- var li, lis, _i, _len, _results;
826
- this.search_field.val("");
827
- lis = this.search_results.find("li");
828
- _results = [];
829
- for (_i = 0, _len = lis.length; _i < _len; _i++) {
830
- li = lis[_i];
831
- li = $(li);
832
- if (li.hasClass("group-result")) {
833
- _results.push(li.css('display', 'auto'));
834
- } else if (!this.is_multiple || !li.hasClass("result-selected")) {
835
- _results.push(this.result_activate(li));
836
- } else {
837
- _results.push(void 0);
838
- }
839
- }
840
- return _results;
841
- };
842
-
843
- Chosen.prototype.winnow_results_set_highlight = function() {
844
- var do_high, selected_results;
845
- if (!this.result_highlight) {
846
- selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
847
- do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
848
- if (do_high != null) return this.result_do_highlight(do_high);
849
- }
850
- };
851
-
852
- Chosen.prototype.no_results = function(terms) {
853
- var no_results_html;
854
- no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
855
- no_results_html.find("span").first().html(terms);
856
- return this.search_results.append(no_results_html);
857
- };
858
-
859
- Chosen.prototype.no_results_clear = function() {
860
- return this.search_results.find(".no-results").remove();
861
- };
862
-
863
- Chosen.prototype.keydown_arrow = function() {
864
- var first_active, next_sib;
865
- if (!this.result_highlight) {
866
- first_active = this.search_results.find("li.active-result").first();
867
- if (first_active) this.result_do_highlight($(first_active));
868
- } else if (this.results_showing) {
869
- next_sib = this.result_highlight.nextAll("li.active-result").first();
870
- if (next_sib) this.result_do_highlight(next_sib);
871
- }
872
- if (!this.results_showing) return this.results_show();
873
- };
874
-
875
- Chosen.prototype.keyup_arrow = function() {
876
- var prev_sibs;
877
- if (!this.results_showing && !this.is_multiple) {
878
- return this.results_show();
879
- } else if (this.result_highlight) {
880
- prev_sibs = this.result_highlight.prevAll("li.active-result");
881
- if (prev_sibs.length) {
882
- return this.result_do_highlight(prev_sibs.first());
883
- } else {
884
- if (this.choices > 0) this.results_hide();
885
- return this.result_clear_highlight();
886
- }
887
- }
888
- };
889
-
890
- Chosen.prototype.keydown_backstroke = function() {
891
- if (this.pending_backstroke) {
892
- this.choice_destroy(this.pending_backstroke.find("a").first());
893
- return this.clear_backstroke();
894
- } else {
895
- this.pending_backstroke = this.search_container.siblings("li.search-choice").last();
896
- return this.pending_backstroke.addClass("search-choice-focus");
897
- }
898
- };
899
-
900
- Chosen.prototype.clear_backstroke = function() {
901
- if (this.pending_backstroke) {
902
- this.pending_backstroke.removeClass("search-choice-focus");
903
- }
904
- return this.pending_backstroke = null;
905
- };
906
-
907
- Chosen.prototype.keydown_checker = function(evt) {
908
- var stroke, _ref;
909
- stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
910
- this.search_field_scale();
911
- if (stroke !== 8 && this.pending_backstroke) this.clear_backstroke();
912
- switch (stroke) {
913
- case 8:
914
- this.backstroke_length = this.search_field.val().length;
915
- break;
916
- case 9:
917
- if (this.results_showing && !this.is_multiple) this.result_select(evt);
918
- this.mouse_on_container = false;
919
- break;
920
- case 13:
921
- evt.preventDefault();
922
- break;
923
- case 38:
924
- evt.preventDefault();
925
- this.keyup_arrow();
926
- break;
927
- case 40:
928
- this.keydown_arrow();
929
- break;
930
- }
931
- };
932
-
933
- Chosen.prototype.search_field_scale = function() {
934
- var dd_top, div, h, style, style_block, styles, w, _i, _len;
935
- if (this.is_multiple) {
936
- h = 0;
937
- w = 0;
938
- style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
939
- styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
940
- for (_i = 0, _len = styles.length; _i < _len; _i++) {
941
- style = styles[_i];
942
- style_block += style + ":" + this.search_field.css(style) + ";";
943
- }
944
- div = $('<div />', {
945
- 'style': style_block
946
- });
947
- div.text(this.search_field.val());
948
- $('body').append(div);
949
- w = div.width() + 25;
950
- div.remove();
951
- if (w > this.f_width - 10) w = this.f_width - 10;
952
- this.search_field.css({
953
- 'width': w + 'px'
954
- });
955
- dd_top = this.container.height();
956
- return this.dropdown.css({
957
- "top": dd_top + "px"
958
- });
959
- }
960
- };
961
-
962
- Chosen.prototype.generate_random_id = function() {
963
- var string;
964
- string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char();
965
- while ($("#" + string).length > 0) {
966
- string += this.generate_random_char();
967
- }
968
- return string;
969
- };
970
-
971
- return Chosen;
972
-
973
- })(AbstractChosen);
974
-
975
- get_side_border_padding = function(elmt) {
976
- var side_border_padding;
977
- return side_border_padding = elmt.outerWidth() - elmt.width();
978
- };
979
-
980
- root.get_side_border_padding = get_side_border_padding;
981
-
982
- }).call(this);
1
+ /*
2
+
3
+ Chosen
4
+
5
+ - by Patrick Filler for Harvest http://getharvest.com
6
+ - Copyright (c) 2011-2013 by Harvest
7
+
8
+ Available for use under the MIT License
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in
18
+ all copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
+ THE SOFTWARE.
27
+
28
+ */
29
+
30
+ // Chosen, a Select Box Enhancer for jQuery and Protoype
31
+ // by Patrick Filler for Harvest, http://getharvest.com
32
+ //
33
+ // Version 0.9.8
34
+ // Full source at https://github.com/harvesthq/chosen
35
+ // Copyright (c) 2011 Harvest http://getharvest.com
36
+
37
+ // MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
38
+ // This file is generated by `cake build`, do not edit it by hand.
39
+ (function() {
40
+ var SelectParser;
41
+
42
+ SelectParser = (function() {
43
+
44
+ function SelectParser() {
45
+ this.options_index = 0;
46
+ this.parsed = [];
47
+ }
48
+
49
+ SelectParser.prototype.add_node = function(child) {
50
+ if (child.nodeName === "OPTGROUP") {
51
+ return this.add_group(child);
52
+ } else {
53
+ return this.add_option(child);
54
+ }
55
+ };
56
+
57
+ SelectParser.prototype.add_group = function(group) {
58
+ var group_position, option, _i, _len, _ref, _results;
59
+ group_position = this.parsed.length;
60
+ this.parsed.push({
61
+ array_index: group_position,
62
+ group: true,
63
+ label: group.label,
64
+ children: 0,
65
+ disabled: group.disabled
66
+ });
67
+ _ref = group.childNodes;
68
+ _results = [];
69
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
70
+ option = _ref[_i];
71
+ _results.push(this.add_option(option, group_position, group.disabled));
72
+ }
73
+ return _results;
74
+ };
75
+
76
+ SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
77
+ if (option.nodeName === "OPTION") {
78
+ if (option.text !== "") {
79
+ if (group_position != null) this.parsed[group_position].children += 1;
80
+ this.parsed.push({
81
+ array_index: this.parsed.length,
82
+ options_index: this.options_index,
83
+ value: option.value,
84
+ text: option.text,
85
+ html: option.innerHTML,
86
+ selected: option.selected,
87
+ disabled: group_disabled === true ? group_disabled : option.disabled,
88
+ group_array_index: group_position,
89
+ classes: option.className,
90
+ style: option.style.cssText
91
+ });
92
+ } else {
93
+ this.parsed.push({
94
+ array_index: this.parsed.length,
95
+ options_index: this.options_index,
96
+ empty: true
97
+ });
98
+ }
99
+ return this.options_index += 1;
100
+ }
101
+ };
102
+
103
+ return SelectParser;
104
+
105
+ })();
106
+
107
+ SelectParser.select_to_array = function(select) {
108
+ var child, parser, _i, _len, _ref;
109
+ parser = new SelectParser();
110
+ _ref = select.childNodes;
111
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
112
+ child = _ref[_i];
113
+ parser.add_node(child);
114
+ }
115
+ return parser.parsed;
116
+ };
117
+
118
+ this.SelectParser = SelectParser;
119
+
120
+ }).call(this);
121
+
122
+ /*
123
+ Chosen source: generate output using 'cake build'
124
+ Copyright (c) 2011 by Harvest
125
+ */
126
+
127
+ (function() {
128
+ var AbstractChosen, root;
129
+
130
+ root = this;
131
+
132
+ AbstractChosen = (function() {
133
+
134
+ function AbstractChosen(form_field, options) {
135
+ this.form_field = form_field;
136
+ this.options = options != null ? options : {};
137
+ this.set_default_values();
138
+ this.is_multiple = this.form_field.multiple;
139
+ this.default_text_default = this.is_multiple ? "Select Some Options" : "Select an Option";
140
+ this.setup();
141
+ this.set_up_html();
142
+ this.register_observers();
143
+ this.finish_setup();
144
+ }
145
+
146
+ AbstractChosen.prototype.set_default_values = function() {
147
+ var _this = this;
148
+ this.click_test_action = function(evt) {
149
+ return _this.test_active_click(evt);
150
+ };
151
+ this.activate_action = function(evt) {
152
+ return _this.activate_field(evt);
153
+ };
154
+ this.active_field = false;
155
+ this.mouse_on_container = false;
156
+ this.results_showing = false;
157
+ this.result_highlighted = null;
158
+ this.result_single_selected = null;
159
+ this.allow_single_deselect = (this.options.allow_single_deselect != null) && (this.form_field.options[0] != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
160
+ this.disable_search_threshold = this.options.disable_search_threshold || 0;
161
+ this.search_contains = this.options.search_contains || false;
162
+ this.choices = 0;
163
+ return this.results_none_found = this.options.no_results_text || "No results match";
164
+ };
165
+
166
+ AbstractChosen.prototype.mouse_enter = function() {
167
+ return this.mouse_on_container = true;
168
+ };
169
+
170
+ AbstractChosen.prototype.mouse_leave = function() {
171
+ return this.mouse_on_container = false;
172
+ };
173
+
174
+ AbstractChosen.prototype.input_focus = function(evt) {
175
+ var _this = this;
176
+ if (!this.active_field) {
177
+ return setTimeout((function() {
178
+ return _this.container_mousedown();
179
+ }), 50);
180
+ }
181
+ };
182
+
183
+ AbstractChosen.prototype.input_blur = function(evt) {
184
+ var _this = this;
185
+ if (!this.mouse_on_container) {
186
+ this.active_field = false;
187
+ return setTimeout((function() {
188
+ return _this.blur_test();
189
+ }), 100);
190
+ }
191
+ };
192
+
193
+ AbstractChosen.prototype.result_add_option = function(option) {
194
+ var classes, style;
195
+ if (!option.disabled) {
196
+ option.dom_id = this.container_id + "_o_" + option.array_index;
197
+ classes = option.selected && this.is_multiple ? [] : ["active-result"];
198
+ if (option.selected) classes.push("result-selected");
199
+ if (option.group_array_index != null) classes.push("group-option");
200
+ if (option.classes !== "") classes.push(option.classes);
201
+ style = option.style.cssText !== "" ? " style=\"" + option.style + "\"" : "";
202
+ return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"' + style + '>' + option.html + '</li>';
203
+ } else {
204
+ return "";
205
+ }
206
+ };
207
+
208
+ AbstractChosen.prototype.results_update_field = function() {
209
+ this.result_clear_highlight();
210
+ this.result_single_selected = null;
211
+ return this.results_build();
212
+ };
213
+
214
+ AbstractChosen.prototype.results_toggle = function() {
215
+ if (this.results_showing) {
216
+ return this.results_hide();
217
+ } else {
218
+ return this.results_show();
219
+ }
220
+ };
221
+
222
+ AbstractChosen.prototype.results_search = function(evt) {
223
+ if (this.results_showing) {
224
+ return this.winnow_results();
225
+ } else {
226
+ return this.results_show();
227
+ }
228
+ };
229
+
230
+ AbstractChosen.prototype.keyup_checker = function(evt) {
231
+ var stroke, _ref;
232
+ stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
233
+ this.search_field_scale();
234
+ switch (stroke) {
235
+ case 8:
236
+ if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) {
237
+ return this.keydown_backstroke();
238
+ } else if (!this.pending_backstroke) {
239
+ this.result_clear_highlight();
240
+ return this.results_search();
241
+ }
242
+ break;
243
+ case 13:
244
+ evt.preventDefault();
245
+ if (this.results_showing) return this.result_select(evt);
246
+ break;
247
+ case 27:
248
+ if (this.results_showing) this.results_hide();
249
+ return true;
250
+ case 9:
251
+ case 38:
252
+ case 40:
253
+ case 16:
254
+ case 91:
255
+ case 17:
256
+ break;
257
+ default:
258
+ return this.results_search();
259
+ }
260
+ };
261
+
262
+ AbstractChosen.prototype.generate_field_id = function() {
263
+ var new_id;
264
+ new_id = this.generate_random_id();
265
+ this.form_field.id = new_id;
266
+ return new_id;
267
+ };
268
+
269
+ AbstractChosen.prototype.generate_random_char = function() {
270
+ var chars, newchar, rand;
271
+ chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ";
272
+ rand = Math.floor(Math.random() * chars.length);
273
+ return newchar = chars.substring(rand, rand + 1);
274
+ };
275
+
276
+ return AbstractChosen;
277
+
278
+ })();
279
+
280
+ root.AbstractChosen = AbstractChosen;
281
+
282
+ }).call(this);
283
+
284
+ /*
285
+ Chosen source: generate output using 'cake build'
286
+ Copyright (c) 2011 by Harvest
287
+ */
288
+
289
+ (function() {
290
+ var $, Chosen, get_side_border_padding, root,
291
+ __hasProp = Object.prototype.hasOwnProperty,
292
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
293
+
294
+ root = this;
295
+
296
+ $ = jQuery;
297
+
298
+ $.fn.extend({
299
+ chosen: function(options) {
300
+ if ($.browser.msie && ($.browser.version === "6.0" || $.browser.version === "7.0")) {
301
+ return this;
302
+ }
303
+ return $(this).each(function(input_field) {
304
+ if (!($(this)).hasClass("chzn-done")) return new Chosen(this, options);
305
+ });
306
+ }
307
+ });
308
+
309
+ Chosen = (function(_super) {
310
+
311
+ __extends(Chosen, _super);
312
+
313
+ function Chosen() {
314
+ Chosen.__super__.constructor.apply(this, arguments);
315
+ }
316
+
317
+ Chosen.prototype.setup = function() {
318
+ this.form_field_jq = $(this.form_field);
319
+ return this.is_rtl = this.form_field_jq.hasClass("chzn-rtl");
320
+ };
321
+
322
+ Chosen.prototype.finish_setup = function() {
323
+ return this.form_field_jq.addClass("chzn-done");
324
+ };
325
+
326
+ Chosen.prototype.set_up_html = function() {
327
+ var container_div, dd_top, dd_width, sf_width;
328
+ this.container_id = this.form_field.id.length ? this.form_field.id.replace(/(:|\.)/g, '_') : this.generate_field_id();
329
+ this.container_id += "_chzn";
330
+ this.f_width = this.form_field_jq.outerWidth();
331
+ this.default_text = this.form_field_jq.data('placeholder') ? this.form_field_jq.data('placeholder') : this.default_text_default;
332
+ container_div = $("<div />", {
333
+ id: this.container_id,
334
+ "class": "chzn-container" + (this.is_rtl ? ' chzn-rtl' : ''),
335
+ style: 'width: ' + this.f_width + 'px;'
336
+ });
337
+ if (this.is_multiple) {
338
+ container_div.html('<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + this.default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>');
339
+ } else {
340
+ container_div.html('<a href="javascript:void(0)" class="chzn-single chzn-default"><span>' + this.default_text + '</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="search" autocomplete="off" /></div><ul class="chzn-results"></ul></div>');
341
+ }
342
+ this.form_field_jq.hide().after(container_div);
343
+ this.container = $('#' + this.container_id);
344
+ this.container.addClass("chzn-container-" + (this.is_multiple ? "multi" : "single"));
345
+ this.dropdown = this.container.find('div.chzn-drop').first();
346
+ dd_top = this.container.height();
347
+ dd_width = this.f_width - get_side_border_padding(this.dropdown);
348
+ this.dropdown.css({
349
+ "width": dd_width + "px",
350
+ "top": dd_top + "px"
351
+ });
352
+ this.search_field = this.container.find('input').first();
353
+ this.search_results = this.container.find('ul.chzn-results').first();
354
+ this.search_field_scale();
355
+ this.search_no_results = this.container.find('li.no-results').first();
356
+ if (this.is_multiple) {
357
+ this.search_choices = this.container.find('ul.chzn-choices').first();
358
+ this.search_container = this.container.find('li.search-field').first();
359
+ } else {
360
+ this.search_container = this.container.find('div.chzn-search').first();
361
+ this.selected_item = this.container.find('.chzn-single').first();
362
+ sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field);
363
+ sf_width = dd_width - get_side_border_padding(this.search_container);
364
+ this.search_field.css({
365
+ "width": sf_width + "px"
366
+ });
367
+ }
368
+ this.results_build();
369
+ this.set_tab_index();
370
+ return this.form_field_jq.trigger("liszt:ready", {
371
+ chosen: this
372
+ });
373
+ };
374
+
375
+ Chosen.prototype.register_observers = function() {
376
+ var _this = this;
377
+ this.container.mousedown(function(evt) {
378
+ return _this.container_mousedown(evt);
379
+ });
380
+ this.container.mouseup(function(evt) {
381
+ return _this.container_mouseup(evt);
382
+ });
383
+ this.container.mouseenter(function(evt) {
384
+ return _this.mouse_enter(evt);
385
+ });
386
+ this.container.mouseleave(function(evt) {
387
+ return _this.mouse_leave(evt);
388
+ });
389
+ this.search_results.mouseup(function(evt) {
390
+ return _this.search_results_mouseup(evt);
391
+ });
392
+ this.search_results.mouseover(function(evt) {
393
+ return _this.search_results_mouseover(evt);
394
+ });
395
+ this.search_results.mouseout(function(evt) {
396
+ return _this.search_results_mouseout(evt);
397
+ });
398
+ this.form_field_jq.bind("liszt:updated", function(evt) {
399
+ return _this.results_update_field(evt);
400
+ });
401
+ this.search_field.blur(function(evt) {
402
+ return _this.input_blur(evt);
403
+ });
404
+ this.search_field.keyup(function(evt) {
405
+ return _this.keyup_checker(evt);
406
+ });
407
+ this.search_field.keydown(function(evt) {
408
+ return _this.keydown_checker(evt);
409
+ });
410
+ if (this.is_multiple) {
411
+ this.search_choices.click(function(evt) {
412
+ return _this.choices_click(evt);
413
+ });
414
+ return this.search_field.focus(function(evt) {
415
+ return _this.input_focus(evt);
416
+ });
417
+ } else {
418
+ return this.container.click(function(evt) {
419
+ return evt.preventDefault();
420
+ });
421
+ }
422
+ };
423
+
424
+ Chosen.prototype.search_field_disabled = function() {
425
+ this.is_disabled = this.form_field_jq[0].disabled;
426
+ if (this.is_disabled) {
427
+ this.container.addClass('chzn-disabled');
428
+ this.search_field[0].disabled = true;
429
+ if (!this.is_multiple) {
430
+ this.selected_item.unbind("focus", this.activate_action);
431
+ }
432
+ return this.close_field();
433
+ } else {
434
+ this.container.removeClass('chzn-disabled');
435
+ this.search_field[0].disabled = false;
436
+ if (!this.is_multiple) {
437
+ return this.selected_item.bind("focus", this.activate_action);
438
+ }
439
+ }
440
+ };
441
+
442
+ Chosen.prototype.container_mousedown = function(evt) {
443
+ var target_closelink;
444
+ if (!this.is_disabled) {
445
+ target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false;
446
+ if (evt && evt.type === "mousedown" && !this.results_showing) {
447
+ evt.stopPropagation();
448
+ }
449
+ if (!this.pending_destroy_click && !target_closelink) {
450
+ if (!this.active_field) {
451
+ if (this.is_multiple) this.search_field.val("");
452
+ $(document).click(this.click_test_action);
453
+ this.results_show();
454
+ } else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chzn-single").length)) {
455
+ evt.preventDefault();
456
+ this.results_toggle();
457
+ }
458
+ return this.activate_field();
459
+ } else {
460
+ return this.pending_destroy_click = false;
461
+ }
462
+ }
463
+ };
464
+
465
+ Chosen.prototype.container_mouseup = function(evt) {
466
+ if (evt.target.nodeName === "ABBR") return this.results_reset(evt);
467
+ };
468
+
469
+ Chosen.prototype.blur_test = function(evt) {
470
+ if (!this.active_field && this.container.hasClass("chzn-container-active")) {
471
+ return this.close_field();
472
+ }
473
+ };
474
+
475
+ Chosen.prototype.close_field = function() {
476
+ $(document).unbind("click", this.click_test_action);
477
+ if (!this.is_multiple) {
478
+ this.selected_item.attr("tabindex", this.search_field.attr("tabindex"));
479
+ this.search_field.attr("tabindex", -1);
480
+ }
481
+ this.active_field = false;
482
+ this.results_hide();
483
+ this.container.removeClass("chzn-container-active");
484
+ this.winnow_results_clear();
485
+ this.clear_backstroke();
486
+ this.show_search_field_default();
487
+ return this.search_field_scale();
488
+ };
489
+
490
+ Chosen.prototype.activate_field = function() {
491
+ if (!this.is_multiple && !this.active_field) {
492
+ this.search_field.attr("tabindex", this.selected_item.attr("tabindex"));
493
+ this.selected_item.attr("tabindex", -1);
494
+ }
495
+ this.container.addClass("chzn-container-active");
496
+ this.active_field = true;
497
+ this.search_field.val(this.search_field.val());
498
+ return this.search_field.focus();
499
+ };
500
+
501
+ Chosen.prototype.test_active_click = function(evt) {
502
+ if ($(evt.target).parents('#' + this.container_id).length) {
503
+ return this.active_field = true;
504
+ } else {
505
+ return this.close_field();
506
+ }
507
+ };
508
+
509
+ Chosen.prototype.results_build = function() {
510
+ var content, data, _i, _len, _ref;
511
+ this.parsing = true;
512
+ this.results_data = root.SelectParser.select_to_array(this.form_field);
513
+ if (this.is_multiple && this.choices > 0) {
514
+ this.search_choices.find("li.search-choice").remove();
515
+ this.choices = 0;
516
+ } else if (!this.is_multiple) {
517
+ this.selected_item.find("span").text(this.default_text);
518
+ if (this.form_field.options.length <= this.disable_search_threshold) {
519
+ this.container.addClass("chzn-container-single-nosearch");
520
+ } else {
521
+ this.container.removeClass("chzn-container-single-nosearch");
522
+ }
523
+ }
524
+ content = '';
525
+ _ref = this.results_data;
526
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
527
+ data = _ref[_i];
528
+ if (data.group) {
529
+ content += this.result_add_group(data);
530
+ } else if (!data.empty) {
531
+ content += this.result_add_option(data);
532
+ if (data.selected && this.is_multiple) {
533
+ this.choice_build(data);
534
+ } else if (data.selected && !this.is_multiple) {
535
+ this.selected_item.removeClass("chzn-default").find("span").text(data.text);
536
+ if (this.allow_single_deselect) this.single_deselect_control_build();
537
+ }
538
+ }
539
+ }
540
+ this.search_field_disabled();
541
+ this.show_search_field_default();
542
+ this.search_field_scale();
543
+ this.search_results.html(content);
544
+ return this.parsing = false;
545
+ };
546
+
547
+ Chosen.prototype.result_add_group = function(group) {
548
+ if (!group.disabled) {
549
+ group.dom_id = this.container_id + "_g_" + group.array_index;
550
+ return '<li id="' + group.dom_id + '" class="group-result">' + $("<div />").text(group.label).html() + '</li>';
551
+ } else {
552
+ return "";
553
+ }
554
+ };
555
+
556
+ Chosen.prototype.result_do_highlight = function(el) {
557
+ var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
558
+ if (el.length) {
559
+ this.result_clear_highlight();
560
+ this.result_highlight = el;
561
+ this.result_highlight.addClass("highlighted");
562
+ maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
563
+ visible_top = this.search_results.scrollTop();
564
+ visible_bottom = maxHeight + visible_top;
565
+ high_top = this.result_highlight.position().top + this.search_results.scrollTop();
566
+ high_bottom = high_top + this.result_highlight.outerHeight();
567
+ if (high_bottom >= visible_bottom) {
568
+ return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0);
569
+ } else if (high_top < visible_top) {
570
+ return this.search_results.scrollTop(high_top);
571
+ }
572
+ }
573
+ };
574
+
575
+ Chosen.prototype.result_clear_highlight = function() {
576
+ if (this.result_highlight) this.result_highlight.removeClass("highlighted");
577
+ return this.result_highlight = null;
578
+ };
579
+
580
+ Chosen.prototype.results_show = function() {
581
+ var dd_top;
582
+ if (!this.is_multiple) {
583
+ this.selected_item.addClass("chzn-single-with-drop");
584
+ if (this.result_single_selected) {
585
+ this.result_do_highlight(this.result_single_selected);
586
+ }
587
+ }
588
+ dd_top = this.is_multiple ? this.container.height() : this.container.height() - 1;
589
+ this.dropdown.css({
590
+ "top": dd_top + "px",
591
+ "left": 0
592
+ });
593
+ this.results_showing = true;
594
+ this.search_field.focus();
595
+ this.search_field.val(this.search_field.val());
596
+ return this.winnow_results();
597
+ };
598
+
599
+ Chosen.prototype.results_hide = function() {
600
+ if (!this.is_multiple) {
601
+ this.selected_item.removeClass("chzn-single-with-drop");
602
+ }
603
+ this.result_clear_highlight();
604
+ this.dropdown.css({
605
+ "left": "-9000px"
606
+ });
607
+ return this.results_showing = false;
608
+ };
609
+
610
+ Chosen.prototype.set_tab_index = function(el) {
611
+ var ti;
612
+ if (this.form_field_jq.attr("tabindex")) {
613
+ ti = this.form_field_jq.attr("tabindex");
614
+ this.form_field_jq.attr("tabindex", -1);
615
+ if (this.is_multiple) {
616
+ return this.search_field.attr("tabindex", ti);
617
+ } else {
618
+ this.selected_item.attr("tabindex", ti);
619
+ return this.search_field.attr("tabindex", -1);
620
+ }
621
+ }
622
+ };
623
+
624
+ Chosen.prototype.show_search_field_default = function() {
625
+ if (this.is_multiple && this.choices < 1 && !this.active_field) {
626
+ this.search_field.val(this.default_text);
627
+ return this.search_field.addClass("default");
628
+ } else {
629
+ this.search_field.val("");
630
+ return this.search_field.removeClass("default");
631
+ }
632
+ };
633
+
634
+ Chosen.prototype.search_results_mouseup = function(evt) {
635
+ var target;
636
+ target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
637
+ if (target.length) {
638
+ this.result_highlight = target;
639
+ return this.result_select(evt);
640
+ }
641
+ };
642
+
643
+ Chosen.prototype.search_results_mouseover = function(evt) {
644
+ var target;
645
+ target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
646
+ if (target) return this.result_do_highlight(target);
647
+ };
648
+
649
+ Chosen.prototype.search_results_mouseout = function(evt) {
650
+ if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
651
+ return this.result_clear_highlight();
652
+ }
653
+ };
654
+
655
+ Chosen.prototype.choices_click = function(evt) {
656
+ evt.preventDefault();
657
+ if (this.active_field && !($(evt.target).hasClass("search-choice" || $(evt.target).parents('.search-choice').first)) && !this.results_showing) {
658
+ return this.results_show();
659
+ }
660
+ };
661
+
662
+ Chosen.prototype.choice_build = function(item) {
663
+ var choice_id, link,
664
+ _this = this;
665
+ choice_id = this.container_id + "_c_" + item.array_index;
666
+ this.choices += 1;
667
+ this.search_container.before('<li class="search-choice" id="' + choice_id + '"><span>' + item.html + '</span><a href="javascript:void(0)" class="search-choice-close" rel="' + item.array_index + '"></a></li>');
668
+ link = $('#' + choice_id).find("a").first();
669
+ return link.click(function(evt) {
670
+ return _this.choice_destroy_link_click(evt);
671
+ });
672
+ };
673
+
674
+ Chosen.prototype.choice_destroy_link_click = function(evt) {
675
+ evt.preventDefault();
676
+ if (!this.is_disabled) {
677
+ this.pending_destroy_click = true;
678
+ return this.choice_destroy($(evt.target));
679
+ } else {
680
+ return evt.stopPropagation;
681
+ }
682
+ };
683
+
684
+ Chosen.prototype.choice_destroy = function(link) {
685
+ this.choices -= 1;
686
+ this.show_search_field_default();
687
+ if (this.is_multiple && this.choices > 0 && this.search_field.val().length < 1) {
688
+ this.results_hide();
689
+ }
690
+ this.result_deselect(link.attr("rel"));
691
+ return link.parents('li').first().remove();
692
+ };
693
+
694
+ Chosen.prototype.results_reset = function(evt) {
695
+ this.form_field.options[0].selected = true;
696
+ this.selected_item.find("span").text(this.default_text);
697
+ if (!this.is_multiple) this.selected_item.addClass("chzn-default");
698
+ this.show_search_field_default();
699
+ $(evt.target).remove();
700
+ this.form_field_jq.trigger("change");
701
+ if (this.active_field) return this.results_hide();
702
+ };
703
+
704
+ Chosen.prototype.result_select = function(evt) {
705
+ var high, high_id, item, position;
706
+ if (this.result_highlight) {
707
+ high = this.result_highlight;
708
+ high_id = high.attr("id");
709
+ this.result_clear_highlight();
710
+ if (this.is_multiple) {
711
+ this.result_deactivate(high);
712
+ } else {
713
+ this.search_results.find(".result-selected").removeClass("result-selected");
714
+ this.result_single_selected = high;
715
+ this.selected_item.removeClass("chzn-default");
716
+ }
717
+ high.addClass("result-selected");
718
+ position = high_id.substr(high_id.lastIndexOf("_") + 1);
719
+ item = this.results_data[position];
720
+ item.selected = true;
721
+ this.form_field.options[item.options_index].selected = true;
722
+ if (this.is_multiple) {
723
+ this.choice_build(item);
724
+ } else {
725
+ this.selected_item.find("span").first().text(item.text);
726
+ if (this.allow_single_deselect) this.single_deselect_control_build();
727
+ }
728
+ if (!(evt.metaKey && this.is_multiple)) this.results_hide();
729
+ this.search_field.val("");
730
+ this.form_field_jq.trigger("change");
731
+ return this.search_field_scale();
732
+ }
733
+ };
734
+
735
+ Chosen.prototype.result_activate = function(el) {
736
+ return el.addClass("active-result");
737
+ };
738
+
739
+ Chosen.prototype.result_deactivate = function(el) {
740
+ return el.removeClass("active-result");
741
+ };
742
+
743
+ Chosen.prototype.result_deselect = function(pos) {
744
+ var result, result_data;
745
+ result_data = this.results_data[pos];
746
+ result_data.selected = false;
747
+ this.form_field.options[result_data.options_index].selected = false;
748
+ result = $("#" + this.container_id + "_o_" + pos);
749
+ result.removeClass("result-selected").addClass("active-result").show();
750
+ this.result_clear_highlight();
751
+ this.winnow_results();
752
+ this.form_field_jq.trigger("change");
753
+ return this.search_field_scale();
754
+ };
755
+
756
+ Chosen.prototype.single_deselect_control_build = function() {
757
+ if (this.allow_single_deselect && this.selected_item.find("abbr").length < 1) {
758
+ return this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
759
+ }
760
+ };
761
+
762
+ Chosen.prototype.winnow_results = function() {
763
+ var found, option, part, parts, regex, regexAnchor, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref;
764
+ this.no_results_clear();
765
+ results = 0;
766
+ searchText = this.search_field.val() === this.default_text ? "" : $('<div/>').text($.trim(this.search_field.val())).html();
767
+ regexAnchor = this.search_contains ? "" : "^";
768
+ regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
769
+ zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
770
+ _ref = this.results_data;
771
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
772
+ option = _ref[_i];
773
+ if (!option.disabled && !option.empty) {
774
+ if (option.group) {
775
+ $('#' + option.dom_id).css('display', 'none');
776
+ } else if (!(this.is_multiple && option.selected)) {
777
+ found = false;
778
+ result_id = option.dom_id;
779
+ result = $("#" + result_id);
780
+ if (regex.test(option.html)) {
781
+ found = true;
782
+ results += 1;
783
+ } else if (option.html.indexOf(" ") >= 0 || option.html.indexOf("[") === 0) {
784
+ parts = option.html.replace(/\[|\]/g, "").split(" ");
785
+ if (parts.length) {
786
+ for (_j = 0, _len2 = parts.length; _j < _len2; _j++) {
787
+ part = parts[_j];
788
+ if (regex.test(part)) {
789
+ found = true;
790
+ results += 1;
791
+ }
792
+ }
793
+ }
794
+ }
795
+ if (found) {
796
+ if (searchText.length) {
797
+ startpos = option.html.search(zregex);
798
+ text = option.html.substr(0, startpos + searchText.length) + '</em>' + option.html.substr(startpos + searchText.length);
799
+ text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
800
+ } else {
801
+ text = option.html;
802
+ }
803
+ result.html(text);
804
+ this.result_activate(result);
805
+ if (option.group_array_index != null) {
806
+ $("#" + this.results_data[option.group_array_index].dom_id).css('display', 'list-item');
807
+ }
808
+ } else {
809
+ if (this.result_highlight && result_id === this.result_highlight.attr('id')) {
810
+ this.result_clear_highlight();
811
+ }
812
+ this.result_deactivate(result);
813
+ }
814
+ }
815
+ }
816
+ }
817
+ if (results < 1 && searchText.length) {
818
+ return this.no_results(searchText);
819
+ } else {
820
+ return this.winnow_results_set_highlight();
821
+ }
822
+ };
823
+
824
+ Chosen.prototype.winnow_results_clear = function() {
825
+ var li, lis, _i, _len, _results;
826
+ this.search_field.val("");
827
+ lis = this.search_results.find("li");
828
+ _results = [];
829
+ for (_i = 0, _len = lis.length; _i < _len; _i++) {
830
+ li = lis[_i];
831
+ li = $(li);
832
+ if (li.hasClass("group-result")) {
833
+ _results.push(li.css('display', 'auto'));
834
+ } else if (!this.is_multiple || !li.hasClass("result-selected")) {
835
+ _results.push(this.result_activate(li));
836
+ } else {
837
+ _results.push(void 0);
838
+ }
839
+ }
840
+ return _results;
841
+ };
842
+
843
+ Chosen.prototype.winnow_results_set_highlight = function() {
844
+ var do_high, selected_results;
845
+ if (!this.result_highlight) {
846
+ selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
847
+ do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
848
+ if (do_high != null) return this.result_do_highlight(do_high);
849
+ }
850
+ };
851
+
852
+ Chosen.prototype.no_results = function(terms) {
853
+ var no_results_html;
854
+ no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
855
+ no_results_html.find("span").first().html(terms);
856
+ return this.search_results.append(no_results_html);
857
+ };
858
+
859
+ Chosen.prototype.no_results_clear = function() {
860
+ return this.search_results.find(".no-results").remove();
861
+ };
862
+
863
+ Chosen.prototype.keydown_arrow = function() {
864
+ var first_active, next_sib;
865
+ if (!this.result_highlight) {
866
+ first_active = this.search_results.find("li.active-result").first();
867
+ if (first_active) this.result_do_highlight($(first_active));
868
+ } else if (this.results_showing) {
869
+ next_sib = this.result_highlight.nextAll("li.active-result").first();
870
+ if (next_sib) this.result_do_highlight(next_sib);
871
+ }
872
+ if (!this.results_showing) return this.results_show();
873
+ };
874
+
875
+ Chosen.prototype.keyup_arrow = function() {
876
+ var prev_sibs;
877
+ if (!this.results_showing && !this.is_multiple) {
878
+ return this.results_show();
879
+ } else if (this.result_highlight) {
880
+ prev_sibs = this.result_highlight.prevAll("li.active-result");
881
+ if (prev_sibs.length) {
882
+ return this.result_do_highlight(prev_sibs.first());
883
+ } else {
884
+ if (this.choices > 0) this.results_hide();
885
+ return this.result_clear_highlight();
886
+ }
887
+ }
888
+ };
889
+
890
+ Chosen.prototype.keydown_backstroke = function() {
891
+ if (this.pending_backstroke) {
892
+ this.choice_destroy(this.pending_backstroke.find("a").first());
893
+ return this.clear_backstroke();
894
+ } else {
895
+ this.pending_backstroke = this.search_container.siblings("li.search-choice").last();
896
+ return this.pending_backstroke.addClass("search-choice-focus");
897
+ }
898
+ };
899
+
900
+ Chosen.prototype.clear_backstroke = function() {
901
+ if (this.pending_backstroke) {
902
+ this.pending_backstroke.removeClass("search-choice-focus");
903
+ }
904
+ return this.pending_backstroke = null;
905
+ };
906
+
907
+ Chosen.prototype.keydown_checker = function(evt) {
908
+ var stroke, _ref;
909
+ stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
910
+ this.search_field_scale();
911
+ if (stroke !== 8 && this.pending_backstroke) this.clear_backstroke();
912
+ switch (stroke) {
913
+ case 8:
914
+ this.backstroke_length = this.search_field.val().length;
915
+ break;
916
+ case 9:
917
+ if (this.results_showing && !this.is_multiple) this.result_select(evt);
918
+ this.mouse_on_container = false;
919
+ break;
920
+ case 13:
921
+ evt.preventDefault();
922
+ break;
923
+ case 38:
924
+ evt.preventDefault();
925
+ this.keyup_arrow();
926
+ break;
927
+ case 40:
928
+ this.keydown_arrow();
929
+ break;
930
+ }
931
+ };
932
+
933
+ Chosen.prototype.search_field_scale = function() {
934
+ var dd_top, div, h, style, style_block, styles, w, _i, _len;
935
+ if (this.is_multiple) {
936
+ h = 0;
937
+ w = 0;
938
+ style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
939
+ styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
940
+ for (_i = 0, _len = styles.length; _i < _len; _i++) {
941
+ style = styles[_i];
942
+ style_block += style + ":" + this.search_field.css(style) + ";";
943
+ }
944
+ div = $('<div />', {
945
+ 'style': style_block
946
+ });
947
+ div.text(this.search_field.val());
948
+ $('body').append(div);
949
+ w = div.width() + 25;
950
+ div.remove();
951
+ if (w > this.f_width - 10) w = this.f_width - 10;
952
+ this.search_field.css({
953
+ 'width': w + 'px'
954
+ });
955
+ dd_top = this.container.height();
956
+ return this.dropdown.css({
957
+ "top": dd_top + "px"
958
+ });
959
+ }
960
+ };
961
+
962
+ Chosen.prototype.generate_random_id = function() {
963
+ var string;
964
+ string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char();
965
+ while ($("#" + string).length > 0) {
966
+ string += this.generate_random_char();
967
+ }
968
+ return string;
969
+ };
970
+
971
+ return Chosen;
972
+
973
+ })(AbstractChosen);
974
+
975
+ get_side_border_padding = function(elmt) {
976
+ var side_border_padding;
977
+ return side_border_padding = elmt.outerWidth() - elmt.width();
978
+ };
979
+
980
+ root.get_side_border_padding = get_side_border_padding;
981
+
982
+ }).call(this);