wagn 1.12.13 → 1.13.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (545) hide show
  1. checksums.yaml +5 -13
  2. data/.gitignore +7 -8
  3. data/.rspec +1 -1
  4. data/.simplecov +23 -0
  5. data/.tm_properties +1 -0
  6. data/Gemfile +15 -13
  7. data/Guardfile +34 -0
  8. data/README.rdoc +4 -10
  9. data/VERSION +1 -1
  10. data/app/assets/images/smoothness/animated-overlay.gif +0 -0
  11. data/app/assets/images/smoothness/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  12. data/app/assets/images/smoothness/ui-bg_flat_75_ffffff_40x100.png +0 -0
  13. data/app/assets/images/smoothness/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  14. data/app/assets/images/smoothness/ui-bg_glass_65_ffffff_1x400.png +0 -0
  15. data/app/assets/images/smoothness/ui-bg_glass_75_dadada_1x400.png +0 -0
  16. data/app/assets/images/smoothness/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  17. data/app/assets/images/smoothness/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  18. data/app/assets/images/smoothness/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  19. data/app/assets/images/smoothness/ui-icons_222222_256x240.png +0 -0
  20. data/app/assets/images/smoothness/ui-icons_2e83ff_256x240.png +0 -0
  21. data/app/assets/images/smoothness/ui-icons_454545_256x240.png +0 -0
  22. data/app/assets/images/smoothness/ui-icons_888888_256x240.png +0 -0
  23. data/app/assets/images/smoothness/ui-icons_cd0a0a_256x240.png +0 -0
  24. data/app/assets/javascripts/application.js +9 -8
  25. data/app/assets/javascripts/jquery.ui.autocomplete.html.js +1 -1
  26. data/app/controllers/card_controller.rb +190 -23
  27. data/config/environments/development.rb +17 -12
  28. data/config/initializers/01_init_ruby_extensions.rb +1 -70
  29. data/config/routes.rb +21 -8
  30. data/config/version_cards.txt +1 -1
  31. data/db/bootstrap/card_references.yml +520 -352
  32. data/db/bootstrap/card_revisions.yml +1818 -1887
  33. data/db/bootstrap/cards.yml +2279 -1310
  34. data/db/migrate_cards/20130411191151_renaming_for_menu.rb +0 -5
  35. data/db/migrate_cards/20130411211600_delete_old_related_tab_cards.rb +0 -6
  36. data/db/migrate_cards/20130419215612_import_help_text.rb +0 -7
  37. data/db/migrate_cards/20130823192433_add_style_cards.rb +2 -6
  38. data/db/migrate_cards/20130910183318_move_styles_to_content.rb +0 -5
  39. data/db/migrate_cards/20130920214038_jsonize_tinymce.rb +0 -6
  40. data/db/migrate_cards/20130920291703_update_stylesheets.rb +0 -5
  41. data/db/migrate_cards/20130927191728_account_events.rb +1 -6
  42. data/db/migrate_cards/20131016172445_common_css_patch.rb +0 -6
  43. data/db/migrate_cards/20140110193325_reset_account_request_type.rb +1 -6
  44. data/db/migrate_cards/20140307231621_user_data_to_cards.rb +78 -0
  45. data/db/migrate_cards/20140317035504_account_requests_to_signups.rb +45 -0
  46. data/db/migrate_cards/20140512155840_add_script_cards.rb +85 -0
  47. data/db/migrate_cards/data/1.12_stylesheets/common.scss +1 -1
  48. data/features/autonaming.feature +3 -3
  49. data/features/flexmail.feature +2 -2
  50. data/features/layouts.feature +1 -1
  51. data/features/navbox.feature +17 -0
  52. data/features/notifications.feature +4 -4
  53. data/features/pointer_inputs.feature +2 -2
  54. data/features/presetting_content.feature +1 -1
  55. data/features/reset_password.feature +34 -0
  56. data/features/{pattern_settings.feature → rules.feature} +7 -7
  57. data/features/setup.feature +32 -0
  58. data/features/signup.feature +47 -0
  59. data/features/step_definitions/email_steps.rb +24 -1
  60. data/features/step_definitions/wagn_steps.rb +66 -31
  61. data/features/step_definitions/web_steps.rb +1 -0
  62. data/features/{content_settings.feature → structure.feature} +3 -6
  63. data/features/support/env.rb +3 -0
  64. data/features/support/paths.rb +2 -2
  65. data/features/support/{wag_env.rb → wagn_env.rb} +1 -1
  66. data/features/table_of_contents.feature +1 -1
  67. data/features/update_includers.feature +3 -3
  68. data/features/watch.feature +2 -2
  69. data/lib/card.rb +12 -10
  70. data/lib/{active_record/quoting_and_matching.rb → card/active_record_ext.rb} +25 -20
  71. data/lib/card/auth.rb +205 -0
  72. data/lib/card/chunk.rb +70 -69
  73. data/lib/card/content.rb +1 -1
  74. data/lib/card/core_ext.rb +74 -0
  75. data/lib/card/env.rb +66 -0
  76. data/lib/card/flexmail.rb +43 -37
  77. data/lib/card/format.rb +42 -29
  78. data/lib/{generators → card/generators}/card_migration/USAGE +0 -0
  79. data/lib/{generators → card/generators}/card_migration/card_migration_generator.rb +0 -0
  80. data/lib/{generators → card/generators}/card_migration/templates/card_migration.erb +0 -6
  81. data/lib/{generators → card/generators}/format/USAGE +0 -0
  82. data/lib/{generators → card/generators}/format/format_generator.rb +0 -0
  83. data/lib/{generators → card/generators}/format/templates/format_spec_template.erb +1 -2
  84. data/lib/{generators → card/generators}/format/templates/format_template.erb +0 -0
  85. data/lib/{generators → card/generators}/set/USAGE +0 -0
  86. data/lib/{generators → card/generators}/set/set_generator.rb +0 -0
  87. data/lib/{generators → card/generators}/set/templates/set_spec_template.erb +1 -2
  88. data/lib/card/generators/set/templates/set_template.erb +1 -0
  89. data/lib/card/loader.rb +145 -0
  90. data/lib/card/mailer.rb +117 -0
  91. data/{app/views → lib/card}/mailer/change_notice.html.erb +2 -2
  92. data/lib/card/mailer/confirmation_email.html.erb +8 -0
  93. data/{app/views → lib/card}/mailer/flexmail.html.erb +0 -0
  94. data/lib/card/mailer/password_reset.html.erb +9 -0
  95. data/{app/views → lib/card}/mailer/signup_alert.html.erb +0 -0
  96. data/lib/card/name.rb +2 -3
  97. data/lib/card/query.rb +0 -3
  98. data/lib/card/query/card_spec.rb +4 -4
  99. data/lib/card/revision.rb +34 -32
  100. data/lib/card/set.rb +204 -180
  101. data/lib/card/set_pattern.rb +126 -101
  102. data/lib/wagn/all.rb +1 -8
  103. data/lib/wagn/application.rb +14 -7
  104. data/lib/wagn/commands/application.rb +1 -1
  105. data/lib/{generators → wagn/generators}/wagn/USAGE +0 -0
  106. data/lib/{generators → wagn/generators}/wagn/templates/Gemfile +0 -0
  107. data/lib/{generators → wagn/generators}/wagn/templates/Rakefile +0 -0
  108. data/lib/{generators → wagn/generators}/wagn/templates/config.ru +0 -0
  109. data/lib/{generators → wagn/generators}/wagn/templates/config/application.rb +0 -0
  110. data/lib/{generators → wagn/generators}/wagn/templates/config/boot.rb +0 -0
  111. data/lib/{generators → wagn/generators}/wagn/templates/config/database.yml +0 -0
  112. data/lib/{generators → wagn/generators}/wagn/templates/config/databases/frontbase.yml +0 -0
  113. data/lib/{generators → wagn/generators}/wagn/templates/config/databases/ibm_db.yml +0 -0
  114. data/lib/{generators → wagn/generators}/wagn/templates/config/databases/jdbc.yml +0 -0
  115. data/lib/{generators → wagn/generators}/wagn/templates/config/databases/jdbcmysql.yml +0 -0
  116. data/lib/{generators → wagn/generators}/wagn/templates/config/databases/jdbcpostgresql.yml +0 -0
  117. data/lib/{generators → wagn/generators}/wagn/templates/config/databases/jdbcsqlite3.yml +0 -0
  118. data/lib/{generators → wagn/generators}/wagn/templates/config/databases/mysql.yml +0 -0
  119. data/lib/{generators → wagn/generators}/wagn/templates/config/databases/oracle.yml +0 -0
  120. data/lib/{generators → wagn/generators}/wagn/templates/config/databases/postgresql.yml +0 -0
  121. data/lib/{generators → wagn/generators}/wagn/templates/config/databases/sqlite3.yml +0 -0
  122. data/lib/{generators → wagn/generators}/wagn/templates/config/environment.rb +0 -0
  123. data/lib/{generators → wagn/generators}/wagn/templates/gitignore +0 -0
  124. data/lib/wagn/generators/wagn/templates/public/files/htaccess +9 -0
  125. data/{public → lib/wagn/generators/wagn/templates/public}/robots.txt +0 -0
  126. data/lib/{generators → wagn/generators}/wagn/templates/script/wagn +0 -0
  127. data/lib/{generators → wagn/generators}/wagn/wagn_generator.rb +12 -0
  128. data/lib/wagn/location.rb +7 -11
  129. data/lib/wagn/migration_helper.rb +4 -1
  130. data/{app/mailers → lib/wagn/tasks}/.gitkeep +0 -0
  131. data/lib/{tasks → wagn/tasks}/cucumber.rake +0 -0
  132. data/lib/{tasks → wagn/tasks}/db.rake +0 -0
  133. data/lib/{tasks → wagn/tasks}/test.rake +5 -2
  134. data/lib/{tasks → wagn/tasks}/wagn.rake +29 -12
  135. data/mods/{standard → core}/chunks/include.rb +2 -0
  136. data/mods/{standard → core}/chunks/link.rb +3 -0
  137. data/mods/core/formats/html_format.rb +27 -35
  138. data/mods/core/sets/all/active_card.rb +15 -3
  139. data/mods/core/sets/all/attribute_tracking.rb +1 -1
  140. data/mods/core/sets/all/collection.rb +4 -5
  141. data/mods/core/sets/all/fetch.rb +98 -80
  142. data/mods/core/sets/all/initialize.rb +2 -0
  143. data/mods/core/sets/all/name.rb +13 -12
  144. data/mods/core/sets/all/pattern.rb +0 -9
  145. data/mods/core/sets/all/permissions.rb +56 -31
  146. data/mods/core/sets/all/phases.rb +63 -84
  147. data/mods/core/sets/all/references.rb +0 -1
  148. data/mods/core/sets/all/rules.rb +3 -4
  149. data/mods/core/sets/all/templating.rb +2 -3
  150. data/mods/core/sets/all/tracked_attributes.rb +26 -9
  151. data/mods/core/sets/all/trash.rb +1 -2
  152. data/mods/core/sets/all/type.rb +6 -1
  153. data/mods/core/sets/all/utils.rb +2 -3
  154. data/mods/standard/files/103/icon-6566.ico +0 -0
  155. data/mods/standard/files/103/large-6566.ico +0 -0
  156. data/mods/standard/files/103/medium-6566.ico +0 -0
  157. data/{public/favicon.ico → mods/standard/files/103/original-6566.ico} +0 -0
  158. data/mods/standard/files/103/small-6566.ico +0 -0
  159. data/mods/standard/files/79/icon-6556.png +0 -0
  160. data/mods/standard/files/79/large-6556.png +0 -0
  161. data/mods/standard/files/79/medium-6556.png +0 -0
  162. data/mods/standard/files/79/original-6556.png +0 -0
  163. data/mods/standard/files/79/small-6556.png +0 -0
  164. data/mods/standard/files/790/icon-6419.png +0 -0
  165. data/mods/standard/files/790/large-6419.png +0 -0
  166. data/mods/standard/files/790/medium-6419.png +0 -0
  167. data/mods/standard/files/790/original-6419.png +0 -0
  168. data/mods/standard/files/790/small-6419.png +0 -0
  169. data/mods/standard/lib/card/machine.rb +152 -0
  170. data/mods/standard/lib/card/machine_input.rb +40 -0
  171. data/{public/assets → mods/standard/lib/javascript}/html5shiv-printshiv.js +0 -0
  172. data/mods/standard/lib/javascript/jquery-ui.js +14913 -0
  173. data/mods/standard/lib/javascript/jquery.autosize.js +255 -0
  174. data/mods/standard/lib/javascript/jquery.fileupload.js +1112 -0
  175. data/mods/standard/lib/javascript/jquery.iframe-transport.js +157 -0
  176. data/mods/standard/lib/javascript/jquery.js +9473 -0
  177. data/mods/standard/lib/javascript/jquery.ui.autocomplete.html.js +41 -0
  178. data/mods/standard/lib/javascript/jquery_ujs.js +429 -0
  179. data/mods/standard/lib/javascript/jquerymobile.js +8800 -0
  180. data/mods/standard/lib/javascript/tinymce.js +13 -0
  181. data/{app/assets/javascripts → mods/standard/lib/javascript}/wagn.js.coffee +10 -0
  182. data/{app/assets/javascripts → mods/standard/lib/javascript}/wagn_menu.js +3 -12
  183. data/{app/assets/javascripts → mods/standard/lib/javascript}/wagn_mod.js.coffee +18 -11
  184. data/mods/standard/lib/stylesheets/functional.scss +13 -9
  185. data/mods/standard/lib/stylesheets/jquery-ui-smoothness.css +922 -218
  186. data/mods/standard/lib/stylesheets/standard.scss +2 -2
  187. data/mods/standard/sets/all/account.rb +18 -205
  188. data/mods/standard/sets/all/all_css.rb +2 -3
  189. data/mods/standard/sets/all/all_csv.rb +0 -1
  190. data/mods/standard/sets/all/attach.rb +0 -1
  191. data/mods/standard/sets/all/base.rb +9 -7
  192. data/mods/standard/sets/all/comment.rb +5 -5
  193. data/mods/standard/sets/all/email_html.rb +0 -2
  194. data/mods/standard/sets/all/event_viz.rb +62 -0
  195. data/mods/standard/sets/all/file.rb +0 -1
  196. data/mods/standard/sets/all/follow.rb +13 -11
  197. data/mods/standard/sets/all/history.rb +2 -7
  198. data/mods/standard/sets/all/json.rb +6 -11
  199. data/mods/standard/sets/all/rich_html.rb +68 -52
  200. data/mods/standard/sets/all/rss.rb +4 -5
  201. data/mods/standard/sets/all/text.rb +0 -1
  202. data/mods/standard/sets/right/account.rb +100 -1
  203. data/mods/standard/sets/right/create.rb +8 -2
  204. data/mods/standard/sets/right/delete.rb +2 -0
  205. data/mods/standard/sets/right/email.rb +50 -2
  206. data/mods/standard/sets/right/machine_output.rb +12 -0
  207. data/mods/standard/sets/right/password.rb +39 -0
  208. data/mods/standard/sets/right/read.rb +2 -0
  209. data/mods/standard/sets/right/salt.rb +2 -1
  210. data/mods/standard/sets/right/script.rb +10 -0
  211. data/mods/standard/sets/right/stats.rb +35 -0
  212. data/mods/standard/sets/right/status.rb +9 -0
  213. data/mods/standard/sets/right/style.rb +7 -53
  214. data/mods/standard/sets/right/{crypted_password.rb → token.rb} +2 -1
  215. data/mods/standard/sets/right/update.rb +2 -0
  216. data/mods/standard/sets/rstar/rules.rb +7 -3
  217. data/mods/standard/sets/self/account_links.rb +16 -23
  218. data/mods/standard/sets/self/alerts.rb +0 -1
  219. data/mods/standard/sets/self/all.rb +21 -0
  220. data/mods/standard/sets/self/foot.rb +0 -1
  221. data/mods/standard/sets/self/head.rb +21 -24
  222. data/mods/standard/sets/self/navbox.rb +0 -1
  223. data/mods/standard/sets/self/now.rb +0 -1
  224. data/mods/standard/sets/self/recent.rb +38 -35
  225. data/mods/standard/sets/self/script_card_menu.rb +8 -0
  226. data/mods/standard/sets/self/script_html5shiv_printshiv.rb +7 -0
  227. data/mods/standard/sets/self/script_jquery.rb +8 -0
  228. data/mods/standard/sets/self/script_jquery_helper.rb +13 -0
  229. data/mods/standard/sets/self/script_slot.rb +9 -0
  230. data/mods/standard/sets/self/script_tinymce.rb +8 -0
  231. data/mods/standard/sets/self/search.rb +0 -1
  232. data/mods/standard/sets/self/signin.rb +111 -0
  233. data/mods/standard/sets/self/stats.rb +91 -0
  234. data/mods/standard/sets/self/style_functional.rb +1 -1
  235. data/mods/standard/sets/self/style_jquery_ui_smoothness.rb +1 -1
  236. data/mods/standard/sets/self/style_standard.rb +1 -1
  237. data/mods/standard/sets/type/basic.rb +15 -14
  238. data/mods/standard/sets/type/cardtype.rb +2 -3
  239. data/mods/standard/sets/type/coffee_script.rb +46 -0
  240. data/mods/standard/sets/type/css.rb +16 -5
  241. data/mods/standard/sets/type/date.rb +0 -1
  242. data/mods/standard/sets/type/file.rb +0 -2
  243. data/mods/standard/sets/type/html.rb +0 -1
  244. data/mods/standard/sets/type/image.rb +1 -2
  245. data/mods/standard/sets/type/java_script.rb +32 -0
  246. data/mods/standard/sets/type/layout_type.rb +1 -1
  247. data/mods/standard/sets/type/number.rb +0 -1
  248. data/mods/standard/sets/type/pointer.rb +13 -8
  249. data/mods/standard/sets/type/scss.rb +17 -3
  250. data/mods/standard/sets/type/search_type.rb +36 -34
  251. data/mods/standard/sets/type/set.rb +1 -5
  252. data/mods/standard/sets/type/setting.rb +1 -2
  253. data/mods/standard/sets/type/signup.rb +92 -0
  254. data/mods/standard/sets/type/skin.rb +4 -5
  255. data/mods/standard/sets/type/toggle.rb +1 -1
  256. data/mods/standard/sets/type/user.rb +51 -4
  257. data/public/{404.html → assets/jasmine/404.html} +0 -0
  258. data/public/{500.html → assets/jasmine/500.html} +0 -0
  259. data/public/{jasmine → assets/jasmine}/card_form.html +0 -0
  260. data/public/assets/jquery-ui/animated-overlay-602eee4c79a4796b02bb6442948c9e28.gif +0 -0
  261. data/public/assets/jquery-ui/animated-overlay.gif +0 -0
  262. data/public/assets/{images → jquery-ui}/ui-bg_flat_0_aaaaaa_40x100-7d1197a52442bc56fcad60d0390f4b32.png +0 -0
  263. data/{app/assets/images/images → public/assets/jquery-ui}/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  264. data/public/assets/{images → jquery-ui}/ui-bg_flat_75_ffffff_40x100-3c4b974defa5e8bdaf8a603034c4435e.png +0 -0
  265. data/{app/assets/images/images → public/assets/jquery-ui}/ui-bg_flat_75_ffffff_40x100.png +0 -0
  266. data/public/assets/{images → jquery-ui}/ui-bg_glass_55_fbf9ee_1x400-38c2dea4d046fd3f56cc3996e2e6018b.png +0 -0
  267. data/{app/assets/images/images → public/assets/jquery-ui}/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  268. data/public/assets/{images → jquery-ui}/ui-bg_glass_65_ffffff_1x400-ddb7ee7527bff283054406c50e597e1e.png +0 -0
  269. data/{app/assets/images/images → public/assets/jquery-ui}/ui-bg_glass_65_ffffff_1x400.png +0 -0
  270. data/public/assets/{images → jquery-ui}/ui-bg_glass_75_dadada_1x400-d618461418b1ebc6b7996979f4c3dc92.png +0 -0
  271. data/{app/assets/images/images → public/assets/jquery-ui}/ui-bg_glass_75_dadada_1x400.png +0 -0
  272. data/public/assets/{images → jquery-ui}/ui-bg_glass_75_e6e6e6_1x400-48d8d545f708e5870a965ce9df8b0e38.png +0 -0
  273. data/{app/assets/images/images → public/assets/jquery-ui}/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  274. data/public/assets/{images → jquery-ui}/ui-bg_glass_95_fef1ec_1x400-f3526b8f82249928f0a6baf044204b15.png +0 -0
  275. data/{app/assets/images/images → public/assets/jquery-ui}/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  276. data/public/assets/{images → jquery-ui}/ui-bg_highlight-soft_75_cccccc_1x100-cec5c56503b8480f834c3fce35dae8df.png +0 -0
  277. data/{app/assets/images/images → public/assets/jquery-ui}/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  278. data/{app/assets/images/images/ui-icons_2e83ff_256x240.png → public/assets/jquery-ui/ui-icons_222222_256x240-b1eb177a51ea7925448318a26d988842.png} +0 -0
  279. data/{app/assets/images/images → public/assets/jquery-ui}/ui-icons_222222_256x240.png +0 -0
  280. data/{app/assets/images/images/ui-icons_454545_256x240.png → public/assets/jquery-ui/ui-icons_2e83ff_256x240-49c2da9cac2dc565265586f716491298.png} +0 -0
  281. data/public/assets/{images → jquery-ui}/ui-icons_2e83ff_256x240.png +0 -0
  282. data/{app/assets/images/images/ui-icons_888888_256x240.png → public/assets/jquery-ui/ui-icons_454545_256x240-68b2fe3268f7604fb0767a0372e2db85.png} +0 -0
  283. data/public/assets/{images → jquery-ui}/ui-icons_454545_256x240.png +0 -0
  284. data/public/assets/jquery-ui/ui-icons_888888_256x240-8040cfcc88792375b7788feb59189eef.png +0 -0
  285. data/public/assets/{images → jquery-ui}/ui-icons_888888_256x240.png +0 -0
  286. data/public/assets/jquery-ui/ui-icons_cd0a0a_256x240-d4a62216bf6f0cd0071149890763a5ff.png +0 -0
  287. data/{app/assets/images/images → public/assets/jquery-ui}/ui-icons_cd0a0a_256x240.png +0 -0
  288. data/public/assets/jquery.min-388372ef65cc311f6a3df4a6ceac8d22.map +1 -0
  289. data/public/assets/jquery.min.map +1 -1
  290. data/public/assets/manifest.yml +61 -31
  291. data/public/assets/smoothness/animated-overlay-602eee4c79a4796b02bb6442948c9e28.gif +0 -0
  292. data/public/assets/smoothness/animated-overlay.gif +0 -0
  293. data/public/assets/smoothness/ui-bg_flat_0_aaaaaa_40x100-31613497e63975a54520b7065b125dea.png +0 -0
  294. data/public/assets/smoothness/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  295. data/public/assets/smoothness/ui-bg_flat_75_ffffff_40x100-f4b0e20e6f4c83b9f52cf062ed0f5284.png +0 -0
  296. data/public/assets/smoothness/ui-bg_flat_75_ffffff_40x100.png +0 -0
  297. data/public/assets/smoothness/ui-bg_glass_55_fbf9ee_1x400-e3606d6e7ad67486ffdc83edca64d4c5.png +0 -0
  298. data/public/assets/smoothness/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  299. data/public/assets/smoothness/ui-bg_glass_65_ffffff_1x400-dcec96932b90ff4cd4fea91284a6e9a3.png +0 -0
  300. data/public/assets/smoothness/ui-bg_glass_65_ffffff_1x400.png +0 -0
  301. data/public/assets/smoothness/ui-bg_glass_75_dadada_1x400-a2310f533684ede4f1216d7299b5cd58.png +0 -0
  302. data/public/assets/smoothness/ui-bg_glass_75_dadada_1x400.png +0 -0
  303. data/public/assets/smoothness/ui-bg_glass_75_e6e6e6_1x400-d872f3a0a02dea609e4b0321520236d9.png +0 -0
  304. data/public/assets/smoothness/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  305. data/public/assets/smoothness/ui-bg_glass_95_fef1ec_1x400-9ccaed8a65a3c285c16a73bdf03a69b3.png +0 -0
  306. data/public/assets/smoothness/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  307. data/public/assets/smoothness/ui-bg_highlight-soft_75_cccccc_1x100-2ef1d227b5c0f33ce3c5e45afa953991.png +0 -0
  308. data/public/assets/smoothness/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  309. data/public/assets/smoothness/ui-icons_222222_256x240-0675a996f0bdc78890f7b312c543b06a.png +0 -0
  310. data/public/assets/smoothness/ui-icons_222222_256x240.png +0 -0
  311. data/public/assets/smoothness/ui-icons_2e83ff_256x240-6aea736f81a417977efd77f183519a54.png +0 -0
  312. data/public/assets/smoothness/ui-icons_2e83ff_256x240.png +0 -0
  313. data/public/assets/smoothness/ui-icons_454545_256x240-6f4361f45745fb0cd7b0cc2851dc1cc3.png +0 -0
  314. data/public/assets/smoothness/ui-icons_454545_256x240.png +0 -0
  315. data/public/assets/smoothness/ui-icons_888888_256x240-8f6818bd8631ba3489de718e26c7e6cf.png +0 -0
  316. data/public/assets/smoothness/ui-icons_888888_256x240.png +0 -0
  317. data/public/assets/smoothness/ui-icons_cd0a0a_256x240-2969ddba6d0a9c62603a4aa85a363cda.png +0 -0
  318. data/public/assets/smoothness/ui-icons_cd0a0a_256x240.png +0 -0
  319. data/spec/controllers/card_controller_spec.rb +77 -61
  320. data/spec/controllers/location_spec.rb +3 -2
  321. data/spec/lib/card/auth_spec.rb +17 -0
  322. data/spec/lib/card/chunk_spec.rb +0 -1
  323. data/spec/lib/card/codename_spec.rb +12 -18
  324. data/spec/lib/card/content_spec.rb +0 -1
  325. data/spec/lib/card/diff_spec.rb +0 -1
  326. data/spec/lib/card/flexmail_spec.rb +19 -20
  327. data/spec/lib/card/format_spec.rb +0 -169
  328. data/spec/lib/{wagn → card}/loader_spec.rb +1 -2
  329. data/spec/lib/card/name_spec.rb +3 -5
  330. data/spec/lib/card/query_spec.rb +5 -8
  331. data/spec/{models → lib}/card/reference_spec.rb +6 -7
  332. data/spec/lib/card/revision_spec.rb +30 -0
  333. data/spec/lib/card/set_pattern_spec.rb +0 -1
  334. data/spec/lib/card/set_spec.rb +9 -9
  335. data/spec/lib/wagn/cache_spec.rb +0 -1
  336. data/spec/mailers/mailer_spec.rb +4 -9
  337. data/spec/models/card/cardtype_spec.rb +12 -14
  338. data/spec/models/card/create_spec.rb +3 -4
  339. data/spec/models/card/trash_spec.rb +24 -23
  340. data/spec/models/card/type_transition_spec.rb +3 -4
  341. data/spec/models/card/validation_spec.rb +0 -1
  342. data/spec/models/card_spec.rb +10 -11
  343. data/spec/mods/core/chunks/literal_spec.rb +0 -1
  344. data/spec/mods/core/chunks/uri_spec.rb +0 -1
  345. data/spec/mods/core/formats/data_format_spec.rb +0 -1
  346. data/spec/mods/core/formats/html_format_spec.rb +17 -18
  347. data/spec/mods/core/formats/text_format_spec.rb +0 -1
  348. data/spec/mods/core/sets/all/active_card_spec.rb +1 -2
  349. data/spec/mods/core/sets/all/attribute_tracking_spec.rb +1 -2
  350. data/spec/mods/core/sets/all/collection_spec.rb +1 -5
  351. data/spec/mods/core/sets/all/content_spec.rb +0 -1
  352. data/spec/mods/core/sets/all/fetch_spec.rb +7 -10
  353. data/spec/mods/core/sets/all/initialize_spec.rb +0 -1
  354. data/spec/mods/core/sets/all/name_spec.rb +34 -3
  355. data/spec/mods/core/sets/all/pattern_spec.rb +6 -9
  356. data/spec/mods/core/sets/all/permissions_spec.rb +61 -62
  357. data/spec/mods/core/sets/all/phases_spec.rb +1 -2
  358. data/spec/mods/core/sets/all/references_spec.rb +0 -1
  359. data/spec/mods/core/sets/all/rules2_spec.rb +31 -31
  360. data/spec/mods/core/sets/all/rules_spec.rb +3 -4
  361. data/spec/mods/core/sets/all/states_spec.rb +1 -2
  362. data/spec/mods/core/sets/all/templating_spec.rb +11 -12
  363. data/spec/mods/core/sets/all/tracked_attributes_spec.rb +18 -8
  364. data/spec/mods/core/sets/all/trash_spec.rb +1 -2
  365. data/spec/mods/core/sets/all/type_spec.rb +6 -5
  366. data/spec/mods/core/sets/all/utils_spec.rb +1 -2
  367. data/spec/mods/standard/chunks/include_spec.rb +14 -15
  368. data/spec/mods/standard/chunks/link_spec.rb +0 -1
  369. data/spec/mods/standard/formats/css_format_spec.rb +1 -2
  370. data/spec/mods/standard/formats/csv_format_spec.rb +0 -1
  371. data/spec/mods/standard/formats/email_html_format_spec.rb +1 -2
  372. data/spec/mods/standard/formats/file_format_spec.rb +0 -1
  373. data/spec/mods/standard/formats/js_format_spec.rb +3 -0
  374. data/spec/mods/standard/formats/json_format_spec.rb +0 -1
  375. data/spec/mods/standard/formats/rss_format_spec.rb +1 -2
  376. data/spec/mods/standard/formats/xml_format_spec.rb +0 -1
  377. data/spec/mods/standard/lib/machine_input_spec.rb +48 -0
  378. data/spec/mods/standard/lib/machine_spec.rb +110 -0
  379. data/spec/mods/standard/sets/all/account_spec.rb +50 -30
  380. data/spec/mods/standard/sets/all/all_css_spec.rb +0 -1
  381. data/spec/mods/standard/sets/all/all_csv_spec.rb +0 -1
  382. data/spec/mods/standard/sets/all/attach_spec.rb +0 -1
  383. data/spec/mods/standard/sets/all/base_spec.rb +5 -6
  384. data/spec/mods/standard/sets/all/comment_spec.rb +5 -0
  385. data/spec/mods/standard/sets/all/email_html_spec.rb +2 -3
  386. data/spec/mods/standard/sets/all/event_viz_spec.rb +7 -0
  387. data/spec/mods/standard/sets/all/file_spec.rb +0 -1
  388. data/spec/mods/standard/sets/all/flexmail_spec.rb +0 -1
  389. data/spec/mods/standard/sets/all/follow_spec.rb +10 -11
  390. data/spec/mods/standard/sets/all/history_spec.rb +10 -0
  391. data/spec/mods/standard/sets/all/json_spec.rb +5 -6
  392. data/spec/mods/standard/sets/all/rich_html_spec.rb +16 -13
  393. data/spec/mods/standard/sets/all/rss_spec.rb +4 -2
  394. data/spec/mods/standard/sets/all/text_spec.rb +1 -2
  395. data/spec/mods/standard/sets/right/account_spec.rb +86 -2
  396. data/spec/mods/standard/sets/right/add_help_spec.rb +0 -1
  397. data/spec/mods/standard/sets/right/comment_spec.rb +37 -2
  398. data/spec/mods/standard/sets/right/create_spec.rb +6 -2
  399. data/spec/mods/standard/sets/right/default_spec.rb +0 -1
  400. data/spec/mods/standard/sets/right/delete_spec.rb +0 -1
  401. data/spec/mods/standard/sets/right/email_spec.rb +43 -15
  402. data/spec/mods/standard/sets/right/help_spec.rb +0 -1
  403. data/spec/mods/standard/sets/right/machine_output_spec.rb +20 -0
  404. data/spec/mods/standard/sets/right/password_spec.rb +45 -0
  405. data/spec/mods/standard/sets/right/read_spec.rb +0 -1
  406. data/spec/mods/standard/sets/right/salt_spec.rb +0 -1
  407. data/spec/mods/standard/sets/right/script_spec.rb +20 -0
  408. data/spec/mods/standard/sets/right/stats_spec.rb +13 -0
  409. data/spec/mods/standard/sets/right/status_spec.rb +5 -0
  410. data/spec/mods/standard/sets/right/structure_spec.rb +2 -3
  411. data/spec/mods/standard/sets/right/style_spec.rb +19 -2
  412. data/spec/mods/standard/sets/right/token_spec.rb +5 -0
  413. data/spec/mods/standard/sets/right/update_spec.rb +0 -1
  414. data/spec/mods/standard/sets/right/when_created_spec.rb +0 -1
  415. data/spec/mods/standard/sets/right/when_last_edited_spec.rb +0 -1
  416. data/spec/mods/standard/sets/rstar/rules_spec.rb +3 -4
  417. data/spec/mods/standard/sets/self/account_links_spec.rb +0 -1
  418. data/spec/mods/standard/sets/self/alerts_spec.rb +0 -1
  419. data/spec/mods/standard/sets/self/all_spec.rb +47 -0
  420. data/spec/mods/standard/sets/self/foot_spec.rb +0 -1
  421. data/spec/mods/standard/sets/self/head_spec.rb +0 -1
  422. data/spec/mods/standard/sets/self/navbox_spec.rb +0 -1
  423. data/spec/mods/standard/sets/self/now_spec.rb +0 -1
  424. data/spec/mods/standard/sets/self/recent_spec.rb +1 -2
  425. data/spec/mods/standard/sets/self/search_spec.rb +1 -2
  426. data/spec/mods/standard/sets/self/signin_spec.rb +73 -0
  427. data/spec/mods/standard/sets/self/stats_spec.rb +12 -0
  428. data/spec/mods/standard/sets/self/style_functional_spec.rb +1 -2
  429. data/spec/mods/standard/sets/self/style_jquery_ui_smoothness_spec.rb +1 -2
  430. data/spec/mods/standard/sets/self/style_standard_spec.rb +1 -2
  431. data/spec/mods/standard/sets/self/version_spec.rb +0 -1
  432. data/spec/mods/standard/sets/type/basic_spec.rb +1 -2
  433. data/spec/mods/standard/sets/type/cardtype_spec.rb +1 -2
  434. data/spec/mods/standard/sets/type/coffeescript_spec.rb +28 -0
  435. data/spec/mods/standard/sets/type/css_spec.rb +31 -4
  436. data/spec/mods/standard/sets/type/date_spec.rb +0 -1
  437. data/spec/mods/standard/sets/type/file_spec.rb +1 -2
  438. data/spec/mods/standard/sets/type/html_spec.rb +3 -4
  439. data/spec/mods/standard/sets/type/image_spec.rb +1 -2
  440. data/spec/mods/standard/sets/type/javascript_spec.rb +28 -0
  441. data/spec/mods/standard/sets/type/layout_type_spec.rb +0 -1
  442. data/spec/mods/standard/sets/type/number_spec.rb +0 -1
  443. data/spec/mods/standard/sets/type/phrase_spec.rb +0 -1
  444. data/spec/mods/standard/sets/type/plain_text_spec.rb +0 -1
  445. data/spec/mods/standard/sets/type/pointer_spec.rb +1 -2
  446. data/spec/mods/standard/sets/type/scss_spec.rb +47 -2
  447. data/spec/mods/standard/sets/type/search_type_spec.rb +14 -3
  448. data/spec/mods/standard/sets/type/set_spec.rb +0 -1
  449. data/spec/mods/standard/sets/type/setting_spec.rb +6 -2
  450. data/spec/mods/standard/sets/type/signup_spec.rb +93 -0
  451. data/spec/mods/standard/sets/type/skin_spec.rb +23 -2
  452. data/spec/mods/standard/sets/type/toggle_spec.rb +0 -1
  453. data/spec/mods/standard/sets/type/user_spec.rb +1 -2
  454. data/{lib/wagn → spec}/spec_helper.rb +59 -14
  455. data/test/1.10.0-data-dump.sql +327 -0
  456. data/test/fixtures/card_references.yml +777 -581
  457. data/test/fixtures/card_revisions.yml +2737 -2488
  458. data/test/fixtures/cards.yml +4037 -2184
  459. data/test/performance/card_create_test.rb +1 -1
  460. data/test/performance/render_test.rb +1 -1
  461. data/test/seed.rb +36 -63
  462. data/test/test_helper.rb +1 -1
  463. data/wagn.gemspec +9 -9
  464. metadata +257 -237
  465. data/app/assets/javascripts/html5shiv-printshiv.js +0 -499
  466. data/app/controllers/account_controller.rb +0 -61
  467. data/app/controllers/admin_controller.rb +0 -124
  468. data/app/controllers/stub_card_controller.rb +0 -9
  469. data/app/controllers/wagn_controller.rb +0 -165
  470. data/app/mailers/mailer.rb +0 -109
  471. data/app/models/.gitkeep +0 -0
  472. data/app/models/account.rb +0 -198
  473. data/app/models/user.rb +0 -123
  474. data/app/views/mailer/account_info.text.erb +0 -17
  475. data/config/initializers/backtrace_silencers.rb +0 -8
  476. data/config/initializers/schema_views.rb +0 -59
  477. data/config/initializers/wrap_parameters.rb +0 -15
  478. data/config/samples/database.yml.erb +0 -34
  479. data/db/bootstrap/users.yml +0 -29
  480. data/features/account_requests.feature +0 -22
  481. data/features/google_maps.feature +0 -31
  482. data/features/hello_wagn.feature +0 -31
  483. data/features/step_definitions/notification_steps.rb +0 -23
  484. data/features/templates.feature +0 -30
  485. data/features/virtual_cards.feature +0 -11
  486. data/lib/active_record/foreign_keys.rb +0 -80
  487. data/lib/card/constant.rb +0 -20
  488. data/lib/generators/set/templates/set_template.erb +0 -1
  489. data/lib/tasks/.gitkeep +0 -0
  490. data/lib/wagn/authenticated_system.rb +0 -38
  491. data/lib/wagn/env.rb +0 -42
  492. data/lib/wagn/loader.rb +0 -135
  493. data/mods/standard/formats/kml_format.rb +0 -6
  494. data/mods/standard/lib/google_maps_addon.rb +0 -30
  495. data/mods/standard/sets/all/admin.rb +0 -53
  496. data/mods/standard/sets/all/geocode.rb +0 -16
  497. data/mods/standard/sets/all/kml.rb +0 -49
  498. data/mods/standard/sets/type/account_request.rb +0 -74
  499. data/mods/standard/sets/type/ruby_and_script.rb +0 -31
  500. data/public/assets/application-058913c45d4f3262667bad443a03eb45.js +0 -144
  501. data/public/assets/application-058913c45d4f3262667bad443a03eb45.js.gz +0 -0
  502. data/public/assets/application.js +0 -144
  503. data/public/assets/application.js.gz +0 -0
  504. data/public/assets/html5shiv-printshiv-ad36fc7219f4aeaa275f9a7fe2383413.js +0 -1
  505. data/public/assets/html5shiv-printshiv-ad36fc7219f4aeaa275f9a7fe2383413.js.gz +0 -0
  506. data/public/assets/html5shiv-printshiv.js.gz +0 -0
  507. data/public/assets/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  508. data/public/assets/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  509. data/public/assets/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  510. data/public/assets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  511. data/public/assets/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  512. data/public/assets/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  513. data/public/assets/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  514. data/public/assets/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  515. data/public/assets/images/ui-icons_222222_256x240-66e635a2f90b9f90675d402617630b24.png +0 -0
  516. data/public/assets/images/ui-icons_222222_256x240.png +0 -0
  517. data/public/assets/images/ui-icons_2e83ff_256x240-2ea4c160a75c1992daa2eeac86255b99.png +0 -0
  518. data/public/assets/images/ui-icons_454545_256x240-5c7f12676bcead9cb2d4cb8f23f16e95.png +0 -0
  519. data/public/assets/images/ui-icons_888888_256x240-95fd3047e1f7325d995a21c729b04125.png +0 -0
  520. data/public/assets/images/ui-icons_cd0a0a_256x240-c0c1ec6a8bcf48fec40303e975a4dfa6.png +0 -0
  521. data/public/assets/images/ui-icons_cd0a0a_256x240.png +0 -0
  522. data/public/assets/jquery.min-8b58c0fbf303b938d8e749262f7e50dd.map +0 -1
  523. data/public/assets/tinymce-22b5a139d9ff7df7643afae9ce205508.js +0 -13
  524. data/public/assets/tinymce-22b5a139d9ff7df7643afae9ce205508.js.gz +0 -0
  525. data/public/assets/tinymce.js +0 -13
  526. data/public/assets/tinymce.js.gz +0 -0
  527. data/spec/controllers/account_controller_spec.rb +0 -42
  528. data/spec/controllers/admin_controller_spec.rb +0 -23
  529. data/spec/controllers/captcha_spec.rb +0 -103
  530. data/spec/controllers/sets_spec.rb +0 -97
  531. data/spec/controllers/wagn_controller_spec.rb +0 -5
  532. data/spec/mailers/account_spec.rb +0 -66
  533. data/spec/models/account_spec.rb +0 -19
  534. data/spec/models/card/comment_spec.rb +0 -38
  535. data/spec/models/card/revision_spec.rb +0 -58
  536. data/spec/models/user_spec.rb +0 -95
  537. data/spec/mods/standard/formats/kml_format_spec.rb +0 -6
  538. data/spec/mods/standard/sets/all/admin_spec.rb +0 -6
  539. data/spec/mods/standard/sets/all/geocode_spec.rb +0 -37
  540. data/spec/mods/standard/sets/all/kml_spec.rb +0 -6
  541. data/spec/mods/standard/sets/right/crypted_password_spec.rb +0 -6
  542. data/spec/mods/standard/sets/type/account_request_spec.rb +0 -160
  543. data/spec/mods/standard/sets/type/ruby_and_script_spec.rb +0 -6
  544. data/spec/spec.opts +0 -6
  545. data/test/fixtures/users.yml +0 -169
