alchemy_cms 2.1.12 → 2.2.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (405) hide show
  1. data/.travis.yml +1 -1
  2. data/Gemfile +20 -16
  3. data/README.md +11 -7
  4. data/alchemy_cms.gemspec +31 -29
  5. data/app/assets/javascripts/alchemy/alchemy.base.js +234 -233
  6. data/app/assets/javascripts/alchemy/alchemy.buttons.js +26 -26
  7. data/app/assets/javascripts/alchemy/alchemy.datepicker.js +32 -32
  8. data/app/assets/javascripts/alchemy/alchemy.dirty.js +78 -78
  9. data/app/assets/javascripts/alchemy/alchemy.dragndrop.js +103 -103
  10. data/app/assets/javascripts/alchemy/alchemy.element_editor_selector.js +84 -84
  11. data/app/assets/javascripts/alchemy/alchemy.elements_window.js +88 -88
  12. data/app/assets/javascripts/alchemy/alchemy.file_progress.js +92 -0
  13. data/app/assets/javascripts/alchemy/alchemy.growler.js +23 -23
  14. data/app/assets/javascripts/alchemy/alchemy.html5.js +23 -0
  15. data/app/assets/javascripts/alchemy/alchemy.image_cropper.js +53 -52
  16. data/app/assets/javascripts/alchemy/alchemy.jquery_loader.js +33 -30
  17. data/app/assets/javascripts/alchemy/alchemy.js +2 -0
  18. data/app/assets/javascripts/alchemy/alchemy.js_extensions.js +14 -14
  19. data/app/assets/javascripts/alchemy/alchemy.link_overlay.js.coffee +181 -0
  20. data/app/assets/javascripts/alchemy/alchemy.menubar.js +48 -48
  21. data/app/assets/javascripts/alchemy/alchemy.page_sorter.js +39 -39
  22. data/app/assets/javascripts/alchemy/alchemy.preview.js +81 -83
  23. data/app/assets/javascripts/alchemy/alchemy.preview_window.js +86 -86
  24. data/app/assets/javascripts/alchemy/alchemy.routes.js.erb +23 -23
  25. data/app/assets/javascripts/alchemy/alchemy.swf_upload.js +208 -353
  26. data/app/assets/javascripts/alchemy/alchemy.uploader.js +279 -0
  27. data/app/assets/javascripts/alchemy/alchemy.windows.js +268 -268
  28. data/app/assets/javascripts/tiny_mce/plugins/alchemy_link/editor_plugin.js +42 -42
  29. data/app/assets/stylesheets/alchemy/_defaults.scss +89 -89
  30. data/app/assets/stylesheets/alchemy/base.css.scss +790 -804
  31. data/app/assets/stylesheets/alchemy/buttons.css.scss +263 -264
  32. data/app/assets/stylesheets/alchemy/dashboard.css.scss +66 -66
  33. data/app/assets/stylesheets/alchemy/elements.css.scss +575 -564
  34. data/app/assets/stylesheets/alchemy/flash.css.scss +45 -45
  35. data/app/assets/stylesheets/alchemy/frame.css.scss +262 -262
  36. data/app/assets/stylesheets/alchemy/icons.css.scss +86 -86
  37. data/app/assets/stylesheets/alchemy/jquery-ui.alchemy.css.scss +706 -707
  38. data/app/assets/stylesheets/alchemy/jquery.Jcrop.css.scss +46 -27
  39. data/app/assets/stylesheets/alchemy/jquery.sb.css.scss +107 -107
  40. data/app/assets/stylesheets/alchemy/login.css.scss +40 -38
  41. data/app/assets/stylesheets/alchemy/menubar.css.scss +84 -82
  42. data/app/assets/stylesheets/alchemy/modules.css.scss +9 -9
  43. data/app/assets/stylesheets/alchemy/pagination.css.scss +49 -49
  44. data/app/assets/stylesheets/alchemy/print.css +7 -7
  45. data/app/assets/stylesheets/alchemy/sitemap.css.scss +185 -154
  46. data/app/assets/stylesheets/alchemy/standard_set.css +205 -206
  47. data/app/assets/stylesheets/alchemy/tables.css.scss +94 -60
  48. data/app/assets/stylesheets/alchemy/tinymce_content.css.scss +34 -34
  49. data/app/assets/stylesheets/alchemy/tinymce_dialog.css.scss +177 -177
  50. data/app/assets/stylesheets/alchemy/upload.css.scss +68 -45
  51. data/app/assets/stylesheets/tiny_mce/plugins/inlinepopups/skins/alchemy/window.css.scss +222 -221
  52. data/app/controllers/alchemy/admin/attachments_controller.rb +100 -100
  53. data/app/controllers/alchemy/admin/base_controller.rb +116 -116
  54. data/app/controllers/alchemy/admin/clipboard_controller.rb +44 -44
  55. data/app/controllers/alchemy/admin/contents_controller.rb +55 -55
  56. data/app/controllers/alchemy/admin/dashboard_controller.rb +12 -11
  57. data/app/controllers/alchemy/admin/elements_controller.rb +109 -109
  58. data/app/controllers/alchemy/admin/essence_audios_controller.rb +8 -8
  59. data/app/controllers/alchemy/admin/essence_files_controller.rb +20 -20
  60. data/app/controllers/alchemy/admin/essence_flashes_controller.rb +8 -8
  61. data/app/controllers/alchemy/admin/essence_pictures_controller.rb +81 -81
  62. data/app/controllers/alchemy/admin/essence_videos_controller.rb +8 -8
  63. data/app/controllers/alchemy/admin/languages_controller.rb +16 -4
  64. data/app/controllers/alchemy/admin/layoutpages_controller.rb +9 -9
  65. data/app/controllers/alchemy/admin/pages_controller.rb +249 -248
  66. data/app/controllers/alchemy/admin/pictures_controller.rb +105 -105
  67. data/app/controllers/alchemy/admin/resources_controller.rb +111 -166
  68. data/app/controllers/alchemy/admin/trash_controller.rb +18 -18
  69. data/app/controllers/alchemy/admin/users_controller.rb +69 -69
  70. data/app/controllers/alchemy/attachments_controller.rb +27 -27
  71. data/app/controllers/alchemy/base_controller.rb +159 -155
  72. data/app/controllers/alchemy/elements_controller.rb +16 -16
  73. data/app/controllers/alchemy/messages_controller.rb +59 -59
  74. data/app/controllers/alchemy/pages_controller.rb +194 -198
  75. data/app/controllers/alchemy/pictures_controller.rb +57 -57
  76. data/app/controllers/alchemy/user_sessions_controller.rb +70 -70
  77. data/app/helpers/alchemy/admin/attachments_helper.rb +7 -7
  78. data/app/helpers/alchemy/admin/base_helper.rb +425 -425
  79. data/app/helpers/alchemy/admin/contents_helper.rb +72 -72
  80. data/app/helpers/alchemy/admin/elements_helper.rb +108 -107
  81. data/app/helpers/alchemy/admin/essences_helper.rb +108 -108
  82. data/app/helpers/alchemy/admin/pages_helper.rb +42 -42
  83. data/app/helpers/alchemy/admin/pictures_helper.rb +26 -26
  84. data/app/helpers/alchemy/base_helper.rb +90 -90
  85. data/app/helpers/alchemy/elements_helper.rb +167 -168
  86. data/app/helpers/alchemy/essences_helper.rb +133 -133
  87. data/app/helpers/alchemy/pages_helper.rb +515 -526
  88. data/app/helpers/alchemy/pictures_helper.rb +19 -0
  89. data/app/mailers/alchemy/messages.rb +13 -13
  90. data/app/mailers/alchemy/notifications.rb +19 -19
  91. data/app/models/alchemy.rb +3 -3
  92. data/app/models/alchemy/attachment.rb +52 -78
  93. data/app/models/alchemy/cell.rb +48 -48
  94. data/app/models/alchemy/content.rb +196 -196
  95. data/app/models/alchemy/element.rb +500 -490
  96. data/app/models/alchemy/essence_audio.rb +7 -7
  97. data/app/models/alchemy/essence_date.rb +10 -10
  98. data/app/models/alchemy/essence_file.rb +7 -7
  99. data/app/models/alchemy/essence_flash.rb +6 -6
  100. data/app/models/alchemy/essence_html.rb +9 -9
  101. data/app/models/alchemy/essence_picture.rb +17 -17
  102. data/app/models/alchemy/essence_richtext.rb +53 -53
  103. data/app/models/alchemy/essence_text.rb +21 -21
  104. data/app/models/alchemy/essence_video.rb +7 -7
  105. data/app/models/alchemy/folded_page.rb +3 -3
  106. data/app/models/alchemy/language.rb +91 -91
  107. data/app/models/alchemy/language/code.rb +14 -14
  108. data/app/models/alchemy/message.rb +48 -45
  109. data/app/models/alchemy/page.rb +555 -558
  110. data/app/models/alchemy/picture.rb +100 -99
  111. data/app/models/alchemy/user.rb +76 -74
  112. data/app/models/alchemy/user_session.rb +8 -8
  113. data/app/sweepers/alchemy/content_sweeper.rb +15 -15
  114. data/app/sweepers/alchemy/pages_sweeper.rb +50 -50
  115. data/app/sweepers/alchemy/pictures_sweeper.rb +14 -14
  116. data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +23 -23
  117. data/app/views/alchemy/admin/attachments/_attachment.html.erb +56 -56
  118. data/app/views/alchemy/admin/attachments/_file_to_assign.html.erb +15 -15
  119. data/app/views/alchemy/admin/attachments/_files_list.html.erb +16 -16
  120. data/app/views/alchemy/admin/attachments/create.js.erb +2 -2
  121. data/app/views/alchemy/admin/attachments/destroy.js.erb +3 -3
  122. data/app/views/alchemy/admin/attachments/edit.html.erb +10 -10
  123. data/app/views/alchemy/admin/attachments/index.html.erb +14 -14
  124. data/app/views/alchemy/admin/attachments/new.html.erb +9 -9
  125. data/app/views/alchemy/admin/clipboard/index.html.erb +21 -21
  126. data/app/views/alchemy/admin/clipboard/insert.js.erb +5 -5
  127. data/app/views/alchemy/admin/contents/_missing.html.erb +1 -1
  128. data/app/views/alchemy/admin/contents/create.js.erb +33 -33
  129. data/app/views/alchemy/admin/contents/destroy.js.erb +5 -5
  130. data/app/views/alchemy/admin/contents/new.html.erb +13 -13
  131. data/app/views/alchemy/admin/contents/order.js.erb +2 -2
  132. data/app/views/alchemy/admin/dashboard/index.html.erb +96 -92
  133. data/app/views/alchemy/admin/elements/_add_content.html.erb +12 -12
  134. data/app/views/alchemy/admin/elements/_element.html.erb +3 -3
  135. data/app/views/alchemy/admin/elements/_new_element_form.html.erb +28 -28
  136. data/app/views/alchemy/admin/elements/_picture_editor.html.erb +21 -21
  137. data/app/views/alchemy/admin/elements/create.js.erb +32 -32
  138. data/app/views/alchemy/admin/elements/index.html.erb +2 -2
  139. data/app/views/alchemy/admin/elements/new.html.erb +31 -31
  140. data/app/views/alchemy/admin/elements/order.js.erb +3 -3
  141. data/app/views/alchemy/admin/elements/trash.js.erb +13 -13
  142. data/app/views/alchemy/admin/elements/update.js.erb +6 -6
  143. data/app/views/alchemy/admin/essence_files/assign.js.erb +6 -6
  144. data/app/views/alchemy/admin/essence_pictures/crop.html.erb +32 -32
  145. data/app/views/alchemy/admin/essence_pictures/destroy.js.erb +1 -1
  146. data/app/views/alchemy/admin/essence_pictures/edit.html.erb +1 -1
  147. data/app/views/alchemy/admin/essence_pictures/update.js.erb +11 -11
  148. data/app/views/alchemy/admin/languages/_form.html.erb +51 -45
  149. data/app/views/alchemy/admin/languages/_language.html.erb +45 -45
  150. data/app/views/alchemy/admin/languages/_table.html.erb +25 -25
  151. data/app/views/alchemy/admin/layoutpages/index.html.erb +35 -35
  152. data/app/views/alchemy/admin/pages/_create_language_form.html.erb +42 -42
  153. data/app/views/alchemy/admin/pages/_external_link.html.erb +1 -1
  154. data/app/views/alchemy/admin/pages/_new_page_form.html.erb +27 -27
  155. data/app/views/alchemy/admin/pages/_page.html.erb +112 -112
  156. data/app/views/alchemy/admin/pages/_sitemap.html.erb +1 -1
  157. data/app/views/alchemy/admin/pages/configure.html.erb +71 -69
  158. data/app/views/alchemy/admin/pages/configure_external.html.erb +38 -38
  159. data/app/views/alchemy/admin/pages/destroy.js.erb +10 -10
  160. data/app/views/alchemy/admin/pages/edit.html.erb +165 -165
  161. data/app/views/alchemy/admin/pages/fold.js.erb +2 -2
  162. data/app/views/alchemy/admin/pages/index.html.erb +66 -66
  163. data/app/views/alchemy/admin/pages/locked.html.erb +1 -1
  164. data/app/views/alchemy/admin/pages/new.html.erb +40 -40
  165. data/app/views/alchemy/admin/pages/sort.js.erb +4 -4
  166. data/app/views/alchemy/admin/pages/unlock.js.erb +6 -6
  167. data/app/views/alchemy/admin/pages/update.js.erb +19 -19
  168. data/app/views/alchemy/admin/partials/_flash.html.erb +2 -2
  169. data/app/views/alchemy/admin/partials/_flash_notices.html.erb +1 -1
  170. data/app/views/alchemy/admin/partials/_flash_upload.html.erb +38 -0
  171. data/app/views/alchemy/admin/partials/_language_tree_select.html.erb +15 -15
  172. data/app/views/alchemy/admin/partials/_main_navigation_entry.html.erb +8 -8
  173. data/app/views/alchemy/admin/partials/_remote_search_form.html.erb +35 -35
  174. data/app/views/alchemy/admin/partials/_search_form.html.erb +14 -14
  175. data/app/views/alchemy/admin/partials/_sub_navigation_tab.html.erb +6 -6
  176. data/app/views/alchemy/admin/partials/_upload_form.html.erb +56 -118
  177. data/app/views/alchemy/admin/pictures/_archive_overlay.html.erb +11 -11
  178. data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +71 -71
  179. data/app/views/alchemy/admin/pictures/_picture.html.erb +32 -32
  180. data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +26 -26
  181. data/app/views/alchemy/admin/pictures/_pictures_list.html.erb +6 -6
  182. data/app/views/alchemy/admin/pictures/create.js.erb +7 -7
  183. data/app/views/alchemy/admin/pictures/index.html.erb +67 -67
  184. data/app/views/alchemy/admin/pictures/show_in_window.html.erb +5 -4
  185. data/app/views/alchemy/admin/resources/_form.html.erb +25 -19
  186. data/app/views/alchemy/admin/resources/_resource.html.erb +37 -36
  187. data/app/views/alchemy/admin/resources/_table.html.erb +17 -17
  188. data/app/views/alchemy/admin/resources/destroy.js.erb +1 -1
  189. data/app/views/alchemy/admin/resources/index.html.erb +14 -14
  190. data/app/views/alchemy/admin/trash/index.html.erb +20 -20
  191. data/app/views/alchemy/admin/users/_table.html.erb +52 -52
  192. data/app/views/alchemy/admin/users/_user.html.erb +35 -36
  193. data/app/views/alchemy/admin/users/index.html.erb +26 -27
  194. data/app/views/alchemy/base/error_notice.html.erb +2 -2
  195. data/app/views/alchemy/base/update.js.erb +1 -1
  196. data/app/views/alchemy/elements/_contactform_view.html.erb +76 -76
  197. data/app/views/alchemy/elements/_download_view.html.erb +1 -1
  198. data/app/views/alchemy/elements/_editor_not_found.html.erb +3 -3
  199. data/app/views/alchemy/elements/_searchresult_view.html.erb +2 -2
  200. data/app/views/alchemy/elements/_sitemap_editor.html.erb +1 -1
  201. data/app/views/alchemy/essences/_essence_audio_view.html.erb +13 -13
  202. data/app/views/alchemy/essences/_essence_date_editor.html.erb +10 -10
  203. data/app/views/alchemy/essences/_essence_file_editor.html.erb +62 -62
  204. data/app/views/alchemy/essences/_essence_file_view.html.erb +8 -8
  205. data/app/views/alchemy/essences/_essence_flash_view.html.erb +19 -19
  206. data/app/views/alchemy/essences/_essence_html_editor.html.erb +6 -6
  207. data/app/views/alchemy/essences/_essence_picture_editor.html.erb +73 -73
  208. data/app/views/alchemy/essences/_essence_picture_view.html.erb +34 -34
  209. data/app/views/alchemy/essences/_essence_richtext_editor.html.erb +7 -7
  210. data/app/views/alchemy/essences/_essence_text_editor.html.erb +8 -8
  211. data/app/views/alchemy/navigation/_image_link.html.erb +12 -12
  212. data/app/views/alchemy/navigation/_link.html.erb +13 -13
  213. data/app/views/alchemy/navigation/_renderer.html.erb +17 -17
  214. data/app/views/alchemy/page_layouts/_layout_footer.html.erb +1 -1
  215. data/app/views/alchemy/page_layouts/_layout_header.html.erb +1 -1
  216. data/app/views/alchemy/pages/show.rss.builder +14 -14
  217. data/app/views/alchemy/search/_result.html.erb +7 -7
  218. data/app/views/alchemy/user_sessions/leave.html.erb +9 -9
  219. data/app/views/alchemy/user_sessions/login.html.erb +39 -39
  220. data/app/views/alchemy/user_sessions/logout.html.erb +1 -1
  221. data/app/views/layouts/alchemy/admin.html.erb +81 -81
  222. data/app/views/layouts/alchemy/login.html.erb +36 -36
  223. data/app/views/layouts/alchemy/pages.html.erb +48 -27
  224. data/bin/alchemy +136 -134
  225. data/config/alchemy/config.yml +13 -9
  226. data/config/locales/alchemy.de.yml +24 -30
  227. data/config/locales/alchemy.en.yml +11 -28
  228. data/config/routes.rb +146 -146
  229. data/db/migrate/20100607193638_create_essence_pictures.rb +3 -3
  230. data/db/migrate/20101109150312_alter_pages_visible_column_default.rb +1 -1
  231. data/db/migrate/20101109151812_create_languages.rb +3 -3
  232. data/db/migrate/20110115123343_remove_css_class_default_from_essence_pictures.rb +3 -3
  233. data/db/migrate/20110224105120_change_pages_visible_default.rb +3 -3
  234. data/db/migrate/20110228182659_remove_default_page_layout_from_pages.rb +2 -2
  235. data/db/migrate/20110414163140_remove_display_name_from_elements.rb +3 -3
  236. data/db/migrate/20110511100516_rename_essence_texts_title_to_link_title.rb +2 -2
  237. data/db/migrate/20110529130500_add_cell_id_to_elements.rb +3 -3
  238. data/db/migrate/20110530102804_change_pages_page_layout_column.rb +3 -3
  239. data/db/migrate/20110711142057_change_open_link_in_new_window_to_link_target.rb +1 -1
  240. data/db/migrate/20111116125112_namespace_alchemy_models.rb +21 -21
  241. data/lib/alchemy/auth_engine.rb +5 -5
  242. data/lib/alchemy/capistrano.rb +64 -64
  243. data/lib/alchemy/config.rb +47 -44
  244. data/lib/alchemy/engine.rb +41 -41
  245. data/lib/alchemy/essence.rb +50 -51
  246. data/lib/alchemy/i18n.rb +48 -48
  247. data/lib/alchemy/modules.rb +30 -30
  248. data/lib/alchemy/mount_point.rb +6 -6
  249. data/lib/alchemy/page_layout.rb +94 -93
  250. data/lib/alchemy/resource.rb +82 -0
  251. data/lib/alchemy/resources_helper.rb +56 -0
  252. data/lib/alchemy/scoped_pagination_url_helper.rb +8 -8
  253. data/lib/alchemy/seeder.rb +88 -88
  254. data/lib/alchemy/tinymce.rb +49 -49
  255. data/lib/alchemy/upgrader.rb +103 -103
  256. data/lib/alchemy/version.rb +1 -1
  257. data/lib/alchemy_cms.rb +26 -27
  258. data/lib/extensions/action_view.rb +1 -1
  259. data/lib/extensions/array.rb +3 -3
  260. data/lib/extensions/hash.rb +3 -3
  261. data/lib/middleware/flash_session_cookie.rb +1 -1
  262. data/lib/rails/generators/alchemy/deploy_script/deploy_script_generator.rb +24 -24
  263. data/lib/rails/generators/alchemy/elements/elements_generator.rb +7 -7
  264. data/lib/rails/generators/alchemy/elements/templates/view.html.erb +17 -17
  265. data/lib/rails/generators/alchemy/page_layouts/page_layouts_generator.rb +6 -6
  266. data/lib/rails/generators/alchemy/plugin/templates/authorization_rules.rb +8 -8
  267. data/lib/rails/generators/alchemy/scaffold/files/pages.html.erb +7 -7
  268. data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +36 -36
  269. data/lib/rails/templates/alchemy.rb +1 -1
  270. data/lib/tasks/ferret.rake +2 -2
  271. data/lib/tasks/fleximage.rake +32 -32
  272. data/lib/tasks/install.rake +12 -12
  273. data/lib/tasks/upgrade.rake +4 -4
  274. data/spec/controllers/admin/clipboard_controller_spec.rb +43 -43
  275. data/spec/controllers/admin/contents_controller_spec.rb +22 -22
  276. data/spec/controllers/admin/elements_controller_spec.rb +13 -13
  277. data/spec/controllers/admin/languages_controller_spec.rb +31 -0
  278. data/spec/controllers/admin/pages_controller_spec.rb +10 -41
  279. data/spec/controllers/admin/resources_controller_spec.rb +19 -0
  280. data/spec/controllers/admin/trash_controller_spec.rb +11 -11
  281. data/spec/controllers/base_controller_spec.rb +46 -46
  282. data/spec/controllers/pages_controller_spec.rb +102 -92
  283. data/spec/dummy/app/controllers/admin/events_controller.rb +3 -0
  284. data/spec/dummy/app/controllers/errors_controller.rb +5 -0
  285. data/spec/dummy/app/models/event.rb +3 -0
  286. data/spec/dummy/config.ru +1 -1
  287. data/spec/dummy/config/application.rb +3 -0
  288. data/spec/dummy/config/authorization_rules.rb +7 -0
  289. data/spec/dummy/config/environments/development.rb +8 -1
  290. data/spec/dummy/config/environments/production.rb +1 -1
  291. data/spec/dummy/config/environments/test.rb +5 -2
  292. data/spec/dummy/config/routes.rb +9 -1
  293. data/spec/dummy/db/schema.rb +47 -35
  294. data/spec/dummy/public/404.html +19 -7
  295. data/spec/dummy/public/404.html.bak +26 -0
  296. data/spec/dummy/public/422.html +19 -7
  297. data/spec/dummy/public/500.html +19 -7
  298. data/spec/dummy/script/rails +2 -2
  299. data/spec/factories.rb +76 -76
  300. data/spec/helpers/admin/base_helper_spec.rb +21 -21
  301. data/spec/helpers/admin/contents_helper_spec.rb +14 -14
  302. data/spec/helpers/admin/elements_helper_spec.rb +40 -40
  303. data/spec/helpers/admin/essences_helper_spec.rb +7 -7
  304. data/spec/helpers/elements_helper_spec.rb +154 -154
  305. data/spec/helpers/essences_helper_spec.rb +10 -10
  306. data/spec/helpers/pages_helper_spec.rb +369 -372
  307. data/spec/helpers/pictures_helper_spec.rb +14 -0
  308. data/spec/helpers/url_helpers_spec.rb +29 -34
  309. data/spec/integration/admin/pages_controller_spec.rb +50 -50
  310. data/spec/integration/admin/resources_integration_spec.rb +100 -0
  311. data/spec/integration/navigation_spec.rb +1 -1
  312. data/spec/integration/pages_controller_spec.rb +205 -207
  313. data/spec/integration/security_spec.rb +47 -47
  314. data/spec/javascripts/alchemy/link_overlay_spec.js.coffee +42 -0
  315. data/spec/javascripts/alchemy_integration_spec.coffee +12 -0
  316. data/spec/javascripts/fixtures/select.html +3 -0
  317. data/spec/javascripts/helpers/.gitkeep +0 -0
  318. data/spec/javascripts/helpers/jasmine-jquery-1.3.1.js +289 -0
  319. data/spec/javascripts/helpers/mock-ajax.js +207 -0
  320. data/spec/javascripts/helpers/test_responses/test_responses.js +1 -0
  321. data/spec/javascripts/spec.css +3 -0
  322. data/spec/javascripts/spec.js +2 -0
  323. data/spec/libraries/resource_spec.rb +122 -0
  324. data/spec/libraries/resources_helper_spec.rb +105 -0
  325. data/spec/models/content_spec.rb +67 -67
  326. data/spec/models/element_spec.rb +133 -133
  327. data/spec/models/essence_picture_spec.rb +5 -5
  328. data/spec/models/essence_richtext_spec.rb +4 -4
  329. data/spec/models/language_spec.rb +89 -89
  330. data/spec/models/page_spec.rb +436 -506
  331. data/spec/models/picture_spec.rb +34 -34
  332. data/spec/models/user_spec.rb +2 -2
  333. data/spec/page_layout_spec.rb +24 -20
  334. data/spec/routing_spec.rb +253 -253
  335. data/spec/spec_helper.rb +51 -50
  336. data/spec/support/alchemy/controller_hacks.rb +25 -25
  337. data/spec/support/alchemy/specs_helpers.rb +25 -25
  338. data/spec/support/integration_spec_helper.rb +24 -0
  339. data/vendor/assets/javascripts/jquery_plugins/jquery.html5uploader.js +271 -0
  340. data/vendor/assets/javascripts/jquery_plugins/jquery.in-place-edit.js +86 -85
  341. data/vendor/assets/javascripts/jquery_plugins/jquery.ui.nestedSortable.js +380 -377
  342. data/vendor/assets/javascripts/jquery_plugins/jquery.ui.tabspaging.js +285 -279
  343. data/vendor/assets/javascripts/swfupload/SWFObject License.txt +3 -3
  344. data/vendor/assets/javascripts/swfupload/swfupload.cookies.js +47 -47
  345. data/vendor/assets/javascripts/swfupload/swfupload.js +612 -612
  346. data/vendor/assets/javascripts/swfupload/swfupload.queue.js +93 -93
  347. data/vendor/assets/javascripts/swfupload/swfupload.speed.js +337 -337
  348. data/vendor/assets/javascripts/swfupload/swfupload.swfobject.js +706 -102
  349. data/vendor/assets/javascripts/tiny_mce/license.txt +6 -6
  350. data/vendor/assets/javascripts/tiny_mce/plugins/fullscreen/fullscreen.htm +97 -97
  351. data/vendor/assets/javascripts/tiny_mce/plugins/inlinepopups/template.htm +386 -376
  352. data/vendor/assets/javascripts/tiny_mce/plugins/paste/js/pastetext.js +30 -30
  353. data/vendor/assets/javascripts/tiny_mce/plugins/paste/js/pasteword.js +45 -45
  354. data/vendor/assets/javascripts/tiny_mce/plugins/paste/pastetext.htm +20 -17
  355. data/vendor/assets/javascripts/tiny_mce/plugins/paste/pasteword.htm +12 -12
  356. data/vendor/assets/javascripts/tiny_mce/plugins/table/cell.htm +183 -173
  357. data/vendor/assets/javascripts/tiny_mce/plugins/table/css/cell.css +4 -4
  358. data/vendor/assets/javascripts/tiny_mce/plugins/table/css/row.css +7 -7
  359. data/vendor/assets/javascripts/tiny_mce/plugins/table/css/table.css +3 -3
  360. data/vendor/assets/javascripts/tiny_mce/plugins/table/js/cell.js +282 -280
  361. data/vendor/assets/javascripts/tiny_mce/plugins/table/js/merge_cells.js +15 -15
  362. data/vendor/assets/javascripts/tiny_mce/plugins/table/js/row.js +204 -204
  363. data/vendor/assets/javascripts/tiny_mce/plugins/table/js/table.js +435 -435
  364. data/vendor/assets/javascripts/tiny_mce/plugins/table/merge_cells.htm +24 -22
  365. data/vendor/assets/javascripts/tiny_mce/plugins/table/row.htm +144 -136
  366. data/vendor/assets/javascripts/tiny_mce/plugins/table/table.htm +184 -168
  367. data/vendor/assets/javascripts/tiny_mce/themes/advanced/about.htm +62 -46
  368. data/vendor/assets/javascripts/tiny_mce/themes/advanced/anchor.htm +17 -16
  369. data/vendor/assets/javascripts/tiny_mce/themes/advanced/charmap.htm +56 -47
  370. data/vendor/assets/javascripts/tiny_mce/themes/advanced/color_picker.htm +67 -54
  371. data/vendor/assets/javascripts/tiny_mce/themes/advanced/editor_template.js +852 -1
  372. data/vendor/assets/javascripts/tiny_mce/themes/advanced/image.htm +79 -69
  373. data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/about.js +48 -48
  374. data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/anchor.js +28 -28
  375. data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/charmap.js +317 -317
  376. data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/color_picker.js +248 -246
  377. data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/image.js +246 -246
  378. data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/link.js +146 -146
  379. data/vendor/assets/javascripts/tiny_mce/themes/advanced/js/source_editor.js +31 -31
  380. data/vendor/assets/javascripts/tiny_mce/themes/advanced/langs/de.js +1 -1
  381. data/vendor/assets/javascripts/tiny_mce/themes/advanced/langs/de_dlg.js +1 -1
  382. data/vendor/assets/javascripts/tiny_mce/themes/advanced/langs/en.js +1 -1
  383. data/vendor/assets/javascripts/tiny_mce/themes/advanced/langs/en_dlg.js +1 -1
  384. data/vendor/assets/javascripts/tiny_mce/themes/advanced/link.htm +53 -46
  385. data/vendor/assets/javascripts/tiny_mce/themes/advanced/shortcuts.htm +57 -45
  386. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/default/content.css +182 -47
  387. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/default/dialog.css +399 -92
  388. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/default/ui.css +891 -187
  389. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/highcontrast/content.css +102 -24
  390. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/highcontrast/dialog.css +377 -78
  391. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/highcontrast/ui.css +452 -77
  392. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/content.css +167 -45
  393. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/dialog.css +399 -92
  394. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/ui.css +890 -190
  395. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/ui_black.css +33 -7
  396. data/vendor/assets/javascripts/tiny_mce/themes/advanced/skins/o2k7/ui_silver.css +15 -4
  397. data/vendor/assets/javascripts/tiny_mce/themes/advanced/source_editor.htm +18 -15
  398. data/vendor/assets/javascripts/tiny_mce/utils/editable_selects.js +46 -46
  399. data/vendor/assets/javascripts/tiny_mce/utils/form_utils.js +124 -124
  400. data/vendor/assets/javascripts/tiny_mce/utils/mctabs.js +112 -112
  401. data/vendor/assets/javascripts/tiny_mce/utils/validate.js +213 -213
  402. metadata +102 -115
  403. data/app/assets/javascripts/alchemy/alchemy.link_overlay.js +0 -216
  404. data/lib/tasks/routes.rake +0 -29
  405. data/spec/integration/admin/resources_spec.rb +0 -19
