loyal_rails_kindeditor 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (207) hide show
  1. data/lib/loyal_rails_kindeditor.rb +1 -0
  2. metadata +27 -231
  3. data/.gitignore +0 -5
  4. data/Gemfile +0 -6
  5. data/loyal_rails_kindeditor.gemspec +0 -24
  6. data/rails_kindeditor.gemspec +0 -23
  7. data/screenshots/rails_kindeditor.png +0 -0
  8. data/screenshots/simple_mode.png +0 -0
  9. data/vendor/assets/javascripts/kindeditor/kindeditor.js +0 -5827
  10. data/vendor/assets/javascripts/kindeditor/lang/ar.js +0 -232
  11. data/vendor/assets/javascripts/kindeditor/lang/en.js +0 -231
  12. data/vendor/assets/javascripts/kindeditor/lang/ko.js +0 -237
  13. data/vendor/assets/javascripts/kindeditor/lang/zh_CN.js +0 -235
  14. data/vendor/assets/javascripts/kindeditor/lang/zh_TW.js +0 -234
  15. data/vendor/assets/javascripts/kindeditor/plugins/anchor/anchor.js +0 -46
  16. data/vendor/assets/javascripts/kindeditor/plugins/autoheight/autoheight.js +0 -27
  17. data/vendor/assets/javascripts/kindeditor/plugins/baidumap/baidumap.js +0 -93
  18. data/vendor/assets/javascripts/kindeditor/plugins/baidumap/index.html +0 -83
  19. data/vendor/assets/javascripts/kindeditor/plugins/baidumap/map.html +0 -43
  20. data/vendor/assets/javascripts/kindeditor/plugins/clearhtml/clearhtml.js +0 -29
  21. data/vendor/assets/javascripts/kindeditor/plugins/code/code.js +0 -92
  22. data/vendor/assets/javascripts/kindeditor/plugins/code/prettify.css +0 -13
  23. data/vendor/assets/javascripts/kindeditor/plugins/code/prettify.js +0 -28
  24. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/emoticons.js +0 -129
  25. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/0.gif +0 -0
  26. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/1.gif +0 -0
  27. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/10.gif +0 -0
  28. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/100.gif +0 -0
  29. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/101.gif +0 -0
  30. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/102.gif +0 -0
  31. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/103.gif +0 -0
  32. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/104.gif +0 -0
  33. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/105.gif +0 -0
  34. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/106.gif +0 -0
  35. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/107.gif +0 -0
  36. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/108.gif +0 -0
  37. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/109.gif +0 -0
  38. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/11.gif +0 -0
  39. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/110.gif +0 -0
  40. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/111.gif +0 -0
  41. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/112.gif +0 -0
  42. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/113.gif +0 -0
  43. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/114.gif +0 -0
  44. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/115.gif +0 -0
  45. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/116.gif +0 -0
  46. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/117.gif +0 -0
  47. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/118.gif +0 -0
  48. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/119.gif +0 -0
  49. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/12.gif +0 -0
  50. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/120.gif +0 -0
  51. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/121.gif +0 -0
  52. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/122.gif +0 -0
  53. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/123.gif +0 -0
  54. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/124.gif +0 -0
  55. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/125.gif +0 -0
  56. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/126.gif +0 -0
  57. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/127.gif +0 -0
  58. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/128.gif +0 -0
  59. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/129.gif +0 -0
  60. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/13.gif +0 -0
  61. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/130.gif +0 -0
  62. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/131.gif +0 -0
  63. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/132.gif +0 -0
  64. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/133.gif +0 -0
  65. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/134.gif +0 -0
  66. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/14.gif +0 -0
  67. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/15.gif +0 -0
  68. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/16.gif +0 -0
  69. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/17.gif +0 -0
  70. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/18.gif +0 -0
  71. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/19.gif +0 -0
  72. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/2.gif +0 -0
  73. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/20.gif +0 -0
  74. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/21.gif +0 -0
  75. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/22.gif +0 -0
  76. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/23.gif +0 -0
  77. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/24.gif +0 -0
  78. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/25.gif +0 -0
  79. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/26.gif +0 -0
  80. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/27.gif +0 -0
  81. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/28.gif +0 -0
  82. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/29.gif +0 -0
  83. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/3.gif +0 -0
  84. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/30.gif +0 -0
  85. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/31.gif +0 -0
  86. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/32.gif +0 -0
  87. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/33.gif +0 -0
  88. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/34.gif +0 -0
  89. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/35.gif +0 -0
  90. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/36.gif +0 -0
  91. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/37.gif +0 -0
  92. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/38.gif +0 -0
  93. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/39.gif +0 -0
  94. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/4.gif +0 -0
  95. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/40.gif +0 -0
  96. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/41.gif +0 -0
  97. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/42.gif +0 -0
  98. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/43.gif +0 -0
  99. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/44.gif +0 -0
  100. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/45.gif +0 -0
  101. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/46.gif +0 -0
  102. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/47.gif +0 -0
  103. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/48.gif +0 -0
  104. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/49.gif +0 -0
  105. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/5.gif +0 -0
  106. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/50.gif +0 -0
  107. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/51.gif +0 -0
  108. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/52.gif +0 -0
  109. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/53.gif +0 -0
  110. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/54.gif +0 -0
  111. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/55.gif +0 -0
  112. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/56.gif +0 -0
  113. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/57.gif +0 -0
  114. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/58.gif +0 -0
  115. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/59.gif +0 -0
  116. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/6.gif +0 -0
  117. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/60.gif +0 -0
  118. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/61.gif +0 -0
  119. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/62.gif +0 -0
  120. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/63.gif +0 -0
  121. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/64.gif +0 -0
  122. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/65.gif +0 -0
  123. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/66.gif +0 -0
  124. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/67.gif +0 -0
  125. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/68.gif +0 -0
  126. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/69.gif +0 -0
  127. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/7.gif +0 -0
  128. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/70.gif +0 -0
  129. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/71.gif +0 -0
  130. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/72.gif +0 -0
  131. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/73.gif +0 -0
  132. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/74.gif +0 -0
  133. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/75.gif +0 -0
  134. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/76.gif +0 -0
  135. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/77.gif +0 -0
  136. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/78.gif +0 -0
  137. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/79.gif +0 -0
  138. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/8.gif +0 -0
  139. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/80.gif +0 -0
  140. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/81.gif +0 -0
  141. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/82.gif +0 -0
  142. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/83.gif +0 -0
  143. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/84.gif +0 -0
  144. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/85.gif +0 -0
  145. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/86.gif +0 -0
  146. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/87.gif +0 -0
  147. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/88.gif +0 -0
  148. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/89.gif +0 -0
  149. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/9.gif +0 -0
  150. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/90.gif +0 -0
  151. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/91.gif +0 -0
  152. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/92.gif +0 -0
  153. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/93.gif +0 -0
  154. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/94.gif +0 -0
  155. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/95.gif +0 -0
  156. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/96.gif +0 -0
  157. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/97.gif +0 -0
  158. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/98.gif +0 -0
  159. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/99.gif +0 -0
  160. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/static.gif +0 -0
  161. data/vendor/assets/javascripts/kindeditor/plugins/filemanager/filemanager.js +0 -190
  162. data/vendor/assets/javascripts/kindeditor/plugins/filemanager/images/file-16.gif +0 -0
  163. data/vendor/assets/javascripts/kindeditor/plugins/filemanager/images/file-64.gif +0 -0
  164. data/vendor/assets/javascripts/kindeditor/plugins/filemanager/images/folder-16.gif +0 -0
  165. data/vendor/assets/javascripts/kindeditor/plugins/filemanager/images/folder-64.gif +0 -0
  166. data/vendor/assets/javascripts/kindeditor/plugins/filemanager/images/go-up.gif +0 -0
  167. data/vendor/assets/javascripts/kindeditor/plugins/flash/flash.js +0 -160
  168. data/vendor/assets/javascripts/kindeditor/plugins/image/image.js +0 -316
  169. data/vendor/assets/javascripts/kindeditor/plugins/image/images/align_left.gif +0 -0
  170. data/vendor/assets/javascripts/kindeditor/plugins/image/images/align_right.gif +0 -0
  171. data/vendor/assets/javascripts/kindeditor/plugins/image/images/align_top.gif +0 -0
  172. data/vendor/assets/javascripts/kindeditor/plugins/image/images/refresh.png +0 -0
  173. data/vendor/assets/javascripts/kindeditor/plugins/insertfile/insertfile.js +0 -139
  174. data/vendor/assets/javascripts/kindeditor/plugins/lineheight/lineheight.js +0 -38
  175. data/vendor/assets/javascripts/kindeditor/plugins/link/link.js +0 -66
  176. data/vendor/assets/javascripts/kindeditor/plugins/map/map.html +0 -57
  177. data/vendor/assets/javascripts/kindeditor/plugins/map/map.js +0 -137
  178. data/vendor/assets/javascripts/kindeditor/plugins/media/media.js +0 -169
  179. data/vendor/assets/javascripts/kindeditor/plugins/multiimage/images/image.png +0 -0
  180. data/vendor/assets/javascripts/kindeditor/plugins/multiimage/images/select-files-en.png +0 -0
  181. data/vendor/assets/javascripts/kindeditor/plugins/multiimage/images/select-files-zh_CN.png +0 -0
  182. data/vendor/assets/javascripts/kindeditor/plugins/multiimage/images/swfupload.swf +0 -0
  183. data/vendor/assets/javascripts/kindeditor/plugins/multiimage/multiimage.js +0 -1385
  184. data/vendor/assets/javascripts/kindeditor/plugins/pagebreak/pagebreak.js +0 -29
  185. data/vendor/assets/javascripts/kindeditor/plugins/plainpaste/plainpaste.js +0 -41
  186. data/vendor/assets/javascripts/kindeditor/plugins/preview/preview.js +0 -31
  187. data/vendor/assets/javascripts/kindeditor/plugins/quickformat/quickformat.js +0 -81
  188. data/vendor/assets/javascripts/kindeditor/plugins/table/table.js +0 -705
  189. data/vendor/assets/javascripts/kindeditor/plugins/template/html/1.html +0 -14
  190. data/vendor/assets/javascripts/kindeditor/plugins/template/html/2.html +0 -42
  191. data/vendor/assets/javascripts/kindeditor/plugins/template/html/3.html +0 -36
  192. data/vendor/assets/javascripts/kindeditor/plugins/template/template.js +0 -58
  193. data/vendor/assets/javascripts/kindeditor/plugins/wordpaste/wordpaste.js +0 -51
  194. data/vendor/assets/javascripts/kindeditor/themes/common/anchor.gif +0 -0
  195. data/vendor/assets/javascripts/kindeditor/themes/common/blank.gif +0 -0
  196. data/vendor/assets/javascripts/kindeditor/themes/common/blockquote.gif +0 -0
  197. data/vendor/assets/javascripts/kindeditor/themes/common/flash.gif +0 -0
  198. data/vendor/assets/javascripts/kindeditor/themes/common/iframe.css +0 -98
  199. data/vendor/assets/javascripts/kindeditor/themes/common/loading.gif +0 -0
  200. data/vendor/assets/javascripts/kindeditor/themes/common/media.gif +0 -0
  201. data/vendor/assets/javascripts/kindeditor/themes/common/rm.gif +0 -0
  202. data/vendor/assets/javascripts/kindeditor/themes/default/background.png +0 -0
  203. data/vendor/assets/javascripts/kindeditor/themes/default/default.css +0 -1148
  204. data/vendor/assets/javascripts/kindeditor/themes/default/default.png +0 -0
  205. data/vendor/assets/javascripts/kindeditor/themes/qq/editor.gif +0 -0
  206. data/vendor/assets/javascripts/kindeditor/themes/qq/qq.css +0 -143
  207. data/vendor/assets/javascripts/kindeditor/themes/simple/simple.css +0 -100