@@ -0,0 +1,255 @@
1
+ /*!
2
+ Autosize v1.17.7 - 2013-09-03
3
+ Automatically adjust textarea height based on user input.
4
+ (c) 2013 Jack Moore - http://www.jacklmoore.com/autosize
5
+ license: http://www.opensource.org/licenses/mit-license.php
6
+ */
7
+
8
+ (function (factory) {
9
+ if (typeof define === 'function' && define.amd) {
10
+ // AMD. Register as an anonymous module.
11
+ define(['jquery'], factory);
12
+ } else {
13
+ // Browser globals: jQuery or jQuery-like library, such as Zepto
14
+ factory(window.jQuery || window.$);
15
+ }
16
+ }(function ($) {
17
+ var
18
+ defaults = {
19
+ className: 'autosizejs',
20
+ append: '',
21
+ callback: false,
22
+ resizeDelay: 10
23
+ },
24
+
25
+ // border:0 is unnecessary, but avoids a bug in FireFox on OSX
26
+ copy = '<textarea tabindex="-1" style="position:absolute; top:-999px; left:0; right:auto; bottom:auto; border:0; padding: 0; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden; transition:none; -webkit-transition:none; -moz-transition:none;"/>',
27
+
28
+ // line-height is conditionally included because IE7/IE8/old Opera do not return the correct value.
29
+ typographyStyles = [
30
+ 'fontFamily',
31
+ 'fontSize',
32
+ 'fontWeight',
33
+ 'fontStyle',
34
+ 'letterSpacing',
35
+ 'textTransform',
36
+ 'wordSpacing',
37
+ 'textIndent'
38
+ ],
39
+
40
+ // to keep track which textarea is being mirrored when adjust() is called.
41
+ mirrored,
42
+
43
+ // the mirror element, which is used to calculate what size the mirrored element should be.
44
+ mirror = $(copy).data('autosize', true)[0];
45
+
46
+ // test that line-height can be accurately copied.
47
+ mirror.style.lineHeight = '99px';
48
+ if ($(mirror).css('lineHeight') === '99px') {
49
+ typographyStyles.push('lineHeight');
50
+ }
51
+ mirror.style.lineHeight = '';
52
+
53
+ $.fn.autosize = function (options) {
54
+ options = $.extend({}, defaults, options || {});
55
+
56
+ if (mirror.parentNode !== document.body) {
57
+ $(document.body).append(mirror);
58
+ }
59
+
60
+ return this.each(function () {
61
+ var
62
+ ta = this,
63
+ $ta = $(ta),
64
+ maxHeight,
65
+ minHeight,
66
+ boxOffset = 0,
67
+ callback = $.isFunction(options.callback),
68
+ originalStyles = {
69
+ height: ta.style.height,
70
+ overflow: ta.style.overflow,
71
+ overflowY: ta.style.overflowY,
72
+ wordWrap: ta.style.wordWrap,
73
+ resize: ta.style.resize
74
+ },
75
+ timeout,
76
+ width = $ta.width();
77
+
78
+ if ($ta.data('autosize')) {
79
+ // exit if autosize has already been applied, or if the textarea is the mirror element.
80
+ return;
81
+ }
82
+ $ta.data('autosize', true);
83
+
84
+ if ($ta.css('box-sizing') === 'border-box' || $ta.css('-moz-box-sizing') === 'border-box' || $ta.css('-webkit-box-sizing') === 'border-box'){
85
+ boxOffset = $ta.outerHeight() - $ta.height();
86
+ }
87
+
88
+ // IE8 and lower return 'auto', which parses to NaN, if no min-height is set.
89
+ minHeight = Math.max(parseInt($ta.css('minHeight'), 10) - boxOffset || 0, $ta.height());
90
+
91
+ $ta.css({
92
+ overflow: 'hidden',
93
+ overflowY: 'hidden',
94
+ wordWrap: 'break-word', // horizontal overflow is hidden, so break-word is necessary for handling words longer than the textarea width
95
+ resize: ($ta.css('resize') === 'none' || $ta.css('resize') === 'vertical') ? 'none' : 'horizontal'
96
+ });
97
+
98
+ // The mirror width must exactly match the textarea width, so using getBoundingClientRect because it doesn't round the sub-pixel value.
99
+ function setWidth() {
100
+ var style, width;
101
+
102
+ if ('getComputedStyle' in window) {
103
+ style = window.getComputedStyle(ta);
104
+ width = ta.getBoundingClientRect().width;
105
+
106
+ $.each(['paddingLeft', 'paddingRight', 'borderLeftWidth', 'borderRightWidth'], function(i,val){
107
+ width -= parseInt(style[val],10);
108
+ });
109
+
110
+ mirror.style.width = width + 'px';
111
+ }
112
+ else {
113
+ // window.getComputedStyle, getBoundingClientRect returning a width are unsupported and unneeded in IE8 and lower.
114
+ mirror.style.width = Math.max($ta.width(), 0) + 'px';
115
+ }
116
+ }
117
+
118
+ function initMirror() {
119
+ var styles = {};
120
+
121
+ mirrored = ta;
122
+ mirror.className = options.className;
123
+ maxHeight = parseInt($ta.css('maxHeight'), 10);
124
+
125
+ // mirror is a duplicate textarea located off-screen that
126
+ // is automatically updated to contain the same text as the
127
+ // original textarea. mirror always has a height of 0.
128
+ // This gives a cross-browser supported way getting the actual
129
+ // height of the text, through the scrollTop property.
130
+ $.each(typographyStyles, function(i,val){
131
+ styles[val] = $ta.css(val);
132
+ });
133
+ $(mirror).css(styles);
134
+
135
+ setWidth();
136
+
137
+ // Chrome-specific fix:
138
+ // When the textarea y-overflow is hidden, Chrome doesn't reflow the text to account for the space
139
+ // made available by removing the scrollbar. This workaround triggers the reflow for Chrome.
140
+ if (window.chrome) {
141
+ var width = ta.style.width;
142
+ ta.style.width = '0px';
143
+ var ignore = ta.offsetWidth;
144
+ ta.style.width = width;
145
+ }
146
+ }
147
+
148
+ // Using mainly bare JS in this function because it is going
149
+ // to fire very often while typing, and needs to very efficient.
150
+ function adjust() {
151
+ var height, original;
152
+
153
+ if (mirrored !== ta) {
154
+ initMirror();
155
+ } else {
156
+ setWidth();
157
+ }
158
+
159
+ mirror.value = ta.value + options.append;
160
+ mirror.style.overflowY = ta.style.overflowY;
161
+ original = parseInt(ta.style.height,10);
162
+
163
+ // Setting scrollTop to zero is needed in IE8 and lower for the next step to be accurately applied
164
+ mirror.scrollTop = 0;
165
+
166
+ mirror.scrollTop = 9e4;
167
+
168
+ // Using scrollTop rather than scrollHeight because scrollHeight is non-standard and includes padding.
169
+ height = mirror.scrollTop;
170
+
171
+ if (maxHeight && height > maxHeight) {
172
+ ta.style.overflowY = 'scroll';
173
+ height = maxHeight;
174
+ } else {
175
+ ta.style.overflowY = 'hidden';
176
+ if (height < minHeight) {
177
+ height = minHeight;
178
+ }
179
+ }
180
+
181
+ height += boxOffset;
182
+
183
+ if (original !== height) {
184
+ ta.style.height = height + 'px';
185
+ if (callback) {
186
+ options.callback.call(ta,ta);
187
+ }
188
+ }
189
+ }
190
+
191
+ function resize () {
192
+ clearTimeout(timeout);
193
+ timeout = setTimeout(function(){
194
+ var newWidth = $ta.width();
195
+
196
+ if (newWidth !== width) {
197
+ width = newWidth;
198
+ adjust();
199
+ }
200
+ }, parseInt(options.resizeDelay,10));
201
+ }
202
+
203
+ if ('onpropertychange' in ta) {
204
+ if ('oninput' in ta) {
205
+ // Detects IE9. IE9 does not fire onpropertychange or oninput for deletions,
206
+ // so binding to onkeyup to catch most of those occasions. There is no way that I
207
+ // know of to detect something like 'cut' in IE9.
208
+ $ta.on('input.autosize keyup.autosize', adjust);
209
+ } else {
210
+ // IE7 / IE8
211
+ $ta.on('propertychange.autosize', function(){
212
+ if(event.propertyName === 'value'){
213
+ adjust();
214
+ }
215
+ });
216
+ }
217
+ } else {
218
+ // Modern Browsers
219
+ $ta.on('input.autosize', adjust);
220
+ }
221
+
222
+ // Set options.resizeDelay to false if using fixed-width textarea elements.
223
+ // Uses a timeout and width check to reduce the amount of times adjust needs to be called after window resize.
224
+
225
+ if (options.resizeDelay !== false) {
226
+ $(window).on('resize.autosize', resize);
227
+ }
228
+
229
+ // Event for manual triggering if needed.
230
+ // Should only be needed when the value of the textarea is changed through JavaScript rather than user input.
231
+ $ta.on('autosize.resize', adjust);
232
+
233
+ // Event for manual triggering that also forces the styles to update as well.
234
+ // Should only be needed if one of typography styles of the textarea change, and the textarea is already the target of the adjust method.
235
+ $ta.on('autosize.resizeIncludeStyle', function() {
236
+ mirrored = null;
237
+ adjust();
238
+ });
239
+
240
+ $ta.on('autosize.destroy', function(){
241
+ mirrored = null;
242
+ clearTimeout(timeout);
243
+ $(window).off('resize', resize);
244
+ $ta
245
+ .off('autosize')
246
+ .off('.autosize')
247
+ .css(originalStyles)
248
+ .removeData('autosize');
249
+ });
250
+
251
+ // Call adjust in case the textarea already contains text.
252
+ adjust();
253
+ });
254
+ };
255
+ }));
@@ -0,0 +1,1112 @@
1
+ /*
2
+ * jQuery File Upload Plugin 5.19.4
3
+ * https://github.com/blueimp/jQuery-File-Upload
4
+ *
5
+ * Copyright 2010, Sebastian Tschan
6
+ * https://blueimp.net
7
+ *
8
+ * Licensed under the MIT license:
9
+ * http://www.opensource.org/licenses/MIT
10
+ */
11
+
12
+ /*jslint nomen: true, unparam: true, regexp: true */
13
+ /*global define, window, document, File, Blob, FormData, location */
14
+
15
+
16
+ (function (factory) {
17
+ 'use strict';
18
+ if (typeof define === 'function' && define.amd) {
19
+ // Register as an anonymous AMD module:
20
+ define([
21
+ 'jquery',
22
+ 'jquery.ui.widget'
23
+ ], factory);
24
+ } else {
25
+ // Browser globals:
26
+ factory(window.jQuery);
27
+ }
28
+ }(function ($) {
29
+ 'use strict';
30
+
31
+ // The FileReader API is not actually used, but works as feature detection,
32
+ // as e.g. Safari supports XHR file uploads via the FormData API,
33
+ // but not non-multipart XHR file uploads:
34
+ $.support.xhrFileUpload = !!(window.XMLHttpRequestUpload && window.FileReader);
35
+ $.support.xhrFormDataFileUpload = !!window.FormData;
36
+
37
+ // The fileupload widget listens for change events on file input fields defined
38
+ // via fileInput setting and paste or drop events of the given dropZone.
39
+ // In addition to the default jQuery Widget methods, the fileupload widget
40
+ // exposes the "add" and "send" methods, to add or directly send files using
41
+ // the fileupload API.
42
+ // By default, files added via file input selection, paste, drag & drop or
43
+ // "add" method are uploaded immediately, but it is possible to override
44
+ // the "add" callback option to queue file uploads.
45
+ $.widget('blueimp.fileupload', {
46
+
47
+ options: {
48
+ // The drop target element(s), by the default the complete document.
49
+ // Set to null to disable drag & drop support:
50
+ dropZone: $(document),
51
+ // The paste target element(s), by the default the complete document.
52
+ // Set to null to disable paste support:
53
+ pasteZone: $(document),
54
+ // The file input field(s), that are listened to for change events.
55
+ // If undefined, it is set to the file input fields inside
56
+ // of the widget element on plugin initialization.
57
+ // Set to null to disable the change listener.
58
+ fileInput: undefined,
59
+ // By default, the file input field is replaced with a clone after
60
+ // each input field change event. This is required for iframe transport
61
+ // queues and allows change events to be fired for the same file
62
+ // selection, but can be disabled by setting the following option to false:
63
+ replaceFileInput: true,
64
+ // The parameter name for the file form data (the request argument name).
65
+ // If undefined or empty, the name property of the file input field is
66
+ // used, or "files[]" if the file input name property is also empty,
67
+ // can be a string or an array of strings:
68
+ paramName: undefined,
69
+ // By default, each file of a selection is uploaded using an individual
70
+ // request for XHR type uploads. Set to false to upload file
71
+ // selections in one request each:
72
+ singleFileUploads: true,
73
+ // To limit the number of files uploaded with one XHR request,
74
+ // set the following option to an integer greater than 0:
75
+ limitMultiFileUploads: undefined,
76
+ // Set the following option to true to issue all file upload requests
77
+ // in a sequential order:
78
+ sequentialUploads: false,
79
+ // To limit the number of concurrent uploads,
80
+ // set the following option to an integer greater than 0:
81
+ limitConcurrentUploads: undefined,
82
+ // Set the following option to true to force iframe transport uploads:
83
+ forceIframeTransport: false,
84
+ // Set the following option to the location of a redirect url on the
85
+ // origin server, for cross-domain iframe transport uploads:
86
+ redirect: undefined,
87
+ // The parameter name for the redirect url, sent as part of the form
88
+ // data and set to 'redirect' if this option is empty:
89
+ redirectParamName: undefined,
90
+ // Set the following option to the location of a postMessage window,
91
+ // to enable postMessage transport uploads:
92
+ postMessage: undefined,
93
+ // By default, XHR file uploads are sent as multipart/form-data.
94
+ // The iframe transport is always using multipart/form-data.
95
+ // Set to false to enable non-multipart XHR uploads:
96
+ multipart: true,
97
+ // To upload large files in smaller chunks, set the following option
98
+ // to a preferred maximum chunk size. If set to 0, null or undefined,
99
+ // or the browser does not support the required Blob API, files will
100
+ // be uploaded as a whole.
101
+ maxChunkSize: undefined,
102
+ // When a non-multipart upload or a chunked multipart upload has been
103
+ // aborted, this option can be used to resume the upload by setting
104
+ // it to the size of the already uploaded bytes. This option is most
105
+ // useful when modifying the options object inside of the "add" or
106
+ // "send" callbacks, as the options are cloned for each file upload.
107
+ uploadedBytes: undefined,
108
+ // By default, failed (abort or error) file uploads are removed from the
109
+ // global progress calculation. Set the following option to false to
110
+ // prevent recalculating the global progress data:
111
+ recalculateProgress: true,
112
+ // Interval in milliseconds to calculate and trigger progress events:
113
+ progressInterval: 100,
114
+ // Interval in milliseconds to calculate progress bitrate:
115
+ bitrateInterval: 500,
116
+
117
+ // Additional form data to be sent along with the file uploads can be set
118
+ // using this option, which accepts an array of objects with name and
119
+ // value properties, a function returning such an array, a FormData
120
+ // object (for XHR file uploads), or a simple object.
121
+ // The form of the first fileInput is given as parameter to the function:
122
+ formData: function (form) {
123
+ return form.serializeArray();
124
+ },
125
+
126
+ // The add callback is invoked as soon as files are added to the fileupload
127
+ // widget (via file input selection, drag & drop, paste or add API call).
128
+ // If the singleFileUploads option is enabled, this callback will be
129
+ // called once for each file in the selection for XHR file uplaods, else
130
+ // once for each file selection.
131
+ // The upload starts when the submit method is invoked on the data parameter.
132
+ // The data object contains a files property holding the added files
133
+ // and allows to override plugin options as well as define ajax settings.
134
+ // Listeners for this callback can also be bound the following way:
135
+ // .bind('fileuploadadd', func);
136
+ // data.submit() returns a Promise object and allows to attach additional
137
+ // handlers using jQuery's Deferred callbacks:
138
+ // data.submit().done(func).fail(func).always(func);
139
+ add: function (e, data) {
140
+ data.submit();
141
+ },
142
+
143
+ // Other callbacks:
144
+ // Callback for the submit event of each file upload:
145
+ // submit: function (e, data) {}, // .bind('fileuploadsubmit', func);
146
+ // Callback for the start of each file upload request:
147
+ // send: function (e, data) {}, // .bind('fileuploadsend', func);
148
+ // Callback for successful uploads:
149
+ // done: function (e, data) {}, // .bind('fileuploaddone', func);
150
+ // Callback for failed (abort or error) uploads:
151
+ // fail: function (e, data) {}, // .bind('fileuploadfail', func);
152
+ // Callback for completed (success, abort or error) requests:
153
+ // always: function (e, data) {}, // .bind('fileuploadalways', func);
154
+ // Callback for upload progress events:
155
+ // progress: function (e, data) {}, // .bind('fileuploadprogress', func);
156
+ // Callback for global upload progress events:
157
+ // progressall: function (e, data) {}, // .bind('fileuploadprogressall', func);
158
+ // Callback for uploads start, equivalent to the global ajaxStart event:
159
+ // start: function (e) {}, // .bind('fileuploadstart', func);
160
+ // Callback for uploads stop, equivalent to the global ajaxStop event:
161
+ // stop: function (e) {}, // .bind('fileuploadstop', func);
162
+ // Callback for change events of the fileInput(s):
163
+ // change: function (e, data) {}, // .bind('fileuploadchange', func);
164
+ // Callback for paste events to the pasteZone(s):
165
+ // paste: function (e, data) {}, // .bind('fileuploadpaste', func);
166
+ // Callback for drop events of the dropZone(s):
167
+ // drop: function (e, data) {}, // .bind('fileuploaddrop', func);
168
+ // Callback for dragover events of the dropZone(s):
169
+ // dragover: function (e) {}, // .bind('fileuploaddragover', func);
170
+
171
+ // The plugin options are used as settings object for the ajax calls.
172
+ // The following are jQuery ajax settings required for the file uploads:
173
+ processData: false,
174
+ contentType: false,
175
+ cache: false
176
+ },
177
+
178
+ // A list of options that require a refresh after assigning a new value:
179
+ _refreshOptionsList: [
180
+ 'fileInput',
181
+ 'dropZone',
182
+ 'pasteZone',
183
+ 'multipart',
184
+ 'forceIframeTransport'
185
+ ],
186
+
187
+ _BitrateTimer: function () {
188
+ this.timestamp = +(new Date());
189
+ this.loaded = 0;
190
+ this.bitrate = 0;
191
+ this.getBitrate = function (now, loaded, interval) {
192
+ var timeDiff = now - this.timestamp;
193
+ if (!this.bitrate || !interval || timeDiff > interval) {
194
+ this.bitrate = (loaded - this.loaded) * (1000 / timeDiff) * 8;
195
+ this.loaded = loaded;
196
+ this.timestamp = now;
197
+ }
198
+ return this.bitrate;
199
+ };
200
+ },
201
+
202
+ _isXHRUpload: function (options) {
203
+ return !options.forceIframeTransport &&
204
+ ((!options.multipart && $.support.xhrFileUpload) ||
205
+ $.support.xhrFormDataFileUpload);
206
+ },
207
+
208
+ _getFormData: function (options) {
209
+ var formData;
210
+ if (typeof options.formData === 'function') {
211
+ return options.formData(options.form);
212
+ }
213
+ if ($.isArray(options.formData)) {
214
+ return options.formData;
215
+ }
216
+ if (options.formData) {
217
+ formData = [];
218
+ $.each(options.formData, function (name, value) {
219
+ formData.push({name: name, value: value});
220
+ });
221
+ return formData;
222
+ }
223
+ return [];
224
+ },
225
+
226
+ _getTotal: function (files) {
227
+ var total = 0;
228
+ $.each(files, function (index, file) {
229
+ total += file.size || 1;
230
+ });
231
+ return total;
232
+ },
233
+
234
+ _onProgress: function (e, data) {
235
+ if (e.lengthComputable) {
236
+ var now = +(new Date()),
237
+ total,
238
+ loaded;
239
+ if (data._time && data.progressInterval &&
240
+ (now - data._time < data.progressInterval) &&
241
+ e.loaded !== e.total) {
242
+ return;
243
+ }
244
+ data._time = now;
245
+ total = data.total || this._getTotal(data.files);
246
+ loaded = parseInt(
247
+ e.loaded / e.total * (data.chunkSize || total),
248
+ 10
249
+ ) + (data.uploadedBytes || 0);
250
+ this._loaded += loaded - (data.loaded || data.uploadedBytes || 0);
251
+ data.lengthComputable = true;
252
+ data.loaded = loaded;
253
+ data.total = total;
254
+ data.bitrate = data._bitrateTimer.getBitrate(
255
+ now,
256
+ loaded,
257
+ data.bitrateInterval
258
+ );
259
+ // Trigger a custom progress event with a total data property set
260
+ // to the file size(s) of the current upload and a loaded data
261
+ // property calculated accordingly:
262
+ this._trigger('progress', e, data);
263
+ // Trigger a global progress event for all current file uploads,
264
+ // including ajax calls queued for sequential file uploads:
265
+ this._trigger('progressall', e, {
266
+ lengthComputable: true,
267
+ loaded: this._loaded,
268
+ total: this._total,
269
+ bitrate: this._bitrateTimer.getBitrate(
270
+ now,
271
+ this._loaded,
272
+ data.bitrateInterval
273
+ )
274
+ });
275
+ }
276
+ },
277
+
278
+ _initProgressListener: function (options) {
279
+ var that = this,
280
+ xhr = options.xhr ? options.xhr() : $.ajaxSettings.xhr();
281
+ // Accesss to the native XHR object is required to add event listeners
282
+ // for the upload progress event:
283
+ if (xhr.upload) {
284
+ $(xhr.upload).bind('progress', function (e) {
285
+ var oe = e.originalEvent;
286
+ // Make sure the progress event properties get copied over:
287
+ e.lengthComputable = oe.lengthComputable;
288
+ e.loaded = oe.loaded;
289
+ e.total = oe.total;
290
+ that._onProgress(e, options);
291
+ });
292
+ options.xhr = function () {
293
+ return xhr;
294
+ };
295
+ }
296
+ },
297
+
298
+ _initXHRData: function (options) {
299
+ var formData,
300
+ file = options.files[0],
301
+ // Ignore non-multipart setting if not supported:
302
+ multipart = options.multipart || !$.support.xhrFileUpload,
303
+ paramName = options.paramName[0];
304
+ options.headers = options.headers || {};
305
+ if (options.contentRange) {
306
+ options.headers['Content-Range'] = options.contentRange;
307
+ }
308
+ if (!multipart) {
309
+ options.headers['Content-Disposition'] = 'attachment; filename="' +
310
+ encodeURI(file.name) + '"';
311
+ options.contentType = file.type;
312
+ options.data = options.blob || file;
313
+ } else if ($.support.xhrFormDataFileUpload) {
314
+ if (options.postMessage) {
315
+ // window.postMessage does not allow sending FormData
316
+ // objects, so we just add the File/Blob objects to
317
+ // the formData array and let the postMessage window
318
+ // create the FormData object out of this array:
319
+ formData = this._getFormData(options);
320
+ if (options.blob) {
321
+ formData.push({
322
+ name: paramName,
323
+ value: options.blob
324
+ });
325
+ } else {
326
+ $.each(options.files, function (index, file) {
327
+ formData.push({
328
+ name: options.paramName[index] || paramName,
329
+ value: file
330
+ });
331
+ });
332
+ }
333
+ } else {
334
+ if (options.formData instanceof FormData) {
335
+ formData = options.formData;
336
+ } else {
337
+ formData = new FormData();
338
+ $.each(this._getFormData(options), function (index, field) {
339
+ formData.append(field.name, field.value);
340
+ });
341
+ }
342
+ if (options.blob) {
343
+ options.headers['Content-Disposition'] = 'attachment; filename="' +
344
+ encodeURI(file.name) + '"';
345
+ options.headers['Content-Description'] = encodeURI(file.type);
346
+ formData.append(paramName, options.blob, file.name);
347
+ } else {
348
+ $.each(options.files, function (index, file) {
349
+ // Files are also Blob instances, but some browsers
350
+ // (Firefox 3.6) support the File API but not Blobs.
351
+ // This check allows the tests to run with
352
+ // dummy objects:
353
+ if ((window.Blob && file instanceof Blob) ||
354
+ (window.File && file instanceof File)) {
355
+ formData.append(
356
+ options.paramName[index] || paramName,
357
+ file,
358
+ file.name
359
+ );
360
+ }
361
+ });
362
+ }
363
+ }
364
+ options.data = formData;
365
+ }
366
+ // Blob reference is not needed anymore, free memory:
367
+ options.blob = null;
368
+ },
369
+
370
+ _initIframeSettings: function (options) {
371
+ // Setting the dataType to iframe enables the iframe transport:
372
+ options.dataType = 'iframe ' + (options.dataType || '');
373
+ // The iframe transport accepts a serialized array as form data:
374
+ options.formData = this._getFormData(options);
375
+ // Add redirect url to form data on cross-domain uploads:
376
+ if (options.redirect && $('<a></a>').prop('href', options.url)
377
+ .prop('host') !== location.host) {
378
+ options.formData.push({
379
+ name: options.redirectParamName || 'redirect',
380
+ value: options.redirect
381
+ });
382
+ }
383
+ },
384
+
385
+ _initDataSettings: function (options) {
386
+ if (this._isXHRUpload(options)) {
387
+ if (!this._chunkedUpload(options, true)) {
388
+ if (!options.data) {
389
+ this._initXHRData(options);
390
+ }
391
+ this._initProgressListener(options);
392
+ }
393
+ if (options.postMessage) {
394
+ // Setting the dataType to postmessage enables the
395
+ // postMessage transport:
396
+ options.dataType = 'postmessage ' + (options.dataType || '');
397
+ }
398
+ } else {
399
+ this._initIframeSettings(options, 'iframe');
400
+ }
401
+ },
402
+
403
+ _getParamName: function (options) {
404
+ var fileInput = $(options.fileInput),
405
+ paramName = options.paramName;
406
+ if (!paramName) {
407
+ paramName = [];
408
+ fileInput.each(function () {
409
+ var input = $(this),
410
+ name = input.prop('name') || 'files[]',
411
+ i = (input.prop('files') || [1]).length;
412
+ while (i) {
413
+ paramName.push(name);
414
+ i -= 1;
415
+ }
416
+ });
417
+ if (!paramName.length) {
418
+ paramName = [fileInput.prop('name') || 'files[]'];
419
+ }
420
+ } else if (!$.isArray(paramName)) {
421
+ paramName = [paramName];
422
+ }
423
+ return paramName;
424
+ },
425
+
426
+ _initFormSettings: function (options) {
427
+ // Retrieve missing options from the input field and the
428
+ // associated form, if available:
429
+ if (!options.form || !options.form.length) {
430
+ options.form = $(options.fileInput.prop('form'));
431
+ // If the given file input doesn't have an associated form,
432
+ // use the default widget file input's form:
433
+ if (!options.form.length) {
434
+ options.form = $(this.options.fileInput.prop('form'));
435
+ }
436
+ }
437
+ options.paramName = this._getParamName(options);
438
+ if (!options.url) {
439
+ options.url = options.form.prop('action') || location.href;
440
+ }
441
+ // The HTTP request method must be "POST" or "PUT":
442
+ options.type = (options.type || options.form.prop('method') || '')
443
+ .toUpperCase();
444
+ if (options.type !== 'POST' && options.type !== 'PUT') {
445
+ options.type = 'POST';
446
+ }
447
+ if (!options.formAcceptCharset) {
448
+ options.formAcceptCharset = options.form.attr('accept-charset');
449
+ }
450
+ },
451
+
452
+ _getAJAXSettings: function (data) {
453
+ var options = $.extend({}, this.options, data);
454
+ this._initFormSettings(options);
455
+ this._initDataSettings(options);
456
+ return options;
457
+ },
458
+
459
+ // Maps jqXHR callbacks to the equivalent
460
+ // methods of the given Promise object:
461
+ _enhancePromise: function (promise) {
462
+ promise.success = promise.done;
463
+ promise.error = promise.fail;
464
+ promise.complete = promise.always;
465
+ return promise;
466
+ },
467
+
468
+ // Creates and returns a Promise object enhanced with
469
+ // the jqXHR methods abort, success, error and complete:
470
+ _getXHRPromise: function (resolveOrReject, context, args) {
471
+ var dfd = $.Deferred(),
472
+ promise = dfd.promise();
473
+ context = context || this.options.context || promise;
474
+ if (resolveOrReject === true) {
475
+ dfd.resolveWith(context, args);
476
+ } else if (resolveOrReject === false) {
477
+ dfd.rejectWith(context, args);
478
+ }
479
+ promise.abort = dfd.promise;
480
+ return this._enhancePromise(promise);
481
+ },
482
+
483
+ // Parses the Range header from the server response
484
+ // and returns the uploaded bytes:
485
+ _getUploadedBytes: function (jqXHR) {
486
+ var range = jqXHR.getResponseHeader('Range'),
487
+ parts = range && range.split('-'),
488
+ upperBytesPos = parts && parts.length > 1 &&
489
+ parseInt(parts[1], 10);
490
+ return upperBytesPos && upperBytesPos + 1;
491
+ },
492
+
493
+ // Uploads a file in multiple, sequential requests
494
+ // by splitting the file up in multiple blob chunks.
495
+ // If the second parameter is true, only tests if the file
496
+ // should be uploaded in chunks, but does not invoke any
497
+ // upload requests:
498
+ _chunkedUpload: function (options, testOnly) {
499
+ var that = this,
500
+ file = options.files[0],
501
+ fs = file.size,
502
+ ub = options.uploadedBytes = options.uploadedBytes || 0,
503
+ mcs = options.maxChunkSize || fs,
504
+ slice = file.slice || file.webkitSlice || file.mozSlice,
505
+ dfd = $.Deferred(),
506
+ promise = dfd.promise(),
507
+ jqXHR,
508
+ upload;
509
+ if (!(this._isXHRUpload(options) && slice && (ub || mcs < fs)) ||
510
+ options.data) {
511
+ return false;
512
+ }
513
+ if (testOnly) {
514
+ return true;
515
+ }
516
+ if (ub >= fs) {
517
+ file.error = 'Uploaded bytes exceed file size';
518
+ return this._getXHRPromise(
519
+ false,
520
+ options.context,
521
+ [null, 'error', file.error]
522
+ );
523
+ }
524
+ // The chunk upload method:
525
+ upload = function (i) {
526
+ // Clone the options object for each chunk upload:
527
+ var o = $.extend({}, options);
528
+ o.blob = slice.call(
529
+ file,
530
+ ub,
531
+ ub + mcs
532
+ );
533
+ // Store the current chunk size, as the blob itself
534
+ // will be dereferenced after data processing:
535
+ o.chunkSize = o.blob.size;
536
+ // Expose the chunk bytes position range:
537
+ o.contentRange = 'bytes ' + ub + '-' +
538
+ (ub + o.chunkSize - 1) + '/' + fs;
539
+ // Process the upload data (the blob and potential form data):
540
+ that._initXHRData(o);
541
+ // Add progress listeners for this chunk upload:
542
+ that._initProgressListener(o);
543
+ jqXHR = ($.ajax(o) || that._getXHRPromise(false, o.context))
544
+ .done(function (result, textStatus, jqXHR) {
545
+ ub = that._getUploadedBytes(jqXHR) ||
546
+ (ub + o.chunkSize);
547
+ // Create a progress event if upload is done and
548
+ // no progress event has been invoked for this chunk:
549
+ if (!o.loaded) {
550
+ that._onProgress($.Event('progress', {
551
+ lengthComputable: true,
552
+ loaded: ub - o.uploadedBytes,
553
+ total: ub - o.uploadedBytes
554
+ }), o);
555
+ }
556
+ options.uploadedBytes = o.uploadedBytes = ub;
557
+ if (ub < fs) {
558
+ // File upload not yet complete,
559
+ // continue with the next chunk:
560
+ upload();
561
+ } else {
562
+ dfd.resolveWith(
563
+ o.context,
564
+ [result, textStatus, jqXHR]
565
+ );
566
+ }
567
+ })
568
+ .fail(function (jqXHR, textStatus, errorThrown) {
569
+ dfd.rejectWith(
570
+ o.context,
571
+ [jqXHR, textStatus, errorThrown]
572
+ );
573
+ });
574
+ };
575
+ this._enhancePromise(promise);
576
+ promise.abort = function () {
577
+ return jqXHR.abort();
578
+ };
579
+ upload();
580
+ return promise;
581
+ },
582
+
583
+ _beforeSend: function (e, data) {
584
+ if (this._active === 0) {
585
+ // the start callback is triggered when an upload starts
586
+ // and no other uploads are currently running,
587
+ // equivalent to the global ajaxStart event:
588
+ this._trigger('start');
589
+ // Set timer for global bitrate progress calculation:
590
+ this._bitrateTimer = new this._BitrateTimer();
591
+ }
592
+ this._active += 1;
593
+ // Initialize the global progress values:
594
+ this._loaded += data.uploadedBytes || 0;
595
+ this._total += this._getTotal(data.files);
596
+ },
597
+
598
+ _onDone: function (result, textStatus, jqXHR, options) {
599
+ if (!this._isXHRUpload(options)) {
600
+ // Create a progress event for each iframe load:
601
+ this._onProgress($.Event('progress', {
602
+ lengthComputable: true,
603
+ loaded: 1,
604
+ total: 1
605
+ }), options);
606
+ }
607
+ options.result = result;
608
+ options.textStatus = textStatus;
609
+ options.jqXHR = jqXHR;
610
+ this._trigger('done', null, options);
611
+ },
612
+
613
+ _onFail: function (jqXHR, textStatus, errorThrown, options) {
614
+ options.jqXHR = jqXHR;
615
+ options.textStatus = textStatus;
616
+ options.errorThrown = errorThrown;
617
+ this._trigger('fail', null, options);
618
+ if (options.recalculateProgress) {
619
+ // Remove the failed (error or abort) file upload from
620
+ // the global progress calculation:
621
+ this._loaded -= options.loaded || options.uploadedBytes || 0;
622
+ this._total -= options.total || this._getTotal(options.files);
623
+ }
624
+ },
625
+
626
+ _onAlways: function (jqXHRorResult, textStatus, jqXHRorError, options) {
627
+ this._active -= 1;
628
+ options.textStatus = textStatus;
629
+ if (jqXHRorError && jqXHRorError.always) {
630
+ options.jqXHR = jqXHRorError;
631
+ options.result = jqXHRorResult;
632
+ } else {
633
+ options.jqXHR = jqXHRorResult;
634
+ options.errorThrown = jqXHRorError;
635
+ }
636
+ this._trigger('always', null, options);
637
+ if (this._active === 0) {
638
+ // The stop callback is triggered when all uploads have
639
+ // been completed, equivalent to the global ajaxStop event:
640
+ this._trigger('stop');
641
+ // Reset the global progress values:
642
+ this._loaded = this._total = 0;
643
+ this._bitrateTimer = null;
644
+ }
645
+ },
646
+
647
+ _onSend: function (e, data) {
648
+ var that = this,
649
+ jqXHR,
650
+ aborted,
651
+ slot,
652
+ pipe,
653
+ options = that._getAJAXSettings(data),
654
+ send = function () {
655
+ that._sending += 1;
656
+ // Set timer for bitrate progress calculation:
657
+ options._bitrateTimer = new that._BitrateTimer();
658
+ jqXHR = jqXHR || (
659
+ ((aborted || that._trigger('send', e, options) === false) &&
660
+ that._getXHRPromise(false, options.context, aborted)) ||
661
+ that._chunkedUpload(options) || $.ajax(options)
662
+ ).done(function (result, textStatus, jqXHR) {
663
+ that._onDone(result, textStatus, jqXHR, options);
664
+ }).fail(function (jqXHR, textStatus, errorThrown) {
665
+ that._onFail(jqXHR, textStatus, errorThrown, options);
666
+ }).always(function (jqXHRorResult, textStatus, jqXHRorError) {
667
+ that._sending -= 1;
668
+ that._onAlways(
669
+ jqXHRorResult,
670
+ textStatus,
671
+ jqXHRorError,
672
+ options
673
+ );
674
+ if (options.limitConcurrentUploads &&
675
+ options.limitConcurrentUploads > that._sending) {
676
+ // Start the next queued upload,
677
+ // that has not been aborted:
678
+ var nextSlot = that._slots.shift(),
679
+ isPending;
680
+ while (nextSlot) {
681
+ // jQuery 1.6 doesn't provide .state(),
682
+ // while jQuery 1.8+ removed .isRejected():
683
+ isPending = nextSlot.state ?
684
+ nextSlot.state() === 'pending' :
685
+ !nextSlot.isRejected();
686
+ if (isPending) {
687
+ nextSlot.resolve();
688
+ break;
689
+ }
690
+ nextSlot = that._slots.shift();
691
+ }
692
+ }
693
+ });
694
+ return jqXHR;
695
+ };
696
+ this._beforeSend(e, options);
697
+ if (this.options.sequentialUploads ||
698
+ (this.options.limitConcurrentUploads &&
699
+ this.options.limitConcurrentUploads <= this._sending)) {
700
+ if (this.options.limitConcurrentUploads > 1) {
701
+ slot = $.Deferred();
702
+ this._slots.push(slot);
703
+ pipe = slot.pipe(send);
704
+ } else {
705
+ pipe = (this._sequence = this._sequence.pipe(send, send));
706
+ }
707
+ // Return the piped Promise object, enhanced with an abort method,
708
+ // which is delegated to the jqXHR object of the current upload,
709
+ // and jqXHR callbacks mapped to the equivalent Promise methods:
710
+ pipe.abort = function () {
711
+ aborted = [undefined, 'abort', 'abort'];
712
+ if (!jqXHR) {
713
+ if (slot) {
714
+ slot.rejectWith(options.context, aborted);
715
+ }
716
+ return send();
717
+ }
718
+ return jqXHR.abort();
719
+ };
720
+ return this._enhancePromise(pipe);
721
+ }
722
+ return send();
723
+ },
724
+
725
+ _onAdd: function (e, data) {
726
+ var that = this,
727
+ result = true,
728
+ options = $.extend({}, this.options, data),
729
+ limit = options.limitMultiFileUploads,
730
+ paramName = this._getParamName(options),
731
+ paramNameSet,
732
+ paramNameSlice,
733
+ fileSet,
734
+ i;
735
+ if (!(options.singleFileUploads || limit) ||
736
+ !this._isXHRUpload(options)) {
737
+ fileSet = [data.files];
738
+ paramNameSet = [paramName];
739
+ } else if (!options.singleFileUploads && limit) {
740
+ fileSet = [];
741
+ paramNameSet = [];
742
+ for (i = 0; i < data.files.length; i += limit) {
743
+ fileSet.push(data.files.slice(i, i + limit));
744
+ paramNameSlice = paramName.slice(i, i + limit);
745
+ if (!paramNameSlice.length) {
746
+ paramNameSlice = paramName;
747
+ }
748
+ paramNameSet.push(paramNameSlice);
749
+ }
750
+ } else {
751
+ paramNameSet = paramName;
752
+ }
753
+ data.originalFiles = data.files;
754
+ $.each(fileSet || data.files, function (index, element) {
755
+ var newData = $.extend({}, data);
756
+ newData.files = fileSet ? element : [element];
757
+ newData.paramName = paramNameSet[index];
758
+ newData.submit = function () {
759
+ newData.jqXHR = this.jqXHR =
760
+ (that._trigger('submit', e, this) !== false) &&
761
+ that._onSend(e, this);
762
+ return this.jqXHR;
763
+ };
764
+ result = that._trigger('add', e, newData);
765
+ return result;
766
+ });
767
+ return result;
768
+ },
769
+
770
+ _replaceFileInput: function (input) {
771
+ var inputClone = input.clone(true);
772
+ $('<form></form>').append(inputClone)[0].reset();
773
+ // Detaching allows to insert the fileInput on another form
774
+ // without loosing the file input value:
775
+ input.after(inputClone).detach();
776
+ // Avoid memory leaks with the detached file input:
777
+ $.cleanData(input.unbind('remove'));
778
+ // Replace the original file input element in the fileInput
779
+ // elements set with the clone, which has been copied including
780
+ // event handlers:
781
+ this.options.fileInput = this.options.fileInput.map(function (i, el) {
782
+ if (el === input[0]) {
783
+ return inputClone[0];
784
+ }
785
+ return el;
786
+ });
787
+ // If the widget has been initialized on the file input itself,
788
+ // override this.element with the file input clone:
789
+ if (input[0] === this.element[0]) {
790
+ this.element = inputClone;
791
+ }
792
+ },
793
+
794
+ _handleFileTreeEntry: function (entry, path) {
795
+ var that = this,
796
+ dfd = $.Deferred(),
797
+ errorHandler = function (e) {
798
+ if (e && !e.entry) {
799
+ e.entry = entry;
800
+ }
801
+ // Since $.when returns immediately if one
802
+ // Deferred is rejected, we use resolve instead.
803
+ // This allows valid files and invalid items
804
+ // to be returned together in one set:
805
+ dfd.resolve([e]);
806
+ },
807
+ dirReader;
808
+ path = path || '';
809
+ if (entry.isFile) {
810
+ if (entry._file) {
811
+ // Workaround for Chrome bug #149735
812
+ entry._file.relativePath = path;
813
+ dfd.resolve(entry._file);
814
+ } else {
815
+ entry.file(function (file) {
816
+ file.relativePath = path;
817
+ dfd.resolve(file);
818
+ }, errorHandler);
819
+ }
820
+ } else if (entry.isDirectory) {
821
+ dirReader = entry.createReader();
822
+ dirReader.readEntries(function (entries) {
823
+ that._handleFileTreeEntries(
824
+ entries,
825
+ path + entry.name + '/'
826
+ ).done(function (files) {
827
+ dfd.resolve(files);
828
+ }).fail(errorHandler);
829
+ }, errorHandler);
830
+ } else {
831
+ // Return an empy list for file system items
832
+ // other than files or directories:
833
+ dfd.resolve([]);
834
+ }
835
+ return dfd.promise();
836
+ },
837
+
838
+ _handleFileTreeEntries: function (entries, path) {
839
+ var that = this;
840
+ return $.when.apply(
841
+ $,
842
+ $.map(entries, function (entry) {
843
+ return that._handleFileTreeEntry(entry, path);
844
+ })
845
+ ).pipe(function () {
846
+ return Array.prototype.concat.apply(
847
+ [],
848
+ arguments
849
+ );
850
+ });
851
+ },
852
+
853
+ _getDroppedFiles: function (dataTransfer) {
854
+ dataTransfer = dataTransfer || {};
855
+ var items = dataTransfer.items;
856
+ if (items && items.length && (items[0].webkitGetAsEntry ||
857
+ items[0].getAsEntry)) {
858
+ return this._handleFileTreeEntries(
859
+ $.map(items, function (item) {
860
+ var entry;
861
+ if (item.webkitGetAsEntry) {
862
+ entry = item.webkitGetAsEntry();
863
+ if (entry) {
864
+ // Workaround for Chrome bug #149735:
865
+ entry._file = item.getAsFile();
866
+ }
867
+ return entry;
868
+ }
869
+ return item.getAsEntry();
870
+ })
871
+ );
872
+ }
873
+ return $.Deferred().resolve(
874
+ $.makeArray(dataTransfer.files)
875
+ ).promise();
876
+ },
877
+
878
+ _getSingleFileInputFiles: function (fileInput) {
879
+ fileInput = $(fileInput);
880
+ var entries = fileInput.prop('webkitEntries') ||
881
+ fileInput.prop('entries'),
882
+ files,
883
+ value;
884
+ if (entries && entries.length) {
885
+ return this._handleFileTreeEntries(entries);
886
+ }
887
+ files = $.makeArray(fileInput.prop('files'));
888
+ if (!files.length) {
889
+ value = fileInput.prop('value');
890
+ if (!value) {
891
+ return $.Deferred().resolve([]).promise();
892
+ }
893
+ // If the files property is not available, the browser does not
894
+ // support the File API and we add a pseudo File object with
895
+ // the input value as name with path information removed:
896
+ files = [{name: value.replace(/^.*\\/, '')}];
897
+ } else if (files[0].name === undefined && files[0].fileName) {
898
+ // File normalization for Safari 4 and Firefox 3:
899
+ $.each(files, function (index, file) {
900
+ file.name = file.fileName;
901
+ file.size = file.fileSize;
902
+ });
903
+ }
904
+ return $.Deferred().resolve(files).promise();
905
+ },
906
+
907
+ _getFileInputFiles: function (fileInput) {
908
+ if (!(fileInput instanceof $) || fileInput.length === 1) {
909
+ return this._getSingleFileInputFiles(fileInput);
910
+ }
911
+ return $.when.apply(
912
+ $,
913
+ $.map(fileInput, this._getSingleFileInputFiles)
914
+ ).pipe(function () {
915
+ return Array.prototype.concat.apply(
916
+ [],
917
+ arguments
918
+ );
919
+ });
920
+ },
921
+
922
+ _onChange: function (e) {
923
+ var that = this,
924
+ data = {
925
+ fileInput: $(e.target),
926
+ form: $(e.target.form)
927
+ };
928
+ this._getFileInputFiles(data.fileInput).always(function (files) {
929
+ data.files = files;
930
+ if (that.options.replaceFileInput) {
931
+ that._replaceFileInput(data.fileInput);
932
+ }
933
+ if (that._trigger('change', e, data) !== false) {
934
+ that._onAdd(e, data);
935
+ }
936
+ });
937
+ },
938
+
939
+ _onPaste: function (e) {
940
+ var cbd = e.originalEvent.clipboardData,
941
+ items = (cbd && cbd.items) || [],
942
+ data = {files: []};
943
+ $.each(items, function (index, item) {
944
+ var file = item.getAsFile && item.getAsFile();
945
+ if (file) {
946
+ data.files.push(file);
947
+ }
948
+ });
949
+ if (this._trigger('paste', e, data) === false ||
950
+ this._onAdd(e, data) === false) {
951
+ return false;
952
+ }
953
+ },
954
+
955
+ _onDrop: function (e) {
956
+ e.preventDefault();
957
+ var that = this,
958
+ dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer,
959
+ data = {};
960
+ this._getDroppedFiles(dataTransfer).always(function (files) {
961
+ data.files = files;
962
+ if (that._trigger('drop', e, data) !== false) {
963
+ that._onAdd(e, data);
964
+ }
965
+ });
966
+ },
967
+
968
+ _onDragOver: function (e) {
969
+ var dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer;
970
+ if (this._trigger('dragover', e) === false) {
971
+ return false;
972
+ }
973
+ if (dataTransfer) {
974
+ dataTransfer.dropEffect = 'copy';
975
+ }
976
+ e.preventDefault();
977
+ },
978
+
979
+ _initEventHandlers: function () {
980
+ if (this._isXHRUpload(this.options)) {
981
+ this._on(this.options.dropZone, {
982
+ dragover: this._onDragOver,
983
+ drop: this._onDrop
984
+ });
985
+ this._on(this.options.pasteZone, {
986
+ paste: this._onPaste
987
+ });
988
+ }
989
+ this._on(this.options.fileInput, {
990
+ change: this._onChange
991
+ });
992
+ },
993
+
994
+ _destroyEventHandlers: function () {
995
+ this._off(this.options.dropZone, 'dragover drop');
996
+ this._off(this.options.pasteZone, 'paste');
997
+ this._off(this.options.fileInput, 'change');
998
+ },
999
+
1000
+ _setOption: function (key, value) {
1001
+ var refresh = $.inArray(key, this._refreshOptionsList) !== -1;
1002
+ if (refresh) {
1003
+ this._destroyEventHandlers();
1004
+ }
1005
+ this._super(key, value);
1006
+ if (refresh) {
1007
+ this._initSpecialOptions();
1008
+ this._initEventHandlers();
1009
+ }
1010
+ },
1011
+
1012
+ _initSpecialOptions: function () {
1013
+ var options = this.options;
1014
+ if (options.fileInput === undefined) {
1015
+ options.fileInput = this.element.is('input[type="file"]') ?
1016
+ this.element : this.element.find('input[type="file"]');
1017
+ } else if (!(options.fileInput instanceof $)) {
1018
+ options.fileInput = $(options.fileInput);
1019
+ }
1020
+ if (!(options.dropZone instanceof $)) {
1021
+ options.dropZone = $(options.dropZone);
1022
+ }
1023
+ if (!(options.pasteZone instanceof $)) {
1024
+ options.pasteZone = $(options.pasteZone);
1025
+ }
1026
+ },
1027
+
1028
+ _create: function () {
1029
+ var options = this.options;
1030
+ // Initialize options set via HTML5 data-attributes:
1031
+ $.extend(options, $(this.element[0].cloneNode(false)).data());
1032
+ this._initSpecialOptions();
1033
+ this._slots = [];
1034
+ this._sequence = this._getXHRPromise(true);
1035
+ this._sending = this._active = this._loaded = this._total = 0;
1036
+ this._initEventHandlers();
1037
+ },
1038
+
1039
+ _destroy: function () {
1040
+ this._destroyEventHandlers();
1041
+ },
1042
+
1043
+ // This method is exposed to the widget API and allows adding files
1044
+ // using the fileupload API. The data parameter accepts an object which
1045
+ // must have a files property and can contain additional options:
1046
+ // .fileupload('add', {files: filesList});
1047
+ add: function (data) {
1048
+ var that = this;
1049
+ if (!data || this.options.disabled) {
1050
+ return;
1051
+ }
1052
+ if (data.fileInput && !data.files) {
1053
+ this._getFileInputFiles(data.fileInput).always(function (files) {
1054
+ data.files = files;
1055
+ that._onAdd(null, data);
1056
+ });
1057
+ } else {
1058
+ data.files = $.makeArray(data.files);
1059
+ this._onAdd(null, data);
1060
+ }
1061
+ },
1062
+
1063
+ // This method is exposed to the widget API and allows sending files
1064
+ // using the fileupload API. The data parameter accepts an object which
1065
+ // must have a files or fileInput property and can contain additional options:
1066
+ // .fileupload('send', {files: filesList});
1067
+ // The method returns a Promise object for the file upload call.
1068
+ send: function (data) {
1069
+ if (data && !this.options.disabled) {
1070
+ if (data.fileInput && !data.files) {
1071
+ var that = this,
1072
+ dfd = $.Deferred(),
1073
+ promise = dfd.promise(),
1074
+ jqXHR,
1075
+ aborted;
1076
+ promise.abort = function () {
1077
+ aborted = true;
1078
+ if (jqXHR) {
1079
+ return jqXHR.abort();
1080
+ }
1081
+ dfd.reject(null, 'abort', 'abort');
1082
+ return promise;
1083
+ };
1084
+ this._getFileInputFiles(data.fileInput).always(
1085
+ function (files) {
1086
+ if (aborted) {
1087
+ return;
1088
+ }
1089
+ data.files = files;
1090
+ jqXHR = that._onSend(null, data).then(
1091
+ function (result, textStatus, jqXHR) {
1092
+ dfd.resolve(result, textStatus, jqXHR);
1093
+ },
1094
+ function (jqXHR, textStatus, errorThrown) {
1095
+ dfd.reject(jqXHR, textStatus, errorThrown);
1096
+ }
1097
+ );
1098
+ }
1099
+ );
1100
+ return this._enhancePromise(promise);
1101
+ }
1102
+ data.files = $.makeArray(data.files);
1103
+ if (data.files.length) {
1104
+ return this._onSend(null, data);
1105
+ }
1106
+ }
1107
+ return this._getXHRPromise(false, data && data.context);
1108
+ }
1109
+
1110
+ });
1111
+
1112
+ }));