@@ -1,4 +1,4 @@
1
- /* SWFObject v2.0 rc4 <http://code.google.com/p/swfobject/>
2
- Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis
3
- This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
1
+ /* SWFObject v2.0 rc4 <http://code.google.com/p/swfobject/>
2
+ Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis
3
+ This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
4
4
  */
@@ -1,53 +1,53 @@
1
1
  /*
2
- Cookie Plug-in
3
-
4
- This plug in automatically gets all the cookies for this site and adds them to the post_params.
5
- Cookies are loaded only on initialization. The refreshCookies function can be called to update the post_params.
6
- The cookies will override any other post params with the same name.
7
- */
2
+ Cookie Plug-in
3
+
4
+ This plug in automatically gets all the cookies for this site and adds them to the post_params.
5
+ Cookies are loaded only on initialization. The refreshCookies function can be called to update the post_params.
6
+ The cookies will override any other post params with the same name.
7
+ */
8
8
 
9
9
  var SWFUpload;
10
10
  if (typeof(SWFUpload) === "function") {
11
- SWFUpload.prototype.initSettings = function (oldInitSettings) {
12
- return function () {
13
- if (typeof(oldInitSettings) === "function") {
14
- oldInitSettings.call(this);
15
- }
16
-
17
- this.refreshCookies(false); // The false parameter must be sent since SWFUpload has not initialzed at this point
18
- };
19
- }(SWFUpload.prototype.initSettings);
20
-
21
- // refreshes the post_params and updates SWFUpload. The sendToFlash parameters is optional and defaults to True
22
- SWFUpload.prototype.refreshCookies = function (sendToFlash) {
23
- if (sendToFlash === undefined) {
24
- sendToFlash = true;
25
- }
26
- sendToFlash = !!sendToFlash;
27
-
28
- // Get the post_params object
29
- var postParams = this.settings.post_params;
30
-
31
- // Get the cookies
32
- var i, cookieArray = document.cookie.split(';'), caLength = cookieArray.length, c, eqIndex, name, value;
33
- for (i = 0; i < caLength; i++) {
34
- c = cookieArray[i];
35
-
36
- // Left Trim spaces
37
- while (c.charAt(0) === " ") {
38
- c = c.substring(1, c.length);
39
- }
40
- eqIndex = c.indexOf("=");
41
- if (eqIndex > 0) {
42
- name = c.substring(0, eqIndex);
43
- value = c.substring(eqIndex + 1);
44
- postParams[name] = value;
45
- }
46
- }
47
-
48
- if (sendToFlash) {
49
- this.setPostParams(postParams);
50
- }
51
- };
11
+ SWFUpload.prototype.initSettings = function (oldInitSettings) {
12
+ return function () {
13
+ if (typeof(oldInitSettings) === "function") {
14
+ oldInitSettings.call(this);
15
+ }
16
+
17
+ this.refreshCookies(false); // The false parameter must be sent since SWFUpload has not initialzed at this point
18
+ };
19
+ }(SWFUpload.prototype.initSettings);
20
+
21
+ // refreshes the post_params and updates SWFUpload. The sendToFlash parameters is optional and defaults to True
22
+ SWFUpload.prototype.refreshCookies = function (sendToFlash) {
23
+ if (sendToFlash === undefined) {
24
+ sendToFlash = true;
25
+ }
26
+ sendToFlash = !!sendToFlash;
27
+
28
+ // Get the post_params object
29
+ var postParams = this.settings.post_params;
30
+
31
+ // Get the cookies
32
+ var i, cookieArray = document.cookie.split(';'), caLength = cookieArray.length, c, eqIndex, name, value;
33
+ for (i = 0; i < caLength; i++) {
34
+ c = cookieArray[i];
35
+
36
+ // Left Trim spaces
37
+ while (c.charAt(0) === " ") {
38
+ c = c.substring(1, c.length);
39
+ }
40
+ eqIndex = c.indexOf("=");
41
+ if (eqIndex > 0) {
42
+ name = c.substring(0, eqIndex);
43
+ value = c.substring(eqIndex + 1);
44
+ postParams[name] = value;
45
+ }
46
+ }
47
+
48
+ if (sendToFlash) {
49
+ this.setPostParams(postParams);
50
+ }
51
+ };
52
52
 
53
53
  }
