mo_page 0.0.2

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