sunspot_solr 2.2.2 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,71 +1,71 @@
1
- /*
2
-
3
- The MIT License (MIT)
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
22
-
23
- */
24
-
25
- /*!
26
- * jQuery Cookie Plugin
27
- * https://github.com/carhartl/jquery-cookie
28
- *
29
- * Copyright 2011, Klaus Hartl
30
- * Dual licensed under the MIT or GPL Version 2 licenses.
31
- * http://www.opensource.org/licenses/mit-license.php
32
- * http://www.opensource.org/licenses/GPL-2.0
33
- */
34
- (function($) {
35
- $.cookie = function(key, value, options) {
36
-
37
- // key and at least value given, set cookie...
38
- if (arguments.length > 1 && (!/Object/.test(Object.prototype.toString.call(value)) || value === null || value === undefined)) {
39
- options = $.extend({}, options);
40
-
41
- if (value === null || value === undefined) {
42
- options.expires = -1;
43
- }
44
-
45
- if (typeof options.expires === 'number') {
46
- var days = options.expires, t = options.expires = new Date();
47
- t.setDate(t.getDate() + days);
48
- }
49
-
50
- value = String(value);
51
-
52
- return (document.cookie = [
53
- encodeURIComponent(key), '=', options.raw ? value : encodeURIComponent(value),
54
- options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
55
- options.path ? '; path=' + options.path : '',
56
- options.domain ? '; domain=' + options.domain : '',
57
- options.secure ? '; secure' : ''
58
- ].join(''));
59
- }
60
-
61
- // key and possibly options given, get cookie...
62
- options = value || {};
63
- var decode = options.raw ? function(s) { return s; } : decodeURIComponent;
64
-
65
- var pairs = document.cookie.split('; ');
66
- for (var i = 0, pair; pair = pairs[i] && pairs[i].split('='); i++) {
67
- if (decode(pair[0]) === key) return decode(pair[1] || ''); // IE saves cookies with empty string as "c; ", e.g. without "=" as opposed to EOMB, thus pair[1] may be undefined
68
- }
69
- return null;
70
- };
71
- })(jQuery);
1
+ /*
2
+
3
+ The MIT License (MIT)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ /*!
26
+ * jQuery Cookie Plugin
27
+ * https://github.com/carhartl/jquery-cookie
28
+ *
29
+ * Copyright 2011, Klaus Hartl
30
+ * Dual licensed under the MIT or GPL Version 2 licenses.
31
+ * http://www.opensource.org/licenses/mit-license.php
32
+ * http://www.opensource.org/licenses/GPL-2.0
33
+ */
34
+ (function($) {
35
+ $.cookie = function(key, value, options) {
36
+
37
+ // key and at least value given, set cookie...
38
+ if (arguments.length > 1 && (!/Object/.test(Object.prototype.toString.call(value)) || value === null || value === undefined)) {
39
+ options = $.extend({}, options);
40
+
41
+ if (value === null || value === undefined) {
42
+ options.expires = -1;
43
+ }
44
+
45
+ if (typeof options.expires === 'number') {
46
+ var days = options.expires, t = options.expires = new Date();
47
+ t.setDate(t.getDate() + days);
48
+ }
49
+
50
+ value = String(value);
51
+
52
+ return (document.cookie = [
53
+ encodeURIComponent(key), '=', options.raw ? value : encodeURIComponent(value),
54
+ options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
55
+ options.path ? '; path=' + options.path : '',
56
+ options.domain ? '; domain=' + options.domain : '',
57
+ options.secure ? '; secure' : ''
58
+ ].join(''));
59
+ }
60
+
61
+ // key and possibly options given, get cookie...
62
+ options = value || {};
63
+ var decode = options.raw ? function(s) { return s; } : decodeURIComponent;
64
+
65
+ var pairs = document.cookie.split('; ');
66
+ for (var i = 0, pair; pair = pairs[i] && pairs[i].split('='); i++) {
67
+ if (decode(pair[0]) === key) return decode(pair[1] || ''); // IE saves cookies with empty string as "c; ", e.g. without "=" as opposed to EOMB, thus pair[1] may be undefined
68
+ }
69
+ return null;
70
+ };
71
+ })(jQuery);
@@ -1,806 +1,806 @@
1
- /*
2
-
3
- The MIT License (MIT)
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
22
-
23
- */
24
-
25
- /*!
26
- * jQuery Form Plugin
27
- * version: 2.47 (04-SEP-2010)
28
- * @requires jQuery v1.3.2 or later
29
- *
30
- * Examples and documentation at: http://malsup.com/jquery/form/
31
- * Dual licensed under the MIT and GPL licenses:
32
- * http://www.opensource.org/licenses/mit-license.php
33
- * http://www.gnu.org/licenses/gpl.html
34
- */
35
-
36
- ;(function($) {
37
-
38
- /*
39
- Usage Note:
40
- -----------
41
- Do not use both ajaxSubmit and ajaxForm on the same form. These
42
- functions are intended to be exclusive. Use ajaxSubmit if you want
43
- to bind your own submit handler to the form. For example,
44
-
45
- $(document).ready(function() {
46
- $('#myForm').bind('submit', function() {
47
- $(this).ajaxSubmit({
48
- target: '#output'
49
- });
50
- return false; // <-- important!
51
- });
52
- });
53
-
54
- Use ajaxForm when you want the plugin to manage all the event binding
55
- for you. For example,
56
-
57
- $(document).ready(function() {
58
- $('#myForm').ajaxForm({
59
- target: '#output'
60
- });
61
- });
62
-
63
- When using ajaxForm, the ajaxSubmit function will be invoked for you
64
- at the appropriate time.
65
- */
66
-
67
- /**
68
- * ajaxSubmit() provides a mechanism for immediately submitting
69
- * an HTML form using AJAX.
70
- */
71
- $.fn.ajaxSubmit = function(options) {
72
- // fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
73
- if (!this.length) {
74
- log('ajaxSubmit: skipping submit process - no element selected');
75
- return this;
76
- }
77
-
78
- if (typeof options == 'function') {
79
- options = { success: options };
80
- }
81
-
82
- var url = $.trim(this.attr('action'));
83
- if (url) {
84
- // clean url (don't include hash vaue)
85
- url = (url.match(/^([^#]+)/)||[])[1];
86
- }
87
- url = url || window.location.href || '';
88
-
89
- options = $.extend(true, {
90
- url: url,
91
- type: this.attr('method') || 'GET',
92
- iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
93
- }, options);
94
-
95
- // hook for manipulating the form data before it is extracted;
96
- // convenient for use with rich editors like tinyMCE or FCKEditor
97
- var veto = {};
98
- this.trigger('form-pre-serialize', [this, options, veto]);
99
- if (veto.veto) {
100
- log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
101
- return this;
102
- }
103
-
104
- // provide opportunity to alter form data before it is serialized
105
- if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
106
- log('ajaxSubmit: submit aborted via beforeSerialize callback');
107
- return this;
108
- }
109
-
110
- var n,v,a = this.formToArray(options.semantic);
111
- if (options.data) {
112
- options.extraData = options.data;
113
- for (n in options.data) {
114
- if(options.data[n] instanceof Array) {
115
- for (var k in options.data[n]) {
116
- a.push( { name: n, value: options.data[n][k] } );
117
- }
118
- }
119
- else {
120
- v = options.data[n];
121
- v = $.isFunction(v) ? v() : v; // if value is fn, invoke it
122
- a.push( { name: n, value: v } );
123
- }
124
- }
125
- }
126
-
127
- // give pre-submit callback an opportunity to abort the submit
128
- if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
129
- log('ajaxSubmit: submit aborted via beforeSubmit callback');
130
- return this;
131
- }
132
-
133
- // fire vetoable 'validate' event
134
- this.trigger('form-submit-validate', [a, this, options, veto]);
135
- if (veto.veto) {
136
- log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
137
- return this;
138
- }
139
-
140
- var q = $.param(a);
141
-
142
- if (options.type.toUpperCase() == 'GET') {
143
- options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
144
- options.data = null; // data is null for 'get'
145
- }
146
- else {
147
- options.data = q; // data is the query string for 'post'
148
- }
149
-
150
- var $form = this, callbacks = [];
151
- if (options.resetForm) {
152
- callbacks.push(function() { $form.resetForm(); });
153
- }
154
- if (options.clearForm) {
155
- callbacks.push(function() { $form.clearForm(); });
156
- }
157
-
158
- // perform a load on the target only if dataType is not provided
159
- if (!options.dataType && options.target) {
160
- var oldSuccess = options.success || function(){};
161
- callbacks.push(function(data) {
162
- var fn = options.replaceTarget ? 'replaceWith' : 'html';
163
- $(options.target)[fn](data).each(oldSuccess, arguments);
164
- });
165
- }
166
- else if (options.success) {
167
- callbacks.push(options.success);
168
- }
169
-
170
- options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg
171
- var context = options.context || options; // jQuery 1.4+ supports scope context
172
- for (var i=0, max=callbacks.length; i < max; i++) {
173
- callbacks[i].apply(context, [data, status, xhr || $form, $form]);
174
- }
175
- };
176
-
177
- // are there files to upload?
178
- var fileInputs = $('input:file', this).length > 0;
179
- var mp = 'multipart/form-data';
180
- var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);
181
-
182
- // options.iframe allows user to force iframe mode
183
- // 06-NOV-09: now defaulting to iframe mode if file input is detected
184
- if (options.iframe !== false && (fileInputs || options.iframe || multipart)) {
185
- // hack to fix Safari hang (thanks to Tim Molendijk for this)
186
- // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
187
- if (options.closeKeepAlive) {
188
- $.get(options.closeKeepAlive, fileUpload);
189
- }
190
- else {
191
- fileUpload();
192
- }
193
- }
194
- else {
195
- $.ajax(options);
196
- }
197
-
198
- // fire 'notify' event
199
- this.trigger('form-submit-notify', [this, options]);
200
- return this;
201
-
202
-
203
- // private function for handling file uploads (hat tip to YAHOO!)
204
- function fileUpload() {
205
- var form = $form[0];
206
-
207
- if ($(':input[name=submit],:input[id=submit]', form).length) {
208
- // if there is an input with a name or id of 'submit' then we won't be
209
- // able to invoke the submit fn on the form (at least not x-browser)
210
- alert('Error: Form elements must not have name or id of "submit".');
211
- return;
212
- }
213
-
214
- var s = $.extend(true, {}, $.ajaxSettings, options);
215
- s.context = s.context || s;
216
- var id = 'jqFormIO' + (new Date().getTime()), fn = '_'+id;
217
- window[fn] = function() {
218
- var f = $io.data('form-plugin-onload');
219
- if (f) {
220
- f();
221
- window[fn] = undefined;
222
- try { delete window[fn]; } catch(e){}
223
- }
224
- }
225
- var $io = $('<iframe id="' + id + '" name="' + id + '" src="'+ s.iframeSrc +'" onload="window[\'_\'+this.id]()" />');
226
- var io = $io[0];
227
-
228
- $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
229
-
230
- var xhr = { // mock object
231
- aborted: 0,
232
- responseText: null,
233
- responseXML: null,
234
- status: 0,
235
- statusText: 'n/a',
236
- getAllResponseHeaders: function() {},
237
- getResponseHeader: function() {},
238
- setRequestHeader: function() {},
239
- abort: function() {
240
- this.aborted = 1;
241
- $io.attr('src', s.iframeSrc); // abort op in progress
242
- }
243
- };
244
-
245
- var g = s.global;
246
- // trigger ajax global events so that activity/block indicators work like normal
247
- if (g && ! $.active++) {
248
- $.event.trigger("ajaxStart");
249
- }
250
- if (g) {
251
- $.event.trigger("ajaxSend", [xhr, s]);
252
- }
253
-
254
- if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {
255
- if (s.global) {
256
- $.active--;
257
- }
258
- return;
259
- }
260
- if (xhr.aborted) {
261
- return;
262
- }
263
-
264
- var cbInvoked = false;
265
- var timedOut = 0;
266
-
267
- // add submitting element to data if we know it
268
- var sub = form.clk;
269
- if (sub) {
270
- var n = sub.name;
271
- if (n && !sub.disabled) {
272
- s.extraData = s.extraData || {};
273
- s.extraData[n] = sub.value;
274
- if (sub.type == "image") {
275
- s.extraData[n+'.x'] = form.clk_x;
276
- s.extraData[n+'.y'] = form.clk_y;
277
- }
278
- }
279
- }
280
-
281
- // take a breath so that pending repaints get some cpu time before the upload starts
282
- function doSubmit() {
283
- // make sure form attrs are set
284
- var t = $form.attr('target'), a = $form.attr('action');
285
-
286
- // update form attrs in IE friendly way
287
- form.setAttribute('target',id);
288
- if (form.getAttribute('method') != 'POST') {
289
- form.setAttribute('method', 'POST');
290
- }
291
- if (form.getAttribute('action') != s.url) {
292
- form.setAttribute('action', s.url);
293
- }
294
-
295
- // ie borks in some cases when setting encoding
296
- if (! s.skipEncodingOverride) {
297
- $form.attr({
298
- encoding: 'multipart/form-data',
299
- enctype: 'multipart/form-data'
300
- });
301
- }
302
-
303
- // support timout
304
- if (s.timeout) {
305
- setTimeout(function() { timedOut = true; cb(); }, s.timeout);
306
- }
307
-
308
- // add "extra" data to form if provided in options
309
- var extraInputs = [];
310
- try {
311
- if (s.extraData) {
312
- for (var n in s.extraData) {
313
- extraInputs.push(
314
- $('<input type="hidden" name="'+n+'" value="'+s.extraData[n]+'" />')
315
- .appendTo(form)[0]);
316
- }
317
- }
318
-
319
- // add iframe to doc and submit the form
320
- $io.appendTo('body');
321
- $io.data('form-plugin-onload', cb);
322
- form.submit();
323
- }
324
- finally {
325
- // reset attrs and remove "extra" input elements
326
- form.setAttribute('action',a);
327
- if(t) {
328
- form.setAttribute('target', t);
329
- } else {
330
- $form.removeAttr('target');
331
- }
332
- $(extraInputs).remove();
333
- }
334
- }
335
-
336
- if (s.forceSync) {
337
- doSubmit();
338
- }
339
- else {
340
- setTimeout(doSubmit, 10); // this lets dom updates render
341
- }
342
-
343
- var data, doc, domCheckCount = 50;
344
-
345
- function cb() {
346
- if (cbInvoked) {
347
- return;
348
- }
349
-
350
- $io.removeData('form-plugin-onload');
351
-
352
- var ok = true;
353
- try {
354
- if (timedOut) {
355
- throw 'timeout';
356
- }
357
- // extract the server response from the iframe
358
- doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
359
-
360
- var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
361
- log('isXml='+isXml);
362
- if (!isXml && window.opera && (doc.body == null || doc.body.innerHTML == '')) {
363
- if (--domCheckCount) {
364
- // in some browsers (Opera) the iframe DOM is not always traversable when
365
- // the onload callback fires, so we loop a bit to accommodate
366
- log('requeing onLoad callback, DOM not available');
367
- setTimeout(cb, 250);
368
- return;
369
- }
370
- // let this fall through because server response could be an empty document
371
- //log('Could not access iframe DOM after mutiple tries.');
372
- //throw 'DOMException: not available';
373
- }
374
-
375
- //log('response detected');
376
- cbInvoked = true;
377
- xhr.responseText = doc.documentElement ? doc.documentElement.innerHTML : null;
378
- xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
379
- xhr.getResponseHeader = function(header){
380
- var headers = {'content-type': s.dataType};
381
- return headers[header];
382
- };
383
-
384
- var scr = /(json|script)/.test(s.dataType);
385
- if (scr || s.textarea) {
386
- // see if user embedded response in textarea
387
- var ta = doc.getElementsByTagName('textarea')[0];
388
- if (ta) {
389
- xhr.responseText = ta.value;
390
- }
391
- else if (scr) {
392
- // account for browsers injecting pre around json response
393
- var pre = doc.getElementsByTagName('pre')[0];
394
- if (pre) {
395
- xhr.responseText = pre.innerHTML;
396
- }
397
- }
398
- }
399
- else if (s.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) {
400
- xhr.responseXML = toXml(xhr.responseText);
401
- }
402
- data = $.httpData(xhr, s.dataType);
403
- }
404
- catch(e){
405
- log('error caught:',e);
406
- ok = false;
407
- xhr.error = e;
408
- $.handleError(s, xhr, 'error', e);
409
- }
410
-
411
- // ordering of these callbacks/triggers is odd, but that's how $.ajax does it
412
- if (ok) {
413
- s.success.call(s.context, data, 'success', xhr);
414
- if (g) {
415
- $.event.trigger("ajaxSuccess", [xhr, s]);
416
- }
417
- }
418
- if (g) {
419
- $.event.trigger("ajaxComplete", [xhr, s]);
420
- }
421
- if (g && ! --$.active) {
422
- $.event.trigger("ajaxStop");
423
- }
424
- if (s.complete) {
425
- s.complete.call(s.context, xhr, ok ? 'success' : 'error');
426
- }
427
-
428
- // clean up
429
- setTimeout(function() {
430
- $io.removeData('form-plugin-onload');
431
- $io.remove();
432
- xhr.responseXML = null;
433
- }, 100);
434
- }
435
-
436
- function toXml(s, doc) {
437
- if (window.ActiveXObject) {
438
- doc = new ActiveXObject('Microsoft.XMLDOM');
439
- doc.async = 'false';
440
- doc.loadXML(s);
441
- }
442
- else {
443
- doc = (new DOMParser()).parseFromString(s, 'text/xml');
444
- }
445
- return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null;
446
- }
447
- }
448
- };
449
-
450
- /**
451
- * ajaxForm() provides a mechanism for fully automating form submission.
452
- *
453
- * The advantages of using this method instead of ajaxSubmit() are:
454
- *
455
- * 1: This method will include coordinates for <input type="image" /> elements (if the element
456
- * is used to submit the form).
457
- * 2. This method will include the submit element's name/value data (for the element that was
458
- * used to submit the form).
459
- * 3. This method binds the submit() method to the form for you.
460
- *
461
- * The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
462
- * passes the options argument along after properly binding events for submit elements and
463
- * the form itself.
464
- */
465
- $.fn.ajaxForm = function(options) {
466
- // in jQuery 1.3+ we can fix mistakes with the ready state
467
- if (this.length === 0) {
468
- var o = { s: this.selector, c: this.context };
469
- if (!$.isReady && o.s) {
470
- log('DOM not ready, queuing ajaxForm');
471
- $(function() {
472
- $(o.s,o.c).ajaxForm(options);
473
- });
474
- return this;
475
- }
476
- // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
477
- log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
478
- return this;
479
- }
480
-
481
- return this.ajaxFormUnbind().bind('submit.form-plugin', function(e) {
482
- if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
483
- e.preventDefault();
484
- $(this).ajaxSubmit(options);
485
- }
486
- }).bind('click.form-plugin', function(e) {
487
- var target = e.target;
488
- var $el = $(target);
489
- if (!($el.is(":submit,input:image"))) {
490
- // is this a child element of the submit el? (ex: a span within a button)
491
- var t = $el.closest(':submit');
492
- if (t.length == 0) {
493
- return;
494
- }
495
- target = t[0];
496
- }
497
- var form = this;
498
- form.clk = target;
499
- if (target.type == 'image') {
500
- if (e.offsetX != undefined) {
501
- form.clk_x = e.offsetX;
502
- form.clk_y = e.offsetY;
503
- } else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
504
- var offset = $el.offset();
505
- form.clk_x = e.pageX - offset.left;
506
- form.clk_y = e.pageY - offset.top;
507
- } else {
508
- form.clk_x = e.pageX - target.offsetLeft;
509
- form.clk_y = e.pageY - target.offsetTop;
510
- }
511
- }
512
- // clear form vars
513
- setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 100);
514
- });
515
- };
516
-
517
- // ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
518
- $.fn.ajaxFormUnbind = function() {
519
- return this.unbind('submit.form-plugin click.form-plugin');
520
- };
521
-
522
- /**
523
- * formToArray() gathers form element data into an array of objects that can
524
- * be passed to any of the following ajax functions: $.get, $.post, or load.
525
- * Each object in the array has both a 'name' and 'value' property. An example of
526
- * an array for a simple login form might be:
527
- *
528
- * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
529
- *
530
- * It is this array that is passed to pre-submit callback functions provided to the
531
- * ajaxSubmit() and ajaxForm() methods.
532
- */
533
- $.fn.formToArray = function(semantic) {
534
- var a = [];
535
- if (this.length === 0) {
536
- return a;
537
- }
538
-
539
- var form = this[0];
540
- var els = semantic ? form.getElementsByTagName('*') : form.elements;
541
- if (!els) {
542
- return a;
543
- }
544
-
545
- var i,j,n,v,el;
546
- for(i=0, max=els.length; i < max; i++) {
547
- el = els[i];
548
- n = el.name;
549
- if (!n) {
550
- continue;
551
- }
552
-
553
- if (semantic && form.clk && el.type == "image") {
554
- // handle image inputs on the fly when semantic == true
555
- if(!el.disabled && form.clk == el) {
556
- a.push({name: n, value: $(el).val()});
557
- a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
558
- }
559
- continue;
560
- }
561
-
562
- v = $.fieldValue(el, true);
563
- if (v && v.constructor == Array) {
564
- for(j=0, jmax=v.length; j < jmax; j++) {
565
- a.push({name: n, value: v[j]});
566
- }
567
- }
568
- else if (v !== null && typeof v != 'undefined') {
569
- a.push({name: n, value: v});
570
- }
571
- }
572
-
573
- if (!semantic && form.clk) {
574
- // input type=='image' are not found in elements array! handle it here
575
- var $input = $(form.clk), input = $input[0];
576
- n = input.name;
577
- if (n && !input.disabled && input.type == 'image') {
578
- a.push({name: n, value: $input.val()});
579
- a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
580
- }
581
- }
582
- return a;
583
- };
584
-
585
- /**
586
- * Serializes form data into a 'submittable' string. This method will return a string
587
- * in the format: name1=value1&amp;name2=value2
588
- */
589
- $.fn.formSerialize = function(semantic) {
590
- //hand off to jQuery.param for proper encoding
591
- return $.param(this.formToArray(semantic));
592
- };
593
-
594
- /**
595
- * Serializes all field elements in the jQuery object into a query string.
596
- * This method will return a string in the format: name1=value1&amp;name2=value2
597
- */
598
- $.fn.fieldSerialize = function(successful) {
599
- var a = [];
600
- this.each(function() {
601
- var n = this.name;
602
- if (!n) {
603
- return;
604
- }
605
- var v = $.fieldValue(this, successful);
606
- if (v && v.constructor == Array) {
607
- for (var i=0,max=v.length; i < max; i++) {
608
- a.push({name: n, value: v[i]});
609
- }
610
- }
611
- else if (v !== null && typeof v != 'undefined') {
612
- a.push({name: this.name, value: v});
613
- }
614
- });
615
- //hand off to jQuery.param for proper encoding
616
- return $.param(a);
617
- };
618
-
619
- /**
620
- * Returns the value(s) of the element in the matched set. For example, consider the following form:
621
- *
622
- * <form><fieldset>
623
- * <input name="A" type="text" />
624
- * <input name="A" type="text" />
625
- * <input name="B" type="checkbox" value="B1" />
626
- * <input name="B" type="checkbox" value="B2"/>
627
- * <input name="C" type="radio" value="C1" />
628
- * <input name="C" type="radio" value="C2" />
629
- * </fieldset></form>
630
- *
631
- * var v = $(':text').fieldValue();
632
- * // if no values are entered into the text inputs
633
- * v == ['','']
634
- * // if values entered into the text inputs are 'foo' and 'bar'
635
- * v == ['foo','bar']
636
- *
637
- * var v = $(':checkbox').fieldValue();
638
- * // if neither checkbox is checked
639
- * v === undefined
640
- * // if both checkboxes are checked
641
- * v == ['B1', 'B2']
642
- *
643
- * var v = $(':radio').fieldValue();
644
- * // if neither radio is checked
645
- * v === undefined
646
- * // if first radio is checked
647
- * v == ['C1']
648
- *
649
- * The successful argument controls whether or not the field element must be 'successful'
650
- * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
651
- * The default value of the successful argument is true. If this value is false the value(s)
652
- * for each element is returned.
653
- *
654
- * Note: This method *always* returns an array. If no valid value can be determined the
655
- * array will be empty, otherwise it will contain one or more values.
656
- */
657
- $.fn.fieldValue = function(successful) {
658
- for (var val=[], i=0, max=this.length; i < max; i++) {
659
- var el = this[i];
660
- var v = $.fieldValue(el, successful);
661
- if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
662
- continue;
663
- }
664
- v.constructor == Array ? $.merge(val, v) : val.push(v);
665
- }
666
- return val;
667
- };
668
-
669
- /**
670
- * Returns the value of the field element.
671
- */
672
- $.fieldValue = function(el, successful) {
673
- var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
674
- if (successful === undefined) {
675
- successful = true;
676
- }
677
-
678
- if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
679
- (t == 'checkbox' || t == 'radio') && !el.checked ||
680
- (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
681
- tag == 'select' && el.selectedIndex == -1)) {
682
- return null;
683
- }
684
-
685
- if (tag == 'select') {
686
- var index = el.selectedIndex;
687
- if (index < 0) {
688
- return null;
689
- }
690
- var a = [], ops = el.options;
691
- var one = (t == 'select-one');
692
- var max = (one ? index+1 : ops.length);
693
- for(var i=(one ? index : 0); i < max; i++) {
694
- var op = ops[i];
695
- if (op.selected) {
696
- var v = op.value;
697
- if (!v) { // extra pain for IE...
698
- v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;
699
- }
700
- if (one) {
701
- return v;
702
- }
703
- a.push(v);
704
- }
705
- }
706
- return a;
707
- }
708
- return $(el).val();
709
- };
710
-
711
- /**
712
- * Clears the form data. Takes the following actions on the form's input fields:
713
- * - input text fields will have their 'value' property set to the empty string
714
- * - select elements will have their 'selectedIndex' property set to -1
715
- * - checkbox and radio inputs will have their 'checked' property set to false
716
- * - inputs of type submit, button, reset, and hidden will *not* be effected
717
- * - button elements will *not* be effected
718
- */
719
- $.fn.clearForm = function() {
720
- return this.each(function() {
721
- $('input,select,textarea', this).clearFields();
722
- });
723
- };
724
-
725
- /**
726
- * Clears the selected form elements.
727
- */
728
- $.fn.clearFields = $.fn.clearInputs = function() {
729
- return this.each(function() {
730
- var t = this.type, tag = this.tagName.toLowerCase();
731
- if (t == 'text' || t == 'password' || tag == 'textarea') {
732
- this.value = '';
733
- }
734
- else if (t == 'checkbox' || t == 'radio') {
735
- this.checked = false;
736
- }
737
- else if (tag == 'select') {
738
- this.selectedIndex = -1;
739
- }
740
- });
741
- };
742
-
743
- /**
744
- * Resets the form data. Causes all form elements to be reset to their original value.
745
- */
746
- $.fn.resetForm = function() {
747
- return this.each(function() {
748
- // guard against an input with the name of 'reset'
749
- // note that IE reports the reset function as an 'object'
750
- if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) {
751
- this.reset();
752
- }
753
- });
754
- };
755
-
756
- /**
757
- * Enables or disables any matching elements.
758
- */
759
- $.fn.enable = function(b) {
760
- if (b === undefined) {
761
- b = true;
762
- }
763
- return this.each(function() {
764
- this.disabled = !b;
765
- });
766
- };
767
-
768
- /**
769
- * Checks/unchecks any matching checkboxes or radio buttons and
770
- * selects/deselects and matching option elements.
771
- */
772
- $.fn.selected = function(select) {
773
- if (select === undefined) {
774
- select = true;
775
- }
776
- return this.each(function() {
777
- var t = this.type;
778
- if (t == 'checkbox' || t == 'radio') {
779
- this.checked = select;
780
- }
781
- else if (this.tagName.toLowerCase() == 'option') {
782
- var $sel = $(this).parent('select');
783
- if (select && $sel[0] && $sel[0].type == 'select-one') {
784
- // deselect all other options
785
- $sel.find('option').selected(false);
786
- }
787
- this.selected = select;
788
- }
789
- });
790
- };
791
-
792
- // helper fn for console logging
793
- // set $.fn.ajaxSubmit.debug to true to enable debug logging
794
- function log() {
795
- if ($.fn.ajaxSubmit.debug) {
796
- var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,'');
797
- if (window.console && window.console.log) {
798
- window.console.log(msg);
799
- }
800
- else if (window.opera && window.opera.postError) {
801
- window.opera.postError(msg);
802
- }
803
- }
804
- };
805
-
806
- })(jQuery);
1
+ /*
2
+
3
+ The MIT License (MIT)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ /*!
26
+ * jQuery Form Plugin
27
+ * version: 2.47 (04-SEP-2010)
28
+ * @requires jQuery v1.3.2 or later
29
+ *
30
+ * Examples and documentation at: http://malsup.com/jquery/form/
31
+ * Dual licensed under the MIT and GPL licenses:
32
+ * http://www.opensource.org/licenses/mit-license.php
33
+ * http://www.gnu.org/licenses/gpl.html
34
+ */
35
+
36
+ ;(function($) {
37
+
38
+ /*
39
+ Usage Note:
40
+ -----------
41
+ Do not use both ajaxSubmit and ajaxForm on the same form. These
42
+ functions are intended to be exclusive. Use ajaxSubmit if you want
43
+ to bind your own submit handler to the form. For example,
44
+
45
+ $(document).ready(function() {
46
+ $('#myForm').bind('submit', function() {
47
+ $(this).ajaxSubmit({
48
+ target: '#output'
49
+ });
50
+ return false; // <-- important!
51
+ });
52
+ });
53
+
54
+ Use ajaxForm when you want the plugin to manage all the event binding
55
+ for you. For example,
56
+
57
+ $(document).ready(function() {
58
+ $('#myForm').ajaxForm({
59
+ target: '#output'
60
+ });
61
+ });
62
+
63
+ When using ajaxForm, the ajaxSubmit function will be invoked for you
64
+ at the appropriate time.
65
+ */
66
+
67
+ /**
68
+ * ajaxSubmit() provides a mechanism for immediately submitting
69
+ * an HTML form using AJAX.
70
+ */
71
+ $.fn.ajaxSubmit = function(options) {
72
+ // fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
73
+ if (!this.length) {
74
+ log('ajaxSubmit: skipping submit process - no element selected');
75
+ return this;
76
+ }
77
+
78
+ if (typeof options == 'function') {
79
+ options = { success: options };
80
+ }
81
+
82
+ var url = $.trim(this.attr('action'));
83
+ if (url) {
84
+ // clean url (don't include hash vaue)
85
+ url = (url.match(/^([^#]+)/)||[])[1];
86
+ }
87
+ url = url || window.location.href || '';
88
+
89
+ options = $.extend(true, {
90
+ url: url,
91
+ type: this.attr('method') || 'GET',
92
+ iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
93
+ }, options);
94
+
95
+ // hook for manipulating the form data before it is extracted;
96
+ // convenient for use with rich editors like tinyMCE or FCKEditor
97
+ var veto = {};
98
+ this.trigger('form-pre-serialize', [this, options, veto]);
99
+ if (veto.veto) {
100
+ log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
101
+ return this;
102
+ }
103
+
104
+ // provide opportunity to alter form data before it is serialized
105
+ if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
106
+ log('ajaxSubmit: submit aborted via beforeSerialize callback');
107
+ return this;
108
+ }
109
+
110
+ var n,v,a = this.formToArray(options.semantic);
111
+ if (options.data) {
112
+ options.extraData = options.data;
113
+ for (n in options.data) {
114
+ if(options.data[n] instanceof Array) {
115
+ for (var k in options.data[n]) {
116
+ a.push( { name: n, value: options.data[n][k] } );
117
+ }
118
+ }
119
+ else {
120
+ v = options.data[n];
121
+ v = $.isFunction(v) ? v() : v; // if value is fn, invoke it
122
+ a.push( { name: n, value: v } );
123
+ }
124
+ }
125
+ }
126
+
127
+ // give pre-submit callback an opportunity to abort the submit
128
+ if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
129
+ log('ajaxSubmit: submit aborted via beforeSubmit callback');
130
+ return this;
131
+ }
132
+
133
+ // fire vetoable 'validate' event
134
+ this.trigger('form-submit-validate', [a, this, options, veto]);
135
+ if (veto.veto) {
136
+ log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
137
+ return this;
138
+ }
139
+
140
+ var q = $.param(a);
141
+
142
+ if (options.type.toUpperCase() == 'GET') {
143
+ options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
144
+ options.data = null; // data is null for 'get'
145
+ }
146
+ else {
147
+ options.data = q; // data is the query string for 'post'
148
+ }
149
+
150
+ var $form = this, callbacks = [];
151
+ if (options.resetForm) {
152
+ callbacks.push(function() { $form.resetForm(); });
153
+ }
154
+ if (options.clearForm) {
155
+ callbacks.push(function() { $form.clearForm(); });
156
+ }
157
+
158
+ // perform a load on the target only if dataType is not provided
159
+ if (!options.dataType && options.target) {
160
+ var oldSuccess = options.success || function(){};
161
+ callbacks.push(function(data) {
162
+ var fn = options.replaceTarget ? 'replaceWith' : 'html';
163
+ $(options.target)[fn](data).each(oldSuccess, arguments);
164
+ });
165
+ }
166
+ else if (options.success) {
167
+ callbacks.push(options.success);
168
+ }
169
+
170
+ options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg
171
+ var context = options.context || options; // jQuery 1.4+ supports scope context
172
+ for (var i=0, max=callbacks.length; i < max; i++) {
173
+ callbacks[i].apply(context, [data, status, xhr || $form, $form]);
174
+ }
175
+ };
176
+
177
+ // are there files to upload?
178
+ var fileInputs = $('input:file', this).length > 0;
179
+ var mp = 'multipart/form-data';
180
+ var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);
181
+
182
+ // options.iframe allows user to force iframe mode
183
+ // 06-NOV-09: now defaulting to iframe mode if file input is detected
184
+ if (options.iframe !== false && (fileInputs || options.iframe || multipart)) {
185
+ // hack to fix Safari hang (thanks to Tim Molendijk for this)
186
+ // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
187
+ if (options.closeKeepAlive) {
188
+ $.get(options.closeKeepAlive, fileUpload);
189
+ }
190
+ else {
191
+ fileUpload();
192
+ }
193
+ }
194
+ else {
195
+ $.ajax(options);
196
+ }
197
+
198
+ // fire 'notify' event
199
+ this.trigger('form-submit-notify', [this, options]);
200
+ return this;
201
+
202
+
203
+ // private function for handling file uploads (hat tip to YAHOO!)
204
+ function fileUpload() {
205
+ var form = $form[0];
206
+
207
+ if ($(':input[name=submit],:input[id=submit]', form).length) {
208
+ // if there is an input with a name or id of 'submit' then we won't be
209
+ // able to invoke the submit fn on the form (at least not x-browser)
210
+ alert('Error: Form elements must not have name or id of "submit".');
211
+ return;
212
+ }
213
+
214
+ var s = $.extend(true, {}, $.ajaxSettings, options);
215
+ s.context = s.context || s;
216
+ var id = 'jqFormIO' + (new Date().getTime()), fn = '_'+id;
217
+ window[fn] = function() {
218
+ var f = $io.data('form-plugin-onload');
219
+ if (f) {
220
+ f();
221
+ window[fn] = undefined;
222
+ try { delete window[fn]; } catch(e){}
223
+ }
224
+ }
225
+ var $io = $('<iframe id="' + id + '" name="' + id + '" src="'+ s.iframeSrc +'" onload="window[\'_\'+this.id]()" />');
226
+ var io = $io[0];
227
+
228
+ $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
229
+
230
+ var xhr = { // mock object
231
+ aborted: 0,
232
+ responseText: null,
233
+ responseXML: null,
234
+ status: 0,
235
+ statusText: 'n/a',
236
+ getAllResponseHeaders: function() {},
237
+ getResponseHeader: function() {},
238
+ setRequestHeader: function() {},
239
+ abort: function() {
240
+ this.aborted = 1;
241
+ $io.attr('src', s.iframeSrc); // abort op in progress
242
+ }
243
+ };
244
+
245
+ var g = s.global;
246
+ // trigger ajax global events so that activity/block indicators work like normal
247
+ if (g && ! $.active++) {
248
+ $.event.trigger("ajaxStart");
249
+ }
250
+ if (g) {
251
+ $.event.trigger("ajaxSend", [xhr, s]);
252
+ }
253
+
254
+ if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {
255
+ if (s.global) {
256
+ $.active--;
257
+ }
258
+ return;
259
+ }
260
+ if (xhr.aborted) {
261
+ return;
262
+ }
263
+
264
+ var cbInvoked = false;
265
+ var timedOut = 0;
266
+
267
+ // add submitting element to data if we know it
268
+ var sub = form.clk;
269
+ if (sub) {
270
+ var n = sub.name;
271
+ if (n && !sub.disabled) {
272
+ s.extraData = s.extraData || {};
273
+ s.extraData[n] = sub.value;
274
+ if (sub.type == "image") {
275
+ s.extraData[n+'.x'] = form.clk_x;
276
+ s.extraData[n+'.y'] = form.clk_y;
277
+ }
278
+ }
279
+ }
280
+
281
+ // take a breath so that pending repaints get some cpu time before the upload starts
282
+ function doSubmit() {
283
+ // make sure form attrs are set
284
+ var t = $form.attr('target'), a = $form.attr('action');
285
+
286
+ // update form attrs in IE friendly way
287
+ form.setAttribute('target',id);
288
+ if (form.getAttribute('method') != 'POST') {
289
+ form.setAttribute('method', 'POST');
290
+ }
291
+ if (form.getAttribute('action') != s.url) {
292
+ form.setAttribute('action', s.url);
293
+ }
294
+
295
+ // ie borks in some cases when setting encoding
296
+ if (! s.skipEncodingOverride) {
297
+ $form.attr({
298
+ encoding: 'multipart/form-data',
299
+ enctype: 'multipart/form-data'
300
+ });
301
+ }
302
+
303
+ // support timout
304
+ if (s.timeout) {
305
+ setTimeout(function() { timedOut = true; cb(); }, s.timeout);
306
+ }
307
+
308
+ // add "extra" data to form if provided in options
309
+ var extraInputs = [];
310
+ try {
311
+ if (s.extraData) {
312
+ for (var n in s.extraData) {
313
+ extraInputs.push(
314
+ $('<input type="hidden" name="'+n+'" value="'+s.extraData[n]+'" />')
315
+ .appendTo(form)[0]);
316
+ }
317
+ }
318
+
319
+ // add iframe to doc and submit the form
320
+ $io.appendTo('body');
321
+ $io.data('form-plugin-onload', cb);
322
+ form.submit();
323
+ }
324
+ finally {
325
+ // reset attrs and remove "extra" input elements
326
+ form.setAttribute('action',a);
327
+ if(t) {
328
+ form.setAttribute('target', t);
329
+ } else {
330
+ $form.removeAttr('target');
331
+ }
332
+ $(extraInputs).remove();
333
+ }
334
+ }
335
+
336
+ if (s.forceSync) {
337
+ doSubmit();
338
+ }
339
+ else {
340
+ setTimeout(doSubmit, 10); // this lets dom updates render
341
+ }
342
+
343
+ var data, doc, domCheckCount = 50;
344
+
345
+ function cb() {
346
+ if (cbInvoked) {
347
+ return;
348
+ }
349
+
350
+ $io.removeData('form-plugin-onload');
351
+
352
+ var ok = true;
353
+ try {
354
+ if (timedOut) {
355
+ throw 'timeout';
356
+ }
357
+ // extract the server response from the iframe
358
+ doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
359
+
360
+ var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
361
+ log('isXml='+isXml);
362
+ if (!isXml && window.opera && (doc.body == null || doc.body.innerHTML == '')) {
363
+ if (--domCheckCount) {
364
+ // in some browsers (Opera) the iframe DOM is not always traversable when
365
+ // the onload callback fires, so we loop a bit to accommodate
366
+ log('requeing onLoad callback, DOM not available');
367
+ setTimeout(cb, 250);
368
+ return;
369
+ }
370
+ // let this fall through because server response could be an empty document
371
+ //log('Could not access iframe DOM after mutiple tries.');
372
+ //throw 'DOMException: not available';
373
+ }
374
+
375
+ //log('response detected');
376
+ cbInvoked = true;
377
+ xhr.responseText = doc.documentElement ? doc.documentElement.innerHTML : null;
378
+ xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
379
+ xhr.getResponseHeader = function(header){
380
+ var headers = {'content-type': s.dataType};
381
+ return headers[header];
382
+ };
383
+
384
+ var scr = /(json|script)/.test(s.dataType);
385
+ if (scr || s.textarea) {
386
+ // see if user embedded response in textarea
387
+ var ta = doc.getElementsByTagName('textarea')[0];
388
+ if (ta) {
389
+ xhr.responseText = ta.value;
390
+ }
391
+ else if (scr) {
392
+ // account for browsers injecting pre around json response
393
+ var pre = doc.getElementsByTagName('pre')[0];
394
+ if (pre) {
395
+ xhr.responseText = pre.innerHTML;
396
+ }
397
+ }
398
+ }
399
+ else if (s.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) {
400
+ xhr.responseXML = toXml(xhr.responseText);
401
+ }
402
+ data = $.httpData(xhr, s.dataType);
403
+ }
404
+ catch(e){
405
+ log('error caught:',e);
406
+ ok = false;
407
+ xhr.error = e;
408
+ $.handleError(s, xhr, 'error', e);
409
+ }
410
+
411
+ // ordering of these callbacks/triggers is odd, but that's how $.ajax does it
412
+ if (ok) {
413
+ s.success.call(s.context, data, 'success', xhr);
414
+ if (g) {
415
+ $.event.trigger("ajaxSuccess", [xhr, s]);
416
+ }
417
+ }
418
+ if (g) {
419
+ $.event.trigger("ajaxComplete", [xhr, s]);
420
+ }
421
+ if (g && ! --$.active) {
422
+ $.event.trigger("ajaxStop");
423
+ }
424
+ if (s.complete) {
425
+ s.complete.call(s.context, xhr, ok ? 'success' : 'error');
426
+ }
427
+
428
+ // clean up
429
+ setTimeout(function() {
430
+ $io.removeData('form-plugin-onload');
431
+ $io.remove();
432
+ xhr.responseXML = null;
433
+ }, 100);
434
+ }
435
+
436
+ function toXml(s, doc) {
437
+ if (window.ActiveXObject) {
438
+ doc = new ActiveXObject('Microsoft.XMLDOM');
439
+ doc.async = 'false';
440
+ doc.loadXML(s);
441
+ }
442
+ else {
443
+ doc = (new DOMParser()).parseFromString(s, 'text/xml');
444
+ }
445
+ return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null;
446
+ }
447
+ }
448
+ };
449
+
450
+ /**
451
+ * ajaxForm() provides a mechanism for fully automating form submission.
452
+ *
453
+ * The advantages of using this method instead of ajaxSubmit() are:
454
+ *
455
+ * 1: This method will include coordinates for <input type="image" /> elements (if the element
456
+ * is used to submit the form).
457
+ * 2. This method will include the submit element's name/value data (for the element that was
458
+ * used to submit the form).
459
+ * 3. This method binds the submit() method to the form for you.
460
+ *
461
+ * The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
462
+ * passes the options argument along after properly binding events for submit elements and
463
+ * the form itself.
464
+ */
465
+ $.fn.ajaxForm = function(options) {
466
+ // in jQuery 1.3+ we can fix mistakes with the ready state
467
+ if (this.length === 0) {
468
+ var o = { s: this.selector, c: this.context };
469
+ if (!$.isReady && o.s) {
470
+ log('DOM not ready, queuing ajaxForm');
471
+ $(function() {
472
+ $(o.s,o.c).ajaxForm(options);
473
+ });
474
+ return this;
475
+ }
476
+ // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
477
+ log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
478
+ return this;
479
+ }
480
+
481
+ return this.ajaxFormUnbind().bind('submit.form-plugin', function(e) {
482
+ if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
483
+ e.preventDefault();
484
+ $(this).ajaxSubmit(options);
485
+ }
486
+ }).bind('click.form-plugin', function(e) {
487
+ var target = e.target;
488
+ var $el = $(target);
489
+ if (!($el.is(":submit,input:image"))) {
490
+ // is this a child element of the submit el? (ex: a span within a button)
491
+ var t = $el.closest(':submit');
492
+ if (t.length == 0) {
493
+ return;
494
+ }
495
+ target = t[0];
496
+ }
497
+ var form = this;
498
+ form.clk = target;
499
+ if (target.type == 'image') {
500
+ if (e.offsetX != undefined) {
501
+ form.clk_x = e.offsetX;
502
+ form.clk_y = e.offsetY;
503
+ } else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
504
+ var offset = $el.offset();
505
+ form.clk_x = e.pageX - offset.left;
506
+ form.clk_y = e.pageY - offset.top;
507
+ } else {
508
+ form.clk_x = e.pageX - target.offsetLeft;
509
+ form.clk_y = e.pageY - target.offsetTop;
510
+ }
511
+ }
512
+ // clear form vars
513
+ setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 100);
514
+ });
515
+ };
516
+
517
+ // ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
518
+ $.fn.ajaxFormUnbind = function() {
519
+ return this.unbind('submit.form-plugin click.form-plugin');
520
+ };
521
+
522
+ /**
523
+ * formToArray() gathers form element data into an array of objects that can
524
+ * be passed to any of the following ajax functions: $.get, $.post, or load.
525
+ * Each object in the array has both a 'name' and 'value' property. An example of
526
+ * an array for a simple login form might be:
527
+ *
528
+ * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
529
+ *
530
+ * It is this array that is passed to pre-submit callback functions provided to the
531
+ * ajaxSubmit() and ajaxForm() methods.
532
+ */
533
+ $.fn.formToArray = function(semantic) {
534
+ var a = [];
535
+ if (this.length === 0) {
536
+ return a;
537
+ }
538
+
539
+ var form = this[0];
540
+ var els = semantic ? form.getElementsByTagName('*') : form.elements;
541
+ if (!els) {
542
+ return a;
543
+ }
544
+
545
+ var i,j,n,v,el;
546
+ for(i=0, max=els.length; i < max; i++) {
547
+ el = els[i];
548
+ n = el.name;
549
+ if (!n) {
550
+ continue;
551
+ }
552
+
553
+ if (semantic && form.clk && el.type == "image") {
554
+ // handle image inputs on the fly when semantic == true
555
+ if(!el.disabled && form.clk == el) {
556
+ a.push({name: n, value: $(el).val()});
557
+ a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
558
+ }
559
+ continue;
560
+ }
561
+
562
+ v = $.fieldValue(el, true);
563
+ if (v && v.constructor == Array) {
564
+ for(j=0, jmax=v.length; j < jmax; j++) {
565
+ a.push({name: n, value: v[j]});
566
+ }
567
+ }
568
+ else if (v !== null && typeof v != 'undefined') {
569
+ a.push({name: n, value: v});
570
+ }
571
+ }
572
+
573
+ if (!semantic && form.clk) {
574
+ // input type=='image' are not found in elements array! handle it here
575
+ var $input = $(form.clk), input = $input[0];
576
+ n = input.name;
577
+ if (n && !input.disabled && input.type == 'image') {
578
+ a.push({name: n, value: $input.val()});
579
+ a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
580
+ }
581
+ }
582
+ return a;
583
+ };
584
+
585
+ /**
586
+ * Serializes form data into a 'submittable' string. This method will return a string
587
+ * in the format: name1=value1&amp;name2=value2
588
+ */
589
+ $.fn.formSerialize = function(semantic) {
590
+ //hand off to jQuery.param for proper encoding
591
+ return $.param(this.formToArray(semantic));
592
+ };
593
+
594
+ /**
595
+ * Serializes all field elements in the jQuery object into a query string.
596
+ * This method will return a string in the format: name1=value1&amp;name2=value2
597
+ */
598
+ $.fn.fieldSerialize = function(successful) {
599
+ var a = [];
600
+ this.each(function() {
601
+ var n = this.name;
602
+ if (!n) {
603
+ return;
604
+ }
605
+ var v = $.fieldValue(this, successful);
606
+ if (v && v.constructor == Array) {
607
+ for (var i=0,max=v.length; i < max; i++) {
608
+ a.push({name: n, value: v[i]});
609
+ }
610
+ }
611
+ else if (v !== null && typeof v != 'undefined') {
612
+ a.push({name: this.name, value: v});
613
+ }
614
+ });
615
+ //hand off to jQuery.param for proper encoding
616
+ return $.param(a);
617
+ };
618
+
619
+ /**
620
+ * Returns the value(s) of the element in the matched set. For example, consider the following form:
621
+ *
622
+ * <form><fieldset>
623
+ * <input name="A" type="text" />
624
+ * <input name="A" type="text" />
625
+ * <input name="B" type="checkbox" value="B1" />
626
+ * <input name="B" type="checkbox" value="B2"/>
627
+ * <input name="C" type="radio" value="C1" />
628
+ * <input name="C" type="radio" value="C2" />
629
+ * </fieldset></form>
630
+ *
631
+ * var v = $(':text').fieldValue();
632
+ * // if no values are entered into the text inputs
633
+ * v == ['','']
634
+ * // if values entered into the text inputs are 'foo' and 'bar'
635
+ * v == ['foo','bar']
636
+ *
637
+ * var v = $(':checkbox').fieldValue();
638
+ * // if neither checkbox is checked
639
+ * v === undefined
640
+ * // if both checkboxes are checked
641
+ * v == ['B1', 'B2']
642
+ *
643
+ * var v = $(':radio').fieldValue();
644
+ * // if neither radio is checked
645
+ * v === undefined
646
+ * // if first radio is checked
647
+ * v == ['C1']
648
+ *
649
+ * The successful argument controls whether or not the field element must be 'successful'
650
+ * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
651
+ * The default value of the successful argument is true. If this value is false the value(s)
652
+ * for each element is returned.
653
+ *
654
+ * Note: This method *always* returns an array. If no valid value can be determined the
655
+ * array will be empty, otherwise it will contain one or more values.
656
+ */
657
+ $.fn.fieldValue = function(successful) {
658
+ for (var val=[], i=0, max=this.length; i < max; i++) {
659
+ var el = this[i];
660
+ var v = $.fieldValue(el, successful);
661
+ if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
662
+ continue;
663
+ }
664
+ v.constructor == Array ? $.merge(val, v) : val.push(v);
665
+ }
666
+ return val;
667
+ };
668
+
669
+ /**
670
+ * Returns the value of the field element.
671
+ */
672
+ $.fieldValue = function(el, successful) {
673
+ var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
674
+ if (successful === undefined) {
675
+ successful = true;
676
+ }
677
+
678
+ if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
679
+ (t == 'checkbox' || t == 'radio') && !el.checked ||
680
+ (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
681
+ tag == 'select' && el.selectedIndex == -1)) {
682
+ return null;
683
+ }
684
+
685
+ if (tag == 'select') {
686
+ var index = el.selectedIndex;
687
+ if (index < 0) {
688
+ return null;
689
+ }
690
+ var a = [], ops = el.options;
691
+ var one = (t == 'select-one');
692
+ var max = (one ? index+1 : ops.length);
693
+ for(var i=(one ? index : 0); i < max; i++) {
694
+ var op = ops[i];
695
+ if (op.selected) {
696
+ var v = op.value;
697
+ if (!v) { // extra pain for IE...
698
+ v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;
699
+ }
700
+ if (one) {
701
+ return v;
702
+ }
703
+ a.push(v);
704
+ }
705
+ }
706
+ return a;
707
+ }
708
+ return $(el).val();
709
+ };
710
+
711
+ /**
712
+ * Clears the form data. Takes the following actions on the form's input fields:
713
+ * - input text fields will have their 'value' property set to the empty string
714
+ * - select elements will have their 'selectedIndex' property set to -1
715
+ * - checkbox and radio inputs will have their 'checked' property set to false
716
+ * - inputs of type submit, button, reset, and hidden will *not* be effected
717
+ * - button elements will *not* be effected
718
+ */
719
+ $.fn.clearForm = function() {
720
+ return this.each(function() {
721
+ $('input,select,textarea', this).clearFields();
722
+ });
723
+ };
724
+
725
+ /**
726
+ * Clears the selected form elements.
727
+ */
728
+ $.fn.clearFields = $.fn.clearInputs = function() {
729
+ return this.each(function() {
730
+ var t = this.type, tag = this.tagName.toLowerCase();
731
+ if (t == 'text' || t == 'password' || tag == 'textarea') {
732
+ this.value = '';
733
+ }
734
+ else if (t == 'checkbox' || t == 'radio') {
735
+ this.checked = false;
736
+ }
737
+ else if (tag == 'select') {
738
+ this.selectedIndex = -1;
739
+ }
740
+ });
741
+ };
742
+
743
+ /**
744
+ * Resets the form data. Causes all form elements to be reset to their original value.
745
+ */
746
+ $.fn.resetForm = function() {
747
+ return this.each(function() {
748
+ // guard against an input with the name of 'reset'
749
+ // note that IE reports the reset function as an 'object'
750
+ if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) {
751
+ this.reset();
752
+ }
753
+ });
754
+ };
755
+
756
+ /**
757
+ * Enables or disables any matching elements.
758
+ */
759
+ $.fn.enable = function(b) {
760
+ if (b === undefined) {
761
+ b = true;
762
+ }
763
+ return this.each(function() {
764
+ this.disabled = !b;
765
+ });
766
+ };
767
+
768
+ /**
769
+ * Checks/unchecks any matching checkboxes or radio buttons and
770
+ * selects/deselects and matching option elements.
771
+ */
772
+ $.fn.selected = function(select) {
773
+ if (select === undefined) {
774
+ select = true;
775
+ }
776
+ return this.each(function() {
777
+ var t = this.type;
778
+ if (t == 'checkbox' || t == 'radio') {
779
+ this.checked = select;
780
+ }
781
+ else if (this.tagName.toLowerCase() == 'option') {
782
+ var $sel = $(this).parent('select');
783
+ if (select && $sel[0] && $sel[0].type == 'select-one') {
784
+ // deselect all other options
785
+ $sel.find('option').selected(false);
786
+ }
787
+ this.selected = select;
788
+ }
789
+ });
790
+ };
791
+
792
+ // helper fn for console logging
793
+ // set $.fn.ajaxSubmit.debug to true to enable debug logging
794
+ function log() {
795
+ if ($.fn.ajaxSubmit.debug) {
796
+ var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,'');
797
+ if (window.console && window.console.log) {
798
+ window.console.log(msg);
799
+ }
800
+ else if (window.opera && window.opera.postError) {
801
+ window.opera.postError(msg);
802
+ }
803
+ }
804
+ };
805
+
806
+ })(jQuery);