@@ -18,31 +18,31 @@
18
18
  var SWFUpload;
19
19
 
20
20
  if (SWFUpload == undefined) {
21
- SWFUpload = function (settings) {
22
- this.initSWFUpload(settings);
23
- };
21
+ SWFUpload = function (settings) {
22
+ this.initSWFUpload(settings);
23
+ };
24
24
  }
25
25
 
26
26
  SWFUpload.prototype.initSWFUpload = function (settings) {
27
- try {
28
- this.customSettings = {}; // A container where developers can place their own settings associated with this instance.
29
- this.settings = settings;
30
- this.eventQueue = [];
31
- this.movieName = "SWFUpload_" + SWFUpload.movieCount++;
32
- this.movieElement = null;
27
+ try {
28
+ this.customSettings = {}; // A container where developers can place their own settings associated with this instance.
29
+ this.settings = settings;
30
+ this.eventQueue = [];
31
+ this.movieName = "SWFUpload_" + SWFUpload.movieCount++;
32
+ this.movieElement = null;
33
33
 
34
34
 
35
- // Setup global control tracking
36
- SWFUpload.instances[this.movieName] = this;
35
+ // Setup global control tracking
36
+ SWFUpload.instances[this.movieName] = this;
37
37
 
38
- // Load the settings. Load the Flash movie.
39
- this.initSettings();
40
- this.loadFlash();
41
- this.displayDebugInfo();
42
- } catch (ex) {
43
- delete SWFUpload.instances[this.movieName];
44
- throw ex;
45
- }
38
+ // Load the settings. Load the Flash movie.
39
+ this.initSettings();
40
+ this.loadFlash();
41
+ this.displayDebugInfo();
42
+ } catch (ex) {
43
+ delete SWFUpload.instances[this.movieName];
44
+ throw ex;
45
+ }
46
46
  };
47
47
 
48
48
  /* *************** */
@@ -52,63 +52,63 @@ SWFUpload.instances = {};
52
52
  SWFUpload.movieCount = 0;
53
53
  SWFUpload.version = "2.2.0 2009-03-25";
54
54
  SWFUpload.QUEUE_ERROR = {
55
- QUEUE_LIMIT_EXCEEDED : -100,
56
- FILE_EXCEEDS_SIZE_LIMIT : -110,
57
- ZERO_BYTE_FILE : -120,
58
- INVALID_FILETYPE : -130
55
+ QUEUE_LIMIT_EXCEEDED:-100,
56
+ FILE_EXCEEDS_SIZE_LIMIT:-110,
57
+ ZERO_BYTE_FILE:-120,
58
+ INVALID_FILETYPE:-130
59
59
  };