@@ -1,1385 +0,0 @@
1
- /*******************************************************************************
2
- * KindEditor - WYSIWYG HTML Editor for Internet
3
- * Copyright (C) 2006-2011 kindsoft.net
4
- *
5
- * @author Roddy <luolonghao@gmail.com>
6
- * @site http://www.kindsoft.net/
7
- * @licence http://www.kindsoft.net/license.php
8
- *******************************************************************************/
9
-
10
-
11
- (function(K) {
12
-
13
- function KSWFUpload(options) {
14
- this.init(options);
15
- }
16
- K.extend(KSWFUpload, {
17
- init : function(options) {
18
- var self = this;
19
- options.afterError = options.afterError || function(str) {
20
- alert(str);
21
- };
22
- self.options = options;
23
- self.progressbars = {};
24
- // template
25
- self.div = K(options.container).html([
26
- '<div class="ke-swfupload">',
27
- '<div class="ke-swfupload-top">',
28
- '<div class="ke-inline-block ke-swfupload-button">',
29
- '<input type="button" value="Browse" />',
30
- '</div>',
31
- '<div class="ke-inline-block ke-swfupload-desc">' + options.uploadDesc + '</div>',
32
- '<span class="ke-button-common ke-button-outer ke-swfupload-startupload">',
33
- '<input type="button" class="ke-button-common ke-button" value="' + options.startButtonValue + '" />',
34
- '</span>',
35
- '</div>',
36
- '<div class="ke-swfupload-body"></div>',
37
- '</div>'
38
- ].join(''));
39
- self.bodyDiv = K('.ke-swfupload-body', self.div);
40
-
41
- function showError(itemDiv, msg) {
42
- K('.ke-status > div', itemDiv).hide();
43
- K('.ke-message', itemDiv).addClass('ke-error').show().html(K.escape(msg));
44
- }
45
-
46
- var settings = {
47
- debug : false,
48
- upload_url : options.uploadUrl,
49
- flash_url : options.flashUrl,
50
- file_post_name : options.filePostName,
51
- button_placeholder : K('.ke-swfupload-button > input', self.div)[0],
52
- button_image_url: options.buttonImageUrl,
53
- button_width: options.buttonWidth,
54
- button_height: options.buttonHeight,
55
- button_cursor : SWFUpload.CURSOR.HAND,
56
- file_types : options.fileTypes,
57
- file_types_description : options.fileTypesDesc,
58
- file_upload_limit : options.fileUploadLimit,
59
- file_size_limit : options.fileSizeLimit,
60
- post_params : options.postParams,
61
- file_queued_handler : function(file) {
62
- file.url = self.options.fileIconUrl;
63
- self.appendFile(file);
64
- },
65
- file_queue_error_handler : function(file, errorCode, message) {
66
- var errorName = '';
67
- switch (errorCode) {
68
- case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
69
- errorName = options.queueLimitExceeded;
70
- break;
71
- case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
72
- errorName = options.fileExceedsSizeLimit;
73
- break;
74
- case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
75
- errorName = options.zeroByteFile;
76
- break;
77
- case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
78
- errorName = options.invalidFiletype;
79
- break;
80
- default:
81
- errorName = options.unknownError;
82
- break;
83
- }
84
- K.DEBUG && alert(errorName);
85
- },
86
- upload_start_handler : function(file) {
87
- var self = this;
88
- var itemDiv = K('div[data-id="' + file.id + '"]', self.bodyDiv);
89
- K('.ke-status > div', itemDiv).hide();
90
- K('.ke-progressbar', itemDiv).show();
91
- },
92
- upload_progress_handler : function(file, bytesLoaded, bytesTotal) {
93
- var percent = Math.round(bytesLoaded * 100 / bytesTotal);
94
- var progressbar = self.progressbars[file.id];
95
- progressbar.bar.css('width', Math.round(percent * 80 / 100) + 'px');
96
- progressbar.percent.html(percent + '%');
97
- },
98
- upload_error_handler : function(file, errorCode, message) {
99
- if (file && file.filestatus == SWFUpload.FILE_STATUS.ERROR) {
100
- var itemDiv = K('div[data-id="' + file.id + '"]', self.bodyDiv).eq(0);
101
- showError(itemDiv, self.options.errorMessage);
102
- }
103
- },
104
- upload_success_handler : function(file, serverData) {
105
- var itemDiv = K('div[data-id="' + file.id + '"]', self.bodyDiv).eq(0);
106
- var data = {};
107
- try {
108
- data = K.json(serverData);
109
- } catch (e) {
110
- self.options.afterError.call(this, '<!doctype html><html>' + serverData + '</html>');
111
- }
112
- if (data.error !== 0) {
113
- showError(itemDiv, K.DEBUG ? data.message : self.options.errorMessage);
114
- return;
115
- }
116
- file.url = data.url;
117
- K('.ke-img', itemDiv).attr('src', file.url).attr('data-status', file.filestatus).data('data', data);
118
- K('.ke-status > div', itemDiv).hide();
119
- }
120
- };
121
- self.swfu = new SWFUpload(settings);
122
-
123
- K('.ke-swfupload-startupload input', self.div).click(function() {
124
- self.swfu.startUpload();
125
- });
126
- },
127
- getUrlList : function() {
128
- var list = [];
129
- K('.ke-img', self.bodyDiv).each(function() {
130
- var img = K(this);
131
- var status = img.attr('data-status');
132
- if (status == SWFUpload.FILE_STATUS.COMPLETE) {
133
- list.push(img.data('data'));
134
- }
135
- });
136
- return list;
137
- },
138
- removeFile : function(fileId) {
139
- var self = this;
140
- self.swfu.cancelUpload(fileId);
141
- var itemDiv = K('div[data-id="' + fileId + '"]', self.bodyDiv);
142
- K('.ke-photo', itemDiv).unbind();
143
- K('.ke-delete', itemDiv).unbind();
144
- itemDiv.remove();
145
- },
146
- removeFiles : function() {
147
- var self = this;
148
- K('.ke-item', self.bodyDiv).each(function() {
149
- self.removeFile(K(this).attr('data-id'));
150
- });
151
- },
152
- appendFile : function(file) {
153
- var self = this;
154
- var itemDiv = K('<div class="ke-inline-block ke-item" data-id="' + file.id + '"></div>');
155
- self.bodyDiv.append(itemDiv);
156
- var photoDiv = K('<div class="ke-inline-block ke-photo"></div>')
157
- .mouseover(function(e) {
158
- K(this).addClass('ke-on');
159
- })
160
- .mouseout(function(e) {
161
- K(this).removeClass('ke-on');
162
- });
163
- itemDiv.append(photoDiv);
164
-
165
- var img = K('<img src="' + file.url + '" class="ke-img" data-status="' + file.filestatus + '" width="80" height="80" alt="' + file.name + '" />');
166
- photoDiv.append(img);
167
- K('<span class="ke-delete"></span>').appendTo(photoDiv).click(function() {
168
- self.removeFile(file.id);
169
- });
170
- var statusDiv = K('<div class="ke-status"></div>').appendTo(photoDiv);
171
- // progressbar
172
- K(['<div class="ke-progressbar">',
173
- '<div class="ke-progressbar-bar"><div class="ke-progressbar-bar-inner"></div></div>',
174
- '<div class="ke-progressbar-percent">0%</div></div>'].join('')).hide().appendTo(statusDiv);
175
- // message
176
- K('<div class="ke-message">' + self.options.pendingMessage + '</div>').appendTo(statusDiv);
177
-
178
- itemDiv.append('<div class="ke-name">' + file.name + '</div>');
179
-
180
- self.progressbars[file.id] = {
181
- bar : K('.ke-progressbar-bar-inner', photoDiv),
182
- percent : K('.ke-progressbar-percent', photoDiv)
183
- };
184
- },
185
- remove : function() {
186
- this.removeFiles();
187
- this.swfu.destroy();
188
- this.div.html('');
189
- }
190
- });
191
-
192
- K.swfupload = function(element, options) {
193
- return new KSWFUpload(element, options);
194
- };
195
-
196
- })(KindEditor);
197
-
198
- KindEditor.plugin('multiimage', function(K) {
199
- var self = this, name = 'multiimage',
200
- formatUploadUrl = K.undef(self.formatUploadUrl, true),
201
- uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php'),
202
- imgPath = self.pluginsPath + 'multiimage/images/',
203
- imageSizeLimit = K.undef(self.imageSizeLimit, '1MB'),
204
- imageFileTypes = K.undef(self.imageFileTypes, '*.jpg;*.gif;*.png'),
205
- imageUploadLimit = K.undef(self.imageUploadLimit, 20),
206
- filePostName = K.undef(self.filePostName, 'imgFile'),
207
- lang = self.lang(name + '.');
208
-
209
- self.plugin.multiImageDialog = function(options) {
210
- var clickFn = options.clickFn,
211
- uploadDesc = K.tmpl(lang.uploadDesc, {uploadLimit : imageUploadLimit, sizeLimit : imageSizeLimit});
212
- var html = [
213
- '<div style="padding:20px;">',
214
- '<div class="swfupload">',
215
- '</div>',
216
- '</div>'
217
- ].join('');
218
- var dialog = self.createDialog({
219
- name : name,
220
- width : 650,
221
- height : 510,
222
- title : self.lang(name),
223
- body : html,
224
- previewBtn : {
225
- name : lang.insertAll,
226
- click : function(e) {
227
- clickFn.call(self, swfupload.getUrlList());
228
- }
229
- },
230
- yesBtn : {
231
- name : lang.clearAll,
232
- click : function(e) {
233
- swfupload.removeFiles();
234
- }
235
- },
236
- beforeRemove : function() {
237
- swfupload.remove();
238
- }
239
- }),
240
- div = dialog.div;
241
-
242
- var swfupload = K.swfupload({
243
- container : K('.swfupload', div),
244
- buttonImageUrl : imgPath + (self.langType == 'zh_CN' ? 'select-files-zh_CN.png' : 'select-files-en.png'),
245
- buttonWidth : self.langType == 'zh_CN' ? 72 : 88,
246
- buttonHeight : 23,
247
- fileIconUrl : imgPath + 'image.png',
248
- uploadDesc : uploadDesc,
249
- startButtonValue : lang.startUpload,
250
- uploadUrl : K.addParam(uploadJson, 'dir=image'),
251
- flashUrl : imgPath + 'swfupload.swf',
252
- filePostName : filePostName,
253
- fileTypes : '*.jpg;*.jpeg;*.gif;*.png;*.bmp',
254
- fileTypesDesc : 'Image Files',
255
- fileUploadLimit : imageUploadLimit,
256
- fileSizeLimit : imageSizeLimit,
257
- postParams : K.undef(self.extraFileUploadParams, {}),
258
- queueLimitExceeded : lang.queueLimitExceeded,
259
- fileExceedsSizeLimit : lang.fileExceedsSizeLimit,
260
- zeroByteFile : lang.zeroByteFile,
261
- invalidFiletype : lang.invalidFiletype,
262
- unknownError : lang.unknownError,
263
- pendingMessage : lang.pending,
264
- errorMessage : lang.uploadError,
265
- afterError : function(html) {
266
- self.errorDialog(html);
267
- }
268
- });
269
-
270
- return dialog;
271
- };
272
- self.clickToolbar(name, function() {
273
- self.plugin.multiImageDialog({
274
- clickFn : function (urlList) {
275
- if (urlList.length === 0) {
276
- return;
277
- }
278
- K.each(urlList, function(i, data) {
279
- if (self.afterUpload) {
280
- self.afterUpload.call(self, data.url, data, 'multiimage');
281
- }
282
- self.exec('insertimage', data.url, data.title, data.width, data.height, data.border, data.align);
283
- });
284
- // Bugfix: [Firefox] 上传图片后,总是出现正在加载的样式,需要延迟执行hideDialog
285
- setTimeout(function() {
286
- self.hideDialog().focus();
287
- }, 0);
288
- }
289
- });
290
- });
291
- });
292
-
293
-
294
- /**
295
- * SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com
296
- *
297
- * mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/, http://www.vinterwebb.se/
298
- *
299
- * SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilz閚 and Mammon Media and is released under the MIT License:
300
- * http://www.opensource.org/licenses/mit-license.php
301
- *
302
- * SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License:
303
- * http://www.opensource.org/licenses/mit-license.php
304
- *
305
- */
306
-
307
-
308
- /* ******************* */
309
- /* Constructor & Init */
310
- /* ******************* */
311
-
312
- (function() {
313
-
314
- if (window.SWFUpload) {
315
- return;
316
- }
317
-
318
- window.SWFUpload = function (settings) {
319
- this.initSWFUpload(settings);
320
- };
321
-
322
- SWFUpload.prototype.initSWFUpload = function (settings) {
323
- try {
324
- this.customSettings = {}; // A container where developers can place their own settings associated with this instance.
325
- this.settings = settings;
326
- this.eventQueue = [];
327
- this.movieName = "SWFUpload_" + SWFUpload.movieCount++;
328
- this.movieElement = null;
329
-
330
-
331
- // Setup global control tracking
332
- SWFUpload.instances[this.movieName] = this;
333
-
334
- // Load the settings. Load the Flash movie.
335
- this.initSettings();
336
- this.loadFlash();
337
- this.displayDebugInfo();
338
- } catch (ex) {
339
- delete SWFUpload.instances[this.movieName];
340
- throw ex;
341
- }
342
- };
343
-
344
- /* *************** */
345
- /* Static Members */
346
- /* *************** */
347
- SWFUpload.instances = {};
348
- SWFUpload.movieCount = 0;
349
- SWFUpload.version = "2.2.0 2009-03-25";
350
- SWFUpload.QUEUE_ERROR = {
351
- QUEUE_LIMIT_EXCEEDED : -100,
352
- FILE_EXCEEDS_SIZE_LIMIT : -110,
353
- ZERO_BYTE_FILE : -120,
354
- INVALID_FILETYPE : -130
355
- };
356
- SWFUpload.UPLOAD_ERROR = {
357
- HTTP_ERROR : -200,
358
- MISSING_UPLOAD_URL : -210,
359
- IO_ERROR : -220,
360
- SECURITY_ERROR : -230,
361
- UPLOAD_LIMIT_EXCEEDED : -240,
362
- UPLOAD_FAILED : -250,
363
- SPECIFIED_FILE_ID_NOT_FOUND : -260,
364
- FILE_VALIDATION_FAILED : -270,
365
- FILE_CANCELLED : -280,
366
- UPLOAD_STOPPED : -290
367
- };
368
- SWFUpload.FILE_STATUS = {
369
- QUEUED : -1,
370
- IN_PROGRESS : -2,
371
- ERROR : -3,
372
- COMPLETE : -4,
373
- CANCELLED : -5
374
- };
375
- SWFUpload.BUTTON_ACTION = {
376
- SELECT_FILE : -100,
377
- SELECT_FILES : -110,
378
- START_UPLOAD : -120
379
- };
380
- SWFUpload.CURSOR = {
381
- ARROW : -1,
382
- HAND : -2
383
- };
384
- SWFUpload.WINDOW_MODE = {
385
- WINDOW : "window",
386
- TRANSPARENT : "transparent",
387
- OPAQUE : "opaque"
388
- };
389
-
390
- // Private: takes a URL, determines if it is relative and converts to an absolute URL
391
- // using the current site. Only processes the URL if it can, otherwise returns the URL untouched
392
- SWFUpload.completeURL = function(url) {
393
- if (typeof(url) !== "string" || url.match(/^https?:\/\//i) || url.match(/^\//)) {
394
- return url;
395
- }
396
-
397
- var currentURL = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
398
-
399
- var indexSlash = window.location.pathname.lastIndexOf("/");
400
- if (indexSlash <= 0) {
401
- path = "/";
402
- } else {
403
- path = window.location.pathname.substr(0, indexSlash) + "/";
404
- }
405
-
406
- return /*currentURL +*/ path + url;
407
-
408
- };
409
-
410
-
411
- /* ******************** */
412
- /* Instance Members */
413
- /* ******************** */
414
-
415
- // Private: initSettings ensures that all the
416
- // settings are set, getting a default value if one was not assigned.
417
- SWFUpload.prototype.initSettings = function () {
418
- this.ensureDefault = function (settingName, defaultValue) {
419
- this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
420
- };
421
-
422
- // Upload backend settings
423
- this.ensureDefault("upload_url", "");
424
- this.ensureDefault("preserve_relative_urls", false);
425
- this.ensureDefault("file_post_name", "Filedata");
426
- this.ensureDefault("post_params", {});
427
- this.ensureDefault("use_query_string", false);
428
- this.ensureDefault("requeue_on_error", false);
429
- this.ensureDefault("http_success", []);
430
- this.ensureDefault("assume_success_timeout", 0);
431
-
432
- // File Settings
433
- this.ensureDefault("file_types", "*.*");
434
- this.ensureDefault("file_types_description", "All Files");
435
- this.ensureDefault("file_size_limit", 0); // Default zero means "unlimited"
436
- this.ensureDefault("file_upload_limit", 0);
437
- this.ensureDefault("file_queue_limit", 0);
438
-
439
- // Flash Settings
440
- this.ensureDefault("flash_url", "swfupload.swf");
441
- this.ensureDefault("prevent_swf_caching", true);
442
-
443
- // Button Settings
444
- this.ensureDefault("button_image_url", "");
445
- this.ensureDefault("button_width", 1);
446
- this.ensureDefault("button_height", 1);
447
- this.ensureDefault("button_text", "");
448
- this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;");
449
- this.ensureDefault("button_text_top_padding", 0);
450
- this.ensureDefault("button_text_left_padding", 0);
451
- this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES);
452
- this.ensureDefault("button_disabled", false);
453
- this.ensureDefault("button_placeholder_id", "");
454
- this.ensureDefault("button_placeholder", null);
455
- this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW);
456
- this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW);
457
-
458
- // Debug Settings
459
- this.ensureDefault("debug", false);
460
- this.settings.debug_enabled = this.settings.debug; // Here to maintain v2 API
461
-
462
- // Event Handlers
463
- this.settings.return_upload_start_handler = this.returnUploadStart;
464
- this.ensureDefault("swfupload_loaded_handler", null);
465
- this.ensureDefault("file_dialog_start_handler", null);
466
- this.ensureDefault("file_queued_handler", null);
467
- this.ensureDefault("file_queue_error_handler", null);
468
- this.ensureDefault("file_dialog_complete_handler", null);
469
-
470
- this.ensureDefault("upload_start_handler", null);
471
- this.ensureDefault("upload_progress_handler", null);
472
- this.ensureDefault("upload_error_handler", null);
473
- this.ensureDefault("upload_success_handler", null);
474
- this.ensureDefault("upload_complete_handler", null);
475
-
476
- this.ensureDefault("debug_handler", this.debugMessage);
477
-
478
- this.ensureDefault("custom_settings", {});
479
-
480
- // Other settings
481
- this.customSettings = this.settings.custom_settings;
482
-
483
- // Update the flash url if needed
484
- if (!!this.settings.prevent_swf_caching) {
485
- this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime();
486
- }
487
-
488
- if (!this.settings.preserve_relative_urls) {
489
- //this.settings.flash_url = SWFUpload.completeURL(this.settings.flash_url); // Don't need to do this one since flash doesn't look at it
490
- this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url);
491
- this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url);
492
- }
493
-
494
- delete this.ensureDefault;
495
- };
496
-
497
- // Private: loadFlash replaces the button_placeholder element with the flash movie.
498
- SWFUpload.prototype.loadFlash = function () {
499
- var targetElement, tempParent;
500
-
501
- // Make sure an element with the ID we are going to use doesn't already exist
502
- if (document.getElementById(this.movieName) !== null) {
503
- throw "ID " + this.movieName + " is already in use. The Flash Object could not be added";
504
- }
505
-
506
- // Get the element where we will be placing the flash movie
507
- targetElement = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder;
508
-
509
- if (targetElement == undefined) {
510
- throw "Could not find the placeholder element: " + this.settings.button_placeholder_id;
511
- }
512
-
513
- // Append the container and load the flash
514
- tempParent = document.createElement("div");
515
- tempParent.innerHTML = this.getFlashHTML(); // Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers)
516
- targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement);
517
-
518
- // Fix IE Flash/Form bug
519
- if (window[this.movieName] == undefined) {
520
- window[this.movieName] = this.getMovieElement();
521
- }
522
-
523
- };
524
-
525
- // Private: getFlashHTML generates the object tag needed to embed the flash in to the document
526
- SWFUpload.prototype.getFlashHTML = function () {
527
- // Flash Satay object syntax: http://www.alistapart.com/articles/flashsatay
528
- // Fix bug for IE9
529
- // http://www.kindsoft.net/view.php?bbsid=7&postid=5825&pagenum=1
530
- var classid = '';
531
- if (KindEditor.IE && KindEditor.V > 8) {
532
- classid = ' classid = "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
533
- }
534
- return ['<object id="', this.movieName, '"' + classid + ' type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">',
535
- '<param name="wmode" value="', this.settings.button_window_mode, '" />',
536
- '<param name="movie" value="', this.settings.flash_url, '" />',
537
- '<param name="quality" value="high" />',
538
- '<param name="menu" value="false" />',
539
- '<param name="allowScriptAccess" value="always" />',
540
- '<param name="flashvars" value="' + this.getFlashVars() + '" />',
541
- '</object>'].join("");
542
- };
543
-
544
- // Private: getFlashVars builds the parameter string that will be passed
545
- // to flash in the flashvars param.
546
- SWFUpload.prototype.getFlashVars = function () {
547
- // Build a string from the post param object
548
- var paramString = this.buildParamString();
549
- var httpSuccessString = this.settings.http_success.join(",");
550
-
551
- // Build the parameter string
552
- return ["movieName=", encodeURIComponent(this.movieName),
553
- "&amp;uploadURL=", encodeURIComponent(this.settings.upload_url),
554
- "&amp;useQueryString=", encodeURIComponent(this.settings.use_query_string),
555
- "&amp;requeueOnError=", encodeURIComponent(this.settings.requeue_on_error),
556
- "&amp;httpSuccess=", encodeURIComponent(httpSuccessString),
557
- "&amp;assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout),
558
- "&amp;params=", encodeURIComponent(paramString),
559
- "&amp;filePostName=", encodeURIComponent(this.settings.file_post_name),
560
- "&amp;fileTypes=", encodeURIComponent(this.settings.file_types),
561
- "&amp;fileTypesDescription=", encodeURIComponent(this.settings.file_types_description),
562
- "&amp;fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit),
563
- "&amp;fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit),
564
- "&amp;fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit),
565
- "&amp;debugEnabled=", encodeURIComponent(this.settings.debug_enabled),
566
- "&amp;buttonImageURL=", encodeURIComponent(this.settings.button_image_url),
567
- "&amp;buttonWidth=", encodeURIComponent(this.settings.button_width),
568
- "&amp;buttonHeight=", encodeURIComponent(this.settings.button_height),
569
- "&amp;buttonText=", encodeURIComponent(this.settings.button_text),
570
- "&amp;buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding),
571
- "&amp;buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding),
572
- "&amp;buttonTextStyle=", encodeURIComponent(this.settings.button_text_style),
573
- "&amp;buttonAction=", encodeURIComponent(this.settings.button_action),
574
- "&amp;buttonDisabled=", encodeURIComponent(this.settings.button_disabled),
575
- "&amp;buttonCursor=", encodeURIComponent(this.settings.button_cursor)
576
- ].join("");
577
- };
578
-
579
- // Public: getMovieElement retrieves the DOM reference to the Flash element added by SWFUpload
580
- // The element is cached after the first lookup
581
- SWFUpload.prototype.getMovieElement = function () {
582
- if (this.movieElement == undefined) {
583
- this.movieElement = document.getElementById(this.movieName);
584
- }
585
-
586
- if (this.movieElement === null) {
587
- throw "Could not find Flash element";
588
- }
589
-
590
- return this.movieElement;
591
- };
592
-
593
- // Private: buildParamString takes the name/value pairs in the post_params setting object
594
- // and joins them up in to a string formatted "name=value&amp;name=value"
595
- SWFUpload.prototype.buildParamString = function () {
596
- var postParams = this.settings.post_params;
597
- var paramStringPairs = [];
598
-
599
- if (typeof(postParams) === "object") {
600
- for (var name in postParams) {
601
- if (postParams.hasOwnProperty(name)) {
602
- paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString()));
603
- }
604
- }
605
- }
606
-
607
- return paramStringPairs.join("&amp;");
608
- };
609
-
610
- // Public: Used to remove a SWFUpload instance from the page. This method strives to remove
611
- // all references to the SWF, and other objects so memory is properly freed.
612
- // Returns true if everything was destroyed. Returns a false if a failure occurs leaving SWFUpload in an inconsistant state.
613
- // Credits: Major improvements provided by steffen
614
- SWFUpload.prototype.destroy = function () {
615
- try {
616
- // Make sure Flash is done before we try to remove it
617
- this.cancelUpload(null, false);
618
-
619
-
620
- // Remove the SWFUpload DOM nodes
621
- var movieElement = null;
622
- movieElement = this.getMovieElement();
623
-
624
- if (movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
625
- // Loop through all the movie's properties and remove all function references (DOM/JS IE 6/7 memory leak workaround)
626
- for (var i in movieElement) {
627
- try {
628
- if (typeof(movieElement[i]) === "function") {
629
- movieElement[i] = null;
630
- }
631
- } catch (ex1) {}
632
- }
633
-
634
- // Remove the Movie Element from the page
635
- try {
636
- movieElement.parentNode.removeChild(movieElement);
637
- } catch (ex) {}
638
- }
639
-
640
- // Remove IE form fix reference
641
- window[this.movieName] = null;
642
-
643
- // Destroy other references
644
- SWFUpload.instances[this.movieName] = null;
645
- delete SWFUpload.instances[this.movieName];
646
-
647
- this.movieElement = null;
648
- this.settings = null;
649
- this.customSettings = null;
650
- this.eventQueue = null;
651
- this.movieName = null;
652
-
653
-
654
- return true;
655
- } catch (ex2) {
656
- return false;
657
- }
658
- };
659
-
660
-
661
- // Public: displayDebugInfo prints out settings and configuration
662
- // information about this SWFUpload instance.
663
- // This function (and any references to it) can be deleted when placing
664
- // SWFUpload in production.
665
- SWFUpload.prototype.displayDebugInfo = function () {
666
- this.debug(
667
- [
668
- "---SWFUpload Instance Info---\n",
669
- "Version: ", SWFUpload.version, "\n",
670
- "Movie Name: ", this.movieName, "\n",
671
- "Settings:\n",
672
- "\t", "upload_url: ", this.settings.upload_url, "\n",
673
- "\t", "flash_url: ", this.settings.flash_url, "\n",
674
- "\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n",
675
- "\t", "requeue_on_error: ", this.settings.requeue_on_error.toString(), "\n",
676
- "\t", "http_success: ", this.settings.http_success.join(", "), "\n",
677
- "\t", "assume_success_timeout: ", this.settings.assume_success_timeout, "\n",
678
- "\t", "file_post_name: ", this.settings.file_post_name, "\n",
679
- "\t", "post_params: ", this.settings.post_params.toString(), "\n",
680
- "\t", "file_types: ", this.settings.file_types, "\n",
681
- "\t", "file_types_description: ", this.settings.file_types_description, "\n",
682
- "\t", "file_size_limit: ", this.settings.file_size_limit, "\n",
683
- "\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n",
684
- "\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n",
685
- "\t", "debug: ", this.settings.debug.toString(), "\n",
686
-
687
- "\t", "prevent_swf_caching: ", this.settings.prevent_swf_caching.toString(), "\n",
688
-
689
- "\t", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n",
690
- "\t", "button_placeholder: ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n",
691
- "\t", "button_image_url: ", this.settings.button_image_url.toString(), "\n",
692
- "\t", "button_width: ", this.settings.button_width.toString(), "\n",
693
- "\t", "button_height: ", this.settings.button_height.toString(), "\n",
694
- "\t", "button_text: ", this.settings.button_text.toString(), "\n",
695
- "\t", "button_text_style: ", this.settings.button_text_style.toString(), "\n",
696
- "\t", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n",
697
- "\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n",
698
- "\t", "button_action: ", this.settings.button_action.toString(), "\n",
699
- "\t", "button_disabled: ", this.settings.button_disabled.toString(), "\n",
700
-
701
- "\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n",
702
- "Event Handlers:\n",
703
- "\t", "swfupload_loaded_handler assigned: ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n",
704
- "\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n",
705
- "\t", "file_queued_handler assigned: ", (typeof this.settings.file_queued_handler === "function").toString(), "\n",
706
- "\t", "file_queue_error_handler assigned: ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n",
707
- "\t", "upload_start_handler assigned: ", (typeof this.settings.upload_start_handler === "function").toString(), "\n",
708
- "\t", "upload_progress_handler assigned: ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n",
709
- "\t", "upload_error_handler assigned: ", (typeof this.settings.upload_error_handler === "function").toString(), "\n",
710
- "\t", "upload_success_handler assigned: ", (typeof this.settings.upload_success_handler === "function").toString(), "\n",
711
- "\t", "upload_complete_handler assigned: ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n",
712
- "\t", "debug_handler assigned: ", (typeof this.settings.debug_handler === "function").toString(), "\n"
713
- ].join("")
714
- );
715
- };
716
-
717
- /* Note: addSetting and getSetting are no longer used by SWFUpload but are included
718
- the maintain v2 API compatibility
719
- */
720
- // Public: (Deprecated) addSetting adds a setting value. If the value given is undefined or null then the default_value is used.
721
- SWFUpload.prototype.addSetting = function (name, value, default_value) {
722
- if (value == undefined) {
723
- return (this.settings[name] = default_value);
724
- } else {
725
- return (this.settings[name] = value);
726
- }
727
- };
728
-
729
- // Public: (Deprecated) getSetting gets a setting. Returns an empty string if the setting was not found.
730
- SWFUpload.prototype.getSetting = function (name) {
731
- if (this.settings[name] != undefined) {
732
- return this.settings[name];
733
- }
734
-
735
- return "";
736
- };
737
-
738
-
739
-
740
- // Private: callFlash handles function calls made to the Flash element.
741
- // Calls are made with a setTimeout for some functions to work around
742
- // bugs in the ExternalInterface library.
743
- SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
744
- argumentArray = argumentArray || [];
745
-
746
- var movieElement = this.getMovieElement();
747
- var returnValue, returnString;
748
-
749
- // Flash's method if calling ExternalInterface methods (code adapted from MooTools).
750
- try {
751
- returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + '</invoke>');
752
- returnValue = eval(returnString);
753
- } catch (ex) {
754
- throw "Call to " + functionName + " failed";
755
- }
756
-
757
- // Unescape file post param values
758
- if (returnValue != undefined && typeof returnValue.post === "object") {
759
- returnValue = this.unescapeFilePostParams(returnValue);
760
- }
761
-
762
- return returnValue;
763
- };
764
-
765
- /* *****************************
766
- -- Flash control methods --
767
- Your UI should use these
768
- to operate SWFUpload
769
- ***************************** */
770
-
771
- // WARNING: this function does not work in Flash Player 10
772
- // Public: selectFile causes a File Selection Dialog window to appear. This
773
- // dialog only allows 1 file to be selected.
774
- SWFUpload.prototype.selectFile = function () {
775
- this.callFlash("SelectFile");
776
- };
777
-
778
- // WARNING: this function does not work in Flash Player 10
779
- // Public: selectFiles causes a File Selection Dialog window to appear/ This
780
- // dialog allows the user to select any number of files
781
- // Flash Bug Warning: Flash limits the number of selectable files based on the combined length of the file names.
782
- // If the selection name length is too long the dialog will fail in an unpredictable manner. There is no work-around
783
- // for this bug.
784
- SWFUpload.prototype.selectFiles = function () {
785
- this.callFlash("SelectFiles");
786
- };
787
-
788
-
789
- // Public: startUpload starts uploading the first file in the queue unless
790
- // the optional parameter 'fileID' specifies the ID
791
- SWFUpload.prototype.startUpload = function (fileID) {
792
- this.callFlash("StartUpload", [fileID]);
793
- };
794
-
795
- // Public: cancelUpload cancels any queued file. The fileID parameter may be the file ID or index.
796
- // If you do not specify a fileID the current uploading file or first file in the queue is cancelled.
797
- // If you do not want the uploadError event to trigger you can specify false for the triggerErrorEvent parameter.
798
- SWFUpload.prototype.cancelUpload = function (fileID, triggerErrorEvent) {
799
- if (triggerErrorEvent !== false) {
800
- triggerErrorEvent = true;
801
- }
802
- this.callFlash("CancelUpload", [fileID, triggerErrorEvent]);
803
- };
804
-
805
- // Public: stopUpload stops the current upload and requeues the file at the beginning of the queue.
806
- // If nothing is currently uploading then nothing happens.
807
- SWFUpload.prototype.stopUpload = function () {
808
- this.callFlash("StopUpload");
809
- };
810
-
811
- /* ************************
812
- * Settings methods
813
- * These methods change the SWFUpload settings.
814
- * SWFUpload settings should not be changed directly on the settings object
815
- * since many of the settings need to be passed to Flash in order to take
816
- * effect.
817
- * *********************** */
818
-
819
- // Public: getStats gets the file statistics object.
820
- SWFUpload.prototype.getStats = function () {
821
- return this.callFlash("GetStats");
822
- };
823
-
824
- // Public: setStats changes the SWFUpload statistics. You shouldn't need to
825
- // change the statistics but you can. Changing the statistics does not
826
- // affect SWFUpload accept for the successful_uploads count which is used
827
- // by the upload_limit setting to determine how many files the user may upload.
828
- SWFUpload.prototype.setStats = function (statsObject) {
829
- this.callFlash("SetStats", [statsObject]);
830
- };
831
-
832
- // Public: getFile retrieves a File object by ID or Index. If the file is
833
- // not found then 'null' is returned.
834
- SWFUpload.prototype.getFile = function (fileID) {
835
- if (typeof(fileID) === "number") {
836
- return this.callFlash("GetFileByIndex", [fileID]);
837
- } else {
838
- return this.callFlash("GetFile", [fileID]);
839
- }
840
- };
841
-
842
- // Public: addFileParam sets a name/value pair that will be posted with the
843
- // file specified by the Files ID. If the name already exists then the
844
- // exiting value will be overwritten.
845
- SWFUpload.prototype.addFileParam = function (fileID, name, value) {
846
- return this.callFlash("AddFileParam", [fileID, name, value]);
847
- };
848
-
849
- // Public: removeFileParam removes a previously set (by addFileParam) name/value
850
- // pair from the specified file.
851
- SWFUpload.prototype.removeFileParam = function (fileID, name) {
852
- this.callFlash("RemoveFileParam", [fileID, name]);
853
- };
854
-
855
- // Public: setUploadUrl changes the upload_url setting.
856
- SWFUpload.prototype.setUploadURL = function (url) {
857
- this.settings.upload_url = url.toString();
858
- this.callFlash("SetUploadURL", [url]);
859
- };
860
-
861
- // Public: setPostParams changes the post_params setting
862
- SWFUpload.prototype.setPostParams = function (paramsObject) {
863
- this.settings.post_params = paramsObject;
864
- this.callFlash("SetPostParams", [paramsObject]);
865
- };
866
-
867
- // Public: addPostParam adds post name/value pair. Each name can have only one value.
868
- SWFUpload.prototype.addPostParam = function (name, value) {
869
- this.settings.post_params[name] = value;
870
- this.callFlash("SetPostParams", [this.settings.post_params]);
871
- };
872
-
873
- // Public: removePostParam deletes post name/value pair.
874
- SWFUpload.prototype.removePostParam = function (name) {
875
- delete this.settings.post_params[name];
876
- this.callFlash("SetPostParams", [this.settings.post_params]);
877
- };
878
-
879
- // Public: setFileTypes changes the file_types setting and the file_types_description setting
880
- SWFUpload.prototype.setFileTypes = function (types, description) {
881
- this.settings.file_types = types;
882
- this.settings.file_types_description = description;
883
- this.callFlash("SetFileTypes", [types, description]);
884
- };
885
-
886
- // Public: setFileSizeLimit changes the file_size_limit setting
887
- SWFUpload.prototype.setFileSizeLimit = function (fileSizeLimit) {
888
- this.settings.file_size_limit = fileSizeLimit;
889
- this.callFlash("SetFileSizeLimit", [fileSizeLimit]);
890
- };
891
-
892
- // Public: setFileUploadLimit changes the file_upload_limit setting
893
- SWFUpload.prototype.setFileUploadLimit = function (fileUploadLimit) {
894
- this.settings.file_upload_limit = fileUploadLimit;
895
- this.callFlash("SetFileUploadLimit", [fileUploadLimit]);
896
- };
897
-
898
- // Public: setFileQueueLimit changes the file_queue_limit setting
899
- SWFUpload.prototype.setFileQueueLimit = function (fileQueueLimit) {
900
- this.settings.file_queue_limit = fileQueueLimit;
901
- this.callFlash("SetFileQueueLimit", [fileQueueLimit]);
902
- };
903
-
904
- // Public: setFilePostName changes the file_post_name setting
905
- SWFUpload.prototype.setFilePostName = function (filePostName) {
906
- this.settings.file_post_name = filePostName;
907
- this.callFlash("SetFilePostName", [filePostName]);
908
- };
909
-
910
- // Public: setUseQueryString changes the use_query_string setting
911
- SWFUpload.prototype.setUseQueryString = function (useQueryString) {
912
- this.settings.use_query_string = useQueryString;
913
- this.callFlash("SetUseQueryString", [useQueryString]);
914
- };
915
-
916
- // Public: setRequeueOnError changes the requeue_on_error setting
917
- SWFUpload.prototype.setRequeueOnError = function (requeueOnError) {
918
- this.settings.requeue_on_error = requeueOnError;
919
- this.callFlash("SetRequeueOnError", [requeueOnError]);
920
- };
921
-
922
- // Public: setHTTPSuccess changes the http_success setting
923
- SWFUpload.prototype.setHTTPSuccess = function (http_status_codes) {
924
- if (typeof http_status_codes === "string") {
925
- http_status_codes = http_status_codes.replace(" ", "").split(",");
926
- }
927
-
928
- this.settings.http_success = http_status_codes;
929
- this.callFlash("SetHTTPSuccess", [http_status_codes]);
930
- };
931
-
932
- // Public: setHTTPSuccess changes the http_success setting
933
- SWFUpload.prototype.setAssumeSuccessTimeout = function (timeout_seconds) {
934
- this.settings.assume_success_timeout = timeout_seconds;
935
- this.callFlash("SetAssumeSuccessTimeout", [timeout_seconds]);
936
- };
937
-
938
- // Public: setDebugEnabled changes the debug_enabled setting
939
- SWFUpload.prototype.setDebugEnabled = function (debugEnabled) {
940
- this.settings.debug_enabled = debugEnabled;
941
- this.callFlash("SetDebugEnabled", [debugEnabled]);
942
- };
943
-
944
- // Public: setButtonImageURL loads a button image sprite
945
- SWFUpload.prototype.setButtonImageURL = function (buttonImageURL) {
946
- if (buttonImageURL == undefined) {
947
- buttonImageURL = "";
948
- }
949
-
950
- this.settings.button_image_url = buttonImageURL;
951
- this.callFlash("SetButtonImageURL", [buttonImageURL]);
952
- };
953
-
954
- // Public: setButtonDimensions resizes the Flash Movie and button
955
- SWFUpload.prototype.setButtonDimensions = function (width, height) {
956
- this.settings.button_width = width;
957
- this.settings.button_height = height;
958
-
959
- var movie = this.getMovieElement();
960
- if (movie != undefined) {
961
- movie.style.width = width + "px";
962
- movie.style.height = height + "px";
963
- }
964
-
965
- this.callFlash("SetButtonDimensions", [width, height]);
966
- };
967
- // Public: setButtonText Changes the text overlaid on the button
968
- SWFUpload.prototype.setButtonText = function (html) {
969
- this.settings.button_text = html;
970
- this.callFlash("SetButtonText", [html]);
971
- };
972
- // Public: setButtonTextPadding changes the top and left padding of the text overlay
973
- SWFUpload.prototype.setButtonTextPadding = function (left, top) {
974
- this.settings.button_text_top_padding = top;
975
- this.settings.button_text_left_padding = left;
976
- this.callFlash("SetButtonTextPadding", [left, top]);
977
- };
978
-
979
- // Public: setButtonTextStyle changes the CSS used to style the HTML/Text overlaid on the button
980
- SWFUpload.prototype.setButtonTextStyle = function (css) {
981
- this.settings.button_text_style = css;
982
- this.callFlash("SetButtonTextStyle", [css]);
983
- };
984
- // Public: setButtonDisabled disables/enables the button
985
- SWFUpload.prototype.setButtonDisabled = function (isDisabled) {
986
- this.settings.button_disabled = isDisabled;
987
- this.callFlash("SetButtonDisabled", [isDisabled]);
988
- };
989
- // Public: setButtonAction sets the action that occurs when the button is clicked
990
- SWFUpload.prototype.setButtonAction = function (buttonAction) {
991
- this.settings.button_action = buttonAction;
992
- this.callFlash("SetButtonAction", [buttonAction]);
993
- };
994
-
995
- // Public: setButtonCursor changes the mouse cursor displayed when hovering over the button
996
- SWFUpload.prototype.setButtonCursor = function (cursor) {
997
- this.settings.button_cursor = cursor;
998
- this.callFlash("SetButtonCursor", [cursor]);
999
- };
1000
-
1001
- /* *******************************
1002
- Flash Event Interfaces
1003
- These functions are used by Flash to trigger the various
1004
- events.
1005
-
1006
- All these functions a Private.
1007
-
1008
- Because the ExternalInterface library is buggy the event calls
1009
- are added to a queue and the queue then executed by a setTimeout.
1010
- This ensures that events are executed in a determinate order and that
1011
- the ExternalInterface bugs are avoided.
1012
- ******************************* */
1013
-
1014
- SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) {
1015
- // Warning: Don't call this.debug inside here or you'll create an infinite loop
1016
-
1017
- if (argumentArray == undefined) {
1018
- argumentArray = [];
1019
- } else if (!(argumentArray instanceof Array)) {
1020
- argumentArray = [argumentArray];
1021
- }
1022
-
1023
- var self = this;
1024
- if (typeof this.settings[handlerName] === "function") {
1025
- // Queue the event
1026
- this.eventQueue.push(function () {
1027
- this.settings[handlerName].apply(this, argumentArray);
1028
- });
1029
-
1030
- // Execute the next queued event
1031
- setTimeout(function () {
1032
- self.executeNextEvent();
1033
- }, 0);
1034
-
1035
- } else if (this.settings[handlerName] !== null) {
1036
- throw "Event handler " + handlerName + " is unknown or is not a function";
1037
- }
1038
- };
1039
-
1040
- // Private: Causes the next event in the queue to be executed. Since events are queued using a setTimeout
1041
- // we must queue them in order to garentee that they are executed in order.
1042
- SWFUpload.prototype.executeNextEvent = function () {
1043
- // Warning: Don't call this.debug inside here or you'll create an infinite loop
1044
-
1045
- var f = this.eventQueue ? this.eventQueue.shift() : null;
1046
- if (typeof(f) === "function") {
1047
- f.apply(this);
1048
- }
1049
- };
1050
-
1051
- // Private: unescapeFileParams is part of a workaround for a flash bug where objects passed through ExternalInterface cannot have
1052
- // properties that contain characters that are not valid for JavaScript identifiers. To work around this
1053
- // the Flash Component escapes the parameter names and we must unescape again before passing them along.
1054
- SWFUpload.prototype.unescapeFilePostParams = function (file) {
1055
- var reg = /[$]([0-9a-f]{4})/i;
1056
- var unescapedPost = {};
1057
- var uk;
1058
-
1059
- if (file != undefined) {
1060
- for (var k in file.post) {
1061
- if (file.post.hasOwnProperty(k)) {
1062
- uk = k;
1063
- var match;
1064
- while ((match = reg.exec(uk)) !== null) {
1065
- uk = uk.replace(match[0], String.fromCharCode(parseInt("0x" + match[1], 16)));
1066
- }
1067
- unescapedPost[uk] = file.post[k];
1068
- }
1069
- }
1070
-
1071
- file.post = unescapedPost;
1072
- }
1073
-
1074
- return file;
1075
- };
1076
-
1077
- // Private: Called by Flash to see if JS can call in to Flash (test if External Interface is working)
1078
- SWFUpload.prototype.testExternalInterface = function () {
1079
- try {
1080
- return this.callFlash("TestExternalInterface");
1081
- } catch (ex) {
1082
- return false;
1083
- }
1084
- };
1085
-
1086
- // Private: This event is called by Flash when it has finished loading. Don't modify this.
1087
- // Use the swfupload_loaded_handler event setting to execute custom code when SWFUpload has loaded.
1088
- SWFUpload.prototype.flashReady = function () {
1089
- // Check that the movie element is loaded correctly with its ExternalInterface methods defined
1090
- var movieElement = this.getMovieElement();
1091
-
1092
- if (!movieElement) {
1093
- this.debug("Flash called back ready but the flash movie can't be found.");
1094
- return;
1095
- }
1096
-
1097
- this.cleanUp(movieElement);
1098
-
1099
- this.queueEvent("swfupload_loaded_handler");
1100
- };
1101
-
1102
- // Private: removes Flash added fuctions to the DOM node to prevent memory leaks in IE.
1103
- // This function is called by Flash each time the ExternalInterface functions are created.
1104
- SWFUpload.prototype.cleanUp = function (movieElement) {
1105
- // Pro-actively unhook all the Flash functions
1106
- try {
1107
- if (this.movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
1108
- this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");
1109
- for (var key in movieElement) {
1110
- try {
1111
- if (typeof(movieElement[key]) === "function") {
1112
- movieElement[key] = null;
1113
- }
1114
- } catch (ex) {
1115
- }
1116
- }
1117
- }
1118
- } catch (ex1) {
1119
-
1120
- }
1121
-
1122
- // Fix Flashes own cleanup code so if the SWFMovie was removed from the page
1123
- // it doesn't display errors.
1124
- window["__flash__removeCallback"] = function (instance, name) {
1125
- try {
1126
- if (instance) {
1127
- instance[name] = null;
1128
- }
1129
- } catch (flashEx) {
1130
-
1131
- }
1132
- };
1133
-
1134
- };
1135
-
1136
-
1137
- /* This is a chance to do something before the browse window opens */
1138
- SWFUpload.prototype.fileDialogStart = function () {
1139
- this.queueEvent("file_dialog_start_handler");
1140
- };
1141
-
1142
-
1143
- /* Called when a file is successfully added to the queue. */
1144
- SWFUpload.prototype.fileQueued = function (file) {
1145
- file = this.unescapeFilePostParams(file);
1146
- this.queueEvent("file_queued_handler", file);
1147
- };
1148
-
1149
-
1150
- /* Handle errors that occur when an attempt to queue a file fails. */
1151
- SWFUpload.prototype.fileQueueError = function (file, errorCode, message) {
1152
- file = this.unescapeFilePostParams(file);
1153
- this.queueEvent("file_queue_error_handler", [file, errorCode, message]);
1154
- };
1155
-
1156
- /* Called after the file dialog has closed and the selected files have been queued.
1157
- You could call startUpload here if you want the queued files to begin uploading immediately. */
1158
- SWFUpload.prototype.fileDialogComplete = function (numFilesSelected, numFilesQueued, numFilesInQueue) {
1159
- this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued, numFilesInQueue]);
1160
- };
1161
-
1162
- SWFUpload.prototype.uploadStart = function (file) {
1163
- file = this.unescapeFilePostParams(file);
1164
- this.queueEvent("return_upload_start_handler", file);
1165
- };
1166
-
1167
- SWFUpload.prototype.returnUploadStart = function (file) {
1168
- var returnValue;
1169
- if (typeof this.settings.upload_start_handler === "function") {
1170
- file = this.unescapeFilePostParams(file);
1171
- returnValue = this.settings.upload_start_handler.call(this, file);
1172
- } else if (this.settings.upload_start_handler != undefined) {
1173
- throw "upload_start_handler must be a function";
1174
- }
1175
-
1176
- // Convert undefined to true so if nothing is returned from the upload_start_handler it is
1177
- // interpretted as 'true'.
1178
- if (returnValue === undefined) {
1179
- returnValue = true;
1180
- }
1181
-
1182
- returnValue = !!returnValue;
1183
-
1184
- this.callFlash("ReturnUploadStart", [returnValue]);
1185
- };
1186
-
1187
-
1188
-
1189
- SWFUpload.prototype.uploadProgress = function (file, bytesComplete, bytesTotal) {
1190
- file = this.unescapeFilePostParams(file);
1191
- this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]);
1192
- };
1193
-
1194
- SWFUpload.prototype.uploadError = function (file, errorCode, message) {
1195
- file = this.unescapeFilePostParams(file);
1196
- this.queueEvent("upload_error_handler", [file, errorCode, message]);
1197
- };
1198
-
1199
- SWFUpload.prototype.uploadSuccess = function (file, serverData, responseReceived) {
1200
- file = this.unescapeFilePostParams(file);
1201
- this.queueEvent("upload_success_handler", [file, serverData, responseReceived]);
1202
- };
1203
-
1204
- SWFUpload.prototype.uploadComplete = function (file) {
1205
- file = this.unescapeFilePostParams(file);
1206
- this.queueEvent("upload_complete_handler", file);
1207
- };
1208
-
1209
- /* Called by SWFUpload JavaScript and Flash functions when debug is enabled. By default it writes messages to the
1210
- internal debug console. You can override this event and have messages written where you want. */
1211
- SWFUpload.prototype.debug = function (message) {
1212
- this.queueEvent("debug_handler", message);
1213
- };
1214
-
1215
-
1216
- /* **********************************
1217
- Debug Console
1218
- The debug console is a self contained, in page location
1219
- for debug message to be sent. The Debug Console adds
1220
- itself to the body if necessary.
1221
-
1222
- The console is automatically scrolled as messages appear.
1223
-
1224
- If you are using your own debug handler or when you deploy to production and
1225
- have debug disabled you can remove these functions to reduce the file size
1226
- and complexity.
1227
- ********************************** */
1228
-
1229
- // Private: debugMessage is the default debug_handler. If you want to print debug messages
1230
- // call the debug() function. When overriding the function your own function should
1231
- // check to see if the debug setting is true before outputting debug information.
1232
- SWFUpload.prototype.debugMessage = function (message) {
1233
- if (this.settings.debug) {
1234
- var exceptionMessage, exceptionValues = [];
1235
-
1236
- // Check for an exception object and print it nicely
1237
- if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") {
1238
- for (var key in message) {
1239
- if (message.hasOwnProperty(key)) {
1240
- exceptionValues.push(key + ": " + message[key]);
1241
- }
1242
- }
1243
- exceptionMessage = exceptionValues.join("\n") || "";
1244
- exceptionValues = exceptionMessage.split("\n");
1245
- exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: ");
1246
- SWFUpload.Console.writeLine(exceptionMessage);
1247
- } else {
1248
- SWFUpload.Console.writeLine(message);
1249
- }
1250
- }
1251
- };
1252
-
1253
- SWFUpload.Console = {};
1254
- SWFUpload.Console.writeLine = function (message) {
1255
- var console, documentForm;
1256
-
1257
- try {
1258
- console = document.getElementById("SWFUpload_Console");
1259
-
1260
- if (!console) {
1261
- documentForm = document.createElement("form");
1262
- document.getElementsByTagName("body")[0].appendChild(documentForm);
1263
-
1264
- console = document.createElement("textarea");
1265
- console.id = "SWFUpload_Console";
1266
- console.style.fontFamily = "monospace";
1267
- console.setAttribute("wrap", "off");
1268
- console.wrap = "off";
1269
- console.style.overflow = "auto";
1270
- console.style.width = "700px";
1271
- console.style.height = "350px";
1272
- console.style.margin = "5px";
1273
- documentForm.appendChild(console);
1274
- }
1275
-
1276
- console.value += message + "\n";
1277
-
1278
- console.scrollTop = console.scrollHeight - console.clientHeight;
1279
- } catch (ex) {
1280
- alert("Exception: " + ex.name + " Message: " + ex.message);
1281
- }
1282
- };
1283
-
1284
- })();
1285
-
1286
- (function() {
1287
- /*
1288
- Queue Plug-in
1289
-
1290
- Features:
1291
- *Adds a cancelQueue() method for cancelling the entire queue.
1292
- *All queued files are uploaded when startUpload() is called.
1293
- *If false is returned from uploadComplete then the queue upload is stopped.
1294
- If false is not returned (strict comparison) then the queue upload is continued.
1295
- *Adds a QueueComplete event that is fired when all the queued files have finished uploading.
1296
- Set the event handler with the queue_complete_handler setting.
1297
-
1298
- */
1299
-
1300
- if (typeof(SWFUpload) === "function") {
1301
- SWFUpload.queue = {};
1302
-
1303
- SWFUpload.prototype.initSettings = (function (oldInitSettings) {
1304
- return function () {
1305
- if (typeof(oldInitSettings) === "function") {
1306
- oldInitSettings.call(this);
1307
- }
1308
-
1309
- this.queueSettings = {};
1310
-
1311
- this.queueSettings.queue_cancelled_flag = false;
1312
- this.queueSettings.queue_upload_count = 0;
1313
-
1314
- this.queueSettings.user_upload_complete_handler = this.settings.upload_complete_handler;
1315
- this.queueSettings.user_upload_start_handler = this.settings.upload_start_handler;
1316
- this.settings.upload_complete_handler = SWFUpload.queue.uploadCompleteHandler;
1317
- this.settings.upload_start_handler = SWFUpload.queue.uploadStartHandler;
1318
-
1319
- this.settings.queue_complete_handler = this.settings.queue_complete_handler || null;
1320
- };
1321
- })(SWFUpload.prototype.initSettings);
1322
-
1323
- SWFUpload.prototype.startUpload = function (fileID) {
1324
- this.queueSettings.queue_cancelled_flag = false;
1325
- this.callFlash("StartUpload", [fileID]);
1326
- };
1327
-
1328
- SWFUpload.prototype.cancelQueue = function () {
1329
- this.queueSettings.queue_cancelled_flag = true;
1330
- this.stopUpload();
1331
-
1332
- var stats = this.getStats();
1333
- while (stats.files_queued > 0) {
1334
- this.cancelUpload();
1335
- stats = this.getStats();
1336
- }
1337
- };
1338
-
1339
- SWFUpload.queue.uploadStartHandler = function (file) {
1340
- var returnValue;
1341
- if (typeof(this.queueSettings.user_upload_start_handler) === "function") {
1342
- returnValue = this.queueSettings.user_upload_start_handler.call(this, file);
1343
- }
1344
-
1345
- // To prevent upload a real "FALSE" value must be returned, otherwise default to a real "TRUE" value.
1346
- returnValue = (returnValue === false) ? false : true;
1347
-
1348
- this.queueSettings.queue_cancelled_flag = !returnValue;
1349
-
1350
- return returnValue;
1351
- };
1352
-
1353
- SWFUpload.queue.uploadCompleteHandler = function (file) {
1354
- var user_upload_complete_handler = this.queueSettings.user_upload_complete_handler;
1355
- var continueUpload;
1356
-
1357
- if (file.filestatus === SWFUpload.FILE_STATUS.COMPLETE) {
1358
- this.queueSettings.queue_upload_count++;
1359
- }
1360
-
1361
- if (typeof(user_upload_complete_handler) === "function") {
1362
- continueUpload = (user_upload_complete_handler.call(this, file) === false) ? false : true;
1363
- } else if (file.filestatus === SWFUpload.FILE_STATUS.QUEUED) {
1364
- // If the file was stopped and re-queued don't restart the upload
1365
- continueUpload = false;
1366
- } else {
1367
- continueUpload = true;
1368
- }
1369
-
1370
- if (continueUpload) {
1371
- var stats = this.getStats();
1372
- if (stats.files_queued > 0 && this.queueSettings.queue_cancelled_flag === false) {
1373
- this.startUpload();
1374
- } else if (this.queueSettings.queue_cancelled_flag === false) {
1375
- this.queueEvent("queue_complete_handler", [this.queueSettings.queue_upload_count]);
1376
- this.queueSettings.queue_upload_count = 0;
1377
- } else {
1378
- this.queueSettings.queue_cancelled_flag = false;
1379
- this.queueSettings.queue_upload_count = 0;
1380
- }
1381
- }
1382
- };
1383
- }
1384
-
1385
- })();