sunrise-core 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (268) hide show
  1. data/README.rdoc +46 -0
  2. data/Rakefile +44 -0
  3. data/app/controllers/manage/assets_controller.rb +70 -0
  4. data/app/controllers/manage/base_controller.rb +24 -0
  5. data/app/controllers/manage/pages_controller.rb +37 -0
  6. data/app/controllers/manage/settings_controller.rb +24 -0
  7. data/app/controllers/manage/structures_controller.rb +45 -0
  8. data/app/controllers/manage/users_controller.rb +78 -0
  9. data/app/controllers/pages_controller.rb +22 -0
  10. data/app/views/layouts/manage.html.erb +40 -0
  11. data/app/views/manage/assets/_collection.html.erb +32 -0
  12. data/app/views/manage/assets/_picture.html.erb +10 -0
  13. data/app/views/manage/assets/_swfscript.html.erb +51 -0
  14. data/app/views/manage/headers/_form.html.erb +14 -0
  15. data/app/views/manage/pages/_form.html.erb +11 -0
  16. data/app/views/manage/pages/edit.html.erb +6 -0
  17. data/app/views/manage/pages/new.html.erb +6 -0
  18. data/app/views/manage/settings/_form.html.erb +22 -0
  19. data/app/views/manage/settings/index.html.erb +14 -0
  20. data/app/views/manage/shared/_head.html.erb +41 -0
  21. data/app/views/manage/shared/_locale.html.erb +8 -0
  22. data/app/views/manage/shared/_notice.html.erb +7 -0
  23. data/app/views/manage/shared/_panel.html.erb +34 -0
  24. data/app/views/manage/structures/_form.html.erb +28 -0
  25. data/app/views/manage/structures/_structure.html.erb +34 -0
  26. data/app/views/manage/structures/edit.html.erb +6 -0
  27. data/app/views/manage/structures/index.html.erb +51 -0
  28. data/app/views/manage/structures/new.html.erb +6 -0
  29. data/app/views/manage/users/_form.html.erb +15 -0
  30. data/app/views/manage/users/_model_filter.html.erb +33 -0
  31. data/app/views/manage/users/_user.html.erb +55 -0
  32. data/app/views/manage/users/edit.html.erb +6 -0
  33. data/app/views/manage/users/index.html.erb +36 -0
  34. data/app/views/manage/users/new.html.erb +6 -0
  35. data/app/views/manage/users/show.html.erb +19 -0
  36. data/config/locales/defaults/en.yml +149 -0
  37. data/config/locales/defaults/pluralize.rb +6 -0
  38. data/config/locales/defaults/ru.yml +170 -0
  39. data/config/locales/defaults/uk.yml +238 -0
  40. data/config/locales/devise.en.yml +39 -0
  41. data/config/locales/devise.ru.yml +41 -0
  42. data/config/locales/devise.uk.yml +41 -0
  43. data/config/locales/manage/en.yml +248 -0
  44. data/config/locales/manage/ru.yml +248 -0
  45. data/config/locales/manage/uk.yml +248 -0
  46. data/config/routes.rb +24 -0
  47. data/lib/generators/sunrise/USAGE +7 -0
  48. data/lib/generators/sunrise/install_generator.rb +120 -0
  49. data/lib/generators/sunrise/templates/config/application.yml +4 -0
  50. data/lib/generators/sunrise/templates/config/database.yml +34 -0
  51. data/lib/generators/sunrise/templates/config/logrotate-config +9 -0
  52. data/lib/generators/sunrise/templates/config/nginx-config-passenger +51 -0
  53. data/lib/generators/sunrise/templates/config/seeds.rb +25 -0
  54. data/lib/generators/sunrise/templates/config/sunrise.rb +7 -0
  55. data/lib/generators/sunrise/templates/helpers/manage/assets_helper.rb +16 -0
  56. data/lib/generators/sunrise/templates/helpers/manage/base_helper.rb +81 -0
  57. data/lib/generators/sunrise/templates/helpers/manage/pages_helper.rb +2 -0
  58. data/lib/generators/sunrise/templates/helpers/manage/settings_helper.rb +2 -0
  59. data/lib/generators/sunrise/templates/helpers/manage/structures_helper.rb +12 -0
  60. data/lib/generators/sunrise/templates/helpers/manage/users_helper.rb +6 -0
  61. data/lib/generators/sunrise/templates/images/manage/add_post_bot.gif +0 -0
  62. data/lib/generators/sunrise/templates/images/manage/add_post_top.gif +0 -0
  63. data/lib/generators/sunrise/templates/images/manage/add_white_bot.gif +0 -0
  64. data/lib/generators/sunrise/templates/images/manage/add_white_top.gif +0 -0
  65. data/lib/generators/sunrise/templates/images/manage/arrow.png +0 -0
  66. data/lib/generators/sunrise/templates/images/manage/back_but_lc.gif +0 -0
  67. data/lib/generators/sunrise/templates/images/manage/back_but_rc.gif +0 -0
  68. data/lib/generators/sunrise/templates/images/manage/bot_corn.gif +0 -0
  69. data/lib/generators/sunrise/templates/images/manage/bot_duo_corn.gif +0 -0
  70. data/lib/generators/sunrise/templates/images/manage/but_bg.png +0 -0
  71. data/lib/generators/sunrise/templates/images/manage/but_block_lc.gif +0 -0
  72. data/lib/generators/sunrise/templates/images/manage/but_block_rc.gif +0 -0
  73. data/lib/generators/sunrise/templates/images/manage/but_freze_lc.gif +0 -0
  74. data/lib/generators/sunrise/templates/images/manage/but_freze_rc.gif +0 -0
  75. data/lib/generators/sunrise/templates/images/manage/but_gr.gif +0 -0
  76. data/lib/generators/sunrise/templates/images/manage/but_gr_l.gif +0 -0
  77. data/lib/generators/sunrise/templates/images/manage/but_gr_r.gif +0 -0
  78. data/lib/generators/sunrise/templates/images/manage/but_search.gif +0 -0
  79. data/lib/generators/sunrise/templates/images/manage/but_unfreze_lc.gif +0 -0
  80. data/lib/generators/sunrise/templates/images/manage/but_unfreze_rc.gif +0 -0
  81. data/lib/generators/sunrise/templates/images/manage/button_add_foto.gif +0 -0
  82. data/lib/generators/sunrise/templates/images/manage/button_add_foto_ru.gif +0 -0
  83. data/lib/generators/sunrise/templates/images/manage/button_add_foto_ua.gif +0 -0
  84. data/lib/generators/sunrise/templates/images/manage/button_add_foto_uk.gif +0 -0
  85. data/lib/generators/sunrise/templates/images/manage/cancelbutton.gif +0 -0
  86. data/lib/generators/sunrise/templates/images/manage/dark_arr.gif +0 -0
  87. data/lib/generators/sunrise/templates/images/manage/dark_arr_left.gif +0 -0
  88. data/lib/generators/sunrise/templates/images/manage/dark_cross_ico.gif +0 -0
  89. data/lib/generators/sunrise/templates/images/manage/dot.gif +0 -0
  90. data/lib/generators/sunrise/templates/images/manage/duo_bg.gif +0 -0
  91. data/lib/generators/sunrise/templates/images/manage/duo_bg_small.gif +0 -0
  92. data/lib/generators/sunrise/templates/images/manage/duo_bg_small_blocked.gif +0 -0
  93. data/lib/generators/sunrise/templates/images/manage/duo_bg_small_frozed.gif +0 -0
  94. data/lib/generators/sunrise/templates/images/manage/duo_bg_small_notact.gif +0 -0
  95. data/lib/generators/sunrise/templates/images/manage/duo_bot_small.gif +0 -0
  96. data/lib/generators/sunrise/templates/images/manage/duo_bot_small_blocked.gif +0 -0
  97. data/lib/generators/sunrise/templates/images/manage/duo_bot_small_frozed.gif +0 -0
  98. data/lib/generators/sunrise/templates/images/manage/duo_bot_small_notact.gif +0 -0
  99. data/lib/generators/sunrise/templates/images/manage/duo_top_small.gif +0 -0
  100. data/lib/generators/sunrise/templates/images/manage/duo_top_small_blocked.gif +0 -0
  101. data/lib/generators/sunrise/templates/images/manage/duo_top_small_frozed.gif +0 -0
  102. data/lib/generators/sunrise/templates/images/manage/duo_top_small_notact.gif +0 -0
  103. data/lib/generators/sunrise/templates/images/manage/edit_white_top.gif +0 -0
  104. data/lib/generators/sunrise/templates/images/manage/empty.gif +0 -0
  105. data/lib/generators/sunrise/templates/images/manage/filter_bot_bg.gif +0 -0
  106. data/lib/generators/sunrise/templates/images/manage/filter_top_bg.gif +0 -0
  107. data/lib/generators/sunrise/templates/images/manage/flag_en.gif +0 -0
  108. data/lib/generators/sunrise/templates/images/manage/flag_en_nonact.gif +0 -0
  109. data/lib/generators/sunrise/templates/images/manage/flag_ru.gif +0 -0
  110. data/lib/generators/sunrise/templates/images/manage/flag_ru_nonact.gif +0 -0
  111. data/lib/generators/sunrise/templates/images/manage/flag_ua.gif +0 -0
  112. data/lib/generators/sunrise/templates/images/manage/flag_ua_nonact.gif +0 -0
  113. data/lib/generators/sunrise/templates/images/manage/foto.jpg +0 -0
  114. data/lib/generators/sunrise/templates/images/manage/ico_add.gif +0 -0
  115. data/lib/generators/sunrise/templates/images/manage/ico_del.gif +0 -0
  116. data/lib/generators/sunrise/templates/images/manage/ico_down.gif +0 -0
  117. data/lib/generators/sunrise/templates/images/manage/ico_edit.gif +0 -0
  118. data/lib/generators/sunrise/templates/images/manage/ico_settings.gif +0 -0
  119. data/lib/generators/sunrise/templates/images/manage/ico_up.gif +0 -0
  120. data/lib/generators/sunrise/templates/images/manage/input_bg.gif +0 -0
  121. data/lib/generators/sunrise/templates/images/manage/l_but_corn.gif +0 -0
  122. data/lib/generators/sunrise/templates/images/manage/minimise_but.gif +0 -0
  123. data/lib/generators/sunrise/templates/images/manage/mp3.png +0 -0
  124. data/lib/generators/sunrise/templates/images/manage/page_arr_hover.png +0 -0
  125. data/lib/generators/sunrise/templates/images/manage/page_next_arr.gif +0 -0
  126. data/lib/generators/sunrise/templates/images/manage/page_num_hover.gif +0 -0
  127. data/lib/generators/sunrise/templates/images/manage/page_prev_arr.gif +0 -0
  128. data/lib/generators/sunrise/templates/images/manage/panel/l_but_corn.gif +0 -0
  129. data/lib/generators/sunrise/templates/images/manage/panel/maximise_but.gif +0 -0
  130. data/lib/generators/sunrise/templates/images/manage/panel/r_but_corn.gif +0 -0
  131. data/lib/generators/sunrise/templates/images/manage/panel/top_menu_arr.gif +0 -0
  132. data/lib/generators/sunrise/templates/images/manage/panel/user_pic.gif +0 -0
  133. data/lib/generators/sunrise/templates/images/manage/preloader.gif +0 -0
  134. data/lib/generators/sunrise/templates/images/manage/r_but_corn.gif +0 -0
  135. data/lib/generators/sunrise/templates/images/manage/select_bg.gif +0 -0
  136. data/lib/generators/sunrise/templates/images/manage/select_corn.gif +0 -0
  137. data/lib/generators/sunrise/templates/images/manage/struct_corn_lg.gif +0 -0
  138. data/lib/generators/sunrise/templates/images/manage/struct_corn_llg.gif +0 -0
  139. data/lib/generators/sunrise/templates/images/manage/struct_corn_lw.gif +0 -0
  140. data/lib/generators/sunrise/templates/images/manage/struct_corn_rg.gif +0 -0
  141. data/lib/generators/sunrise/templates/images/manage/struct_corn_rlg.gif +0 -0
  142. data/lib/generators/sunrise/templates/images/manage/struct_corn_rw.gif +0 -0
  143. data/lib/generators/sunrise/templates/images/manage/tab_gl.gif +0 -0
  144. data/lib/generators/sunrise/templates/images/manage/tab_gr.gif +0 -0
  145. data/lib/generators/sunrise/templates/images/manage/tab_wl.gif +0 -0
  146. data/lib/generators/sunrise/templates/images/manage/tab_wr.gif +0 -0
  147. data/lib/generators/sunrise/templates/images/manage/top_corn.gif +0 -0
  148. data/lib/generators/sunrise/templates/images/manage/top_duo_corn.gif +0 -0
  149. data/lib/generators/sunrise/templates/images/manage/top_menu_arr.gif +0 -0
  150. data/lib/generators/sunrise/templates/images/manage/transp_cross.png +0 -0
  151. data/lib/generators/sunrise/templates/images/manage/upload_progress.gif +0 -0
  152. data/lib/generators/sunrise/templates/images/manage/user_act_lc.gif +0 -0
  153. data/lib/generators/sunrise/templates/images/manage/user_act_rc.gif +0 -0
  154. data/lib/generators/sunrise/templates/images/manage/user_ico.gif +0 -0
  155. data/lib/generators/sunrise/templates/images/manage/user_pic.gif +0 -0
  156. data/lib/generators/sunrise/templates/images/manage/user_pic_small.gif +0 -0
  157. data/lib/generators/sunrise/templates/images/manage/user_pic_thumb.gif +0 -0
  158. data/lib/generators/sunrise/templates/javascripts/datepicker/jquery-ui-i18n.js +1176 -0
  159. data/lib/generators/sunrise/templates/javascripts/datepicker/jquery.ui.datepicker-ru.js +37 -0
  160. data/lib/generators/sunrise/templates/javascripts/datepicker/jquery.ui.datepicker-uk.js +37 -0
  161. data/lib/generators/sunrise/templates/javascripts/jquery-ui-timepicker-addon.js +911 -0
  162. data/lib/generators/sunrise/templates/javascripts/jquery.cookie.js +97 -0
  163. data/lib/generators/sunrise/templates/javascripts/jquery.fancybox-1.3.4.pack.js +46 -0
  164. data/lib/generators/sunrise/templates/javascripts/jquery.tmpl.min.js +10 -0
  165. data/lib/generators/sunrise/templates/javascripts/manage.js +290 -0
  166. data/lib/generators/sunrise/templates/javascripts/preloader.js +47 -0
  167. data/lib/generators/sunrise/templates/javascripts/swfupload/fileprogress.js +114 -0
  168. data/lib/generators/sunrise/templates/javascripts/swfupload/handlers.js +164 -0
  169. data/lib/generators/sunrise/templates/javascripts/swfupload/swfupload.js +1134 -0
  170. data/lib/generators/sunrise/templates/javascripts/swfupload/swfupload.queue.js +98 -0
  171. data/lib/generators/sunrise/templates/javascripts/swfupload/swfupload.swf +0 -0
  172. data/lib/generators/sunrise/templates/migrate/create_assets.rb +28 -0
  173. data/lib/generators/sunrise/templates/migrate/create_headers.rb +20 -0
  174. data/lib/generators/sunrise/templates/migrate/create_pages.rb +17 -0
  175. data/lib/generators/sunrise/templates/migrate/create_roles.rb +16 -0
  176. data/lib/generators/sunrise/templates/migrate/create_structures.rb +27 -0
  177. data/lib/generators/sunrise/templates/migrate/create_users.rb +29 -0
  178. data/lib/generators/sunrise/templates/models/defaults/ability.rb +38 -0
  179. data/lib/generators/sunrise/templates/models/defaults/asset.rb +7 -0
  180. data/lib/generators/sunrise/templates/models/defaults/attachment_file.rb +33 -0
  181. data/lib/generators/sunrise/templates/models/defaults/avatar.rb +36 -0
  182. data/lib/generators/sunrise/templates/models/defaults/header.rb +5 -0
  183. data/lib/generators/sunrise/templates/models/defaults/page.rb +5 -0
  184. data/lib/generators/sunrise/templates/models/defaults/picture.rb +34 -0
  185. data/lib/generators/sunrise/templates/models/defaults/position_type.rb +7 -0
  186. data/lib/generators/sunrise/templates/models/defaults/role.rb +20 -0
  187. data/lib/generators/sunrise/templates/models/defaults/role_type.rb +8 -0
  188. data/lib/generators/sunrise/templates/models/defaults/structure.rb +11 -0
  189. data/lib/generators/sunrise/templates/models/defaults/structure_type.rb +9 -0
  190. data/lib/generators/sunrise/templates/models/defaults/user.rb +51 -0
  191. data/lib/generators/sunrise/templates/stylesheets/application.css +1 -0
  192. data/lib/generators/sunrise/templates/stylesheets/fancybox/images/blank.gif +0 -0
  193. data/lib/generators/sunrise/templates/stylesheets/fancybox/images/fancy_close.png +0 -0
  194. data/lib/generators/sunrise/templates/stylesheets/fancybox/images/fancy_loading.png +0 -0
  195. data/lib/generators/sunrise/templates/stylesheets/fancybox/images/fancy_nav_left.png +0 -0
  196. data/lib/generators/sunrise/templates/stylesheets/fancybox/images/fancy_nav_right.png +0 -0
  197. data/lib/generators/sunrise/templates/stylesheets/fancybox/images/fancy_shadow_e.png +0 -0
  198. data/lib/generators/sunrise/templates/stylesheets/fancybox/images/fancy_shadow_n.png +0 -0
  199. data/lib/generators/sunrise/templates/stylesheets/fancybox/images/fancy_shadow_ne.png +0 -0
  200. data/lib/generators/sunrise/templates/stylesheets/fancybox/images/fancy_shadow_nw.png +0 -0
  201. data/lib/generators/sunrise/templates/stylesheets/fancybox/images/fancy_shadow_s.png +0 -0
  202. data/lib/generators/sunrise/templates/stylesheets/fancybox/images/fancy_shadow_se.png +0 -0
  203. data/lib/generators/sunrise/templates/stylesheets/fancybox/images/fancy_shadow_sw.png +0 -0
  204. data/lib/generators/sunrise/templates/stylesheets/fancybox/images/fancy_shadow_w.png +0 -0
  205. data/lib/generators/sunrise/templates/stylesheets/fancybox/images/fancy_title_left.png +0 -0
  206. data/lib/generators/sunrise/templates/stylesheets/fancybox/images/fancy_title_main.png +0 -0
  207. data/lib/generators/sunrise/templates/stylesheets/fancybox/images/fancy_title_over.png +0 -0
  208. data/lib/generators/sunrise/templates/stylesheets/fancybox/images/fancy_title_right.png +0 -0
  209. data/lib/generators/sunrise/templates/stylesheets/fancybox/images/fancybox-x.png +0 -0
  210. data/lib/generators/sunrise/templates/stylesheets/fancybox/images/fancybox-y.png +0 -0
  211. data/lib/generators/sunrise/templates/stylesheets/fancybox/images/fancybox.png +0 -0
  212. data/lib/generators/sunrise/templates/stylesheets/fancybox/jquery.fancybox-1.3.4.css +359 -0
  213. data/lib/generators/sunrise/templates/stylesheets/manage/ie.css +16 -0
  214. data/lib/generators/sunrise/templates/stylesheets/manage/main.css +1074 -0
  215. data/lib/generators/sunrise/templates/stylesheets/manage/panel.css +126 -0
  216. data/lib/generators/sunrise/templates/stylesheets/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  217. data/lib/generators/sunrise/templates/stylesheets/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  218. data/lib/generators/sunrise/templates/stylesheets/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  219. data/lib/generators/sunrise/templates/stylesheets/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  220. data/lib/generators/sunrise/templates/stylesheets/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  221. data/lib/generators/sunrise/templates/stylesheets/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  222. data/lib/generators/sunrise/templates/stylesheets/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  223. data/lib/generators/sunrise/templates/stylesheets/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  224. data/lib/generators/sunrise/templates/stylesheets/smoothness/images/ui-icons_222222_256x240.png +0 -0
  225. data/lib/generators/sunrise/templates/stylesheets/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  226. data/lib/generators/sunrise/templates/stylesheets/smoothness/images/ui-icons_454545_256x240.png +0 -0
  227. data/lib/generators/sunrise/templates/stylesheets/smoothness/images/ui-icons_888888_256x240.png +0 -0
  228. data/lib/generators/sunrise/templates/stylesheets/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  229. data/lib/generators/sunrise/templates/stylesheets/smoothness/jquery-ui-1.8.6.custom.css +572 -0
  230. data/lib/generators/sunrise/templates/sweepers/page_sweeper.rb +22 -0
  231. data/lib/generators/sunrise/templates/sweepers/structure_sweeper.rb +29 -0
  232. data/lib/generators/sunrise/templates/sweepers/user_sweeper.rb +17 -0
  233. data/lib/generators/sunrise/templates/views/layouts/application.html.erb +37 -0
  234. data/lib/generators/sunrise/templates/views/pages/show.html.erb +2 -0
  235. data/lib/generators/sunrise/templates/views/shared/_notice.html.erb +17 -0
  236. data/lib/sunrise/controllers/head_options.rb +40 -0
  237. data/lib/sunrise/core.rb +80 -0
  238. data/lib/sunrise/core_ext/array.rb +22 -0
  239. data/lib/sunrise/core_ext/i18n.rb +21 -0
  240. data/lib/sunrise/core_ext/string.rb +28 -0
  241. data/lib/sunrise/core_ext.rb +3 -0
  242. data/lib/sunrise/core_plugins.rb +32 -0
  243. data/lib/sunrise/engine.rb +45 -0
  244. data/lib/sunrise/model_filter.rb +158 -0
  245. data/lib/sunrise/models/asset.rb +102 -0
  246. data/lib/sunrise/models/header.rb +34 -0
  247. data/lib/sunrise/models/page.rb +27 -0
  248. data/lib/sunrise/models/position_type.rb +15 -0
  249. data/lib/sunrise/models/role.rb +28 -0
  250. data/lib/sunrise/models/role_type.rb +15 -0
  251. data/lib/sunrise/models/structure.rb +43 -0
  252. data/lib/sunrise/models/structure_type.rb +15 -0
  253. data/lib/sunrise/models/user.rb +124 -0
  254. data/lib/sunrise/plugin.rb +46 -0
  255. data/lib/sunrise/plugins.rb +56 -0
  256. data/lib/sunrise/system_settings.rb +65 -0
  257. data/lib/sunrise/utils/accessible_attributes.rb +32 -0
  258. data/lib/sunrise/utils/header.rb +29 -0
  259. data/lib/sunrise/utils/i18n_backend.rb +87 -0
  260. data/lib/sunrise/utils/mysql.rb +105 -0
  261. data/lib/sunrise/utils/settingslogic.rb +164 -0
  262. data/lib/sunrise/utils/transliteration.rb +72 -0
  263. data/lib/sunrise/version.rb +3 -0
  264. data/lib/sunrise/views/form_builder.rb +44 -0
  265. data/lib/sunrise/views/helpers.rb +190 -0
  266. data/lib/sunrise/views/inputs/date_time_input.rb +46 -0
  267. data/lib/sunrise-core.rb +2 -0
  268. metadata +492 -0