60
60
  SWFUpload.UPLOAD_ERROR = {
61
- HTTP_ERROR : -200,
62
- MISSING_UPLOAD_URL : -210,
63
- IO_ERROR : -220,
64
- SECURITY_ERROR : -230,
65
- UPLOAD_LIMIT_EXCEEDED : -240,
66
- UPLOAD_FAILED : -250,
67
- SPECIFIED_FILE_ID_NOT_FOUND : -260,
68
- FILE_VALIDATION_FAILED : -270,
69
- FILE_CANCELLED : -280,
70
- UPLOAD_STOPPED : -290
61
+ HTTP_ERROR:-200,
62
+ MISSING_UPLOAD_URL:-210,
63
+ IO_ERROR:-220,
64
+ SECURITY_ERROR:-230,
65
+ UPLOAD_LIMIT_EXCEEDED:-240,
66
+ UPLOAD_FAILED:-250,
67
+ SPECIFIED_FILE_ID_NOT_FOUND:-260,
68
+ FILE_VALIDATION_FAILED:-270,
69
+ FILE_CANCELLED:-280,
70
+ UPLOAD_STOPPED:-290
71
71
  };
72
72
  SWFUpload.FILE_STATUS = {
73
- QUEUED : -1,
74
- IN_PROGRESS : -2,
75
- ERROR : -3,
76
- COMPLETE : -4,
77
- CANCELLED : -5
73
+ QUEUED:-1,
74
+ IN_PROGRESS:-2,
75
+ ERROR:-3,
76
+ COMPLETE:-4,
77
+ CANCELLED:-5
78
78
  };
79
79
  SWFUpload.BUTTON_ACTION = {
80
- SELECT_FILE : -100,
81
- SELECT_FILES : -110,
82
- START_UPLOAD : -120
80
+ SELECT_FILE:-100,
81
+ SELECT_FILES:-110,
82
+ START_UPLOAD:-120
83
83
  };
84
84
  SWFUpload.CURSOR = {
85
- ARROW : -1,
86
- HAND : -2
85
+ ARROW:-1,
86
+ HAND:-2
87
87
  };
88
88
  SWFUpload.WINDOW_MODE = {
89
- WINDOW : "window",
90
- TRANSPARENT : "transparent",
91
- OPAQUE : "opaque"
89
+ WINDOW:"window",
90
+ TRANSPARENT:"transparent",
91
+ OPAQUE:"opaque"
92
92
  };
93
93
 
94
94
  // Private: takes a URL, determines if it is relative and converts to an absolute URL
95
95
  // using the current site. Only processes the URL if it can, otherwise returns the URL untouched
96
- SWFUpload.completeURL = function(url) {
97
- if (typeof(url) !== "string" || url.match(/^https?:\/\//i) || url.match(/^\//)) {
98
- return url;
99
- }
100
-
101
- var currentURL = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
102
-
103
- var indexSlash = window.location.pathname.lastIndexOf("/");
104
- if (indexSlash <= 0) {
105
- path = "/";
106
- } else {
107
- path = window.location.pathname.substr(0, indexSlash) + "/";
108
- }
109
-
110
- return /*currentURL +*/ path + url;
111
-
96
+ SWFUpload.completeURL = function (url) {
97
+ if (typeof(url) !== "string" || url.match(/^https?:\/\//i) || url.match(/^\//)) {
98
+ return url;
99
+ }
100
+
101
+ var currentURL = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
102
+
103
+ var indexSlash = window.location.pathname.lastIndexOf("/");
104
+ if (indexSlash <= 0) {
105
+ path = "/";
106
+ } else {
107
+ path = window.location.pathname.substr(0, indexSlash) + "/";
108
+ }
109
+
110
+ return /*currentURL +*/ path + url;
111
+
112
112
  };
113
113
 
114
114
 
@@ -119,190 +119,190 @@ SWFUpload.completeURL = function(url) {
119
119
  // Private: initSettings ensures that all the
120
120
  // settings are set, getting a default value if one was not assigned.
121
121
  SWFUpload.prototype.initSettings = function () {
122
- this.ensureDefault = function (settingName, defaultValue) {
123
- this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
124
- };
125
-
126
- // Upload backend settings
127
- this.ensureDefault("upload_url", "");
128
- this.ensureDefault("preserve_relative_urls", false);
129
- this.ensureDefault("file_post_name", "Filedata");
130
- this.ensureDefault("post_params", {});
131
- this.ensureDefault("use_query_string", false);
132
- this.ensureDefault("requeue_on_error", false);
133
- this.ensureDefault("http_success", []);
134
- this.ensureDefault("assume_success_timeout", 0);
135
-
136
- // File Settings
137
- this.ensureDefault("file_types", "*.*");
138
- this.ensureDefault("file_types_description", "All Files");
139
- this.ensureDefault("file_size_limit", 0); // Default zero means "unlimited"
140
- this.ensureDefault("file_upload_limit", 0);
141
- this.ensureDefault("file_queue_limit", 0);
142
-
143
- // Flash Settings
144
- this.ensureDefault("flash_url", "swfupload.swf");
145
- this.ensureDefault("prevent_swf_caching", true);
146
-
147
- // Button Settings
148
- this.ensureDefault("button_image_url", "");
149
- this.ensureDefault("button_width", 1);
150
- this.ensureDefault("button_height", 1);
151
- this.ensureDefault("button_text", "");
152
- this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;");
153
- this.ensureDefault("button_text_top_padding", 0);
154
- this.ensureDefault("button_text_left_padding", 0);
155
- this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES);
156
- this.ensureDefault("button_disabled", false);
157
- this.ensureDefault("button_placeholder_id", "");
158
- this.ensureDefault("button_placeholder", null);
159
- this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW);
160
- this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW);
161
-
162
- // Debug Settings
163
- this.ensureDefault("debug", false);
164
- this.settings.debug_enabled = this.settings.debug; // Here to maintain v2 API
165
-
166
- // Event Handlers
167
- this.settings.return_upload_start_handler = this.returnUploadStart;
168
- this.ensureDefault("swfupload_loaded_handler", null);
169
- this.ensureDefault("file_dialog_start_handler", null);
170
- this.ensureDefault("file_queued_handler", null);
171
- this.ensureDefault("file_queue_error_handler", null);
172
- this.ensureDefault("file_dialog_complete_handler", null);
173
-
174
- this.ensureDefault("upload_start_handler", null);
175
- this.ensureDefault("upload_progress_handler", null);
176
- this.ensureDefault("upload_error_handler", null);
177
- this.ensureDefault("upload_success_handler", null);
178
- this.ensureDefault("upload_complete_handler", null);
179
-
180
- this.ensureDefault("debug_handler", this.debugMessage);
181
-
182
- this.ensureDefault("custom_settings", {});
183
-
184
- // Other settings
185
- this.customSettings = this.settings.custom_settings;
186
-
187
- // Update the flash url if needed
188
- if (!!this.settings.prevent_swf_caching) {
189
- this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime();
190
- }
191
-
192
- if (!this.settings.preserve_relative_urls) {
193
- //this.settings.flash_url = SWFUpload.completeURL(this.settings.flash_url); // Don't need to do this one since flash doesn't look at it
194
- this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url);
195
- this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url);
196
- }
197
-
198
- delete this.ensureDefault;
122
+ this.ensureDefault = function (settingName, defaultValue) {
123
+ this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
124
+ };
125
+
126
+ // Upload backend settings
127
+ this.ensureDefault("upload_url", "");
128
+ this.ensureDefault("preserve_relative_urls", false);
129
+ this.ensureDefault("file_post_name", "Filedata");
130
+ this.ensureDefault("post_params", {});
131
+ this.ensureDefault("use_query_string", false);
132
+ this.ensureDefault("requeue_on_error", false);
133
+ this.ensureDefault("http_success", []);
134
+ this.ensureDefault("assume_success_timeout", 0);
135
+
136
+ // File Settings
137
+ this.ensureDefault("file_types", "*.*");
138
+ this.ensureDefault("file_types_description", "All Files");
139
+ this.ensureDefault("file_size_limit", 0); // Default zero means "unlimited"
140
+ this.ensureDefault("file_upload_limit", 0);
141
+ this.ensureDefault("file_queue_limit", 0);
142
+
143
+ // Flash Settings
144
+ this.ensureDefault("flash_url", "swfupload.swf");
145
+ this.ensureDefault("prevent_swf_caching", true);
146
+
147
+ // Button Settings
148
+ this.ensureDefault("button_image_url", "");
149
+ this.ensureDefault("button_width", 1);
150
+ this.ensureDefault("button_height", 1);
151
+ this.ensureDefault("button_text", "");
152
+ this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;");
153
+ this.ensureDefault("button_text_top_padding", 0);
154
+ this.ensureDefault("button_text_left_padding", 0);
155
+ this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES);
156
+ this.ensureDefault("button_disabled", false);
157
+ this.ensureDefault("button_placeholder_id", "");
158
+ this.ensureDefault("button_placeholder", null);
159
+ this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW);
160
+ this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW);
161
+
162
+ // Debug Settings
163
+ this.ensureDefault("debug", false);
164
+ this.settings.debug_enabled = this.settings.debug; // Here to maintain v2 API
165
+
166
+ // Event Handlers
167
+ this.settings.return_upload_start_handler = this.returnUploadStart;
168
+ this.ensureDefault("swfupload_loaded_handler", null);
169
+ this.ensureDefault("file_dialog_start_handler", null);
170
+ this.ensureDefault("file_queued_handler", null);
171
+ this.ensureDefault("file_queue_error_handler", null);
172
+ this.ensureDefault("file_dialog_complete_handler", null);
173
+
174
+ this.ensureDefault("upload_start_handler", null);
175
+ this.ensureDefault("upload_progress_handler", null);
176
+ this.ensureDefault("upload_error_handler", null);
177
+ this.ensureDefault("upload_success_handler", null);
178
+ this.ensureDefault("upload_complete_handler", null);
179
+
180
+ this.ensureDefault("debug_handler", this.debugMessage);
181
+
182
+ this.ensureDefault("custom_settings", {});
183
+
184
+ // Other settings
185
+ this.customSettings = this.settings.custom_settings;
186
+
187
+ // Update the flash url if needed
188
+ if (!!this.settings.prevent_swf_caching) {
189
+ this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime();
190
+ }
191
+
192
+ if (!this.settings.preserve_relative_urls) {
193
+ //this.settings.flash_url = SWFUpload.completeURL(this.settings.flash_url); // Don't need to do this one since flash doesn't look at it
194
+ this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url);
195
+ this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url);
196
+ }
197
+
198
+ delete this.ensureDefault;
199
199
  };
200
200
 
201
201
  // Private: loadFlash replaces the button_placeholder element with the flash movie.
202
202
  SWFUpload.prototype.loadFlash = function () {
203
- var targetElement, tempParent;
203
+ var targetElement, tempParent;
204
+
205
+ // Make sure an element with the ID we are going to use doesn't already exist
206
+ if (document.getElementById(this.movieName) !== null) {
207
+ throw "ID " + this.movieName + " is already in use. The Flash Object could not be added";
208
+ }
204
209
 
205
- // Make sure an element with the ID we are going to use doesn't already exist
206
- if (document.getElementById(this.movieName) !== null) {
207
- throw "ID " + this.movieName + " is already in use. The Flash Object could not be added";
208
- }
210
+ // Get the element where we will be placing the flash movie
211
+ targetElement = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder;
209
212
 
210
- // Get the element where we will be placing the flash movie
211
- targetElement = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder;
213
+ if (targetElement == undefined) {
214
+ throw "Could not find the placeholder element: " + this.settings.button_placeholder_id;
215
+ }
212
216
 
213
- if (targetElement == undefined) {
214
- throw "Could not find the placeholder element: " + this.settings.button_placeholder_id;
215
- }
217
+ // Append the container and load the flash
218
+ tempParent = document.createElement("div");
219
+ tempParent.innerHTML = this.getFlashHTML(); // Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers)
220
+ targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement);
216
221
 
217
- // Append the container and load the flash
218
- tempParent = document.createElement("div");
219
- tempParent.innerHTML = this.getFlashHTML(); // Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers)
220
- targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement);
222
+ // Fix IE Flash/Form bug
223
+ if (window[this.movieName] == undefined) {
224
+ window[this.movieName] = this.getMovieElement();
225
+ }
221
226
 
222
- // Fix IE Flash/Form bug
223
- if (window[this.movieName] == undefined) {
224
- window[this.movieName] = this.getMovieElement();
225
- }
226
-
227
227
  };
228
228
 
229
229
  // Private: getFlashHTML generates the object tag needed to embed the flash in to the document
230
230
  SWFUpload.prototype.getFlashHTML = function () {
231
- // Flash Satay object syntax: http://www.alistapart.com/articles/flashsatay
232
- return ['<object id="', this.movieName, '" type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">',
233
- '<param name="wmode" value="', this.settings.button_window_mode, '" />',
234
- '<param name="movie" value="', this.settings.flash_url, '" />',
235
- '<param name="quality" value="high" />',
236
- '<param name="menu" value="false" />',
237
- '<param name="allowScriptAccess" value="always" />',
238
- '<param name="flashvars" value="' + this.getFlashVars() + '" />',
239
- '</object>'].join("");
231
+ // Flash Satay object syntax: http://www.alistapart.com/articles/flashsatay
232
+ return ['<object id="', this.movieName, '" type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">',
233
+ '<param name="wmode" value="', this.settings.button_window_mode, '" />',
234
+ '<param name="movie" value="', this.settings.flash_url, '" />',
235
+ '<param name="quality" value="high" />',
236
+ '<param name="menu" value="false" />',
237
+ '<param name="allowScriptAccess" value="always" />',
238
+ '<param name="flashvars" value="' + this.getFlashVars() + '" />',
239
+ '</object>'].join("");
240
240
  };
