ueditor_rails4 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.markdown +45 -0
  4. data/Rakefile +40 -0
  5. data/app/assets/images/ueditor/themes/default/anchor.gif +0 -0
  6. data/app/assets/images/ueditor/themes/default/arrow.png +0 -0
  7. data/app/assets/images/ueditor/themes/default/button-bg.gif +0 -0
  8. data/app/assets/images/ueditor/themes/default/cancelbutton.gif +0 -0
  9. data/app/assets/images/ueditor/themes/default/cursor_h.gif +0 -0
  10. data/app/assets/images/ueditor/themes/default/cursor_h.png +0 -0
  11. data/app/assets/images/ueditor/themes/default/cursor_v.gif +0 -0
  12. data/app/assets/images/ueditor/themes/default/cursor_v.png +0 -0
  13. data/app/assets/images/ueditor/themes/default/dialog-title-bg.png +0 -0
  14. data/app/assets/images/ueditor/themes/default/filescan.png +0 -0
  15. data/app/assets/images/ueditor/themes/default/highlighted.gif +0 -0
  16. data/app/assets/images/ueditor/themes/default/icons-all.gif +0 -0
  17. data/app/assets/images/ueditor/themes/default/icons.gif +0 -0
  18. data/app/assets/images/ueditor/themes/default/icons.png +0 -0
  19. data/app/assets/images/ueditor/themes/default/lock.gif +0 -0
  20. data/app/assets/images/ueditor/themes/default/neweditor-tab-bg.png +0 -0
  21. data/app/assets/images/ueditor/themes/default/pagebreak.gif +0 -0
  22. data/app/assets/images/ueditor/themes/default/scale.png +0 -0
  23. data/app/assets/images/ueditor/themes/default/spacer.gif +0 -0
  24. data/app/assets/images/ueditor/themes/default/sparator_v.png +0 -0
  25. data/app/assets/images/ueditor/themes/default/toolbar_bg.png +0 -0
  26. data/app/assets/images/ueditor/themes/default/unhighlighted.gif +0 -0
  27. data/app/assets/images/ueditor/themes/default/upload.png +0 -0
  28. data/app/assets/images/ueditor/themes/default/videologo.gif +0 -0
  29. data/app/assets/images/ueditor/themes/default/word.gif +0 -0
  30. data/app/assets/images/ueditor/themes/default/wordpaste.png +0 -0
  31. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_chm.gif +0 -0
  32. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_default.png +0 -0
  33. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_doc.gif +0 -0
  34. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_exe.gif +0 -0
  35. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_mp3.gif +0 -0
  36. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_mv.gif +0 -0
  37. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_pdf.gif +0 -0
  38. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_ppt.gif +0 -0
  39. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_psd.gif +0 -0
  40. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_rar.gif +0 -0
  41. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_txt.gif +0 -0
  42. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_xls.gif +0 -0
  43. data/app/assets/images/ueditor_rails/dialogs/image/center_focus.jpg +0 -0
  44. data/app/assets/images/ueditor_rails/dialogs/image/left_focus.jpg +0 -0
  45. data/app/assets/images/ueditor_rails/dialogs/image/none_focus.jpg +0 -0
  46. data/app/assets/images/ueditor_rails/dialogs/image/right_focus.jpg +0 -0
  47. data/app/assets/images/ueditor_rails/dialogs/scrawl/addimg.png +0 -0
  48. data/app/assets/images/ueditor_rails/dialogs/scrawl/brush.png +0 -0
  49. data/app/assets/images/ueditor_rails/dialogs/scrawl/delimg.png +0 -0
  50. data/app/assets/images/ueditor_rails/dialogs/scrawl/delimgH.png +0 -0
  51. data/app/assets/images/ueditor_rails/dialogs/scrawl/empty.png +0 -0
  52. data/app/assets/images/ueditor_rails/dialogs/scrawl/emptyH.png +0 -0
  53. data/app/assets/images/ueditor_rails/dialogs/scrawl/eraser.png +0 -0
  54. data/app/assets/images/ueditor_rails/dialogs/scrawl/redo.png +0 -0
  55. data/app/assets/images/ueditor_rails/dialogs/scrawl/redoH.png +0 -0
  56. data/app/assets/images/ueditor_rails/dialogs/scrawl/scale.png +0 -0
  57. data/app/assets/images/ueditor_rails/dialogs/scrawl/scaleH.png +0 -0
  58. data/app/assets/images/ueditor_rails/dialogs/scrawl/size.png +0 -0
  59. data/app/assets/images/ueditor_rails/dialogs/scrawl/undo.png +0 -0
  60. data/app/assets/images/ueditor_rails/dialogs/scrawl/undoH.png +0 -0
  61. data/app/assets/javascripts/ueditor_rails/_config.js.erb +211 -0
  62. data/app/assets/javascripts/ueditor_rails/dialogs/attachment.js +5 -0
  63. data/app/assets/javascripts/ueditor_rails/dialogs/attachment/_callbacks.js +166 -0
  64. data/app/assets/javascripts/ueditor_rails/dialogs/attachment/_file_type_maps.js.erb +14 -0
  65. data/app/assets/javascripts/ueditor_rails/dialogs/image.js.erb +724 -0
  66. data/app/assets/javascripts/ueditor_rails/dialogs/scrawl.js +655 -0
  67. data/app/assets/javascripts/ueditor_rails/dialogs/wordimage.js +154 -0
  68. data/app/assets/javascripts/ueditor_rails/init.js +12 -0
  69. data/app/assets/stylesheets/ueditor/themes/default/dialogbase.css.erb +100 -0
  70. data/app/assets/stylesheets/ueditor/themes/default/ueditor.css +1582 -0
  71. data/app/assets/stylesheets/ueditor/themes/iframe.css +1 -0
  72. data/app/assets/stylesheets/ueditor_rails/dialogs/attachment.css.erb +161 -0
  73. data/app/assets/stylesheets/ueditor_rails/dialogs/image.css.erb +69 -0
  74. data/app/assets/stylesheets/ueditor_rails/dialogs/scrawl.css.erb +72 -0
  75. data/app/controllers/ueditor_rails/application_controller.rb +5 -0
  76. data/app/controllers/ueditor_rails/dialogs_controller.rb +21 -0
  77. data/app/controllers/ueditor_rails/libs_controller.rb +33 -0
  78. data/app/helpers/ueditor_rails/application_helper.rb +27 -0
  79. data/app/views/ueditor_rails/dialogs/attachment.html.erb +124 -0
  80. data/app/views/ueditor_rails/dialogs/image.html.erb +203 -0
  81. data/app/views/ueditor_rails/dialogs/scrawl.html.erb +96 -0
  82. data/app/views/ueditor_rails/dialogs/wordimage.html.erb +155 -0
  83. data/config/routes.rb +11 -0
  84. data/lib/generators/ueditor_rails/USAGE +8 -0
  85. data/lib/generators/ueditor_rails/install_generator.rb +15 -0
  86. data/lib/generators/ueditor_rails/templates/ueditor_config.js.erb +216 -0
  87. data/lib/tasks/ueditor_rails_tasks.rake +4 -0
  88. data/lib/ueditor_rails/engine.rb +17 -0
  89. data/lib/ueditor_rails/helpers/form_builder.rb +11 -0
  90. data/lib/ueditor_rails/helpers/form_helper.rb +37 -0
  91. data/lib/ueditor_rails/helpers/view_helper.rb +21 -0
  92. data/lib/ueditor_rails/util.rb +42 -0
  93. data/lib/ueditor_rails/version.rb +3 -0
  94. data/lib/ueditor_rails4.rb +32 -0
  95. data/test/dummy/README.rdoc +261 -0
  96. data/test/dummy/Rakefile +7 -0
  97. data/test/dummy/app/assets/javascripts/application.js +16 -0
  98. data/test/dummy/app/assets/javascripts/posts.js +2 -0
  99. data/test/dummy/app/assets/javascripts/ueditor_config.js.erb +208 -0
  100. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  101. data/test/dummy/app/assets/stylesheets/posts.css +4 -0
  102. data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
  103. data/test/dummy/app/controllers/application_controller.rb +3 -0
  104. data/test/dummy/app/controllers/posts_controller.rb +83 -0
  105. data/test/dummy/app/helpers/application_helper.rb +2 -0
  106. data/test/dummy/app/helpers/posts_helper.rb +2 -0
  107. data/test/dummy/app/models/post.rb +3 -0
  108. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  109. data/test/dummy/app/views/posts/_form.html.erb +25 -0
  110. data/test/dummy/app/views/posts/edit.html.erb +6 -0
  111. data/test/dummy/app/views/posts/index.html.erb +29 -0
  112. data/test/dummy/app/views/posts/new.html.erb +5 -0
  113. data/test/dummy/app/views/posts/show.html.erb +14 -0
  114. data/test/dummy/config.ru +4 -0
  115. data/test/dummy/config/application.rb +61 -0
  116. data/test/dummy/config/boot.rb +10 -0
  117. data/test/dummy/config/database.yml +25 -0
  118. data/test/dummy/config/environment.rb +5 -0
  119. data/test/dummy/config/environments/development.rb +37 -0
  120. data/test/dummy/config/environments/production.rb +67 -0
  121. data/test/dummy/config/environments/test.rb +37 -0
  122. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  123. data/test/dummy/config/initializers/inflections.rb +15 -0
  124. data/test/dummy/config/initializers/mime_types.rb +5 -0
  125. data/test/dummy/config/initializers/secret_token.rb +7 -0
  126. data/test/dummy/config/initializers/session_store.rb +8 -0
  127. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  128. data/test/dummy/config/locales/en.yml +5 -0
  129. data/test/dummy/config/routes.rb +8 -0
  130. data/test/dummy/db/migrate/20130327173045_create_posts.rb +10 -0
  131. data/test/dummy/db/schema.rb +23 -0
  132. data/test/dummy/public/404.html +26 -0
  133. data/test/dummy/public/422.html +26 -0
  134. data/test/dummy/public/500.html +25 -0
  135. data/test/dummy/public/favicon.ico +0 -0
  136. data/test/dummy/script/rails +6 -0
  137. data/test/dummy/test/fixtures/posts.yml +9 -0
  138. data/test/dummy/test/functional/posts_controller_test.rb +49 -0
  139. data/test/dummy/test/unit/helpers/posts_helper_test.rb +4 -0
  140. data/test/dummy/test/unit/post_test.rb +7 -0
  141. data/test/functional/ueditor_rails/dialogs_controller_test.rb +16 -0
  142. data/test/functional/ueditor_rails/libs_controller_test.rb +21 -0
  143. data/test/integration/navigation_test.rb +10 -0
  144. data/test/test_helper.rb +15 -0
  145. data/test/ueditor_rails_test.rb +7 -0
  146. data/vendor/assets/javascripts/ueditor/dialogs/anchor/anchor.html.erb +57 -0
  147. data/vendor/assets/javascripts/ueditor/dialogs/background/background.css +24 -0
  148. data/vendor/assets/javascripts/ueditor/dialogs/background/background.html.erb +55 -0
  149. data/vendor/assets/javascripts/ueditor/dialogs/background/background.js +348 -0
  150. data/vendor/assets/javascripts/ueditor/dialogs/emotion/emotion.css.erb +43 -0
  151. data/vendor/assets/javascripts/ueditor/dialogs/emotion/emotion.html.erb +54 -0
  152. data/vendor/assets/javascripts/ueditor/dialogs/emotion/emotion.js +186 -0
  153. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/0.gif +0 -0
  154. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/bface.gif +0 -0
  155. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/cface.gif +0 -0
  156. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/fface.gif +0 -0
  157. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/jxface2.gif +0 -0
  158. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/neweditor-tab-bg.png +0 -0
  159. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/tface.gif +0 -0
  160. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/wface.gif +0 -0
  161. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/yface.gif +0 -0
  162. data/vendor/assets/javascripts/ueditor/dialogs/gmap/gmap.html.erb +89 -0
  163. data/vendor/assets/javascripts/ueditor/dialogs/help/help.css +7 -0
  164. data/vendor/assets/javascripts/ueditor/dialogs/help/help.html.erb +84 -0
  165. data/vendor/assets/javascripts/ueditor/dialogs/help/help.js +54 -0
  166. data/vendor/assets/javascripts/ueditor/dialogs/highlightcode/highlightcode.html.erb +131 -0
  167. data/vendor/assets/javascripts/ueditor/dialogs/insertframe/insertframe.html.erb +98 -0
  168. data/vendor/assets/javascripts/ueditor/dialogs/internal.js +79 -0
  169. data/vendor/assets/javascripts/ueditor/dialogs/link/link.html.erb +141 -0
  170. data/vendor/assets/javascripts/ueditor/dialogs/map/map.html.erb +105 -0
  171. data/vendor/assets/javascripts/ueditor/dialogs/music/music.css +30 -0
  172. data/vendor/assets/javascripts/ueditor/dialogs/music/music.html.erb +32 -0
  173. data/vendor/assets/javascripts/ueditor/dialogs/music/music.js +192 -0
  174. data/vendor/assets/javascripts/ueditor/dialogs/searchreplace/searchreplace.html.erb +74 -0
  175. data/vendor/assets/javascripts/ueditor/dialogs/searchreplace/searchreplace.js +160 -0
  176. data/vendor/assets/javascripts/ueditor/dialogs/snapscreen/snapscreen.html.erb +91 -0
  177. data/vendor/assets/javascripts/ueditor/dialogs/spechars/spechars.html.erb +21 -0
  178. data/vendor/assets/javascripts/ueditor/dialogs/spechars/spechars.js +56 -0
  179. data/vendor/assets/javascripts/ueditor/dialogs/table/dragicon.png +0 -0
  180. data/vendor/assets/javascripts/ueditor/dialogs/table/edittable.css +75 -0
  181. data/vendor/assets/javascripts/ueditor/dialogs/table/edittable.html.erb +57 -0
  182. data/vendor/assets/javascripts/ueditor/dialogs/table/edittable.js +182 -0
  183. data/vendor/assets/javascripts/ueditor/dialogs/table/edittd.html.erb +51 -0
  184. data/vendor/assets/javascripts/ueditor/dialogs/table/edittip.html.erb +33 -0
  185. data/vendor/assets/javascripts/ueditor/dialogs/tangram.js +1238 -0
  186. data/vendor/assets/javascripts/ueditor/dialogs/template/config.js +42 -0
  187. data/vendor/assets/javascripts/ueditor/dialogs/template/images/bg.gif +0 -0
  188. data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre0.png +0 -0
  189. data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre1.png +0 -0
  190. data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre2.png +0 -0
  191. data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre3.png +0 -0
  192. data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre4.png +0 -0
  193. data/vendor/assets/javascripts/ueditor/dialogs/template/template.css +18 -0
  194. data/vendor/assets/javascripts/ueditor/dialogs/template/template.html.erb +26 -0
  195. data/vendor/assets/javascripts/ueditor/dialogs/template/template.js +53 -0
  196. data/vendor/assets/javascripts/ueditor/dialogs/video/images/center_focus.jpg +0 -0
  197. data/vendor/assets/javascripts/ueditor/dialogs/video/images/left_focus.jpg +0 -0
  198. data/vendor/assets/javascripts/ueditor/dialogs/video/images/none_focus.jpg +0 -0
  199. data/vendor/assets/javascripts/ueditor/dialogs/video/images/right_focus.jpg +0 -0
  200. data/vendor/assets/javascripts/ueditor/dialogs/video/video.css +59 -0
  201. data/vendor/assets/javascripts/ueditor/dialogs/video/video.html.erb +78 -0
  202. data/vendor/assets/javascripts/ueditor/dialogs/video/video.js.erb +409 -0
  203. data/vendor/assets/javascripts/ueditor/dialogs/webapp/webapp.html.erb +64 -0
  204. data/vendor/assets/javascripts/ueditor/editor_all.js.erb +19133 -0
  205. data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/copy.png +0 -0
  206. data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/imglabel.png +0 -0
  207. data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/localimage.png +0 -0
  208. data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/music.png +0 -0
  209. data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/upload.png +0 -0
  210. data/vendor/assets/javascripts/ueditor/lang/zh-cn/zh-cn.js +492 -0
  211. data/vendor/assets/javascripts/ueditor/third-party/SyntaxHighlighter/shCore.js +3655 -0
  212. data/vendor/assets/javascripts/ueditor/third-party/SyntaxHighlighter/shCoreDefault.css +316 -0
  213. data/vendor/assets/javascripts/ueditor/third-party/codemirror/codemirror.css +104 -0
  214. data/vendor/assets/javascripts/ueditor/third-party/codemirror/codemirror.js +3581 -0
  215. data/vendor/assets/javascripts/ueditor/third-party/fClipboard_ueditor.swf +0 -0
  216. data/vendor/assets/javascripts/ueditor/third-party/imageUploader.swf +0 -0
  217. data/vendor/assets/javascripts/ueditor/third-party/snapscreen/UEditorSnapscreen.exe +0 -0
  218. data/vendor/assets/javascripts/ueditor/third-party/swfupload/fileprogress.js +215 -0
  219. data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.cookies.js +53 -0
  220. data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.js +1132 -0
  221. data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.proxy.js +96 -0
  222. data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.queue.js +98 -0
  223. data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.speed.js +346 -0
  224. data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.swf +0 -0
  225. data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload_fp9.swf +0 -0
  226. data/vendor/assets/javascripts/ueditor/uparse.js +348 -0
  227. metadata +363 -0