@@ -0,0 +1,1134 @@
1
+ /**
2
+ * SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com
3
+ *
4
+ * mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/, http://www.vinterwebb.se/
5
+ *
6
+ * SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilz�n and Mammon Media and is released under the MIT License:
7
+ * http://www.opensource.org/licenses/mit-license.php
8
+ *
9
+ * SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License:
10
+ * http://www.opensource.org/licenses/mit-license.php
11
+ *
12
+ * SWFObject v2.2 <http://code.google.com/p/swfobject/>
13
+ * is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
14
+ */
15
+
16
+
17
+
18
+ /* ******************* */
19
+ /* Constructor & Init */
20
+ /* ******************* */
21
+ var SWFUpload;
22
+ var swfobject;
23
+
24
+ if (SWFUpload == undefined) {
25
+ SWFUpload = function (settings) {
26
+ this.initSWFUpload(settings);
27
+ };
28
+ }
29
+
30
+ SWFUpload.prototype.initSWFUpload = function (userSettings) {
31
+ try {
32
+ this.customSettings = {}; // A container where developers can place their own settings associated with this instance.
33
+ this.settings = {};
34
+ this.eventQueue = [];
35
+ this.movieName = "SWFUpload_" + SWFUpload.movieCount++;
36
+ this.movieElement = null;
37
+
38
+
39
+ // Setup global control tracking
40
+ SWFUpload.instances[this.movieName] = this;
41
+
42
+ // Load the settings. Load the Flash movie.
43
+ this.initSettings(userSettings);
44
+ this.loadSupport();
45
+ if (this.swfuploadPreload()) {
46
+ this.loadFlash();
47
+ }
48
+
49
+ this.displayDebugInfo();
50
+ } catch (ex) {
51
+ delete SWFUpload.instances[this.movieName];
52
+ throw ex;
53
+ }
54
+ };
55
+
56
+ /* *************** */
57
+ /* Static Members */
58
+ /* *************** */
59
+ SWFUpload.instances = {};
60
+ SWFUpload.movieCount = 0;
61
+ SWFUpload.version = "2.5.0 2010-01-15 Beta 2";
62
+ SWFUpload.QUEUE_ERROR = {
63
+ QUEUE_LIMIT_EXCEEDED : -100,
64
+ FILE_EXCEEDS_SIZE_LIMIT : -110,
65
+ ZERO_BYTE_FILE : -120,
66
+ INVALID_FILETYPE : -130
67
+ };
68
+ SWFUpload.UPLOAD_ERROR = {
69
+ HTTP_ERROR : -200,
70
+ MISSING_UPLOAD_URL : -210,
71
+ IO_ERROR : -220,
72
+ SECURITY_ERROR : -230,
73
+ UPLOAD_LIMIT_EXCEEDED : -240,
74
+ UPLOAD_FAILED : -250,
75
+ SPECIFIED_FILE_ID_NOT_FOUND : -260,
76
+ FILE_VALIDATION_FAILED : -270,
77
+ FILE_CANCELLED : -280,
78
+ UPLOAD_STOPPED : -290,
79
+ RESIZE : -300
80
+ };
81
+ SWFUpload.FILE_STATUS = {
82
+ QUEUED : -1,
83
+ IN_PROGRESS : -2,
84
+ ERROR : -3,
85
+ COMPLETE : -4,
86
+ CANCELLED : -5
87
+ };
88
+ SWFUpload.UPLOAD_TYPE = {
89
+ NORMAL : -1,
90
+ RESIZED : -2
91
+ };
92
+
93
+ SWFUpload.BUTTON_ACTION = {
94
+ SELECT_FILE : -100,
95
+ SELECT_FILES : -110,
96
+ START_UPLOAD : -120,
97
+ JAVASCRIPT : -130, // DEPRECATED
98
+ NONE : -130
99
+ };
100
+ SWFUpload.CURSOR = {
101
+ ARROW : -1,
102
+ HAND : -2
103
+ };
104
+ SWFUpload.WINDOW_MODE = {
105
+ WINDOW : "window",
106
+ TRANSPARENT : "transparent",
107
+ OPAQUE : "opaque"
108
+ };
109
+
110
+ SWFUpload.RESIZE_ENCODING = {
111
+ JPEG : -1,
112
+ PNG : -2
113
+ };
114
+
115
+ // Private: takes a URL, determines if it is relative and converts to an absolute URL
116
+ // using the current site. Only processes the URL if it can, otherwise returns the URL untouched
117
+ SWFUpload.completeURL = function (url) {
118
+ try {
119
+ var path = "", indexSlash = -1;
120
+ if (typeof(url) !== "string" || url.match(/^https?:\/\//i) || url.match(/^\//) || url === "") {
121
+ return url;
122
+ }
123
+
124
+ indexSlash = window.location.pathname.lastIndexOf("/");
125
+ if (indexSlash <= 0) {
126
+ path = "/";
127
+ } else {
128
+ path = window.location.pathname.substr(0, indexSlash) + "/";
129
+ }
130
+
131
+ return path + url;
132
+ } catch (ex) {
133
+ return url;
134
+ }
135
+ };
136
+
137
+ // Public: assign a new function to onload to use swfobject's domLoad functionality
138
+ SWFUpload.onload = function () {};
139
+
140
+
141
+ /* ******************** */
142
+ /* Instance Members */
143
+ /* ******************** */
144
+
145
+ // Private: initSettings ensures that all the
146
+ // settings are set, getting a default value if one was not assigned.
147
+ SWFUpload.prototype.initSettings = function (userSettings) {
148
+ this.user_settings = userSettings;
149
+
150
+ this.ensureDefault = function (settingName, defaultValue) {
151
+ var setting = this.user_settings[settingName];
152
+ if (setting != undefined) {
153
+ this.settings[settingName] = setting;
154
+ } else {
155
+ this.settings[settingName] = defaultValue;
156
+ }
157
+ };
158
+
159
+ // Upload backend settings
160
+ this.ensureDefault("upload_url", "");
161
+ this.ensureDefault("preserve_relative_urls", false);
162
+ this.ensureDefault("file_post_name", "Filedata");
163
+ this.ensureDefault("post_params", {});
164
+ this.ensureDefault("use_query_string", false);
165
+ this.ensureDefault("requeue_on_error", false);
166
+ this.ensureDefault("http_success", []);
167
+ this.ensureDefault("assume_success_timeout", 0);
168
+
169
+ // File Settings
170
+ this.ensureDefault("file_types", "*.*");
171
+ this.ensureDefault("file_types_description", "All Files");
172
+ this.ensureDefault("file_size_limit", 0); // Default zero means "unlimited"
173
+ this.ensureDefault("file_upload_limit", 0);
174
+ this.ensureDefault("file_queue_limit", 0);
175
+
176
+ // Flash Settings
177
+ this.ensureDefault("flash_url", "swfupload.swf");
178
+ this.ensureDefault("flash9_url", "swfupload_fp9.swf");
179
+ this.ensureDefault("prevent_swf_caching", true);
180
+
181
+ // Button Settings
182
+ this.ensureDefault("button_image_url", "");
183
+ this.ensureDefault("button_width", 1);
184
+ this.ensureDefault("button_height", 1);
185
+ this.ensureDefault("button_text", "");
186
+ this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;");
187
+ this.ensureDefault("button_text_top_padding", 0);
188
+ this.ensureDefault("button_text_left_padding", 0);
189
+ this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES);
190
+ this.ensureDefault("button_disabled", false);
191
+ this.ensureDefault("button_placeholder_id", "");
192
+ this.ensureDefault("button_placeholder", null);
193
+ this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW);
194
+ this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW);
195
+
196
+ // Debug Settings
197
+ this.ensureDefault("debug", false);
198
+ this.settings.debug_enabled = this.settings.debug; // Here to maintain v2 API
199
+
200
+ // Event Handlers
201
+ this.settings.return_upload_start_handler = this.returnUploadStart;
202
+ this.ensureDefault("swfupload_preload_handler", null);
203
+ this.ensureDefault("swfupload_load_failed_handler", null);
204
+ this.ensureDefault("swfupload_loaded_handler", null);
205
+ this.ensureDefault("file_dialog_start_handler", null);
206
+ this.ensureDefault("file_queued_handler", null);
207
+ this.ensureDefault("file_queue_error_handler", null);
208
+ this.ensureDefault("file_dialog_complete_handler", null);
209
+
210
+ this.ensureDefault("upload_resize_start_handler", null);
211
+ this.ensureDefault("upload_start_handler", null);
212
+ this.ensureDefault("upload_progress_handler", null);
213
+ this.ensureDefault("upload_error_handler", null);
214
+ this.ensureDefault("upload_success_handler", null);
215
+ this.ensureDefault("upload_complete_handler", null);
216
+
217
+ this.ensureDefault("mouse_click_handler", null);
218
+ this.ensureDefault("mouse_out_handler", null);
219
+ this.ensureDefault("mouse_over_handler", null);
220
+
221
+ this.ensureDefault("debug_handler", this.debugMessage);
222
+
223
+ this.ensureDefault("custom_settings", {});
224
+
225
+ // Other settings
226
+ this.customSettings = this.settings.custom_settings;
227
+
228
+ // Update the flash url if needed
229
+ if (!!this.settings.prevent_swf_caching) {
230
+ this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime();
231
+ this.settings.flash9_url = this.settings.flash9_url + (this.settings.flash9_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime();
232
+ }
233
+
234
+ if (!this.settings.preserve_relative_urls) {
235
+ this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url);
236
+ this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url);
237
+ }
238
+
239
+ delete this.ensureDefault;
240
+ };
241
+
242
+ // Initializes the supported functionality based the Flash Player version, state, and event that occur during initialization
243
+ SWFUpload.prototype.loadSupport = function () {
244
+ this.support = {
245
+ loading : swfobject.hasFlashPlayerVersion("9.0.28"),
246
+ imageResize : swfobject.hasFlashPlayerVersion("10.0.0")
247
+ };
248
+
249
+ };
250
+
251
+ // Private: loadFlash replaces the button_placeholder element with the flash movie.
252
+ SWFUpload.prototype.loadFlash = function () {
253
+ var targetElement, tempParent, wrapperType, flashHTML, els;
254
+
255
+ if (!this.support.loading) {
256
+ this.queueEvent("swfupload_load_failed_handler", ["Flash Player doesn't support SWFUpload"]);
257
+ return;
258
+ }
259
+
260
+ // Make sure an element with the ID we are going to use doesn't already exist
261
+ if (document.getElementById(this.movieName) !== null) {
262
+ this.support.loading = false;
263
+ this.queueEvent("swfupload_load_failed_handler", ["Element ID already in use"]);
264
+ return;
265
+ }
266
+
267
+ // Get the element where we will be placing the flash movie
268
+ targetElement = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder;
269
+
270
+ if (targetElement == undefined) {
271
+ this.support.loading = false;
272
+ this.queueEvent("swfupload_load_failed_handler", ["button place holder not found"]);
273
+ return;
274
+ }
275
+
276
+ wrapperType = (targetElement.currentStyle && targetElement.currentStyle["display"] || window.getComputedStyle && document.defaultView.getComputedStyle(targetElement, null).getPropertyValue("display")) !== "block" ? "span" : "div";
277
+
278
+ // Append the container and load the flash
279
+ tempParent = document.createElement(wrapperType);
280
+
281
+ flashHTML = this.getFlashHTML();
282
+
283
+ try {
284
+ tempParent.innerHTML = flashHTML; // Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers)
285
+ } catch (ex) {
286
+ this.support.loading = false;
287
+ this.queueEvent("swfupload_load_failed_handler", ["Exception loading Flash HTML into placeholder"]);
288
+ return;
289
+ }
290
+
291
+ // Try to get the movie element immediately
292
+ els = tempParent.getElementsByTagName("object");
293
+ if (!els || els.length > 1 || els.length === 0) {
294
+ this.support.loading = false;
295
+ this.queueEvent("swfupload_load_failed_handler", ["Unable to find movie after adding to DOM"]);
296
+ return;
297
+ } else if (els.length === 1) {
298
+ this.movieElement = els[0];
299
+ }
300
+
301
+ targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement);
302
+
303
+ // Fix IE Flash/Form bug
304
+ if (window[this.movieName] == undefined) {
305
+ window[this.movieName] = this.getMovieElement();
306
+ }
307
+ };
308
+
309
+ // Private: getFlashHTML generates the object tag needed to embed the flash in to the document
310
+ SWFUpload.prototype.getFlashHTML = function (flashVersion) {
311
+ // Flash Satay object syntax: http://www.alistapart.com/articles/flashsatay
312
+ return ['<object id="', this.movieName, '" type="application/x-shockwave-flash" data="', (this.support.imageResize ? this.settings.flash_url : this.settings.flash9_url), '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">',
313
+ '<param name="wmode" value="', this.settings.button_window_mode, '" />',
314
+ '<param name="movie" value="', (this.support.imageResize ? this.settings.flash_url : this.settings.flash9_url), '" />',
315
+ '<param name="quality" value="high" />',
316
+ '<param name="allowScriptAccess" value="always" />',
317
+ '<param name="flashvars" value="' + this.getFlashVars() + '" />',
318
+ '</object>'].join("");
319
+ };
320
+
321
+ // Private: getFlashVars builds the parameter string that will be passed
322
+ // to flash in the flashvars param.
323
+ SWFUpload.prototype.getFlashVars = function () {
324
+ // Build a string from the post param object
325
+ var httpSuccessString, paramString;
326
+
327
+ paramString = this.buildParamString();
328
+ httpSuccessString = this.settings.http_success.join(",");
329
+
330
+ // Build the parameter string
331
+ return ["movieName=", encodeURIComponent(this.movieName),
332
+ "&amp;uploadURL=", encodeURIComponent(this.settings.upload_url),
333
+ "&amp;useQueryString=", encodeURIComponent(this.settings.use_query_string),
334
+ "&amp;requeueOnError=", encodeURIComponent(this.settings.requeue_on_error),
335
+ "&amp;httpSuccess=", encodeURIComponent(httpSuccessString),
336
+ "&amp;assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout),
337
+ "&amp;params=", encodeURIComponent(paramString),
338
+ "&amp;filePostName=", encodeURIComponent(this.settings.file_post_name),
339
+ "&amp;fileTypes=", encodeURIComponent(this.settings.file_types),
340
+ "&amp;fileTypesDescription=", encodeURIComponent(this.settings.file_types_description),
341
+ "&amp;fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit),
342
+ "&amp;fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit),
343
+ "&amp;fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit),
344
+ "&amp;debugEnabled=", encodeURIComponent(this.settings.debug_enabled),
345
+ "&amp;buttonImageURL=", encodeURIComponent(this.settings.button_image_url),
346
+ "&amp;buttonWidth=", encodeURIComponent(this.settings.button_width),
347
+ "&amp;buttonHeight=", encodeURIComponent(this.settings.button_height),
348
+ "&amp;buttonText=", encodeURIComponent(this.settings.button_text),
349
+ "&amp;buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding),
350
+ "&amp;buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding),
351
+ "&amp;buttonTextStyle=", encodeURIComponent(this.settings.button_text_style),
352
+ "&amp;buttonAction=", encodeURIComponent(this.settings.button_action),
353
+ "&amp;buttonDisabled=", encodeURIComponent(this.settings.button_disabled),
354
+ "&amp;buttonCursor=", encodeURIComponent(this.settings.button_cursor)
355
+ ].join("");
356
+ };
357
+
358
+ // Public: get retrieves the DOM reference to the Flash element added by SWFUpload
359
+ // The element is cached after the first lookup
360
+ SWFUpload.prototype.getMovieElement = function () {
361
+ if (this.movieElement == undefined) {
362
+ this.movieElement = document.getElementById(this.movieName);
363
+ }
364
+
365
+ if (this.movieElement === null) {
366
+ throw "Could not find Flash element";
367
+ }
368
+
369
+ return this.movieElement;
370
+ };
371
+
372
+ // Private: buildParamString takes the name/value pairs in the post_params setting object
373
+ // and joins them up in to a string formatted "name=value&amp;name=value"
374
+ SWFUpload.prototype.buildParamString = function () {
375
+ var name, postParams, paramStringPairs = [];
376
+
377
+ postParams = this.settings.post_params;
378
+
379
+ if (typeof(postParams) === "object") {
380
+ for (name in postParams) {
381
+ if (postParams.hasOwnProperty(name)) {
382
+ paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString()));
383
+ }
384
+ }
385
+ }
386
+
387
+ return paramStringPairs.join("&amp;");
388
+ };
389
+
390
+ // Public: Used to remove a SWFUpload instance from the page. This method strives to remove
391
+ // all references to the SWF, and other objects so memory is properly freed.
392
+ // Returns true if everything was destroyed. Returns a false if a failure occurs leaving SWFUpload in an inconsistant state.
393
+ // Credits: Major improvements provided by steffen
394
+ SWFUpload.prototype.destroy = function () {
395
+ var movieElement;
396
+
397
+ try {
398
+ // Make sure Flash is done before we try to remove it
399
+ this.cancelUpload(null, false);
400
+
401
+ movieElement = this.cleanUp();
402
+
403
+ // Remove the SWFUpload DOM nodes
404
+ if (movieElement) {
405
+ // Remove the Movie Element from the page
406
+ try {
407
+ movieElement.parentNode.removeChild(movieElement);
408
+ } catch (ex) {}
409
+ }
410
+
411
+ // Remove IE form fix reference
412
+ window[this.movieName] = null;
413
+
414
+ // Destroy other references
415
+ SWFUpload.instances[this.movieName] = null;
416
+ delete SWFUpload.instances[this.movieName];
417
+
418
+ this.movieElement = null;
419
+ this.settings = null;
420
+ this.customSettings = null;
421
+ this.eventQueue = null;
422
+ this.movieName = null;
423
+
424
+
425
+ return true;
426
+ } catch (ex2) {
427
+ return false;
428
+ }
429
+ };
430
+
431
+
432
+ // Public: displayDebugInfo prints out settings and configuration
433
+ // information about this SWFUpload instance.
434
+ // This function (and any references to it) can be deleted when placing
435
+ // SWFUpload in production.
436
+ SWFUpload.prototype.displayDebugInfo = function () {
437
+ this.debug(
438
+ [
439
+ "---SWFUpload Instance Info---\n",
440
+ "Version: ", SWFUpload.version, "\n",
441
+ "Movie Name: ", this.movieName, "\n",
442
+ "Settings:\n",
443
+ "\t", "upload_url: ", this.settings.upload_url, "\n",
444
+ "\t", "flash_url: ", this.settings.flash_url, "\n",
445
+ "\t", "flash9_url: ", this.settings.flash9_url, "\n",
446
+ "\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n",
447
+ "\t", "requeue_on_error: ", this.settings.requeue_on_error.toString(), "\n",
448
+ "\t", "http_success: ", this.settings.http_success.join(", "), "\n",
449
+ "\t", "assume_success_timeout: ", this.settings.assume_success_timeout, "\n",
450
+ "\t", "file_post_name: ", this.settings.file_post_name, "\n",
451
+ "\t", "post_params: ", this.settings.post_params.toString(), "\n",
452
+ "\t", "file_types: ", this.settings.file_types, "\n",
453
+ "\t", "file_types_description: ", this.settings.file_types_description, "\n",
454
+ "\t", "file_size_limit: ", this.settings.file_size_limit, "\n",
455
+ "\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n",
456
+ "\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n",
457
+ "\t", "debug: ", this.settings.debug.toString(), "\n",
458
+
459
+ "\t", "prevent_swf_caching: ", this.settings.prevent_swf_caching.toString(), "\n",
460
+
461
+ "\t", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n",
462
+ "\t", "button_placeholder: ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n",
463
+ "\t", "button_image_url: ", this.settings.button_image_url.toString(), "\n",
464
+ "\t", "button_width: ", this.settings.button_width.toString(), "\n",
465
+ "\t", "button_height: ", this.settings.button_height.toString(), "\n",
466
+ "\t", "button_text: ", this.settings.button_text.toString(), "\n",
467
+ "\t", "button_text_style: ", this.settings.button_text_style.toString(), "\n",
468
+ "\t", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n",
469
+ "\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n",
470
+ "\t", "button_action: ", this.settings.button_action.toString(), "\n",
471
+ "\t", "button_cursor: ", this.settings.button_cursor.toString(), "\n",
472
+ "\t", "button_disabled: ", this.settings.button_disabled.toString(), "\n",
473
+
474
+ "\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n",
475
+ "Event Handlers:\n",
476
+ "\t", "swfupload_preload_handler assigned: ", (typeof this.settings.swfupload_preload_handler === "function").toString(), "\n",
477
+ "\t", "swfupload_load_failed_handler assigned: ", (typeof this.settings.swfupload_load_failed_handler === "function").toString(), "\n",
478
+ "\t", "swfupload_loaded_handler assigned: ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n",
479
+ "\t", "mouse_click_handler assigned: ", (typeof this.settings.mouse_click_handler === "function").toString(), "\n",
480
+ "\t", "mouse_over_handler assigned: ", (typeof this.settings.mouse_over_handler === "function").toString(), "\n",
481
+ "\t", "mouse_out_handler assigned: ", (typeof this.settings.mouse_out_handler === "function").toString(), "\n",
482
+ "\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n",
483
+ "\t", "file_queued_handler assigned: ", (typeof this.settings.file_queued_handler === "function").toString(), "\n",
484
+ "\t", "file_queue_error_handler assigned: ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n",
485
+ "\t", "upload_resize_start_handler assigned: ", (typeof this.settings.upload_resize_start_handler === "function").toString(), "\n",
486
+ "\t", "upload_start_handler assigned: ", (typeof this.settings.upload_start_handler === "function").toString(), "\n",
487
+ "\t", "upload_progress_handler assigned: ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n",
488
+ "\t", "upload_error_handler assigned: ", (typeof this.settings.upload_error_handler === "function").toString(), "\n",
489
+ "\t", "upload_success_handler assigned: ", (typeof this.settings.upload_success_handler === "function").toString(), "\n",
490
+ "\t", "upload_complete_handler assigned: ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n",
491
+ "\t", "debug_handler assigned: ", (typeof this.settings.debug_handler === "function").toString(), "\n",
492
+
493
+ "Support:\n",
494
+ "\t", "Load: ", (this.support.loading ? "Yes" : "No"), "\n",
495
+ "\t", "Image Resize: ", (this.support.imageResize ? "Yes" : "No"), "\n"
496
+
497
+ ].join("")
498
+ );
499
+ };
500
+
501
+ /* Note: addSetting and getSetting are no longer used by SWFUpload but are included
502
+ the maintain v2 API compatibility
503
+ */
504
+ // Public: (Deprecated) addSetting adds a setting value. If the value given is undefined or null then the default_value is used.
505
+ SWFUpload.prototype.addSetting = function (name, value, default_value) {
506
+ if (value == undefined) {
507
+ return (this.settings[name] = default_value);
508
+ } else {
509
+ return (this.settings[name] = value);
510
+ }
511
+ };
512
+
513
+ // Public: (Deprecated) getSetting gets a setting. Returns an empty string if the setting was not found.
514
+ SWFUpload.prototype.getSetting = function (name) {
515
+ if (this.settings[name] != undefined) {
516
+ return this.settings[name];
517
+ }
518
+
519
+ return "";
520
+ };
521
+
522
+
523
+
524
+ // Private: callFlash handles function calls made to the Flash element.
525
+ // Calls are made with a setTimeout for some functions to work around
526
+ // bugs in the ExternalInterface library.
527
+ SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
528
+ var movieElement, returnValue, returnString;
529
+
530
+ argumentArray = argumentArray || [];
531
+ movieElement = this.getMovieElement();
532
+
533
+ // Flash's method if calling ExternalInterface methods (code adapted from MooTools).
534
+ try {
535
+ if (movieElement != undefined) {
536
+ returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + '</invoke>');
537
+ returnValue = eval(returnString);
538
+ } else {
539
+ this.debug("Can't call flash because the movie wasn't found.");
540
+ }
541
+ } catch (ex) {
542
+ this.debug("Exception calling flash function '" + functionName + "': " + ex.message);
543
+ }
544
+
545
+ // Unescape file post param values
546
+ if (returnValue != undefined && typeof returnValue.post === "object") {
547
+ returnValue = this.unescapeFilePostParams(returnValue);
548
+ }
549
+
550
+ return returnValue;
551
+ };
552
+
553
+ /* *****************************
554
+ -- Flash control methods --
555
+ Your UI should use these
556
+ to operate SWFUpload
557
+ ***************************** */
558
+
559
+ // WARNING: this function does not work in Flash Player 10
560
+ // Public: selectFile causes a File Selection Dialog window to appear. This
561
+ // dialog only allows 1 file to be selected.
562
+ SWFUpload.prototype.selectFile = function () {
563
+ this.callFlash("SelectFile");
564
+ };
565
+
566
+ // WARNING: this function does not work in Flash Player 10
567
+ // Public: selectFiles causes a File Selection Dialog window to appear/ This
568
+ // dialog allows the user to select any number of files
569
+ // Flash Bug Warning: Flash limits the number of selectable files based on the combined length of the file names.
570
+ // If the selection name length is too long the dialog will fail in an unpredictable manner. There is no work-around
571
+ // for this bug.
572
+ SWFUpload.prototype.selectFiles = function () {
573
+ this.callFlash("SelectFiles");
574
+ };
575
+
576
+
577
+ // Public: startUpload starts uploading the first file in the queue unless
578
+ // the optional parameter 'fileID' specifies the ID
579
+ SWFUpload.prototype.startUpload = function (fileID) {
580
+ this.callFlash("StartUpload", [fileID]);
581
+ };
582
+
583
+ // Public: startUpload starts uploading the first file in the queue unless
584
+ // the optional parameter 'fileID' specifies the ID
585
+ SWFUpload.prototype.startResizedUpload = function (fileID, width, height, encoding, quality, allowEnlarging) {
586
+ this.callFlash("StartUpload", [fileID, { "width": width, "height" : height, "encoding" : encoding, "quality" : quality, "allowEnlarging" : allowEnlarging }]);
587
+ };
588
+
589
+ // Public: cancelUpload cancels any queued file. The fileID parameter may be the file ID or index.
590
+ // If you do not specify a fileID the current uploading file or first file in the queue is cancelled.
591
+ // If you do not want the uploadError event to trigger you can specify false for the triggerErrorEvent parameter.
592
+ SWFUpload.prototype.cancelUpload = function (fileID, triggerErrorEvent) {
593
+ if (triggerErrorEvent !== false) {
594
+ triggerErrorEvent = true;
595
+ }
596
+ this.callFlash("CancelUpload", [fileID, triggerErrorEvent]);
597
+ };
598
+
599
+ // Public: stopUpload stops the current upload and requeues the file at the beginning of the queue.
600
+ // If nothing is currently uploading then nothing happens.
601
+ SWFUpload.prototype.stopUpload = function () {
602
+ this.callFlash("StopUpload");
603
+ };
604
+
605
+
606
+ // Public: requeueUpload requeues any file. If the file is requeued or already queued true is returned.
607
+ // If the file is not found or is currently uploading false is returned. Requeuing a file bypasses the
608
+ // file size, queue size, upload limit and other queue checks. Certain files can't be requeued (e.g, invalid or zero bytes files).
609
+ SWFUpload.prototype.requeueUpload = function (indexOrFileID) {
610
+ return this.callFlash("RequeueUpload", [indexOrFileID]);
611
+ };
612
+
613
+
614
+ /* ************************
615
+ * Settings methods
616
+ * These methods change the SWFUpload settings.
617
+ * SWFUpload settings should not be changed directly on the settings object
618
+ * since many of the settings need to be passed to Flash in order to take
619
+ * effect.
620
+ * *********************** */
621
+
622
+ // Public: getStats gets the file statistics object.
623
+ SWFUpload.prototype.getStats = function () {
624
+ return this.callFlash("GetStats");
625
+ };
626
+
627
+ // Public: setStats changes the SWFUpload statistics. You shouldn't need to
628
+ // change the statistics but you can. Changing the statistics does not
629
+ // affect SWFUpload accept for the successful_uploads count which is used
630
+ // by the upload_limit setting to determine how many files the user may upload.
631
+ SWFUpload.prototype.setStats = function (statsObject) {
632
+ this.callFlash("SetStats", [statsObject]);
633
+ };
634
+
635
+ // Public: getFile retrieves a File object by ID or Index. If the file is
636
+ // not found then 'null' is returned.
637
+ SWFUpload.prototype.getFile = function (fileID) {
638
+ if (typeof(fileID) === "number") {
639
+ return this.callFlash("GetFileByIndex", [fileID]);
640
+ } else {
641
+ return this.callFlash("GetFile", [fileID]);
642
+ }
643
+ };
644
+
645
+ // Public: getFileFromQueue retrieves a File object by ID or Index. If the file is
646
+ // not found then 'null' is returned.
647
+ SWFUpload.prototype.getQueueFile = function (fileID) {
648
+ if (typeof(fileID) === "number") {
649
+ return this.callFlash("GetFileByQueueIndex", [fileID]);
650
+ } else {
651
+ return this.callFlash("GetFile", [fileID]);
652
+ }
653
+ };
654
+
655
+
656
+ // Public: addFileParam sets a name/value pair that will be posted with the
657
+ // file specified by the Files ID. If the name already exists then the
658
+ // exiting value will be overwritten.
659
+ SWFUpload.prototype.addFileParam = function (fileID, name, value) {
660
+ return this.callFlash("AddFileParam", [fileID, name, value]);
661
+ };
662
+
663
+ // Public: removeFileParam removes a previously set (by addFileParam) name/value
664
+ // pair from the specified file.
665
+ SWFUpload.prototype.removeFileParam = function (fileID, name) {
666
+ this.callFlash("RemoveFileParam", [fileID, name]);
667
+ };
668
+
669
+ // Public: setUploadUrl changes the upload_url setting.
670
+ SWFUpload.prototype.setUploadURL = function (url) {
671
+ this.settings.upload_url = url.toString();
672
+ this.callFlash("SetUploadURL", [url]);
673
+ };
674
+
675
+ // Public: setPostParams changes the post_params setting
676
+ SWFUpload.prototype.setPostParams = function (paramsObject) {
677
+ this.settings.post_params = paramsObject;
678
+ this.callFlash("SetPostParams", [paramsObject]);
679
+ };
680
+
681
+ // Public: addPostParam adds post name/value pair. Each name can have only one value.
682
+ SWFUpload.prototype.addPostParam = function (name, value) {
683
+ this.settings.post_params[name] = value;
684
+ this.callFlash("SetPostParams", [this.settings.post_params]);
685
+ };
686
+
687
+ // Public: removePostParam deletes post name/value pair.
688
+ SWFUpload.prototype.removePostParam = function (name) {
689
+ delete this.settings.post_params[name];
690
+ this.callFlash("SetPostParams", [this.settings.post_params]);
691
+ };
692
+
693
+ // Public: setFileTypes changes the file_types setting and the file_types_description setting
694
+ SWFUpload.prototype.setFileTypes = function (types, description) {
695
+ this.settings.file_types = types;
696
+ this.settings.file_types_description = description;
697
+ this.callFlash("SetFileTypes", [types, description]);
698
+ };
699
+
700
+ // Public: setFileSizeLimit changes the file_size_limit setting
701
+ SWFUpload.prototype.setFileSizeLimit = function (fileSizeLimit) {
702
+ this.settings.file_size_limit = fileSizeLimit;
703
+ this.callFlash("SetFileSizeLimit", [fileSizeLimit]);
704
+ };
705
+
706
+ // Public: setFileUploadLimit changes the file_upload_limit setting
707
+ SWFUpload.prototype.setFileUploadLimit = function (fileUploadLimit) {
708
+ this.settings.file_upload_limit = fileUploadLimit;
709
+ this.callFlash("SetFileUploadLimit", [fileUploadLimit]);
710
+ };
711
+
712
+ // Public: setFileQueueLimit changes the file_queue_limit setting
713
+ SWFUpload.prototype.setFileQueueLimit = function (fileQueueLimit) {
714
+ this.settings.file_queue_limit = fileQueueLimit;
715
+ this.callFlash("SetFileQueueLimit", [fileQueueLimit]);
716
+ };
717
+
718
+ // Public: setFilePostName changes the file_post_name setting
719
+ SWFUpload.prototype.setFilePostName = function (filePostName) {
720
+ this.settings.file_post_name = filePostName;
721
+ this.callFlash("SetFilePostName", [filePostName]);
722
+ };
723
+
724
+ // Public: setUseQueryString changes the use_query_string setting
725
+ SWFUpload.prototype.setUseQueryString = function (useQueryString) {
726
+ this.settings.use_query_string = useQueryString;
727
+ this.callFlash("SetUseQueryString", [useQueryString]);
728
+ };
729
+
730
+ // Public: setRequeueOnError changes the requeue_on_error setting
731
+ SWFUpload.prototype.setRequeueOnError = function (requeueOnError) {
732
+ this.settings.requeue_on_error = requeueOnError;
733
+ this.callFlash("SetRequeueOnError", [requeueOnError]);
734
+ };
735
+
736
+ // Public: setHTTPSuccess changes the http_success setting
737
+ SWFUpload.prototype.setHTTPSuccess = function (http_status_codes) {
738
+ if (typeof http_status_codes === "string") {
739
+ http_status_codes = http_status_codes.replace(" ", "").split(",");
740
+ }
741
+
742
+ this.settings.http_success = http_status_codes;
743
+ this.callFlash("SetHTTPSuccess", [http_status_codes]);
744
+ };
745
+
746
+ // Public: setHTTPSuccess changes the http_success setting
747
+ SWFUpload.prototype.setAssumeSuccessTimeout = function (timeout_seconds) {
748
+ this.settings.assume_success_timeout = timeout_seconds;
749
+ this.callFlash("SetAssumeSuccessTimeout", [timeout_seconds]);
750
+ };
751
+
752
+ // Public: setDebugEnabled changes the debug_enabled setting
753
+ SWFUpload.prototype.setDebugEnabled = function (debugEnabled) {
754
+ this.settings.debug_enabled = debugEnabled;
755
+ this.callFlash("SetDebugEnabled", [debugEnabled]);
756
+ };
757
+
758
+ // Public: setButtonImageURL loads a button image sprite
759
+ SWFUpload.prototype.setButtonImageURL = function (buttonImageURL) {
760
+ if (buttonImageURL == undefined) {
761
+ buttonImageURL = "";
762
+ }
763
+
764
+ this.settings.button_image_url = buttonImageURL;
765
+ this.callFlash("SetButtonImageURL", [buttonImageURL]);
766
+ };
767
+
768
+ // Public: setButtonDimensions resizes the Flash Movie and button
769
+ SWFUpload.prototype.setButtonDimensions = function (width, height) {
770
+ this.settings.button_width = width;
771
+ this.settings.button_height = height;
772
+
773
+ var movie = this.getMovieElement();
774
+ if (movie != undefined) {
775
+ movie.style.width = width + "px";
776
+ movie.style.height = height + "px";
777
+ }
778
+
779
+ this.callFlash("SetButtonDimensions", [width, height]);
780
+ };
781
+ // Public: setButtonText Changes the text overlaid on the button
782
+ SWFUpload.prototype.setButtonText = function (html) {
783
+ this.settings.button_text = html;
784
+ this.callFlash("SetButtonText", [html]);
785
+ };
786
+ // Public: setButtonTextPadding changes the top and left padding of the text overlay
787
+ SWFUpload.prototype.setButtonTextPadding = function (left, top) {
788
+ this.settings.button_text_top_padding = top;
789
+ this.settings.button_text_left_padding = left;
790
+ this.callFlash("SetButtonTextPadding", [left, top]);
791
+ };
792
+
793
+ // Public: setButtonTextStyle changes the CSS used to style the HTML/Text overlaid on the button
794
+ SWFUpload.prototype.setButtonTextStyle = function (css) {
795
+ this.settings.button_text_style = css;
796
+ this.callFlash("SetButtonTextStyle", [css]);
797
+ };
798
+ // Public: setButtonDisabled disables/enables the button
799
+ SWFUpload.prototype.setButtonDisabled = function (isDisabled) {
800
+ this.settings.button_disabled = isDisabled;
801
+ this.callFlash("SetButtonDisabled", [isDisabled]);
802
+ };
803
+ // Public: setButtonAction sets the action that occurs when the button is clicked
804
+ SWFUpload.prototype.setButtonAction = function (buttonAction) {
805
+ this.settings.button_action = buttonAction;
806
+ this.callFlash("SetButtonAction", [buttonAction]);
807
+ };
808
+
809
+ // Public: setButtonCursor changes the mouse cursor displayed when hovering over the button
810
+ SWFUpload.prototype.setButtonCursor = function (cursor) {
811
+ this.settings.button_cursor = cursor;
812
+ this.callFlash("SetButtonCursor", [cursor]);
813
+ };
814
+
815
+ /* *******************************
816
+ Flash Event Interfaces
817
+ These functions are used by Flash to trigger the various
818
+ events.
819
+
820
+ All these functions a Private.
821
+
822
+ Because the ExternalInterface library is buggy the event calls
823
+ are added to a queue and the queue then executed by a setTimeout.
824
+ This ensures that events are executed in a determinate order and that
825
+ the ExternalInterface bugs are avoided.
826
+ ******************************* */
827
+
828
+ SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) {
829
+ // Warning: Don't call this.debug inside here or you'll create an infinite loop
830
+ var self = this;
831
+
832
+ if (argumentArray == undefined) {
833
+ argumentArray = [];
834
+ } else if (!(argumentArray instanceof Array)) {
835
+ argumentArray = [argumentArray];
836
+ }
837
+
838
+ if (typeof this.settings[handlerName] === "function") {
839
+ // Queue the event
840
+ this.eventQueue.push(function () {
841
+ this.settings[handlerName].apply(this, argumentArray);
842
+ });
843
+
844
+ // Execute the next queued event
845
+ setTimeout(function () {
846
+ self.executeNextEvent();
847
+ }, 0);
848
+
849
+ } else if (this.settings[handlerName] !== null) {
850
+ throw "Event handler " + handlerName + " is unknown or is not a function";
851
+ }
852
+ };
853
+
854
+ // Private: Causes the next event in the queue to be executed. Since events are queued using a setTimeout
855
+ // we must queue them in order to garentee that they are executed in order.
856
+ SWFUpload.prototype.executeNextEvent = function () {
857
+ // Warning: Don't call this.debug inside here or you'll create an infinite loop
858
+
859
+ var f = this.eventQueue ? this.eventQueue.shift() : null;
860
+ if (typeof(f) === "function") {
861
+ f.apply(this);
862
+ }
863
+ };
864
+
865
+ // Private: unescapeFileParams is part of a workaround for a flash bug where objects passed through ExternalInterface cannot have
866
+ // properties that contain characters that are not valid for JavaScript identifiers. To work around this
867
+ // the Flash Component escapes the parameter names and we must unescape again before passing them along.
868
+ SWFUpload.prototype.unescapeFilePostParams = function (file) {
869
+ var reg = /[$]([0-9a-f]{4})/i, unescapedPost = {}, uk, k, match;
870
+
871
+ if (file != undefined) {
872
+ for (k in file.post) {
873
+ if (file.post.hasOwnProperty(k)) {
874
+ uk = k;
875
+ while ((match = reg.exec(uk)) !== null) {
876
+ uk = uk.replace(match[0], String.fromCharCode(parseInt("0x" + match[1], 16)));
877
+ }
878
+ unescapedPost[uk] = file.post[k];
879
+ }
880
+ }
881
+
882
+ file.post = unescapedPost;
883
+ }
884
+
885
+ return file;
886
+ };
887
+
888
+ // Private: This event is called by SWFUpload Init after we've determined what the user's Flash Player supports.
889
+ // Use the swfupload_preload_handler event setting to execute custom code when SWFUpload has loaded.
890
+ // Return false to prevent SWFUpload from loading and allow your script to do something else if your required feature is
891
+ // not supported
892
+ SWFUpload.prototype.swfuploadPreload = function () {
893
+ var returnValue;
894
+ if (typeof this.settings.swfupload_preload_handler === "function") {
895
+ returnValue = this.settings.swfupload_preload_handler.call(this);
896
+ } else if (this.settings.swfupload_preload_handler != undefined) {
897
+ throw "upload_start_handler must be a function";
898
+ }
899
+
900
+ // Convert undefined to true so if nothing is returned from the upload_start_handler it is
901
+ // interpretted as 'true'.
902
+ if (returnValue === undefined) {
903
+ returnValue = true;
904
+ }
905
+
906
+ return !!returnValue;
907
+ }
908
+
909
+ // Private: This event is called by Flash when it has finished loading. Don't modify this.
910
+ // Use the swfupload_loaded_handler event setting to execute custom code when SWFUpload has loaded.
911
+ SWFUpload.prototype.flashReady = function () {
912
+ // Check that the movie element is loaded correctly with its ExternalInterface methods defined
913
+ var movieElement = this.cleanUp();
914
+
915
+ if (!movieElement) {
916
+ this.debug("Flash called back ready but the flash movie can't be found.");
917
+ return;
918
+ }
919
+
920
+ this.queueEvent("swfupload_loaded_handler");
921
+ };
922
+
923
+ // Private: removes Flash added fuctions to the DOM node to prevent memory leaks in IE.
924
+ // This function is called by Flash each time the ExternalInterface functions are created.
925
+ SWFUpload.prototype.cleanUp = function () {
926
+ var key, movieElement = this.getMovieElement();
927
+
928
+ // Pro-actively unhook all the Flash functions
929
+ try {
930
+ if (movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
931
+ this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");
932
+ for (key in movieElement) {
933
+ try {
934
+ if (typeof(movieElement[key]) === "function") {
935
+ movieElement[key] = null;
936
+ }
937
+ } catch (ex) {
938
+ }
939
+ }
940
+ }
941
+ } catch (ex1) {
942
+
943
+ }
944
+
945
+ // Fix Flashes own cleanup code so if the SWF Movie was removed from the page
946
+ // it doesn't display errors.
947
+ window["__flash__removeCallback"] = function (instance, name) {
948
+ try {
949
+ if (instance) {
950
+ instance[name] = null;
951
+ }
952
+ } catch (flashEx) {
953
+
954
+ }
955
+ };
956
+
957
+ return movieElement;
958
+ };
959
+
960
+ /* When the button_action is set to None this event gets fired and executes the mouse_click_handler */
961
+ SWFUpload.prototype.mouseClick = function () {
962
+ this.queueEvent("mouse_click_handler");
963
+ };
964
+ SWFUpload.prototype.mouseOver = function () {
965
+ this.queueEvent("mouse_over_handler");
966
+ };
967
+ SWFUpload.prototype.mouseOut = function () {
968
+ this.queueEvent("mouse_out_handler");
969
+ };
970
+
971
+ /* This is a chance to do something before the browse window opens */
972
+ SWFUpload.prototype.fileDialogStart = function () {
973
+ this.queueEvent("file_dialog_start_handler");
974
+ };
975
+
976
+
977
+ /* Called when a file is successfully added to the queue. */
978
+ SWFUpload.prototype.fileQueued = function (file) {
979
+ file = this.unescapeFilePostParams(file);
980
+ this.queueEvent("file_queued_handler", file);
981
+ };
982
+
983
+
984
+ /* Handle errors that occur when an attempt to queue a file fails. */
985
+ SWFUpload.prototype.fileQueueError = function (file, errorCode, message) {
986
+ file = this.unescapeFilePostParams(file);
987
+ this.queueEvent("file_queue_error_handler", [file, errorCode, message]);
988
+ };
989
+
990
+ /* Called after the file dialog has closed and the selected files have been queued.
991
+ You could call startUpload here if you want the queued files to begin uploading immediately. */
992
+ SWFUpload.prototype.fileDialogComplete = function (numFilesSelected, numFilesQueued, numFilesInQueue) {
993
+ this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued, numFilesInQueue]);
994
+ };
995
+
996
+ SWFUpload.prototype.uploadResizeStart = function (file, resizeSettings) {
997
+ file = this.unescapeFilePostParams(file);
998
+ this.queueEvent("upload_resize_start_handler", [file, resizeSettings.width, resizeSettings.height, resizeSettings.encoding, resizeSettings.quality]);
999
+ };
1000
+
1001
+ SWFUpload.prototype.uploadStart = function (file) {
1002
+ file = this.unescapeFilePostParams(file);
1003
+ this.queueEvent("return_upload_start_handler", file);
1004
+ };
1005
+
1006
+ SWFUpload.prototype.returnUploadStart = function (file) {
1007
+ var returnValue;
1008
+ if (typeof this.settings.upload_start_handler === "function") {
1009
+ file = this.unescapeFilePostParams(file);
1010
+ returnValue = this.settings.upload_start_handler.call(this, file);
1011
+ } else if (this.settings.upload_start_handler != undefined) {
1012
+ throw "upload_start_handler must be a function";
1013
+ }
1014
+
1015
+ // Convert undefined to true so if nothing is returned from the upload_start_handler it is
1016
+ // interpretted as 'true'.
1017
+ if (returnValue === undefined) {
1018
+ returnValue = true;
1019
+ }
1020
+
1021
+ returnValue = !!returnValue;
1022
+
1023
+ this.callFlash("ReturnUploadStart", [returnValue]);
1024
+ };
1025
+
1026
+
1027
+
1028
+ SWFUpload.prototype.uploadProgress = function (file, bytesComplete, bytesTotal) {
1029
+ file = this.unescapeFilePostParams(file);
1030
+ this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]);
1031
+ };
1032
+
1033
+ SWFUpload.prototype.uploadError = function (file, errorCode, message) {
1034
+ file = this.unescapeFilePostParams(file);
1035
+ this.queueEvent("upload_error_handler", [file, errorCode, message]);
1036
+ };
1037
+
1038
+ SWFUpload.prototype.uploadSuccess = function (file, serverData, responseReceived) {
1039
+ file = this.unescapeFilePostParams(file);
1040
+ this.queueEvent("upload_success_handler", [file, serverData, responseReceived]);
1041
+ };
1042
+
1043
+ SWFUpload.prototype.uploadComplete = function (file) {
1044
+ file = this.unescapeFilePostParams(file);
1045
+ this.queueEvent("upload_complete_handler", file);
1046
+ };
1047
+
1048
+ /* Called by SWFUpload JavaScript and Flash functions when debug is enabled. By default it writes messages to the
1049
+ internal debug console. You can override this event and have messages written where you want. */
1050
+ SWFUpload.prototype.debug = function (message) {
1051
+ this.queueEvent("debug_handler", message);
1052
+ };
1053
+
1054
+
1055
+ /* **********************************
1056
+ Debug Console
1057
+ The debug console is a self contained, in page location
1058
+ for debug message to be sent. The Debug Console adds
1059
+ itself to the body if necessary.
1060
+
1061
+ The console is automatically scrolled as messages appear.
1062
+
1063
+ If you are using your own debug handler or when you deploy to production and
1064
+ have debug disabled you can remove these functions to reduce the file size
1065
+ and complexity.
1066
+ ********************************** */
1067
+
1068
+ // Private: debugMessage is the default debug_handler. If you want to print debug messages
1069
+ // call the debug() function. When overriding the function your own function should
1070
+ // check to see if the debug setting is true before outputting debug information.
1071
+ SWFUpload.prototype.debugMessage = function (message) {
1072
+ var exceptionMessage, exceptionValues, key;
1073
+
1074
+ if (this.settings.debug) {
1075
+ exceptionValues = [];
1076
+
1077
+ // Check for an exception object and print it nicely
1078
+ if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") {
1079
+ for (key in message) {
1080
+ if (message.hasOwnProperty(key)) {
1081
+ exceptionValues.push(key + ": " + message[key]);
1082
+ }
1083
+ }
1084
+ exceptionMessage = exceptionValues.join("\n") || "";
1085
+ exceptionValues = exceptionMessage.split("\n");
1086
+ exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: ");
1087
+ SWFUpload.Console.writeLine(exceptionMessage);
1088
+ } else {
1089
+ SWFUpload.Console.writeLine(message);
1090
+ }
1091
+ }
1092
+ };
1093
+
1094
+ SWFUpload.Console = {};
1095
+ SWFUpload.Console.writeLine = function (message) {
1096
+ var console, documentForm;
1097
+
1098
+ try {
1099
+ console = document.getElementById("SWFUpload_Console");
1100
+
1101
+ if (!console) {
1102
+ documentForm = document.createElement("form");
1103
+ document.getElementsByTagName("body")[0].appendChild(documentForm);
1104
+
1105
+ console = document.createElement("textarea");
1106
+ console.id = "SWFUpload_Console";
1107
+ console.style.fontFamily = "monospace";
1108
+ console.setAttribute("wrap", "off");
1109
+ console.wrap = "off";
1110
+ console.style.overflow = "auto";
1111
+ console.style.width = "700px";
1112
+ console.style.height = "350px";
1113
+ console.style.margin = "5px";
1114
+ documentForm.appendChild(console);
1115
+ }
1116
+
1117
+ console.value += message + "\n";
1118
+
1119
+ console.scrollTop = console.scrollHeight - console.clientHeight;
1120
+ } catch (ex) {
1121
+ alert("Exception: " + ex.name + " Message: " + ex.message);
1122
+ }
1123
+ };
1124
+
1125
+
1126
+ /* SWFObject v2.2 <http://code.google.com/p/swfobject/>
1127
+ is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
1128
+ */
1129
+ swfobject = function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();
1130
+ swfobject.addDomLoadEvent(function () {
1131
+ if (typeof(SWFUpload.onload) === "function") {
1132
+ SWFUpload.onload.call(window);
1133
+ }
1134
+ });