241
241
 
242
242
  // Private: getFlashVars builds the parameter string that will be passed
243
243
  // to flash in the flashvars param.
244
244
  SWFUpload.prototype.getFlashVars = function () {
245
- // Build a string from the post param object
246
- var paramString = this.buildParamString();
247
- var httpSuccessString = this.settings.http_success.join(",");
248
-
249
- // Build the parameter string
250
- return ["movieName=", encodeURIComponent(this.movieName),
251
- "&amp;uploadURL=", encodeURIComponent(this.settings.upload_url),
252
- "&amp;useQueryString=", encodeURIComponent(this.settings.use_query_string),
253
- "&amp;requeueOnError=", encodeURIComponent(this.settings.requeue_on_error),
254
- "&amp;httpSuccess=", encodeURIComponent(httpSuccessString),
255
- "&amp;assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout),
256
- "&amp;params=", encodeURIComponent(paramString),
257
- "&amp;filePostName=", encodeURIComponent(this.settings.file_post_name),
258
- "&amp;fileTypes=", encodeURIComponent(this.settings.file_types),
259
- "&amp;fileTypesDescription=", encodeURIComponent(this.settings.file_types_description),
260
- "&amp;fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit),
261
- "&amp;fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit),
262
- "&amp;fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit),
263
- "&amp;debugEnabled=", encodeURIComponent(this.settings.debug_enabled),
264
- "&amp;buttonImageURL=", encodeURIComponent(this.settings.button_image_url),
265
- "&amp;buttonWidth=", encodeURIComponent(this.settings.button_width),
266
- "&amp;buttonHeight=", encodeURIComponent(this.settings.button_height),
267
- "&amp;buttonText=", encodeURIComponent(this.settings.button_text),
268
- "&amp;buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding),
269
- "&amp;buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding),
270
- "&amp;buttonTextStyle=", encodeURIComponent(this.settings.button_text_style),
271
- "&amp;buttonAction=", encodeURIComponent(this.settings.button_action),
272
- "&amp;buttonDisabled=", encodeURIComponent(this.settings.button_disabled),
273
- "&amp;buttonCursor=", encodeURIComponent(this.settings.button_cursor)
274
- ].join("");
245
+ // Build a string from the post param object
246
+ var paramString = this.buildParamString();
247
+ var httpSuccessString = this.settings.http_success.join(",");
248
+
249
+ // Build the parameter string
250
+ return ["movieName=", encodeURIComponent(this.movieName),
251
+ "&amp;uploadURL=", encodeURIComponent(this.settings.upload_url),
252
+ "&amp;useQueryString=", encodeURIComponent(this.settings.use_query_string),
253
+ "&amp;requeueOnError=", encodeURIComponent(this.settings.requeue_on_error),
254
+ "&amp;httpSuccess=", encodeURIComponent(httpSuccessString),
255
+ "&amp;assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout),
256
+ "&amp;params=", encodeURIComponent(paramString),
257
+ "&amp;filePostName=", encodeURIComponent(this.settings.file_post_name),
258
+ "&amp;fileTypes=", encodeURIComponent(this.settings.file_types),
259
+ "&amp;fileTypesDescription=", encodeURIComponent(this.settings.file_types_description),
260
+ "&amp;fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit),
261
+ "&amp;fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit),
262
+ "&amp;fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit),
263
+ "&amp;debugEnabled=", encodeURIComponent(this.settings.debug_enabled),
264
+ "&amp;buttonImageURL=", encodeURIComponent(this.settings.button_image_url),
265
+ "&amp;buttonWidth=", encodeURIComponent(this.settings.button_width),
266
+ "&amp;buttonHeight=", encodeURIComponent(this.settings.button_height),
267
+ "&amp;buttonText=", encodeURIComponent(this.settings.button_text),
268
+ "&amp;buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding),
269
+ "&amp;buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding),
270
+ "&amp;buttonTextStyle=", encodeURIComponent(this.settings.button_text_style),
271
+ "&amp;buttonAction=", encodeURIComponent(this.settings.button_action),
272
+ "&amp;buttonDisabled=", encodeURIComponent(this.settings.button_disabled),
273
+ "&amp;buttonCursor=", encodeURIComponent(this.settings.button_cursor)
274
+ ].join("");
275
275
  };
276
276
 
277
277
  // Public: getMovieElement retrieves the DOM reference to the Flash element added by SWFUpload
278
278
  // The element is cached after the first lookup
279
279
  SWFUpload.prototype.getMovieElement = function () {
280
- if (this.movieElement == undefined) {
281
- this.movieElement = document.getElementById(this.movieName);
282
- }
280
+ if (this.movieElement == undefined) {
281
+ this.movieElement = document.getElementById(this.movieName);
282
+ }
283
283
 
284
- if (this.movieElement === null) {
285
- throw "Could not find Flash element";
286
- }
287
-
288
- return this.movieElement;
284
+ if (this.movieElement === null) {
285
+ throw "Could not find Flash element";
286
+ }
287
+
288
+ return this.movieElement;
289
289
  };
290
290
 
291
291
  // Private: buildParamString takes the name/value pairs in the post_params setting object
292
292
  // and joins them up in to a string formatted "name=value&amp;name=value"
293
293
  SWFUpload.prototype.buildParamString = function () {
294
- var postParams = this.settings.post_params;
295
- var paramStringPairs = [];
294
+ var postParams = this.settings.post_params;
295
+ var paramStringPairs = [];
296
296
 
297
- if (typeof(postParams) === "object") {
298
- for (var name in postParams) {
299
- if (postParams.hasOwnProperty(name)) {
300
- paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString()));
301
- }
302
- }
303
- }
297
+ if (typeof(postParams) === "object") {
298
+ for (var name in postParams) {
299
+ if (postParams.hasOwnProperty(name)) {
300
+ paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString()));
301
+ }
302
+ }
303
+ }
304
304
 
305
- return paramStringPairs.join("&amp;");
305
+ return paramStringPairs.join("&amp;");
306
306
  };
307
307
 
308
308
  // Public: Used to remove a SWFUpload instance from the page. This method strives to remove
@@ -310,49 +310,51 @@ SWFUpload.prototype.buildParamString = function () {
310
310
  // Returns true if everything was destroyed. Returns a false if a failure occurs leaving SWFUpload in an inconsistant state.
311
311
  // Credits: Major improvements provided by steffen
312
312
  SWFUpload.prototype.destroy = function () {
313
- try {
314
- // Make sure Flash is done before we try to remove it
315
- this.cancelUpload(null, false);
316
-
317
-
318
- // Remove the SWFUpload DOM nodes
319
- var movieElement = null;
320
- movieElement = this.getMovieElement();
321
-
322
- if (movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
323
- // Loop through all the movie's properties and remove all function references (DOM/JS IE 6/7 memory leak workaround)
324
- for (var i in movieElement) {
325
- try {
326
- if (typeof(movieElement[i]) === "function") {
327
- movieElement[i] = null;
328
- }
329
- } catch (ex1) {}
330
- }
331
-
332
- // Remove the Movie Element from the page
333
- try {
334
- movieElement.parentNode.removeChild(movieElement);
335
- } catch (ex) {}
336
- }
337
-
338
- // Remove IE form fix reference
339
- window[this.movieName] = null;
340
-
341
- // Destroy other references
342
- SWFUpload.instances[this.movieName] = null;
343
- delete SWFUpload.instances[this.movieName];
344
-
345
- this.movieElement = null;
346
- this.settings = null;
347
- this.customSettings = null;
348
- this.eventQueue = null;
349
- this.movieName = null;
350
-
351
-
352
- return true;
353
- } catch (ex2) {
354
- return false;
355
- }
313
+ try {
314
+ // Make sure Flash is done before we try to remove it
315
+ this.cancelUpload(null, false);
316
+
317
+
318
+ // Remove the SWFUpload DOM nodes
319
+ var movieElement = null;
320
+ movieElement = this.getMovieElement();
321
+
322
+ if (movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
323
+ // Loop through all the movie's properties and remove all function references (DOM/JS IE 6/7 memory leak workaround)
324
+ for (var i in movieElement) {
325
+ try {
326
+ if (typeof(movieElement[i]) === "function") {
327
+ movieElement[i] = null;
328
+ }
329
+ } catch (ex1) {
330
+ }
331
+ }
332
+
333
+ // Remove the Movie Element from the page
334
+ try {
335
+ movieElement.parentNode.removeChild(movieElement);
336
+ } catch (ex) {
337
+ }
338
+ }
339
+
340
+ // Remove IE form fix reference
341
+ window[this.movieName] = null;
342
+
343
+ // Destroy other references
344
+ SWFUpload.instances[this.movieName] = null;
345
+ delete SWFUpload.instances[this.movieName];
346
+
347
+ this.movieElement = null;
348
+ this.settings = null;
349
+ this.customSettings = null;
350
+ this.eventQueue = null;
351
+ this.movieName = null;
352
+
353
+
354
+ return true;
355
+ } catch (ex2) {
356
+ return false;
357
+ }
356
358
  };
357
359
 
358
360
 
@@ -361,116 +363,115 @@ SWFUpload.prototype.destroy = function () {
361
363
  // This function (and any references to it) can be deleted when placing
362
364
  // SWFUpload in production.
363
365
  SWFUpload.prototype.displayDebugInfo = function () {
364
- this.debug(
365
- [
366
- "---SWFUpload Instance Info---\n",
367
- "Version: ", SWFUpload.version, "\n",
368
- "Movie Name: ", this.movieName, "\n",
369
- "Settings:\n",
370
- "\t", "upload_url: ", this.settings.upload_url, "\n",
371
- "\t", "flash_url: ", this.settings.flash_url, "\n",
372
- "\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n",
373
- "\t", "requeue_on_error: ", this.settings.requeue_on_error.toString(), "\n",
374
- "\t", "http_success: ", this.settings.http_success.join(", "), "\n",
375
- "\t", "assume_success_timeout: ", this.settings.assume_success_timeout, "\n",
376
- "\t", "file_post_name: ", this.settings.file_post_name, "\n",
377
- "\t", "post_params: ", this.settings.post_params.toString(), "\n",
378
- "\t", "file_types: ", this.settings.file_types, "\n",
379
- "\t", "file_types_description: ", this.settings.file_types_description, "\n",
380
- "\t", "file_size_limit: ", this.settings.file_size_limit, "\n",
381
- "\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n",
382
- "\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n",
383
- "\t", "debug: ", this.settings.debug.toString(), "\n",
384
-
385
- "\t", "prevent_swf_caching: ", this.settings.prevent_swf_caching.toString(), "\n",
386
-
387
- "\t", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n",
388
- "\t", "button_placeholder: ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n",
389
- "\t", "button_image_url: ", this.settings.button_image_url.toString(), "\n",
390
- "\t", "button_width: ", this.settings.button_width.toString(), "\n",
391
- "\t", "button_height: ", this.settings.button_height.toString(), "\n",
392
- "\t", "button_text: ", this.settings.button_text.toString(), "\n",
393
- "\t", "button_text_style: ", this.settings.button_text_style.toString(), "\n",
394
- "\t", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n",
395
- "\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n",
396
- "\t", "button_action: ", this.settings.button_action.toString(), "\n",
397
- "\t", "button_disabled: ", this.settings.button_disabled.toString(), "\n",
398
-
399
- "\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n",
400
- "Event Handlers:\n",
401
- "\t", "swfupload_loaded_handler assigned: ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n",
402
- "\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n",
403
- "\t", "file_queued_handler assigned: ", (typeof this.settings.file_queued_handler === "function").toString(), "\n",
404
- "\t", "file_queue_error_handler assigned: ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n",
405
- "\t", "upload_start_handler assigned: ", (typeof this.settings.upload_start_handler === "function").toString(), "\n",
406
- "\t", "upload_progress_handler assigned: ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n",
407
- "\t", "upload_error_handler assigned: ", (typeof this.settings.upload_error_handler === "function").toString(), "\n",
408
- "\t", "upload_success_handler assigned: ", (typeof this.settings.upload_success_handler === "function").toString(), "\n",
409
- "\t", "upload_complete_handler assigned: ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n",
410
- "\t", "debug_handler assigned: ", (typeof this.settings.debug_handler === "function").toString(), "\n"
411
- ].join("")
412
- );
366
+ this.debug(
367
+ [
368
+ "---SWFUpload Instance Info---\n",
369
+ "Version: ", SWFUpload.version, "\n",
370
+ "Movie Name: ", this.movieName, "\n",
371
+ "Settings:\n",
372
+ "\t", "upload_url: ", this.settings.upload_url, "\n",
373
+ "\t", "flash_url: ", this.settings.flash_url, "\n",
374
+ "\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n",
375
+ "\t", "requeue_on_error: ", this.settings.requeue_on_error.toString(), "\n",
376
+ "\t", "http_success: ", this.settings.http_success.join(", "), "\n",
377
+ "\t", "assume_success_timeout: ", this.settings.assume_success_timeout, "\n",
378
+ "\t", "file_post_name: ", this.settings.file_post_name, "\n",
379
+ "\t", "post_params: ", this.settings.post_params.toString(), "\n",
380
+ "\t", "file_types: ", this.settings.file_types, "\n",
381
+ "\t", "file_types_description: ", this.settings.file_types_description, "\n",
382
+ "\t", "file_size_limit: ", this.settings.file_size_limit, "\n",
383
+ "\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n",
384
+ "\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n",
385
+ "\t", "debug: ", this.settings.debug.toString(), "\n",
386
+
387
+ "\t", "prevent_swf_caching: ", this.settings.prevent_swf_caching.toString(), "\n",
388
+
389
+ "\t", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n",
390
+ "\t", "button_placeholder: ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n",
391
+ "\t", "button_image_url: ", this.settings.button_image_url.toString(), "\n",
392
+ "\t", "button_width: ", this.settings.button_width.toString(), "\n",
393
+ "\t", "button_height: ", this.settings.button_height.toString(), "\n",
394
+ "\t", "button_text: ", this.settings.button_text.toString(), "\n",
395
+ "\t", "button_text_style: ", this.settings.button_text_style.toString(), "\n",
396
+ "\t", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n",
397
+ "\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n",
398
+ "\t", "button_action: ", this.settings.button_action.toString(), "\n",
399
+ "\t", "button_disabled: ", this.settings.button_disabled.toString(), "\n",
400
+
401
+ "\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n",
402
+ "Event Handlers:\n",
403
+ "\t", "swfupload_loaded_handler assigned: ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n",
404
+ "\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n",
405
+ "\t", "file_queued_handler assigned: ", (typeof this.settings.file_queued_handler === "function").toString(), "\n",
406
+ "\t", "file_queue_error_handler assigned: ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n",
407
+ "\t", "upload_start_handler assigned: ", (typeof this.settings.upload_start_handler === "function").toString(), "\n",
408
+ "\t", "upload_progress_handler assigned: ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n",
409
+ "\t", "upload_error_handler assigned: ", (typeof this.settings.upload_error_handler === "function").toString(), "\n",
410
+ "\t", "upload_success_handler assigned: ", (typeof this.settings.upload_success_handler === "function").toString(), "\n",
411
+ "\t", "upload_complete_handler assigned: ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n",
412
+ "\t", "debug_handler assigned: ", (typeof this.settings.debug_handler === "function").toString(), "\n"
413
+ ].join("")
414
+ );
413
415
  };
414
416
 
415
417
  /* Note: addSetting and getSetting are no longer used by SWFUpload but are included
416
- the maintain v2 API compatibility
417
- */
418
+ the maintain v2 API compatibility
419
+ */
418
420
  // Public: (Deprecated) addSetting adds a setting value. If the value given is undefined or null then the default_value is used.
419
421
  SWFUpload.prototype.addSetting = function (name, value, default_value) {
420
- if (value == undefined) {
421
- return (this.settings[name] = default_value);
422
- } else {
423
- return (this.settings[name] = value);
424
- }
422
+ if (value == undefined) {
423
+ return (this.settings[name] = default_value);
424
+ } else {
425
+ return (this.settings[name] = value);
426
+ }
425
427
  };
426
428
 
427
429
  // Public: (Deprecated) getSetting gets a setting. Returns an empty string if the setting was not found.
428
430
  SWFUpload.prototype.getSetting = function (name) {
429
- if (this.settings[name] != undefined) {
430
- return this.settings[name];
431
- }
431
+ if (this.settings[name] != undefined) {
432
+ return this.settings[name];
433
+ }
432
434
 
433
- return "";
435
+ return "";
434
436
  };
435
437
 
436
438
 
437
-
438
439
  // Private: callFlash handles function calls made to the Flash element.
439
440
  // Calls are made with a setTimeout for some functions to work around
440
441
  // bugs in the ExternalInterface library.
441
442
  SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
442
- argumentArray = argumentArray || [];
443
-
444
- var movieElement = this.getMovieElement();
445
- var returnValue, returnString;
446
-
447
- // Flash's method if calling ExternalInterface methods (code adapted from MooTools).
448
- try {
449
- returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + '</invoke>');
450
- returnValue = eval(returnString);
451
- } catch (ex) {
452
- throw "Call to " + functionName + " failed";
453
- }
454
-
455
- // Unescape file post param values
456
- if (returnValue != undefined && typeof returnValue.post === "object") {
457
- returnValue = this.unescapeFilePostParams(returnValue);
458
- }
459
-
460
- return returnValue;
443
+ argumentArray = argumentArray || [];
444
+
445
+ var movieElement = this.getMovieElement();
446
+ var returnValue, returnString;
447
+
448
+ // Flash's method if calling ExternalInterface methods (code adapted from MooTools).
449
+ try {
450
+ returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + '</invoke>');
451
+ returnValue = eval(returnString);
452
+ } catch (ex) {
453
+ throw "Call to " + functionName + " failed";
454
+ }
455
+
456
+ // Unescape file post param values
457
+ if (returnValue != undefined && typeof returnValue.post === "object") {
458
+ returnValue = this.unescapeFilePostParams(returnValue);
459
+ }
460
+
461
+ return returnValue;
461
462
  };