@@ -0,0 +1,215 @@
1
+ /*
2
+ A simple class for displaying file information and progress
3
+ Note: This is a demonstration only and not part of SWFUpload.
4
+ Note: Some have had problems adapting this class in IE7. It may not be suitable for your application.
5
+ */
6
+
7
+ // Constructor
8
+ // file is a SWFUpload file object
9
+ // targetID is the HTML element id attribute that the FileProgress HTML structure will be added to.
10
+ // Instantiating a new FileProgress object with an existing file will reuse/update the existing DOM elements
11
+ function FileProgress(file, targetID) {
12
+ this.fileProgressID = file.id;
13
+
14
+ this.opacity = 100;
15
+ this.height = 0;
16
+
17
+
18
+ this.fileProgressWrapper = document.getElementById(this.fileProgressID);
19
+ if (!this.fileProgressWrapper) {
20
+ this.fileProgressWrapper = document.createElement("div");
21
+ this.fileProgressWrapper.className = "progressWrapper";
22
+ this.fileProgressWrapper.id = this.fileProgressID;
23
+
24
+ this.fileProgressElement = document.createElement("div");
25
+ this.fileProgressElement.className = "progressContainer";
26
+
27
+ var progressCancel = document.createElement("a");
28
+ progressCancel.className = "progressCancel";
29
+ progressCancel.href = "#";
30
+ progressCancel.style.visibility = "hidden";
31
+ progressCancel.appendChild(document.createTextNode(" "));
32
+
33
+ //by ue
34
+ progressCancel.onclick = function(){
35
+ alert(1);
36
+ }
37
+
38
+ var progressText = document.createElement("div");
39
+ progressText.className = "progressName";
40
+ progressText.appendChild(document.createTextNode(file.name));
41
+
42
+ var progressBar = document.createElement("div");
43
+ progressBar.className = "progressBarInProgress";
44
+
45
+ var progressStatus = document.createElement("div");
46
+ progressStatus.className = "progressBarStatus";
47
+ progressStatus.innerHTML = " ";
48
+
49
+ this.fileProgressElement.appendChild(progressCancel);
50
+ this.fileProgressElement.appendChild(progressText);
51
+ this.fileProgressElement.appendChild(progressStatus);
52
+ this.fileProgressElement.appendChild(progressBar);
53
+
54
+ this.fileProgressWrapper.appendChild(this.fileProgressElement);
55
+
56
+ document.getElementById(targetID).appendChild(this.fileProgressWrapper);
57
+ } else {
58
+ this.fileProgressElement = this.fileProgressWrapper.firstChild;
59
+ this.reset();
60
+ }
61
+
62
+ this.height = this.fileProgressWrapper.offsetHeight;
63
+ this.setTimer(null);
64
+
65
+
66
+ }
67
+
68
+ FileProgress.prototype.setTimer = function (timer) {
69
+ this.fileProgressElement["FP_TIMER"] = timer;
70
+ };
71
+ FileProgress.prototype.getTimer = function (timer) {
72
+ return this.fileProgressElement["FP_TIMER"] || null;
73
+ };
74
+
75
+ FileProgress.prototype.reset = function () {
76
+ this.fileProgressElement.className = "progressContainer";
77
+
78
+ this.fileProgressElement.childNodes[2].innerHTML = " ";
79
+ this.fileProgressElement.childNodes[2].className = "progressBarStatus";
80
+
81
+ this.fileProgressElement.childNodes[3].className = "progressBarInProgress";
82
+ this.fileProgressElement.childNodes[3].style.width = "0%";
83
+
84
+ this.appear();
85
+ };
86
+
87
+ FileProgress.prototype.setProgress = function (percentage) {
88
+ this.fileProgressElement.className = "progressContainer green";
89
+ this.fileProgressElement.childNodes[3].className = "progressBarInProgress";
90
+ this.fileProgressElement.childNodes[3].style.width = percentage + "%";
91
+
92
+ this.appear();
93
+ };
94
+ FileProgress.prototype.setComplete = function () {
95
+ this.fileProgressElement.className = "progressContainer blue";
96
+ this.fileProgressElement.childNodes[3].className = "progressBarComplete";
97
+ this.fileProgressElement.childNodes[3].style.width = "";
98
+
99
+ var oSelf = this;
100
+ this.setTimer(setTimeout(function () {
101
+ //oSelf.disappear(); //隐藏已完成列表
102
+ }, 10000));
103
+ };
104
+ FileProgress.prototype.setError = function () {
105
+ this.fileProgressElement.className = "progressContainer red";
106
+ this.fileProgressElement.childNodes[3].className = "progressBarError";
107
+ this.fileProgressElement.childNodes[3].style.width = "";
108
+ //edir by ue
109
+ var oSelf = this;
110
+ this.setTimer(setTimeout(function () {
111
+ //oSelf.disappear();
112
+ }, 3000));
113
+ };
114
+ FileProgress.prototype.setCancelled = function () {
115
+ this.fileProgressElement.className = "progressContainer";
116
+ this.fileProgressElement.childNodes[3].className = "progressBarError";
117
+ this.fileProgressElement.childNodes[3].style.width = "";
118
+
119
+ var oSelf = this;
120
+ this.setTimer(setTimeout(function () {
121
+ oSelf.disappear();
122
+ }, 1000));
123
+ };
124
+ FileProgress.prototype.setStatus = function (status) {
125
+ this.fileProgressElement.childNodes[2].innerHTML = status;
126
+ };
127
+
128
+ // Show/Hide the cancel button
129
+ FileProgress.prototype.toggleCancel = function (show, swfUploadInstance,message) {
130
+ //edit by ue
131
+ var cancelBtn = this.fileProgressElement.childNodes[0];
132
+ cancelBtn.style.visibility = show ? "visible" : "hidden";
133
+ cancelBtn.title = message?message:"取消上传";
134
+ if (swfUploadInstance) {
135
+ //edit by ue
136
+ var me = this;
137
+ var fileID = me.fileProgressID,
138
+ e = me.fileProgressElement;
139
+ e.children[0].onclick = function () {
140
+ me.disappear();
141
+ swfUploadInstance.cancelUpload(fileID);
142
+ return false;
143
+ };
144
+ }
145
+ };
146
+
147
+ FileProgress.prototype.appear = function () {
148
+ if (this.getTimer() !== null) {
149
+ clearTimeout(this.getTimer());
150
+ this.setTimer(null);
151
+ }
152
+
153
+ if (this.fileProgressWrapper.filters) {
154
+ try {
155
+ this.fileProgressWrapper.filters.item("DXImageTransform.Microsoft.Alpha").opacity = 100;
156
+ } catch (e) {
157
+ // If it is not set initially, the browser will throw an error. This will set it if it is not set yet.
158
+ this.fileProgressWrapper.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
159
+ }
160
+ } else {
161
+ this.fileProgressWrapper.style.opacity = 1;
162
+ }
163
+
164
+ this.fileProgressWrapper.style.height = "";
165
+
166
+ this.height = this.fileProgressWrapper.offsetHeight;
167
+ this.opacity = 100;
168
+ this.fileProgressWrapper.style.display = "";
169
+
170
+ };
171
+
172
+ // Fades out and clips away the FileProgress box.
173
+ FileProgress.prototype.disappear = function () {
174
+
175
+ var reduceOpacityBy = 15;
176
+ var reduceHeightBy = 4;
177
+ var rate = 30; // 15 fps
178
+
179
+ if (this.opacity > 0) {
180
+ this.opacity -= reduceOpacityBy;
181
+ if (this.opacity < 0) {
182
+ this.opacity = 0;
183
+ }
184
+
185
+ if (this.fileProgressWrapper.filters) {
186
+ try {
187
+ this.fileProgressWrapper.filters.item("DXImageTransform.Microsoft.Alpha").opacity = this.opacity;
188
+ } catch (e) {
189
+ // If it is not set initially, the browser will throw an error. This will set it if it is not set yet.
190
+ this.fileProgressWrapper.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + this.opacity + ")";
191
+ }
192
+ } else {
193
+ this.fileProgressWrapper.style.opacity = this.opacity / 100;
194
+ }
195
+ }
196
+
197
+ if (this.height > 0) {
198
+ this.height -= reduceHeightBy;
199
+ if (this.height < 0) {
200
+ this.height = 0;
201
+ }
202
+
203
+ this.fileProgressWrapper.style.height = this.height + "px";
204
+ }
205
+
206
+ if (this.height > 0 || this.opacity > 0) {
207
+ var oSelf = this;
208
+ this.setTimer(setTimeout(function () {
209
+ oSelf.disappear();
210
+ }, rate));
211
+ } else {
212
+ this.fileProgressWrapper.style.display = "none";
213
+ this.setTimer(null);
214
+ }
215
+ };
@@ -0,0 +1,53 @@
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
+ */
8
+
9
+ var SWFUpload;
10
+ if (typeof(SWFUpload) === "function") {
11
+ SWFUpload.prototype.initSettings = function (oldInitSettings) {
12
+ return function (userSettings) {
13
+ if (typeof(oldInitSettings) === "function") {
14
+ oldInitSettings.call(this, userSettings);
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
+
53
+ }
@@ -0,0 +1,1132 @@
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 Nilzn 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.ensureDefault = function (settingName, defaultValue) {
149
+ var setting = userSettings[settingName];
150
+ if (setting != undefined) {
151
+ this.settings[settingName] = setting;
152
+ } else {
153
+ this.settings[settingName] = defaultValue;
154
+ }
155
+ };
156
+
157
+ // Upload backend settings
158
+ this.ensureDefault("upload_url", "");
159
+ this.ensureDefault("preserve_relative_urls", false);
160
+ this.ensureDefault("file_post_name", "Filedata");
161
+ this.ensureDefault("post_params", {});
162
+ this.ensureDefault("use_query_string", false);
163
+ this.ensureDefault("requeue_on_error", false);
164
+ this.ensureDefault("http_success", []);
165
+ this.ensureDefault("assume_success_timeout", 0);
166
+
167
+ // File Settings
168
+ this.ensureDefault("file_types", "*.*");
169
+ this.ensureDefault("file_types_description", "All Files");
170
+ this.ensureDefault("file_size_limit", 0); // Default zero means "unlimited"
171
+ this.ensureDefault("file_upload_limit", 0);
172
+ this.ensureDefault("file_queue_limit", 0);
173
+
174
+ // Flash Settings
175
+ this.ensureDefault("flash_url", "swfupload.swf");
176
+ this.ensureDefault("flash9_url", "swfupload_fp9.swf");
177
+ this.ensureDefault("prevent_swf_caching", true);
178
+
179
+ // Button Settings
180
+ this.ensureDefault("button_image_url", "");
181
+ this.ensureDefault("button_width", 1);
182
+ this.ensureDefault("button_height", 1);
183
+ this.ensureDefault("button_text", "");
184
+ this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;");
185
+ this.ensureDefault("button_text_top_padding", 0);
186
+ this.ensureDefault("button_text_left_padding", 0);
187
+ this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES);
188
+ this.ensureDefault("button_disabled", false);
189
+ this.ensureDefault("button_placeholder_id", "");
190
+ this.ensureDefault("button_placeholder", null);
191
+ this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW);
192
+ this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW);
193
+
194
+ // Debug Settings
195
+ this.ensureDefault("debug", false);
196
+ this.settings.debug_enabled = this.settings.debug; // Here to maintain v2 API
197
+
198
+ // Event Handlers
199
+ this.settings.return_upload_start_handler = this.returnUploadStart;
200
+ this.ensureDefault("swfupload_preload_handler", null);
201
+ this.ensureDefault("swfupload_load_failed_handler", null);
202
+ this.ensureDefault("swfupload_loaded_handler", null);
203
+ this.ensureDefault("file_dialog_start_handler", null);
204
+ this.ensureDefault("file_queued_handler", null);
205
+ this.ensureDefault("file_queue_error_handler", null);
206
+ this.ensureDefault("file_dialog_complete_handler", null);
207
+
208
+ this.ensureDefault("upload_resize_start_handler", null);
209
+ this.ensureDefault("upload_start_handler", null);
210
+ this.ensureDefault("upload_progress_handler", null);
211
+ this.ensureDefault("upload_error_handler", null);
212
+ this.ensureDefault("upload_success_handler", null);
213
+ this.ensureDefault("upload_complete_handler", null);
214
+
215
+ this.ensureDefault("mouse_click_handler", null);
216
+ this.ensureDefault("mouse_out_handler", null);
217
+ this.ensureDefault("mouse_over_handler", null);
218
+
219
+ this.ensureDefault("debug_handler", this.debugMessage);
220
+
221
+ this.ensureDefault("custom_settings", {});
222
+
223
+ // Other settings
224
+ this.customSettings = this.settings.custom_settings;
225
+
226
+ // Update the flash url if needed
227
+ if (!!this.settings.prevent_swf_caching) {
228
+ this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime();
229
+ this.settings.flash9_url = this.settings.flash9_url + (this.settings.flash9_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime();
230
+ }
231
+
232
+ if (!this.settings.preserve_relative_urls) {
233
+ this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url);
234
+ this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url);
235
+ }
236
+
237
+ delete this.ensureDefault;
238
+ };
239
+
240
+ // Initializes the supported functionality based the Flash Player version, state, and event that occur during initialization
241
+ SWFUpload.prototype.loadSupport = function () {
242
+ this.support = {
243
+ loading : swfobject.hasFlashPlayerVersion("9.0.28"),
244
+ imageResize : swfobject.hasFlashPlayerVersion("10.0.0")
245
+ };
246
+
247
+ };
248
+
249
+ // Private: loadFlash replaces the button_placeholder element with the flash movie.
250
+ SWFUpload.prototype.loadFlash = function () {
251
+ var targetElement, tempParent, wrapperType, flashHTML, els;
252
+
253
+ if (!this.support.loading) {
254
+ this.queueEvent("swfupload_load_failed_handler", ["Flash Player doesn't support SWFUpload"]);
255
+ return;
256
+ }
257
+
258
+ // Make sure an element with the ID we are going to use doesn't already exist
259
+ if (document.getElementById(this.movieName) !== null) {
260
+ this.support.loading = false;
261
+ this.queueEvent("swfupload_load_failed_handler", ["Element ID already in use"]);
262
+ return;
263
+ }
264
+
265
+ // Get the element where we will be placing the flash movie
266
+ targetElement = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder;
267
+
268
+ if (targetElement == undefined) {
269
+ this.support.loading = false;
270
+ this.queueEvent("swfupload_load_failed_handler", ["button place holder not found"]);
271
+ return;
272
+ }
273
+
274
+ wrapperType = (targetElement.currentStyle && targetElement.currentStyle["display"] || window.getComputedStyle && document.defaultView.getComputedStyle(targetElement, null).getPropertyValue("display")) !== "block" ? "span" : "div";
275
+
276
+ // Append the container and load the flash
277
+ tempParent = document.createElement(wrapperType);
278
+
279
+ flashHTML = this.getFlashHTML();
280
+
281
+ try {
282
+ tempParent.innerHTML = flashHTML; // Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers)
283
+ } catch (ex) {
284
+ this.support.loading = false;
285
+ this.queueEvent("swfupload_load_failed_handler", ["Exception loading Flash HTML into placeholder"]);
286
+ return;
287
+ }
288
+
289
+ // Try to get the movie element immediately
290
+ els = tempParent.getElementsByTagName("object");
291
+ if (!els || els.length > 1 || els.length === 0) {
292
+ this.support.loading = false;
293
+ this.queueEvent("swfupload_load_failed_handler", ["Unable to find movie after adding to DOM"]);
294
+ return;
295
+ } else if (els.length === 1) {
296
+ this.movieElement = els[0];
297
+ }
298
+
299
+ targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement);
300
+
301
+ // Fix IE Flash/Form bug
302
+ if (window[this.movieName] == undefined) {
303
+ window[this.movieName] = this.getMovieElement();
304
+ }
305
+ };
306
+
307
+ // Private: getFlashHTML generates the object tag needed to embed the flash in to the document
308
+ SWFUpload.prototype.getFlashHTML = function (flashVersion) {
309
+ // Flash Satay object syntax: http://www.alistapart.com/articles/flashsatay
310
+ 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">',
311
+ '<param name="wmode" value="', this.settings.button_window_mode, '" />',
312
+ '<param name="movie" value="', (this.support.imageResize ? this.settings.flash_url : this.settings.flash9_url), '" />',
313
+ '<param name="quality" value="high" />',
314
+ '<param name="allowScriptAccess" value="always" />',
315
+ '<param name="flashvars" value="' + this.getFlashVars() + '" />',
316
+ '</object>'].join("");
317
+ };
318
+
319
+ // Private: getFlashVars builds the parameter string that will be passed
320
+ // to flash in the flashvars param.
321
+ SWFUpload.prototype.getFlashVars = function () {
322
+ // Build a string from the post param object
323
+ var httpSuccessString, paramString;
324
+
325
+ paramString = this.buildParamString();
326
+ httpSuccessString = this.settings.http_success.join(",");
327
+
328
+ // Build the parameter string
329
+ return ["movieName=", encodeURIComponent(this.movieName),
330
+ "&amp;uploadURL=", encodeURIComponent(this.settings.upload_url),
331
+ "&amp;useQueryString=", encodeURIComponent(this.settings.use_query_string),
332
+ "&amp;requeueOnError=", encodeURIComponent(this.settings.requeue_on_error),
333
+ "&amp;httpSuccess=", encodeURIComponent(httpSuccessString),
334
+ "&amp;assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout),
335
+ "&amp;params=", encodeURIComponent(paramString),
336
+ "&amp;filePostName=", encodeURIComponent(this.settings.file_post_name),
337
+ "&amp;fileTypes=", encodeURIComponent(this.settings.file_types),
338
+ "&amp;fileTypesDescription=", encodeURIComponent(this.settings.file_types_description),
339
+ "&amp;fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit),
340
+ "&amp;fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit),
341
+ "&amp;fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit),
342
+ "&amp;debugEnabled=", encodeURIComponent(this.settings.debug_enabled),
343
+ "&amp;buttonImageURL=", encodeURIComponent(this.settings.button_image_url),
344
+ "&amp;buttonWidth=", encodeURIComponent(this.settings.button_width),
345
+ "&amp;buttonHeight=", encodeURIComponent(this.settings.button_height),
346
+ "&amp;buttonText=", encodeURIComponent(this.settings.button_text),
347
+ "&amp;buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding),
348
+ "&amp;buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding),
349
+ "&amp;buttonTextStyle=", encodeURIComponent(this.settings.button_text_style),
350
+ "&amp;buttonAction=", encodeURIComponent(this.settings.button_action),
351
+ "&amp;buttonDisabled=", encodeURIComponent(this.settings.button_disabled),
352
+ "&amp;buttonCursor=", encodeURIComponent(this.settings.button_cursor)
353
+ ].join("");
354
+ };
355
+
356
+ // Public: get retrieves the DOM reference to the Flash element added by SWFUpload
357
+ // The element is cached after the first lookup
358
+ SWFUpload.prototype.getMovieElement = function () {
359
+ if (this.movieElement == undefined) {
360
+ this.movieElement = document.getElementById(this.movieName);
361
+ }
362
+
363
+ if (this.movieElement === null) {
364
+ throw "Could not find Flash element";
365
+ }
366
+
367
+ return this.movieElement;
368
+ };
369
+
370
+ // Private: buildParamString takes the name/value pairs in the post_params setting object
371
+ // and joins them up in to a string formatted "name=value&amp;name=value"
372
+ SWFUpload.prototype.buildParamString = function () {
373
+ var name, postParams, paramStringPairs = [];
374
+
375
+ postParams = this.settings.post_params;
376
+
377
+ if (typeof(postParams) === "object") {
378
+ for (name in postParams) {
379
+ if (postParams.hasOwnProperty(name)) {
380
+ paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString()));
381
+ }
382
+ }
383
+ }
384
+
385
+ return paramStringPairs.join("&amp;");
386
+ };
387
+
388
+ // Public: Used to remove a SWFUpload instance from the page. This method strives to remove
389
+ // all references to the SWF, and other objects so memory is properly freed.
390
+ // Returns true if everything was destroyed. Returns a false if a failure occurs leaving SWFUpload in an inconsistant state.
391
+ // Credits: Major improvements provided by steffen
392
+ SWFUpload.prototype.destroy = function () {
393
+ var movieElement;
394
+
395
+ try {
396
+ // Make sure Flash is done before we try to remove it
397
+ this.cancelUpload(null, false);
398
+
399
+ movieElement = this.cleanUp();
400
+
401
+ // Remove the SWFUpload DOM nodes
402
+ if (movieElement) {
403
+ // Remove the Movie Element from the page
404
+ try {
405
+ movieElement.parentNode.removeChild(movieElement);
406
+ } catch (ex) {}
407
+ }
408
+
409
+ // Remove IE form fix reference
410
+ window[this.movieName] = null;
411
+
412
+ // Destroy other references
413
+ SWFUpload.instances[this.movieName] = null;
414
+ delete SWFUpload.instances[this.movieName];
415
+
416
+ this.movieElement = null;
417
+ this.settings = null;
418
+ this.customSettings = null;
419
+ this.eventQueue = null;
420
+ this.movieName = null;
421
+
422
+
423
+ return true;
424
+ } catch (ex2) {
425
+ return false;
426
+ }
427
+ };
428
+
429
+
430
+ // Public: displayDebugInfo prints out settings and configuration
431
+ // information about this SWFUpload instance.
432
+ // This function (and any references to it) can be deleted when placing
433
+ // SWFUpload in production.
434
+ SWFUpload.prototype.displayDebugInfo = function () {
435
+ this.debug(
436
+ [
437
+ "---SWFUpload Instance Info---\n",
438
+ "Version: ", SWFUpload.version, "\n",
439
+ "Movie Name: ", this.movieName, "\n",
440
+ "Settings:\n",
441
+ "\t", "upload_url: ", this.settings.upload_url, "\n",
442
+ "\t", "flash_url: ", this.settings.flash_url, "\n",
443
+ "\t", "flash9_url: ", this.settings.flash9_url, "\n",
444
+ "\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n",
445
+ "\t", "requeue_on_error: ", this.settings.requeue_on_error.toString(), "\n",
446
+ "\t", "http_success: ", this.settings.http_success.join(", "), "\n",
447
+ "\t", "assume_success_timeout: ", this.settings.assume_success_timeout, "\n",
448
+ "\t", "file_post_name: ", this.settings.file_post_name, "\n",
449
+ "\t", "post_params: ", this.settings.post_params.toString(), "\n",
450
+ "\t", "file_types: ", this.settings.file_types, "\n",
451
+ "\t", "file_types_description: ", this.settings.file_types_description, "\n",
452
+ "\t", "file_size_limit: ", this.settings.file_size_limit, "\n",
453
+ "\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n",
454
+ "\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n",
455
+ "\t", "debug: ", this.settings.debug.toString(), "\n",
456
+
457
+ "\t", "prevent_swf_caching: ", this.settings.prevent_swf_caching.toString(), "\n",
458
+
459
+ "\t", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n",
460
+ "\t", "button_placeholder: ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n",
461
+ "\t", "button_image_url: ", this.settings.button_image_url.toString(), "\n",
462
+ "\t", "button_width: ", this.settings.button_width.toString(), "\n",
463
+ "\t", "button_height: ", this.settings.button_height.toString(), "\n",
464
+ "\t", "button_text: ", this.settings.button_text.toString(), "\n",
465
+ "\t", "button_text_style: ", this.settings.button_text_style.toString(), "\n",
466
+ "\t", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n",
467
+ "\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n",
468
+ "\t", "button_action: ", this.settings.button_action.toString(), "\n",
469
+ "\t", "button_cursor: ", this.settings.button_cursor.toString(), "\n",
470
+ "\t", "button_disabled: ", this.settings.button_disabled.toString(), "\n",
471
+
472
+ "\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n",
473
+ "Event Handlers:\n",
474
+ "\t", "swfupload_preload_handler assigned: ", (typeof this.settings.swfupload_preload_handler === "function").toString(), "\n",
475
+ "\t", "swfupload_load_failed_handler assigned: ", (typeof this.settings.swfupload_load_failed_handler === "function").toString(), "\n",
476
+ "\t", "swfupload_loaded_handler assigned: ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n",
477
+ "\t", "mouse_click_handler assigned: ", (typeof this.settings.mouse_click_handler === "function").toString(), "\n",
478
+ "\t", "mouse_over_handler assigned: ", (typeof this.settings.mouse_over_handler === "function").toString(), "\n",
479
+ "\t", "mouse_out_handler assigned: ", (typeof this.settings.mouse_out_handler === "function").toString(), "\n",
480
+ "\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n",
481
+ "\t", "file_queued_handler assigned: ", (typeof this.settings.file_queued_handler === "function").toString(), "\n",
482
+ "\t", "file_queue_error_handler assigned: ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n",
483
+ "\t", "upload_resize_start_handler assigned: ", (typeof this.settings.upload_resize_start_handler === "function").toString(), "\n",
484
+ "\t", "upload_start_handler assigned: ", (typeof this.settings.upload_start_handler === "function").toString(), "\n",
485
+ "\t", "upload_progress_handler assigned: ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n",
486
+ "\t", "upload_error_handler assigned: ", (typeof this.settings.upload_error_handler === "function").toString(), "\n",
487
+ "\t", "upload_success_handler assigned: ", (typeof this.settings.upload_success_handler === "function").toString(), "\n",
488
+ "\t", "upload_complete_handler assigned: ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n",
489
+ "\t", "debug_handler assigned: ", (typeof this.settings.debug_handler === "function").toString(), "\n",
490
+
491
+ "Support:\n",
492
+ "\t", "Load: ", (this.support.loading ? "Yes" : "No"), "\n",
493
+ "\t", "Image Resize: ", (this.support.imageResize ? "Yes" : "No"), "\n"
494
+
495
+ ].join("")
496
+ );
497
+ };
498
+
499
+ /* Note: addSetting and getSetting are no longer used by SWFUpload but are included
500
+ the maintain v2 API compatibility
501
+ */
502
+ // Public: (Deprecated) addSetting adds a setting value. If the value given is undefined or null then the default_value is used.
503
+ SWFUpload.prototype.addSetting = function (name, value, default_value) {
504
+ if (value == undefined) {
505
+ return (this.settings[name] = default_value);
506
+ } else {
507
+ return (this.settings[name] = value);
508
+ }
509
+ };
510
+
511
+ // Public: (Deprecated) getSetting gets a setting. Returns an empty string if the setting was not found.
512
+ SWFUpload.prototype.getSetting = function (name) {
513
+ if (this.settings[name] != undefined) {
514
+ return this.settings[name];
515
+ }
516
+
517
+ return "";
518
+ };
519
+
520
+
521
+
522
+ // Private: callFlash handles function calls made to the Flash element.
523
+ // Calls are made with a setTimeout for some functions to work around
524
+ // bugs in the ExternalInterface library.
525
+ SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
526
+ var movieElement, returnValue, returnString;
527
+
528
+ argumentArray = argumentArray || [];
529
+ movieElement = this.getMovieElement();
530
+
531
+ // Flash's method if calling ExternalInterface methods (code adapted from MooTools).
532
+ try {
533
+ if (movieElement != undefined) {
534
+ returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + '</invoke>');
535
+ returnValue = eval(returnString);
536
+ } else {
537
+ this.debug("Can't call flash because the movie wasn't found.");
538
+ }
539
+ } catch (ex) {
540
+ this.debug("Exception calling flash function '" + functionName + "': " + ex.message);
541
+ }
542
+
543
+ // Unescape file post param values
544
+ if (returnValue != undefined && typeof returnValue.post === "object") {
545
+ returnValue = this.unescapeFilePostParams(returnValue);
546
+ }
547
+
548
+ return returnValue;
549
+ };
550
+
551
+ /* *****************************
552
+ -- Flash control methods --
553
+ Your UI should use these
554
+ to operate SWFUpload
555
+ ***************************** */
556
+
557
+ // WARNING: this function does not work in Flash Player 10
558
+ // Public: selectFile causes a File Selection Dialog window to appear. This
559
+ // dialog only allows 1 file to be selected.
560
+ SWFUpload.prototype.selectFile = function () {
561
+ this.callFlash("SelectFile");
562
+ };
563
+
564
+ // WARNING: this function does not work in Flash Player 10
565
+ // Public: selectFiles causes a File Selection Dialog window to appear/ This
566
+ // dialog allows the user to select any number of files
567
+ // Flash Bug Warning: Flash limits the number of selectable files based on the combined length of the file names.
568
+ // If the selection name length is too long the dialog will fail in an unpredictable manner. There is no work-around
569
+ // for this bug.
570
+ SWFUpload.prototype.selectFiles = function () {
571
+ this.callFlash("SelectFiles");
572
+ };
573
+
574
+
575
+ // Public: startUpload starts uploading the first file in the queue unless
576
+ // the optional parameter 'fileID' specifies the ID
577
+ SWFUpload.prototype.startUpload = function (fileID) {
578
+ this.callFlash("StartUpload", [fileID]);
579
+ };
580
+
581
+ // Public: startUpload starts uploading the first file in the queue unless
582
+ // the optional parameter 'fileID' specifies the ID
583
+ SWFUpload.prototype.startResizedUpload = function (fileID, width, height, encoding, quality, allowEnlarging) {
584
+ this.callFlash("StartUpload", [fileID, { "width": width, "height" : height, "encoding" : encoding, "quality" : quality, "allowEnlarging" : allowEnlarging }]);
585
+ };
586
+
587
+ // Public: cancelUpload cancels any queued file. The fileID parameter may be the file ID or index.
588
+ // If you do not specify a fileID the current uploading file or first file in the queue is cancelled.
589
+ // If you do not want the uploadError event to trigger you can specify false for the triggerErrorEvent parameter.
590
+ SWFUpload.prototype.cancelUpload = function (fileID, triggerErrorEvent) {
591
+ if (triggerErrorEvent !== false) {
592
+ triggerErrorEvent = true;
593
+ }
594
+ this.callFlash("CancelUpload", [fileID, triggerErrorEvent]);
595
+ };
596
+
597
+ // Public: stopUpload stops the current upload and requeues the file at the beginning of the queue.
598
+ // If nothing is currently uploading then nothing happens.
599
+ SWFUpload.prototype.stopUpload = function () {
600
+ this.callFlash("StopUpload");
601
+ };
602
+
603
+
604
+ // Public: requeueUpload requeues any file. If the file is requeued or already queued true is returned.
605
+ // If the file is not found or is currently uploading false is returned. Requeuing a file bypasses the
606
+ // file size, queue size, upload limit and other queue checks. Certain files can't be requeued (e.g, invalid or zero bytes files).
607
+ SWFUpload.prototype.requeueUpload = function (indexOrFileID) {
608
+ return this.callFlash("RequeueUpload", [indexOrFileID]);
609
+ };
610
+
611
+
612
+ /* ************************
613
+ * Settings methods
614
+ * These methods change the SWFUpload settings.
615
+ * SWFUpload settings should not be changed directly on the settings object
616
+ * since many of the settings need to be passed to Flash in order to take
617
+ * effect.
618
+ * *********************** */
619
+
620
+ // Public: getStats gets the file statistics object.
621
+ SWFUpload.prototype.getStats = function () {
622
+ return this.callFlash("GetStats");
623
+ };
624
+
625
+ // Public: setStats changes the SWFUpload statistics. You shouldn't need to
626
+ // change the statistics but you can. Changing the statistics does not
627
+ // affect SWFUpload accept for the successful_uploads count which is used
628
+ // by the upload_limit setting to determine how many files the user may upload.
629
+ SWFUpload.prototype.setStats = function (statsObject) {
630
+ this.callFlash("SetStats", [statsObject]);
631
+ };
632
+
633
+ // Public: getFile retrieves a File object by ID or Index. If the file is
634
+ // not found then 'null' is returned.
635
+ SWFUpload.prototype.getFile = function (fileID) {
636
+ if (typeof(fileID) === "number") {
637
+ return this.callFlash("GetFileByIndex", [fileID]);
638
+ } else {
639
+ return this.callFlash("GetFile", [fileID]);
640
+ }
641
+ };
642
+
643
+ // Public: getFileFromQueue retrieves a File object by ID or Index. If the file is
644
+ // not found then 'null' is returned.
645
+ SWFUpload.prototype.getQueueFile = function (fileID) {
646
+ if (typeof(fileID) === "number") {
647
+ return this.callFlash("GetFileByQueueIndex", [fileID]);
648
+ } else {
649
+ return this.callFlash("GetFile", [fileID]);
650
+ }
651
+ };
652
+
653
+
654
+ // Public: addFileParam sets a name/value pair that will be posted with the
655
+ // file specified by the Files ID. If the name already exists then the
656
+ // exiting value will be overwritten.
657
+ SWFUpload.prototype.addFileParam = function (fileID, name, value) {
658
+ return this.callFlash("AddFileParam", [fileID, name, value]);
659
+ };
660
+
661
+ // Public: removeFileParam removes a previously set (by addFileParam) name/value
662
+ // pair from the specified file.
663
+ SWFUpload.prototype.removeFileParam = function (fileID, name) {
664
+ this.callFlash("RemoveFileParam", [fileID, name]);
665
+ };
666
+
667
+ // Public: setUploadUrl changes the upload_url setting.
668
+ SWFUpload.prototype.setUploadURL = function (url) {
669
+ this.settings.upload_url = url.toString();
670
+ this.callFlash("SetUploadURL", [url]);
671
+ };
672
+
673
+ // Public: setPostParams changes the post_params setting
674
+ SWFUpload.prototype.setPostParams = function (paramsObject) {
675
+ this.settings.post_params = paramsObject;
676
+ this.callFlash("SetPostParams", [paramsObject]);
677
+ };
678
+
679
+ // Public: addPostParam adds post name/value pair. Each name can have only one value.
680
+ SWFUpload.prototype.addPostParam = function (name, value) {
681
+ this.settings.post_params[name] = value;
682
+ this.callFlash("SetPostParams", [this.settings.post_params]);
683
+ };
684
+
685
+ // Public: removePostParam deletes post name/value pair.
686
+ SWFUpload.prototype.removePostParam = function (name) {
687
+ delete this.settings.post_params[name];
688
+ this.callFlash("SetPostParams", [this.settings.post_params]);
689
+ };
690
+
691
+ // Public: setFileTypes changes the file_types setting and the file_types_description setting
692
+ SWFUpload.prototype.setFileTypes = function (types, description) {
693
+ this.settings.file_types = types;
694
+ this.settings.file_types_description = description;
695
+ this.callFlash("SetFileTypes", [types, description]);
696
+ };
697
+
698
+ // Public: setFileSizeLimit changes the file_size_limit setting
699
+ SWFUpload.prototype.setFileSizeLimit = function (fileSizeLimit) {
700
+ this.settings.file_size_limit = fileSizeLimit;
701
+ this.callFlash("SetFileSizeLimit", [fileSizeLimit]);
702
+ };
703
+
704
+ // Public: setFileUploadLimit changes the file_upload_limit setting
705
+ SWFUpload.prototype.setFileUploadLimit = function (fileUploadLimit) {
706
+ this.settings.file_upload_limit = fileUploadLimit;
707
+ this.callFlash("SetFileUploadLimit", [fileUploadLimit]);
708
+ };
709
+
710
+ // Public: setFileQueueLimit changes the file_queue_limit setting
711
+ SWFUpload.prototype.setFileQueueLimit = function (fileQueueLimit) {
712
+ this.settings.file_queue_limit = fileQueueLimit;
713
+ this.callFlash("SetFileQueueLimit", [fileQueueLimit]);
714
+ };
715
+
716
+ // Public: setFilePostName changes the file_post_name setting
717
+ SWFUpload.prototype.setFilePostName = function (filePostName) {
718
+ this.settings.file_post_name = filePostName;
719
+ this.callFlash("SetFilePostName", [filePostName]);
720
+ };
721
+
722
+ // Public: setUseQueryString changes the use_query_string setting
723
+ SWFUpload.prototype.setUseQueryString = function (useQueryString) {
724
+ this.settings.use_query_string = useQueryString;
725
+ this.callFlash("SetUseQueryString", [useQueryString]);
726
+ };
727
+
728
+ // Public: setRequeueOnError changes the requeue_on_error setting
729
+ SWFUpload.prototype.setRequeueOnError = function (requeueOnError) {
730
+ this.settings.requeue_on_error = requeueOnError;
731
+ this.callFlash("SetRequeueOnError", [requeueOnError]);
732
+ };
733
+
734
+ // Public: setHTTPSuccess changes the http_success setting
735
+ SWFUpload.prototype.setHTTPSuccess = function (http_status_codes) {
736
+ if (typeof http_status_codes === "string") {
737
+ http_status_codes = http_status_codes.replace(" ", "").split(",");
738
+ }
739
+
740
+ this.settings.http_success = http_status_codes;
741
+ this.callFlash("SetHTTPSuccess", [http_status_codes]);
742
+ };
743
+
744
+ // Public: setHTTPSuccess changes the http_success setting
745
+ SWFUpload.prototype.setAssumeSuccessTimeout = function (timeout_seconds) {
746
+ this.settings.assume_success_timeout = timeout_seconds;
747
+ this.callFlash("SetAssumeSuccessTimeout", [timeout_seconds]);
748
+ };
749
+
750
+ // Public: setDebugEnabled changes the debug_enabled setting
751
+ SWFUpload.prototype.setDebugEnabled = function (debugEnabled) {
752
+ this.settings.debug_enabled = debugEnabled;
753
+ this.callFlash("SetDebugEnabled", [debugEnabled]);
754
+ };
755
+
756
+ // Public: setButtonImageURL loads a button image sprite
757
+ SWFUpload.prototype.setButtonImageURL = function (buttonImageURL) {
758
+ if (buttonImageURL == undefined) {
759
+ buttonImageURL = "";
760
+ }
761
+
762
+ this.settings.button_image_url = buttonImageURL;
763
+ this.callFlash("SetButtonImageURL", [buttonImageURL]);
764
+ };
765
+
766
+ // Public: setButtonDimensions resizes the Flash Movie and button
767
+ SWFUpload.prototype.setButtonDimensions = function (width, height) {
768
+ this.settings.button_width = width;
769
+ this.settings.button_height = height;
770
+
771
+ var movie = this.getMovieElement();
772
+ if (movie != undefined) {
773
+ movie.style.width = width + "px";
774
+ movie.style.height = height + "px";
775
+ }
776
+
777
+ this.callFlash("SetButtonDimensions", [width, height]);
778
+ };
779
+ // Public: setButtonText Changes the text overlaid on the button
780
+ SWFUpload.prototype.setButtonText = function (html) {
781
+ this.settings.button_text = html;
782
+ this.callFlash("SetButtonText", [html]);
783
+ };
784
+ // Public: setButtonTextPadding changes the top and left padding of the text overlay
785
+ SWFUpload.prototype.setButtonTextPadding = function (left, top) {
786
+ this.settings.button_text_top_padding = top;
787
+ this.settings.button_text_left_padding = left;
788
+ this.callFlash("SetButtonTextPadding", [left, top]);
789
+ };
790
+
791
+ // Public: setButtonTextStyle changes the CSS used to style the HTML/Text overlaid on the button
792
+ SWFUpload.prototype.setButtonTextStyle = function (css) {
793
+ this.settings.button_text_style = css;
794
+ this.callFlash("SetButtonTextStyle", [css]);
795
+ };
796
+ // Public: setButtonDisabled disables/enables the button
797
+ SWFUpload.prototype.setButtonDisabled = function (isDisabled) {
798
+ this.settings.button_disabled = isDisabled;
799
+ this.callFlash("SetButtonDisabled", [isDisabled]);
800
+ };
801
+ // Public: setButtonAction sets the action that occurs when the button is clicked
802
+ SWFUpload.prototype.setButtonAction = function (buttonAction) {
803
+ this.settings.button_action = buttonAction;
804
+ this.callFlash("SetButtonAction", [buttonAction]);
805
+ };
806
+
807
+ // Public: setButtonCursor changes the mouse cursor displayed when hovering over the button
808
+ SWFUpload.prototype.setButtonCursor = function (cursor) {
809
+ this.settings.button_cursor = cursor;
810
+ this.callFlash("SetButtonCursor", [cursor]);
811
+ };
812
+
813
+ /* *******************************
814
+ Flash Event Interfaces
815
+ These functions are used by Flash to trigger the various
816
+ events.
817
+
818
+ All these functions a Private.
819
+
820
+ Because the ExternalInterface library is buggy the event calls
821
+ are added to a queue and the queue then executed by a setTimeout.
822
+ This ensures that events are executed in a determinate order and that
823
+ the ExternalInterface bugs are avoided.
824
+ ******************************* */
825
+
826
+ SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) {
827
+ // Warning: Don't call this.debug inside here or you'll create an infinite loop
828
+ var self = this;
829
+
830
+ if (argumentArray == undefined) {
831
+ argumentArray = [];
832
+ } else if (!(argumentArray instanceof Array)) {
833
+ argumentArray = [argumentArray];
834
+ }
835
+
836
+ if (typeof this.settings[handlerName] === "function") {
837
+ // Queue the event
838
+ this.eventQueue.push(function () {
839
+ this.settings[handlerName].apply(this, argumentArray);
840
+ });
841
+
842
+ // Execute the next queued event
843
+ setTimeout(function () {
844
+ self.executeNextEvent();
845
+ }, 0);
846
+
847
+ } else if (this.settings[handlerName] !== null) {
848
+ throw "Event handler " + handlerName + " is unknown or is not a function";
849
+ }
850
+ };
851
+
852
+ // Private: Causes the next event in the queue to be executed. Since events are queued using a setTimeout
853
+ // we must queue them in order to garentee that they are executed in order.
854
+ SWFUpload.prototype.executeNextEvent = function () {
855
+ // Warning: Don't call this.debug inside here or you'll create an infinite loop
856
+
857
+ var f = this.eventQueue ? this.eventQueue.shift() : null;
858
+ if (typeof(f) === "function") {
859
+ f.apply(this);
860
+ }
861
+ };
862
+
863
+ // Private: unescapeFileParams is part of a workaround for a flash bug where objects passed through ExternalInterface cannot have
864
+ // properties that contain characters that are not valid for JavaScript identifiers. To work around this
865
+ // the Flash Component escapes the parameter names and we must unescape again before passing them along.
866
+ SWFUpload.prototype.unescapeFilePostParams = function (file) {
867
+ var reg = /[$]([0-9a-f]{4})/i, unescapedPost = {}, uk, k, match;
868
+
869
+ if (file != undefined) {
870
+ for (k in file.post) {
871
+ if (file.post.hasOwnProperty(k)) {
872
+ uk = k;
873
+ while ((match = reg.exec(uk)) !== null) {
874
+ uk = uk.replace(match[0], String.fromCharCode(parseInt("0x" + match[1], 16)));
875
+ }
876
+ unescapedPost[uk] = file.post[k];
877
+ }
878
+ }
879
+
880
+ file.post = unescapedPost;
881
+ }
882
+
883
+ return file;
884
+ };
885
+
886
+ // Private: This event is called by SWFUpload Init after we've determined what the user's Flash Player supports.
887
+ // Use the swfupload_preload_handler event setting to execute custom code when SWFUpload has loaded.
888
+ // Return false to prevent SWFUpload from loading and allow your script to do something else if your required feature is
889
+ // not supported
890
+ SWFUpload.prototype.swfuploadPreload = function () {
891
+ var returnValue;
892
+ if (typeof this.settings.swfupload_preload_handler === "function") {
893
+ returnValue = this.settings.swfupload_preload_handler.call(this);
894
+ } else if (this.settings.swfupload_preload_handler != undefined) {
895
+ throw "upload_start_handler must be a function";
896
+ }
897
+
898
+ // Convert undefined to true so if nothing is returned from the upload_start_handler it is
899
+ // interpretted as 'true'.
900
+ if (returnValue === undefined) {
901
+ returnValue = true;
902
+ }
903
+
904
+ return !!returnValue;
905
+ }
906
+
907
+ // Private: This event is called by Flash when it has finished loading. Don't modify this.
908
+ // Use the swfupload_loaded_handler event setting to execute custom code when SWFUpload has loaded.
909
+ SWFUpload.prototype.flashReady = function () {
910
+ // Check that the movie element is loaded correctly with its ExternalInterface methods defined
911
+ var movieElement = this.cleanUp();
912
+
913
+ if (!movieElement) {
914
+ this.debug("Flash called back ready but the flash movie can't be found.");
915
+ return;
916
+ }
917
+
918
+ this.queueEvent("swfupload_loaded_handler");
919
+ };
920
+
921
+ // Private: removes Flash added fuctions to the DOM node to prevent memory leaks in IE.
922
+ // This function is called by Flash each time the ExternalInterface functions are created.
923
+ SWFUpload.prototype.cleanUp = function () {
924
+ var key, movieElement = this.getMovieElement();
925
+
926
+ // Pro-actively unhook all the Flash functions
927
+ try {
928
+ if (movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
929
+ this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");
930
+ for (key in movieElement) {
931
+ try {
932
+ if (typeof(movieElement[key]) === "function") {
933
+ movieElement[key] = null;
934
+ }
935
+ } catch (ex) {
936
+ }
937
+ }
938
+ }
939
+ } catch (ex1) {
940
+
941
+ }
942
+
943
+ // Fix Flashes own cleanup code so if the SWF Movie was removed from the page
944
+ // it doesn't display errors.
945
+ window["__flash__removeCallback"] = function (instance, name) {
946
+ try {
947
+ if (instance) {
948
+ instance[name] = null;
949
+ }
950
+ } catch (flashEx) {
951
+
952
+ }
953
+ };
954
+
955
+ return movieElement;
956
+ };
957
+
958
+ /* When the button_action is set to None this event gets fired and executes the mouse_click_handler */
959
+ SWFUpload.prototype.mouseClick = function () {
960
+ this.queueEvent("mouse_click_handler");
961
+ };
962
+ SWFUpload.prototype.mouseOver = function () {
963
+ this.queueEvent("mouse_over_handler");
964
+ };
965
+ SWFUpload.prototype.mouseOut = function () {
966
+ this.queueEvent("mouse_out_handler");
967
+ };
968
+
969
+ /* This is a chance to do something before the browse window opens */
970
+ SWFUpload.prototype.fileDialogStart = function () {
971
+ this.queueEvent("file_dialog_start_handler");
972
+ };
973
+
974
+
975
+ /* Called when a file is successfully added to the queue. */
976
+ SWFUpload.prototype.fileQueued = function (file) {
977
+ file = this.unescapeFilePostParams(file);
978
+ this.queueEvent("file_queued_handler", file);
979
+ };
980
+
981
+
982
+ /* Handle errors that occur when an attempt to queue a file fails. */
983
+ SWFUpload.prototype.fileQueueError = function (file, errorCode, message) {
984
+ file = this.unescapeFilePostParams(file);
985
+ this.queueEvent("file_queue_error_handler", [file, errorCode, message]);
986
+ };
987
+
988
+ /* Called after the file dialog has closed and the selected files have been queued.
989
+ You could call startUpload here if you want the queued files to begin uploading immediately. */
990
+ SWFUpload.prototype.fileDialogComplete = function (numFilesSelected, numFilesQueued, numFilesInQueue) {
991
+ this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued, numFilesInQueue]);
992
+ };
993
+
994
+ SWFUpload.prototype.uploadResizeStart = function (file, resizeSettings) {
995
+ file = this.unescapeFilePostParams(file);
996
+ this.queueEvent("upload_resize_start_handler", [file, resizeSettings.width, resizeSettings.height, resizeSettings.encoding, resizeSettings.quality]);
997
+ };
998
+
999
+ SWFUpload.prototype.uploadStart = function (file) {
1000
+ file = this.unescapeFilePostParams(file);
1001
+ this.queueEvent("return_upload_start_handler", file);
1002
+ };
1003
+
1004
+ SWFUpload.prototype.returnUploadStart = function (file) {
1005
+ var returnValue;
1006
+ if (typeof this.settings.upload_start_handler === "function") {
1007
+ file = this.unescapeFilePostParams(file);
1008
+ returnValue = this.settings.upload_start_handler.call(this, file);
1009
+ } else if (this.settings.upload_start_handler != undefined) {
1010
+ throw "upload_start_handler must be a function";
1011
+ }
1012
+
1013
+ // Convert undefined to true so if nothing is returned from the upload_start_handler it is
1014
+ // interpretted as 'true'.
1015
+ if (returnValue === undefined) {
1016
+ returnValue = true;
1017
+ }
1018
+
1019
+ returnValue = !!returnValue;
1020
+
1021
+ this.callFlash("ReturnUploadStart", [returnValue]);
1022
+ };
1023
+
1024
+
1025
+
1026
+ SWFUpload.prototype.uploadProgress = function (file, bytesComplete, bytesTotal) {
1027
+ file = this.unescapeFilePostParams(file);
1028
+ this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]);
1029
+ };
1030
+
1031
+ SWFUpload.prototype.uploadError = function (file, errorCode, message) {
1032
+ file = this.unescapeFilePostParams(file);
1033
+ this.queueEvent("upload_error_handler", [file, errorCode, message]);
1034
+ };
1035
+
1036
+ SWFUpload.prototype.uploadSuccess = function (file, serverData, responseReceived) {
1037
+ file = this.unescapeFilePostParams(file);
1038
+ this.queueEvent("upload_success_handler", [file, serverData, responseReceived]);
1039
+ };
1040
+
1041
+ SWFUpload.prototype.uploadComplete = function (file) {
1042
+ file = this.unescapeFilePostParams(file);
1043
+ this.queueEvent("upload_complete_handler", file);
1044
+ };
1045
+
1046
+ /* Called by SWFUpload JavaScript and Flash functions when debug is enabled. By default it writes messages to the
1047
+ internal debug console. You can override this event and have messages written where you want. */
1048
+ SWFUpload.prototype.debug = function (message) {
1049
+ this.queueEvent("debug_handler", message);
1050
+ };
1051
+
1052
+
1053
+ /* **********************************
1054
+ Debug Console
1055
+ The debug console is a self contained, in page location
1056
+ for debug message to be sent. The Debug Console adds
1057
+ itself to the body if necessary.
1058
+
1059
+ The console is automatically scrolled as messages appear.
1060
+
1061
+ If you are using your own debug handler or when you deploy to production and
1062
+ have debug disabled you can remove these functions to reduce the file size
1063
+ and complexity.
1064
+ ********************************** */
1065
+
1066
+ // Private: debugMessage is the default debug_handler. If you want to print debug messages
1067
+ // call the debug() function. When overriding the function your own function should
1068
+ // check to see if the debug setting is true before outputting debug information.
1069
+ SWFUpload.prototype.debugMessage = function (message) {
1070
+ var exceptionMessage, exceptionValues, key;
1071
+
1072
+ if (this.settings.debug) {
1073
+ exceptionValues = [];
1074
+
1075
+ // Check for an exception object and print it nicely
1076
+ if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") {
1077
+ for (key in message) {
1078
+ if (message.hasOwnProperty(key)) {
1079
+ exceptionValues.push(key + ": " + message[key]);
1080
+ }
1081
+ }
1082
+ exceptionMessage = exceptionValues.join("\n") || "";
1083
+ exceptionValues = exceptionMessage.split("\n");
1084
+ exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: ");
1085
+ SWFUpload.Console.writeLine(exceptionMessage);
1086
+ } else {
1087
+ SWFUpload.Console.writeLine(message);
1088
+ }
1089
+ }
1090
+ };
1091
+
1092
+ SWFUpload.Console = {};
1093
+ SWFUpload.Console.writeLine = function (message) {
1094
+ var console, documentForm;
1095
+
1096
+ try {
1097
+ console = document.getElementById("SWFUpload_Console");
1098
+
1099
+ if (!console) {
1100
+ documentForm = document.createElement("form");
1101
+ document.getElementsByTagName("body")[0].appendChild(documentForm);
1102
+
1103
+ console = document.createElement("textarea");
1104
+ console.id = "SWFUpload_Console";
1105
+ console.style.fontFamily = "monospace";
1106
+ console.setAttribute("wrap", "off");
1107
+ console.wrap = "off";
1108
+ console.style.overflow = "auto";
1109
+ console.style.width = "700px";
1110
+ console.style.height = "350px";
1111
+ console.style.margin = "5px";
1112
+ documentForm.appendChild(console);
1113
+ }
1114
+
1115
+ console.value += message + "\n";
1116
+
1117
+ console.scrollTop = console.scrollHeight - console.clientHeight;
1118
+ } catch (ex) {
1119
+ alert("Exception: " + ex.name + " Message: " + ex.message);
1120
+ }
1121
+ };
1122
+
1123
+
1124
+ /* SWFObject v2.2 <http://code.google.com/p/swfobject/>
1125
+ is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
1126
+ */
1127
+ 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}}}}();
1128
+ swfobject.addDomLoadEvent(function () {
1129
+ if (typeof(SWFUpload.onload) === "function") {
1130
+ SWFUpload.onload.call(window);
1131
+ }
1132
+ });