alchemy_cms 2.9.1 → 3.0.0.rc5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (695) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/.travis.yml +14 -3
  4. data/CONTRIBUTING.md +73 -0
  5. data/Gemfile +25 -24
  6. data/LICENSE +19 -16
  7. data/README.md +16 -33
  8. data/alchemy_cms.gemspec +62 -59
  9. data/app/assets/images/alchemy/alchemy-logo.svg +70 -0
  10. data/app/assets/images/alchemy/favicon.ico +0 -0
  11. data/app/assets/images/alchemy/icon.svg +14 -0
  12. data/app/assets/javascripts/alchemy/alchemy.autocomplete.js.coffee +30 -0
  13. data/app/assets/javascripts/alchemy/alchemy.base.js.coffee +28 -30
  14. data/app/assets/javascripts/alchemy/alchemy.browser.js.coffee +20 -26
  15. data/app/assets/javascripts/alchemy/alchemy.confirm_dialog.js.coffee +80 -0
  16. data/app/assets/javascripts/alchemy/alchemy.dialog.js.coffee +261 -0
  17. data/app/assets/javascripts/alchemy/alchemy.dirty.js.coffee +15 -15
  18. data/app/assets/javascripts/alchemy/alchemy.dragndrop.js.coffee +4 -1
  19. data/app/assets/javascripts/alchemy/alchemy.element_editors.js.coffee +20 -9
  20. data/app/assets/javascripts/alchemy/alchemy.elements_window.js.coffee +67 -68
  21. data/app/assets/javascripts/alchemy/alchemy.file_progress.js.coffee +63 -0
  22. data/app/assets/javascripts/alchemy/alchemy.growler.js.coffee +1 -1
  23. data/app/assets/javascripts/alchemy/alchemy.gui.js.coffee +2 -1
  24. data/app/assets/javascripts/alchemy/alchemy.hotkeys.js.coffee +32 -14
  25. data/app/assets/javascripts/alchemy/alchemy.i18n.js.coffee +21 -0
  26. data/app/assets/javascripts/alchemy/alchemy.image_cropper.js.coffee +4 -1
  27. data/app/assets/javascripts/alchemy/{alchemy.onload.js.coffee → alchemy.initializer.js.coffee} +22 -5
  28. data/app/assets/javascripts/alchemy/alchemy.js +13 -11
  29. data/app/assets/javascripts/alchemy/alchemy.link_dialog.js.coffee +221 -0
  30. data/app/assets/javascripts/alchemy/alchemy.list_filter.js.coffee +2 -2
  31. data/app/assets/javascripts/alchemy/alchemy.page_sorter.js +0 -2
  32. data/app/assets/javascripts/alchemy/alchemy.preview.js.coffee +37 -35
  33. data/app/assets/javascripts/alchemy/alchemy.preview_window.js.coffee +42 -69
  34. data/app/assets/javascripts/alchemy/alchemy.sitemap.js.coffee +1 -1
  35. data/app/assets/javascripts/alchemy/alchemy.spinner.js.coffee +4 -4
  36. data/app/assets/javascripts/alchemy/alchemy.tinymce.js.coffee.erb +3 -7
  37. data/app/assets/javascripts/alchemy/alchemy.translations.js.coffee +107 -19
  38. data/app/assets/javascripts/alchemy/alchemy.uploader.js.coffee +97 -0
  39. data/app/assets/javascripts/alchemy/alchemy.windows.js.coffee +14 -273
  40. data/app/assets/javascripts/alchemy/menubar.js.coffee +8 -0
  41. data/app/assets/javascripts/alchemy/preview.js +0 -2
  42. data/app/assets/javascripts/tinymce/plugins/alchemy_link/plugin.min.js +19 -0
  43. data/app/assets/stylesheets/alchemy/{defaults.scss → _defaults.scss} +2 -0
  44. data/app/assets/stylesheets/alchemy/{extends.scss → _extends.scss} +7 -61
  45. data/app/assets/stylesheets/alchemy/_mixins.scss +112 -0
  46. data/app/assets/stylesheets/alchemy/{variables.scss → _variables.scss} +31 -11
  47. data/app/assets/stylesheets/alchemy/admin.css.scss +6 -3
  48. data/app/assets/stylesheets/alchemy/archive.scss +27 -32
  49. data/app/assets/stylesheets/alchemy/base.scss +93 -127
  50. data/app/assets/stylesheets/alchemy/buttons.scss +227 -0
  51. data/app/assets/stylesheets/alchemy/dashboard.scss +14 -1
  52. data/app/assets/stylesheets/alchemy/dialogs.scss +209 -0
  53. data/app/assets/stylesheets/alchemy/elements.scss +173 -210
  54. data/app/assets/stylesheets/alchemy/errors.scss +5 -15
  55. data/app/assets/stylesheets/alchemy/flash.scss +12 -11
  56. data/app/assets/stylesheets/alchemy/form_fields.scss +56 -0
  57. data/app/assets/stylesheets/alchemy/forms.scss +161 -0
  58. data/app/assets/stylesheets/alchemy/frame.scss +8 -6
  59. data/app/assets/stylesheets/alchemy/icon-font.css.scss +40 -40
  60. data/app/assets/stylesheets/alchemy/icons.scss +14 -6
  61. data/app/assets/stylesheets/alchemy/jquery-ui.scss +11 -629
  62. data/app/assets/stylesheets/alchemy/menubar.css.scss +27 -72
  63. data/app/assets/stylesheets/alchemy/notices.scss +6 -5
  64. data/app/assets/stylesheets/alchemy/pagination.scss +1 -1
  65. data/app/assets/stylesheets/alchemy/search.scss +4 -3
  66. data/app/assets/stylesheets/alchemy/selects.scss +199 -0
  67. data/app/assets/stylesheets/alchemy/sitemap.scss +31 -60
  68. data/app/assets/stylesheets/alchemy/tables.scss +0 -77
  69. data/app/assets/stylesheets/alchemy/toolbar.scss +0 -2
  70. data/app/assets/stylesheets/alchemy/upload.scss +60 -57
  71. data/app/assets/stylesheets/tinymce/skins/alchemy/content.min.css.scss +81 -0
  72. data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/readme.md +1 -0
  73. data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/tinymce-small.eot +0 -0
  74. data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/tinymce-small.svg +175 -0
  75. data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/tinymce-small.ttf +0 -0
  76. data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/tinymce-small.woff +0 -0
  77. data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/tinymce.eot +0 -0
  78. data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/tinymce.svg +153 -0
  79. data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/tinymce.ttf +0 -0
  80. data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/tinymce.woff +0 -0
  81. data/app/assets/stylesheets/tinymce/skins/alchemy/img/anchor.gif +0 -0
  82. data/app/assets/stylesheets/tinymce/skins/alchemy/img/loader.gif +0 -0
  83. data/app/assets/stylesheets/tinymce/skins/alchemy/img/object.gif +0 -0
  84. data/{vendor/assets/javascripts/tiny_mce/themes/advanced → app/assets/stylesheets/tinymce/skins/alchemy}/img/trans.gif +0 -0
  85. data/app/assets/stylesheets/tinymce/skins/alchemy/img/wline.gif +0 -0
  86. data/app/assets/stylesheets/tinymce/skins/alchemy/skin.ie7.min.css +1 -0
  87. data/app/assets/stylesheets/tinymce/skins/alchemy/skin.min.css.scss +1813 -0
  88. data/app/controllers/alchemy/admin/attachments_controller.rb +39 -50
  89. data/app/controllers/alchemy/admin/base_controller.rb +32 -32
  90. data/app/controllers/alchemy/admin/clipboard_controller.rb +2 -2
  91. data/app/controllers/alchemy/admin/contents_controller.rb +12 -7
  92. data/app/controllers/alchemy/admin/dashboard_controller.rb +1 -1
  93. data/app/controllers/alchemy/admin/elements_controller.rb +41 -32
  94. data/app/controllers/alchemy/admin/essence_files_controller.rb +4 -3
  95. data/app/controllers/alchemy/admin/essence_pictures_controller.rb +13 -16
  96. data/app/controllers/alchemy/admin/languages_controller.rb +0 -1
  97. data/app/controllers/alchemy/admin/layoutpages_controller.rb +2 -1
  98. data/app/controllers/alchemy/admin/pages_controller.rb +106 -166
  99. data/app/controllers/alchemy/admin/pictures_controller.rb +54 -80
  100. data/app/controllers/alchemy/admin/resources_controller.rb +25 -9
  101. data/app/controllers/alchemy/admin/tags_controller.rb +26 -14
  102. data/app/controllers/alchemy/admin/trash_controller.rb +5 -2
  103. data/app/controllers/alchemy/attachments_controller.rb +8 -8
  104. data/app/controllers/alchemy/base_controller.rb +23 -89
  105. data/app/controllers/alchemy/contents_controller.rb +17 -0
  106. data/app/controllers/alchemy/elements_controller.rb +7 -30
  107. data/app/controllers/alchemy/messages_controller.rb +18 -18
  108. data/app/controllers/alchemy/pages_controller.rb +73 -48
  109. data/app/controllers/alchemy/pictures_controller.rb +45 -46
  110. data/app/helpers/alchemy/admin/attachments_helper.rb +1 -0
  111. data/app/helpers/alchemy/admin/base_helper.rb +95 -90
  112. data/app/helpers/alchemy/admin/contents_helper.rb +34 -37
  113. data/app/helpers/alchemy/admin/elements_helper.rb +4 -5
  114. data/app/helpers/alchemy/admin/essences_helper.rb +13 -90
  115. data/app/helpers/alchemy/admin/form_helper.rb +30 -0
  116. data/app/helpers/alchemy/admin/navigation_helper.rb +34 -2
  117. data/app/helpers/alchemy/base_helper.rb +3 -3
  118. data/app/helpers/alchemy/elements_helper.rb +105 -142
  119. data/app/helpers/alchemy/essences_helper.rb +17 -53
  120. data/app/helpers/alchemy/pages_helper.rb +148 -177
  121. data/app/helpers/alchemy/url_helper.rb +5 -25
  122. data/app/models/alchemy/attachment.rb +39 -14
  123. data/app/models/alchemy/cell.rb +18 -4
  124. data/app/models/alchemy/content.rb +69 -79
  125. data/app/models/alchemy/content/factory.rb +2 -6
  126. data/app/models/alchemy/element.rb +94 -89
  127. data/app/models/alchemy/essence_boolean.rb +13 -2
  128. data/app/models/alchemy/essence_date.rb +15 -8
  129. data/app/models/alchemy/essence_file.rb +25 -1
  130. data/app/models/alchemy/essence_html.rb +13 -6
  131. data/app/models/alchemy/essence_link.rb +16 -7
  132. data/app/models/alchemy/essence_picture.rb +102 -21
  133. data/app/models/alchemy/essence_richtext.rb +15 -37
  134. data/app/models/alchemy/essence_select.rb +13 -2
  135. data/app/models/alchemy/essence_text.rb +17 -42
  136. data/app/models/alchemy/folded_page.rb +10 -0
  137. data/app/models/alchemy/language.rb +62 -48
  138. data/app/models/alchemy/legacy_page_url.rb +12 -2
  139. data/app/models/alchemy/message.rb +11 -43
  140. data/app/models/alchemy/page.rb +107 -88
  141. data/app/models/alchemy/page/{page_cells.rb → cells.rb} +2 -2
  142. data/app/models/alchemy/page/{page_elements.rb → elements.rb} +5 -6
  143. data/app/models/alchemy/page/{page_naming.rb → naming.rb} +6 -11
  144. data/app/models/alchemy/page/{page_natures.rb → natures.rb} +29 -5
  145. data/app/models/alchemy/page/{page_scopes.rb → scopes.rb} +14 -14
  146. data/app/models/alchemy/page/{page_users.rb → users.rb} +4 -4
  147. data/app/models/alchemy/picture.rb +113 -41
  148. data/app/models/alchemy/picture/sweeping.rb +17 -0
  149. data/app/models/alchemy/site.rb +14 -2
  150. data/app/models/alchemy/tag.rb +8 -0
  151. data/app/serializers/alchemy/attachment_serializer.rb +15 -0
  152. data/app/serializers/alchemy/cell_serializer.rb +18 -0
  153. data/app/serializers/alchemy/content_serializer.rb +27 -0
  154. data/app/serializers/alchemy/element_serializer.rb +17 -0
  155. data/app/serializers/alchemy/essence_boolean_serializer.rb +11 -0
  156. data/app/serializers/alchemy/essence_date_serializer.rb +11 -0
  157. data/app/serializers/alchemy/essence_file_serializer.rb +12 -0
  158. data/app/serializers/alchemy/essence_html_serializer.rb +11 -0
  159. data/app/serializers/alchemy/essence_link_serializer.rb +14 -0
  160. data/app/serializers/alchemy/essence_picture_serializer.rb +28 -0
  161. data/app/serializers/alchemy/essence_richtext_serializer.rb +12 -0
  162. data/app/serializers/alchemy/essence_select_serializer.rb +11 -0
  163. data/app/serializers/alchemy/essence_text_serializer.rb +22 -0
  164. data/app/serializers/alchemy/page_serializer.rb +29 -0
  165. data/app/serializers/alchemy/picture_serializer.rb +16 -0
  166. data/app/views/alchemy/_menubar.html.erb +16 -0
  167. data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +27 -29
  168. data/app/views/alchemy/admin/attachments/_attachment.html.erb +24 -24
  169. data/app/views/alchemy/admin/attachments/_file_to_assign.html.erb +1 -1
  170. data/app/views/alchemy/admin/attachments/_files_list.html.erb +1 -1
  171. data/app/views/alchemy/admin/attachments/_overlay_file_list.html.erb +2 -2
  172. data/app/views/alchemy/admin/attachments/archive_overlay.js.erb +7 -4
  173. data/app/views/alchemy/admin/attachments/create.js.erb +11 -9
  174. data/app/views/alchemy/admin/attachments/edit.html.erb +9 -26
  175. data/app/views/alchemy/admin/attachments/index.html.erb +4 -4
  176. data/app/views/alchemy/admin/attachments/new.html.erb +13 -10
  177. data/app/views/alchemy/admin/attachments/show.html.erb +1 -1
  178. data/app/views/alchemy/admin/clipboard/clear.js.erb +3 -7
  179. data/app/views/alchemy/admin/clipboard/index.html.erb +21 -22
  180. data/app/views/alchemy/admin/clipboard/insert.js.erb +19 -14
  181. data/app/views/alchemy/admin/contents/_missing.html.erb +10 -12
  182. data/app/views/alchemy/admin/contents/create.js.erb +32 -36
  183. data/app/views/alchemy/admin/contents/destroy.js.coffee +3 -3
  184. data/app/views/alchemy/admin/contents/new.html.erb +9 -21
  185. data/app/views/alchemy/admin/contents/order.js.erb +2 -5
  186. data/app/views/alchemy/admin/dashboard/help.html.erb +21 -0
  187. data/app/views/alchemy/admin/dashboard/index.html.erb +5 -7
  188. data/app/views/alchemy/admin/dashboard/info.html.erb +13 -9
  189. data/app/views/alchemy/admin/elements/_add_picture.html.erb +6 -6
  190. data/app/views/alchemy/admin/elements/_element.html.erb +4 -1
  191. data/app/views/alchemy/admin/elements/_element_head.html.erb +2 -2
  192. data/app/views/alchemy/admin/elements/_new_element_form.html.erb +20 -27
  193. data/app/views/alchemy/admin/elements/_picture_gallery_editor.html.erb +7 -7
  194. data/app/views/alchemy/admin/elements/_refresh_editor.js.erb +1 -1
  195. data/app/views/alchemy/admin/elements/create.js.erb +6 -6
  196. data/app/views/alchemy/admin/elements/fold.js.erb +10 -10
  197. data/app/views/alchemy/admin/elements/index.html.erb +24 -26
  198. data/app/views/alchemy/admin/elements/list.html.erb +16 -0
  199. data/app/views/alchemy/admin/elements/new.html.erb +12 -28
  200. data/app/views/alchemy/admin/elements/trash.js.erb +3 -3
  201. data/app/views/alchemy/admin/elements/update.js.erb +12 -8
  202. data/app/views/alchemy/admin/essence_files/assign.js.erb +9 -14
  203. data/app/views/alchemy/admin/essence_files/edit.html.erb +17 -27
  204. data/app/views/alchemy/admin/essence_pictures/assign.js.erb +18 -0
  205. data/app/views/alchemy/admin/essence_pictures/crop.html.erb +1 -1
  206. data/app/views/alchemy/admin/essence_pictures/destroy.js.erb +9 -13
  207. data/app/views/alchemy/admin/essence_pictures/edit.html.erb +27 -67
  208. data/app/views/alchemy/admin/essence_pictures/save_link.js.erb +1 -1
  209. data/app/views/alchemy/admin/essence_pictures/update.js.erb +3 -3
  210. data/app/views/alchemy/admin/languages/_form.html.erb +13 -55
  211. data/app/views/alchemy/admin/languages/_language.html.erb +10 -16
  212. data/app/views/alchemy/admin/languages/_table.html.erb +1 -1
  213. data/app/views/alchemy/admin/languages/index.html.erb +4 -4
  214. data/app/views/alchemy/admin/layoutpages/_layoutpage.html.erb +25 -27
  215. data/app/views/alchemy/admin/layoutpages/index.html.erb +5 -5
  216. data/app/views/alchemy/admin/pages/_create_language_form.html.erb +25 -31
  217. data/app/views/alchemy/admin/pages/_external_link.html.erb +24 -35
  218. data/app/views/alchemy/admin/pages/_file_link.html.erb +31 -45
  219. data/app/views/alchemy/admin/pages/_internal_link.html.erb +36 -42
  220. data/app/views/alchemy/admin/pages/_new_page_form.html.erb +8 -26
  221. data/app/views/alchemy/admin/pages/_page.html.erb +76 -75
  222. data/app/views/alchemy/admin/pages/_page_for_links.html.erb +15 -16
  223. data/app/views/alchemy/admin/pages/configure.html.erb +56 -86
  224. data/app/views/alchemy/admin/pages/configure_external.html.erb +32 -39
  225. data/app/views/alchemy/admin/pages/destroy.js.erb +10 -10
  226. data/app/views/alchemy/admin/pages/edit.html.erb +57 -63
  227. data/app/views/alchemy/admin/pages/fold.js.erb +3 -5
  228. data/app/views/alchemy/admin/pages/index.html.erb +11 -13
  229. data/app/views/alchemy/admin/pages/info.html.erb +28 -31
  230. data/app/views/alchemy/admin/pages/link.html.erb +8 -19
  231. data/app/views/alchemy/admin/pages/new.html.erb +11 -35
  232. data/app/views/alchemy/admin/pages/show.html.erb +1 -1
  233. data/app/views/alchemy/admin/pages/sort.js.erb +5 -7
  234. data/app/views/alchemy/admin/pages/update.js.erb +19 -20
  235. data/app/views/alchemy/admin/partials/_autocomplete_tag_list.html.erb +1 -9
  236. data/app/views/alchemy/admin/partials/_language_tree_select.html.erb +8 -19
  237. data/app/views/alchemy/admin/partials/_main_navigation_entry.html.erb +1 -1
  238. data/app/views/alchemy/admin/partials/_sub_navigation.html.erb +1 -1
  239. data/app/views/alchemy/admin/partials/_toolbar_button.html.erb +3 -3
  240. data/app/views/alchemy/admin/partials/_upload_form.html.erb +37 -55
  241. data/app/views/alchemy/admin/pictures/_archive.html.erb +3 -3
  242. data/app/views/alchemy/admin/pictures/_archive_overlay.html.erb +11 -13
  243. data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +1 -1
  244. data/app/views/alchemy/admin/pictures/_overlay_picture_list.html.erb +4 -2
  245. data/app/views/alchemy/admin/pictures/_picture.html.erb +37 -37
  246. data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +1 -1
  247. data/app/views/alchemy/admin/pictures/archive_overlay.js.erb +8 -5
  248. data/app/views/alchemy/admin/pictures/edit.html.erb +8 -21
  249. data/app/views/alchemy/admin/pictures/edit_multiple.html.erb +15 -33
  250. data/app/views/alchemy/admin/pictures/index.html.erb +9 -7
  251. data/app/views/alchemy/admin/pictures/index.js.erb +2 -2
  252. data/app/views/alchemy/admin/pictures/info.html.erb +35 -40
  253. data/app/views/alchemy/admin/pictures/new.html.erb +15 -11
  254. data/app/views/alchemy/admin/pictures/show.html.erb +5 -5
  255. data/app/views/alchemy/admin/resources/_form.html.erb +7 -31
  256. data/app/views/alchemy/admin/resources/_resource.html.erb +9 -16
  257. data/app/views/alchemy/admin/resources/_table.html.erb +1 -1
  258. data/app/views/alchemy/admin/resources/index.html.erb +5 -5
  259. data/app/views/alchemy/admin/sites/index.html.erb +3 -3
  260. data/app/views/alchemy/admin/tags/_tag.html.erb +15 -15
  261. data/app/views/alchemy/admin/tags/edit.html.erb +20 -37
  262. data/app/views/alchemy/admin/tags/index.html.erb +16 -19
  263. data/app/views/alchemy/admin/tags/new.html.erb +6 -15
  264. data/app/views/alchemy/admin/trash/clear.js.coffee +2 -2
  265. data/app/views/alchemy/admin/trash/index.html.erb +24 -20
  266. data/app/views/alchemy/base/500.html.erb +2 -2
  267. data/app/views/alchemy/base/error_notice.js.erb +1 -1
  268. data/app/views/alchemy/base/leave.html.erb +11 -11
  269. data/app/views/alchemy/base/permission_denied.js.erb +1 -1
  270. data/app/views/alchemy/base/redirect.js.erb +12 -1
  271. data/app/views/alchemy/base/update.js.erb +4 -4
  272. data/app/views/alchemy/breadcrumb/_spacer.html.erb +1 -1
  273. data/app/views/alchemy/elements/show.js.erb +1 -5
  274. data/app/views/alchemy/essences/_essence_boolean_editor.html.erb +1 -1
  275. data/app/views/alchemy/essences/_essence_boolean_view.html.erb +3 -1
  276. data/app/views/alchemy/essences/_essence_date_editor.html.erb +4 -3
  277. data/app/views/alchemy/essences/_essence_date_view.html.erb +9 -5
  278. data/app/views/alchemy/essences/_essence_file_editor.html.erb +33 -32
  279. data/app/views/alchemy/essences/_essence_file_view.html.erb +9 -7
  280. data/app/views/alchemy/essences/_essence_html_view.html.erb +3 -1
  281. data/app/views/alchemy/essences/_essence_link_editor.html.erb +2 -2
  282. data/app/views/alchemy/essences/_essence_link_view.html.erb +5 -1
  283. data/app/views/alchemy/essences/_essence_picture_editor.html.erb +11 -11
  284. data/app/views/alchemy/essences/_essence_picture_view.html.erb +3 -1
  285. data/app/views/alchemy/essences/_essence_richtext_editor.html.erb +1 -1
  286. data/app/views/alchemy/essences/_essence_richtext_view.html.erb +3 -4
  287. data/app/views/alchemy/essences/_essence_select_editor.html.erb +1 -1
  288. data/app/views/alchemy/essences/_essence_select_view.html.erb +3 -1
  289. data/app/views/alchemy/essences/_essence_text_editor.html.erb +14 -28
  290. data/app/views/alchemy/essences/_essence_text_view.html.erb +4 -0
  291. data/app/views/alchemy/essences/shared/_essence_picture_tools.html.erb +29 -29
  292. data/app/views/alchemy/essences/shared/_linkable_essence_tools.html.erb +9 -9
  293. data/app/views/alchemy/language_links/_language.html.erb +1 -1
  294. data/app/views/kaminari/{_first_page.html.erb → alchemy/_first_page.html.erb} +1 -1
  295. data/app/views/kaminari/{_gap.html.erb → alchemy/_gap.html.erb} +0 -0
  296. data/app/views/kaminari/{_last_page.html.erb → alchemy/_last_page.html.erb} +1 -1
  297. data/app/views/kaminari/{_next_page.html.erb → alchemy/_next_page.html.erb} +2 -2
  298. data/app/views/kaminari/{_page.html.erb → alchemy/_page.html.erb} +2 -2
  299. data/app/views/kaminari/{_paginator.html.erb → alchemy/_paginator.html.erb} +0 -0
  300. data/app/views/kaminari/{_prev_page.html.erb → alchemy/_prev_page.html.erb} +2 -2
  301. data/app/views/layouts/alchemy/admin.html.erb +17 -17
  302. data/bin/alchemy +179 -44
  303. data/bin/rails +8 -0
  304. data/config/alchemy/config.yml +24 -22
  305. data/config/alchemy/modules.yml +7 -1
  306. data/config/initializers/dragonfly.rb +20 -23
  307. data/config/initializers/simple_form.rb +144 -0
  308. data/config/locales/alchemy.de.yml +42 -33
  309. data/config/locales/alchemy.en.yml +32 -19
  310. data/config/locales/alchemy.nl.yml +937 -0
  311. data/config/locales/simple_form.de.yml +26 -0
  312. data/config/locales/simple_form.en.yml +25 -0
  313. data/config/locales/simple_form.nl.yml +25 -0
  314. data/config/routes.rb +9 -10
  315. data/db/migrate/20130827094554_alchemy_two_point_six.rb +261 -251
  316. data/db/migrate/20130828121054_remove_do_not_index_from_alchemy_essence_texts.rb +5 -0
  317. data/db/migrate/20130828121120_remove_do_not_index_from_alchemy_essence_richtexts.rb +5 -0
  318. data/db/migrate/20130918201742_add_published_at_to_alchemy_pages.rb +5 -0
  319. data/db/migrate/20140107192720_add_missing_unique_indices_to_tags_and_taggings.rb +21 -0
  320. data/lib/alchemy/auth_accessors.rb +23 -2
  321. data/lib/alchemy/cache_digests/template_tracker.rb +65 -0
  322. data/lib/alchemy/capistrano.rb +28 -38
  323. data/lib/alchemy/controller_actions.rb +130 -0
  324. data/lib/alchemy/engine.rb +54 -47
  325. data/lib/alchemy/essence.rb +83 -63
  326. data/lib/alchemy/forms/builder.rb +23 -0
  327. data/lib/alchemy/hints.rb +57 -0
  328. data/lib/alchemy/locale.rb +63 -0
  329. data/lib/alchemy/modules.rb +17 -17
  330. data/lib/alchemy/mount_point.rb +1 -1
  331. data/lib/alchemy/permissions.rb +199 -0
  332. data/lib/alchemy/picture_attributes.rb +1 -1
  333. data/lib/alchemy/resource.rb +13 -17
  334. data/lib/alchemy/resources_helper.rb +16 -18
  335. data/lib/alchemy/seeder.rb +8 -10
  336. data/lib/alchemy/shell.rb +8 -6
  337. data/lib/alchemy/tasks/helpers.rb +6 -4
  338. data/lib/alchemy/test_support/auth_helpers.rb +3 -3
  339. data/lib/alchemy/test_support/controller_requests.rb +1 -1
  340. data/lib/alchemy/test_support/essence_shared_examples.rb +141 -0
  341. data/lib/alchemy/test_support/factories.rb +27 -9
  342. data/lib/alchemy/test_support/integration_helpers.rb +1 -27
  343. data/lib/alchemy/tinymce.rb +12 -32
  344. data/lib/alchemy/touching.rb +41 -0
  345. data/lib/alchemy/upgrader.rb +17 -12
  346. data/lib/alchemy/upgrader/three_point_zero.rb +62 -0
  347. data/lib/alchemy/version.rb +2 -1
  348. data/lib/alchemy_cms.rb +1 -7
  349. data/lib/rails/generators/alchemy/elements/elements_generator.rb +3 -2
  350. data/lib/rails/generators/alchemy/elements/templates/editor.html.erb +0 -2
  351. data/lib/rails/generators/alchemy/elements/templates/editor.html.haml +2 -3
  352. data/lib/rails/generators/alchemy/elements/templates/editor.html.slim +0 -2
  353. data/lib/rails/generators/alchemy/elements/templates/view.html.erb +23 -23
  354. data/lib/rails/generators/alchemy/elements/templates/view.html.haml +16 -17
  355. data/lib/rails/generators/alchemy/elements/templates/view.html.slim +16 -17
  356. data/lib/rails/generators/alchemy/essence/templates/editor.html.erb +1 -1
  357. data/lib/rails/generators/alchemy/scaffold/files/_article_editor.html.erb +5 -0
  358. data/lib/rails/generators/alchemy/scaffold/files/_article_view.html.erb +7 -0
  359. data/lib/rails/generators/alchemy/scaffold/files/alchemy.de.yml +31 -0
  360. data/lib/rails/generators/alchemy/scaffold/files/alchemy.elements.css.scss +30 -0
  361. data/lib/rails/generators/alchemy/scaffold/files/alchemy.en.yml +31 -0
  362. data/lib/rails/generators/alchemy/scaffold/files/application.html.erb +4 -2
  363. data/lib/rails/generators/alchemy/scaffold/files/elements.yml +16 -0
  364. data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +16 -7
  365. data/lib/rails/generators/alchemy/scaffold/templates/page_layouts.yml.tt +3 -2
  366. data/lib/rails/templates/alchemy.rb +3 -6
  367. data/lib/tasks/alchemy/install.rake +29 -38
  368. data/lib/tasks/alchemy/tidy.rake +1 -1
  369. data/spec/controllers/admin/attachments_controller_spec.rb +101 -35
  370. data/spec/controllers/admin/clipboard_controller_spec.rb +16 -18
  371. data/spec/controllers/admin/contents_controller_spec.rb +34 -27
  372. data/spec/controllers/admin/dashboard_controller_spec.rb +2 -4
  373. data/spec/controllers/admin/elements_controller_spec.rb +288 -160
  374. data/spec/controllers/admin/essence_files_controller_spec.rb +11 -18
  375. data/spec/controllers/admin/essence_pictures_controller_spec.rb +15 -24
  376. data/spec/controllers/admin/languages_controller_spec.rb +11 -4
  377. data/spec/controllers/admin/layoutpages_controller_spec.rb +1 -2
  378. data/spec/controllers/admin/pages_controller_spec.rb +137 -167
  379. data/spec/controllers/admin/pictures_controller_spec.rb +286 -14
  380. data/spec/controllers/admin/resources_controller_spec.rb +4 -1
  381. data/spec/controllers/alchemy/admin/tags_controller_spec.rb +63 -0
  382. data/spec/controllers/attachments_controller_spec.rb +3 -3
  383. data/spec/controllers/base_controller_spec.rb +12 -104
  384. data/spec/controllers/elements_controller_spec.rb +2 -5
  385. data/spec/controllers/messages_controller_spec.rb +49 -51
  386. data/spec/controllers/pages_controller_spec.rb +91 -111
  387. data/spec/controllers/pictures_controller_spec.rb +126 -72
  388. data/spec/dummy/Rakefile +0 -1
  389. data/spec/dummy/app/assets/javascripts/application.js +11 -7
  390. data/spec/dummy/app/assets/stylesheets/application.css +11 -5
  391. data/spec/dummy/app/models/ability.rb +9 -0
  392. data/spec/dummy/app/models/dummy_user.rb +7 -0
  393. data/spec/dummy/app/models/event.rb +7 -2
  394. data/spec/dummy/app/models/location.rb +0 -1
  395. data/spec/dummy/app/views/alchemy/elements/_article_editor.html.erb +0 -1
  396. data/spec/dummy/app/views/alchemy/elements/_headline_editor.html.erb +1 -0
  397. data/spec/dummy/app/views/layouts/application.html.erb +3 -1
  398. data/spec/dummy/bin/bundle +3 -0
  399. data/spec/dummy/bin/rails +4 -0
  400. data/spec/dummy/bin/rake +4 -0
  401. data/spec/dummy/config.ru +2 -2
  402. data/spec/dummy/config/alchemy/elements.yml +0 -3
  403. data/spec/dummy/config/alchemy/page_layouts.yml +0 -6
  404. data/spec/dummy/config/application.rb +5 -57
  405. data/spec/dummy/config/boot.rb +4 -9
  406. data/spec/dummy/config/environment.rb +2 -2
  407. data/spec/dummy/config/environments/development.rb +11 -19
  408. data/spec/dummy/config/environments/production.rb +40 -27
  409. data/spec/dummy/config/environments/test.rb +15 -14
  410. data/spec/dummy/config/initializers/alchemy.rb +2 -0
  411. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  412. data/spec/dummy/config/initializers/inflections.rb +9 -3
  413. data/spec/dummy/config/initializers/secret_token.rb +7 -2
  414. data/spec/dummy/config/initializers/session_store.rb +1 -6
  415. data/spec/dummy/config/initializers/wrap_parameters.rb +6 -6
  416. data/spec/dummy/config/routes.rb +3 -1
  417. data/spec/dummy/db/migrate/20130827094554_alchemy_two_point_six.rb +261 -251
  418. data/spec/dummy/db/migrate/20130828121054_remove_do_not_index_from_alchemy_essence_texts.rb +5 -0
  419. data/spec/dummy/db/migrate/20130828121120_remove_do_not_index_from_alchemy_essence_richtexts.rb +5 -0
  420. data/spec/dummy/db/migrate/20130918201742_add_published_at_to_alchemy_pages.rb +5 -0
  421. data/spec/dummy/db/migrate/20131209225243_create_dummy_users.rb +9 -0
  422. data/spec/dummy/db/migrate/20140107192720_add_missing_unique_indices_to_tags_and_taggings.rb +21 -0
  423. data/spec/dummy/db/schema.rb +112 -105
  424. data/spec/dummy/public/404.html +46 -26
  425. data/spec/dummy/public/422.html +46 -26
  426. data/spec/dummy/public/500.html +45 -26
  427. data/spec/features/admin/language_tree_feature_spec.rb +2 -2
  428. data/spec/features/admin/modules_integration_spec.rb +7 -13
  429. data/spec/features/admin/page_creation_feature_spec.rb +50 -0
  430. data/spec/features/admin/page_editing_feature_spec.rb +16 -0
  431. data/spec/features/admin/picture_library_integration_spec.rb +4 -4
  432. data/spec/features/admin/resources_integration_spec.rb +11 -11
  433. data/spec/features/page_feature_spec.rb +225 -0
  434. data/spec/features/translation_integration_spec.rb +7 -7
  435. data/spec/fixtures/500x500.png +0 -0
  436. data/spec/helpers/admin/attachments_helper_spec.rb +15 -0
  437. data/spec/helpers/admin/base_helper_spec.rb +88 -13
  438. data/spec/helpers/admin/contents_helper_spec.rb +53 -12
  439. data/spec/helpers/admin/elements_helper_spec.rb +24 -36
  440. data/spec/helpers/admin/essences_helper_spec.rb +48 -10
  441. data/spec/helpers/admin/navigation_helper_spec.rb +64 -29
  442. data/spec/helpers/admin/pages_helper_spec.rb +22 -1
  443. data/spec/helpers/admin/pictures_helper_spec.rb +29 -0
  444. data/spec/helpers/admin/tags_helper_spec.rb +1 -1
  445. data/spec/helpers/base_helper_spec.rb +6 -13
  446. data/spec/helpers/elements_block_helper_spec.rb +3 -3
  447. data/spec/helpers/elements_helper_spec.rb +203 -167
  448. data/spec/helpers/essences_helper_spec.rb +69 -15
  449. data/spec/helpers/pages_helper_spec.rb +28 -66
  450. data/spec/helpers/url_helper_spec.rb +41 -73
  451. data/spec/javascripts/alchemy/dialog_spec.coffee +82 -0
  452. data/spec/javascripts/alchemy/link_overlay_spec.coffee +25 -0
  453. data/spec/javascripts/alchemy_integration_spec.coffee +3 -12
  454. data/spec/javascripts/helpers/mock-ajax.js +52 -60
  455. data/spec/javascripts/support/jasmine.yml +29 -0
  456. data/spec/libraries/auth_accessors_spec.rb +24 -0
  457. data/spec/libraries/config_spec.rb +3 -3
  458. data/spec/libraries/controller_actions_spec.rb +133 -0
  459. data/spec/libraries/kaminari/scoped_pagination_url_helper_spec.rb +30 -0
  460. data/spec/libraries/modules_spec.rb +17 -0
  461. data/spec/libraries/mount_point_spec.rb +7 -7
  462. data/spec/libraries/page_layout_spec.rb +1 -1
  463. data/spec/libraries/permissions_spec.rb +219 -0
  464. data/spec/libraries/resource_spec.rb +61 -68
  465. data/spec/libraries/resources_helper_spec.rb +51 -51
  466. data/spec/libraries/shell_spec.rb +7 -8
  467. data/spec/libraries/template_tracker_spec.rb +94 -0
  468. data/spec/libraries/tinymce_spec.rb +0 -12
  469. data/spec/libraries/userstamp_spec.rb +10 -0
  470. data/spec/models/attachment_spec.rb +51 -18
  471. data/spec/models/cell_spec.rb +5 -5
  472. data/spec/models/content_spec.rb +103 -15
  473. data/spec/models/element_spec.rb +82 -18
  474. data/spec/models/essence_boolean_spec.rb +3 -8
  475. data/spec/models/essence_date_spec.rb +11 -7
  476. data/spec/models/essence_file_spec.rb +24 -4
  477. data/spec/models/essence_html_spec.rb +8 -3
  478. data/spec/models/essence_link_spec.rb +10 -0
  479. data/spec/models/essence_picture_spec.rb +109 -0
  480. data/spec/models/essence_richtext_spec.rb +6 -35
  481. data/spec/models/essence_select_spec.rb +3 -8
  482. data/spec/models/essence_text_spec.rb +83 -39
  483. data/spec/models/language_spec.rb +20 -54
  484. data/spec/models/message_spec.rb +12 -7
  485. data/spec/models/page_spec.rb +192 -185
  486. data/spec/models/picture_spec.rb +200 -45
  487. data/spec/models/resource_spec.rb +4 -24
  488. data/spec/models/site_spec.rb +69 -3
  489. data/spec/models/tag_spec.rb +6 -6
  490. data/spec/routing/routing_spec.rb +0 -32
  491. data/spec/spec_helper.rb +29 -38
  492. data/spec/support/hint_examples.rb +30 -0
  493. data/spec/support/phantomjs_mavericks_fix.rb +32 -0
  494. data/spec/support/test_tweaks.rb +31 -0
  495. data/spec/views/essences/essence_boolean_view_spec.rb +25 -0
  496. data/spec/views/essences/essence_date_view_spec.rb +39 -0
  497. data/spec/views/essences/essence_file_view_spec.rb +24 -0
  498. data/spec/views/essences/essence_html_view_spec.rb +22 -0
  499. data/spec/views/essences/essence_link_view_spec.rb +30 -0
  500. data/spec/views/essences/essence_picture_view_spec.rb +1 -1
  501. data/spec/views/essences/essence_richtext_view_spec.rb +20 -0
  502. data/spec/views/essences/essence_select_view_spec.rb +12 -0
  503. data/spec/views/essences/essence_text_view_spec.rb +40 -0
  504. data/vendor/assets/javascripts/fileupload/jquery.fileupload-process.js +172 -0
  505. data/vendor/assets/javascripts/fileupload/jquery.fileupload-validate.js +120 -0
  506. data/vendor/assets/javascripts/fileupload/jquery.fileupload.js +1416 -0
  507. data/vendor/assets/javascripts/fileupload/jquery.iframe-transport.js +210 -0
  508. data/vendor/assets/javascripts/jquery_plugins/jquery.ui.nestedSortable.js +381 -352
  509. data/vendor/assets/javascripts/jquery_plugins/jquery.ui.tabspaging.js +1 -52
  510. data/vendor/assets/javascripts/keymaster.js +296 -0
  511. data/vendor/assets/javascripts/requestAnimationFrame.js +31 -0
  512. data/vendor/assets/javascripts/tinymce/langs/de.js +179 -0
  513. data/vendor/assets/javascripts/tinymce/langs/nl.js +179 -0
  514. data/vendor/assets/javascripts/{tiny_mce → tinymce}/license.txt +504 -504
  515. data/vendor/assets/javascripts/tinymce/plugins/autoresize/plugin.min.js +1 -0
  516. data/vendor/assets/javascripts/tinymce/plugins/charmap/plugin.min.js +1 -0
  517. data/vendor/assets/javascripts/tinymce/plugins/code/plugin.min.js +1 -0
  518. data/vendor/assets/javascripts/tinymce/plugins/directionality/plugin.min.js +1 -0
  519. data/vendor/assets/javascripts/tinymce/plugins/fullscreen/plugin.min.js +1 -0
  520. data/vendor/assets/javascripts/tinymce/plugins/link/plugin.min.js +1 -0
  521. data/vendor/assets/javascripts/tinymce/plugins/paste/plugin.min.js +1 -0
  522. data/vendor/assets/javascripts/tinymce/plugins/tabfocus/plugin.min.js +1 -0
  523. data/vendor/assets/javascripts/tinymce/plugins/table/plugin.min.js +1 -0
  524. data/vendor/assets/javascripts/tinymce/themes/modern/theme.min.js +1 -0
  525. data/vendor/assets/javascripts/tinymce/tinymce.min.js +10 -0
  526. metadata +351 -332
  527. data/.simplecov +0 -14
  528. data/app/assets/images/alchemy/alchemy-logo.png +0 -0
  529. data/app/assets/images/alchemy/swfupload/browse_button.png +0 -0
  530. data/app/assets/javascripts/alchemy/alchemy.file_progress.js +0 -102
  531. data/app/assets/javascripts/alchemy/alchemy.link_overlay.js.coffee +0 -227
  532. data/app/assets/javascripts/alchemy/alchemy.menubar.js +0 -62
  533. data/app/assets/javascripts/alchemy/alchemy.swf_upload.js +0 -212
  534. data/app/assets/javascripts/alchemy/alchemy.uploader.js +0 -274
  535. data/app/assets/javascripts/alchemy/menubar.js +0 -2
  536. data/app/assets/javascripts/tiny_mce/plugins/alchemy_link/editor_plugin.js +0 -42
  537. data/app/assets/javascripts/tiny_mce/plugins/alchemy_link/langs/de.js +0 -4
  538. data/app/assets/javascripts/tiny_mce/plugins/alchemy_link/langs/en.js +0 -4
  539. data/app/assets/stylesheets/alchemy/form_elements.scss +0 -538
  540. data/app/assets/stylesheets/alchemy/login.scss +0 -55
  541. data/app/assets/stylesheets/alchemy/tinymce_content.css.scss +0 -98
  542. data/app/assets/stylesheets/alchemy/tinymce_dialog.css.scss +0 -420
  543. data/app/assets/stylesheets/tiny_mce/plugins/inlinepopups/skins/alchemy-tinymce-dialog/window.css.scss +0 -434
  544. data/app/controllers/alchemy/admin/users_controller.rb +0 -76
  545. data/app/models/alchemy/tree_node.rb +0 -4
  546. data/app/sweepers/alchemy/content_sweeper.rb +0 -41
  547. data/app/sweepers/alchemy/pages_sweeper.rb +0 -44
  548. data/app/sweepers/alchemy/pictures_sweeper.rb +0 -21
  549. data/app/views/alchemy/admin/elements/_elements_select.html.erb +0 -9
  550. data/app/views/alchemy/admin/elements/list.js.erb +0 -22
  551. data/app/views/alchemy/admin/essence_pictures/assign.js.coffee +0 -15
  552. data/app/views/alchemy/admin/pages/_contactform_links.html.erb +0 -62
  553. data/app/views/alchemy/admin/partials/_flash_upload.html.erb +0 -37
  554. data/app/views/alchemy/admin/partials/_pagination_links.html.erb +0 -1
  555. data/app/views/alchemy/admin/pictures/create.js.erb +0 -3
  556. data/app/views/alchemy/admin/resources/_boolean.html.erb +0 -5
  557. data/app/views/alchemy/admin/resources/_date.html.erb +0 -8
  558. data/app/views/alchemy/admin/resources/_datetime.html.erb +0 -1
  559. data/app/views/alchemy/admin/resources/_string.html.erb +0 -5
  560. data/app/views/alchemy/admin/resources/_text.html.erb +0 -5
  561. data/app/views/alchemy/admin/resources/destroy.js.erb +0 -1
  562. data/app/views/alchemy/base/remote_errors.js.erb +0 -6
  563. data/app/views/alchemy/search/_form.html.erb +0 -11
  564. data/app/views/alchemy/search/_result.html.erb +0 -7
  565. data/app/views/alchemy/search/_results.html.erb +0 -27
  566. data/config/authorization_rules.rb +0 -110
  567. data/config/initializers/cache_storage.rb +0 -1
  568. data/lib/alchemy/auth/engine.rb +0 -9
  569. data/lib/alchemy/ferret/search.rb +0 -86
  570. data/lib/alchemy/language_helpers.rb +0 -55
  571. data/lib/alchemy/upgrader/two_point_five.rb +0 -86
  572. data/lib/alchemy/upgrader/two_point_four.rb +0 -25
  573. data/lib/alchemy/upgrader/two_point_nine.rb +0 -33
  574. data/lib/alchemy/upgrader/two_point_one.rb +0 -95
  575. data/lib/alchemy/upgrader/two_point_six.rb +0 -32
  576. data/lib/alchemy/upgrader/two_point_three.rb +0 -25
  577. data/lib/alchemy/upgrader/two_point_two.rb +0 -114
  578. data/lib/alchemy/upgrader/two_point_zero.rb +0 -13
  579. data/lib/middleware/flash_session_cookie.rb +0 -22
  580. data/lib/rails/generators/alchemy/gallery_pictures_migration/gallery_pictures_migration_generator.rb +0 -40
  581. data/lib/tasks/ferret.rake +0 -10
  582. data/script/rails +0 -6
  583. data/spec/dummy/app/models/user.rb +0 -14
  584. data/spec/dummy/app/views/alchemy/elements/_searchresult_view.html.erb +0 -4
  585. data/spec/dummy/config/authorization_rules.rb +0 -7
  586. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  587. data/spec/dummy/script/rails +0 -6
  588. data/spec/fast_specs.rb +0 -15
  589. data/spec/features/admin/element_create_feature_spec.rb +0 -18
  590. data/spec/features/admin/element_trash_feature_spec.rb +0 -21
  591. data/spec/features/admin/pages_controller_spec.rb +0 -59
  592. data/spec/features/pages_controller_spec.rb +0 -262
  593. data/spec/javascripts/alchemy/link_overlay_spec.js.coffee +0 -42
  594. data/spec/javascripts/helpers/.gitkeep +0 -0
  595. data/spec/javascripts/helpers/jasmine-jquery-1.3.1.js +0 -289
  596. data/spec/javascripts/spec.css +0 -3
  597. data/spec/javascripts/spec.js +0 -2
  598. data/spec/libraries/essence_spec.rb +0 -76
  599. data/spec/support/alchemy/controller_hacks.rb +0 -41
  600. data/vendor/assets/javascripts/jquery_plugins/jquery.dialogextend.js +0 -684
  601. data/vendor/assets/javascripts/jquery_plugins/jquery.html5uploader.js +0 -271
  602. data/vendor/assets/javascripts/jquery_plugins/jquery.selectboxit.min.js +0 -11
  603. data/vendor/assets/javascripts/jquery_plugins/preloadCssImages.jQuery_v5.js +0 -152
  604. data/vendor/assets/javascripts/keymage.min.js +0 -6
  605. data/vendor/assets/javascripts/swfupload/SWFObject License.txt +0 -4
  606. data/vendor/assets/javascripts/swfupload/swfupload.cookies.js +0 -53
  607. data/vendor/assets/javascripts/swfupload/swfupload.js +0 -980
  608. data/vendor/assets/javascripts/swfupload/swfupload.queue.js +0 -98
  609. data/vendor/assets/javascripts/swfupload/swfupload.speed.js +0 -342
  610. data/vendor/assets/javascripts/swfupload/swfupload.swf +0 -0
  611. data/vendor/assets/javascripts/swfupload/swfupload.swfobject.js +0 -715
  612. data/vendor/assets/javascripts/tiny_mce/langs/de.js +0 -1
  613. data/vendor/assets/javascripts/tiny_mce/langs/en.js +0 -1
  614. data/vendor/assets/javascripts/tiny_mce/plugins/autoresize/editor_plugin.js +0 -1
  615. data/vendor/assets/javascripts/tiny_mce/plugins/fullscreen/editor_plugin.js +0 -1
  616. data/vendor/assets/javascripts/tiny_mce/plugins/fullscreen/fullscreen.htm +0 -110
  617. data/vendor/assets/javascripts/tiny_mce/plugins/inlinepopups/editor_plugin.js +0 -1
  618. data/vendor/assets/javascripts/tiny_mce/plugins/inlinepopups/template.htm +0 -387
  619. data/vendor/assets/javascripts/tiny_mce/plugins/paste/editor_plugin.js +0 -1
  620. data/vendor/assets/javascripts/tiny_mce/plugins/paste/js/pastetext.js +0 -36
  621. data/vendor/assets/javascripts/tiny_mce/plugins/paste/js/pasteword.js +0 -51
  622. data/vendor/assets/javascripts/tiny_mce/plugins/paste/langs/de_dlg.js +0 -1
  623. data/vendor/assets/javascripts/tiny_mce/plugins/paste/langs/en_dlg.js +0 -1
  624. data/vendor/assets/javascripts/tiny_mce/plugins/paste/pastetext.htm +0 -27
  625. data/vendor/assets/javascripts/tiny_mce/plugins/paste/pasteword.htm +0 -21
  626. data/vendor/assets/javascripts/tiny_mce/plugins/table/cell.htm +0 -180
  627. data/vendor/assets/javascripts/tiny_mce/plugins/table/css/cell.css +0 -17
  628. data/vendor/assets/javascripts/tiny_mce/plugins/table/css/row.css +0 -25
  629. data/vendor/assets/javascripts/tiny_mce/plugins/table/css/table.css +0 -13
  630. data/vendor/assets/javascripts/tiny_mce/plugins/table/editor_plugin.js +0 -1
  631. data/vendor/assets/javascripts/tiny_mce/plugins/table/js/cell.js +0 -319
  632. data/vendor/assets/javascripts/tiny_mce/plugins/table/js/merge_cells.js +0 -27
  633. data/vendor/assets/javascripts/tiny_mce/plugins/table/js/row.js +0 -254
  634. data/vendor/assets/javascripts/tiny_mce/plugins/table/js/table.js +0 -501
  635. data/vendor/assets/javascripts/tiny_mce/plugins/table/langs/de_dlg.js +0 -1
  636. data/vendor/assets/javascripts/tiny_mce/plugins/table/langs/en_dlg.js +0 -1
  637. data/vendor/assets/javascripts/tiny_mce/plugins/table/merge_cells.htm +0 -32
  638. data/vendor/assets/javascripts/tiny_mce/plugins/table/row.htm +0 -158
  639. data/vendor/assets/javascripts/tiny_mce/plugins/table/table.htm +0 -188
  640. data/vendor/assets/javascripts/tiny_mce/themes/advanced/about.htm +0 -52
  641. data/vendor/assets/javascripts/tiny_mce/themes/advanced/anchor.htm +0 -26
  642. data/vendor/assets/javascripts/tiny_mce/themes/advanced/charmap.htm +0 -55
  643. data/vendor/assets/javascripts/tiny_mce/themes/advanced/color_picker.htm +0 -70
  644. data/vendor/assets/javascripts/tiny_mce/themes/advanced/editor_template.js +0 -1
  645. data/vendor/assets/javascripts/tiny_mce/themes/advanced/image.htm +0 -80
  646. data/vendor/assets/javascripts/tiny_mce/themes/advanced/img/colorpicker.jpg +0 -0
  647. data/vendor/assets/javascripts/tiny_mce/themes/advanced/img/flash.gif +0 -0
  648. data/vendor/assets/javascripts/tiny_mce/themes/advanced/img/icons.gif +0 -0
  649. data/vendor/assets/javascripts/tiny_mce/themes/advanced/img/iframe.gif +0 -0
  650. data/vendor/assets/javascripts/tiny_mce/themes/advanced/img/pagebreak.gif +0 -0
  651. data/vendor/assets/javascripts/tiny_mce/themes/advanced/img/quicktime.gif +0 -0
  652. data/vendor/assets/javascripts/tiny_mce/themes/advanced/img/realmedia.gif +0 -0
  653. data/vendor/assets/javascripts/tiny_mce/themes/advanced/img/shockwave.gif +0 -0
  654. data/vendor/assets/javascripts/tiny_mce/themes/advanced/img/video.gif +0 -0
  655. data/vendor/assets/javascripts/tiny_mce/themes/advanced/img/windowsmedia.gif +0 -0
  656. data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/about.js +0 -73
  657. data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/anchor.js +0 -56
  658. data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/charmap.js +0 -363
  659. data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/color_picker.js +0 -345
  660. data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/image.js +0 -253
  661. data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/link.js +0 -159
  662. data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/source_editor.js +0 -78
  663. data/vendor/assets/javascripts/tiny_mce/themes/advanced/langs/de.js +0 -1
  664. data/vendor/assets/javascripts/tiny_mce/themes/advanced/langs/de_dlg.js +0 -1
  665. data/vendor/assets/javascripts/tiny_mce/themes/advanced/langs/en.js +0 -1
  666. data/vendor/assets/javascripts/tiny_mce/themes/advanced/langs/en_dlg.js +0 -1
  667. data/vendor/assets/javascripts/tiny_mce/themes/advanced/link.htm +0 -57
  668. data/vendor/assets/javascripts/tiny_mce/themes/advanced/shortcuts.htm +0 -47
  669. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/default/content.css +0 -50
  670. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/default/dialog.css +0 -118
  671. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/default/img/buttons.png +0 -0
  672. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/default/img/items.gif +0 -0
  673. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/default/img/menu_arrow.gif +0 -0
  674. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/default/img/menu_check.gif +0 -0
  675. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/default/img/progress.gif +0 -0
  676. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/default/img/tabs.gif +0 -0
  677. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/default/ui.css +0 -219
  678. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/highcontrast/content.css +0 -24
  679. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/highcontrast/dialog.css +0 -106
  680. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/highcontrast/ui.css +0 -106
  681. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/content.css +0 -48
  682. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/dialog.css +0 -118
  683. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/img/button_bg.png +0 -0
  684. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/img/button_bg_black.png +0 -0
  685. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/img/button_bg_silver.png +0 -0
  686. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/ui.css +0 -222
  687. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/ui_black.css +0 -8
  688. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/ui_silver.css +0 -5
  689. data/vendor/assets/javascripts/tiny_mce/themes/advanced/source_editor.htm +0 -25
  690. data/vendor/assets/javascripts/tiny_mce/tiny_mce.js +0 -1
  691. data/vendor/assets/javascripts/tiny_mce/tiny_mce_popup.js +0 -5
  692. data/vendor/assets/javascripts/tiny_mce/utils/editable_selects.js +0 -70
  693. data/vendor/assets/javascripts/tiny_mce/utils/form_utils.js +0 -210
  694. data/vendor/assets/javascripts/tiny_mce/utils/mctabs.js +0 -162
  695. data/vendor/assets/javascripts/tiny_mce/utils/validate.js +0 -252
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'alchemy/essences/_essence_select_view' do
4
+ let(:content) { Alchemy::Content.new(essence: essence) }
5
+ let(:essence) { Alchemy::EssenceSelect.new(ingredient: 'blue') }
6
+
7
+ it "renders the ingredient" do
8
+ render content, content: content
9
+ expect(rendered).to have_content('blue')
10
+ end
11
+
12
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'alchemy/essences/_essence_text_view' do
4
+ let(:essence) { Alchemy::EssenceText.new(body: 'Hello World') }
5
+ let(:content) { Alchemy::Content.new(essence: essence) }
6
+
7
+ context 'with blank link value' do
8
+ it "only renders the ingredient" do
9
+ render content, content: content
10
+ expect(rendered).to have_content('Hello World')
11
+ expect(rendered).to_not have_selector('a')
12
+ end
13
+ end
14
+
15
+ context 'with a link set' do
16
+ let(:essence) { Alchemy::EssenceText.new(body: 'Hello World', link: 'http://google.com', link_title: 'Foo', link_target: 'blank') }
17
+
18
+ it "renders the linked ingredient" do
19
+ render content, content: content
20
+ expect(rendered).to have_content('Hello World')
21
+ expect(rendered).to have_selector('a[title="Foo"][target="_blank"][data-link-target="blank"][href="http://google.com"]')
22
+ end
23
+
24
+ context 'with html_options given' do
25
+ it "renders the linked with these options" do
26
+ render content, content: content, html_options: {title: 'Bar', class: 'blue'}
27
+ expect(rendered).to have_selector('a.blue[title="Bar"][target="_blank"][data-link-target="blank"]')
28
+ end
29
+ end
30
+
31
+ context 'but with options disable_link set to true' do
32
+ it "only renders the ingredient" do
33
+ render content, content: content, options: {disable_link: true}
34
+ expect(rendered).to have_content('Hello World')
35
+ expect(rendered).to_not have_selector('a')
36
+ end
37
+ end
38
+ end
39
+
40
+ end
@@ -0,0 +1,172 @@
1
+ /*
2
+ * jQuery File Upload Processing Plugin 1.3.0
3
+ * https://github.com/blueimp/jQuery-File-Upload
4
+ *
5
+ * Copyright 2012, 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 */
13
+ /*global define, window */
14
+
15
+ (function (factory) {
16
+ 'use strict';
17
+ if (typeof define === 'function' && define.amd) {
18
+ // Register as an anonymous AMD module:
19
+ define([
20
+ 'jquery',
21
+ './jquery.fileupload'
22
+ ], factory);
23
+ } else {
24
+ // Browser globals:
25
+ factory(
26
+ window.jQuery
27
+ );
28
+ }
29
+ }(function ($) {
30
+ 'use strict';
31
+
32
+ var originalAdd = $.blueimp.fileupload.prototype.options.add;
33
+
34
+ // The File Upload Processing plugin extends the fileupload widget
35
+ // with file processing functionality:
36
+ $.widget('blueimp.fileupload', $.blueimp.fileupload, {
37
+
38
+ options: {
39
+ // The list of processing actions:
40
+ processQueue: [
41
+ /*
42
+ {
43
+ action: 'log',
44
+ type: 'debug'
45
+ }
46
+ */
47
+ ],
48
+ add: function (e, data) {
49
+ var $this = $(this);
50
+ data.process(function () {
51
+ return $this.fileupload('process', data);
52
+ });
53
+ originalAdd.call(this, e, data);
54
+ }
55
+ },
56
+
57
+ processActions: {
58
+ /*
59
+ log: function (data, options) {
60
+ console[options.type](
61
+ 'Processing "' + data.files[data.index].name + '"'
62
+ );
63
+ }
64
+ */
65
+ },
66
+
67
+ _processFile: function (data, originalData) {
68
+ var that = this,
69
+ dfd = $.Deferred().resolveWith(that, [data]),
70
+ chain = dfd.promise();
71
+ this._trigger('process', null, data);
72
+ $.each(data.processQueue, function (i, settings) {
73
+ var func = function (data) {
74
+ if (originalData.errorThrown) {
75
+ return $.Deferred()
76
+ .rejectWith(that, [originalData]).promise();
77
+ }
78
+ return that.processActions[settings.action].call(
79
+ that,
80
+ data,
81
+ settings
82
+ );
83
+ };
84
+ chain = chain.pipe(func, settings.always && func);
85
+ });
86
+ chain
87
+ .done(function () {
88
+ that._trigger('processdone', null, data);
89
+ that._trigger('processalways', null, data);
90
+ })
91
+ .fail(function () {
92
+ that._trigger('processfail', null, data);
93
+ that._trigger('processalways', null, data);
94
+ });
95
+ return chain;
96
+ },
97
+
98
+ // Replaces the settings of each processQueue item that
99
+ // are strings starting with an "@", using the remaining
100
+ // substring as key for the option map,
101
+ // e.g. "@autoUpload" is replaced with options.autoUpload:
102
+ _transformProcessQueue: function (options) {
103
+ var processQueue = [];
104
+ $.each(options.processQueue, function () {
105
+ var settings = {},
106
+ action = this.action,
107
+ prefix = this.prefix === true ? action : this.prefix;
108
+ $.each(this, function (key, value) {
109
+ if ($.type(value) === 'string' &&
110
+ value.charAt(0) === '@') {
111
+ settings[key] = options[
112
+ value.slice(1) || (prefix ? prefix +
113
+ key.charAt(0).toUpperCase() + key.slice(1) : key)
114
+ ];
115
+ } else {
116
+ settings[key] = value;
117
+ }
118
+
119
+ });
120
+ processQueue.push(settings);
121
+ });
122
+ options.processQueue = processQueue;
123
+ },
124
+
125
+ // Returns the number of files currently in the processsing queue:
126
+ processing: function () {
127
+ return this._processing;
128
+ },
129
+
130
+ // Processes the files given as files property of the data parameter,
131
+ // returns a Promise object that allows to bind callbacks:
132
+ process: function (data) {
133
+ var that = this,
134
+ options = $.extend({}, this.options, data);
135
+ if (options.processQueue && options.processQueue.length) {
136
+ this._transformProcessQueue(options);
137
+ if (this._processing === 0) {
138
+ this._trigger('processstart');
139
+ }
140
+ $.each(data.files, function (index) {
141
+ var opts = index ? $.extend({}, options) : options,
142
+ func = function () {
143
+ if (data.errorThrown) {
144
+ return $.Deferred()
145
+ .rejectWith(that, [data]).promise();
146
+ }
147
+ return that._processFile(opts, data);
148
+ };
149
+ opts.index = index;
150
+ that._processing += 1;
151
+ that._processingQueue = that._processingQueue.pipe(func, func)
152
+ .always(function () {
153
+ that._processing -= 1;
154
+ if (that._processing === 0) {
155
+ that._trigger('processstop');
156
+ }
157
+ });
158
+ });
159
+ }
160
+ return this._processingQueue;
161
+ },
162
+
163
+ _create: function () {
164
+ this._super();
165
+ this._processing = 0;
166
+ this._processingQueue = $.Deferred().resolveWith(this)
167
+ .promise();
168
+ }
169
+
170
+ });
171
+
172
+ }));
@@ -0,0 +1,120 @@
1
+ /*
2
+ * jQuery File Upload Validation Plugin 1.1.2
3
+ * https://github.com/blueimp/jQuery-File-Upload
4
+ *
5
+ * Copyright 2013, 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 */
14
+
15
+ (function (factory) {
16
+ 'use strict';
17
+ if (typeof define === 'function' && define.amd) {
18
+ // Register as an anonymous AMD module:
19
+ define([
20
+ 'jquery',
21
+ './jquery.fileupload-process'
22
+ ], factory);
23
+ } else {
24
+ // Browser globals:
25
+ factory(
26
+ window.jQuery
27
+ );
28
+ }
29
+ }(function ($) {
30
+ 'use strict';
31
+
32
+ // Append to the default processQueue:
33
+ $.blueimp.fileupload.prototype.options.processQueue.push(
34
+ {
35
+ action: 'validate',
36
+ // Always trigger this action,
37
+ // even if the previous action was rejected:
38
+ always: true,
39
+ // Options taken from the global options map:
40
+ acceptFileTypes: '@',
41
+ maxFileSize: '@',
42
+ minFileSize: '@',
43
+ maxNumberOfFiles: '@',
44
+ disabled: '@disableValidation'
45
+ }
46
+ );
47
+
48
+ // The File Upload Validation plugin extends the fileupload widget
49
+ // with file validation functionality:
50
+ $.widget('blueimp.fileupload', $.blueimp.fileupload, {
51
+
52
+ options: {
53
+ /*
54
+ // The regular expression for allowed file types, matches
55
+ // against either file type or file name:
56
+ acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
57
+ // The maximum allowed file size in bytes:
58
+ maxFileSize: 10000000, // 10 MB
59
+ // The minimum allowed file size in bytes:
60
+ minFileSize: undefined, // No minimal file size
61
+ // The limit of files to be uploaded:
62
+ maxNumberOfFiles: 10,
63
+ */
64
+
65
+ // Function returning the current number of files,
66
+ // has to be overriden for maxNumberOfFiles validation:
67
+ getNumberOfFiles: $.noop,
68
+
69
+ // Error and info messages:
70
+ messages: {
71
+ maxNumberOfFiles: 'Maximum number of files exceeded',
72
+ acceptFileTypes: 'File type not allowed',
73
+ maxFileSize: 'File is too large',
74
+ minFileSize: 'File is too small'
75
+ }
76
+ },
77
+
78
+ processActions: {
79
+
80
+ validate: function (data, options) {
81
+ if (options.disabled) {
82
+ return data;
83
+ }
84
+ var dfd = $.Deferred(),
85
+ settings = this.options,
86
+ file = data.files[data.index],
87
+ fileSize;
88
+ if (options.minFileSize || options.maxFileSize) {
89
+ fileSize = file.size;
90
+ }
91
+ if ($.type(options.maxNumberOfFiles) === 'number' &&
92
+ (settings.getNumberOfFiles() || 0) + data.files.length >
93
+ options.maxNumberOfFiles) {
94
+ file.error = settings.i18n('maxNumberOfFiles');
95
+ } else if (options.acceptFileTypes &&
96
+ !(options.acceptFileTypes.test(file.type) ||
97
+ options.acceptFileTypes.test(file.name))) {
98
+ file.error = settings.i18n('acceptFileTypes');
99
+ } else if (fileSize > options.maxFileSize) {
100
+ file.error = settings.i18n('maxFileSize');
101
+ } else if ($.type(fileSize) === 'number' &&
102
+ fileSize < options.minFileSize) {
103
+ file.error = settings.i18n('minFileSize');
104
+ } else {
105
+ delete file.error;
106
+ }
107
+ if (file.error || data.files.error) {
108
+ data.files.error = true;
109
+ dfd.rejectWith(this, [data]);
110
+ } else {
111
+ dfd.resolveWith(this, [data]);
112
+ }
113
+ return dfd.promise();
114
+ }
115
+
116
+ }
117
+
118
+ });
119
+
120
+ }));
@@ -0,0 +1,1416 @@
1
+ /*
2
+ * jQuery File Upload Plugin 5.38.0
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, location, File, Blob, FormData */
14
+
15
+ (function (factory) {
16
+ 'use strict';
17
+ if (typeof define === 'function' && define.amd) {
18
+ // Register as an anonymous AMD module:
19
+ define([
20
+ 'jquery',
21
+ 'jquery.ui.widget'
22
+ ], factory);
23
+ } else {
24
+ // Browser globals:
25
+ factory(window.jQuery);
26
+ }
27
+ }(function ($) {
28
+ 'use strict';
29
+
30
+ // Detect file input support, based on
31
+ // http://viljamis.com/blog/2012/file-upload-support-on-mobile/
32
+ $.support.fileInput = !(new RegExp(
33
+ // Handle devices which give false positives for the feature detection:
34
+ '(Android (1\\.[0156]|2\\.[01]))' +
35
+ '|(Windows Phone (OS 7|8\\.0))|(XBLWP)|(ZuneWP)|(WPDesktop)' +
36
+ '|(w(eb)?OSBrowser)|(webOS)' +
37
+ '|(Kindle/(1\\.0|2\\.[05]|3\\.0))'
38
+ ).test(window.navigator.userAgent) ||
39
+ // Feature detection for all other devices:
40
+ $('<input type="file">').prop('disabled'));
41
+
42
+ // The FileReader API is not actually used, but works as feature detection,
43
+ // as some Safari versions (5?) support XHR file uploads via the FormData API,
44
+ // but not non-multipart XHR file uploads.
45
+ // window.XMLHttpRequestUpload is not available on IE10, so we check for
46
+ // window.ProgressEvent instead to detect XHR2 file upload capability:
47
+ $.support.xhrFileUpload = !!(window.ProgressEvent && window.FileReader);
48
+ $.support.xhrFormDataFileUpload = !!window.FormData;
49
+
50
+ // Detect support for Blob slicing (required for chunked uploads):
51
+ $.support.blobSlice = window.Blob && (Blob.prototype.slice ||
52
+ Blob.prototype.webkitSlice || Blob.prototype.mozSlice);
53
+
54
+ // The fileupload widget listens for change events on file input fields defined
55
+ // via fileInput setting and paste or drop events of the given dropZone.
56
+ // In addition to the default jQuery Widget methods, the fileupload widget
57
+ // exposes the "add" and "send" methods, to add or directly send files using
58
+ // the fileupload API.
59
+ // By default, files added via file input selection, paste, drag & drop or
60
+ // "add" method are uploaded immediately, but it is possible to override
61
+ // the "add" callback option to queue file uploads.
62
+ $.widget('blueimp.fileupload', {
63
+
64
+ options: {
65
+ // The drop target element(s), by the default the complete document.
66
+ // Set to null to disable drag & drop support:
67
+ dropZone: $(document),
68
+ // The paste target element(s), by the default the complete document.
69
+ // Set to null to disable paste support:
70
+ pasteZone: $(document),
71
+ // The file input field(s), that are listened to for change events.
72
+ // If undefined, it is set to the file input fields inside
73
+ // of the widget element on plugin initialization.
74
+ // Set to null to disable the change listener.
75
+ fileInput: undefined,
76
+ // By default, the file input field is replaced with a clone after
77
+ // each input field change event. This is required for iframe transport
78
+ // queues and allows change events to be fired for the same file
79
+ // selection, but can be disabled by setting the following option to false:
80
+ replaceFileInput: true,
81
+ // The parameter name for the file form data (the request argument name).
82
+ // If undefined or empty, the name property of the file input field is
83
+ // used, or "files[]" if the file input name property is also empty,
84
+ // can be a string or an array of strings:
85
+ paramName: undefined,
86
+ // By default, each file of a selection is uploaded using an individual
87
+ // request for XHR type uploads. Set to false to upload file
88
+ // selections in one request each:
89
+ singleFileUploads: true,
90
+ // To limit the number of files uploaded with one XHR request,
91
+ // set the following option to an integer greater than 0:
92
+ limitMultiFileUploads: undefined,
93
+ // The following option limits the number of files uploaded with one
94
+ // XHR request to keep the request size under or equal to the defined
95
+ // limit in bytes:
96
+ limitMultiFileUploadSize: undefined,
97
+ // Multipart file uploads add a number of bytes to each uploaded file,
98
+ // therefore the following option adds an overhead for each file used
99
+ // in the limitMultiFileUploadSize configuration:
100
+ limitMultiFileUploadSizeOverhead: 512,
101
+ // Set the following option to true to issue all file upload requests
102
+ // in a sequential order:
103
+ sequentialUploads: false,
104
+ // To limit the number of concurrent uploads,
105
+ // set the following option to an integer greater than 0:
106
+ limitConcurrentUploads: undefined,
107
+ // Set the following option to true to force iframe transport uploads:
108
+ forceIframeTransport: false,
109
+ // Set the following option to the location of a redirect url on the
110
+ // origin server, for cross-domain iframe transport uploads:
111
+ redirect: undefined,
112
+ // The parameter name for the redirect url, sent as part of the form
113
+ // data and set to 'redirect' if this option is empty:
114
+ redirectParamName: undefined,
115
+ // Set the following option to the location of a postMessage window,
116
+ // to enable postMessage transport uploads:
117
+ postMessage: undefined,
118
+ // By default, XHR file uploads are sent as multipart/form-data.
119
+ // The iframe transport is always using multipart/form-data.
120
+ // Set to false to enable non-multipart XHR uploads:
121
+ multipart: true,
122
+ // To upload large files in smaller chunks, set the following option
123
+ // to a preferred maximum chunk size. If set to 0, null or undefined,
124
+ // or the browser does not support the required Blob API, files will
125
+ // be uploaded as a whole.
126
+ maxChunkSize: undefined,
127
+ // When a non-multipart upload or a chunked multipart upload has been
128
+ // aborted, this option can be used to resume the upload by setting
129
+ // it to the size of the already uploaded bytes. This option is most
130
+ // useful when modifying the options object inside of the "add" or
131
+ // "send" callbacks, as the options are cloned for each file upload.
132
+ uploadedBytes: undefined,
133
+ // By default, failed (abort or error) file uploads are removed from the
134
+ // global progress calculation. Set the following option to false to
135
+ // prevent recalculating the global progress data:
136
+ recalculateProgress: true,
137
+ // Interval in milliseconds to calculate and trigger progress events:
138
+ progressInterval: 100,
139
+ // Interval in milliseconds to calculate progress bitrate:
140
+ bitrateInterval: 500,
141
+ // By default, uploads are started automatically when adding files:
142
+ autoUpload: true,
143
+
144
+ // Error and info messages:
145
+ messages: {
146
+ uploadedBytes: 'Uploaded bytes exceed file size'
147
+ },
148
+
149
+ // Translation function, gets the message key to be translated
150
+ // and an object with context specific data as arguments:
151
+ i18n: function (message, context) {
152
+ message = this.messages[message] || message.toString();
153
+ if (context) {
154
+ $.each(context, function (key, value) {
155
+ message = message.replace('{' + key + '}', value);
156
+ });
157
+ }
158
+ return message;
159
+ },
160
+
161
+ // Additional form data to be sent along with the file uploads can be set
162
+ // using this option, which accepts an array of objects with name and
163
+ // value properties, a function returning such an array, a FormData
164
+ // object (for XHR file uploads), or a simple object.
165
+ // The form of the first fileInput is given as parameter to the function:
166
+ formData: function (form) {
167
+ return form.serializeArray();
168
+ },
169
+
170
+ // The add callback is invoked as soon as files are added to the fileupload
171
+ // widget (via file input selection, drag & drop, paste or add API call).
172
+ // If the singleFileUploads option is enabled, this callback will be
173
+ // called once for each file in the selection for XHR file uploads, else
174
+ // once for each file selection.
175
+ //
176
+ // The upload starts when the submit method is invoked on the data parameter.
177
+ // The data object contains a files property holding the added files
178
+ // and allows you to override plugin options as well as define ajax settings.
179
+ //
180
+ // Listeners for this callback can also be bound the following way:
181
+ // .bind('fileuploadadd', func);
182
+ //
183
+ // data.submit() returns a Promise object and allows to attach additional
184
+ // handlers using jQuery's Deferred callbacks:
185
+ // data.submit().done(func).fail(func).always(func);
186
+ add: function (e, data) {
187
+ if (e.isDefaultPrevented()) {
188
+ return false;
189
+ }
190
+ if (data.autoUpload || (data.autoUpload !== false &&
191
+ $(this).fileupload('option', 'autoUpload'))) {
192
+ data.process().done(function () {
193
+ data.submit();
194
+ });
195
+ }
196
+ },
197
+
198
+ // Other callbacks:
199
+
200
+ // Callback for the submit event of each file upload:
201
+ // submit: function (e, data) {}, // .bind('fileuploadsubmit', func);
202
+
203
+ // Callback for the start of each file upload request:
204
+ // send: function (e, data) {}, // .bind('fileuploadsend', func);
205
+
206
+ // Callback for successful uploads:
207
+ // done: function (e, data) {}, // .bind('fileuploaddone', func);
208
+
209
+ // Callback for failed (abort or error) uploads:
210
+ // fail: function (e, data) {}, // .bind('fileuploadfail', func);
211
+
212
+ // Callback for completed (success, abort or error) requests:
213
+ // always: function (e, data) {}, // .bind('fileuploadalways', func);
214
+
215
+ // Callback for upload progress events:
216
+ // progress: function (e, data) {}, // .bind('fileuploadprogress', func);
217
+
218
+ // Callback for global upload progress events:
219
+ // progressall: function (e, data) {}, // .bind('fileuploadprogressall', func);
220
+
221
+ // Callback for uploads start, equivalent to the global ajaxStart event:
222
+ // start: function (e) {}, // .bind('fileuploadstart', func);
223
+
224
+ // Callback for uploads stop, equivalent to the global ajaxStop event:
225
+ // stop: function (e) {}, // .bind('fileuploadstop', func);
226
+
227
+ // Callback for change events of the fileInput(s):
228
+ // change: function (e, data) {}, // .bind('fileuploadchange', func);
229
+
230
+ // Callback for paste events to the pasteZone(s):
231
+ // paste: function (e, data) {}, // .bind('fileuploadpaste', func);
232
+
233
+ // Callback for drop events of the dropZone(s):
234
+ // drop: function (e, data) {}, // .bind('fileuploaddrop', func);
235
+
236
+ // Callback for dragover events of the dropZone(s):
237
+ // dragover: function (e) {}, // .bind('fileuploaddragover', func);
238
+
239
+ // Callback for the start of each chunk upload request:
240
+ // chunksend: function (e, data) {}, // .bind('fileuploadchunksend', func);
241
+
242
+ // Callback for successful chunk uploads:
243
+ // chunkdone: function (e, data) {}, // .bind('fileuploadchunkdone', func);
244
+
245
+ // Callback for failed (abort or error) chunk uploads:
246
+ // chunkfail: function (e, data) {}, // .bind('fileuploadchunkfail', func);
247
+
248
+ // Callback for completed (success, abort or error) chunk upload requests:
249
+ // chunkalways: function (e, data) {}, // .bind('fileuploadchunkalways', func);
250
+
251
+ // The plugin options are used as settings object for the ajax calls.
252
+ // The following are jQuery ajax settings required for the file uploads:
253
+ processData: false,
254
+ contentType: false,
255
+ cache: false
256
+ },
257
+
258
+ // A list of options that require reinitializing event listeners and/or
259
+ // special initialization code:
260
+ _specialOptions: [
261
+ 'fileInput',
262
+ 'dropZone',
263
+ 'pasteZone',
264
+ 'multipart',
265
+ 'forceIframeTransport'
266
+ ],
267
+
268
+ _blobSlice: $.support.blobSlice && function () {
269
+ var slice = this.slice || this.webkitSlice || this.mozSlice;
270
+ return slice.apply(this, arguments);
271
+ },
272
+
273
+ _BitrateTimer: function () {
274
+ this.timestamp = ((Date.now) ? Date.now() : (new Date()).getTime());
275
+ this.loaded = 0;
276
+ this.bitrate = 0;
277
+ this.getBitrate = function (now, loaded, interval) {
278
+ var timeDiff = now - this.timestamp;
279
+ if (!this.bitrate || !interval || timeDiff > interval) {
280
+ this.bitrate = (loaded - this.loaded) * (1000 / timeDiff) * 8;
281
+ this.loaded = loaded;
282
+ this.timestamp = now;
283
+ }
284
+ return this.bitrate;
285
+ };
286
+ },
287
+
288
+ _isXHRUpload: function (options) {
289
+ return !options.forceIframeTransport &&
290
+ ((!options.multipart && $.support.xhrFileUpload) ||
291
+ $.support.xhrFormDataFileUpload);
292
+ },
293
+
294
+ _getFormData: function (options) {
295
+ var formData;
296
+ if ($.type(options.formData) === 'function') {
297
+ return options.formData(options.form);
298
+ }
299
+ if ($.isArray(options.formData)) {
300
+ return options.formData;
301
+ }
302
+ if ($.type(options.formData) === 'object') {
303
+ formData = [];
304
+ $.each(options.formData, function (name, value) {
305
+ formData.push({name: name, value: value});
306
+ });
307
+ return formData;
308
+ }
309
+ return [];
310
+ },
311
+
312
+ _getTotal: function (files) {
313
+ var total = 0;
314
+ $.each(files, function (index, file) {
315
+ total += file.size || 1;
316
+ });
317
+ return total;
318
+ },
319
+
320
+ _initProgressObject: function (obj) {
321
+ var progress = {
322
+ loaded: 0,
323
+ total: 0,
324
+ bitrate: 0
325
+ };
326
+ if (obj._progress) {
327
+ $.extend(obj._progress, progress);
328
+ } else {
329
+ obj._progress = progress;
330
+ }
331
+ },
332
+
333
+ _initResponseObject: function (obj) {
334
+ var prop;
335
+ if (obj._response) {
336
+ for (prop in obj._response) {
337
+ if (obj._response.hasOwnProperty(prop)) {
338
+ delete obj._response[prop];
339
+ }
340
+ }
341
+ } else {
342
+ obj._response = {};
343
+ }
344
+ },
345
+
346
+ _onProgress: function (e, data) {
347
+ if (e.lengthComputable) {
348
+ var now = ((Date.now) ? Date.now() : (new Date()).getTime()),
349
+ loaded;
350
+ if (data._time && data.progressInterval &&
351
+ (now - data._time < data.progressInterval) &&
352
+ e.loaded !== e.total) {
353
+ return;
354
+ }
355
+ data._time = now;
356
+ loaded = Math.floor(
357
+ e.loaded / e.total * (data.chunkSize || data._progress.total)
358
+ ) + (data.uploadedBytes || 0);
359
+ // Add the difference from the previously loaded state
360
+ // to the global loaded counter:
361
+ this._progress.loaded += (loaded - data._progress.loaded);
362
+ this._progress.bitrate = this._bitrateTimer.getBitrate(
363
+ now,
364
+ this._progress.loaded,
365
+ data.bitrateInterval
366
+ );
367
+ data._progress.loaded = data.loaded = loaded;
368
+ data._progress.bitrate = data.bitrate = data._bitrateTimer.getBitrate(
369
+ now,
370
+ loaded,
371
+ data.bitrateInterval
372
+ );
373
+ // Trigger a custom progress event with a total data property set
374
+ // to the file size(s) of the current upload and a loaded data
375
+ // property calculated accordingly:
376
+ this._trigger(
377
+ 'progress',
378
+ $.Event('progress', {delegatedEvent: e}),
379
+ data
380
+ );
381
+ // Trigger a global progress event for all current file uploads,
382
+ // including ajax calls queued for sequential file uploads:
383
+ this._trigger(
384
+ 'progressall',
385
+ $.Event('progressall', {delegatedEvent: e}),
386
+ this._progress
387
+ );
388
+ }
389
+ },
390
+
391
+ _initProgressListener: function (options) {
392
+ var that = this,
393
+ xhr = options.xhr ? options.xhr() : $.ajaxSettings.xhr();
394
+ // Accesss to the native XHR object is required to add event listeners
395
+ // for the upload progress event:
396
+ if (xhr.upload) {
397
+ $(xhr.upload).bind('progress', function (e) {
398
+ var oe = e.originalEvent;
399
+ // Make sure the progress event properties get copied over:
400
+ e.lengthComputable = oe.lengthComputable;
401
+ e.loaded = oe.loaded;
402
+ e.total = oe.total;
403
+ that._onProgress(e, options);
404
+ });
405
+ options.xhr = function () {
406
+ return xhr;
407
+ };
408
+ }
409
+ },
410
+
411
+ _isInstanceOf: function (type, obj) {
412
+ // Cross-frame instanceof check
413
+ return Object.prototype.toString.call(obj) === '[object ' + type + ']';
414
+ },
415
+
416
+ _initXHRData: function (options) {
417
+ var that = this,
418
+ formData,
419
+ file = options.files[0],
420
+ // Ignore non-multipart setting if not supported:
421
+ multipart = options.multipart || !$.support.xhrFileUpload,
422
+ paramName = options.paramName[0];
423
+ options.headers = $.extend({}, options.headers);
424
+ if (options.contentRange) {
425
+ options.headers['Content-Range'] = options.contentRange;
426
+ }
427
+ if (!multipart || options.blob || !this._isInstanceOf('File', file)) {
428
+ options.headers['Content-Disposition'] = 'attachment; filename="' +
429
+ encodeURI(file.name) + '"';
430
+ }
431
+ if (!multipart) {
432
+ options.contentType = file.type;
433
+ options.data = options.blob || file;
434
+ } else if ($.support.xhrFormDataFileUpload) {
435
+ if (options.postMessage) {
436
+ // window.postMessage does not allow sending FormData
437
+ // objects, so we just add the File/Blob objects to
438
+ // the formData array and let the postMessage window
439
+ // create the FormData object out of this array:
440
+ formData = this._getFormData(options);
441
+ if (options.blob) {
442
+ formData.push({
443
+ name: paramName,
444
+ value: options.blob
445
+ });
446
+ } else {
447
+ $.each(options.files, function (index, file) {
448
+ formData.push({
449
+ name: options.paramName[index] || paramName,
450
+ value: file
451
+ });
452
+ });
453
+ }
454
+ } else {
455
+ if (that._isInstanceOf('FormData', options.formData)) {
456
+ formData = options.formData;
457
+ } else {
458
+ formData = new FormData();
459
+ $.each(this._getFormData(options), function (index, field) {
460
+ formData.append(field.name, field.value);
461
+ });
462
+ }
463
+ if (options.blob) {
464
+ formData.append(paramName, options.blob, file.name);
465
+ } else {
466
+ $.each(options.files, function (index, file) {
467
+ // This check allows the tests to run with
468
+ // dummy objects:
469
+ if (that._isInstanceOf('File', file) ||
470
+ that._isInstanceOf('Blob', file)) {
471
+ formData.append(
472
+ options.paramName[index] || paramName,
473
+ file,
474
+ file.uploadName || file.name
475
+ );
476
+ }
477
+ });
478
+ }
479
+ }
480
+ options.data = formData;
481
+ }
482
+ // Blob reference is not needed anymore, free memory:
483
+ options.blob = null;
484
+ },
485
+
486
+ _initIframeSettings: function (options) {
487
+ var targetHost = $('<a></a>').prop('href', options.url).prop('host');
488
+ // Setting the dataType to iframe enables the iframe transport:
489
+ options.dataType = 'iframe ' + (options.dataType || '');
490
+ // The iframe transport accepts a serialized array as form data:
491
+ options.formData = this._getFormData(options);
492
+ // Add redirect url to form data on cross-domain uploads:
493
+ if (options.redirect && targetHost && targetHost !== location.host) {
494
+ options.formData.push({
495
+ name: options.redirectParamName || 'redirect',
496
+ value: options.redirect
497
+ });
498
+ }
499
+ },
500
+
501
+ _initDataSettings: function (options) {
502
+ if (this._isXHRUpload(options)) {
503
+ if (!this._chunkedUpload(options, true)) {
504
+ if (!options.data) {
505
+ this._initXHRData(options);
506
+ }
507
+ this._initProgressListener(options);
508
+ }
509
+ if (options.postMessage) {
510
+ // Setting the dataType to postmessage enables the
511
+ // postMessage transport:
512
+ options.dataType = 'postmessage ' + (options.dataType || '');
513
+ }
514
+ } else {
515
+ this._initIframeSettings(options);
516
+ }
517
+ },
518
+
519
+ _getParamName: function (options) {
520
+ var fileInput = $(options.fileInput),
521
+ paramName = options.paramName;
522
+ if (!paramName) {
523
+ paramName = [];
524
+ fileInput.each(function () {
525
+ var input = $(this),
526
+ name = input.prop('name') || 'files[]',
527
+ i = (input.prop('files') || [1]).length;
528
+ while (i) {
529
+ paramName.push(name);
530
+ i -= 1;
531
+ }
532
+ });
533
+ if (!paramName.length) {
534
+ paramName = [fileInput.prop('name') || 'files[]'];
535
+ }
536
+ } else if (!$.isArray(paramName)) {
537
+ paramName = [paramName];
538
+ }
539
+ return paramName;
540
+ },
541
+
542
+ _initFormSettings: function (options) {
543
+ // Retrieve missing options from the input field and the
544
+ // associated form, if available:
545
+ if (!options.form || !options.form.length) {
546
+ options.form = $(options.fileInput.prop('form'));
547
+ // If the given file input doesn't have an associated form,
548
+ // use the default widget file input's form:
549
+ if (!options.form.length) {
550
+ options.form = $(this.options.fileInput.prop('form'));
551
+ }
552
+ }
553
+ options.paramName = this._getParamName(options);
554
+ if (!options.url) {
555
+ options.url = options.form.prop('action') || location.href;
556
+ }
557
+ // The HTTP request method must be "POST" or "PUT":
558
+ options.type = (options.type ||
559
+ ($.type(options.form.prop('method')) === 'string' &&
560
+ options.form.prop('method')) || ''
561
+ ).toUpperCase();
562
+ if (options.type !== 'POST' && options.type !== 'PUT' &&
563
+ options.type !== 'PATCH') {
564
+ options.type = 'POST';
565
+ }
566
+ if (!options.formAcceptCharset) {
567
+ options.formAcceptCharset = options.form.attr('accept-charset');
568
+ }
569
+ },
570
+
571
+ _getAJAXSettings: function (data) {
572
+ var options = $.extend({}, this.options, data);
573
+ this._initFormSettings(options);
574
+ this._initDataSettings(options);
575
+ return options;
576
+ },
577
+
578
+ // jQuery 1.6 doesn't provide .state(),
579
+ // while jQuery 1.8+ removed .isRejected() and .isResolved():
580
+ _getDeferredState: function (deferred) {
581
+ if (deferred.state) {
582
+ return deferred.state();
583
+ }
584
+ if (deferred.isResolved()) {
585
+ return 'resolved';
586
+ }
587
+ if (deferred.isRejected()) {
588
+ return 'rejected';
589
+ }
590
+ return 'pending';
591
+ },
592
+
593
+ // Maps jqXHR callbacks to the equivalent
594
+ // methods of the given Promise object:
595
+ _enhancePromise: function (promise) {
596
+ promise.success = promise.done;
597
+ promise.error = promise.fail;
598
+ promise.complete = promise.always;
599
+ return promise;
600
+ },
601
+
602
+ // Creates and returns a Promise object enhanced with
603
+ // the jqXHR methods abort, success, error and complete:
604
+ _getXHRPromise: function (resolveOrReject, context, args) {
605
+ var dfd = $.Deferred(),
606
+ promise = dfd.promise();
607
+ context = context || this.options.context || promise;
608
+ if (resolveOrReject === true) {
609
+ dfd.resolveWith(context, args);
610
+ } else if (resolveOrReject === false) {
611
+ dfd.rejectWith(context, args);
612
+ }
613
+ promise.abort = dfd.promise;
614
+ return this._enhancePromise(promise);
615
+ },
616
+
617
+ // Adds convenience methods to the data callback argument:
618
+ _addConvenienceMethods: function (e, data) {
619
+ var that = this,
620
+ getPromise = function (args) {
621
+ return $.Deferred().resolveWith(that, args).promise();
622
+ };
623
+ data.process = function (resolveFunc, rejectFunc) {
624
+ if (resolveFunc || rejectFunc) {
625
+ data._processQueue = this._processQueue =
626
+ (this._processQueue || getPromise([this])).pipe(
627
+ function () {
628
+ if (data.errorThrown) {
629
+ return $.Deferred()
630
+ .rejectWith(that, [data]).promise();
631
+ }
632
+ return getPromise(arguments);
633
+ }
634
+ ).pipe(resolveFunc, rejectFunc);
635
+ }
636
+ return this._processQueue || getPromise([this]);
637
+ };
638
+ data.submit = function () {
639
+ if (this.state() !== 'pending') {
640
+ data.jqXHR = this.jqXHR =
641
+ (that._trigger(
642
+ 'submit',
643
+ $.Event('submit', {delegatedEvent: e}),
644
+ this
645
+ ) !== false) && that._onSend(e, this);
646
+ }
647
+ return this.jqXHR || that._getXHRPromise();
648
+ };
649
+ data.abort = function () {
650
+ if (this.jqXHR) {
651
+ return this.jqXHR.abort();
652
+ }
653
+ this.errorThrown = 'abort';
654
+ return that._getXHRPromise();
655
+ };
656
+ data.state = function () {
657
+ if (this.jqXHR) {
658
+ return that._getDeferredState(this.jqXHR);
659
+ }
660
+ if (this._processQueue) {
661
+ return that._getDeferredState(this._processQueue);
662
+ }
663
+ };
664
+ data.processing = function () {
665
+ return !this.jqXHR && this._processQueue && that
666
+ ._getDeferredState(this._processQueue) === 'pending';
667
+ };
668
+ data.progress = function () {
669
+ return this._progress;
670
+ };
671
+ data.response = function () {
672
+ return this._response;
673
+ };
674
+ },
675
+
676
+ // Parses the Range header from the server response
677
+ // and returns the uploaded bytes:
678
+ _getUploadedBytes: function (jqXHR) {
679
+ var range = jqXHR.getResponseHeader('Range'),
680
+ parts = range && range.split('-'),
681
+ upperBytesPos = parts && parts.length > 1 &&
682
+ parseInt(parts[1], 10);
683
+ return upperBytesPos && upperBytesPos + 1;
684
+ },
685
+
686
+ // Uploads a file in multiple, sequential requests
687
+ // by splitting the file up in multiple blob chunks.
688
+ // If the second parameter is true, only tests if the file
689
+ // should be uploaded in chunks, but does not invoke any
690
+ // upload requests:
691
+ _chunkedUpload: function (options, testOnly) {
692
+ options.uploadedBytes = options.uploadedBytes || 0;
693
+ var that = this,
694
+ file = options.files[0],
695
+ fs = file.size,
696
+ ub = options.uploadedBytes,
697
+ mcs = options.maxChunkSize || fs,
698
+ slice = this._blobSlice,
699
+ dfd = $.Deferred(),
700
+ promise = dfd.promise(),
701
+ jqXHR,
702
+ upload;
703
+ if (!(this._isXHRUpload(options) && slice && (ub || mcs < fs)) ||
704
+ options.data) {
705
+ return false;
706
+ }
707
+ if (testOnly) {
708
+ return true;
709
+ }
710
+ if (ub >= fs) {
711
+ file.error = options.i18n('uploadedBytes');
712
+ return this._getXHRPromise(
713
+ false,
714
+ options.context,
715
+ [null, 'error', file.error]
716
+ );
717
+ }
718
+ // The chunk upload method:
719
+ upload = function () {
720
+ // Clone the options object for each chunk upload:
721
+ var o = $.extend({}, options),
722
+ currentLoaded = o._progress.loaded;
723
+ o.blob = slice.call(
724
+ file,
725
+ ub,
726
+ ub + mcs,
727
+ file.type
728
+ );
729
+ // Store the current chunk size, as the blob itself
730
+ // will be dereferenced after data processing:
731
+ o.chunkSize = o.blob.size;
732
+ // Expose the chunk bytes position range:
733
+ o.contentRange = 'bytes ' + ub + '-' +
734
+ (ub + o.chunkSize - 1) + '/' + fs;
735
+ // Process the upload data (the blob and potential form data):
736
+ that._initXHRData(o);
737
+ // Add progress listeners for this chunk upload:
738
+ that._initProgressListener(o);
739
+ jqXHR = ((that._trigger('chunksend', null, o) !== false && $.ajax(o)) ||
740
+ that._getXHRPromise(false, o.context))
741
+ .done(function (result, textStatus, jqXHR) {
742
+ ub = that._getUploadedBytes(jqXHR) ||
743
+ (ub + o.chunkSize);
744
+ // Create a progress event if no final progress event
745
+ // with loaded equaling total has been triggered
746
+ // for this chunk:
747
+ if (currentLoaded + o.chunkSize - o._progress.loaded) {
748
+ that._onProgress($.Event('progress', {
749
+ lengthComputable: true,
750
+ loaded: ub - o.uploadedBytes,
751
+ total: ub - o.uploadedBytes
752
+ }), o);
753
+ }
754
+ options.uploadedBytes = o.uploadedBytes = ub;
755
+ o.result = result;
756
+ o.textStatus = textStatus;
757
+ o.jqXHR = jqXHR;
758
+ that._trigger('chunkdone', null, o);
759
+ that._trigger('chunkalways', null, o);
760
+ if (ub < fs) {
761
+ // File upload not yet complete,
762
+ // continue with the next chunk:
763
+ upload();
764
+ } else {
765
+ dfd.resolveWith(
766
+ o.context,
767
+ [result, textStatus, jqXHR]
768
+ );
769
+ }
770
+ })
771
+ .fail(function (jqXHR, textStatus, errorThrown) {
772
+ o.jqXHR = jqXHR;
773
+ o.textStatus = textStatus;
774
+ o.errorThrown = errorThrown;
775
+ that._trigger('chunkfail', null, o);
776
+ that._trigger('chunkalways', null, o);
777
+ dfd.rejectWith(
778
+ o.context,
779
+ [jqXHR, textStatus, errorThrown]
780
+ );
781
+ });
782
+ };
783
+ this._enhancePromise(promise);
784
+ promise.abort = function () {
785
+ return jqXHR.abort();
786
+ };
787
+ upload();
788
+ return promise;
789
+ },
790
+
791
+ _beforeSend: function (e, data) {
792
+ if (this._active === 0) {
793
+ // the start callback is triggered when an upload starts
794
+ // and no other uploads are currently running,
795
+ // equivalent to the global ajaxStart event:
796
+ this._trigger('start');
797
+ // Set timer for global bitrate progress calculation:
798
+ this._bitrateTimer = new this._BitrateTimer();
799
+ // Reset the global progress values:
800
+ this._progress.loaded = this._progress.total = 0;
801
+ this._progress.bitrate = 0;
802
+ }
803
+ // Make sure the container objects for the .response() and
804
+ // .progress() methods on the data object are available
805
+ // and reset to their initial state:
806
+ this._initResponseObject(data);
807
+ this._initProgressObject(data);
808
+ data._progress.loaded = data.loaded = data.uploadedBytes || 0;
809
+ data._progress.total = data.total = this._getTotal(data.files) || 1;
810
+ data._progress.bitrate = data.bitrate = 0;
811
+ this._active += 1;
812
+ // Initialize the global progress values:
813
+ this._progress.loaded += data.loaded;
814
+ this._progress.total += data.total;
815
+ },
816
+
817
+ _onDone: function (result, textStatus, jqXHR, options) {
818
+ var total = options._progress.total,
819
+ response = options._response;
820
+ if (options._progress.loaded < total) {
821
+ // Create a progress event if no final progress event
822
+ // with loaded equaling total has been triggered:
823
+ this._onProgress($.Event('progress', {
824
+ lengthComputable: true,
825
+ loaded: total,
826
+ total: total
827
+ }), options);
828
+ }
829
+ response.result = options.result = result;
830
+ response.textStatus = options.textStatus = textStatus;
831
+ response.jqXHR = options.jqXHR = jqXHR;
832
+ this._trigger('done', null, options);
833
+ },
834
+
835
+ _onFail: function (jqXHR, textStatus, errorThrown, options) {
836
+ var response = options._response;
837
+ if (options.recalculateProgress) {
838
+ // Remove the failed (error or abort) file upload from
839
+ // the global progress calculation:
840
+ this._progress.loaded -= options._progress.loaded;
841
+ this._progress.total -= options._progress.total;
842
+ }
843
+ response.jqXHR = options.jqXHR = jqXHR;
844
+ response.textStatus = options.textStatus = textStatus;
845
+ response.errorThrown = options.errorThrown = errorThrown;
846
+ this._trigger('fail', null, options);
847
+ },
848
+
849
+ _onAlways: function (jqXHRorResult, textStatus, jqXHRorError, options) {
850
+ // jqXHRorResult, textStatus and jqXHRorError are added to the
851
+ // options object via done and fail callbacks
852
+ this._trigger('always', null, options);
853
+ },
854
+
855
+ _onSend: function (e, data) {
856
+ if (!data.submit) {
857
+ this._addConvenienceMethods(e, data);
858
+ }
859
+ var that = this,
860
+ jqXHR,
861
+ aborted,
862
+ slot,
863
+ pipe,
864
+ options = that._getAJAXSettings(data),
865
+ send = function () {
866
+ that._sending += 1;
867
+ // Set timer for bitrate progress calculation:
868
+ options._bitrateTimer = new that._BitrateTimer();
869
+ jqXHR = jqXHR || (
870
+ ((aborted || that._trigger(
871
+ 'send',
872
+ $.Event('send', {delegatedEvent: e}),
873
+ options
874
+ ) === false) &&
875
+ that._getXHRPromise(false, options.context, aborted)) ||
876
+ that._chunkedUpload(options) || $.ajax(options)
877
+ ).done(function (result, textStatus, jqXHR) {
878
+ that._onDone(result, textStatus, jqXHR, options);
879
+ }).fail(function (jqXHR, textStatus, errorThrown) {
880
+ that._onFail(jqXHR, textStatus, errorThrown, options);
881
+ }).always(function (jqXHRorResult, textStatus, jqXHRorError) {
882
+ that._onAlways(
883
+ jqXHRorResult,
884
+ textStatus,
885
+ jqXHRorError,
886
+ options
887
+ );
888
+ that._sending -= 1;
889
+ that._active -= 1;
890
+ if (options.limitConcurrentUploads &&
891
+ options.limitConcurrentUploads > that._sending) {
892
+ // Start the next queued upload,
893
+ // that has not been aborted:
894
+ var nextSlot = that._slots.shift();
895
+ while (nextSlot) {
896
+ if (that._getDeferredState(nextSlot) === 'pending') {
897
+ nextSlot.resolve();
898
+ break;
899
+ }
900
+ nextSlot = that._slots.shift();
901
+ }
902
+ }
903
+ if (that._active === 0) {
904
+ // The stop callback is triggered when all uploads have
905
+ // been completed, equivalent to the global ajaxStop event:
906
+ that._trigger('stop');
907
+ }
908
+ });
909
+ return jqXHR;
910
+ };
911
+ this._beforeSend(e, options);
912
+ if (this.options.sequentialUploads ||
913
+ (this.options.limitConcurrentUploads &&
914
+ this.options.limitConcurrentUploads <= this._sending)) {
915
+ if (this.options.limitConcurrentUploads > 1) {
916
+ slot = $.Deferred();
917
+ this._slots.push(slot);
918
+ pipe = slot.pipe(send);
919
+ } else {
920
+ this._sequence = this._sequence.pipe(send, send);
921
+ pipe = this._sequence;
922
+ }
923
+ // Return the piped Promise object, enhanced with an abort method,
924
+ // which is delegated to the jqXHR object of the current upload,
925
+ // and jqXHR callbacks mapped to the equivalent Promise methods:
926
+ pipe.abort = function () {
927
+ aborted = [undefined, 'abort', 'abort'];
928
+ if (!jqXHR) {
929
+ if (slot) {
930
+ slot.rejectWith(options.context, aborted);
931
+ }
932
+ return send();
933
+ }
934
+ return jqXHR.abort();
935
+ };
936
+ return this._enhancePromise(pipe);
937
+ }
938
+ return send();
939
+ },
940
+
941
+ _onAdd: function (e, data) {
942
+ var that = this,
943
+ result = true,
944
+ options = $.extend({}, this.options, data),
945
+ files = data.files,
946
+ filesLength = files.length,
947
+ limit = options.limitMultiFileUploads,
948
+ limitSize = options.limitMultiFileUploadSize,
949
+ overhead = options.limitMultiFileUploadSizeOverhead,
950
+ batchSize = 0,
951
+ paramName = this._getParamName(options),
952
+ paramNameSet,
953
+ paramNameSlice,
954
+ fileSet,
955
+ i,
956
+ j = 0;
957
+ if (limitSize && (!filesLength || files[0].size === undefined)) {
958
+ limitSize = undefined;
959
+ }
960
+ if (!(options.singleFileUploads || limit || limitSize) ||
961
+ !this._isXHRUpload(options)) {
962
+ fileSet = [files];
963
+ paramNameSet = [paramName];
964
+ } else if (!(options.singleFileUploads || limitSize) && limit) {
965
+ fileSet = [];
966
+ paramNameSet = [];
967
+ for (i = 0; i < filesLength; i += limit) {
968
+ fileSet.push(files.slice(i, i + limit));
969
+ paramNameSlice = paramName.slice(i, i + limit);
970
+ if (!paramNameSlice.length) {
971
+ paramNameSlice = paramName;
972
+ }
973
+ paramNameSet.push(paramNameSlice);
974
+ }
975
+ } else if (!options.singleFileUploads && limitSize) {
976
+ fileSet = [];
977
+ paramNameSet = [];
978
+ for (i = 0; i < filesLength; i = i + 1) {
979
+ batchSize += files[i].size + overhead;
980
+ if (i + 1 === filesLength ||
981
+ (batchSize + files[i + 1].size + overhead) >
982
+ limitSize) {
983
+ fileSet.push(files.slice(j, i + 1));
984
+ paramNameSlice = paramName.slice(j, i + 1);
985
+ if (!paramNameSlice.length) {
986
+ paramNameSlice = paramName;
987
+ }
988
+ paramNameSet.push(paramNameSlice);
989
+ j = i + 1;
990
+ batchSize = 0;
991
+ }
992
+ }
993
+ } else {
994
+ paramNameSet = paramName;
995
+ }
996
+ data.originalFiles = files;
997
+ $.each(fileSet || files, function (index, element) {
998
+ var newData = $.extend({}, data);
999
+ newData.files = fileSet ? element : [element];
1000
+ newData.paramName = paramNameSet[index];
1001
+ that._initResponseObject(newData);
1002
+ that._initProgressObject(newData);
1003
+ that._addConvenienceMethods(e, newData);
1004
+ result = that._trigger(
1005
+ 'add',
1006
+ $.Event('add', {delegatedEvent: e}),
1007
+ newData
1008
+ );
1009
+ return result;
1010
+ });
1011
+ return result;
1012
+ },
1013
+
1014
+ _replaceFileInput: function (input) {
1015
+ var inputClone = input.clone(true);
1016
+ $('<form></form>').append(inputClone)[0].reset();
1017
+ // Detaching allows to insert the fileInput on another form
1018
+ // without loosing the file input value:
1019
+ input.after(inputClone).detach();
1020
+ // Avoid memory leaks with the detached file input:
1021
+ $.cleanData(input.unbind('remove'));
1022
+ // Replace the original file input element in the fileInput
1023
+ // elements set with the clone, which has been copied including
1024
+ // event handlers:
1025
+ this.options.fileInput = this.options.fileInput.map(function (i, el) {
1026
+ if (el === input[0]) {
1027
+ return inputClone[0];
1028
+ }
1029
+ return el;
1030
+ });
1031
+ // If the widget has been initialized on the file input itself,
1032
+ // override this.element with the file input clone:
1033
+ if (input[0] === this.element[0]) {
1034
+ this.element = inputClone;
1035
+ }
1036
+ },
1037
+
1038
+ _handleFileTreeEntry: function (entry, path) {
1039
+ var that = this,
1040
+ dfd = $.Deferred(),
1041
+ errorHandler = function (e) {
1042
+ if (e && !e.entry) {
1043
+ e.entry = entry;
1044
+ }
1045
+ // Since $.when returns immediately if one
1046
+ // Deferred is rejected, we use resolve instead.
1047
+ // This allows valid files and invalid items
1048
+ // to be returned together in one set:
1049
+ dfd.resolve([e]);
1050
+ },
1051
+ dirReader;
1052
+ path = path || '';
1053
+ if (entry.isFile) {
1054
+ if (entry._file) {
1055
+ // Workaround for Chrome bug #149735
1056
+ entry._file.relativePath = path;
1057
+ dfd.resolve(entry._file);
1058
+ } else {
1059
+ entry.file(function (file) {
1060
+ file.relativePath = path;
1061
+ dfd.resolve(file);
1062
+ }, errorHandler);
1063
+ }
1064
+ } else if (entry.isDirectory) {
1065
+ dirReader = entry.createReader();
1066
+ dirReader.readEntries(function (entries) {
1067
+ that._handleFileTreeEntries(
1068
+ entries,
1069
+ path + entry.name + '/'
1070
+ ).done(function (files) {
1071
+ dfd.resolve(files);
1072
+ }).fail(errorHandler);
1073
+ }, errorHandler);
1074
+ } else {
1075
+ // Return an empy list for file system items
1076
+ // other than files or directories:
1077
+ dfd.resolve([]);
1078
+ }
1079
+ return dfd.promise();
1080
+ },
1081
+
1082
+ _handleFileTreeEntries: function (entries, path) {
1083
+ var that = this;
1084
+ return $.when.apply(
1085
+ $,
1086
+ $.map(entries, function (entry) {
1087
+ return that._handleFileTreeEntry(entry, path);
1088
+ })
1089
+ ).pipe(function () {
1090
+ return Array.prototype.concat.apply(
1091
+ [],
1092
+ arguments
1093
+ );
1094
+ });
1095
+ },
1096
+
1097
+ _getDroppedFiles: function (dataTransfer) {
1098
+ dataTransfer = dataTransfer || {};
1099
+ var items = dataTransfer.items;
1100
+ if (items && items.length && (items[0].webkitGetAsEntry ||
1101
+ items[0].getAsEntry)) {
1102
+ return this._handleFileTreeEntries(
1103
+ $.map(items, function (item) {
1104
+ var entry;
1105
+ if (item.webkitGetAsEntry) {
1106
+ entry = item.webkitGetAsEntry();
1107
+ if (entry) {
1108
+ // Workaround for Chrome bug #149735:
1109
+ entry._file = item.getAsFile();
1110
+ }
1111
+ return entry;
1112
+ }
1113
+ return item.getAsEntry();
1114
+ })
1115
+ );
1116
+ }
1117
+ return $.Deferred().resolve(
1118
+ $.makeArray(dataTransfer.files)
1119
+ ).promise();
1120
+ },
1121
+
1122
+ _getSingleFileInputFiles: function (fileInput) {
1123
+ fileInput = $(fileInput);
1124
+ var entries = fileInput.prop('webkitEntries') ||
1125
+ fileInput.prop('entries'),
1126
+ files,
1127
+ value;
1128
+ if (entries && entries.length) {
1129
+ return this._handleFileTreeEntries(entries);
1130
+ }
1131
+ files = $.makeArray(fileInput.prop('files'));
1132
+ if (!files.length) {
1133
+ value = fileInput.prop('value');
1134
+ if (!value) {
1135
+ return $.Deferred().resolve([]).promise();
1136
+ }
1137
+ // If the files property is not available, the browser does not
1138
+ // support the File API and we add a pseudo File object with
1139
+ // the input value as name with path information removed:
1140
+ files = [{name: value.replace(/^.*\\/, '')}];
1141
+ } else if (files[0].name === undefined && files[0].fileName) {
1142
+ // File normalization for Safari 4 and Firefox 3:
1143
+ $.each(files, function (index, file) {
1144
+ file.name = file.fileName;
1145
+ file.size = file.fileSize;
1146
+ });
1147
+ }
1148
+ return $.Deferred().resolve(files).promise();
1149
+ },
1150
+
1151
+ _getFileInputFiles: function (fileInput) {
1152
+ if (!(fileInput instanceof $) || fileInput.length === 1) {
1153
+ return this._getSingleFileInputFiles(fileInput);
1154
+ }
1155
+ return $.when.apply(
1156
+ $,
1157
+ $.map(fileInput, this._getSingleFileInputFiles)
1158
+ ).pipe(function () {
1159
+ return Array.prototype.concat.apply(
1160
+ [],
1161
+ arguments
1162
+ );
1163
+ });
1164
+ },
1165
+
1166
+ _onChange: function (e) {
1167
+ var that = this,
1168
+ data = {
1169
+ fileInput: $(e.target),
1170
+ form: $(e.target.form)
1171
+ };
1172
+ this._getFileInputFiles(data.fileInput).always(function (files) {
1173
+ data.files = files;
1174
+ if (that.options.replaceFileInput) {
1175
+ that._replaceFileInput(data.fileInput);
1176
+ }
1177
+ if (that._trigger(
1178
+ 'change',
1179
+ $.Event('change', {delegatedEvent: e}),
1180
+ data
1181
+ ) !== false) {
1182
+ that._onAdd(e, data);
1183
+ }
1184
+ });
1185
+ },
1186
+
1187
+ _onPaste: function (e) {
1188
+ var items = e.originalEvent && e.originalEvent.clipboardData &&
1189
+ e.originalEvent.clipboardData.items,
1190
+ data = {files: []};
1191
+ if (items && items.length) {
1192
+ $.each(items, function (index, item) {
1193
+ var file = item.getAsFile && item.getAsFile();
1194
+ if (file) {
1195
+ data.files.push(file);
1196
+ }
1197
+ });
1198
+ if (this._trigger(
1199
+ 'paste',
1200
+ $.Event('paste', {delegatedEvent: e}),
1201
+ data
1202
+ ) !== false) {
1203
+ this._onAdd(e, data);
1204
+ }
1205
+ }
1206
+ },
1207
+
1208
+ _onDrop: function (e) {
1209
+ e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer;
1210
+ var that = this,
1211
+ dataTransfer = e.dataTransfer,
1212
+ data = {};
1213
+ if (dataTransfer && dataTransfer.files && dataTransfer.files.length) {
1214
+ e.preventDefault();
1215
+ this._getDroppedFiles(dataTransfer).always(function (files) {
1216
+ data.files = files;
1217
+ if (that._trigger(
1218
+ 'drop',
1219
+ $.Event('drop', {delegatedEvent: e}),
1220
+ data
1221
+ ) !== false) {
1222
+ that._onAdd(e, data);
1223
+ }
1224
+ });
1225
+ }
1226
+ },
1227
+
1228
+ _onDragOver: function (e) {
1229
+ e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer;
1230
+ var dataTransfer = e.dataTransfer;
1231
+ if (dataTransfer && $.inArray('Files', dataTransfer.types) !== -1 &&
1232
+ this._trigger(
1233
+ 'dragover',
1234
+ $.Event('dragover', {delegatedEvent: e})
1235
+ ) !== false) {
1236
+ e.preventDefault();
1237
+ dataTransfer.dropEffect = 'copy';
1238
+ }
1239
+ },
1240
+
1241
+ _initEventHandlers: function () {
1242
+ if (this._isXHRUpload(this.options)) {
1243
+ this._on(this.options.dropZone, {
1244
+ dragover: this._onDragOver,
1245
+ drop: this._onDrop
1246
+ });
1247
+ this._on(this.options.pasteZone, {
1248
+ paste: this._onPaste
1249
+ });
1250
+ }
1251
+ if ($.support.fileInput) {
1252
+ this._on(this.options.fileInput, {
1253
+ change: this._onChange
1254
+ });
1255
+ }
1256
+ },
1257
+
1258
+ _destroyEventHandlers: function () {
1259
+ this._off(this.options.dropZone, 'dragover drop');
1260
+ this._off(this.options.pasteZone, 'paste');
1261
+ this._off(this.options.fileInput, 'change');
1262
+ },
1263
+
1264
+ _setOption: function (key, value) {
1265
+ var reinit = $.inArray(key, this._specialOptions) !== -1;
1266
+ if (reinit) {
1267
+ this._destroyEventHandlers();
1268
+ }
1269
+ this._super(key, value);
1270
+ if (reinit) {
1271
+ this._initSpecialOptions();
1272
+ this._initEventHandlers();
1273
+ }
1274
+ },
1275
+
1276
+ _initSpecialOptions: function () {
1277
+ var options = this.options;
1278
+ if (options.fileInput === undefined) {
1279
+ options.fileInput = this.element.is('input[type="file"]') ?
1280
+ this.element : this.element.find('input[type="file"]');
1281
+ } else if (!(options.fileInput instanceof $)) {
1282
+ options.fileInput = $(options.fileInput);
1283
+ }
1284
+ if (!(options.dropZone instanceof $)) {
1285
+ options.dropZone = $(options.dropZone);
1286
+ }
1287
+ if (!(options.pasteZone instanceof $)) {
1288
+ options.pasteZone = $(options.pasteZone);
1289
+ }
1290
+ },
1291
+
1292
+ _getRegExp: function (str) {
1293
+ var parts = str.split('/'),
1294
+ modifiers = parts.pop();
1295
+ parts.shift();
1296
+ return new RegExp(parts.join('/'), modifiers);
1297
+ },
1298
+
1299
+ _isRegExpOption: function (key, value) {
1300
+ return key !== 'url' && $.type(value) === 'string' &&
1301
+ /^\/.*\/[igm]{0,3}$/.test(value);
1302
+ },
1303
+
1304
+ _initDataAttributes: function () {
1305
+ var that = this,
1306
+ options = this.options;
1307
+ // Initialize options set via HTML5 data-attributes:
1308
+ $.each(
1309
+ $(this.element[0].cloneNode(false)).data(),
1310
+ function (key, value) {
1311
+ if (that._isRegExpOption(key, value)) {
1312
+ value = that._getRegExp(value);
1313
+ }
1314
+ options[key] = value;
1315
+ }
1316
+ );
1317
+ },
1318
+
1319
+ _create: function () {
1320
+ this._initDataAttributes();
1321
+ this._initSpecialOptions();
1322
+ this._slots = [];
1323
+ this._sequence = this._getXHRPromise(true);
1324
+ this._sending = this._active = 0;
1325
+ this._initProgressObject(this);
1326
+ this._initEventHandlers();
1327
+ },
1328
+
1329
+ // This method is exposed to the widget API and allows to query
1330
+ // the number of active uploads:
1331
+ active: function () {
1332
+ return this._active;
1333
+ },
1334
+
1335
+ // This method is exposed to the widget API and allows to query
1336
+ // the widget upload progress.
1337
+ // It returns an object with loaded, total and bitrate properties
1338
+ // for the running uploads:
1339
+ progress: function () {
1340
+ return this._progress;
1341
+ },
1342
+
1343
+ // This method is exposed to the widget API and allows adding files
1344
+ // using the fileupload API. The data parameter accepts an object which
1345
+ // must have a files property and can contain additional options:
1346
+ // .fileupload('add', {files: filesList});
1347
+ add: function (data) {
1348
+ var that = this;
1349
+ if (!data || this.options.disabled) {
1350
+ return;
1351
+ }
1352
+ if (data.fileInput && !data.files) {
1353
+ this._getFileInputFiles(data.fileInput).always(function (files) {
1354
+ data.files = files;
1355
+ that._onAdd(null, data);
1356
+ });
1357
+ } else {
1358
+ data.files = $.makeArray(data.files);
1359
+ this._onAdd(null, data);
1360
+ }
1361
+ },
1362
+
1363
+ // This method is exposed to the widget API and allows sending files
1364
+ // using the fileupload API. The data parameter accepts an object which
1365
+ // must have a files or fileInput property and can contain additional options:
1366
+ // .fileupload('send', {files: filesList});
1367
+ // The method returns a Promise object for the file upload call.
1368
+ send: function (data) {
1369
+ if (data && !this.options.disabled) {
1370
+ if (data.fileInput && !data.files) {
1371
+ var that = this,
1372
+ dfd = $.Deferred(),
1373
+ promise = dfd.promise(),
1374
+ jqXHR,
1375
+ aborted;
1376
+ promise.abort = function () {
1377
+ aborted = true;
1378
+ if (jqXHR) {
1379
+ return jqXHR.abort();
1380
+ }
1381
+ dfd.reject(null, 'abort', 'abort');
1382
+ return promise;
1383
+ };
1384
+ this._getFileInputFiles(data.fileInput).always(
1385
+ function (files) {
1386
+ if (aborted) {
1387
+ return;
1388
+ }
1389
+ if (!files.length) {
1390
+ dfd.reject();
1391
+ return;
1392
+ }
1393
+ data.files = files;
1394
+ jqXHR = that._onSend(null, data).then(
1395
+ function (result, textStatus, jqXHR) {
1396
+ dfd.resolve(result, textStatus, jqXHR);
1397
+ },
1398
+ function (jqXHR, textStatus, errorThrown) {
1399
+ dfd.reject(jqXHR, textStatus, errorThrown);
1400
+ }
1401
+ );
1402
+ }
1403
+ );
1404
+ return this._enhancePromise(promise);
1405
+ }
1406
+ data.files = $.makeArray(data.files);
1407
+ if (data.files.length) {
1408
+ return this._onSend(null, data);
1409
+ }
1410
+ }
1411
+ return this._getXHRPromise(false, data && data.context);
1412
+ }
1413
+
1414
+ });
1415
+
1416
+ }));