462
463
 
463
464
  /* *****************************
464
- -- Flash control methods --
465
- Your UI should use these
466
- to operate SWFUpload
467
- ***************************** */
465
+ -- Flash control methods --
466
+ Your UI should use these
467
+ to operate SWFUpload
468
+ ***************************** */
468
469
 
469
470
  // WARNING: this function does not work in Flash Player 10
470
471
  // Public: selectFile causes a File Selection Dialog window to appear. This
471
472
  // dialog only allows 1 file to be selected.
472
473
  SWFUpload.prototype.selectFile = function () {
473
- this.callFlash("SelectFile");
474
+ this.callFlash("SelectFile");
474
475
  };
475
476
 
476
477
  // WARNING: this function does not work in Flash Player 10
@@ -480,30 +481,30 @@ SWFUpload.prototype.selectFile = function () {
480
481
  // If the selection name length is too long the dialog will fail in an unpredictable manner. There is no work-around
481
482
  // for this bug.
482
483
  SWFUpload.prototype.selectFiles = function () {
483
- this.callFlash("SelectFiles");
484
+ this.callFlash("SelectFiles");
484
485
  };
485
486
 
486
487
 
487
488
  // Public: startUpload starts uploading the first file in the queue unless
488
489
  // the optional parameter 'fileID' specifies the ID
489
490
  SWFUpload.prototype.startUpload = function (fileID) {
490
- this.callFlash("StartUpload", [fileID]);
491
+ this.callFlash("StartUpload", [fileID]);
491
492
  };
492
493
 
493
494
  // Public: cancelUpload cancels any queued file. The fileID parameter may be the file ID or index.
494
495
  // If you do not specify a fileID the current uploading file or first file in the queue is cancelled.
495
496
  // If you do not want the uploadError event to trigger you can specify false for the triggerErrorEvent parameter.
496
497
  SWFUpload.prototype.cancelUpload = function (fileID, triggerErrorEvent) {
497
- if (triggerErrorEvent !== false) {
498
- triggerErrorEvent = true;
499
- }
500
- this.callFlash("CancelUpload", [fileID, triggerErrorEvent]);
498
+ if (triggerErrorEvent !== false) {
499
+ triggerErrorEvent = true;
500
+ }
501
+ this.callFlash("CancelUpload", [fileID, triggerErrorEvent]);
501
502
  };
502
503
 
503
504
  // Public: stopUpload stops the current upload and requeues the file at the beginning of the queue.
504
505
  // If nothing is currently uploading then nothing happens.
505
506
  SWFUpload.prototype.stopUpload = function () {
506
- this.callFlash("StopUpload");
507
+ this.callFlash("StopUpload");
507
508
  };
508
509
 
509
510
  /* ************************
@@ -516,7 +517,7 @@ SWFUpload.prototype.stopUpload = function () {
516
517
 
517
518
  // Public: getStats gets the file statistics object.
518
519
  SWFUpload.prototype.getStats = function () {
519
- return this.callFlash("GetStats");
520
+ return this.callFlash("GetStats");
520
521
  };
521
522
 
522
523
  // Public: setStats changes the SWFUpload statistics. You shouldn't need to
@@ -524,457 +525,456 @@ SWFUpload.prototype.getStats = function () {
524
525
  // affect SWFUpload accept for the successful_uploads count which is used
525
526
  // by the upload_limit setting to determine how many files the user may upload.
526
527
  SWFUpload.prototype.setStats = function (statsObject) {
527
- this.callFlash("SetStats", [statsObject]);
528
+ this.callFlash("SetStats", [statsObject]);
528
529
  };
529
530
 
530
531
  // Public: getFile retrieves a File object by ID or Index. If the file is
531
532
  // not found then 'null' is returned.
532
533
  SWFUpload.prototype.getFile = function (fileID) {
533
- if (typeof(fileID) === "number") {
534
- return this.callFlash("GetFileByIndex", [fileID]);
535
- } else {
536
- return this.callFlash("GetFile", [fileID]);
537
- }
534
+ if (typeof(fileID) === "number") {
535
+ return this.callFlash("GetFileByIndex", [fileID]);
536
+ } else {
537
+ return this.callFlash("GetFile", [fileID]);
538
+ }
538
539
  };
539
540
 
540
541
  // Public: addFileParam sets a name/value pair that will be posted with the
541
542
  // file specified by the Files ID. If the name already exists then the
542
543
  // exiting value will be overwritten.
543
544
  SWFUpload.prototype.addFileParam = function (fileID, name, value) {
544
- return this.callFlash("AddFileParam", [fileID, name, value]);
545
+ return this.callFlash("AddFileParam", [fileID, name, value]);
545
546
  };
546
547
 
547
548
  // Public: removeFileParam removes a previously set (by addFileParam) name/value
548
549
  // pair from the specified file.
549
550
  SWFUpload.prototype.removeFileParam = function (fileID, name) {
550
- this.callFlash("RemoveFileParam", [fileID, name]);
551
+ this.callFlash("RemoveFileParam", [fileID, name]);
551
552
  };
552
553
 
553
554
  // Public: setUploadUrl changes the upload_url setting.
554
555
  SWFUpload.prototype.setUploadURL = function (url) {
555
- this.settings.upload_url = url.toString();
556
- this.callFlash("SetUploadURL", [url]);
556
+ this.settings.upload_url = url.toString();
557
+ this.callFlash("SetUploadURL", [url]);
557
558
  };
558
559
 
559
560
  // Public: setPostParams changes the post_params setting
560
561
  SWFUpload.prototype.setPostParams = function (paramsObject) {
561
- this.settings.post_params = paramsObject;
562
- this.callFlash("SetPostParams", [paramsObject]);
562
+ this.settings.post_params = paramsObject;
563
+ this.callFlash("SetPostParams", [paramsObject]);
563
564
  };
564
565
 
565
566
  // Public: addPostParam adds post name/value pair. Each name can have only one value.
566
567
  SWFUpload.prototype.addPostParam = function (name, value) {
567
- this.settings.post_params[name] = value;
568
- this.callFlash("SetPostParams", [this.settings.post_params]);
568
+ this.settings.post_params[name] = value;
569
+ this.callFlash("SetPostParams", [this.settings.post_params]);
569
570
  };
570
571
 
571
572
  // Public: removePostParam deletes post name/value pair.
572
573
  SWFUpload.prototype.removePostParam = function (name) {
573
- delete this.settings.post_params[name];
574
- this.callFlash("SetPostParams", [this.settings.post_params]);
574
+ delete this.settings.post_params[name];
575
+ this.callFlash("SetPostParams", [this.settings.post_params]);
575
576
  };
576
577
 
577
578
  // Public: setFileTypes changes the file_types setting and the file_types_description setting
578
579
  SWFUpload.prototype.setFileTypes = function (types, description) {
579
- this.settings.file_types = types;
580
- this.settings.file_types_description = description;
581
- this.callFlash("SetFileTypes", [types, description]);
580
+ this.settings.file_types = types;
581
+ this.settings.file_types_description = description;
582
+ this.callFlash("SetFileTypes", [types, description]);
582
583
  };
583
584
 
584
585
  // Public: setFileSizeLimit changes the file_size_limit setting
585
586
  SWFUpload.prototype.setFileSizeLimit = function (fileSizeLimit) {
586
- this.settings.file_size_limit = fileSizeLimit;
587
- this.callFlash("SetFileSizeLimit", [fileSizeLimit]);
587
+ this.settings.file_size_limit = fileSizeLimit;
588
+ this.callFlash("SetFileSizeLimit", [fileSizeLimit]);
588
589
  };
589
590
 
590
591
  // Public: setFileUploadLimit changes the file_upload_limit setting
591
592
  SWFUpload.prototype.setFileUploadLimit = function (fileUploadLimit) {
592
- this.settings.file_upload_limit = fileUploadLimit;
593
- this.callFlash("SetFileUploadLimit", [fileUploadLimit]);
593
+ this.settings.file_upload_limit = fileUploadLimit;
594
+ this.callFlash("SetFileUploadLimit", [fileUploadLimit]);
594
595
  };
595
596
 
596
597
  // Public: setFileQueueLimit changes the file_queue_limit setting
597
598
  SWFUpload.prototype.setFileQueueLimit = function (fileQueueLimit) {
598
- this.settings.file_queue_limit = fileQueueLimit;
599
- this.callFlash("SetFileQueueLimit", [fileQueueLimit]);
599
+ this.settings.file_queue_limit = fileQueueLimit;
600
+ this.callFlash("SetFileQueueLimit", [fileQueueLimit]);
600
601
  };
601
602
 
602
603
  // Public: setFilePostName changes the file_post_name setting
603
604
  SWFUpload.prototype.setFilePostName = function (filePostName) {
604
- this.settings.file_post_name = filePostName;
605
- this.callFlash("SetFilePostName", [filePostName]);
605
+ this.settings.file_post_name = filePostName;
606
+ this.callFlash("SetFilePostName", [filePostName]);
606
607
  };
607
608
 
608
609
  // Public: setUseQueryString changes the use_query_string setting
609
610
  SWFUpload.prototype.setUseQueryString = function (useQueryString) {
610
- this.settings.use_query_string = useQueryString;
611
- this.callFlash("SetUseQueryString", [useQueryString]);
611
+ this.settings.use_query_string = useQueryString;
612
+ this.callFlash("SetUseQueryString", [useQueryString]);
612
613
  };
613
614
 
614
615
  // Public: setRequeueOnError changes the requeue_on_error setting
615
616
  SWFUpload.prototype.setRequeueOnError = function (requeueOnError) {
616
- this.settings.requeue_on_error = requeueOnError;
617
- this.callFlash("SetRequeueOnError", [requeueOnError]);
617
+ this.settings.requeue_on_error = requeueOnError;
618
+ this.callFlash("SetRequeueOnError", [requeueOnError]);
618
619
  };
619
620
 
620
621
  // Public: setHTTPSuccess changes the http_success setting
621
622
  SWFUpload.prototype.setHTTPSuccess = function (http_status_codes) {
622
- if (typeof http_status_codes === "string") {
623
- http_status_codes = http_status_codes.replace(" ", "").split(",");
624
- }
625
-
626
- this.settings.http_success = http_status_codes;
627
- this.callFlash("SetHTTPSuccess", [http_status_codes]);
623
+ if (typeof http_status_codes === "string") {
624
+ http_status_codes = http_status_codes.replace(" ", "").split(",");
625
+ }
626
+
627
+ this.settings.http_success = http_status_codes;
628
+ this.callFlash("SetHTTPSuccess", [http_status_codes]);
628
629
  };
629
630
 
630
631
  // Public: setHTTPSuccess changes the http_success setting
631
632
  SWFUpload.prototype.setAssumeSuccessTimeout = function (timeout_seconds) {
632
- this.settings.assume_success_timeout = timeout_seconds;
633
- this.callFlash("SetAssumeSuccessTimeout", [timeout_seconds]);
633
+ this.settings.assume_success_timeout = timeout_seconds;
634
+ this.callFlash("SetAssumeSuccessTimeout", [timeout_seconds]);
634
635
  };
635
636
 
636
637
  // Public: setDebugEnabled changes the debug_enabled setting
637
638
  SWFUpload.prototype.setDebugEnabled = function (debugEnabled) {
638
- this.settings.debug_enabled = debugEnabled;
639
- this.callFlash("SetDebugEnabled", [debugEnabled]);
639
+ this.settings.debug_enabled = debugEnabled;
640
+ this.callFlash("SetDebugEnabled", [debugEnabled]);
640
641
  };
641
642
 
642
643
  // Public: setButtonImageURL loads a button image sprite
643
644
  SWFUpload.prototype.setButtonImageURL = function (buttonImageURL) {
644
- if (buttonImageURL == undefined) {
645
- buttonImageURL = "";
646
- }
647
-
648
- this.settings.button_image_url = buttonImageURL;
649
- this.callFlash("SetButtonImageURL", [buttonImageURL]);
645
+ if (buttonImageURL == undefined) {
646
+ buttonImageURL = "";
647
+ }
648
+
649
+ this.settings.button_image_url = buttonImageURL;
650
+ this.callFlash("SetButtonImageURL", [buttonImageURL]);
650
651
  };
651
652
 
652
653
  // Public: setButtonDimensions resizes the Flash Movie and button
653
654
  SWFUpload.prototype.setButtonDimensions = function (width, height) {
654
- this.settings.button_width = width;
655
- this.settings.button_height = height;
656
-
657
- var movie = this.getMovieElement();
658
- if (movie != undefined) {
659
- movie.style.width = width + "px";
660
- movie.style.height = height + "px";
661
- }
662
-
663
- this.callFlash("SetButtonDimensions", [width, height]);
655
+ this.settings.button_width = width;
656
+ this.settings.button_height = height;
657
+
658
+ var movie = this.getMovieElement();
659
+ if (movie != undefined) {
660
+ movie.style.width = width + "px";
661
+ movie.style.height = height + "px";
662
+ }
663
+
664
+ this.callFlash("SetButtonDimensions", [width, height]);
664
665
  };
665
666
  // Public: setButtonText Changes the text overlaid on the button
666
667
  SWFUpload.prototype.setButtonText = function (html) {
667
- this.settings.button_text = html;
668
- this.callFlash("SetButtonText", [html]);
668
+ this.settings.button_text = html;
669
+ this.callFlash("SetButtonText", [html]);
669
670
  };
670
671
  // Public: setButtonTextPadding changes the top and left padding of the text overlay
671
672
  SWFUpload.prototype.setButtonTextPadding = function (left, top) {
672
- this.settings.button_text_top_padding = top;
673
- this.settings.button_text_left_padding = left;
674
- this.callFlash("SetButtonTextPadding", [left, top]);
673
+ this.settings.button_text_top_padding = top;
674
+ this.settings.button_text_left_padding = left;
675
+ this.callFlash("SetButtonTextPadding", [left, top]);
675
676
  };
676
677
 
677
678
  // Public: setButtonTextStyle changes the CSS used to style the HTML/Text overlaid on the button
678
679
  SWFUpload.prototype.setButtonTextStyle = function (css) {
679
- this.settings.button_text_style = css;
680
- this.callFlash("SetButtonTextStyle", [css]);
680
+ this.settings.button_text_style = css;
681
+ this.callFlash("SetButtonTextStyle", [css]);
681
682
  };
682
683
  // Public: setButtonDisabled disables/enables the button
683
684
  SWFUpload.prototype.setButtonDisabled = function (isDisabled) {
684
- this.settings.button_disabled = isDisabled;
685
- this.callFlash("SetButtonDisabled", [isDisabled]);
685
+ this.settings.button_disabled = isDisabled;
686
+ this.callFlash("SetButtonDisabled", [isDisabled]);
686
687
  };
687
688
  // Public: setButtonAction sets the action that occurs when the button is clicked
688
689
  SWFUpload.prototype.setButtonAction = function (buttonAction) {
689
- this.settings.button_action = buttonAction;
690
- this.callFlash("SetButtonAction", [buttonAction]);
690
+ this.settings.button_action = buttonAction;
691
+ this.callFlash("SetButtonAction", [buttonAction]);
691
692
  };
692
693
 
693
694
  // Public: setButtonCursor changes the mouse cursor displayed when hovering over the button
694
695
  SWFUpload.prototype.setButtonCursor = function (cursor) {
695
- this.settings.button_cursor = cursor;
696
- this.callFlash("SetButtonCursor", [cursor]);
696
+ this.settings.button_cursor = cursor;
697
+ this.callFlash("SetButtonCursor", [cursor]);
697
698
  };
698
699
 
699
700
  /* *******************************
700
- Flash Event Interfaces
701
- These functions are used by Flash to trigger the various
702
- events.
703
-
704
- All these functions a Private.
705
-
706
- Because the ExternalInterface library is buggy the event calls
707
- are added to a queue and the queue then executed by a setTimeout.
708
- This ensures that events are executed in a determinate order and that
709
- the ExternalInterface bugs are avoided.
710
- ******************************* */
701
+ Flash Event Interfaces
702
+ These functions are used by Flash to trigger the various
703
+ events.
704
+
705
+ All these functions a Private.
706
+
707
+ Because the ExternalInterface library is buggy the event calls
708
+ are added to a queue and the queue then executed by a setTimeout.
709
+ This ensures that events are executed in a determinate order and that
710
+ the ExternalInterface bugs are avoided.
711
+ ******************************* */
711
712
 
712
713
  SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) {
713
- // Warning: Don't call this.debug inside here or you'll create an infinite loop
714
-
715
- if (argumentArray == undefined) {
716
- argumentArray = [];
717
- } else if (!(argumentArray instanceof Array)) {
718
- argumentArray = [argumentArray];
719
- }
720
-
721
- var self = this;
722
- if (typeof this.settings[handlerName] === "function") {
723
- // Queue the event
724
- this.eventQueue.push(function () {
725
- this.settings[handlerName].apply(this, argumentArray);
726
- });
727
-
728
- // Execute the next queued event
729
- setTimeout(function () {
730
- self.executeNextEvent();
731
- }, 0);
732
-
733
- } else if (this.settings[handlerName] !== null) {
734
- throw "Event handler " + handlerName + " is unknown or is not a function";
735
- }
714
+ // Warning: Don't call this.debug inside here or you'll create an infinite loop
715
+
716
+ if (argumentArray == undefined) {
717
+ argumentArray = [];
718
+ } else if (!(argumentArray instanceof Array)) {
719
+ argumentArray = [argumentArray];
720
+ }
721
+
722
+ var self = this;
723
+ if (typeof this.settings[handlerName] === "function") {
724
+ // Queue the event
725
+ this.eventQueue.push(function () {
726
+ this.settings[handlerName].apply(this, argumentArray);
727
+ });
728
+
729
+ // Execute the next queued event
730
+ setTimeout(function () {
731
+ self.executeNextEvent();
732
+ }, 0);
733
+
734
+ } else if (this.settings[handlerName] !== null) {
735
+ throw "Event handler " + handlerName + " is unknown or is not a function";
736
+ }
736
737
  };
737
738
 
738
739
  // Private: Causes the next event in the queue to be executed. Since events are queued using a setTimeout
739
740
  // we must queue them in order to garentee that they are executed in order.
740
741
  SWFUpload.prototype.executeNextEvent = function () {
741
- // Warning: Don't call this.debug inside here or you'll create an infinite loop
742
+ // Warning: Don't call this.debug inside here or you'll create an infinite loop
742
743
 
743
- var f = this.eventQueue ? this.eventQueue.shift() : null;
744
- if (typeof(f) === "function") {
745
- f.apply(this);
746
- }
744
+ var f = this.eventQueue ? this.eventQueue.shift() : null;
745
+ if (typeof(f) === "function") {
746
+ f.apply(this);
747
+ }
747
748
  };
748
749
 
749
750
  // Private: unescapeFileParams is part of a workaround for a flash bug where objects passed through ExternalInterface cannot have
750
751
  // properties that contain characters that are not valid for JavaScript identifiers. To work around this
751
752
  // the Flash Component escapes the parameter names and we must unescape again before passing them along.
752
753
  SWFUpload.prototype.unescapeFilePostParams = function (file) {
753
- var reg = /[$]([0-9a-f]{4})/i;
754
- var unescapedPost = {};
755
- var uk;
754
+ var reg = /[$]([0-9a-f]{4})/i;
755
+ var unescapedPost = {};
756
+ var uk;
756
757
 
757
- if (file != undefined) {
758
- for (var k in file.post) {
759
- if (file.post.hasOwnProperty(k)) {
760
- uk = k;
761
- var match;
762
- while ((match = reg.exec(uk)) !== null) {
763
- uk = uk.replace(match[0], String.fromCharCode(parseInt("0x" + match[1], 16)));
764
- }
765
- unescapedPost[uk] = file.post[k];
766
- }
767
- }
758
+ if (file != undefined) {
759
+ for (var k in file.post) {
760
+ if (file.post.hasOwnProperty(k)) {
761
+ uk = k;
762
+ var match;
763
+ while ((match = reg.exec(uk)) !== null) {
764
+ uk = uk.replace(match[0], String.fromCharCode(parseInt("0x" + match[1], 16)));
765
+ }
766
+ unescapedPost[uk] = file.post[k];
767
+ }
768
+ }
768
769
 
769
- file.post = unescapedPost;
770
- }
770
+ file.post = unescapedPost;
771
+ }
771
772
 
772
- return file;
773
+ return file;
773
774
  };
774
775
 
775
776
  // Private: Called by Flash to see if JS can call in to Flash (test if External Interface is working)
776
777
  SWFUpload.prototype.testExternalInterface = function () {
777
- try {
778
- return this.callFlash("TestExternalInterface");
779
- } catch (ex) {
780
- return false;
781
- }
778
+ try {
779
+ return this.callFlash("TestExternalInterface");
780
+ } catch (ex) {
781
+ return false;
782
+ }
782
783
  };
783
784
 
784
785
  // Private: This event is called by Flash when it has finished loading. Don't modify this.
785
786
  // Use the swfupload_loaded_handler event setting to execute custom code when SWFUpload has loaded.
786
787
  SWFUpload.prototype.flashReady = function () {
787
- // Check that the movie element is loaded correctly with its ExternalInterface methods defined
788
- var movieElement = this.getMovieElement();
788
+ // Check that the movie element is loaded correctly with its ExternalInterface methods defined
789
+ var movieElement = this.getMovieElement();
790
+
791
+ if (!movieElement) {
792
+ this.debug("Flash called back ready but the flash movie can't be found.");
793
+ return;
794
+ }
789
795
 
790
- if (!movieElement) {
791
- this.debug("Flash called back ready but the flash movie can't be found.");
792
- return;
793
- }
796
+ this.cleanUp(movieElement);
794
797
 
795
- this.cleanUp(movieElement);
796
-
797
- this.queueEvent("swfupload_loaded_handler");
798
+ this.queueEvent("swfupload_loaded_handler");
798
799
  };
799
800
 
800
801
  // Private: removes Flash added fuctions to the DOM node to prevent memory leaks in IE.
801
802
  // This function is called by Flash each time the ExternalInterface functions are created.
802
803
  SWFUpload.prototype.cleanUp = function (movieElement) {
803
- // Pro-actively unhook all the Flash functions
804
- try {
805
- if (this.movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
806
- this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");
807
- for (var key in movieElement) {
808
- try {
809
- if (typeof(movieElement[key]) === "function") {
810
- movieElement[key] = null;
811
- }
812
- } catch (ex) {
813
- }
814
- }
815
- }
816
- } catch (ex1) {
817
-
818
- }
819
-
820
- // Fix Flashes own cleanup code so if the SWFMovie was removed from the page
821
- // it doesn't display errors.
822
- window["__flash__removeCallback"] = function (instance, name) {
823
- try {
824
- if (instance) {
825
- instance[name] = null;
826
- }
827
- } catch (flashEx) {
828
-
829
- }
830
- };
804
+ // Pro-actively unhook all the Flash functions
805
+ try {
806
+ if (this.movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
807
+ this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");
808
+ for (var key in movieElement) {
809
+ try {
810
+ if (typeof(movieElement[key]) === "function") {
811
+ movieElement[key] = null;
812
+ }
813
+ } catch (ex) {
814
+ }
815
+ }
816
+ }
817
+ } catch (ex1) {
818
+
819
+ }
820
+
821
+ // Fix Flashes own cleanup code so if the SWFMovie was removed from the page
822
+ // it doesn't display errors.
823
+ window["__flash__removeCallback"] = function (instance, name) {
824
+ try {
825
+ if (instance) {
826
+ instance[name] = null;
827
+ }
828
+ } catch (flashEx) {
829
+
830
+ }
831
+ };
831
832
 
832
833
  };
833
834
 
834
835
 
835
836
  /* This is a chance to do something before the browse window opens */
836
837
  SWFUpload.prototype.fileDialogStart = function () {
837
- this.queueEvent("file_dialog_start_handler");
838
+ this.queueEvent("file_dialog_start_handler");
838
839
  };
839
840
 
840
841
 
841
842
  /* Called when a file is successfully added to the queue. */
842
843
  SWFUpload.prototype.fileQueued = function (file) {
843
- file = this.unescapeFilePostParams(file);
844
- this.queueEvent("file_queued_handler", file);
844
+ file = this.unescapeFilePostParams(file);
845
+ this.queueEvent("file_queued_handler", file);
845
846
  };
846
847
 
847
848
 
848
849
  /* Handle errors that occur when an attempt to queue a file fails. */
849
850
  SWFUpload.prototype.fileQueueError = function (file, errorCode, message) {
850
- file = this.unescapeFilePostParams(file);
851
- this.queueEvent("file_queue_error_handler", [file, errorCode, message]);
851
+ file = this.unescapeFilePostParams(file);
852
+ this.queueEvent("file_queue_error_handler", [file, errorCode, message]);
852
853
  };
853
854
 
854
855
  /* Called after the file dialog has closed and the selected files have been queued.
855
- You could call startUpload here if you want the queued files to begin uploading immediately. */
856
+ You could call startUpload here if you want the queued files to begin uploading immediately. */
856
857
  SWFUpload.prototype.fileDialogComplete = function (numFilesSelected, numFilesQueued, numFilesInQueue) {
857
- this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued, numFilesInQueue]);
858
+ this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued, numFilesInQueue]);
858
859
  };
859
860
 
860
861
  SWFUpload.prototype.uploadStart = function (file) {
861
- file = this.unescapeFilePostParams(file);
862
- this.queueEvent("return_upload_start_handler", file);
862
+ file = this.unescapeFilePostParams(file);
863
+ this.queueEvent("return_upload_start_handler", file);
863
864
  };
864
865
 
865
866
  SWFUpload.prototype.returnUploadStart = function (file) {
866
- var returnValue;
867
- if (typeof this.settings.upload_start_handler === "function") {
868
- file = this.unescapeFilePostParams(file);
869
- returnValue = this.settings.upload_start_handler.call(this, file);
870
- } else if (this.settings.upload_start_handler != undefined) {
871
- throw "upload_start_handler must be a function";
872
- }
867
+ var returnValue;
868
+ if (typeof this.settings.upload_start_handler === "function") {
869
+ file = this.unescapeFilePostParams(file);
870
+ returnValue = this.settings.upload_start_handler.call(this, file);
871
+ } else if (this.settings.upload_start_handler != undefined) {
872
+ throw "upload_start_handler must be a function";
873
+ }
873
874
 
874
- // Convert undefined to true so if nothing is returned from the upload_start_handler it is
875
- // interpretted as 'true'.
876
- if (returnValue === undefined) {
877
- returnValue = true;
878
- }
879
-
880
- returnValue = !!returnValue;
881
-
882
- this.callFlash("ReturnUploadStart", [returnValue]);
883
- };
875
+ // Convert undefined to true so if nothing is returned from the upload_start_handler it is
876
+ // interpretted as 'true'.
877
+ if (returnValue === undefined) {
878
+ returnValue = true;
879
+ }
880
+
881
+ returnValue = !!returnValue;
884
882
 
883
+ this.callFlash("ReturnUploadStart", [returnValue]);
884
+ };
885
885
 
886
886
 
887
887
  SWFUpload.prototype.uploadProgress = function (file, bytesComplete, bytesTotal) {
888
- file = this.unescapeFilePostParams(file);
889
- this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]);
888
+ file = this.unescapeFilePostParams(file);
889
+ this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]);
890
890
  };
891
891
 
892
892
  SWFUpload.prototype.uploadError = function (file, errorCode, message) {
893
- file = this.unescapeFilePostParams(file);
894
- this.queueEvent("upload_error_handler", [file, errorCode, message]);
893
+ file = this.unescapeFilePostParams(file);
894
+ this.queueEvent("upload_error_handler", [file, errorCode, message]);
895
895
  };
896
896
 
897
897
  SWFUpload.prototype.uploadSuccess = function (file, serverData, responseReceived) {
898
- file = this.unescapeFilePostParams(file);
899
- this.queueEvent("upload_success_handler", [file, serverData, responseReceived]);
898
+ file = this.unescapeFilePostParams(file);
899
+ this.queueEvent("upload_success_handler", [file, serverData, responseReceived]);
900
900
  };
901
901
 
902
902
  SWFUpload.prototype.uploadComplete = function (file) {
903
- file = this.unescapeFilePostParams(file);
904
- this.queueEvent("upload_complete_handler", file);
903
+ file = this.unescapeFilePostParams(file);
904
+ this.queueEvent("upload_complete_handler", file);
905
905
  };
906
906
 
907
907
  /* Called by SWFUpload JavaScript and Flash functions when debug is enabled. By default it writes messages to the
908
- internal debug console. You can override this event and have messages written where you want. */
908
+ internal debug console. You can override this event and have messages written where you want. */
909
909
  SWFUpload.prototype.debug = function (message) {
910
- this.queueEvent("debug_handler", message);
910
+ this.queueEvent("debug_handler", message);
911
911
  };
912
912
 
913
913
 
914
914
  /* **********************************
915
- Debug Console
916
- The debug console is a self contained, in page location
917
- for debug message to be sent. The Debug Console adds
918
- itself to the body if necessary.
919
-
920
- The console is automatically scrolled as messages appear.
921
-
922
- If you are using your own debug handler or when you deploy to production and
923
- have debug disabled you can remove these functions to reduce the file size
924
- and complexity.
925
- ********************************** */
926
-
915
+ Debug Console
916
+ The debug console is a self contained, in page location
917
+ for debug message to be sent. The Debug Console adds
918
+ itself to the body if necessary.
919
+
920
+ The console is automatically scrolled as messages appear.
921
+
922
+ If you are using your own debug handler or when you deploy to production and
923
+ have debug disabled you can remove these functions to reduce the file size
924
+ and complexity.
925
+ ********************************** */
926
+
927
927
  // Private: debugMessage is the default debug_handler. If you want to print debug messages
928
928
  // call the debug() function. When overriding the function your own function should
929
929
  // check to see if the debug setting is true before outputting debug information.
930
930
  SWFUpload.prototype.debugMessage = function (message) {
931
- if (this.settings.debug) {
932
- var exceptionMessage, exceptionValues = [];
933
-
934
- // Check for an exception object and print it nicely
935
- if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") {
936
- for (var key in message) {
937
- if (message.hasOwnProperty(key)) {
938
- exceptionValues.push(key + ": " + message[key]);
939
- }
940
- }
941
- exceptionMessage = exceptionValues.join("\n") || "";
942
- exceptionValues = exceptionMessage.split("\n");
943
- exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: ");
944
- SWFUpload.Console.writeLine(exceptionMessage);
945
- } else {
946
- SWFUpload.Console.writeLine(message);
947
- }
948
- }
931
+ if (this.settings.debug) {
932
+ var exceptionMessage, exceptionValues = [];
933
+
934
+ // Check for an exception object and print it nicely
935
+ if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") {
936
+ for (var key in message) {
937
+ if (message.hasOwnProperty(key)) {
938
+ exceptionValues.push(key + ": " + message[key]);
939
+ }
940
+ }
941
+ exceptionMessage = exceptionValues.join("\n") || "";
942
+ exceptionValues = exceptionMessage.split("\n");
943
+ exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: ");
944
+ SWFUpload.Console.writeLine(exceptionMessage);
945
+ } else {
946
+ SWFUpload.Console.writeLine(message);
947
+ }
948
+ }
949
949
  };
950
950
 
951
951
  SWFUpload.Console = {};
952
952
  SWFUpload.Console.writeLine = function (message) {
953
- var console, documentForm;
954
-
955
- try {
956
- console = document.getElementById("SWFUpload_Console");
957
-
958
- if (!console) {
959
- documentForm = document.createElement("form");
960
- document.getElementsByTagName("body")[0].appendChild(documentForm);
961
-
962
- console = document.createElement("textarea");
963
- console.id = "SWFUpload_Console";
964
- console.style.fontFamily = "monospace";
965
- console.setAttribute("wrap", "off");
966
- console.wrap = "off";
967
- console.style.overflow = "auto";
968
- console.style.width = "700px";
969
- console.style.height = "350px";
970
- console.style.margin = "5px";
971
- documentForm.appendChild(console);
972
- }
973
-
974
- console.value += message + "\n";
975
-
976
- console.scrollTop = console.scrollHeight - console.clientHeight;
977
- } catch (ex) {
978
- alert("Exception: " + ex.name + " Message: " + ex.message);
979
- }
953
+ var console, documentForm;
954
+
955
+ try {
956
+ console = document.getElementById("SWFUpload_Console");
957
+
958
+ if (!console) {
959
+ documentForm = document.createElement("form");
960
+ document.getElementsByTagName("body")[0].appendChild(documentForm);
961
+
962
+ console = document.createElement("textarea");
963
+ console.id = "SWFUpload_Console";
964
+ console.style.fontFamily = "monospace";
965
+ console.setAttribute("wrap", "off");
966
+ console.wrap = "off";
967
+ console.style.overflow = "auto";
968
+ console.style.width = "700px";
969
+ console.style.height = "350px";
970
+ console.style.margin = "5px";
971
+ documentForm.appendChild(console);
972
+ }
973
+
974
+ console.value += message + "\n";
975
+
976
+ console.scrollTop = console.scrollHeight - console.clientHeight;
977
+ } catch (ex) {
978
+ alert("Exception: " + ex.name + " Message: " + ex.message);
979
+ }
980
980
  };