comfortable_mexican_sofa 2.0.6 → 2.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (243) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +2 -2
  3. data/.gitattributes +2 -2
  4. data/.gitignore +1 -1
  5. data/.travis.yml +21 -7
  6. data/Gemfile +10 -7
  7. data/app/assets/javascripts/comfy/admin/cms/application.js.coffee +24 -22
  8. data/app/assets/javascripts/comfy/admin/cms/base.js.coffee +2 -3
  9. data/app/assets/javascripts/comfy/admin/cms/uploader.js.coffee +13 -9
  10. data/app/assets/javascripts/comfy/vendor/Moxie.swf +0 -0
  11. data/app/assets/javascripts/comfy/vendor/Moxie.xap +0 -0
  12. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/bootstrap.min.js +0 -0
  13. data/app/assets/javascripts/comfy/vendor/codemirror.js +9653 -0
  14. data/app/assets/javascripts/comfy/vendor/codemirror/addon/edit/closetag.js +169 -0
  15. data/app/assets/javascripts/comfy/vendor/codemirror/mode/css/css.js +832 -0
  16. data/app/assets/javascripts/comfy/vendor/codemirror/mode/htmlmixed/htmlmixed.js +152 -0
  17. data/app/assets/javascripts/comfy/vendor/codemirror/mode/javascript/javascript.js +875 -0
  18. data/app/assets/javascripts/comfy/vendor/codemirror/mode/markdown/markdown.js +861 -0
  19. data/app/assets/javascripts/comfy/vendor/codemirror/mode/xml/xml.js +394 -0
  20. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/diff/diff_match_patch.min.js +0 -0
  21. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/diff/pretty_text_diff.js +0 -0
  22. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr.min.js +0 -0
  23. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/ar.js +0 -0
  24. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/bg.js +0 -0
  25. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/bn.js +0 -0
  26. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/ca.js +0 -0
  27. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/cs.js +0 -0
  28. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/cy.js +0 -0
  29. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/da.js +0 -0
  30. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/de.js +0 -0
  31. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/default.js +0 -0
  32. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/eo.js +0 -0
  33. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/es.js +0 -0
  34. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/et.js +0 -0
  35. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/fa.js +0 -0
  36. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/fi.js +0 -0
  37. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/fr.js +0 -0
  38. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/gr.js +0 -0
  39. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/he.js +0 -0
  40. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/hi.js +0 -0
  41. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/hr.js +0 -0
  42. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/hu.js +0 -0
  43. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/id.js +0 -0
  44. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/it.js +0 -0
  45. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/ja.js +0 -0
  46. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/ko.js +0 -0
  47. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/lt.js +0 -0
  48. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/lv.js +0 -0
  49. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/mk.js +0 -0
  50. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/mn.js +0 -0
  51. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/ms.js +0 -0
  52. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/my.js +0 -0
  53. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/nl.js +0 -0
  54. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/no.js +0 -0
  55. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/pa.js +0 -0
  56. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/pl.js +0 -0
  57. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/pt-BR.js +0 -0
  58. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/pt.js +0 -0
  59. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/ro.js +0 -0
  60. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/ru.js +0 -0
  61. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/si.js +0 -0
  62. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/sk.js +0 -0
  63. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/sl.js +0 -0
  64. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/sq.js +0 -0
  65. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/sr.js +0 -0
  66. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/sv.js +0 -0
  67. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/th.js +0 -0
  68. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/tr.js +0 -0
  69. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/uk.js +0 -0
  70. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/vn.js +0 -0
  71. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/zh-CN.js +0 -0
  72. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/flatpickr/i18n/zh-TW.js +0 -0
  73. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/fontawesome.js +0 -0
  74. data/app/assets/javascripts/comfy/vendor/moxie.min.js +16 -0
  75. data/app/assets/javascripts/comfy/vendor/plupload.dev.js +2497 -0
  76. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/popper.min.js +0 -0
  77. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor.js +0 -0
  78. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/definedlinks.js +0 -0
  79. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/filemanager.js +0 -0
  80. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/ar.js +0 -0
  81. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/az.js +0 -0
  82. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/ba.js +0 -0
  83. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/bg.js +0 -0
  84. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/by.js +0 -0
  85. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/ca.js +0 -0
  86. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/cs.js +0 -0
  87. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/da.js +0 -0
  88. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/de.js +0 -0
  89. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/el.js +0 -0
  90. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/en.js +0 -0
  91. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/eo.js +0 -0
  92. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/es.js +0 -0
  93. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/es_AR.js +0 -0
  94. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/fa.js +0 -0
  95. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/fi.js +0 -0
  96. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/fr.js +0 -0
  97. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/ge.js +0 -0
  98. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/gr.js +0 -0
  99. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/he.js +0 -0
  100. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/hr.js +0 -0
  101. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/hu.js +0 -0
  102. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/id.js +0 -0
  103. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/it.js +0 -0
  104. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/ja.js +0 -0
  105. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/kn.js +0 -0
  106. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/ko.js +0 -0
  107. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/lt.js +0 -0
  108. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/lv.js +0 -0
  109. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/mk.js +0 -0
  110. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/nb.js +0 -0
  111. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/nl.js +0 -0
  112. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/pl.js +0 -0
  113. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/pt-BR.js +0 -0
  114. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/pt.js +0 -0
  115. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/ro.js +0 -0
  116. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/ru.js +0 -0
  117. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/sk.js +0 -0
  118. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/sl.js +0 -0
  119. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/sq.js +0 -0
  120. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/sr-CIR.js +0 -0
  121. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/sr-LAT.js +0 -0
  122. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/sv.js +0 -0
  123. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/th.js +0 -0
  124. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/tr.js +0 -0
  125. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/ua.js +0 -0
  126. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/uk.js +0 -0
  127. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/vi.js +0 -0
  128. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/zh-CN.js +0 -0
  129. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/i18n/zh-TW.js +0 -0
  130. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/imagemanager.js +0 -0
  131. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/table.js +0 -0
  132. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/redactor/video.js +0 -0
  133. data/app/assets/javascripts/comfy/{admin/cms/lib → vendor}/sortable.min.js +0 -0
  134. data/app/assets/stylesheets/comfy/admin/cms/application.sass +7 -5
  135. data/app/assets/stylesheets/comfy/admin/cms/codemirror_overrides.sass +6 -14
  136. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/_bootstrap.scss +0 -0
  137. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_alert.scss +0 -0
  138. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_badge.scss +0 -0
  139. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_breadcrumb.scss +0 -0
  140. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_button-group.scss +0 -0
  141. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_buttons.scss +0 -0
  142. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_card.scss +0 -0
  143. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_carousel.scss +0 -0
  144. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_close.scss +0 -0
  145. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_code.scss +0 -0
  146. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_custom-forms.scss +0 -0
  147. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_dropdown.scss +0 -0
  148. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_forms.scss +0 -0
  149. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_functions.scss +0 -0
  150. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_grid.scss +0 -0
  151. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_images.scss +0 -0
  152. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_input-group.scss +0 -0
  153. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_jumbotron.scss +0 -0
  154. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_list-group.scss +0 -0
  155. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_media.scss +0 -0
  156. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_mixins.scss +0 -0
  157. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_modal.scss +0 -0
  158. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_nav.scss +0 -0
  159. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_navbar.scss +0 -0
  160. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_pagination.scss +0 -0
  161. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_popover.scss +0 -0
  162. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_print.scss +0 -0
  163. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_progress.scss +0 -0
  164. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_reboot.scss +0 -0
  165. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_root.scss +0 -0
  166. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_tables.scss +0 -0
  167. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_tooltip.scss +0 -0
  168. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_transitions.scss +0 -0
  169. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_type.scss +0 -0
  170. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_utilities.scss +0 -0
  171. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/_variables.scss +0 -0
  172. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_alert.scss +0 -0
  173. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_background-variant.scss +0 -0
  174. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_badge.scss +0 -0
  175. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_border-radius.scss +0 -0
  176. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_box-shadow.scss +0 -0
  177. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_breakpoints.scss +0 -0
  178. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_buttons.scss +0 -0
  179. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_caret.scss +0 -0
  180. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_clearfix.scss +0 -0
  181. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_float.scss +0 -0
  182. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_forms.scss +0 -0
  183. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_gradients.scss +0 -0
  184. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_grid-framework.scss +0 -0
  185. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_grid.scss +0 -0
  186. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_hover.scss +0 -0
  187. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_image.scss +0 -0
  188. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_list-group.scss +0 -0
  189. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_lists.scss +0 -0
  190. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_nav-divider.scss +0 -0
  191. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_navbar-align.scss +0 -0
  192. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_pagination.scss +0 -0
  193. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_reset-text.scss +0 -0
  194. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_resize.scss +0 -0
  195. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_screen-reader.scss +0 -0
  196. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_size.scss +0 -0
  197. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_table-row.scss +0 -0
  198. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_text-emphasis.scss +0 -0
  199. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_text-hide.scss +0 -0
  200. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_text-truncate.scss +0 -0
  201. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_transition.scss +0 -0
  202. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/mixins/_visibility.scss +0 -0
  203. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/utilities/_align.scss +0 -0
  204. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/utilities/_background.scss +0 -0
  205. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/utilities/_borders.scss +0 -0
  206. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/utilities/_clearfix.scss +0 -0
  207. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/utilities/_display.scss +0 -0
  208. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/utilities/_embed.scss +0 -0
  209. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/utilities/_flex.scss +0 -0
  210. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/utilities/_float.scss +0 -0
  211. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/utilities/_position.scss +0 -0
  212. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/utilities/_screenreaders.scss +0 -0
  213. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/utilities/_sizing.scss +0 -0
  214. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/utilities/_spacing.scss +0 -0
  215. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/utilities/_text.scss +0 -0
  216. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/bootstrap/utilities/_visibility.scss +0 -0
  217. data/app/assets/stylesheets/comfy/vendor/codemirror.css +346 -0
  218. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/flatpickr.min.css +0 -0
  219. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/fontawesome.css +0 -0
  220. data/app/assets/stylesheets/comfy/{admin/cms/lib → vendor}/redactor.css +0 -0
  221. data/app/models/comfy/cms/layout.rb +4 -2
  222. data/app/views/comfy/admin/cms/files/destroy.js.coffee +1 -1
  223. data/comfortable_mexican_sofa.gemspec +0 -2
  224. data/lib/comfortable_mexican_sofa/engine.rb +0 -3
  225. data/lib/comfortable_mexican_sofa/extensions/acts_as_tree.rb +1 -1
  226. data/lib/comfortable_mexican_sofa/extensions/has_revisions.rb +1 -1
  227. data/lib/comfortable_mexican_sofa/version.rb +1 -1
  228. data/public/favicon.ico +0 -0
  229. data/test/controllers/comfy/admin/cms/sites_controller_test.rb +1 -1
  230. data/test/fixtures/comfy/cms/layouts.yml +4 -4
  231. data/test/fixtures/comfy/cms/sites.yml +1 -1
  232. data/test/gemfiles/Gemfile.rails.5.2 +9 -3
  233. data/test/integration/seeds_test.rb +1 -1
  234. data/test/integration/sites_test.rb +6 -6
  235. data/test/lib/seeds/layouts_test.rb +9 -9
  236. data/test/models/page_test.rb +6 -6
  237. data/test/models/site_test.rb +13 -13
  238. data/test/system/layouts_frontend_test.rb +15 -0
  239. data/test/system/pages_frontend_test.rb +15 -0
  240. data/test/system/sites_frontend_test.rb +11 -0
  241. data/test/system/snippets_frontend_test.rb +15 -0
  242. data/test/test_helper.rb +25 -12
  243. metadata +216 -227
@@ -0,0 +1,16 @@
1
+ /**
2
+ * mOxie - multi-runtime File API & XMLHttpRequest L2 Polyfill
3
+ * v1.5.7
4
+ *
5
+ * Copyright 2013, Moxiecode Systems AB
6
+ * Released under GPL License.
7
+ *
8
+ * License: http://www.plupload.com/license
9
+ * Contributing: http://www.plupload.com/contributing
10
+ *
11
+ * Date: 2017-11-03
12
+ */
13
+ !function(e,t){var i=function(){var e={};return t.apply(e,arguments),e.moxie};"function"==typeof define&&define.amd?define("moxie",[],i):"object"==typeof module&&module.exports?module.exports=i():e.moxie=i()}(this||window,function(){!function(e,t){"use strict";function i(e,t){for(var i,n=[],r=0;r<e.length;++r){if(i=s[e[r]]||o(e[r]),!i)throw"module definition dependecy not found: "+e[r];n.push(i)}t.apply(null,n)}function n(e,n,r){if("string"!=typeof e)throw"invalid module definition, module id must be defined and be a string";if(n===t)throw"invalid module definition, dependencies must be specified";if(r===t)throw"invalid module definition, definition function must be specified";i(n,function(){s[e]=r.apply(null,arguments)})}function r(e){return!!s[e]}function o(t){for(var i=e,n=t.split(/[.\/]/),r=0;r<n.length;++r){if(!i[n[r]])return;i=i[n[r]]}return i}function a(i){for(var n=0;n<i.length;n++){for(var r=e,o=i[n],a=o.split(/[.\/]/),u=0;u<a.length-1;++u)r[a[u]]===t&&(r[a[u]]={}),r=r[a[u]];r[a[a.length-1]]=s[o]}}var s={};n("moxie/core/utils/Basic",[],function(){function e(e){var t;return e===t?"undefined":null===e?"null":e.nodeType?"node":{}.toString.call(e).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()}function t(){return s(!1,!1,arguments)}function i(){return s(!0,!1,arguments)}function n(){return s(!1,!0,arguments)}function r(){return s(!0,!0,arguments)}function o(t){switch(e(t)){case"array":return s(!1,!0,[[],t]);case"object":return s(!1,!0,[{},t]);default:return t}}function a(i){switch(e(i)){case"array":return Array.prototype.slice.call(i);case"object":return t({},i)}return i}function s(t,i,n){var r,o=n[0];return c(n,function(n,u){u>0&&c(n,function(n,u){var c=-1!==h(e(n),["array","object"]);return n===r||t&&o[u]===r?!0:(c&&i&&(n=a(n)),e(o[u])===e(n)&&c?s(t,i,[o[u],n]):o[u]=n,void 0)})}),o}function u(e,t){function i(){this.constructor=e}for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n]);return i.prototype=t.prototype,e.prototype=new i,e.parent=t.prototype,e}function c(e,t){var i,n,r,o;if(e){try{i=e.length}catch(a){i=o}if(i===o||"number"!=typeof i){for(n in e)if(e.hasOwnProperty(n)&&t(e[n],n)===!1)return}else for(r=0;i>r;r++)if(t(e[r],r)===!1)return}}function l(t){var i;if(!t||"object"!==e(t))return!0;for(i in t)return!1;return!0}function d(t,i){function n(r){"function"===e(t[r])&&t[r](function(e){++r<o&&!e?n(r):i(e)})}var r=0,o=t.length;"function"!==e(i)&&(i=function(){}),t&&t.length||i(),n(r)}function m(e,t){var i=0,n=e.length,r=new Array(n);c(e,function(e,o){e(function(e){if(e)return t(e);var a=[].slice.call(arguments);a.shift(),r[o]=a,i++,i===n&&(r.unshift(null),t.apply(this,r))})})}function h(e,t){if(t){if(Array.prototype.indexOf)return Array.prototype.indexOf.call(t,e);for(var i=0,n=t.length;n>i;i++)if(t[i]===e)return i}return-1}function f(t,i){var n=[];"array"!==e(t)&&(t=[t]),"array"!==e(i)&&(i=[i]);for(var r in t)-1===h(t[r],i)&&n.push(t[r]);return n.length?n:!1}function p(e,t){var i=[];return c(e,function(e){-1!==h(e,t)&&i.push(e)}),i.length?i:null}function g(e){var t,i=[];for(t=0;t<e.length;t++)i[t]=e[t];return i}function x(e){return e?String.prototype.trim?String.prototype.trim.call(e):e.toString().replace(/^\s*/,"").replace(/\s*$/,""):e}function v(e){if("string"!=typeof e)return e;var t,i={t:1099511627776,g:1073741824,m:1048576,k:1024};return e=/^([0-9\.]+)([tmgk]?)$/.exec(e.toLowerCase().replace(/[^0-9\.tmkg]/g,"")),t=e[2],e=+e[1],i.hasOwnProperty(t)&&(e*=i[t]),Math.floor(e)}function w(e){var t=[].slice.call(arguments,1);return e.replace(/%([a-z])/g,function(e,i){var n=t.shift();switch(i){case"s":return n+"";case"d":return parseInt(n,10);case"f":return parseFloat(n);case"c":return"";default:return n}})}function y(e,t){var i=this;setTimeout(function(){e.call(i)},t||1)}var E=function(){var e=0;return function(t){var i,n=(new Date).getTime().toString(32);for(i=0;5>i;i++)n+=Math.floor(65535*Math.random()).toString(32);return(t||"o_")+n+(e++).toString(32)}}();return{guid:E,typeOf:e,extend:t,extendIf:i,extendImmutable:n,extendImmutableIf:r,clone:o,inherit:u,each:c,isEmptyObj:l,inSeries:d,inParallel:m,inArray:h,arrayDiff:f,arrayIntersect:p,toArray:g,trim:x,sprintf:w,parseSizeStr:v,delay:y}}),n("moxie/core/utils/Encode",[],function(){var e=function(e){return unescape(encodeURIComponent(e))},t=function(e){return decodeURIComponent(escape(e))},i=function(e,i){if("function"==typeof window.atob)return i?t(window.atob(e)):window.atob(e);var n,r,o,a,s,u,c,l,d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",m=0,h=0,f="",p=[];if(!e)return e;e+="";do a=d.indexOf(e.charAt(m++)),s=d.indexOf(e.charAt(m++)),u=d.indexOf(e.charAt(m++)),c=d.indexOf(e.charAt(m++)),l=a<<18|s<<12|u<<6|c,n=255&l>>16,r=255&l>>8,o=255&l,p[h++]=64==u?String.fromCharCode(n):64==c?String.fromCharCode(n,r):String.fromCharCode(n,r,o);while(m<e.length);return f=p.join(""),i?t(f):f},n=function(t,i){if(i&&(t=e(t)),"function"==typeof window.btoa)return window.btoa(t);var n,r,o,a,s,u,c,l,d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",m=0,h=0,f="",p=[];if(!t)return t;do n=t.charCodeAt(m++),r=t.charCodeAt(m++),o=t.charCodeAt(m++),l=n<<16|r<<8|o,a=63&l>>18,s=63&l>>12,u=63&l>>6,c=63&l,p[h++]=d.charAt(a)+d.charAt(s)+d.charAt(u)+d.charAt(c);while(m<t.length);f=p.join("");var g=t.length%3;return(g?f.slice(0,g-3):f)+"===".slice(g||3)};return{utf8_encode:e,utf8_decode:t,atob:i,btoa:n}}),n("moxie/core/utils/Env",["moxie/core/utils/Basic"],function(e){function i(e,t,i){var n=0,r=0,o=0,a={dev:-6,alpha:-5,a:-5,beta:-4,b:-4,RC:-3,rc:-3,"#":-2,p:1,pl:1},s=function(e){return e=(""+e).replace(/[_\-+]/g,"."),e=e.replace(/([^.\d]+)/g,".$1.").replace(/\.{2,}/g,"."),e.length?e.split("."):[-8]},u=function(e){return e?isNaN(e)?a[e]||-7:parseInt(e,10):0};for(e=s(e),t=s(t),r=Math.max(e.length,t.length),n=0;r>n;n++)if(e[n]!=t[n]){if(e[n]=u(e[n]),t[n]=u(t[n]),e[n]<t[n]){o=-1;break}if(e[n]>t[n]){o=1;break}}if(!i)return o;switch(i){case">":case"gt":return o>0;case">=":case"ge":return o>=0;case"<=":case"le":return 0>=o;case"==":case"=":case"eq":return 0===o;case"<>":case"!=":case"ne":return 0!==o;case"":case"<":case"lt":return 0>o;default:return null}}var n=function(e){var t="",i="?",n="function",r="undefined",o="object",a="name",s="version",u={has:function(e,t){return-1!==t.toLowerCase().indexOf(e.toLowerCase())},lowerize:function(e){return e.toLowerCase()}},c={rgx:function(){for(var t,i,a,s,u,c,l,d=0,m=arguments;d<m.length;d+=2){var h=m[d],f=m[d+1];if(typeof t===r){t={};for(s in f)u=f[s],typeof u===o?t[u[0]]=e:t[u]=e}for(i=a=0;i<h.length;i++)if(c=h[i].exec(this.getUA())){for(s=0;s<f.length;s++)l=c[++a],u=f[s],typeof u===o&&u.length>0?2==u.length?t[u[0]]=typeof u[1]==n?u[1].call(this,l):u[1]:3==u.length?t[u[0]]=typeof u[1]!==n||u[1].exec&&u[1].test?l?l.replace(u[1],u[2]):e:l?u[1].call(this,l,u[2]):e:4==u.length&&(t[u[0]]=l?u[3].call(this,l.replace(u[1],u[2])):e):t[u]=l?l:e;break}if(c)break}return t},str:function(t,n){for(var r in n)if(typeof n[r]===o&&n[r].length>0){for(var a=0;a<n[r].length;a++)if(u.has(n[r][a],t))return r===i?e:r}else if(u.has(n[r],t))return r===i?e:r;return t}},l={browser:{oldsafari:{major:{1:["/8","/1","/3"],2:"/4","?":"/"},version:{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}}},device:{sprint:{model:{"Evo Shift 4G":"7373KT"},vendor:{HTC:"APA",Sprint:"Sprint"}}},os:{windows:{version:{ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2000:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",RT:"ARM"}}}},d={browser:[[/(opera\smini)\/([\w\.-]+)/i,/(opera\s[mobiletab]+).+version\/([\w\.-]+)/i,/(opera).+version\/([\w\.]+)/i,/(opera)[\/\s]+([\w\.]+)/i],[a,s],[/\s(opr)\/([\w\.]+)/i],[[a,"Opera"],s],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?([\w\.]+)*/i,/(avant\s|iemobile|slim|baidu)(?:browser)?[\/\s]?([\w\.]*)/i,/(?:ms|\()(ie)\s([\w\.]+)/i,/(rekonq)\/([\w\.]+)*/i,/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi)\/([\w\.-]+)/i],[a,s],[/(trident).+rv[:\s]([\w\.]+).+like\sgecko/i],[[a,"IE"],s],[/(edge)\/((\d+)?[\w\.]+)/i],[a,s],[/(yabrowser)\/([\w\.]+)/i],[[a,"Yandex"],s],[/(comodo_dragon)\/([\w\.]+)/i],[[a,/_/g," "],s],[/(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?([\w\.]+)/i,/(uc\s?browser|qqbrowser)[\/\s]?([\w\.]+)/i],[a,s],[/(dolfin)\/([\w\.]+)/i],[[a,"Dolphin"],s],[/((?:android.+)crmo|crios)\/([\w\.]+)/i],[[a,"Chrome"],s],[/XiaoMi\/MiuiBrowser\/([\w\.]+)/i],[s,[a,"MIUI Browser"]],[/android.+version\/([\w\.]+)\s+(?:mobile\s?safari|safari)/i],[s,[a,"Android Browser"]],[/FBAV\/([\w\.]+);/i],[s,[a,"Facebook"]],[/version\/([\w\.]+).+?mobile\/\w+\s(safari)/i],[s,[a,"Mobile Safari"]],[/version\/([\w\.]+).+?(mobile\s?safari|safari)/i],[s,a],[/webkit.+?(mobile\s?safari|safari)(\/[\w\.]+)/i],[a,[s,c.str,l.browser.oldsafari.version]],[/(konqueror)\/([\w\.]+)/i,/(webkit|khtml)\/([\w\.]+)/i],[a,s],[/(navigator|netscape)\/([\w\.-]+)/i],[[a,"Netscape"],s],[/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?([\w\.\+]+)/i,/(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix)\/([\w\.-]+)/i,/(mozilla)\/([\w\.]+).+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf)[\/\s]?([\w\.]+)/i,/(links)\s\(([\w\.]+)/i,/(gobrowser)\/?([\w\.]+)*/i,/(ice\s?browser)\/v?([\w\._]+)/i,/(mosaic)[\/\s]([\w\.]+)/i],[a,s]],engine:[[/windows.+\sedge\/([\w\.]+)/i],[s,[a,"EdgeHTML"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i,/(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i,/(icab)[\/\s]([23]\.[\d\.]+)/i],[a,s],[/rv\:([\w\.]+).*(gecko)/i],[s,a]],os:[[/microsoft\s(windows)\s(vista|xp)/i],[a,s],[/(windows)\snt\s6\.2;\s(arm)/i,/(windows\sphone(?:\sos)*|windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i],[a,[s,c.str,l.os.windows.version]],[/(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i],[[a,"Windows"],[s,c.str,l.os.windows.version]],[/\((bb)(10);/i],[[a,"BlackBerry"],s],[/(blackberry)\w*\/?([\w\.]+)*/i,/(tizen)[\/\s]([\w\.]+)/i,/(android|webos|palm\os|qnx|bada|rim\stablet\sos|meego|contiki)[\/\s-]?([\w\.]+)*/i,/linux;.+(sailfish);/i],[a,s],[/(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]+)*/i],[[a,"Symbian"],s],[/\((series40);/i],[a],[/mozilla.+\(mobile;.+gecko.+firefox/i],[[a,"Firefox OS"],s],[/(nintendo|playstation)\s([wids3portablevu]+)/i,/(mint)[\/\s\(]?(\w+)*/i,/(mageia|vectorlinux)[;\s]/i,/(joli|[kxln]?ubuntu|debian|[open]*suse|gentoo|arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk|linpus)[\/\s-]?([\w\.-]+)*/i,/(hurd|linux)\s?([\w\.]+)*/i,/(gnu)\s?([\w\.]+)*/i],[a,s],[/(cros)\s[\w]+\s([\w\.]+\w)/i],[[a,"Chromium OS"],s],[/(sunos)\s?([\w\.]+\d)*/i],[[a,"Solaris"],s],[/\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]+)*/i],[a,s],[/(ip[honead]+)(?:.*os\s*([\w]+)*\slike\smac|;\sopera)/i],[[a,"iOS"],[s,/_/g,"."]],[/(mac\sos\sx)\s?([\w\s\.]+\w)*/i,/(macintosh|mac(?=_powerpc)\s)/i],[[a,"Mac OS"],[s,/_/g,"."]],[/((?:open)?solaris)[\/\s-]?([\w\.]+)*/i,/(haiku)\s(\w+)/i,/(aix)\s((\d)(?=\.|\)|\s)[\w\.]*)*/i,/(plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos|openvms)/i,/(unix)\s?([\w\.]+)*/i],[a,s]]},m=function(e){var i=e||(window&&window.navigator&&window.navigator.userAgent?window.navigator.userAgent:t);this.getBrowser=function(){return c.rgx.apply(this,d.browser)},this.getEngine=function(){return c.rgx.apply(this,d.engine)},this.getOS=function(){return c.rgx.apply(this,d.os)},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS()}},this.getUA=function(){return i},this.setUA=function(e){return i=e,this},this.setUA(i)};return m}(),r=function(){var i={access_global_ns:function(){return!!window.moxie},define_property:function(){return!1}(),create_canvas:function(){var e=document.createElement("canvas"),t=!(!e.getContext||!e.getContext("2d"));return i.create_canvas=t,t},return_response_type:function(t){try{if(-1!==e.inArray(t,["","text","document"]))return!0;if(window.XMLHttpRequest){var i=new XMLHttpRequest;if(i.open("get","/"),"responseType"in i)return i.responseType=t,i.responseType!==t?!1:!0}}catch(n){}return!1},use_blob_uri:function(){var e=window.URL;return i.use_blob_uri=e&&"createObjectURL"in e&&"revokeObjectURL"in e&&("IE"!==a.browser||a.verComp(a.version,"11.0.46",">=")),i.use_blob_uri},use_data_uri:function(){var e=new Image;return e.onload=function(){i.use_data_uri=1===e.width&&1===e.height},setTimeout(function(){e.src="data:image/gif;base64,R0lGODlhAQABAIAAAP8AAAAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=="},1),!1}(),use_data_uri_over32kb:function(){return i.use_data_uri&&("IE"!==a.browser||a.version>=9)},use_data_uri_of:function(e){return i.use_data_uri&&33e3>e||i.use_data_uri_over32kb()},use_fileinput:function(){if(navigator.userAgent.match(/(Android (1.0|1.1|1.5|1.6|2.0|2.1))|(Windows Phone (OS 7|8.0))|(XBLWP)|(ZuneWP)|(w(eb)?OSBrowser)|(webOS)|(Kindle\/(1.0|2.0|2.5|3.0))/))return!1;var e=document.createElement("input");return e.setAttribute("type","file"),i.use_fileinput=!e.disabled},use_webgl:function(){var e,n=document.createElement("canvas"),r=null;try{r=n.getContext("webgl")||n.getContext("experimental-webgl")}catch(o){}return r||(r=null),e=!!r,i.use_webgl=e,n=t,e}};return function(t){var n=[].slice.call(arguments);return n.shift(),"function"===e.typeOf(i[t])?i[t].apply(this,n):!!i[t]}}(),o=(new n).getResult(),a={can:r,uaParser:n,browser:o.browser.name,version:o.browser.version,os:o.os.name,osVersion:o.os.version,verComp:i,swf_url:"../flash/Moxie.swf",xap_url:"../silverlight/Moxie.xap",global_event_dispatcher:"moxie.core.EventTarget.instance.dispatchEvent"};return a.OS=a.os,a}),n("moxie/core/Exceptions",["moxie/core/utils/Basic"],function(e){function t(e,t){var i;for(i in e)if(e[i]===t)return i;return null}return{RuntimeError:function(){function i(e,i){this.code=e,this.name=t(n,e),this.message=this.name+(i||": RuntimeError "+this.code)}var n={NOT_INIT_ERR:1,EXCEPTION_ERR:3,NOT_SUPPORTED_ERR:9,JS_ERR:4};return e.extend(i,n),i.prototype=Error.prototype,i}(),OperationNotAllowedException:function(){function t(e){this.code=e,this.name="OperationNotAllowedException"}return e.extend(t,{NOT_ALLOWED_ERR:1}),t.prototype=Error.prototype,t}(),ImageError:function(){function i(e){this.code=e,this.name=t(n,e),this.message=this.name+": ImageError "+this.code}var n={WRONG_FORMAT:1,MAX_RESOLUTION_ERR:2,INVALID_META_ERR:3};return e.extend(i,n),i.prototype=Error.prototype,i}(),FileException:function(){function i(e){this.code=e,this.name=t(n,e),this.message=this.name+": FileException "+this.code}var n={NOT_FOUND_ERR:1,SECURITY_ERR:2,ABORT_ERR:3,NOT_READABLE_ERR:4,ENCODING_ERR:5,NO_MODIFICATION_ALLOWED_ERR:6,INVALID_STATE_ERR:7,SYNTAX_ERR:8};return e.extend(i,n),i.prototype=Error.prototype,i}(),DOMException:function(){function i(e){this.code=e,this.name=t(n,e),this.message=this.name+": DOMException "+this.code}var n={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25};return e.extend(i,n),i.prototype=Error.prototype,i}(),EventException:function(){function t(e){this.code=e,this.name="EventException"}return e.extend(t,{UNSPECIFIED_EVENT_TYPE_ERR:0}),t.prototype=Error.prototype,t}()}}),n("moxie/core/utils/Dom",["moxie/core/utils/Env"],function(e){var t=function(e){return"string"!=typeof e?e:document.getElementById(e)},i=function(e,t){if(!e.className)return!1;var i=new RegExp("(^|\\s+)"+t+"(\\s+|$)");return i.test(e.className)},n=function(e,t){i(e,t)||(e.className=e.className?e.className.replace(/\s+$/,"")+" "+t:t)},r=function(e,t){if(e.className){var i=new RegExp("(^|\\s+)"+t+"(\\s+|$)");e.className=e.className.replace(i,function(e,t,i){return" "===t&&" "===i?" ":""})}},o=function(e,t){return e.currentStyle?e.currentStyle[t]:window.getComputedStyle?window.getComputedStyle(e,null)[t]:void 0},a=function(t,i){function n(e){var t,i,n=0,r=0;return e&&(i=e.getBoundingClientRect(),t="CSS1Compat"===c.compatMode?c.documentElement:c.body,n=i.left+t.scrollLeft,r=i.top+t.scrollTop),{x:n,y:r}}var r,o,a,s=0,u=0,c=document;if(t=t,i=i||c.body,t&&t.getBoundingClientRect&&"IE"===e.browser&&(!c.documentMode||c.documentMode<8))return o=n(t),a=n(i),{x:o.x-a.x,y:o.y-a.y};for(r=t;r&&r!=i&&r.nodeType;)s+=r.offsetLeft||0,u+=r.offsetTop||0,r=r.offsetParent;for(r=t.parentNode;r&&r!=i&&r.nodeType;)s-=r.scrollLeft||0,u-=r.scrollTop||0,r=r.parentNode;return{x:s,y:u}},s=function(e){return{w:e.offsetWidth||e.clientWidth,h:e.offsetHeight||e.clientHeight}};return{get:t,hasClass:i,addClass:n,removeClass:r,getStyle:o,getPos:a,getSize:s}}),n("moxie/core/EventTarget",["moxie/core/utils/Env","moxie/core/Exceptions","moxie/core/utils/Basic"],function(e,t,i){function n(){this.uid=i.guid()}var r={};return i.extend(n.prototype,{init:function(){this.uid||(this.uid=i.guid("uid_"))},addEventListener:function(e,t,n,o){var a,s=this;return this.hasOwnProperty("uid")||(this.uid=i.guid("uid_")),e=i.trim(e),/\s/.test(e)?(i.each(e.split(/\s+/),function(e){s.addEventListener(e,t,n,o)}),void 0):(e=e.toLowerCase(),n=parseInt(n,10)||0,a=r[this.uid]&&r[this.uid][e]||[],a.push({fn:t,priority:n,scope:o||this}),r[this.uid]||(r[this.uid]={}),r[this.uid][e]=a,void 0)},hasEventListener:function(e){var t;return e?(e=e.toLowerCase(),t=r[this.uid]&&r[this.uid][e]):t=r[this.uid],t?t:!1},removeEventListener:function(e,t){var n,o,a=this;if(e=e.toLowerCase(),/\s/.test(e))return i.each(e.split(/\s+/),function(e){a.removeEventListener(e,t)}),void 0;if(n=r[this.uid]&&r[this.uid][e]){if(t){for(o=n.length-1;o>=0;o--)if(n[o].fn===t){n.splice(o,1);break}}else n=[];n.length||(delete r[this.uid][e],i.isEmptyObj(r[this.uid])&&delete r[this.uid])}},removeAllEventListeners:function(){r[this.uid]&&delete r[this.uid]},dispatchEvent:function(e){var n,o,a,s,u,c={},l=!0;if("string"!==i.typeOf(e)){if(s=e,"string"!==i.typeOf(s.type))throw new t.EventException(t.EventException.UNSPECIFIED_EVENT_TYPE_ERR);e=s.type,s.total!==u&&s.loaded!==u&&(c.total=s.total,c.loaded=s.loaded),c.async=s.async||!1}if(-1!==e.indexOf("::")?function(t){n=t[0],e=t[1]}(e.split("::")):n=this.uid,e=e.toLowerCase(),o=r[n]&&r[n][e]){o.sort(function(e,t){return t.priority-e.priority}),a=[].slice.call(arguments),a.shift(),c.type=e,a.unshift(c);var d=[];i.each(o,function(e){a[0].target=e.scope,c.async?d.push(function(t){setTimeout(function(){t(e.fn.apply(e.scope,a)===!1)},1)}):d.push(function(t){t(e.fn.apply(e.scope,a)===!1)})}),d.length&&i.inSeries(d,function(e){l=!e})}return l},bindOnce:function(e,t,i,n){var r=this;r.bind.call(this,e,function o(){return r.unbind(e,o),t.apply(this,arguments)},i,n)},bind:function(){this.addEventListener.apply(this,arguments)},unbind:function(){this.removeEventListener.apply(this,arguments)},unbindAll:function(){this.removeAllEventListeners.apply(this,arguments)},trigger:function(){return this.dispatchEvent.apply(this,arguments)},handleEventProps:function(e){var t=this;this.bind(e.join(" "),function(e){var t="on"+e.type.toLowerCase();"function"===i.typeOf(this[t])&&this[t].apply(this,arguments)}),i.each(e,function(e){e="on"+e.toLowerCase(e),"undefined"===i.typeOf(t[e])&&(t[e]=null)})}}),n.instance=new n,n}),n("moxie/runtime/Runtime",["moxie/core/utils/Env","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/EventTarget"],function(e,t,i,n){function r(e,n,o,s,u){var c,l=this,d=t.guid(n+"_"),m=u||"browser";e=e||{},a[d]=this,o=t.extend({access_binary:!1,access_image_binary:!1,display_media:!1,do_cors:!1,drag_and_drop:!1,filter_by_extension:!0,resize_image:!1,report_upload_progress:!1,return_response_headers:!1,return_response_type:!1,return_status_code:!0,send_custom_headers:!1,select_file:!1,select_folder:!1,select_multiple:!0,send_binary_string:!1,send_browser_cookies:!0,send_multipart:!0,slice_blob:!1,stream_upload:!1,summon_file_dialog:!1,upload_filesize:!0,use_http_method:!0},o),e.preferred_caps&&(m=r.getMode(s,e.preferred_caps,m)),c=function(){var e={};return{exec:function(t,i,n,r){return c[i]&&(e[t]||(e[t]={context:this,instance:new c[i]}),e[t].instance[n])?e[t].instance[n].apply(this,r):void 0},removeInstance:function(t){delete e[t]},removeAllInstances:function(){var i=this;t.each(e,function(e,n){"function"===t.typeOf(e.instance.destroy)&&e.instance.destroy.call(e.context),i.removeInstance(n)})}}}(),t.extend(this,{initialized:!1,uid:d,type:n,mode:r.getMode(s,e.required_caps,m),shimid:d+"_container",clients:0,options:e,can:function(e,i){var n=arguments[2]||o;if("string"===t.typeOf(e)&&"undefined"===t.typeOf(i)&&(e=r.parseCaps(e)),"object"===t.typeOf(e)){for(var a in e)if(!this.can(a,e[a],n))return!1;return!0}return"function"===t.typeOf(n[e])?n[e].call(this,i):i===n[e]},getShimContainer:function(){var e,n=i.get(this.shimid);return n||(e=i.get(this.options.container)||document.body,n=document.createElement("div"),n.id=this.shimid,n.className="moxie-shim moxie-shim-"+this.type,t.extend(n.style,{position:"absolute",top:"0px",left:"0px",width:"1px",height:"1px",overflow:"hidden"}),e.appendChild(n),e=null),n},getShim:function(){return c},shimExec:function(e,t){var i=[].slice.call(arguments,2);return l.getShim().exec.call(this,this.uid,e,t,i)},exec:function(e,t){var i=[].slice.call(arguments,2);return l[e]&&l[e][t]?l[e][t].apply(this,i):l.shimExec.apply(this,arguments)},destroy:function(){if(l){var e=i.get(this.shimid);e&&e.parentNode.removeChild(e),c&&c.removeAllInstances(),this.unbindAll(),delete a[this.uid],this.uid=null,d=l=c=e=null}}}),this.mode&&e.required_caps&&!this.can(e.required_caps)&&(this.mode=!1)}var o={},a={};return r.order="html5,flash,silverlight,html4",r.getRuntime=function(e){return a[e]?a[e]:!1},r.addConstructor=function(e,t){t.prototype=n.instance,o[e]=t},r.getConstructor=function(e){return o[e]||null},r.getInfo=function(e){var t=r.getRuntime(e);return t?{uid:t.uid,type:t.type,mode:t.mode,can:function(){return t.can.apply(t,arguments)}}:null},r.parseCaps=function(e){var i={};return"string"!==t.typeOf(e)?e||{}:(t.each(e.split(","),function(e){i[e]=!0}),i)},r.can=function(e,t){var i,n,o=r.getConstructor(e);return o?(i=new o({required_caps:t}),n=i.mode,i.destroy(),!!n):!1},r.thatCan=function(e,t){var i=(t||r.order).split(/\s*,\s*/);for(var n in i)if(r.can(i[n],e))return i[n];return null},r.getMode=function(e,i,n){var r=null;if("undefined"===t.typeOf(n)&&(n="browser"),i&&!t.isEmptyObj(e)){if(t.each(i,function(i,n){if(e.hasOwnProperty(n)){var o=e[n](i);if("string"==typeof o&&(o=[o]),r){if(!(r=t.arrayIntersect(r,o)))return r=!1}else r=o}}),r)return-1!==t.inArray(n,r)?n:r[0];if(r===!1)return!1}return n},r.getGlobalEventTarget=function(){if(/^moxie\./.test(e.global_event_dispatcher)&&!e.can("access_global_ns")){var i=t.guid("moxie_event_target_");window[i]=function(e,t){n.instance.dispatchEvent(e,t)},e.global_event_dispatcher=i}return e.global_event_dispatcher},r.capTrue=function(){return!0},r.capFalse=function(){return!1},r.capTest=function(e){return function(){return!!e}},r}),n("moxie/runtime/RuntimeClient",["moxie/core/utils/Env","moxie/core/Exceptions","moxie/core/utils/Basic","moxie/runtime/Runtime"],function(e,t,i,n){return function(){var e;i.extend(this,{connectRuntime:function(r){function o(i){var a,u;return i.length?(a=i.shift().toLowerCase(),(u=n.getConstructor(a))?(e=new u(r),e.bind("Init",function(){e.initialized=!0,setTimeout(function(){e.clients++,s.ruid=e.uid,s.trigger("RuntimeInit",e)},1)}),e.bind("Error",function(){e.destroy(),o(i)}),e.bind("Exception",function(e,i){var n=i.name+"(#"+i.code+")"+(i.message?", from: "+i.message:"");s.trigger("RuntimeError",new t.RuntimeError(t.RuntimeError.EXCEPTION_ERR,n))}),e.mode?(e.init(),void 0):(e.trigger("Error"),void 0)):(o(i),void 0)):(s.trigger("RuntimeError",new t.RuntimeError(t.RuntimeError.NOT_INIT_ERR)),e=null,void 0)}var a,s=this;if("string"===i.typeOf(r)?a=r:"string"===i.typeOf(r.ruid)&&(a=r.ruid),a){if(e=n.getRuntime(a))return s.ruid=a,e.clients++,e;throw new t.RuntimeError(t.RuntimeError.NOT_INIT_ERR)}o((r.runtime_order||n.order).split(/\s*,\s*/))},disconnectRuntime:function(){e&&--e.clients<=0&&e.destroy(),e=null},getRuntime:function(){return e&&e.uid?e:e=null},exec:function(){return e?e.exec.apply(this,arguments):null},can:function(t){return e?e.can(t):!1}})}}),n("moxie/file/Blob",["moxie/core/utils/Basic","moxie/core/utils/Encode","moxie/runtime/RuntimeClient"],function(e,t,i){function n(o,a){function s(t,i,o){var a,s=r[this.uid];return"string"===e.typeOf(s)&&s.length?(a=new n(null,{type:o,size:i-t}),a.detach(s.substr(t,a.size)),a):null}i.call(this),o&&this.connectRuntime(o),a?"string"===e.typeOf(a)&&(a={data:a}):a={},e.extend(this,{uid:a.uid||e.guid("uid_"),ruid:o,size:a.size||0,type:a.type||"",slice:function(e,t,i){return this.isDetached()?s.apply(this,arguments):this.getRuntime().exec.call(this,"Blob","slice",this.getSource(),e,t,i)},getSource:function(){return r[this.uid]?r[this.uid]:null},detach:function(e){if(this.ruid&&(this.getRuntime().exec.call(this,"Blob","destroy"),this.disconnectRuntime(),this.ruid=null),e=e||"","data:"==e.substr(0,5)){var i=e.indexOf(";base64,");this.type=e.substring(5,i),e=t.atob(e.substring(i+8))}this.size=e.length,r[this.uid]=e},isDetached:function(){return!this.ruid&&"string"===e.typeOf(r[this.uid])},destroy:function(){this.detach(),delete r[this.uid]}}),a.data?this.detach(a.data):r[this.uid]=a}var r={};return n}),n("moxie/core/I18n",["moxie/core/utils/Basic"],function(e){var t={};return{addI18n:function(i){return e.extend(t,i)},translate:function(e){return t[e]||e},_:function(e){return this.translate(e)},sprintf:function(t){var i=[].slice.call(arguments,1);return t.replace(/%[a-z]/g,function(){var t=i.shift();return"undefined"!==e.typeOf(t)?t:""})}}}),n("moxie/core/utils/Mime",["moxie/core/utils/Basic","moxie/core/I18n"],function(e,t){var i="application/msword,doc dot,application/pdf,pdf,application/pgp-signature,pgp,application/postscript,ps ai eps,application/rtf,rtf,application/vnd.ms-excel,xls xlb xlt xla,application/vnd.ms-powerpoint,ppt pps pot ppa,application/zip,zip,application/x-shockwave-flash,swf swfl,application/vnd.openxmlformats-officedocument.wordprocessingml.document,docx,application/vnd.openxmlformats-officedocument.wordprocessingml.template,dotx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,xlsx,application/vnd.openxmlformats-officedocument.presentationml.presentation,pptx,application/vnd.openxmlformats-officedocument.presentationml.template,potx,application/vnd.openxmlformats-officedocument.presentationml.slideshow,ppsx,application/x-javascript,js,application/json,json,audio/mpeg,mp3 mpga mpega mp2,audio/x-wav,wav,audio/x-m4a,m4a,audio/ogg,oga ogg,audio/aiff,aiff aif,audio/flac,flac,audio/aac,aac,audio/ac3,ac3,audio/x-ms-wma,wma,image/bmp,bmp,image/gif,gif,image/jpeg,jpg jpeg jpe,image/photoshop,psd,image/png,png,image/svg+xml,svg svgz,image/tiff,tiff tif,text/plain,asc txt text diff log,text/html,htm html xhtml,text/css,css,text/csv,csv,text/rtf,rtf,video/mpeg,mpeg mpg mpe m2v,video/quicktime,qt mov,video/mp4,mp4,video/x-m4v,m4v,video/x-flv,flv,video/x-ms-wmv,wmv,video/avi,avi,video/webm,webm,video/3gpp,3gpp 3gp,video/3gpp2,3g2,video/vnd.rn-realvideo,rv,video/ogg,ogv,video/x-matroska,mkv,application/vnd.oasis.opendocument.formula-template,otf,application/octet-stream,exe",n={},r={},o=function(e){var t,i,o,a=e.split(/,/);for(t=0;t<a.length;t+=2){for(o=a[t+1].split(/ /),i=0;i<o.length;i++)n[o[i]]=a[t];r[a[t]]=o}},a=function(t,i){var n,r,o,a,s=[];for(r=0;r<t.length;r++)for(n=t[r].extensions.toLowerCase().split(/\s*,\s*/),o=0;o<n.length;o++){if("*"===n[o])return[];if(a=s[n[o]],i&&/^\w+$/.test(n[o]))s.push("."+n[o]);else if(a&&-1===e.inArray(a,s))s.push(a);else if(!a)return[]}return s},s=function(t){var i=[];return e.each(t,function(t){if(t=t.toLowerCase(),"*"===t)return i=[],!1;var n=t.match(/^(\w+)\/(\*|\w+)$/);n&&("*"===n[2]?e.each(r,function(e,t){new RegExp("^"+n[1]+"/").test(t)&&[].push.apply(i,r[t])}):r[t]&&[].push.apply(i,r[t]))}),i},u=function(i){var n=[],r=[];return"string"===e.typeOf(i)&&(i=e.trim(i).split(/\s*,\s*/)),r=s(i),n.push({title:t.translate("Files"),extensions:r.length?r.join(","):"*"}),n},c=function(e){var t=e&&e.match(/\.([^.]+)$/);return t?t[1].toLowerCase():""},l=function(e){return n[c(e)]||""};return o(i),{mimes:n,extensions:r,addMimeType:o,extList2mimes:a,mimes2exts:s,mimes2extList:u,getFileExtension:c,getFileMime:l}}),n("moxie/file/FileInput",["moxie/core/utils/Basic","moxie/core/utils/Env","moxie/core/utils/Mime","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/core/EventTarget","moxie/core/I18n","moxie/runtime/Runtime","moxie/runtime/RuntimeClient"],function(e,t,i,n,r,o,a,s,u){function c(t){var o,c,d;if(-1!==e.inArray(e.typeOf(t),["string","node"])&&(t={browse_button:t}),c=n.get(t.browse_button),!c)throw new r.DOMException(r.DOMException.NOT_FOUND_ERR);d={accept:[{title:a.translate("All Files"),extensions:"*"}],multiple:!1,required_caps:!1,container:c.parentNode||document.body},t=e.extend({},d,t),"string"==typeof t.required_caps&&(t.required_caps=s.parseCaps(t.required_caps)),"string"==typeof t.accept&&(t.accept=i.mimes2extList(t.accept)),o=n.get(t.container),o||(o=document.body),"static"===n.getStyle(o,"position")&&(o.style.position="relative"),o=c=null,u.call(this),e.extend(this,{uid:e.guid("uid_"),ruid:null,shimid:null,files:null,init:function(){var i=this;i.bind("RuntimeInit",function(r,o){i.ruid=o.uid,i.shimid=o.shimid,i.bind("Ready",function(){i.trigger("Refresh")},999),i.bind("Refresh",function(){var i,r,a,s,u;a=n.get(t.browse_button),s=n.get(o.shimid),a&&(i=n.getPos(a,n.get(t.container)),r=n.getSize(a),u=parseInt(n.getStyle(a,"z-index"),10)||0,s&&e.extend(s.style,{top:i.y+"px",left:i.x+"px",width:r.w+"px",height:r.h+"px",zIndex:u+1})),s=a=null}),o.exec.call(i,"FileInput","init",t)}),i.connectRuntime(e.extend({},t,{required_caps:{select_file:!0}}))},getOption:function(e){return t[e]},setOption:function(e,n){if(t.hasOwnProperty(e)){var o=t[e];switch(e){case"accept":"string"==typeof n&&(n=i.mimes2extList(n));break;case"container":case"required_caps":throw new r.FileException(r.FileException.NO_MODIFICATION_ALLOWED_ERR)}t[e]=n,this.exec("FileInput","setOption",e,n),this.trigger("OptionChanged",e,n,o)}},disable:function(t){var i=this.getRuntime();i&&this.exec("FileInput","disable","undefined"===e.typeOf(t)?!0:t)},refresh:function(){this.trigger("Refresh")},destroy:function(){var t=this.getRuntime();t&&(t.exec.call(this,"FileInput","destroy"),this.disconnectRuntime()),"array"===e.typeOf(this.files)&&e.each(this.files,function(e){e.destroy()}),this.files=null,this.unbindAll()}}),this.handleEventProps(l)}var l=["ready","change","cancel","mouseenter","mouseleave","mousedown","mouseup"];return c.prototype=o.instance,c}),n("moxie/file/File",["moxie/core/utils/Basic","moxie/core/utils/Mime","moxie/file/Blob"],function(e,t,i){function n(n,r){r||(r={}),i.apply(this,arguments),this.type||(this.type=t.getFileMime(r.name));var o;if(r.name)o=r.name.replace(/\\/g,"/"),o=o.substr(o.lastIndexOf("/")+1);else if(this.type){var a=this.type.split("/")[0];o=e.guid((""!==a?a:"file")+"_"),t.extensions[this.type]&&(o+="."+t.extensions[this.type][0])}e.extend(this,{name:o||e.guid("file_"),relativePath:"",lastModifiedDate:r.lastModifiedDate||(new Date).toLocaleString()})}return n.prototype=i.prototype,n}),n("moxie/file/FileDrop",["moxie/core/I18n","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/core/utils/Basic","moxie/core/utils/Env","moxie/file/File","moxie/runtime/RuntimeClient","moxie/core/EventTarget","moxie/core/utils/Mime"],function(e,t,i,n,r,o,a,s,u){function c(i){var r,o=this;"string"==typeof i&&(i={drop_zone:i}),r={accept:[{title:e.translate("All Files"),extensions:"*"}],required_caps:{drag_and_drop:!0}},i="object"==typeof i?n.extend({},r,i):r,i.container=t.get(i.drop_zone)||document.body,"static"===t.getStyle(i.container,"position")&&(i.container.style.position="relative"),"string"==typeof i.accept&&(i.accept=u.mimes2extList(i.accept)),a.call(o),n.extend(o,{uid:n.guid("uid_"),ruid:null,files:null,init:function(){o.bind("RuntimeInit",function(e,t){o.ruid=t.uid,t.exec.call(o,"FileDrop","init",i),o.dispatchEvent("ready")
14
+ }),o.connectRuntime(i)},destroy:function(){var e=this.getRuntime();e&&(e.exec.call(this,"FileDrop","destroy"),this.disconnectRuntime()),this.files=null,this.unbindAll()}}),this.handleEventProps(l)}var l=["ready","dragenter","dragleave","drop","error"];return c.prototype=s.instance,c}),n("moxie/file/FileReader",["moxie/core/utils/Basic","moxie/core/utils/Encode","moxie/core/Exceptions","moxie/core/EventTarget","moxie/file/Blob","moxie/runtime/RuntimeClient"],function(e,t,i,n,r,o){function a(){function n(e,n){if(this.trigger("loadstart"),this.readyState===a.LOADING)return this.trigger("error",new i.DOMException(i.DOMException.INVALID_STATE_ERR)),this.trigger("loadend"),void 0;if(!(n instanceof r))return this.trigger("error",new i.DOMException(i.DOMException.NOT_FOUND_ERR)),this.trigger("loadend"),void 0;if(this.result=null,this.readyState=a.LOADING,n.isDetached()){var o=n.getSource();switch(e){case"readAsText":case"readAsBinaryString":this.result=o;break;case"readAsDataURL":this.result="data:"+n.type+";base64,"+t.btoa(o)}this.readyState=a.DONE,this.trigger("load"),this.trigger("loadend")}else this.connectRuntime(n.ruid),this.exec("FileReader","read",e,n)}o.call(this),e.extend(this,{uid:e.guid("uid_"),readyState:a.EMPTY,result:null,error:null,readAsBinaryString:function(e){n.call(this,"readAsBinaryString",e)},readAsDataURL:function(e){n.call(this,"readAsDataURL",e)},readAsText:function(e){n.call(this,"readAsText",e)},abort:function(){this.result=null,-1===e.inArray(this.readyState,[a.EMPTY,a.DONE])&&(this.readyState===a.LOADING&&(this.readyState=a.DONE),this.exec("FileReader","abort"),this.trigger("abort"),this.trigger("loadend"))},destroy:function(){this.abort(),this.exec("FileReader","destroy"),this.disconnectRuntime(),this.unbindAll()}}),this.handleEventProps(s),this.bind("Error",function(e,t){this.readyState=a.DONE,this.error=t},999),this.bind("Load",function(){this.readyState=a.DONE},999)}var s=["loadstart","progress","load","abort","error","loadend"];return a.EMPTY=0,a.LOADING=1,a.DONE=2,a.prototype=n.instance,a}),n("moxie/core/utils/Url",["moxie/core/utils/Basic"],function(e){var t=function(i,n){var r,o=["source","scheme","authority","userInfo","user","pass","host","port","relative","path","directory","file","query","fragment"],a=o.length,s={http:80,https:443},u={},c=/^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@\/]*):?([^:@\/]*))?@)?(\[[\da-fA-F:]+\]|[^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/,l=c.exec(i||""),d=/^\/\/\w/.test(i);switch(e.typeOf(n)){case"undefined":n=t(document.location.href,!1);break;case"string":n=t(n,!1)}for(;a--;)l[a]&&(u[o[a]]=l[a]);if(r=!d&&!u.scheme,(d||r)&&(u.scheme=n.scheme),r){u.host=n.host,u.port=n.port;var m="";/^[^\/]/.test(u.path)&&(m=n.path,m=/\/[^\/]*\.[^\/]*$/.test(m)?m.replace(/\/[^\/]+$/,"/"):m.replace(/\/?$/,"/")),u.path=m+(u.path||"")}return u.port||(u.port=s[u.scheme]||80),u.port=parseInt(u.port,10),u.path||(u.path="/"),delete u.source,u},i=function(e){var i={http:80,https:443},n="object"==typeof e?e:t(e);return n.scheme+"://"+n.host+(n.port!==i[n.scheme]?":"+n.port:"")+n.path+(n.query?n.query:"")},n=function(e){function i(e){return[e.scheme,e.host,e.port].join("/")}return"string"==typeof e&&(e=t(e)),i(t())===i(e)};return{parseUrl:t,resolveUrl:i,hasSameOrigin:n}}),n("moxie/runtime/RuntimeTarget",["moxie/core/utils/Basic","moxie/runtime/RuntimeClient","moxie/core/EventTarget"],function(e,t,i){function n(){this.uid=e.guid("uid_"),t.call(this),this.destroy=function(){this.disconnectRuntime(),this.unbindAll()}}return n.prototype=i.instance,n}),n("moxie/file/FileReaderSync",["moxie/core/utils/Basic","moxie/runtime/RuntimeClient","moxie/core/utils/Encode"],function(e,t,i){return function(){function n(e,t){if(!t.isDetached()){var n=this.connectRuntime(t.ruid).exec.call(this,"FileReaderSync","read",e,t);return this.disconnectRuntime(),n}var r=t.getSource();switch(e){case"readAsBinaryString":return r;case"readAsDataURL":return"data:"+t.type+";base64,"+i.btoa(r);case"readAsText":for(var o="",a=0,s=r.length;s>a;a++)o+=String.fromCharCode(r[a]);return o}}t.call(this),e.extend(this,{uid:e.guid("uid_"),readAsBinaryString:function(e){return n.call(this,"readAsBinaryString",e)},readAsDataURL:function(e){return n.call(this,"readAsDataURL",e)},readAsText:function(e){return n.call(this,"readAsText",e)}})}}),n("moxie/xhr/FormData",["moxie/core/Exceptions","moxie/core/utils/Basic","moxie/file/Blob"],function(e,t,i){function n(){var e,n=[];t.extend(this,{append:function(r,o){var a=this,s=t.typeOf(o);o instanceof i?e={name:r,value:o}:"array"===s?(r+="[]",t.each(o,function(e){a.append(r,e)})):"object"===s?t.each(o,function(e,t){a.append(r+"["+t+"]",e)}):"null"===s||"undefined"===s||"number"===s&&isNaN(o)?a.append(r,"false"):n.push({name:r,value:o.toString()})},hasBlob:function(){return!!this.getBlob()},getBlob:function(){return e&&e.value||null},getBlobName:function(){return e&&e.name||null},each:function(i){t.each(n,function(e){i(e.value,e.name)}),e&&i(e.value,e.name)},destroy:function(){e=null,n=[]}})}return n}),n("moxie/xhr/XMLHttpRequest",["moxie/core/utils/Basic","moxie/core/Exceptions","moxie/core/EventTarget","moxie/core/utils/Encode","moxie/core/utils/Url","moxie/runtime/Runtime","moxie/runtime/RuntimeTarget","moxie/file/Blob","moxie/file/FileReaderSync","moxie/xhr/FormData","moxie/core/utils/Env","moxie/core/utils/Mime"],function(e,t,i,n,r,o,a,s,u,c,l,d){function m(){this.uid=e.guid("uid_")}function h(){function i(e,t){return I.hasOwnProperty(e)?1===arguments.length?l.can("define_property")?I[e]:A[e]:(l.can("define_property")?I[e]=t:A[e]=t,void 0):void 0}function u(t){function n(){_&&(_.destroy(),_=null),s.dispatchEvent("loadend"),s=null}function r(r){_.bind("LoadStart",function(e){i("readyState",h.LOADING),s.dispatchEvent("readystatechange"),s.dispatchEvent(e),L&&s.upload.dispatchEvent(e)}),_.bind("Progress",function(e){i("readyState")!==h.LOADING&&(i("readyState",h.LOADING),s.dispatchEvent("readystatechange")),s.dispatchEvent(e)}),_.bind("UploadProgress",function(e){L&&s.upload.dispatchEvent({type:"progress",lengthComputable:!1,total:e.total,loaded:e.loaded})}),_.bind("Load",function(t){i("readyState",h.DONE),i("status",Number(r.exec.call(_,"XMLHttpRequest","getStatus")||0)),i("statusText",f[i("status")]||""),i("response",r.exec.call(_,"XMLHttpRequest","getResponse",i("responseType"))),~e.inArray(i("responseType"),["text",""])?i("responseText",i("response")):"document"===i("responseType")&&i("responseXML",i("response")),U=r.exec.call(_,"XMLHttpRequest","getAllResponseHeaders"),s.dispatchEvent("readystatechange"),i("status")>0?(L&&s.upload.dispatchEvent(t),s.dispatchEvent(t)):(F=!0,s.dispatchEvent("error")),n()}),_.bind("Abort",function(e){s.dispatchEvent(e),n()}),_.bind("Error",function(e){F=!0,i("readyState",h.DONE),s.dispatchEvent("readystatechange"),M=!0,s.dispatchEvent(e),n()}),r.exec.call(_,"XMLHttpRequest","send",{url:x,method:v,async:T,user:w,password:y,headers:S,mimeType:D,encoding:O,responseType:s.responseType,withCredentials:s.withCredentials,options:k},t)}var s=this;E=(new Date).getTime(),_=new a,"string"==typeof k.required_caps&&(k.required_caps=o.parseCaps(k.required_caps)),k.required_caps=e.extend({},k.required_caps,{return_response_type:s.responseType}),t instanceof c&&(k.required_caps.send_multipart=!0),e.isEmptyObj(S)||(k.required_caps.send_custom_headers=!0),B||(k.required_caps.do_cors=!0),k.ruid?r(_.connectRuntime(k)):(_.bind("RuntimeInit",function(e,t){r(t)}),_.bind("RuntimeError",function(e,t){s.dispatchEvent("RuntimeError",t)}),_.connectRuntime(k))}function g(){i("responseText",""),i("responseXML",null),i("response",null),i("status",0),i("statusText",""),E=b=null}var x,v,w,y,E,b,_,R,A=this,I={timeout:0,readyState:h.UNSENT,withCredentials:!1,status:0,statusText:"",responseType:"",responseXML:null,responseText:null,response:null},T=!0,S={},O=null,D=null,N=!1,C=!1,L=!1,M=!1,F=!1,B=!1,P=null,H=null,k={},U="";e.extend(this,I,{uid:e.guid("uid_"),upload:new m,open:function(o,a,s,u,c){var l;if(!o||!a)throw new t.DOMException(t.DOMException.SYNTAX_ERR);if(/[\u0100-\uffff]/.test(o)||n.utf8_encode(o)!==o)throw new t.DOMException(t.DOMException.SYNTAX_ERR);if(~e.inArray(o.toUpperCase(),["CONNECT","DELETE","GET","HEAD","OPTIONS","POST","PUT","TRACE","TRACK"])&&(v=o.toUpperCase()),~e.inArray(v,["CONNECT","TRACE","TRACK"]))throw new t.DOMException(t.DOMException.SECURITY_ERR);if(a=n.utf8_encode(a),l=r.parseUrl(a),B=r.hasSameOrigin(l),x=r.resolveUrl(a),(u||c)&&!B)throw new t.DOMException(t.DOMException.INVALID_ACCESS_ERR);if(w=u||l.user,y=c||l.pass,T=s||!0,T===!1&&(i("timeout")||i("withCredentials")||""!==i("responseType")))throw new t.DOMException(t.DOMException.INVALID_ACCESS_ERR);N=!T,C=!1,S={},g.call(this),i("readyState",h.OPENED),this.dispatchEvent("readystatechange")},setRequestHeader:function(r,o){var a=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","content-transfer-encoding","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"];if(i("readyState")!==h.OPENED||C)throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);if(/[\u0100-\uffff]/.test(r)||n.utf8_encode(r)!==r)throw new t.DOMException(t.DOMException.SYNTAX_ERR);return r=e.trim(r).toLowerCase(),~e.inArray(r,a)||/^(proxy\-|sec\-)/.test(r)?!1:(S[r]?S[r]+=", "+o:S[r]=o,!0)},hasRequestHeader:function(e){return e&&S[e.toLowerCase()]||!1},getAllResponseHeaders:function(){return U||""},getResponseHeader:function(t){return t=t.toLowerCase(),F||~e.inArray(t,["set-cookie","set-cookie2"])?null:U&&""!==U&&(R||(R={},e.each(U.split(/\r\n/),function(t){var i=t.split(/:\s+/);2===i.length&&(i[0]=e.trim(i[0]),R[i[0].toLowerCase()]={header:i[0],value:e.trim(i[1])})})),R.hasOwnProperty(t))?R[t].header+": "+R[t].value:null},overrideMimeType:function(n){var r,o;if(~e.inArray(i("readyState"),[h.LOADING,h.DONE]))throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);if(n=e.trim(n.toLowerCase()),/;/.test(n)&&(r=n.match(/^([^;]+)(?:;\scharset\=)?(.*)$/))&&(n=r[1],r[2]&&(o=r[2])),!d.mimes[n])throw new t.DOMException(t.DOMException.SYNTAX_ERR);P=n,H=o},send:function(i,r){if(k="string"===e.typeOf(r)?{ruid:r}:r?r:{},this.readyState!==h.OPENED||C)throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);if(i instanceof s)k.ruid=i.ruid,D=i.type||"application/octet-stream";else if(i instanceof c){if(i.hasBlob()){var o=i.getBlob();k.ruid=o.ruid,D=o.type||"application/octet-stream"}}else"string"==typeof i&&(O="UTF-8",D="text/plain;charset=UTF-8",i=n.utf8_encode(i));this.withCredentials||(this.withCredentials=k.required_caps&&k.required_caps.send_browser_cookies&&!B),L=!N&&this.upload.hasEventListener(),F=!1,M=!i,N||(C=!0),u.call(this,i)},abort:function(){if(F=!0,N=!1,~e.inArray(i("readyState"),[h.UNSENT,h.OPENED,h.DONE]))i("readyState",h.UNSENT);else{if(i("readyState",h.DONE),C=!1,!_)throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);_.getRuntime().exec.call(_,"XMLHttpRequest","abort",M),M=!0}},destroy:function(){_&&("function"===e.typeOf(_.destroy)&&_.destroy(),_=null),this.unbindAll(),this.upload&&(this.upload.unbindAll(),this.upload=null)}}),this.handleEventProps(p.concat(["readystatechange"])),this.upload.handleEventProps(p)}var f={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",306:"Reserved",307:"Temporary Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Large",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",426:"Upgrade Required",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",510:"Not Extended"};m.prototype=i.instance;var p=["loadstart","progress","abort","error","load","timeout","loadend"];return h.UNSENT=0,h.OPENED=1,h.HEADERS_RECEIVED=2,h.LOADING=3,h.DONE=4,h.prototype=i.instance,h}),n("moxie/runtime/Transporter",["moxie/core/utils/Basic","moxie/core/utils/Encode","moxie/runtime/RuntimeClient","moxie/core/EventTarget"],function(e,t,i,n){function r(){function n(){l=d=0,c=this.result=null}function o(t,i){var n=this;u=i,n.bind("TransportingProgress",function(t){d=t.loaded,l>d&&-1===e.inArray(n.state,[r.IDLE,r.DONE])&&a.call(n)},999),n.bind("TransportingComplete",function(){d=l,n.state=r.DONE,c=null,n.result=u.exec.call(n,"Transporter","getAsBlob",t||"")},999),n.state=r.BUSY,n.trigger("TransportingStarted"),a.call(n)}function a(){var e,i=this,n=l-d;m>n&&(m=n),e=t.btoa(c.substr(d,m)),u.exec.call(i,"Transporter","receive",e,l)}var s,u,c,l,d,m;i.call(this),e.extend(this,{uid:e.guid("uid_"),state:r.IDLE,result:null,transport:function(t,i,r){var a=this;if(r=e.extend({chunk_size:204798},r),(s=r.chunk_size%3)&&(r.chunk_size+=3-s),m=r.chunk_size,n.call(this),c=t,l=t.length,"string"===e.typeOf(r)||r.ruid)o.call(a,i,this.connectRuntime(r));else{var u=function(e,t){a.unbind("RuntimeInit",u),o.call(a,i,t)};this.bind("RuntimeInit",u),this.connectRuntime(r)}},abort:function(){var e=this;e.state=r.IDLE,u&&(u.exec.call(e,"Transporter","clear"),e.trigger("TransportingAborted")),n.call(e)},destroy:function(){this.unbindAll(),u=null,this.disconnectRuntime(),n.call(this)}})}return r.IDLE=0,r.BUSY=1,r.DONE=2,r.prototype=n.instance,r}),n("moxie/image/Image",["moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/file/FileReaderSync","moxie/xhr/XMLHttpRequest","moxie/runtime/Runtime","moxie/runtime/RuntimeClient","moxie/runtime/Transporter","moxie/core/utils/Env","moxie/core/EventTarget","moxie/file/Blob","moxie/file/File","moxie/core/utils/Encode"],function(e,t,i,n,r,o,a,s,u,c,l,d,m){function h(){function n(e){try{return e||(e=this.exec("Image","getInfo")),this.size=e.size,this.width=e.width,this.height=e.height,this.type=e.type,this.meta=e.meta,""===this.name&&(this.name=e.name),!0}catch(t){return this.trigger("error",t.code),!1}}function c(t){var n=e.typeOf(t);try{if(t instanceof h){if(!t.size)throw new i.DOMException(i.DOMException.INVALID_STATE_ERR);p.apply(this,arguments)}else if(t instanceof l){if(!~e.inArray(t.type,["image/jpeg","image/png"]))throw new i.ImageError(i.ImageError.WRONG_FORMAT);g.apply(this,arguments)}else if(-1!==e.inArray(n,["blob","file"]))c.call(this,new d(null,t),arguments[1]);else if("string"===n)"data:"===t.substr(0,5)?c.call(this,new l(null,{data:t}),arguments[1]):x.apply(this,arguments);else{if("node"!==n||"img"!==t.nodeName.toLowerCase())throw new i.DOMException(i.DOMException.TYPE_MISMATCH_ERR);c.call(this,t.src,arguments[1])}}catch(r){this.trigger("error",r.code)}}function p(t,i){var n=this.connectRuntime(t.ruid);this.ruid=n.uid,n.exec.call(this,"Image","loadFromImage",t,"undefined"===e.typeOf(i)?!0:i)}function g(t,i){function n(e){r.ruid=e.uid,e.exec.call(r,"Image","loadFromBlob",t)}var r=this;r.name=t.name||"",t.isDetached()?(this.bind("RuntimeInit",function(e,t){n(t)}),i&&"string"==typeof i.required_caps&&(i.required_caps=o.parseCaps(i.required_caps)),this.connectRuntime(e.extend({required_caps:{access_image_binary:!0,resize_image:!0}},i))):n(this.connectRuntime(t.ruid))}function x(e,t){var i,n=this;i=new r,i.open("get",e),i.responseType="blob",i.onprogress=function(e){n.trigger(e)},i.onload=function(){g.call(n,i.response,!0)},i.onerror=function(e){n.trigger(e)},i.onloadend=function(){i.destroy()},i.bind("RuntimeError",function(e,t){n.trigger("RuntimeError",t)}),i.send(null,t)}a.call(this),e.extend(this,{uid:e.guid("uid_"),ruid:null,name:"",size:0,width:0,height:0,type:"",meta:{},clone:function(){this.load.apply(this,arguments)},load:function(){c.apply(this,arguments)},resize:function(t){var n,r,o=this,a={x:0,y:0,width:o.width,height:o.height},s=e.extendIf({width:o.width,height:o.height,type:o.type||"image/jpeg",quality:90,crop:!1,fit:!0,preserveHeaders:!0,resample:"default",multipass:!0},t);try{if(!o.size)throw new i.DOMException(i.DOMException.INVALID_STATE_ERR);if(o.width>h.MAX_RESIZE_WIDTH||o.height>h.MAX_RESIZE_HEIGHT)throw new i.ImageError(i.ImageError.MAX_RESOLUTION_ERR);if(n=o.meta&&o.meta.tiff&&o.meta.tiff.Orientation||1,-1!==e.inArray(n,[5,6,7,8])){var u=s.width;s.width=s.height,s.height=u}if(s.crop){switch(r=Math.max(s.width/o.width,s.height/o.height),t.fit?(a.width=Math.min(Math.ceil(s.width/r),o.width),a.height=Math.min(Math.ceil(s.height/r),o.height),r=s.width/a.width):(a.width=Math.min(s.width,o.width),a.height=Math.min(s.height,o.height),r=1),"boolean"==typeof s.crop&&(s.crop="cc"),s.crop.toLowerCase().replace(/_/,"-")){case"rb":case"right-bottom":a.x=o.width-a.width,a.y=o.height-a.height;break;case"cb":case"center-bottom":a.x=Math.floor((o.width-a.width)/2),a.y=o.height-a.height;break;case"lb":case"left-bottom":a.x=0,a.y=o.height-a.height;break;case"lt":case"left-top":a.x=0,a.y=0;break;case"ct":case"center-top":a.x=Math.floor((o.width-a.width)/2),a.y=0;break;case"rt":case"right-top":a.x=o.width-a.width,a.y=0;break;case"rc":case"right-center":case"right-middle":a.x=o.width-a.width,a.y=Math.floor((o.height-a.height)/2);break;case"lc":case"left-center":case"left-middle":a.x=0,a.y=Math.floor((o.height-a.height)/2);break;case"cc":case"center-center":case"center-middle":default:a.x=Math.floor((o.width-a.width)/2),a.y=Math.floor((o.height-a.height)/2)}a.x=Math.max(a.x,0),a.y=Math.max(a.y,0)}else r=Math.min(s.width/o.width,s.height/o.height),r>1&&!s.fit&&(r=1);this.exec("Image","resize",a,r,s)}catch(c){o.trigger("error",c.code)}},downsize:function(t){var i,n={width:this.width,height:this.height,type:this.type||"image/jpeg",quality:90,crop:!1,fit:!1,preserveHeaders:!0,resample:"default"};i="object"==typeof t?e.extend(n,t):e.extend(n,{width:arguments[0],height:arguments[1],crop:arguments[2],preserveHeaders:arguments[3]}),this.resize(i)},crop:function(e,t,i){this.downsize(e,t,!0,i)},getAsCanvas:function(){if(!u.can("create_canvas"))throw new i.RuntimeError(i.RuntimeError.NOT_SUPPORTED_ERR);return this.exec("Image","getAsCanvas")},getAsBlob:function(e,t){if(!this.size)throw new i.DOMException(i.DOMException.INVALID_STATE_ERR);return this.exec("Image","getAsBlob",e||"image/jpeg",t||90)},getAsDataURL:function(e,t){if(!this.size)throw new i.DOMException(i.DOMException.INVALID_STATE_ERR);return this.exec("Image","getAsDataURL",e||"image/jpeg",t||90)},getAsBinaryString:function(e,t){var i=this.getAsDataURL(e,t);return m.atob(i.substring(i.indexOf("base64,")+7))},embed:function(n,r){function o(t,r){var o=this;if(u.can("create_canvas")){var l=o.getAsCanvas();if(l)return n.appendChild(l),l=null,o.destroy(),c.trigger("embedded"),void 0}var d=o.getAsDataURL(t,r);if(!d)throw new i.ImageError(i.ImageError.WRONG_FORMAT);if(u.can("use_data_uri_of",d.length))n.innerHTML='<img src="'+d+'" width="'+o.width+'" height="'+o.height+'" alt="" />',o.destroy(),c.trigger("embedded");else{var h=new s;h.bind("TransportingComplete",function(){a=c.connectRuntime(this.result.ruid),c.bind("Embedded",function(){e.extend(a.getShimContainer().style,{top:"0px",left:"0px",width:o.width+"px",height:o.height+"px"}),a=null},999),a.exec.call(c,"ImageView","display",this.result.uid,width,height),o.destroy()}),h.transport(m.atob(d.substring(d.indexOf("base64,")+7)),t,{required_caps:{display_media:!0},runtime_order:"flash,silverlight",container:n})}}var a,c=this,l=e.extend({width:this.width,height:this.height,type:this.type||"image/jpeg",quality:90,fit:!0,resample:"nearest"},r);try{if(!(n=t.get(n)))throw new i.DOMException(i.DOMException.INVALID_NODE_TYPE_ERR);if(!this.size)throw new i.DOMException(i.DOMException.INVALID_STATE_ERR);this.width>h.MAX_RESIZE_WIDTH||this.height>h.MAX_RESIZE_HEIGHT;var d=new h;return d.bind("Resize",function(){o.call(this,l.type,l.quality)}),d.bind("Load",function(){this.downsize(l)}),this.meta.thumb&&this.meta.thumb.width>=l.width&&this.meta.thumb.height>=l.height?d.load(this.meta.thumb.data):d.clone(this,!1),d}catch(f){this.trigger("error",f.code)}},destroy:function(){this.ruid&&(this.getRuntime().exec.call(this,"Image","destroy"),this.disconnectRuntime()),this.meta&&this.meta.thumb&&this.meta.thumb.data.destroy(),this.unbindAll()}}),this.handleEventProps(f),this.bind("Load Resize",function(){return n.call(this)},999)}var f=["progress","load","error","resize","embedded"];return h.MAX_RESIZE_WIDTH=8192,h.MAX_RESIZE_HEIGHT=8192,h.prototype=c.instance,h}),n("moxie/runtime/html5/Runtime",["moxie/core/utils/Basic","moxie/core/Exceptions","moxie/runtime/Runtime","moxie/core/utils/Env"],function(e,t,i,n){function o(t){var o=this,u=i.capTest,c=i.capTrue,l=e.extend({access_binary:u(window.FileReader||window.File&&window.File.getAsDataURL),access_image_binary:function(){return o.can("access_binary")&&!!s.Image},display_media:u((n.can("create_canvas")||n.can("use_data_uri_over32kb"))&&r("moxie/image/Image")),do_cors:u(window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest),drag_and_drop:u(function(){var e=document.createElement("div");return("draggable"in e||"ondragstart"in e&&"ondrop"in e)&&("IE"!==n.browser||n.verComp(n.version,9,">"))}()),filter_by_extension:u(function(){return!("Chrome"===n.browser&&n.verComp(n.version,28,"<")||"IE"===n.browser&&n.verComp(n.version,10,"<")||"Safari"===n.browser&&n.verComp(n.version,7,"<")||"Firefox"===n.browser&&n.verComp(n.version,37,"<"))}()),return_response_headers:c,return_response_type:function(e){return"json"===e&&window.JSON?!0:n.can("return_response_type",e)},return_status_code:c,report_upload_progress:u(window.XMLHttpRequest&&(new XMLHttpRequest).upload),resize_image:function(){return o.can("access_binary")&&n.can("create_canvas")},select_file:function(){return n.can("use_fileinput")&&window.File},select_folder:function(){return o.can("select_file")&&("Chrome"===n.browser&&n.verComp(n.version,21,">=")||"Firefox"===n.browser&&n.verComp(n.version,42,">="))},select_multiple:function(){return!(!o.can("select_file")||"Safari"===n.browser&&"Windows"===n.os||"iOS"===n.os&&n.verComp(n.osVersion,"7.0.0",">")&&n.verComp(n.osVersion,"8.0.0","<"))},send_binary_string:u(window.XMLHttpRequest&&((new XMLHttpRequest).sendAsBinary||window.Uint8Array&&window.ArrayBuffer)),send_custom_headers:u(window.XMLHttpRequest),send_multipart:function(){return!!(window.XMLHttpRequest&&(new XMLHttpRequest).upload&&window.FormData)||o.can("send_binary_string")},slice_blob:u(window.File&&(File.prototype.mozSlice||File.prototype.webkitSlice||File.prototype.slice)),stream_upload:function(){return o.can("slice_blob")&&o.can("send_multipart")},summon_file_dialog:function(){return o.can("select_file")&&!("Firefox"===n.browser&&n.verComp(n.version,4,"<")||"Opera"===n.browser&&n.verComp(n.version,12,"<")||"IE"===n.browser&&n.verComp(n.version,10,"<"))},upload_filesize:c,use_http_method:c},arguments[2]);i.call(this,t,arguments[1]||a,l),e.extend(this,{init:function(){this.trigger("Init")},destroy:function(e){return function(){e.call(o),e=o=null}}(this.destroy)}),e.extend(this.getShim(),s)}var a="html5",s={};return i.addConstructor(a,o),s}),n("moxie/runtime/html5/file/Blob",["moxie/runtime/html5/Runtime","moxie/file/Blob"],function(e,t){function i(){function e(e,t,i){var n;if(!window.File.prototype.slice)return(n=window.File.prototype.webkitSlice||window.File.prototype.mozSlice)?n.call(e,t,i):null;try{return e.slice(),e.slice(t,i)}catch(r){return e.slice(t,i-t)}}this.slice=function(){return new t(this.getRuntime().uid,e.apply(this,arguments))},this.destroy=function(){this.getRuntime().getShim().removeInstance(this.uid)}}return e.Blob=i}),n("moxie/core/utils/Events",["moxie/core/utils/Basic"],function(e){function t(){this.returnValue=!1}function i(){this.cancelBubble=!0}var n={},r="moxie_"+e.guid(),o=function(o,a,s,u){var c,l;a=a.toLowerCase(),o.addEventListener?(c=s,o.addEventListener(a,c,!1)):o.attachEvent&&(c=function(){var e=window.event;e.target||(e.target=e.srcElement),e.preventDefault=t,e.stopPropagation=i,s(e)},o.attachEvent("on"+a,c)),o[r]||(o[r]=e.guid()),n.hasOwnProperty(o[r])||(n[o[r]]={}),l=n[o[r]],l.hasOwnProperty(a)||(l[a]=[]),l[a].push({func:c,orig:s,key:u})},a=function(t,i,o){var a,s;if(i=i.toLowerCase(),t[r]&&n[t[r]]&&n[t[r]][i]){a=n[t[r]][i];for(var u=a.length-1;u>=0&&(a[u].orig!==o&&a[u].key!==o||(t.removeEventListener?t.removeEventListener(i,a[u].func,!1):t.detachEvent&&t.detachEvent("on"+i,a[u].func),a[u].orig=null,a[u].func=null,a.splice(u,1),o===s));u--);if(a.length||delete n[t[r]][i],e.isEmptyObj(n[t[r]])){delete n[t[r]];try{delete t[r]}catch(c){t[r]=s}}}},s=function(t,i){t&&t[r]&&e.each(n[t[r]],function(e,n){a(t,n,i)})};return{addEvent:o,removeEvent:a,removeAllEvents:s}}),n("moxie/runtime/html5/file/FileInput",["moxie/runtime/html5/Runtime","moxie/file/File","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/utils/Events","moxie/core/utils/Mime","moxie/core/utils/Env"],function(e,t,i,n,r,o,a){function s(){var e,s;i.extend(this,{init:function(u){var c,l,d,m,h,f,p=this,g=p.getRuntime();e=u,d=o.extList2mimes(e.accept,g.can("filter_by_extension")),l=g.getShimContainer(),l.innerHTML='<input id="'+g.uid+'" type="file" style="font-size:999px;opacity:0;"'+(e.multiple&&g.can("select_multiple")?"multiple":"")+(e.directory&&g.can("select_folder")?"webkitdirectory directory":"")+(d?' accept="'+d.join(",")+'"':"")+" />",c=n.get(g.uid),i.extend(c.style,{position:"absolute",top:0,left:0,width:"100%",height:"100%"}),m=n.get(e.browse_button),s=n.getStyle(m,"z-index")||"auto",g.can("summon_file_dialog")&&("static"===n.getStyle(m,"position")&&(m.style.position="relative"),r.addEvent(m,"click",function(e){var t=n.get(g.uid);t&&!t.disabled&&t.click(),e.preventDefault()},p.uid),p.bind("Refresh",function(){h=parseInt(s,10)||1,n.get(e.browse_button).style.zIndex=h,this.getRuntime().getShimContainer().style.zIndex=h-1})),f=g.can("summon_file_dialog")?m:l,r.addEvent(f,"mouseover",function(){p.trigger("mouseenter")},p.uid),r.addEvent(f,"mouseout",function(){p.trigger("mouseleave")},p.uid),r.addEvent(f,"mousedown",function(){p.trigger("mousedown")},p.uid),r.addEvent(n.get(e.container),"mouseup",function(){p.trigger("mouseup")},p.uid),(g.can("summon_file_dialog")?c:m).setAttribute("tabindex",-1),c.onchange=function x(){if(p.files=[],i.each(this.files,function(i){var n="";return e.directory&&"."==i.name?!0:(i.webkitRelativePath&&(n="/"+i.webkitRelativePath.replace(/^\//,"")),i=new t(g.uid,i),i.relativePath=n,p.files.push(i),void 0)}),"IE"!==a.browser&&"IEMobile"!==a.browser)this.value="";else{var n=this.cloneNode(!0);this.parentNode.replaceChild(n,this),n.onchange=x}p.files.length&&p.trigger("change")},p.trigger({type:"ready",async:!0}),l=null},setOption:function(e,t){var i=this.getRuntime(),r=n.get(i.uid);switch(e){case"accept":if(t){var a=t.mimes||o.extList2mimes(t,i.can("filter_by_extension"));r.setAttribute("accept",a.join(","))}else r.removeAttribute("accept");break;case"directory":t&&i.can("select_folder")?(r.setAttribute("directory",""),r.setAttribute("webkitdirectory","")):(r.removeAttribute("directory"),r.removeAttribute("webkitdirectory"));break;case"multiple":t&&i.can("select_multiple")?r.setAttribute("multiple",""):r.removeAttribute("multiple")}},disable:function(e){var t,i=this.getRuntime();(t=n.get(i.uid))&&(t.disabled=!!e)},destroy:function(){var t=this.getRuntime(),i=t.getShim(),o=t.getShimContainer(),a=e&&n.get(e.container),u=e&&n.get(e.browse_button);a&&r.removeAllEvents(a,this.uid),u&&(r.removeAllEvents(u,this.uid),u.style.zIndex=s),o&&(r.removeAllEvents(o,this.uid),o.innerHTML=""),i.removeInstance(this.uid),e=o=a=u=i=null}})}return e.FileInput=s}),n("moxie/runtime/html5/file/FileDrop",["moxie/runtime/html5/Runtime","moxie/file/File","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/utils/Events","moxie/core/utils/Mime"],function(e,t,i,n,r,o){function a(){function e(e){if(!e.dataTransfer||!e.dataTransfer.types)return!1;var t=i.toArray(e.dataTransfer.types||[]);return-1!==i.inArray("Files",t)||-1!==i.inArray("public.file-url",t)||-1!==i.inArray("application/x-moz-file",t)}function a(e,i){if(u(e)){var n=new t(f,e);n.relativePath=i||"",p.push(n)}}function s(e){for(var t=[],n=0;n<e.length;n++)[].push.apply(t,e[n].extensions.split(/\s*,\s*/));return-1===i.inArray("*",t)?t:[]}function u(e){if(!g.length)return!0;var t=o.getFileExtension(e.name);return!t||-1!==i.inArray(t,g)}function c(e,t){var n=[];i.each(e,function(e){var t=e.webkitGetAsEntry();t&&(t.isFile?a(e.getAsFile(),t.fullPath):n.push(t))}),n.length?l(n,t):t()}function l(e,t){var n=[];i.each(e,function(e){n.push(function(t){d(e,t)})}),i.inSeries(n,function(){t()})}function d(e,t){e.isFile?e.file(function(i){a(i,e.fullPath),t()},function(){t()}):e.isDirectory?m(e,t):t()}function m(e,t){function i(e){r.readEntries(function(t){t.length?([].push.apply(n,t),i(e)):e()},e)}var n=[],r=e.createReader();i(function(){l(n,t)})}var h,f,p=[],g=[];i.extend(this,{init:function(t){var n,o=this;h=t,f=o.ruid,g=s(h.accept),n=h.container,r.addEvent(n,"dragover",function(t){e(t)&&(t.preventDefault(),t.dataTransfer.dropEffect="copy")},o.uid),r.addEvent(n,"drop",function(t){e(t)&&(t.preventDefault(),p=[],t.dataTransfer.items&&t.dataTransfer.items[0].webkitGetAsEntry?c(t.dataTransfer.items,function(){o.files=p,o.trigger("drop")}):(i.each(t.dataTransfer.files,function(e){a(e)}),o.files=p,o.trigger("drop")))},o.uid),r.addEvent(n,"dragenter",function(){o.trigger("dragenter")},o.uid),r.addEvent(n,"dragleave",function(){o.trigger("dragleave")},o.uid)},destroy:function(){r.removeAllEvents(h&&n.get(h.container),this.uid),f=p=g=h=null,this.getRuntime().getShim().removeInstance(this.uid)}})}return e.FileDrop=a}),n("moxie/runtime/html5/file/FileReader",["moxie/runtime/html5/Runtime","moxie/core/utils/Encode","moxie/core/utils/Basic"],function(e,t,i){function n(){function e(e){return t.atob(e.substring(e.indexOf("base64,")+7))}var n,r=!1;i.extend(this,{read:function(t,o){var a=this;a.result="",n=new window.FileReader,n.addEventListener("progress",function(e){a.trigger(e)}),n.addEventListener("load",function(t){a.result=r?e(n.result):n.result,a.trigger(t)}),n.addEventListener("error",function(e){a.trigger(e,n.error)}),n.addEventListener("loadend",function(e){n=null,a.trigger(e)}),"function"===i.typeOf(n[t])?(r=!1,n[t](o.getSource())):"readAsBinaryString"===t&&(r=!0,n.readAsDataURL(o.getSource()))},abort:function(){n&&n.abort()},destroy:function(){n=null,this.getRuntime().getShim().removeInstance(this.uid)}})}return e.FileReader=n}),n("moxie/runtime/html5/xhr/XMLHttpRequest",["moxie/runtime/html5/Runtime","moxie/core/utils/Basic","moxie/core/utils/Mime","moxie/core/utils/Url","moxie/file/File","moxie/file/Blob","moxie/xhr/FormData","moxie/core/Exceptions","moxie/core/utils/Env"],function(e,t,i,n,r,o,a,s,u){function c(){function e(e,t){var i,n,r=this;i=t.getBlob().getSource(),n=new window.FileReader,n.onload=function(){t.append(t.getBlobName(),new o(null,{type:i.type,data:n.result})),f.send.call(r,e,t)},n.readAsBinaryString(i)}function c(){return!window.XMLHttpRequest||"IE"===u.browser&&u.verComp(u.version,8,"<")?function(){for(var e=["Msxml2.XMLHTTP.6.0","Microsoft.XMLHTTP"],t=0;t<e.length;t++)try{return new ActiveXObject(e[t])}catch(i){}}():new window.XMLHttpRequest}function l(e){var t=e.responseXML,i=e.responseText;return"IE"===u.browser&&i&&t&&!t.documentElement&&/[^\/]+\/[^\+]+\+xml/.test(e.getResponseHeader("Content-Type"))&&(t=new window.ActiveXObject("Microsoft.XMLDOM"),t.async=!1,t.validateOnParse=!1,t.loadXML(i)),t&&("IE"===u.browser&&0!==t.parseError||!t.documentElement||"parsererror"===t.documentElement.tagName)?null:t
15
+ }function d(e){var t="----moxieboundary"+(new Date).getTime(),i="--",n="\r\n",r="",a=this.getRuntime();if(!a.can("send_binary_string"))throw new s.RuntimeError(s.RuntimeError.NOT_SUPPORTED_ERR);return m.setRequestHeader("Content-Type","multipart/form-data; boundary="+t),e.each(function(e,a){r+=e instanceof o?i+t+n+'Content-Disposition: form-data; name="'+a+'"; filename="'+unescape(encodeURIComponent(e.name||"blob"))+'"'+n+"Content-Type: "+(e.type||"application/octet-stream")+n+n+e.getSource()+n:i+t+n+'Content-Disposition: form-data; name="'+a+'"'+n+n+unescape(encodeURIComponent(e))+n}),r+=i+t+i+n}var m,h,f=this;t.extend(this,{send:function(i,r){var s=this,l="Mozilla"===u.browser&&u.verComp(u.version,4,">=")&&u.verComp(u.version,7,"<"),f="Android Browser"===u.browser,p=!1;if(h=i.url.replace(/^.+?\/([\w\-\.]+)$/,"$1").toLowerCase(),m=c(),m.open(i.method,i.url,i.async,i.user,i.password),r instanceof o)r.isDetached()&&(p=!0),r=r.getSource();else if(r instanceof a){if(r.hasBlob())if(r.getBlob().isDetached())r=d.call(s,r),p=!0;else if((l||f)&&"blob"===t.typeOf(r.getBlob().getSource())&&window.FileReader)return e.call(s,i,r),void 0;if(r instanceof a){var g=new window.FormData;r.each(function(e,t){e instanceof o?g.append(t,e.getSource()):g.append(t,e)}),r=g}}m.upload?(i.withCredentials&&(m.withCredentials=!0),m.addEventListener("load",function(e){s.trigger(e)}),m.addEventListener("error",function(e){s.trigger(e)}),m.addEventListener("progress",function(e){s.trigger(e)}),m.upload.addEventListener("progress",function(e){s.trigger({type:"UploadProgress",loaded:e.loaded,total:e.total})})):m.onreadystatechange=function(){switch(m.readyState){case 1:break;case 2:break;case 3:var e,t;try{n.hasSameOrigin(i.url)&&(e=m.getResponseHeader("Content-Length")||0),m.responseText&&(t=m.responseText.length)}catch(r){e=t=0}s.trigger({type:"progress",lengthComputable:!!e,total:parseInt(e,10),loaded:t});break;case 4:m.onreadystatechange=function(){};try{if(m.status>=200&&m.status<400){s.trigger("load");break}}catch(r){}s.trigger("error")}},t.isEmptyObj(i.headers)||t.each(i.headers,function(e,t){m.setRequestHeader(t,e)}),""!==i.responseType&&"responseType"in m&&(m.responseType="json"!==i.responseType||u.can("return_response_type","json")?i.responseType:"text"),p?m.sendAsBinary?m.sendAsBinary(r):function(){for(var e=new Uint8Array(r.length),t=0;t<r.length;t++)e[t]=255&r.charCodeAt(t);m.send(e.buffer)}():m.send(r),s.trigger("loadstart")},getStatus:function(){try{if(m)return m.status}catch(e){}return 0},getResponse:function(e){var t=this.getRuntime();try{switch(e){case"blob":var n=new r(t.uid,m.response),o=m.getResponseHeader("Content-Disposition");if(o){var a=o.match(/filename=([\'\"'])([^\1]+)\1/);a&&(h=a[2])}return n.name=h,n.type||(n.type=i.getFileMime(h)),n;case"json":return u.can("return_response_type","json")?m.response:200===m.status&&window.JSON?JSON.parse(m.responseText):null;case"document":return l(m);default:return""!==m.responseText?m.responseText:null}}catch(s){return null}},getAllResponseHeaders:function(){try{return m.getAllResponseHeaders()}catch(e){}return""},abort:function(){m&&m.abort()},destroy:function(){f=h=null,this.getRuntime().getShim().removeInstance(this.uid)}})}return e.XMLHttpRequest=c}),n("moxie/runtime/html5/utils/BinaryReader",["moxie/core/utils/Basic"],function(e){function t(e){e instanceof ArrayBuffer?i.apply(this,arguments):n.apply(this,arguments)}function i(t){var i=new DataView(t);e.extend(this,{readByteAt:function(e){return i.getUint8(e)},writeByteAt:function(e,t){i.setUint8(e,t)},SEGMENT:function(e,n,r){switch(arguments.length){case 2:return t.slice(e,e+n);case 1:return t.slice(e);case 3:if(null===r&&(r=new ArrayBuffer),r instanceof ArrayBuffer){var o=new Uint8Array(this.length()-n+r.byteLength);e>0&&o.set(new Uint8Array(t.slice(0,e)),0),o.set(new Uint8Array(r),e),o.set(new Uint8Array(t.slice(e+n)),e+r.byteLength),this.clear(),t=o.buffer,i=new DataView(t);break}default:return t}},length:function(){return t?t.byteLength:0},clear:function(){i=t=null}})}function n(t){function i(e,i,n){n=3===arguments.length?n:t.length-i-1,t=t.substr(0,i)+e+t.substr(n+i)}e.extend(this,{readByteAt:function(e){return t.charCodeAt(e)},writeByteAt:function(e,t){i(String.fromCharCode(t),e,1)},SEGMENT:function(e,n,r){switch(arguments.length){case 1:return t.substr(e);case 2:return t.substr(e,n);case 3:i(null!==r?r:"",e,n);break;default:return t}},length:function(){return t?t.length:0},clear:function(){t=null}})}return e.extend(t.prototype,{littleEndian:!1,read:function(e,t){var i,n,r;if(e+t>this.length())throw new Error("You are trying to read outside the source boundaries.");for(n=this.littleEndian?0:-8*(t-1),r=0,i=0;t>r;r++)i|=this.readByteAt(e+r)<<Math.abs(n+8*r);return i},write:function(e,t,i){var n,r;if(e>this.length())throw new Error("You are trying to write outside the source boundaries.");for(n=this.littleEndian?0:-8*(i-1),r=0;i>r;r++)this.writeByteAt(e+r,255&t>>Math.abs(n+8*r))},BYTE:function(e){return this.read(e,1)},SHORT:function(e){return this.read(e,2)},LONG:function(e){return this.read(e,4)},SLONG:function(e){var t=this.read(e,4);return t>2147483647?t-4294967296:t},CHAR:function(e){return String.fromCharCode(this.read(e,1))},STRING:function(e,t){return this.asArray("CHAR",e,t).join("")},asArray:function(e,t,i){for(var n=[],r=0;i>r;r++)n[r]=this[e](t+r);return n}}),t}),n("moxie/runtime/html5/image/JPEGHeaders",["moxie/runtime/html5/utils/BinaryReader","moxie/core/Exceptions"],function(e,t){return function i(n){var r,o,a,s=[],u=0;if(r=new e(n),65496!==r.SHORT(0))throw r.clear(),new t.ImageError(t.ImageError.WRONG_FORMAT);for(o=2;o<=r.length();)if(a=r.SHORT(o),a>=65488&&65495>=a)o+=2;else{if(65498===a||65497===a)break;u=r.SHORT(o+2)+2,a>=65505&&65519>=a&&s.push({hex:a,name:"APP"+(15&a),start:o,length:u,segment:r.SEGMENT(o,u)}),o+=u}return r.clear(),{headers:s,restore:function(t){var i,n,r;for(r=new e(t),o=65504==r.SHORT(2)?4+r.SHORT(4):2,n=0,i=s.length;i>n;n++)r.SEGMENT(o,0,s[n].segment),o+=s[n].length;return t=r.SEGMENT(),r.clear(),t},strip:function(t){var n,r,o,a;for(o=new i(t),r=o.headers,o.purge(),n=new e(t),a=r.length;a--;)n.SEGMENT(r[a].start,r[a].length,"");return t=n.SEGMENT(),n.clear(),t},get:function(e){for(var t=[],i=0,n=s.length;n>i;i++)s[i].name===e.toUpperCase()&&t.push(s[i].segment);return t},set:function(e,t){var i,n,r,o=[];for("string"==typeof t?o.push(t):o=t,i=n=0,r=s.length;r>i&&(s[i].name===e.toUpperCase()&&(s[i].segment=o[n],s[i].length=o[n].length,n++),!(n>=o.length));i++);},purge:function(){this.headers=s=[]}}}}),n("moxie/runtime/html5/image/ExifParser",["moxie/core/utils/Basic","moxie/runtime/html5/utils/BinaryReader","moxie/core/Exceptions"],function(e,i,n){function r(o){function a(i,r){var o,a,s,u,c,m,h,f,p=this,g=[],x={},v={1:"BYTE",7:"UNDEFINED",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",9:"SLONG",10:"SRATIONAL"},w={BYTE:1,UNDEFINED:1,ASCII:1,SHORT:2,LONG:4,RATIONAL:8,SLONG:4,SRATIONAL:8};for(o=p.SHORT(i),a=0;o>a;a++)if(g=[],h=i+2+12*a,s=r[p.SHORT(h)],s!==t){if(u=v[p.SHORT(h+=2)],c=p.LONG(h+=2),m=w[u],!m)throw new n.ImageError(n.ImageError.INVALID_META_ERR);if(h+=4,m*c>4&&(h=p.LONG(h)+d.tiffHeader),h+m*c>=this.length())throw new n.ImageError(n.ImageError.INVALID_META_ERR);"ASCII"!==u?(g=p.asArray(u,h,c),f=1==c?g[0]:g,x[s]=l.hasOwnProperty(s)&&"object"!=typeof f?l[s][f]:f):x[s]=e.trim(p.STRING(h,c).replace(/\0$/,""))}return x}function s(e,t,i){var n,r,o,a=0;if("string"==typeof t){var s=c[e.toLowerCase()];for(var u in s)if(s[u]===t){t=u;break}}n=d[e.toLowerCase()+"IFD"],r=this.SHORT(n);for(var l=0;r>l;l++)if(o=n+12*l+2,this.SHORT(o)==t){a=o+8;break}if(!a)return!1;try{this.write(a,i,4)}catch(m){return!1}return!0}var u,c,l,d,m,h;if(i.call(this,o),c={tiff:{274:"Orientation",270:"ImageDescription",271:"Make",272:"Model",305:"Software",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer"},exif:{36864:"ExifVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",36867:"DateTimeOriginal",33434:"ExposureTime",33437:"FNumber",34855:"ISOSpeedRatings",37377:"ShutterSpeedValue",37378:"ApertureValue",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37386:"FocalLength",41986:"ExposureMode",41987:"WhiteBalance",41990:"SceneCaptureType",41988:"DigitalZoomRatio",41992:"Contrast",41993:"Saturation",41994:"Sharpness"},gps:{0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude"},thumb:{513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength"}},l={ColorSpace:{1:"sRGB",0:"Uncalibrated"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{1:"Daylight",2:"Fliorescent",3:"Tungsten",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 -5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},ExposureMode:{0:"Auto exposure",1:"Manual exposure",2:"Auto bracket"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},GPSLatitudeRef:{N:"North latitude",S:"South latitude"},GPSLongitudeRef:{E:"East longitude",W:"West longitude"}},d={tiffHeader:10},m=d.tiffHeader,u={clear:this.clear},e.extend(this,{read:function(){try{return r.prototype.read.apply(this,arguments)}catch(e){throw new n.ImageError(n.ImageError.INVALID_META_ERR)}},write:function(){try{return r.prototype.write.apply(this,arguments)}catch(e){throw new n.ImageError(n.ImageError.INVALID_META_ERR)}},UNDEFINED:function(){return this.BYTE.apply(this,arguments)},RATIONAL:function(e){return this.LONG(e)/this.LONG(e+4)},SRATIONAL:function(e){return this.SLONG(e)/this.SLONG(e+4)},ASCII:function(e){return this.CHAR(e)},TIFF:function(){return h||null},EXIF:function(){var t=null;if(d.exifIFD){try{t=a.call(this,d.exifIFD,c.exif)}catch(i){return null}if(t.ExifVersion&&"array"===e.typeOf(t.ExifVersion)){for(var n=0,r="";n<t.ExifVersion.length;n++)r+=String.fromCharCode(t.ExifVersion[n]);t.ExifVersion=r}}return t},GPS:function(){var t=null;if(d.gpsIFD){try{t=a.call(this,d.gpsIFD,c.gps)}catch(i){return null}t.GPSVersionID&&"array"===e.typeOf(t.GPSVersionID)&&(t.GPSVersionID=t.GPSVersionID.join("."))}return t},thumb:function(){if(d.IFD1)try{var e=a.call(this,d.IFD1,c.thumb);if("JPEGInterchangeFormat"in e)return this.SEGMENT(d.tiffHeader+e.JPEGInterchangeFormat,e.JPEGInterchangeFormatLength)}catch(t){}return null},setExif:function(e,t){return"PixelXDimension"!==e&&"PixelYDimension"!==e?!1:s.call(this,"exif",e,t)},clear:function(){u.clear(),o=c=l=h=d=u=null}}),65505!==this.SHORT(0)||"EXIF\0"!==this.STRING(4,5).toUpperCase())throw new n.ImageError(n.ImageError.INVALID_META_ERR);if(this.littleEndian=18761==this.SHORT(m),42!==this.SHORT(m+=2))throw new n.ImageError(n.ImageError.INVALID_META_ERR);d.IFD0=d.tiffHeader+this.LONG(m+=2),h=a.call(this,d.IFD0,c.tiff),"ExifIFDPointer"in h&&(d.exifIFD=d.tiffHeader+h.ExifIFDPointer,delete h.ExifIFDPointer),"GPSInfoIFDPointer"in h&&(d.gpsIFD=d.tiffHeader+h.GPSInfoIFDPointer,delete h.GPSInfoIFDPointer),e.isEmptyObj(h)&&(h=null);var f=this.LONG(d.IFD0+12*this.SHORT(d.IFD0)+2);f&&(d.IFD1=d.tiffHeader+f)}return r.prototype=i.prototype,r}),n("moxie/runtime/html5/image/JPEG",["moxie/core/utils/Basic","moxie/core/Exceptions","moxie/runtime/html5/image/JPEGHeaders","moxie/runtime/html5/utils/BinaryReader","moxie/runtime/html5/image/ExifParser"],function(e,t,i,n,r){function o(o){function a(e){var t,i,n=0;for(e||(e=c);n<=e.length();){if(t=e.SHORT(n+=2),t>=65472&&65475>=t)return n+=5,{height:e.SHORT(n),width:e.SHORT(n+=2)};i=e.SHORT(n+=2),n+=i-2}return null}function s(){var e,t,i=d.thumb();return i&&(e=new n(i),t=a(e),e.clear(),t)?(t.data=i,t):null}function u(){d&&l&&c&&(d.clear(),l.purge(),c.clear(),m=l=d=c=null)}var c,l,d,m;if(c=new n(o),65496!==c.SHORT(0))throw new t.ImageError(t.ImageError.WRONG_FORMAT);l=new i(o);try{d=new r(l.get("app1")[0])}catch(h){}m=a.call(this),e.extend(this,{type:"image/jpeg",size:c.length(),width:m&&m.width||0,height:m&&m.height||0,setExif:function(t,i){return d?("object"===e.typeOf(t)?e.each(t,function(e,t){d.setExif(t,e)}):d.setExif(t,i),l.set("app1",d.SEGMENT()),void 0):!1},writeHeaders:function(){return arguments.length?l.restore(arguments[0]):l.restore(o)},stripHeaders:function(e){return l.strip(e)},purge:function(){u.call(this)}}),d&&(this.meta={tiff:d.TIFF(),exif:d.EXIF(),gps:d.GPS(),thumb:s()})}return o}),n("moxie/runtime/html5/image/PNG",["moxie/core/Exceptions","moxie/core/utils/Basic","moxie/runtime/html5/utils/BinaryReader"],function(e,t,i){function n(n){function r(){var e,t;return e=a.call(this,8),"IHDR"==e.type?(t=e.start,{width:s.LONG(t),height:s.LONG(t+=4)}):null}function o(){s&&(s.clear(),n=l=u=c=s=null)}function a(e){var t,i,n,r;return t=s.LONG(e),i=s.STRING(e+=4,4),n=e+=4,r=s.LONG(e+t),{length:t,type:i,start:n,CRC:r}}var s,u,c,l;s=new i(n),function(){var t=0,i=0,n=[35152,20039,3338,6666];for(i=0;i<n.length;i++,t+=2)if(n[i]!=s.SHORT(t))throw new e.ImageError(e.ImageError.WRONG_FORMAT)}(),l=r.call(this),t.extend(this,{type:"image/png",size:s.length(),width:l.width,height:l.height,purge:function(){o.call(this)}}),o.call(this)}return n}),n("moxie/runtime/html5/image/ImageInfo",["moxie/core/utils/Basic","moxie/core/Exceptions","moxie/runtime/html5/image/JPEG","moxie/runtime/html5/image/PNG"],function(e,t,i,n){return function(r){var o,a=[i,n];o=function(){for(var e=0;e<a.length;e++)try{return new a[e](r)}catch(i){}throw new t.ImageError(t.ImageError.WRONG_FORMAT)}(),e.extend(this,{type:"",size:0,width:0,height:0,setExif:function(){},writeHeaders:function(e){return e},stripHeaders:function(e){return e},purge:function(){r=null}}),e.extend(this,o),this.purge=function(){o.purge(),o=null}}}),n("moxie/runtime/html5/image/ResizerCanvas",[],function(){function e(i,n,r){var o=i.width>i.height?"width":"height",a=Math.round(i[o]*n),s=!1;"nearest"!==r&&(.5>n||n>2)&&(n=.5>n?.5:2,s=!0);var u=t(i,n);return s?e(u,a/u[o],r):u}function t(e,t){var i=e.width,n=e.height,r=Math.round(i*t),o=Math.round(n*t),a=document.createElement("canvas");return a.width=r,a.height=o,a.getContext("2d").drawImage(e,0,0,i,n,0,0,r,o),e=null,a}return{scale:e}}),n("moxie/runtime/html5/image/Image",["moxie/runtime/html5/Runtime","moxie/core/utils/Basic","moxie/core/Exceptions","moxie/core/utils/Encode","moxie/file/Blob","moxie/file/File","moxie/runtime/html5/image/ImageInfo","moxie/runtime/html5/image/ResizerCanvas","moxie/core/utils/Mime","moxie/core/utils/Env"],function(e,t,i,n,r,o,a,s,u){function c(){function e(){if(!v&&!g)throw new i.ImageError(i.DOMException.INVALID_STATE_ERR);return v||g}function c(){var t=e();return"canvas"==t.nodeName.toLowerCase()?t:(v=document.createElement("canvas"),v.width=t.width,v.height=t.height,v.getContext("2d").drawImage(t,0,0),v)}function l(e){return n.atob(e.substring(e.indexOf("base64,")+7))}function d(e,t){return"data:"+(t||"")+";base64,"+n.btoa(e)}function m(e){var t=this;g=new Image,g.onerror=function(){p.call(this),t.trigger("error",i.ImageError.WRONG_FORMAT)},g.onload=function(){t.trigger("load")},g.src="data:"==e.substr(0,5)?e:d(e,y.type)}function h(e,t){var n,r=this;return window.FileReader?(n=new FileReader,n.onload=function(){t.call(r,this.result)},n.onerror=function(){r.trigger("error",i.ImageError.WRONG_FORMAT)},n.readAsDataURL(e),void 0):t.call(this,e.getAsDataURL())}function f(e,i){var n=Math.PI/180,r=document.createElement("canvas"),o=r.getContext("2d"),a=e.width,s=e.height;switch(t.inArray(i,[5,6,7,8])>-1?(r.width=s,r.height=a):(r.width=a,r.height=s),i){case 2:o.translate(a,0),o.scale(-1,1);break;case 3:o.translate(a,s),o.rotate(180*n);break;case 4:o.translate(0,s),o.scale(1,-1);break;case 5:o.rotate(90*n),o.scale(1,-1);break;case 6:o.rotate(90*n),o.translate(0,-s);break;case 7:o.rotate(90*n),o.translate(a,-s),o.scale(-1,1);break;case 8:o.rotate(-90*n),o.translate(-a,0)}return o.drawImage(e,0,0,a,s),r}function p(){x&&(x.purge(),x=null),w=g=v=y=null,b=!1}var g,x,v,w,y,E=this,b=!1,_=!0;t.extend(this,{loadFromBlob:function(e){var t=this.getRuntime(),n=arguments.length>1?arguments[1]:!0;if(!t.can("access_binary"))throw new i.RuntimeError(i.RuntimeError.NOT_SUPPORTED_ERR);return y=e,e.isDetached()?(w=e.getSource(),m.call(this,w),void 0):(h.call(this,e.getSource(),function(e){n&&(w=l(e)),m.call(this,e)}),void 0)},loadFromImage:function(e,t){this.meta=e.meta,y=new o(null,{name:e.name,size:e.size,type:e.type}),m.call(this,t?w=e.getAsBinaryString():e.getAsDataURL())},getInfo:function(){var t,i=this.getRuntime();return!x&&w&&i.can("access_image_binary")&&(x=new a(w)),t={width:e().width||0,height:e().height||0,type:y.type||u.getFileMime(y.name),size:w&&w.length||y.size||0,name:y.name||"",meta:null},_&&(t.meta=x&&x.meta||this.meta||{},!t.meta||!t.meta.thumb||t.meta.thumb.data instanceof r||(t.meta.thumb.data=new r(null,{type:"image/jpeg",data:t.meta.thumb.data}))),t},resize:function(t,i,n){var r=document.createElement("canvas");if(r.width=t.width,r.height=t.height,r.getContext("2d").drawImage(e(),t.x,t.y,t.width,t.height,0,0,r.width,r.height),v=s.scale(r,i),_=n.preserveHeaders,!_){var o=this.meta&&this.meta.tiff&&this.meta.tiff.Orientation||1;v=f(v,o)}this.width=v.width,this.height=v.height,b=!0,this.trigger("Resize")},getAsCanvas:function(){return v||(v=c()),v.id=this.uid+"_canvas",v},getAsBlob:function(e,t){return e!==this.type?(b=!0,new o(null,{name:y.name||"",type:e,data:E.getAsDataURL(e,t)})):new o(null,{name:y.name||"",type:e,data:E.getAsBinaryString(e,t)})},getAsDataURL:function(e){var t=arguments[1]||90;if(!b)return g.src;if(c(),"image/jpeg"!==e)return v.toDataURL("image/png");try{return v.toDataURL("image/jpeg",t/100)}catch(i){return v.toDataURL("image/jpeg")}},getAsBinaryString:function(e,t){if(!b)return w||(w=l(E.getAsDataURL(e,t))),w;if("image/jpeg"!==e)w=l(E.getAsDataURL(e,t));else{var i;t||(t=90),c();try{i=v.toDataURL("image/jpeg",t/100)}catch(n){i=v.toDataURL("image/jpeg")}w=l(i),x&&(w=x.stripHeaders(w),_&&(x.meta&&x.meta.exif&&x.setExif({PixelXDimension:this.width,PixelYDimension:this.height}),w=x.writeHeaders(w)),x.purge(),x=null)}return b=!1,w},destroy:function(){E=null,p.call(this),this.getRuntime().getShim().removeInstance(this.uid)}})}return e.Image=c}),n("moxie/runtime/flash/Runtime",["moxie/core/utils/Basic","moxie/core/utils/Env","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/runtime/Runtime"],function(e,t,i,n,o){function a(){var e;try{e=navigator.plugins["Shockwave Flash"],e=e.description}catch(t){try{e=new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version")}catch(i){e="0.0"}}return e=e.match(/\d+/g),parseFloat(e[0]+"."+e[1])}function s(e){var n=i.get(e);n&&"OBJECT"==n.nodeName&&("IE"===t.browser?(n.style.display="none",function r(){4==n.readyState?u(e):setTimeout(r,10)}()):n.parentNode.removeChild(n))}function u(e){var t=i.get(e);if(t){for(var n in t)"function"==typeof t[n]&&(t[n]=null);t.parentNode.removeChild(t)}}function c(u){var c,m=this;u=e.extend({swf_url:t.swf_url},u),o.call(this,u,l,{access_binary:function(e){return e&&"browser"===m.mode},access_image_binary:function(e){return e&&"browser"===m.mode},display_media:o.capTest(r("moxie/image/Image")),do_cors:o.capTrue,drag_and_drop:!1,report_upload_progress:function(){return"client"===m.mode},resize_image:o.capTrue,return_response_headers:!1,return_response_type:function(t){return"json"===t&&window.JSON?!0:!e.arrayDiff(t,["","text","document"])||"browser"===m.mode},return_status_code:function(t){return"browser"===m.mode||!e.arrayDiff(t,[200,404])},select_file:o.capTrue,select_multiple:o.capTrue,send_binary_string:function(e){return e&&"browser"===m.mode},send_browser_cookies:function(e){return e&&"browser"===m.mode},send_custom_headers:function(e){return e&&"browser"===m.mode},send_multipart:o.capTrue,slice_blob:function(e){return e&&"browser"===m.mode},stream_upload:function(e){return e&&"browser"===m.mode},summon_file_dialog:!1,upload_filesize:function(t){return e.parseSizeStr(t)<=2097152||"client"===m.mode},use_http_method:function(t){return!e.arrayDiff(t,["GET","POST"])}},{access_binary:function(e){return e?"browser":"client"},access_image_binary:function(e){return e?"browser":"client"},report_upload_progress:function(e){return e?"browser":"client"},return_response_type:function(t){return e.arrayDiff(t,["","text","json","document"])?"browser":["client","browser"]},return_status_code:function(t){return e.arrayDiff(t,[200,404])?"browser":["client","browser"]},send_binary_string:function(e){return e?"browser":"client"},send_browser_cookies:function(e){return e?"browser":"client"},send_custom_headers:function(e){return e?"browser":"client"},slice_blob:function(e){return e?"browser":"client"},stream_upload:function(e){return e?"client":"browser"},upload_filesize:function(t){return e.parseSizeStr(t)>=2097152?"client":"browser"}},"client"),a()<11.3&&(this.mode=!1),e.extend(this,{getShim:function(){return i.get(this.uid)},shimExec:function(e,t){var i=[].slice.call(arguments,2);return m.getShim().exec(this.uid,e,t,i)},init:function(){var i,r,a;a=this.getShimContainer(),e.extend(a.style,{position:"absolute",top:"-8px",left:"-8px",width:"9px",height:"9px",overflow:"hidden"}),i='<object id="'+this.uid+'" type="application/x-shockwave-flash" data="'+u.swf_url+'" ',"IE"===t.browser&&(i+='classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '),i+='width="100%" height="100%" style="outline:0"><param name="movie" value="'+u.swf_url+'" />'+'<param name="flashvars" value="uid='+escape(this.uid)+"&target="+o.getGlobalEventTarget()+'" />'+'<param name="wmode" value="transparent" />'+'<param name="allowscriptaccess" value="always" />'+"</object>","IE"===t.browser?(r=document.createElement("div"),a.appendChild(r),r.outerHTML=i,r=a=null):a.innerHTML=i,c=setTimeout(function(){m&&!m.initialized&&m.trigger("Error",new n.RuntimeError(n.RuntimeError.NOT_INIT_ERR))},5e3)},destroy:function(e){return function(){s(m.uid),e.call(m),clearTimeout(c),u=c=e=m=null}}(this.destroy)},d)}var l="flash",d={};return o.addConstructor(l,c),d}),n("moxie/runtime/flash/file/Blob",["moxie/runtime/flash/Runtime","moxie/file/Blob"],function(e,t){var i={slice:function(e,i,n,r){var o=this.getRuntime();return 0>i?i=Math.max(e.size+i,0):i>0&&(i=Math.min(i,e.size)),0>n?n=Math.max(e.size+n,0):n>0&&(n=Math.min(n,e.size)),e=o.shimExec.call(this,"Blob","slice",i,n,r||""),e&&(e=new t(o.uid,e)),e}};return e.Blob=i}),n("moxie/runtime/flash/file/FileInput",["moxie/runtime/flash/Runtime","moxie/file/File","moxie/core/utils/Dom","moxie/core/utils/Basic"],function(e,t,i,n){var r={init:function(e){var r=this,o=this.getRuntime(),a=i.get(e.browse_button);a&&(a.setAttribute("tabindex",-1),a=null),this.bind("Change",function(){var e=o.shimExec.call(r,"FileInput","getFiles");r.files=[],n.each(e,function(e){r.files.push(new t(o.uid,e))})},999),this.getRuntime().shimExec.call(this,"FileInput","init",{accept:e.accept,multiple:e.multiple}),this.trigger("ready")}};return e.FileInput=r}),n("moxie/runtime/flash/file/FileReader",["moxie/runtime/flash/Runtime","moxie/core/utils/Encode"],function(e,t){function i(e,i){switch(i){case"readAsText":return t.atob(e,"utf8");case"readAsBinaryString":return t.atob(e);case"readAsDataURL":return e}return null}var n={read:function(e,t){var n=this;return n.result="","readAsDataURL"===e&&(n.result="data:"+(t.type||"")+";base64,"),n.bind("Progress",function(t,r){r&&(n.result+=i(r,e))},999),n.getRuntime().shimExec.call(this,"FileReader","readAsBase64",t.uid)}};return e.FileReader=n}),n("moxie/runtime/flash/file/FileReaderSync",["moxie/runtime/flash/Runtime","moxie/core/utils/Encode"],function(e,t){function i(e,i){switch(i){case"readAsText":return t.atob(e,"utf8");case"readAsBinaryString":return t.atob(e);case"readAsDataURL":return e}return null}var n={read:function(e,t){var n,r=this.getRuntime();return(n=r.shimExec.call(this,"FileReaderSync","readAsBase64",t.uid))?("readAsDataURL"===e&&(n="data:"+(t.type||"")+";base64,"+n),i(n,e,t.type)):null}};return e.FileReaderSync=n}),n("moxie/runtime/flash/runtime/Transporter",["moxie/runtime/flash/Runtime","moxie/file/Blob"],function(e,t){var i={getAsBlob:function(e){var i=this.getRuntime(),n=i.shimExec.call(this,"Transporter","getAsBlob",e);return n?new t(i.uid,n):null}};return e.Transporter=i}),n("moxie/runtime/flash/xhr/XMLHttpRequest",["moxie/runtime/flash/Runtime","moxie/core/utils/Basic","moxie/file/Blob","moxie/file/File","moxie/file/FileReaderSync","moxie/runtime/flash/file/FileReaderSync","moxie/xhr/FormData","moxie/runtime/Transporter","moxie/runtime/flash/runtime/Transporter"],function(e,t,i,n,r,o,a,s){var u={send:function(e,n){function r(){e.transport=l.mode,l.shimExec.call(c,"XMLHttpRequest","send",e,n)}function o(e,t){l.shimExec.call(c,"XMLHttpRequest","appendBlob",e,t.uid),n=null,r()}function u(e,t){var i=new s;i.bind("TransportingComplete",function(){t(this.result)}),i.transport(e.getSource(),e.type,{ruid:l.uid})}var c=this,l=c.getRuntime();if(t.isEmptyObj(e.headers)||t.each(e.headers,function(e,t){l.shimExec.call(c,"XMLHttpRequest","setRequestHeader",t,e.toString())}),n instanceof a){var d;if(n.each(function(e,t){e instanceof i?d=t:l.shimExec.call(c,"XMLHttpRequest","append",t,e)}),n.hasBlob()){var m=n.getBlob();m.isDetached()?u(m,function(e){m.destroy(),o(d,e)}):o(d,m)}else n=null,r()}else n instanceof i?n.isDetached()?u(n,function(e){n.destroy(),n=e.uid,r()}):(n=n.uid,r()):r()},getResponse:function(e){var i,o,a=this.getRuntime();if(o=a.shimExec.call(this,"XMLHttpRequest","getResponseAsBlob")){if(o=new n(a.uid,o),"blob"===e)return o;try{if(i=new r,~t.inArray(e,["","text"]))return i.readAsText(o);if("json"===e&&window.JSON)return JSON.parse(i.readAsText(o))}finally{o.destroy()}}return null},abort:function(){var e=this.getRuntime();e.shimExec.call(this,"XMLHttpRequest","abort"),this.dispatchEvent("readystatechange"),this.dispatchEvent("abort")}};return e.XMLHttpRequest=u}),n("moxie/runtime/flash/image/Image",["moxie/runtime/flash/Runtime","moxie/core/utils/Basic","moxie/runtime/Transporter","moxie/file/Blob","moxie/file/FileReaderSync"],function(e,t,i,n,r){var o={loadFromBlob:function(e){function t(e){r.shimExec.call(n,"Image","loadFromBlob",e.uid),n=r=null}var n=this,r=n.getRuntime();if(e.isDetached()){var o=new i;o.bind("TransportingComplete",function(){t(o.result.getSource())}),o.transport(e.getSource(),e.type,{ruid:r.uid})}else t(e.getSource())},loadFromImage:function(e){var t=this.getRuntime();return t.shimExec.call(this,"Image","loadFromImage",e.uid)},getInfo:function(){var e=this.getRuntime(),t=e.shimExec.call(this,"Image","getInfo");return t.meta&&t.meta.thumb&&t.meta.thumb.data&&!(e.meta.thumb.data instanceof n)&&(t.meta.thumb.data=new n(e.uid,t.meta.thumb.data)),t},getAsBlob:function(e,t){var i=this.getRuntime(),r=i.shimExec.call(this,"Image","getAsBlob",e,t);return r?new n(i.uid,r):null},getAsDataURL:function(){var e,t=this.getRuntime(),i=t.Image.getAsBlob.apply(this,arguments);return i?(e=new r,e.readAsDataURL(i)):null}};return e.Image=o}),n("moxie/runtime/silverlight/Runtime",["moxie/core/utils/Basic","moxie/core/utils/Env","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/runtime/Runtime"],function(e,t,i,n,o){function a(e){var t,i,n,r,o,a=!1,s=null,u=0;try{try{s=new ActiveXObject("AgControl.AgControl"),s.IsVersionSupported(e)&&(a=!0),s=null}catch(c){var l=navigator.plugins["Silverlight Plug-In"];if(l){for(t=l.description,"1.0.30226.2"===t&&(t="2.0.30226.2"),i=t.split(".");i.length>3;)i.pop();for(;i.length<4;)i.push(0);for(n=e.split(".");n.length>4;)n.pop();do r=parseInt(n[u],10),o=parseInt(i[u],10),u++;while(u<n.length&&r===o);o>=r&&!isNaN(r)&&(a=!0)}}}catch(d){a=!1}return a}function s(s){var l,d=this;s=e.extend({xap_url:t.xap_url},s),o.call(this,s,u,{access_binary:o.capTrue,access_image_binary:o.capTrue,display_media:o.capTest(r("moxie/image/Image")),do_cors:o.capTrue,drag_and_drop:!1,report_upload_progress:o.capTrue,resize_image:o.capTrue,return_response_headers:function(e){return e&&"client"===d.mode},return_response_type:function(e){return"json"!==e?!0:!!window.JSON},return_status_code:function(t){return"client"===d.mode||!e.arrayDiff(t,[200,404])},select_file:o.capTrue,select_multiple:o.capTrue,send_binary_string:o.capTrue,send_browser_cookies:function(e){return e&&"browser"===d.mode},send_custom_headers:function(e){return e&&"client"===d.mode},send_multipart:o.capTrue,slice_blob:o.capTrue,stream_upload:!0,summon_file_dialog:!1,upload_filesize:o.capTrue,use_http_method:function(t){return"client"===d.mode||!e.arrayDiff(t,["GET","POST"])}},{return_response_headers:function(e){return e?"client":"browser"},return_status_code:function(t){return e.arrayDiff(t,[200,404])?"client":["client","browser"]},send_browser_cookies:function(e){return e?"browser":"client"},send_custom_headers:function(e){return e?"client":"browser"},use_http_method:function(t){return e.arrayDiff(t,["GET","POST"])?"client":["client","browser"]}}),a("2.0.31005.0")&&"Opera"!==t.browser||(this.mode=!1),e.extend(this,{getShim:function(){return i.get(this.uid).content.Moxie},shimExec:function(e,t){var i=[].slice.call(arguments,2);return d.getShim().exec(this.uid,e,t,i)},init:function(){var e;e=this.getShimContainer(),e.innerHTML='<object id="'+this.uid+'" data="data:application/x-silverlight," type="application/x-silverlight-2" width="100%" height="100%" style="outline:none;">'+'<param name="source" value="'+s.xap_url+'"/>'+'<param name="background" value="Transparent"/>'+'<param name="windowless" value="true"/>'+'<param name="enablehtmlaccess" value="true"/>'+'<param name="initParams" value="uid='+this.uid+",target="+o.getGlobalEventTarget()+'"/>'+"</object>",l=setTimeout(function(){d&&!d.initialized&&d.trigger("Error",new n.RuntimeError(n.RuntimeError.NOT_INIT_ERR))},"Windows"!==t.OS?1e4:5e3)},destroy:function(e){return function(){e.call(d),clearTimeout(l),s=l=e=d=null}}(this.destroy)},c)}var u="silverlight",c={};return o.addConstructor(u,s),c}),n("moxie/runtime/silverlight/file/Blob",["moxie/runtime/silverlight/Runtime","moxie/core/utils/Basic","moxie/runtime/flash/file/Blob"],function(e,t,i){return e.Blob=t.extend({},i)}),n("moxie/runtime/silverlight/file/FileInput",["moxie/runtime/silverlight/Runtime","moxie/file/File","moxie/core/utils/Dom","moxie/core/utils/Basic"],function(e,t,i,n){function r(e){for(var t="",i=0;i<e.length;i++)t+=(""!==t?"|":"")+e[i].title+" | *."+e[i].extensions.replace(/,/g,";*.");return t}var o={init:function(e){var o=this,a=this.getRuntime(),s=i.get(e.browse_button);s&&(s.setAttribute("tabindex",-1),s=null),this.bind("Change",function(){var e=a.shimExec.call(o,"FileInput","getFiles");
16
+ o.files=[],n.each(e,function(e){o.files.push(new t(a.uid,e))})},999),a.shimExec.call(this,"FileInput","init",r(e.accept),e.multiple),this.trigger("ready")},setOption:function(e,t){"accept"==e&&(t=r(t)),this.getRuntime().shimExec.call(this,"FileInput","setOption",e,t)}};return e.FileInput=o}),n("moxie/runtime/silverlight/file/FileDrop",["moxie/runtime/silverlight/Runtime","moxie/core/utils/Dom","moxie/core/utils/Events"],function(e,t,i){var n={init:function(){var e,n=this,r=n.getRuntime();return e=r.getShimContainer(),i.addEvent(e,"dragover",function(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="copy"},n.uid),i.addEvent(e,"dragenter",function(e){e.preventDefault();var i=t.get(r.uid).dragEnter(e);i&&e.stopPropagation()},n.uid),i.addEvent(e,"drop",function(e){e.preventDefault();var i=t.get(r.uid).dragDrop(e);i&&e.stopPropagation()},n.uid),r.shimExec.call(this,"FileDrop","init")}};return e.FileDrop=n}),n("moxie/runtime/silverlight/file/FileReader",["moxie/runtime/silverlight/Runtime","moxie/core/utils/Basic","moxie/runtime/flash/file/FileReader"],function(e,t,i){return e.FileReader=t.extend({},i)}),n("moxie/runtime/silverlight/file/FileReaderSync",["moxie/runtime/silverlight/Runtime","moxie/core/utils/Basic","moxie/runtime/flash/file/FileReaderSync"],function(e,t,i){return e.FileReaderSync=t.extend({},i)}),n("moxie/runtime/silverlight/runtime/Transporter",["moxie/runtime/silverlight/Runtime","moxie/core/utils/Basic","moxie/runtime/flash/runtime/Transporter"],function(e,t,i){return e.Transporter=t.extend({},i)}),n("moxie/runtime/silverlight/xhr/XMLHttpRequest",["moxie/runtime/silverlight/Runtime","moxie/core/utils/Basic","moxie/runtime/flash/xhr/XMLHttpRequest","moxie/runtime/silverlight/file/FileReaderSync","moxie/runtime/silverlight/runtime/Transporter"],function(e,t,i){return e.XMLHttpRequest=t.extend({},i)}),n("moxie/runtime/silverlight/image/Image",["moxie/runtime/silverlight/Runtime","moxie/core/utils/Basic","moxie/file/Blob","moxie/runtime/flash/image/Image"],function(e,t,i,n){return e.Image=t.extend({},n,{getInfo:function(){var e=this.getRuntime(),n=["tiff","exif","gps","thumb"],r={meta:{}},o=e.shimExec.call(this,"Image","getInfo");return o.meta&&(t.each(n,function(e){var t,i,n,a,s=o.meta[e];if(s&&s.keys)for(r.meta[e]={},i=0,n=s.keys.length;n>i;i++)t=s.keys[i],a=s[t],a&&(/^(\d|[1-9]\d+)$/.test(a)?a=parseInt(a,10):/^\d*\.\d+$/.test(a)&&(a=parseFloat(a)),r.meta[e][t]=a)}),r.meta&&r.meta.thumb&&r.meta.thumb.data&&!(e.meta.thumb.data instanceof i)&&(r.meta.thumb.data=new i(e.uid,r.meta.thumb.data))),r.width=parseInt(o.width,10),r.height=parseInt(o.height,10),r.size=parseInt(o.size,10),r.type=o.type,r.name=o.name,r},resize:function(e,t,i){this.getRuntime().shimExec.call(this,"Image","resize",e.x,e.y,e.width,e.height,t,i.preserveHeaders,i.resample)}})}),n("moxie/runtime/html4/Runtime",["moxie/core/utils/Basic","moxie/core/Exceptions","moxie/runtime/Runtime","moxie/core/utils/Env"],function(e,t,i,n){function o(t){var o=this,u=i.capTest,c=i.capTrue;i.call(this,t,a,{access_binary:u(window.FileReader||window.File&&File.getAsDataURL),access_image_binary:!1,display_media:u((n.can("create_canvas")||n.can("use_data_uri_over32kb"))&&r("moxie/image/Image")),do_cors:!1,drag_and_drop:!1,filter_by_extension:u(function(){return!("Chrome"===n.browser&&n.verComp(n.version,28,"<")||"IE"===n.browser&&n.verComp(n.version,10,"<")||"Safari"===n.browser&&n.verComp(n.version,7,"<")||"Firefox"===n.browser&&n.verComp(n.version,37,"<"))}()),resize_image:function(){return s.Image&&o.can("access_binary")&&n.can("create_canvas")},report_upload_progress:!1,return_response_headers:!1,return_response_type:function(t){return"json"===t&&window.JSON?!0:!!~e.inArray(t,["text","document",""])},return_status_code:function(t){return!e.arrayDiff(t,[200,404])},select_file:function(){return n.can("use_fileinput")},select_multiple:!1,send_binary_string:!1,send_custom_headers:!1,send_multipart:!0,slice_blob:!1,stream_upload:function(){return o.can("select_file")},summon_file_dialog:function(){return o.can("select_file")&&!("Firefox"===n.browser&&n.verComp(n.version,4,"<")||"Opera"===n.browser&&n.verComp(n.version,12,"<")||"IE"===n.browser&&n.verComp(n.version,10,"<"))},upload_filesize:c,use_http_method:function(t){return!e.arrayDiff(t,["GET","POST"])}}),e.extend(this,{init:function(){this.trigger("Init")},destroy:function(e){return function(){e.call(o),e=o=null}}(this.destroy)}),e.extend(this.getShim(),s)}var a="html4",s={};return i.addConstructor(a,o),s}),n("moxie/runtime/html4/file/FileInput",["moxie/runtime/html4/Runtime","moxie/file/File","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/utils/Events","moxie/core/utils/Mime","moxie/core/utils/Env"],function(e,t,i,n,r,o,a){function s(){function e(){var o,c,d,m,h,f,p=this,g=p.getRuntime();f=i.guid("uid_"),o=g.getShimContainer(),s&&(d=n.get(s+"_form"),d&&(i.extend(d.style,{top:"100%"}),d.firstChild.setAttribute("tabindex",-1))),m=document.createElement("form"),m.setAttribute("id",f+"_form"),m.setAttribute("method","post"),m.setAttribute("enctype","multipart/form-data"),m.setAttribute("encoding","multipart/form-data"),i.extend(m.style,{overflow:"hidden",position:"absolute",top:0,left:0,width:"100%",height:"100%"}),h=document.createElement("input"),h.setAttribute("id",f),h.setAttribute("type","file"),h.setAttribute("accept",l.join(",")),g.can("summon_file_dialog")&&h.setAttribute("tabindex",-1),i.extend(h.style,{fontSize:"999px",opacity:0}),m.appendChild(h),o.appendChild(m),i.extend(h.style,{position:"absolute",top:0,left:0,width:"100%",height:"100%"}),"IE"===a.browser&&a.verComp(a.version,10,"<")&&i.extend(h.style,{filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=0)"}),h.onchange=function(){var i;this.value&&(i=this.files?this.files[0]:{name:this.value},i=new t(g.uid,i),this.onchange=function(){},e.call(p),p.files=[i],h.setAttribute("id",i.uid),m.setAttribute("id",i.uid+"_form"),p.trigger("change"),h=m=null)},g.can("summon_file_dialog")&&(c=n.get(u.browse_button),r.removeEvent(c,"click",p.uid),r.addEvent(c,"click",function(e){h&&!h.disabled&&h.click(),e.preventDefault()},p.uid)),s=f,o=d=c=null}var s,u,c,l=[];i.extend(this,{init:function(t){var i,a=this,s=a.getRuntime();u=t,l=o.extList2mimes(t.accept,s.can("filter_by_extension")),i=s.getShimContainer(),function(){var e,o,l;e=n.get(t.browse_button),c=n.getStyle(e,"z-index")||"auto",s.can("summon_file_dialog")?("static"===n.getStyle(e,"position")&&(e.style.position="relative"),a.bind("Refresh",function(){o=parseInt(c,10)||1,n.get(u.browse_button).style.zIndex=o,this.getRuntime().getShimContainer().style.zIndex=o-1})):e.setAttribute("tabindex",-1),l=s.can("summon_file_dialog")?e:i,r.addEvent(l,"mouseover",function(){a.trigger("mouseenter")},a.uid),r.addEvent(l,"mouseout",function(){a.trigger("mouseleave")},a.uid),r.addEvent(l,"mousedown",function(){a.trigger("mousedown")},a.uid),r.addEvent(n.get(t.container),"mouseup",function(){a.trigger("mouseup")},a.uid),e=null}(),e.call(this),i=null,a.trigger({type:"ready",async:!0})},setOption:function(e,t){var i,r=this.getRuntime();"accept"==e&&(l=t.mimes||o.extList2mimes(t,r.can("filter_by_extension"))),i=n.get(s),i&&i.setAttribute("accept",l.join(","))},disable:function(e){var t;(t=n.get(s))&&(t.disabled=!!e)},destroy:function(){var e=this.getRuntime(),t=e.getShim(),i=e.getShimContainer(),o=u&&n.get(u.container),a=u&&n.get(u.browse_button);o&&r.removeAllEvents(o,this.uid),a&&(r.removeAllEvents(a,this.uid),a.style.zIndex=c),i&&(r.removeAllEvents(i,this.uid),i.innerHTML=""),t.removeInstance(this.uid),s=l=u=i=o=a=t=null}})}return e.FileInput=s}),n("moxie/runtime/html4/file/FileReader",["moxie/runtime/html4/Runtime","moxie/runtime/html5/file/FileReader"],function(e,t){return e.FileReader=t}),n("moxie/runtime/html4/xhr/XMLHttpRequest",["moxie/runtime/html4/Runtime","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/utils/Url","moxie/core/Exceptions","moxie/core/utils/Events","moxie/file/Blob","moxie/xhr/FormData"],function(e,t,i,n,r,o,a,s){function u(){function e(e){var t,n,r,a,s=this,u=!1;if(l){if(t=l.id.replace(/_iframe$/,""),n=i.get(t+"_form")){for(r=n.getElementsByTagName("input"),a=r.length;a--;)switch(r[a].getAttribute("type")){case"hidden":r[a].parentNode.removeChild(r[a]);break;case"file":u=!0}r=[],u||n.parentNode.removeChild(n),n=null}setTimeout(function(){o.removeEvent(l,"load",s.uid),l.parentNode&&l.parentNode.removeChild(l);var t=s.getRuntime().getShimContainer();t.children.length||t.parentNode.removeChild(t),t=l=null,e()},1)}}var u,c,l;t.extend(this,{send:function(d,m){function h(){var i=w.getShimContainer()||document.body,r=document.createElement("div");r.innerHTML='<iframe id="'+f+'_iframe" name="'+f+'_iframe" src="javascript:&quot;&quot;" style="display:none"></iframe>',l=r.firstChild,i.appendChild(l),o.addEvent(l,"load",function(){var i;try{i=l.contentWindow.document||l.contentDocument||window.frames[l.id].document,/^4(0[0-9]|1[0-7]|2[2346])\s/.test(i.title)?u=i.title.replace(/^(\d+).*$/,"$1"):(u=200,c=t.trim(i.body.innerHTML),v.trigger({type:"progress",loaded:c.length,total:c.length}),x&&v.trigger({type:"uploadprogress",loaded:x.size||1025,total:x.size||1025}))}catch(r){if(!n.hasSameOrigin(d.url))return e.call(v,function(){v.trigger("error")}),void 0;u=404}e.call(v,function(){v.trigger("load")})},v.uid)}var f,p,g,x,v=this,w=v.getRuntime();if(u=c=null,m instanceof s&&m.hasBlob()){if(x=m.getBlob(),f=x.uid,g=i.get(f),p=i.get(f+"_form"),!p)throw new r.DOMException(r.DOMException.NOT_FOUND_ERR)}else f=t.guid("uid_"),p=document.createElement("form"),p.setAttribute("id",f+"_form"),p.setAttribute("method",d.method),p.setAttribute("enctype","multipart/form-data"),p.setAttribute("encoding","multipart/form-data"),w.getShimContainer().appendChild(p);p.setAttribute("target",f+"_iframe"),m instanceof s&&m.each(function(e,i){if(e instanceof a)g&&g.setAttribute("name",i);else{var n=document.createElement("input");t.extend(n,{type:"hidden",name:i,value:e}),g?p.insertBefore(n,g):p.appendChild(n)}}),p.setAttribute("action",d.url),h(),p.submit(),v.trigger("loadstart")},getStatus:function(){return u},getResponse:function(e){if("json"===e&&"string"===t.typeOf(c)&&window.JSON)try{return JSON.parse(c.replace(/^\s*<pre[^>]*>/,"").replace(/<\/pre>\s*$/,""))}catch(i){return null}return c},abort:function(){var t=this;l&&l.contentWindow&&(l.contentWindow.stop?l.contentWindow.stop():l.contentWindow.document.execCommand?l.contentWindow.document.execCommand("Stop"):l.src="about:blank"),e.call(this,function(){t.dispatchEvent("abort")})},destroy:function(){this.getRuntime().getShim().removeInstance(this.uid)}})}return e.XMLHttpRequest=u}),n("moxie/runtime/html4/image/Image",["moxie/runtime/html4/Runtime","moxie/runtime/html5/image/Image"],function(e,t){return e.Image=t}),a(["moxie/core/utils/Basic","moxie/core/utils/Encode","moxie/core/utils/Env","moxie/core/Exceptions","moxie/core/utils/Dom","moxie/core/EventTarget","moxie/runtime/Runtime","moxie/runtime/RuntimeClient","moxie/file/Blob","moxie/core/I18n","moxie/core/utils/Mime","moxie/file/FileInput","moxie/file/File","moxie/file/FileDrop","moxie/file/FileReader","moxie/core/utils/Url","moxie/runtime/RuntimeTarget","moxie/xhr/FormData","moxie/xhr/XMLHttpRequest","moxie/image/Image","moxie/core/utils/Events","moxie/runtime/html5/image/ResizerCanvas"])}(this)});
@@ -0,0 +1,2497 @@
1
+ /**
2
+ * Plupload - multi-runtime File Uploader
3
+ * v2.3.6
4
+ *
5
+ * Copyright 2013, Moxiecode Systems AB
6
+ * Released under GPL License.
7
+ *
8
+ * License: http://www.plupload.com/license
9
+ * Contributing: http://www.plupload.com/contributing
10
+ *
11
+ * Date: 2017-11-03
12
+ */
13
+ ;(function (global, factory) {
14
+ var extract = function() {
15
+ var ctx = {};
16
+ factory.apply(ctx, arguments);
17
+ return ctx.plupload;
18
+ };
19
+
20
+ if (typeof define === "function" && define.amd) {
21
+ define("plupload", ['./moxie'], extract);
22
+ } else if (typeof module === "object" && module.exports) {
23
+ module.exports = extract(require('./moxie'));
24
+ } else {
25
+ global.plupload = extract(global.moxie);
26
+ }
27
+ }(this || window, function(moxie) {
28
+ /**
29
+ * Plupload.js
30
+ *
31
+ * Copyright 2013, Moxiecode Systems AB
32
+ * Released under GPL License.
33
+ *
34
+ * License: http://www.plupload.com/license
35
+ * Contributing: http://www.plupload.com/contributing
36
+ */
37
+
38
+ ;(function(exports, o, undef) {
39
+
40
+ var delay = window.setTimeout;
41
+ var fileFilters = {};
42
+ var u = o.core.utils;
43
+ var Runtime = o.runtime.Runtime;
44
+
45
+ // convert plupload features to caps acceptable by mOxie
46
+ function normalizeCaps(settings) {
47
+ var features = settings.required_features, caps = {};
48
+
49
+ function resolve(feature, value, strict) {
50
+ // Feature notation is deprecated, use caps (this thing here is required for backward compatibility)
51
+ var map = {
52
+ chunks: 'slice_blob',
53
+ jpgresize: 'send_binary_string',
54
+ pngresize: 'send_binary_string',
55
+ progress: 'report_upload_progress',
56
+ multi_selection: 'select_multiple',
57
+ dragdrop: 'drag_and_drop',
58
+ drop_element: 'drag_and_drop',
59
+ headers: 'send_custom_headers',
60
+ urlstream_upload: 'send_binary_string',
61
+ canSendBinary: 'send_binary',
62
+ triggerDialog: 'summon_file_dialog'
63
+ };
64
+
65
+ if (map[feature]) {
66
+ caps[map[feature]] = value;
67
+ } else if (!strict) {
68
+ caps[feature] = value;
69
+ }
70
+ }
71
+
72
+ if (typeof(features) === 'string') {
73
+ plupload.each(features.split(/\s*,\s*/), function(feature) {
74
+ resolve(feature, true);
75
+ });
76
+ } else if (typeof(features) === 'object') {
77
+ plupload.each(features, function(value, feature) {
78
+ resolve(feature, value);
79
+ });
80
+ } else if (features === true) {
81
+ // check settings for required features
82
+ if (settings.chunk_size && settings.chunk_size > 0) {
83
+ caps.slice_blob = true;
84
+ }
85
+
86
+ if (!plupload.isEmptyObj(settings.resize) || settings.multipart === false) {
87
+ caps.send_binary_string = true;
88
+ }
89
+
90
+ if (settings.http_method) {
91
+ caps.use_http_method = settings.http_method;
92
+ }
93
+
94
+ plupload.each(settings, function(value, feature) {
95
+ resolve(feature, !!value, true); // strict check
96
+ });
97
+ }
98
+
99
+ return caps;
100
+ }
101
+
102
+ /**
103
+ * @module plupload
104
+ * @static
105
+ */
106
+ var plupload = {
107
+ /**
108
+ * Plupload version will be replaced on build.
109
+ *
110
+ * @property VERSION
111
+ * @for Plupload
112
+ * @static
113
+ * @final
114
+ */
115
+ VERSION : '2.3.6',
116
+
117
+ /**
118
+ * The state of the queue before it has started and after it has finished
119
+ *
120
+ * @property STOPPED
121
+ * @static
122
+ * @final
123
+ */
124
+ STOPPED : 1,
125
+
126
+ /**
127
+ * Upload process is running
128
+ *
129
+ * @property STARTED
130
+ * @static
131
+ * @final
132
+ */
133
+ STARTED : 2,
134
+
135
+ /**
136
+ * File is queued for upload
137
+ *
138
+ * @property QUEUED
139
+ * @static
140
+ * @final
141
+ */
142
+ QUEUED : 1,
143
+
144
+ /**
145
+ * File is being uploaded
146
+ *
147
+ * @property UPLOADING
148
+ * @static
149
+ * @final
150
+ */
151
+ UPLOADING : 2,
152
+
153
+ /**
154
+ * File has failed to be uploaded
155
+ *
156
+ * @property FAILED
157
+ * @static
158
+ * @final
159
+ */
160
+ FAILED : 4,
161
+
162
+ /**
163
+ * File has been uploaded successfully
164
+ *
165
+ * @property DONE
166
+ * @static
167
+ * @final
168
+ */
169
+ DONE : 5,
170
+
171
+ // Error constants used by the Error event
172
+
173
+ /**
174
+ * Generic error for example if an exception is thrown inside Silverlight.
175
+ *
176
+ * @property GENERIC_ERROR
177
+ * @static
178
+ * @final
179
+ */
180
+ GENERIC_ERROR : -100,
181
+
182
+ /**
183
+ * HTTP transport error. For example if the server produces a HTTP status other than 200.
184
+ *
185
+ * @property HTTP_ERROR
186
+ * @static
187
+ * @final
188
+ */
189
+ HTTP_ERROR : -200,
190
+
191
+ /**
192
+ * Generic I/O error. For example if it wasn't possible to open the file stream on local machine.
193
+ *
194
+ * @property IO_ERROR
195
+ * @static
196
+ * @final
197
+ */
198
+ IO_ERROR : -300,
199
+
200
+ /**
201
+ * @property SECURITY_ERROR
202
+ * @static
203
+ * @final
204
+ */
205
+ SECURITY_ERROR : -400,
206
+
207
+ /**
208
+ * Initialization error. Will be triggered if no runtime was initialized.
209
+ *
210
+ * @property INIT_ERROR
211
+ * @static
212
+ * @final
213
+ */
214
+ INIT_ERROR : -500,
215
+
216
+ /**
217
+ * File size error. If the user selects a file that is too large or is empty it will be blocked and
218
+ * an error of this type will be triggered.
219
+ *
220
+ * @property FILE_SIZE_ERROR
221
+ * @static
222
+ * @final
223
+ */
224
+ FILE_SIZE_ERROR : -600,
225
+
226
+ /**
227
+ * File extension error. If the user selects a file that isn't valid according to the filters setting.
228
+ *
229
+ * @property FILE_EXTENSION_ERROR
230
+ * @static
231
+ * @final
232
+ */
233
+ FILE_EXTENSION_ERROR : -601,
234
+
235
+ /**
236
+ * Duplicate file error. If prevent_duplicates is set to true and user selects the same file again.
237
+ *
238
+ * @property FILE_DUPLICATE_ERROR
239
+ * @static
240
+ * @final
241
+ */
242
+ FILE_DUPLICATE_ERROR : -602,
243
+
244
+ /**
245
+ * Runtime will try to detect if image is proper one. Otherwise will throw this error.
246
+ *
247
+ * @property IMAGE_FORMAT_ERROR
248
+ * @static
249
+ * @final
250
+ */
251
+ IMAGE_FORMAT_ERROR : -700,
252
+
253
+ /**
254
+ * While working on files runtime may run out of memory and will throw this error.
255
+ *
256
+ * @since 2.1.2
257
+ * @property MEMORY_ERROR
258
+ * @static
259
+ * @final
260
+ */
261
+ MEMORY_ERROR : -701,
262
+
263
+ /**
264
+ * Each runtime has an upper limit on a dimension of the image it can handle. If bigger, will throw this error.
265
+ *
266
+ * @property IMAGE_DIMENSIONS_ERROR
267
+ * @static
268
+ * @final
269
+ */
270
+ IMAGE_DIMENSIONS_ERROR : -702,
271
+
272
+ /**
273
+ * Expose whole moxie (#1469).
274
+ *
275
+ * @property moxie
276
+ * @type Object
277
+ * @final
278
+ */
279
+ moxie: o,
280
+
281
+ /**
282
+ * Mime type lookup table.
283
+ *
284
+ * @property mimeTypes
285
+ * @type Object
286
+ * @final
287
+ */
288
+ mimeTypes : u.Mime.mimes,
289
+
290
+ /**
291
+ * In some cases sniffing is the only way around :(
292
+ */
293
+ ua: u.Env,
294
+
295
+ /**
296
+ * Gets the true type of the built-in object (better version of typeof).
297
+ * @credits Angus Croll (http://javascriptweblog.wordpress.com/)
298
+ *
299
+ * @method typeOf
300
+ * @static
301
+ * @param {Object} o Object to check.
302
+ * @return {String} Object [[Class]]
303
+ */
304
+ typeOf: u.Basic.typeOf,
305
+
306
+ /**
307
+ * Extends the specified object with another object.
308
+ *
309
+ * @method extend
310
+ * @static
311
+ * @param {Object} target Object to extend.
312
+ * @param {Object..} obj Multiple objects to extend with.
313
+ * @return {Object} Same as target, the extended object.
314
+ */
315
+ extend : u.Basic.extend,
316
+
317
+ /**
318
+ * Generates an unique ID. This is 99.99% unique since it takes the current time and 5 random numbers.
319
+ * The only way a user would be able to get the same ID is if the two persons at the same exact millisecond manages
320
+ * to get 5 the same random numbers between 0-65535 it also uses a counter so each call will be guaranteed to be page unique.
321
+ * It's more probable for the earth to be hit with an asteriod. You can also if you want to be 100% sure set the plupload.guidPrefix property
322
+ * to an user unique key.
323
+ *
324
+ * @method guid
325
+ * @static
326
+ * @return {String} Virtually unique id.
327
+ */
328
+ guid : u.Basic.guid,
329
+
330
+ /**
331
+ * Get array of DOM Elements by their ids.
332
+ *
333
+ * @method get
334
+ * @param {String} id Identifier of the DOM Element
335
+ * @return {Array}
336
+ */
337
+ getAll : function get(ids) {
338
+ var els = [], el;
339
+
340
+ if (plupload.typeOf(ids) !== 'array') {
341
+ ids = [ids];
342
+ }
343
+
344
+ var i = ids.length;
345
+ while (i--) {
346
+ el = plupload.get(ids[i]);
347
+ if (el) {
348
+ els.push(el);
349
+ }
350
+ }
351
+
352
+ return els.length ? els : null;
353
+ },
354
+
355
+ /**
356
+ Get DOM element by id
357
+
358
+ @method get
359
+ @param {String} id Identifier of the DOM Element
360
+ @return {Node}
361
+ */
362
+ get: u.Dom.get,
363
+
364
+ /**
365
+ * Executes the callback function for each item in array/object. If you return false in the
366
+ * callback it will break the loop.
367
+ *
368
+ * @method each
369
+ * @static
370
+ * @param {Object} obj Object to iterate.
371
+ * @param {function} callback Callback function to execute for each item.
372
+ */
373
+ each : u.Basic.each,
374
+
375
+ /**
376
+ * Returns the absolute x, y position of an Element. The position will be returned in a object with x, y fields.
377
+ *
378
+ * @method getPos
379
+ * @static
380
+ * @param {Element} node HTML element or element id to get x, y position from.
381
+ * @param {Element} root Optional root element to stop calculations at.
382
+ * @return {object} Absolute position of the specified element object with x, y fields.
383
+ */
384
+ getPos : u.Dom.getPos,
385
+
386
+ /**
387
+ * Returns the size of the specified node in pixels.
388
+ *
389
+ * @method getSize
390
+ * @static
391
+ * @param {Node} node Node to get the size of.
392
+ * @return {Object} Object with a w and h property.
393
+ */
394
+ getSize : u.Dom.getSize,
395
+
396
+ /**
397
+ * Encodes the specified string.
398
+ *
399
+ * @method xmlEncode
400
+ * @static
401
+ * @param {String} s String to encode.
402
+ * @return {String} Encoded string.
403
+ */
404
+ xmlEncode : function(str) {
405
+ var xmlEncodeChars = {'<' : 'lt', '>' : 'gt', '&' : 'amp', '"' : 'quot', '\'' : '#39'}, xmlEncodeRegExp = /[<>&\"\']/g;
406
+
407
+ return str ? ('' + str).replace(xmlEncodeRegExp, function(chr) {
408
+ return xmlEncodeChars[chr] ? '&' + xmlEncodeChars[chr] + ';' : chr;
409
+ }) : str;
410
+ },
411
+
412
+ /**
413
+ * Forces anything into an array.
414
+ *
415
+ * @method toArray
416
+ * @static
417
+ * @param {Object} obj Object with length field.
418
+ * @return {Array} Array object containing all items.
419
+ */
420
+ toArray : u.Basic.toArray,
421
+
422
+ /**
423
+ * Find an element in array and return its index if present, otherwise return -1.
424
+ *
425
+ * @method inArray
426
+ * @static
427
+ * @param {mixed} needle Element to find
428
+ * @param {Array} array
429
+ * @return {Int} Index of the element, or -1 if not found
430
+ */
431
+ inArray : u.Basic.inArray,
432
+
433
+ /**
434
+ Recieve an array of functions (usually async) to call in sequence, each function
435
+ receives a callback as first argument that it should call, when it completes. Finally,
436
+ after everything is complete, main callback is called. Passing truthy value to the
437
+ callback as a first argument will interrupt the sequence and invoke main callback
438
+ immediately.
439
+
440
+ @method inSeries
441
+ @static
442
+ @param {Array} queue Array of functions to call in sequence
443
+ @param {Function} cb Main callback that is called in the end, or in case of error
444
+ */
445
+ inSeries: u.Basic.inSeries,
446
+
447
+ /**
448
+ * Extends the language pack object with new items.
449
+ *
450
+ * @method addI18n
451
+ * @static
452
+ * @param {Object} pack Language pack items to add.
453
+ * @return {Object} Extended language pack object.
454
+ */
455
+ addI18n : o.core.I18n.addI18n,
456
+
457
+ /**
458
+ * Translates the specified string by checking for the english string in the language pack lookup.
459
+ *
460
+ * @method translate
461
+ * @static
462
+ * @param {String} str String to look for.
463
+ * @return {String} Translated string or the input string if it wasn't found.
464
+ */
465
+ translate : o.core.I18n.translate,
466
+
467
+ /**
468
+ * Pseudo sprintf implementation - simple way to replace tokens with specified values.
469
+ *
470
+ * @param {String} str String with tokens
471
+ * @return {String} String with replaced tokens
472
+ */
473
+ sprintf : u.Basic.sprintf,
474
+
475
+ /**
476
+ * Checks if object is empty.
477
+ *
478
+ * @method isEmptyObj
479
+ * @static
480
+ * @param {Object} obj Object to check.
481
+ * @return {Boolean}
482
+ */
483
+ isEmptyObj : u.Basic.isEmptyObj,
484
+
485
+ /**
486
+ * Checks if specified DOM element has specified class.
487
+ *
488
+ * @method hasClass
489
+ * @static
490
+ * @param {Object} obj DOM element like object to add handler to.
491
+ * @param {String} name Class name
492
+ */
493
+ hasClass : u.Dom.hasClass,
494
+
495
+ /**
496
+ * Adds specified className to specified DOM element.
497
+ *
498
+ * @method addClass
499
+ * @static
500
+ * @param {Object} obj DOM element like object to add handler to.
501
+ * @param {String} name Class name
502
+ */
503
+ addClass : u.Dom.addClass,
504
+
505
+ /**
506
+ * Removes specified className from specified DOM element.
507
+ *
508
+ * @method removeClass
509
+ * @static
510
+ * @param {Object} obj DOM element like object to add handler to.
511
+ * @param {String} name Class name
512
+ */
513
+ removeClass : u.Dom.removeClass,
514
+
515
+ /**
516
+ * Returns a given computed style of a DOM element.
517
+ *
518
+ * @method getStyle
519
+ * @static
520
+ * @param {Object} obj DOM element like object.
521
+ * @param {String} name Style you want to get from the DOM element
522
+ */
523
+ getStyle : u.Dom.getStyle,
524
+
525
+ /**
526
+ * Adds an event handler to the specified object and store reference to the handler
527
+ * in objects internal Plupload registry (@see removeEvent).
528
+ *
529
+ * @method addEvent
530
+ * @static
531
+ * @param {Object} obj DOM element like object to add handler to.
532
+ * @param {String} name Name to add event listener to.
533
+ * @param {Function} callback Function to call when event occurs.
534
+ * @param {String} (optional) key that might be used to add specifity to the event record.
535
+ */
536
+ addEvent : u.Events.addEvent,
537
+
538
+ /**
539
+ * Remove event handler from the specified object. If third argument (callback)
540
+ * is not specified remove all events with the specified name.
541
+ *
542
+ * @method removeEvent
543
+ * @static
544
+ * @param {Object} obj DOM element to remove event listener(s) from.
545
+ * @param {String} name Name of event listener to remove.
546
+ * @param {Function|String} (optional) might be a callback or unique key to match.
547
+ */
548
+ removeEvent: u.Events.removeEvent,
549
+
550
+ /**
551
+ * Remove all kind of events from the specified object
552
+ *
553
+ * @method removeAllEvents
554
+ * @static
555
+ * @param {Object} obj DOM element to remove event listeners from.
556
+ * @param {String} (optional) unique key to match, when removing events.
557
+ */
558
+ removeAllEvents: u.Events.removeAllEvents,
559
+
560
+ /**
561
+ * Cleans the specified name from national characters (diacritics). The result will be a name with only a-z, 0-9 and _.
562
+ *
563
+ * @method cleanName
564
+ * @static
565
+ * @param {String} s String to clean up.
566
+ * @return {String} Cleaned string.
567
+ */
568
+ cleanName : function(name) {
569
+ var i, lookup;
570
+
571
+ // Replace diacritics
572
+ lookup = [
573
+ /[\300-\306]/g, 'A', /[\340-\346]/g, 'a',
574
+ /\307/g, 'C', /\347/g, 'c',
575
+ /[\310-\313]/g, 'E', /[\350-\353]/g, 'e',
576
+ /[\314-\317]/g, 'I', /[\354-\357]/g, 'i',
577
+ /\321/g, 'N', /\361/g, 'n',
578
+ /[\322-\330]/g, 'O', /[\362-\370]/g, 'o',
579
+ /[\331-\334]/g, 'U', /[\371-\374]/g, 'u'
580
+ ];
581
+
582
+ for (i = 0; i < lookup.length; i += 2) {
583
+ name = name.replace(lookup[i], lookup[i + 1]);
584
+ }
585
+
586
+ // Replace whitespace
587
+ name = name.replace(/\s+/g, '_');
588
+
589
+ // Remove anything else
590
+ name = name.replace(/[^a-z0-9_\-\.]+/gi, '');
591
+
592
+ return name;
593
+ },
594
+
595
+ /**
596
+ * Builds a full url out of a base URL and an object with items to append as query string items.
597
+ *
598
+ * @method buildUrl
599
+ * @static
600
+ * @param {String} url Base URL to append query string items to.
601
+ * @param {Object} items Name/value object to serialize as a querystring.
602
+ * @return {String} String with url + serialized query string items.
603
+ */
604
+ buildUrl: function(url, items) {
605
+ var query = '';
606
+
607
+ plupload.each(items, function(value, name) {
608
+ query += (query ? '&' : '') + encodeURIComponent(name) + '=' + encodeURIComponent(value);
609
+ });
610
+
611
+ if (query) {
612
+ url += (url.indexOf('?') > 0 ? '&' : '?') + query;
613
+ }
614
+
615
+ return url;
616
+ },
617
+
618
+ /**
619
+ * Formats the specified number as a size string for example 1024 becomes 1 KB.
620
+ *
621
+ * @method formatSize
622
+ * @static
623
+ * @param {Number} size Size to format as string.
624
+ * @return {String} Formatted size string.
625
+ */
626
+ formatSize : function(size) {
627
+
628
+ if (size === undef || /\D/.test(size)) {
629
+ return plupload.translate('N/A');
630
+ }
631
+
632
+ function round(num, precision) {
633
+ return Math.round(num * Math.pow(10, precision)) / Math.pow(10, precision);
634
+ }
635
+
636
+ var boundary = Math.pow(1024, 4);
637
+
638
+ // TB
639
+ if (size > boundary) {
640
+ return round(size / boundary, 1) + " " + plupload.translate('tb');
641
+ }
642
+
643
+ // GB
644
+ if (size > (boundary/=1024)) {
645
+ return round(size / boundary, 1) + " " + plupload.translate('gb');
646
+ }
647
+
648
+ // MB
649
+ if (size > (boundary/=1024)) {
650
+ return round(size / boundary, 1) + " " + plupload.translate('mb');
651
+ }
652
+
653
+ // KB
654
+ if (size > 1024) {
655
+ return Math.round(size / 1024) + " " + plupload.translate('kb');
656
+ }
657
+
658
+ return size + " " + plupload.translate('b');
659
+ },
660
+
661
+
662
+ /**
663
+ * Parses the specified size string into a byte value. For example 10kb becomes 10240.
664
+ *
665
+ * @method parseSize
666
+ * @static
667
+ * @param {String|Number} size String to parse or number to just pass through.
668
+ * @return {Number} Size in bytes.
669
+ */
670
+ parseSize : u.Basic.parseSizeStr,
671
+
672
+
673
+ /**
674
+ * A way to predict what runtime will be choosen in the current environment with the
675
+ * specified settings.
676
+ *
677
+ * @method predictRuntime
678
+ * @static
679
+ * @param {Object|String} config Plupload settings to check
680
+ * @param {String} [runtimes] Comma-separated list of runtimes to check against
681
+ * @return {String} Type of compatible runtime
682
+ */
683
+ predictRuntime : function(config, runtimes) {
684
+ var up, runtime;
685
+
686
+ up = new plupload.Uploader(config);
687
+ runtime = Runtime.thatCan(up.getOption().required_features, runtimes || config.runtimes);
688
+ up.destroy();
689
+ return runtime;
690
+ },
691
+
692
+ /**
693
+ * Registers a filter that will be executed for each file added to the queue.
694
+ * If callback returns false, file will not be added.
695
+ *
696
+ * Callback receives two arguments: a value for the filter as it was specified in settings.filters
697
+ * and a file to be filtered. Callback is executed in the context of uploader instance.
698
+ *
699
+ * @method addFileFilter
700
+ * @static
701
+ * @param {String} name Name of the filter by which it can be referenced in settings.filters
702
+ * @param {String} cb Callback - the actual routine that every added file must pass
703
+ */
704
+ addFileFilter: function(name, cb) {
705
+ fileFilters[name] = cb;
706
+ }
707
+ };
708
+
709
+
710
+ plupload.addFileFilter('mime_types', function(filters, file, cb) {
711
+ if (filters.length && !filters.regexp.test(file.name)) {
712
+ this.trigger('Error', {
713
+ code : plupload.FILE_EXTENSION_ERROR,
714
+ message : plupload.translate('File extension error.'),
715
+ file : file
716
+ });
717
+ cb(false);
718
+ } else {
719
+ cb(true);
720
+ }
721
+ });
722
+
723
+
724
+ plupload.addFileFilter('max_file_size', function(maxSize, file, cb) {
725
+ var undef;
726
+
727
+ maxSize = plupload.parseSize(maxSize);
728
+
729
+ // Invalid file size
730
+ if (file.size !== undef && maxSize && file.size > maxSize) {
731
+ this.trigger('Error', {
732
+ code : plupload.FILE_SIZE_ERROR,
733
+ message : plupload.translate('File size error.'),
734
+ file : file
735
+ });
736
+ cb(false);
737
+ } else {
738
+ cb(true);
739
+ }
740
+ });
741
+
742
+
743
+ plupload.addFileFilter('prevent_duplicates', function(value, file, cb) {
744
+ if (value) {
745
+ var ii = this.files.length;
746
+ while (ii--) {
747
+ // Compare by name and size (size might be 0 or undefined, but still equivalent for both)
748
+ if (file.name === this.files[ii].name && file.size === this.files[ii].size) {
749
+ this.trigger('Error', {
750
+ code : plupload.FILE_DUPLICATE_ERROR,
751
+ message : plupload.translate('Duplicate file error.'),
752
+ file : file
753
+ });
754
+ cb(false);
755
+ return;
756
+ }
757
+ }
758
+ }
759
+ cb(true);
760
+ });
761
+
762
+ plupload.addFileFilter('prevent_empty', function(value, file, cb) {
763
+ if (value && !file.size && file.size !== undef) {
764
+ this.trigger('Error', {
765
+ code : plupload.FILE_SIZE_ERROR,
766
+ message : plupload.translate('File size error.'),
767
+ file : file
768
+ });
769
+ cb(false);
770
+ } else {
771
+ cb(true);
772
+ }
773
+ });
774
+
775
+
776
+ /**
777
+ @class Uploader
778
+ @constructor
779
+
780
+ @param {Object} settings For detailed information about each option check documentation.
781
+ @param {String|DOMElement} settings.browse_button id of the DOM element or DOM element itself to use as file dialog trigger.
782
+ @param {Number|String} [settings.chunk_size=0] Chunk size in bytes to slice the file into. Shorcuts with b, kb, mb, gb, tb suffixes also supported. `e.g. 204800 or "204800b" or "200kb"`. By default - disabled.
783
+ @param {String|DOMElement} [settings.container] id of the DOM element or DOM element itself that will be used to wrap uploader structures. Defaults to immediate parent of the `browse_button` element.
784
+ @param {String|DOMElement} [settings.drop_element] id of the DOM element or DOM element itself to use as a drop zone for Drag-n-Drop.
785
+ @param {String} [settings.file_data_name="file"] Name for the file field in Multipart formated message.
786
+ @param {Object} [settings.filters={}] Set of file type filters.
787
+ @param {String|Number} [settings.filters.max_file_size=0] Maximum file size that the user can pick, in bytes. Optionally supports b, kb, mb, gb, tb suffixes. `e.g. "10mb" or "1gb"`. By default - not set. Dispatches `plupload.FILE_SIZE_ERROR`.
788
+ @param {Array} [settings.filters.mime_types=[]] List of file types to accept, each one defined by title and list of extensions. `e.g. {title : "Image files", extensions : "jpg,jpeg,gif,png"}`. Dispatches `plupload.FILE_EXTENSION_ERROR`
789
+ @param {Boolean} [settings.filters.prevent_duplicates=false] Do not let duplicates into the queue. Dispatches `plupload.FILE_DUPLICATE_ERROR`.
790
+ @param {Boolean} [settings.filters.prevent_empty=true] Do not let empty files into the queue (IE10 is known to hang for example when trying to upload such). Dispatches `plupload.FILE_SIZE_ERROR`.
791
+ @param {String} [settings.flash_swf_url] URL of the Flash swf.
792
+ @param {Object} [settings.headers] Custom headers to send with the upload. Hash of name/value pairs.
793
+ @param {String} [settings.http_method="POST"] HTTP method to use during upload (only PUT or POST allowed).
794
+ @param {Number} [settings.max_retries=0] How many times to retry the chunk or file, before triggering Error event.
795
+ @param {Boolean} [settings.multipart=true] Whether to send file and additional parameters as Multipart formated message.
796
+ @param {Object} [settings.multipart_params] Hash of key/value pairs to send with every file upload.
797
+ @param {Boolean} [settings.multi_selection=true] Enable ability to select multiple files at once in file dialog.
798
+ @param {String|Object} [settings.required_features] Either comma-separated list or hash of required features that chosen runtime should absolutely possess.
799
+ @param {Object} [settings.resize] Enable resizng of images on client-side. Applies to `image/jpeg` and `image/png` only. `e.g. {width : 200, height : 200, quality : 90, crop: true}`
800
+ @param {Number} [settings.resize.width] If image is bigger, it will be resized.
801
+ @param {Number} [settings.resize.height] If image is bigger, it will be resized.
802
+ @param {Number} [settings.resize.quality=90] Compression quality for jpegs (1-100).
803
+ @param {Boolean} [settings.resize.crop=false] Whether to crop images to exact dimensions. By default they will be resized proportionally.
804
+ @param {String} [settings.runtimes="html5,flash,silverlight,html4"] Comma separated list of runtimes, that Plupload will try in turn, moving to the next if previous fails.
805
+ @param {String} [settings.silverlight_xap_url] URL of the Silverlight xap.
806
+ @param {Boolean} [settings.send_chunk_number=true] Whether to send chunks and chunk numbers, or total and offset bytes.
807
+ @param {Boolean} [settings.send_file_name=true] Whether to send file name as additional argument - 'name' (required for chunked uploads and some other cases where file name cannot be sent via normal ways).
808
+ @param {String} settings.url URL of the server-side upload handler.
809
+ @param {Boolean} [settings.unique_names=false] If true will generate unique filenames for uploaded files.
810
+
811
+ */
812
+ plupload.Uploader = function(options) {
813
+ /**
814
+ Fires when the current RunTime has been initialized.
815
+
816
+ @event Init
817
+ @param {plupload.Uploader} uploader Uploader instance sending the event.
818
+ */
819
+
820
+ /**
821
+ Fires after the init event incase you need to perform actions there.
822
+
823
+ @event PostInit
824
+ @param {plupload.Uploader} uploader Uploader instance sending the event.
825
+ */
826
+
827
+ /**
828
+ Fires when the option is changed in via uploader.setOption().
829
+
830
+ @event OptionChanged
831
+ @since 2.1
832
+ @param {plupload.Uploader} uploader Uploader instance sending the event.
833
+ @param {String} name Name of the option that was changed
834
+ @param {Mixed} value New value for the specified option
835
+ @param {Mixed} oldValue Previous value of the option
836
+ */
837
+
838
+ /**
839
+ Fires when the silverlight/flash or other shim needs to move.
840
+
841
+ @event Refresh
842
+ @param {plupload.Uploader} uploader Uploader instance sending the event.
843
+ */
844
+
845
+ /**
846
+ Fires when the overall state is being changed for the upload queue.
847
+
848
+ @event StateChanged
849
+ @param {plupload.Uploader} uploader Uploader instance sending the event.
850
+ */
851
+
852
+ /**
853
+ Fires when browse_button is clicked and browse dialog shows.
854
+
855
+ @event Browse
856
+ @since 2.1.2
857
+ @param {plupload.Uploader} uploader Uploader instance sending the event.
858
+ */
859
+
860
+ /**
861
+ Fires for every filtered file before it is added to the queue.
862
+
863
+ @event FileFiltered
864
+ @since 2.1
865
+ @param {plupload.Uploader} uploader Uploader instance sending the event.
866
+ @param {plupload.File} file Another file that has to be added to the queue.
867
+ */
868
+
869
+ /**
870
+ Fires when the file queue is changed. In other words when files are added/removed to the files array of the uploader instance.
871
+
872
+ @event QueueChanged
873
+ @param {plupload.Uploader} uploader Uploader instance sending the event.
874
+ */
875
+
876
+ /**
877
+ Fires after files were filtered and added to the queue.
878
+
879
+ @event FilesAdded
880
+ @param {plupload.Uploader} uploader Uploader instance sending the event.
881
+ @param {Array} files Array of file objects that were added to queue by the user.
882
+ */
883
+
884
+ /**
885
+ Fires when file is removed from the queue.
886
+
887
+ @event FilesRemoved
888
+ @param {plupload.Uploader} uploader Uploader instance sending the event.
889
+ @param {Array} files Array of files that got removed.
890
+ */
891
+
892
+ /**
893
+ Fires just before a file is uploaded. Can be used to cancel the upload for the specified file
894
+ by returning false from the handler.
895
+
896
+ @event BeforeUpload
897
+ @param {plupload.Uploader} uploader Uploader instance sending the event.
898
+ @param {plupload.File} file File to be uploaded.
899
+ */
900
+
901
+ /**
902
+ Fires when a file is to be uploaded by the runtime.
903
+
904
+ @event UploadFile
905
+ @param {plupload.Uploader} uploader Uploader instance sending the event.
906
+ @param {plupload.File} file File to be uploaded.
907
+ */
908
+
909
+ /**
910
+ Fires while a file is being uploaded. Use this event to update the current file upload progress.
911
+
912
+ @event UploadProgress
913
+ @param {plupload.Uploader} uploader Uploader instance sending the event.
914
+ @param {plupload.File} file File that is currently being uploaded.
915
+ */
916
+
917
+ /**
918
+ * Fires just before a chunk is uploaded. This event enables you to override settings
919
+ * on the uploader instance before the chunk is uploaded.
920
+ *
921
+ * @event BeforeChunkUpload
922
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
923
+ * @param {plupload.File} file File to be uploaded.
924
+ * @param {Object} args POST params to be sent.
925
+ * @param {Blob} chunkBlob Current blob.
926
+ * @param {offset} offset Current offset.
927
+ */
928
+
929
+ /**
930
+ Fires when file chunk is uploaded.
931
+
932
+ @event ChunkUploaded
933
+ @param {plupload.Uploader} uploader Uploader instance sending the event.
934
+ @param {plupload.File} file File that the chunk was uploaded for.
935
+ @param {Object} result Object with response properties.
936
+ @param {Number} result.offset The amount of bytes the server has received so far, including this chunk.
937
+ @param {Number} result.total The size of the file.
938
+ @param {String} result.response The response body sent by the server.
939
+ @param {Number} result.status The HTTP status code sent by the server.
940
+ @param {String} result.responseHeaders All the response headers as a single string.
941
+ */
942
+
943
+ /**
944
+ Fires when a file is successfully uploaded.
945
+
946
+ @event FileUploaded
947
+ @param {plupload.Uploader} uploader Uploader instance sending the event.
948
+ @param {plupload.File} file File that was uploaded.
949
+ @param {Object} result Object with response properties.
950
+ @param {String} result.response The response body sent by the server.
951
+ @param {Number} result.status The HTTP status code sent by the server.
952
+ @param {String} result.responseHeaders All the response headers as a single string.
953
+ */
954
+
955
+ /**
956
+ Fires when all files in a queue are uploaded.
957
+
958
+ @event UploadComplete
959
+ @param {plupload.Uploader} uploader Uploader instance sending the event.
960
+ @param {Array} files Array of file objects that was added to queue/selected by the user.
961
+ */
962
+
963
+ /**
964
+ Fires when a error occurs.
965
+
966
+ @event Error
967
+ @param {plupload.Uploader} uploader Uploader instance sending the event.
968
+ @param {Object} error Contains code, message and sometimes file and other details.
969
+ @param {Number} error.code The plupload error code.
970
+ @param {String} error.message Description of the error (uses i18n).
971
+ */
972
+
973
+ /**
974
+ Fires when destroy method is called.
975
+
976
+ @event Destroy
977
+ @param {plupload.Uploader} uploader Uploader instance sending the event.
978
+ */
979
+ var uid = plupload.guid()
980
+ , settings
981
+ , files = []
982
+ , preferred_caps = {}
983
+ , fileInputs = []
984
+ , fileDrops = []
985
+ , startTime
986
+ , total
987
+ , disabled = false
988
+ , xhr
989
+ ;
990
+
991
+
992
+ // Private methods
993
+ function uploadNext() {
994
+ var file, count = 0, i;
995
+
996
+ if (this.state == plupload.STARTED) {
997
+ // Find first QUEUED file
998
+ for (i = 0; i < files.length; i++) {
999
+ if (!file && files[i].status == plupload.QUEUED) {
1000
+ file = files[i];
1001
+ if (this.trigger("BeforeUpload", file)) {
1002
+ file.status = plupload.UPLOADING;
1003
+ this.trigger("UploadFile", file);
1004
+ }
1005
+ } else {
1006
+ count++;
1007
+ }
1008
+ }
1009
+
1010
+ // All files are DONE or FAILED
1011
+ if (count == files.length) {
1012
+ if (this.state !== plupload.STOPPED) {
1013
+ this.state = plupload.STOPPED;
1014
+ this.trigger("StateChanged");
1015
+ }
1016
+ this.trigger("UploadComplete", files);
1017
+ }
1018
+ }
1019
+ }
1020
+
1021
+
1022
+ function calcFile(file) {
1023
+ file.percent = file.size > 0 ? Math.ceil(file.loaded / file.size * 100) : 100;
1024
+ calc();
1025
+ }
1026
+
1027
+
1028
+ function calc() {
1029
+ var i, file;
1030
+ var loaded;
1031
+ var loadedDuringCurrentSession = 0;
1032
+
1033
+ // Reset stats
1034
+ total.reset();
1035
+
1036
+ // Check status, size, loaded etc on all files
1037
+ for (i = 0; i < files.length; i++) {
1038
+ file = files[i];
1039
+
1040
+ if (file.size !== undef) {
1041
+ // We calculate totals based on original file size
1042
+ total.size += file.origSize;
1043
+
1044
+ // Since we cannot predict file size after resize, we do opposite and
1045
+ // interpolate loaded amount to match magnitude of total
1046
+ loaded = file.loaded * file.origSize / file.size;
1047
+
1048
+ if (!file.completeTimestamp || file.completeTimestamp > startTime) {
1049
+ loadedDuringCurrentSession += loaded;
1050
+ }
1051
+
1052
+ total.loaded += loaded;
1053
+ } else {
1054
+ total.size = undef;
1055
+ }
1056
+
1057
+ if (file.status == plupload.DONE) {
1058
+ total.uploaded++;
1059
+ } else if (file.status == plupload.FAILED) {
1060
+ total.failed++;
1061
+ } else {
1062
+ total.queued++;
1063
+ }
1064
+ }
1065
+
1066
+ // If we couldn't calculate a total file size then use the number of files to calc percent
1067
+ if (total.size === undef) {
1068
+ total.percent = files.length > 0 ? Math.ceil(total.uploaded / files.length * 100) : 0;
1069
+ } else {
1070
+ total.bytesPerSec = Math.ceil(loadedDuringCurrentSession / ((+new Date() - startTime || 1) / 1000.0));
1071
+ total.percent = total.size > 0 ? Math.ceil(total.loaded / total.size * 100) : 0;
1072
+ }
1073
+ }
1074
+
1075
+
1076
+ function getRUID() {
1077
+ var ctrl = fileInputs[0] || fileDrops[0];
1078
+ if (ctrl) {
1079
+ return ctrl.getRuntime().uid;
1080
+ }
1081
+ return false;
1082
+ }
1083
+
1084
+
1085
+ function bindEventListeners() {
1086
+ this.bind('FilesAdded FilesRemoved', function(up) {
1087
+ up.trigger('QueueChanged');
1088
+ up.refresh();
1089
+ });
1090
+
1091
+ this.bind('CancelUpload', onCancelUpload);
1092
+
1093
+ this.bind('BeforeUpload', onBeforeUpload);
1094
+
1095
+ this.bind('UploadFile', onUploadFile);
1096
+
1097
+ this.bind('UploadProgress', onUploadProgress);
1098
+
1099
+ this.bind('StateChanged', onStateChanged);
1100
+
1101
+ this.bind('QueueChanged', calc);
1102
+
1103
+ this.bind('Error', onError);
1104
+
1105
+ this.bind('FileUploaded', onFileUploaded);
1106
+
1107
+ this.bind('Destroy', onDestroy);
1108
+ }
1109
+
1110
+
1111
+ function initControls(settings, cb) {
1112
+ var self = this, inited = 0, queue = [];
1113
+
1114
+ // common settings
1115
+ var options = {
1116
+ runtime_order: settings.runtimes,
1117
+ required_caps: settings.required_features,
1118
+ preferred_caps: preferred_caps,
1119
+ swf_url: settings.flash_swf_url,
1120
+ xap_url: settings.silverlight_xap_url
1121
+ };
1122
+
1123
+ // add runtime specific options if any
1124
+ plupload.each(settings.runtimes.split(/\s*,\s*/), function(runtime) {
1125
+ if (settings[runtime]) {
1126
+ options[runtime] = settings[runtime];
1127
+ }
1128
+ });
1129
+
1130
+ // initialize file pickers - there can be many
1131
+ if (settings.browse_button) {
1132
+ plupload.each(settings.browse_button, function(el) {
1133
+ queue.push(function(cb) {
1134
+ var fileInput = new o.file.FileInput(plupload.extend({}, options, {
1135
+ accept: settings.filters.mime_types,
1136
+ name: settings.file_data_name,
1137
+ multiple: settings.multi_selection,
1138
+ container: settings.container,
1139
+ browse_button: el
1140
+ }));
1141
+
1142
+ fileInput.onready = function() {
1143
+ var info = Runtime.getInfo(this.ruid);
1144
+
1145
+ // for backward compatibility
1146
+ plupload.extend(self.features, {
1147
+ chunks: info.can('slice_blob'),
1148
+ multipart: info.can('send_multipart'),
1149
+ multi_selection: info.can('select_multiple')
1150
+ });
1151
+
1152
+ inited++;
1153
+ fileInputs.push(this);
1154
+ cb();
1155
+ };
1156
+
1157
+ fileInput.onchange = function() {
1158
+ self.addFile(this.files);
1159
+ };
1160
+
1161
+ fileInput.bind('mouseenter mouseleave mousedown mouseup', function(e) {
1162
+ if (!disabled) {
1163
+ if (settings.browse_button_hover) {
1164
+ if ('mouseenter' === e.type) {
1165
+ plupload.addClass(el, settings.browse_button_hover);
1166
+ } else if ('mouseleave' === e.type) {
1167
+ plupload.removeClass(el, settings.browse_button_hover);
1168
+ }
1169
+ }
1170
+
1171
+ if (settings.browse_button_active) {
1172
+ if ('mousedown' === e.type) {
1173
+ plupload.addClass(el, settings.browse_button_active);
1174
+ } else if ('mouseup' === e.type) {
1175
+ plupload.removeClass(el, settings.browse_button_active);
1176
+ }
1177
+ }
1178
+ }
1179
+ });
1180
+
1181
+ fileInput.bind('mousedown', function() {
1182
+ self.trigger('Browse');
1183
+ });
1184
+
1185
+ fileInput.bind('error runtimeerror', function() {
1186
+ fileInput = null;
1187
+ cb();
1188
+ });
1189
+
1190
+ fileInput.init();
1191
+ });
1192
+ });
1193
+ }
1194
+
1195
+ // initialize drop zones
1196
+ if (settings.drop_element) {
1197
+ plupload.each(settings.drop_element, function(el) {
1198
+ queue.push(function(cb) {
1199
+ var fileDrop = new o.file.FileDrop(plupload.extend({}, options, {
1200
+ drop_zone: el
1201
+ }));
1202
+
1203
+ fileDrop.onready = function() {
1204
+ var info = Runtime.getInfo(this.ruid);
1205
+
1206
+ // for backward compatibility
1207
+ plupload.extend(self.features, {
1208
+ chunks: info.can('slice_blob'),
1209
+ multipart: info.can('send_multipart'),
1210
+ dragdrop: info.can('drag_and_drop')
1211
+ });
1212
+
1213
+ inited++;
1214
+ fileDrops.push(this);
1215
+ cb();
1216
+ };
1217
+
1218
+ fileDrop.ondrop = function() {
1219
+ self.addFile(this.files);
1220
+ };
1221
+
1222
+ fileDrop.bind('error runtimeerror', function() {
1223
+ fileDrop = null;
1224
+ cb();
1225
+ });
1226
+
1227
+ fileDrop.init();
1228
+ });
1229
+ });
1230
+ }
1231
+
1232
+
1233
+ plupload.inSeries(queue, function() {
1234
+ if (typeof(cb) === 'function') {
1235
+ cb(inited);
1236
+ }
1237
+ });
1238
+ }
1239
+
1240
+
1241
+ function resizeImage(blob, params, runtimeOptions, cb) {
1242
+ var img = new o.image.Image();
1243
+
1244
+ try {
1245
+ img.onload = function() {
1246
+ // no manipulation required if...
1247
+ if (params.width > this.width &&
1248
+ params.height > this.height &&
1249
+ params.quality === undef &&
1250
+ params.preserve_headers &&
1251
+ !params.crop
1252
+ ) {
1253
+ this.destroy();
1254
+ cb(blob);
1255
+ } else {
1256
+ // otherwise downsize
1257
+ img.downsize(params.width, params.height, params.crop, params.preserve_headers);
1258
+ }
1259
+ };
1260
+
1261
+ img.onresize = function() {
1262
+ var resizedBlob = this.getAsBlob(blob.type, params.quality);
1263
+ this.destroy();
1264
+ cb(resizedBlob);
1265
+ };
1266
+
1267
+ img.bind('error runtimeerror', function() {
1268
+ this.destroy();
1269
+ cb(blob);
1270
+ });
1271
+
1272
+ img.load(blob, runtimeOptions);
1273
+ } catch(ex) {
1274
+ cb(blob);
1275
+ }
1276
+ }
1277
+
1278
+
1279
+ function setOption(option, value, init) {
1280
+ var self = this, reinitRequired = false;
1281
+
1282
+ function _setOption(option, value, init) {
1283
+ var oldValue = settings[option];
1284
+
1285
+ switch (option) {
1286
+ case 'max_file_size':
1287
+ if (option === 'max_file_size') {
1288
+ settings.max_file_size = settings.filters.max_file_size = value;
1289
+ }
1290
+ break;
1291
+
1292
+ case 'chunk_size':
1293
+ if (value = plupload.parseSize(value)) {
1294
+ settings[option] = value;
1295
+ settings.send_file_name = true;
1296
+ }
1297
+ break;
1298
+
1299
+ case 'multipart':
1300
+ settings[option] = value;
1301
+ if (!value) {
1302
+ settings.send_file_name = true;
1303
+ }
1304
+ break;
1305
+
1306
+ case 'http_method':
1307
+ settings[option] = value.toUpperCase() === 'PUT' ? 'PUT' : 'POST';
1308
+ break;
1309
+
1310
+ case 'unique_names':
1311
+ settings[option] = value;
1312
+ if (value) {
1313
+ settings.send_file_name = true;
1314
+ }
1315
+ break;
1316
+
1317
+ case 'filters':
1318
+ // for sake of backward compatibility
1319
+ if (plupload.typeOf(value) === 'array') {
1320
+ value = {
1321
+ mime_types: value
1322
+ };
1323
+ }
1324
+
1325
+ if (init) {
1326
+ plupload.extend(settings.filters, value);
1327
+ } else {
1328
+ settings.filters = value;
1329
+ }
1330
+
1331
+ // if file format filters are being updated, regenerate the matching expressions
1332
+ if (value.mime_types) {
1333
+ if (plupload.typeOf(value.mime_types) === 'string') {
1334
+ value.mime_types = o.core.utils.Mime.mimes2extList(value.mime_types);
1335
+ }
1336
+
1337
+ value.mime_types.regexp = (function(filters) {
1338
+ var extensionsRegExp = [];
1339
+
1340
+ plupload.each(filters, function(filter) {
1341
+ plupload.each(filter.extensions.split(/,/), function(ext) {
1342
+ if (/^\s*\*\s*$/.test(ext)) {
1343
+ extensionsRegExp.push('\\.*');
1344
+ } else {
1345
+ extensionsRegExp.push('\\.' + ext.replace(new RegExp('[' + ('/^$.*+?|()[]{}\\'.replace(/./g, '\\$&')) + ']', 'g'), '\\$&'));
1346
+ }
1347
+ });
1348
+ });
1349
+
1350
+ return new RegExp('(' + extensionsRegExp.join('|') + ')$', 'i');
1351
+ }(value.mime_types));
1352
+
1353
+ settings.filters.mime_types = value.mime_types;
1354
+ }
1355
+ break;
1356
+
1357
+ case 'resize':
1358
+ if (value) {
1359
+ settings.resize = plupload.extend({
1360
+ preserve_headers: true,
1361
+ crop: false
1362
+ }, value);
1363
+ } else {
1364
+ settings.resize = false;
1365
+ }
1366
+ break;
1367
+
1368
+ case 'prevent_duplicates':
1369
+ settings.prevent_duplicates = settings.filters.prevent_duplicates = !!value;
1370
+ break;
1371
+
1372
+ // options that require reinitialisation
1373
+ case 'container':
1374
+ case 'browse_button':
1375
+ case 'drop_element':
1376
+ value = 'container' === option
1377
+ ? plupload.get(value)
1378
+ : plupload.getAll(value)
1379
+ ;
1380
+
1381
+ case 'runtimes':
1382
+ case 'multi_selection':
1383
+ case 'flash_swf_url':
1384
+ case 'silverlight_xap_url':
1385
+ settings[option] = value;
1386
+ if (!init) {
1387
+ reinitRequired = true;
1388
+ }
1389
+ break;
1390
+
1391
+ default:
1392
+ settings[option] = value;
1393
+ }
1394
+
1395
+ if (!init) {
1396
+ self.trigger('OptionChanged', option, value, oldValue);
1397
+ }
1398
+ }
1399
+
1400
+ if (typeof(option) === 'object') {
1401
+ plupload.each(option, function(value, option) {
1402
+ _setOption(option, value, init);
1403
+ });
1404
+ } else {
1405
+ _setOption(option, value, init);
1406
+ }
1407
+
1408
+ if (init) {
1409
+ // Normalize the list of required capabilities
1410
+ settings.required_features = normalizeCaps(plupload.extend({}, settings));
1411
+
1412
+ // Come up with the list of capabilities that can affect default mode in a multi-mode runtimes
1413
+ preferred_caps = normalizeCaps(plupload.extend({}, settings, {
1414
+ required_features: true
1415
+ }));
1416
+ } else if (reinitRequired) {
1417
+ self.trigger('Destroy');
1418
+
1419
+ initControls.call(self, settings, function(inited) {
1420
+ if (inited) {
1421
+ self.runtime = Runtime.getInfo(getRUID()).type;
1422
+ self.trigger('Init', { runtime: self.runtime });
1423
+ self.trigger('PostInit');
1424
+ } else {
1425
+ self.trigger('Error', {
1426
+ code : plupload.INIT_ERROR,
1427
+ message : plupload.translate('Init error.')
1428
+ });
1429
+ }
1430
+ });
1431
+ }
1432
+ }
1433
+
1434
+
1435
+ // Internal event handlers
1436
+ function onBeforeUpload(up, file) {
1437
+ // Generate unique target filenames
1438
+ if (up.settings.unique_names) {
1439
+ var matches = file.name.match(/\.([^.]+)$/), ext = "part";
1440
+ if (matches) {
1441
+ ext = matches[1];
1442
+ }
1443
+ file.target_name = file.id + '.' + ext;
1444
+ }
1445
+ }
1446
+
1447
+
1448
+ function onUploadFile(up, file) {
1449
+ var url = up.settings.url;
1450
+ var chunkSize = up.settings.chunk_size;
1451
+ var retries = up.settings.max_retries;
1452
+ var features = up.features;
1453
+ var offset = 0;
1454
+ var blob;
1455
+
1456
+ var runtimeOptions = {
1457
+ runtime_order: up.settings.runtimes,
1458
+ required_caps: up.settings.required_features,
1459
+ preferred_caps: preferred_caps,
1460
+ swf_url: up.settings.flash_swf_url,
1461
+ xap_url: up.settings.silverlight_xap_url
1462
+ };
1463
+
1464
+ // make sure we start at a predictable offset
1465
+ if (file.loaded) {
1466
+ offset = file.loaded = chunkSize ? chunkSize * Math.floor(file.loaded / chunkSize) : 0;
1467
+ }
1468
+
1469
+ function handleError() {
1470
+ if (retries-- > 0) {
1471
+ delay(uploadNextChunk, 1000);
1472
+ } else {
1473
+ file.loaded = offset; // reset all progress
1474
+
1475
+ up.trigger('Error', {
1476
+ code : plupload.HTTP_ERROR,
1477
+ message : plupload.translate('HTTP Error.'),
1478
+ file : file,
1479
+ response : xhr.responseText,
1480
+ status : xhr.status,
1481
+ responseHeaders: xhr.getAllResponseHeaders()
1482
+ });
1483
+ }
1484
+ }
1485
+
1486
+ function uploadNextChunk() {
1487
+ var chunkBlob, args = {}, curChunkSize;
1488
+
1489
+ // make sure that file wasn't cancelled and upload is not stopped in general
1490
+ if (file.status !== plupload.UPLOADING || up.state === plupload.STOPPED) {
1491
+ return;
1492
+ }
1493
+
1494
+ // send additional 'name' parameter only if required
1495
+ if (up.settings.send_file_name) {
1496
+ args.name = file.target_name || file.name;
1497
+ }
1498
+
1499
+ if (chunkSize && features.chunks && blob.size > chunkSize) { // blob will be of type string if it was loaded in memory
1500
+ curChunkSize = Math.min(chunkSize, blob.size - offset);
1501
+ chunkBlob = blob.slice(offset, offset + curChunkSize);
1502
+ } else {
1503
+ curChunkSize = blob.size;
1504
+ chunkBlob = blob;
1505
+ }
1506
+
1507
+ // If chunking is enabled add corresponding args, no matter if file is bigger than chunk or smaller
1508
+ if (chunkSize && features.chunks) {
1509
+ // Setup query string arguments
1510
+ if (up.settings.send_chunk_number) {
1511
+ args.chunk = Math.ceil(offset / chunkSize);
1512
+ args.chunks = Math.ceil(blob.size / chunkSize);
1513
+ } else { // keep support for experimental chunk format, just in case
1514
+ args.offset = offset;
1515
+ args.total = blob.size;
1516
+ }
1517
+ }
1518
+
1519
+ if (up.trigger('BeforeChunkUpload', file, args, chunkBlob, offset)) {
1520
+ uploadChunk(args, chunkBlob, curChunkSize);
1521
+ }
1522
+ }
1523
+
1524
+ function uploadChunk(args, chunkBlob, curChunkSize) {
1525
+ var formData;
1526
+
1527
+ xhr = new o.xhr.XMLHttpRequest();
1528
+
1529
+ // Do we have upload progress support
1530
+ if (xhr.upload) {
1531
+ xhr.upload.onprogress = function(e) {
1532
+ file.loaded = Math.min(file.size, offset + e.loaded);
1533
+ up.trigger('UploadProgress', file);
1534
+ };
1535
+ }
1536
+
1537
+ xhr.onload = function() {
1538
+ // check if upload made itself through
1539
+ if (xhr.status < 200 || xhr.status >= 400) {
1540
+ handleError();
1541
+ return;
1542
+ }
1543
+
1544
+ retries = up.settings.max_retries; // reset the counter
1545
+
1546
+ // Handle chunk response
1547
+ if (curChunkSize < blob.size) {
1548
+ chunkBlob.destroy();
1549
+
1550
+ offset += curChunkSize;
1551
+ file.loaded = Math.min(offset, blob.size);
1552
+
1553
+ up.trigger('ChunkUploaded', file, {
1554
+ offset : file.loaded,
1555
+ total : blob.size,
1556
+ response : xhr.responseText,
1557
+ status : xhr.status,
1558
+ responseHeaders: xhr.getAllResponseHeaders()
1559
+ });
1560
+
1561
+ // stock Android browser doesn't fire upload progress events, but in chunking mode we can fake them
1562
+ if (plupload.ua.browser === 'Android Browser') {
1563
+ // doesn't harm in general, but is not required anywhere else
1564
+ up.trigger('UploadProgress', file);
1565
+ }
1566
+ } else {
1567
+ file.loaded = file.size;
1568
+ }
1569
+
1570
+ chunkBlob = formData = null; // Free memory
1571
+
1572
+ // Check if file is uploaded
1573
+ if (!offset || offset >= blob.size) {
1574
+ // If file was modified, destory the copy
1575
+ if (file.size != file.origSize) {
1576
+ blob.destroy();
1577
+ blob = null;
1578
+ }
1579
+
1580
+ up.trigger('UploadProgress', file);
1581
+
1582
+ file.status = plupload.DONE;
1583
+ file.completeTimestamp = +new Date();
1584
+
1585
+ up.trigger('FileUploaded', file, {
1586
+ response : xhr.responseText,
1587
+ status : xhr.status,
1588
+ responseHeaders: xhr.getAllResponseHeaders()
1589
+ });
1590
+ } else {
1591
+ // Still chunks left
1592
+ delay(uploadNextChunk, 1); // run detached, otherwise event handlers interfere
1593
+ }
1594
+ };
1595
+
1596
+ xhr.onerror = function() {
1597
+ handleError();
1598
+ };
1599
+
1600
+ xhr.onloadend = function() {
1601
+ this.destroy();
1602
+ };
1603
+
1604
+ // Build multipart request
1605
+ if (up.settings.multipart && features.multipart) {
1606
+ xhr.open(up.settings.http_method, url, true);
1607
+
1608
+ // Set custom headers
1609
+ plupload.each(up.settings.headers, function(value, name) {
1610
+ xhr.setRequestHeader(name, value);
1611
+ });
1612
+
1613
+ formData = new o.xhr.FormData();
1614
+
1615
+ // Add multipart params
1616
+ plupload.each(plupload.extend(args, up.settings.multipart_params), function(value, name) {
1617
+ formData.append(name, value);
1618
+ });
1619
+
1620
+ // Add file and send it
1621
+ formData.append(up.settings.file_data_name, chunkBlob);
1622
+ xhr.send(formData, runtimeOptions);
1623
+ } else {
1624
+ // if no multipart, send as binary stream
1625
+ url = plupload.buildUrl(up.settings.url, plupload.extend(args, up.settings.multipart_params));
1626
+
1627
+ xhr.open(up.settings.http_method, url, true);
1628
+
1629
+ // Set custom headers
1630
+ plupload.each(up.settings.headers, function(value, name) {
1631
+ xhr.setRequestHeader(name, value);
1632
+ });
1633
+
1634
+ // do not set Content-Type, if it was defined previously (see #1203)
1635
+ if (!xhr.hasRequestHeader('Content-Type')) {
1636
+ xhr.setRequestHeader('Content-Type', 'application/octet-stream'); // Binary stream header
1637
+ }
1638
+
1639
+ xhr.send(chunkBlob, runtimeOptions);
1640
+ }
1641
+ }
1642
+
1643
+
1644
+ blob = file.getSource();
1645
+
1646
+ // Start uploading chunks
1647
+ if (!plupload.isEmptyObj(up.settings.resize) && plupload.inArray(blob.type, ['image/jpeg', 'image/png']) !== -1) {
1648
+ // Resize if required
1649
+ resizeImage(blob, up.settings.resize, runtimeOptions, function(resizedBlob) {
1650
+ blob = resizedBlob;
1651
+ file.size = resizedBlob.size;
1652
+ uploadNextChunk();
1653
+ });
1654
+ } else {
1655
+ uploadNextChunk();
1656
+ }
1657
+ }
1658
+
1659
+
1660
+ function onUploadProgress(up, file) {
1661
+ calcFile(file);
1662
+ }
1663
+
1664
+
1665
+ function onStateChanged(up) {
1666
+ if (up.state == plupload.STARTED) {
1667
+ // Get start time to calculate bps
1668
+ startTime = (+new Date());
1669
+ } else if (up.state == plupload.STOPPED) {
1670
+ // Reset currently uploading files
1671
+ for (var i = up.files.length - 1; i >= 0; i--) {
1672
+ if (up.files[i].status == plupload.UPLOADING) {
1673
+ up.files[i].status = plupload.QUEUED;
1674
+ calc();
1675
+ }
1676
+ }
1677
+ }
1678
+ }
1679
+
1680
+
1681
+ function onCancelUpload() {
1682
+ if (xhr) {
1683
+ xhr.abort();
1684
+ }
1685
+ }
1686
+
1687
+
1688
+ function onFileUploaded(up) {
1689
+ calc();
1690
+
1691
+ // Upload next file but detach it from the error event
1692
+ // since other custom listeners might want to stop the queue
1693
+ delay(function() {
1694
+ uploadNext.call(up);
1695
+ }, 1);
1696
+ }
1697
+
1698
+
1699
+ function onError(up, err) {
1700
+ if (err.code === plupload.INIT_ERROR) {
1701
+ up.destroy();
1702
+ }
1703
+ // Set failed status if an error occured on a file
1704
+ else if (err.code === plupload.HTTP_ERROR) {
1705
+ err.file.status = plupload.FAILED;
1706
+ err.file.completeTimestamp = +new Date();
1707
+ calcFile(err.file);
1708
+
1709
+ // Upload next file but detach it from the error event
1710
+ // since other custom listeners might want to stop the queue
1711
+ if (up.state == plupload.STARTED) { // upload in progress
1712
+ up.trigger('CancelUpload');
1713
+ delay(function() {
1714
+ uploadNext.call(up);
1715
+ }, 1);
1716
+ }
1717
+ }
1718
+ }
1719
+
1720
+
1721
+ function onDestroy(up) {
1722
+ up.stop();
1723
+
1724
+ // Purge the queue
1725
+ plupload.each(files, function(file) {
1726
+ file.destroy();
1727
+ });
1728
+ files = [];
1729
+
1730
+ if (fileInputs.length) {
1731
+ plupload.each(fileInputs, function(fileInput) {
1732
+ fileInput.destroy();
1733
+ });
1734
+ fileInputs = [];
1735
+ }
1736
+
1737
+ if (fileDrops.length) {
1738
+ plupload.each(fileDrops, function(fileDrop) {
1739
+ fileDrop.destroy();
1740
+ });
1741
+ fileDrops = [];
1742
+ }
1743
+
1744
+ preferred_caps = {};
1745
+ disabled = false;
1746
+ startTime = xhr = null;
1747
+ total.reset();
1748
+ }
1749
+
1750
+
1751
+ // Default settings
1752
+ settings = {
1753
+ chunk_size: 0,
1754
+ file_data_name: 'file',
1755
+ filters: {
1756
+ mime_types: [],
1757
+ max_file_size: 0,
1758
+ prevent_duplicates: false,
1759
+ prevent_empty: true
1760
+ },
1761
+ flash_swf_url: 'js/Moxie.swf',
1762
+ http_method: 'POST',
1763
+ max_retries: 0,
1764
+ multipart: true,
1765
+ multi_selection: true,
1766
+ resize: false,
1767
+ runtimes: Runtime.order,
1768
+ send_file_name: true,
1769
+ send_chunk_number: true,
1770
+ silverlight_xap_url: 'js/Moxie.xap'
1771
+ };
1772
+
1773
+
1774
+ setOption.call(this, options, null, true);
1775
+
1776
+ // Inital total state
1777
+ total = new plupload.QueueProgress();
1778
+
1779
+ // Add public methods
1780
+ plupload.extend(this, {
1781
+
1782
+ /**
1783
+ * Unique id for the Uploader instance.
1784
+ *
1785
+ * @property id
1786
+ * @type String
1787
+ */
1788
+ id : uid,
1789
+ uid : uid, // mOxie uses this to differentiate between event targets
1790
+
1791
+ /**
1792
+ * Current state of the total uploading progress. This one can either be plupload.STARTED or plupload.STOPPED.
1793
+ * These states are controlled by the stop/start methods. The default value is STOPPED.
1794
+ *
1795
+ * @property state
1796
+ * @type Number
1797
+ */
1798
+ state : plupload.STOPPED,
1799
+
1800
+ /**
1801
+ * Map of features that are available for the uploader runtime. Features will be filled
1802
+ * before the init event is called, these features can then be used to alter the UI for the end user.
1803
+ * Some of the current features that might be in this map is: dragdrop, chunks, jpgresize, pngresize.
1804
+ *
1805
+ * @property features
1806
+ * @type Object
1807
+ */
1808
+ features : {},
1809
+
1810
+ /**
1811
+ * Current runtime name.
1812
+ *
1813
+ * @property runtime
1814
+ * @type String
1815
+ */
1816
+ runtime : null,
1817
+
1818
+ /**
1819
+ * Current upload queue, an array of File instances.
1820
+ *
1821
+ * @property files
1822
+ * @type Array
1823
+ * @see plupload.File
1824
+ */
1825
+ files : files,
1826
+
1827
+ /**
1828
+ * Object with name/value settings.
1829
+ *
1830
+ * @property settings
1831
+ * @type Object
1832
+ */
1833
+ settings : settings,
1834
+
1835
+ /**
1836
+ * Total progess information. How many files has been uploaded, total percent etc.
1837
+ *
1838
+ * @property total
1839
+ * @type plupload.QueueProgress
1840
+ */
1841
+ total : total,
1842
+
1843
+
1844
+ /**
1845
+ * Initializes the Uploader instance and adds internal event listeners.
1846
+ *
1847
+ * @method init
1848
+ */
1849
+ init : function() {
1850
+ var self = this, opt, preinitOpt, err;
1851
+
1852
+ preinitOpt = self.getOption('preinit');
1853
+ if (typeof(preinitOpt) == "function") {
1854
+ preinitOpt(self);
1855
+ } else {
1856
+ plupload.each(preinitOpt, function(func, name) {
1857
+ self.bind(name, func);
1858
+ });
1859
+ }
1860
+
1861
+ bindEventListeners.call(self);
1862
+
1863
+ // Check for required options
1864
+ plupload.each(['container', 'browse_button', 'drop_element'], function(el) {
1865
+ if (self.getOption(el) === null) {
1866
+ err = {
1867
+ code : plupload.INIT_ERROR,
1868
+ message : plupload.sprintf(plupload.translate("%s specified, but cannot be found."), el)
1869
+ }
1870
+ return false;
1871
+ }
1872
+ });
1873
+
1874
+ if (err) {
1875
+ return self.trigger('Error', err);
1876
+ }
1877
+
1878
+
1879
+ if (!settings.browse_button && !settings.drop_element) {
1880
+ return self.trigger('Error', {
1881
+ code : plupload.INIT_ERROR,
1882
+ message : plupload.translate("You must specify either browse_button or drop_element.")
1883
+ });
1884
+ }
1885
+
1886
+
1887
+ initControls.call(self, settings, function(inited) {
1888
+ var initOpt = self.getOption('init');
1889
+ if (typeof(initOpt) == "function") {
1890
+ initOpt(self);
1891
+ } else {
1892
+ plupload.each(initOpt, function(func, name) {
1893
+ self.bind(name, func);
1894
+ });
1895
+ }
1896
+
1897
+ if (inited) {
1898
+ self.runtime = Runtime.getInfo(getRUID()).type;
1899
+ self.trigger('Init', { runtime: self.runtime });
1900
+ self.trigger('PostInit');
1901
+ } else {
1902
+ self.trigger('Error', {
1903
+ code : plupload.INIT_ERROR,
1904
+ message : plupload.translate('Init error.')
1905
+ });
1906
+ }
1907
+ });
1908
+ },
1909
+
1910
+ /**
1911
+ * Set the value for the specified option(s).
1912
+ *
1913
+ * @method setOption
1914
+ * @since 2.1
1915
+ * @param {String|Object} option Name of the option to change or the set of key/value pairs
1916
+ * @param {Mixed} [value] Value for the option (is ignored, if first argument is object)
1917
+ */
1918
+ setOption: function(option, value) {
1919
+ setOption.call(this, option, value, !this.runtime); // until runtime not set we do not need to reinitialize
1920
+ },
1921
+
1922
+ /**
1923
+ * Get the value for the specified option or the whole configuration, if not specified.
1924
+ *
1925
+ * @method getOption
1926
+ * @since 2.1
1927
+ * @param {String} [option] Name of the option to get
1928
+ * @return {Mixed} Value for the option or the whole set
1929
+ */
1930
+ getOption: function(option) {
1931
+ if (!option) {
1932
+ return settings;
1933
+ }
1934
+ return settings[option];
1935
+ },
1936
+
1937
+ /**
1938
+ * Refreshes the upload instance by dispatching out a refresh event to all runtimes.
1939
+ * This would for example reposition flash/silverlight shims on the page.
1940
+ *
1941
+ * @method refresh
1942
+ */
1943
+ refresh : function() {
1944
+ if (fileInputs.length) {
1945
+ plupload.each(fileInputs, function(fileInput) {
1946
+ fileInput.trigger('Refresh');
1947
+ });
1948
+ }
1949
+ this.trigger('Refresh');
1950
+ },
1951
+
1952
+ /**
1953
+ * Starts uploading the queued files.
1954
+ *
1955
+ * @method start
1956
+ */
1957
+ start : function() {
1958
+ if (this.state != plupload.STARTED) {
1959
+ this.state = plupload.STARTED;
1960
+ this.trigger('StateChanged');
1961
+
1962
+ uploadNext.call(this);
1963
+ }
1964
+ },
1965
+
1966
+ /**
1967
+ * Stops the upload of the queued files.
1968
+ *
1969
+ * @method stop
1970
+ */
1971
+ stop : function() {
1972
+ if (this.state != plupload.STOPPED) {
1973
+ this.state = plupload.STOPPED;
1974
+ this.trigger('StateChanged');
1975
+ this.trigger('CancelUpload');
1976
+ }
1977
+ },
1978
+
1979
+
1980
+ /**
1981
+ * Disables/enables browse button on request.
1982
+ *
1983
+ * @method disableBrowse
1984
+ * @param {Boolean} disable Whether to disable or enable (default: true)
1985
+ */
1986
+ disableBrowse : function() {
1987
+ disabled = arguments[0] !== undef ? arguments[0] : true;
1988
+
1989
+ if (fileInputs.length) {
1990
+ plupload.each(fileInputs, function(fileInput) {
1991
+ fileInput.disable(disabled);
1992
+ });
1993
+ }
1994
+
1995
+ this.trigger('DisableBrowse', disabled);
1996
+ },
1997
+
1998
+ /**
1999
+ * Returns the specified file object by id.
2000
+ *
2001
+ * @method getFile
2002
+ * @param {String} id File id to look for.
2003
+ * @return {plupload.File} File object or undefined if it wasn't found;
2004
+ */
2005
+ getFile : function(id) {
2006
+ var i;
2007
+ for (i = files.length - 1; i >= 0; i--) {
2008
+ if (files[i].id === id) {
2009
+ return files[i];
2010
+ }
2011
+ }
2012
+ },
2013
+
2014
+ /**
2015
+ * Adds file to the queue programmatically. Can be native file, instance of Plupload.File,
2016
+ * instance of mOxie.File, input[type="file"] element, or array of these. Fires FilesAdded,
2017
+ * if any files were added to the queue. Otherwise nothing happens.
2018
+ *
2019
+ * @method addFile
2020
+ * @since 2.0
2021
+ * @param {plupload.File|mOxie.File|File|Node|Array} file File or files to add to the queue.
2022
+ * @param {String} [fileName] If specified, will be used as a name for the file
2023
+ */
2024
+ addFile : function(file, fileName) {
2025
+ var self = this
2026
+ , queue = []
2027
+ , filesAdded = []
2028
+ , ruid
2029
+ ;
2030
+
2031
+ function filterFile(file, cb) {
2032
+ var queue = [];
2033
+ plupload.each(self.settings.filters, function(rule, name) {
2034
+ if (fileFilters[name]) {
2035
+ queue.push(function(cb) {
2036
+ fileFilters[name].call(self, rule, file, function(res) {
2037
+ cb(!res);
2038
+ });
2039
+ });
2040
+ }
2041
+ });
2042
+ plupload.inSeries(queue, cb);
2043
+ }
2044
+
2045
+ /**
2046
+ * @method resolveFile
2047
+ * @private
2048
+ * @param {moxie.file.File|moxie.file.Blob|plupload.File|File|Blob|input[type="file"]} file
2049
+ */
2050
+ function resolveFile(file) {
2051
+ var type = plupload.typeOf(file);
2052
+
2053
+ // moxie.file.File
2054
+ if (file instanceof o.file.File) {
2055
+ if (!file.ruid && !file.isDetached()) {
2056
+ if (!ruid) { // weird case
2057
+ return false;
2058
+ }
2059
+ file.ruid = ruid;
2060
+ file.connectRuntime(ruid);
2061
+ }
2062
+ resolveFile(new plupload.File(file));
2063
+ }
2064
+ // moxie.file.Blob
2065
+ else if (file instanceof o.file.Blob) {
2066
+ resolveFile(file.getSource());
2067
+ file.destroy();
2068
+ }
2069
+ // plupload.File - final step for other branches
2070
+ else if (file instanceof plupload.File) {
2071
+ if (fileName) {
2072
+ file.name = fileName;
2073
+ }
2074
+
2075
+ queue.push(function(cb) {
2076
+ // run through the internal and user-defined filters, if any
2077
+ filterFile(file, function(err) {
2078
+ if (!err) {
2079
+ // make files available for the filters by updating the main queue directly
2080
+ files.push(file);
2081
+ // collect the files that will be passed to FilesAdded event
2082
+ filesAdded.push(file);
2083
+
2084
+ self.trigger("FileFiltered", file);
2085
+ }
2086
+ delay(cb, 1); // do not build up recursions or eventually we might hit the limits
2087
+ });
2088
+ });
2089
+ }
2090
+ // native File or blob
2091
+ else if (plupload.inArray(type, ['file', 'blob']) !== -1) {
2092
+ resolveFile(new o.file.File(null, file));
2093
+ }
2094
+ // input[type="file"]
2095
+ else if (type === 'node' && plupload.typeOf(file.files) === 'filelist') {
2096
+ // if we are dealing with input[type="file"]
2097
+ plupload.each(file.files, resolveFile);
2098
+ }
2099
+ // mixed array of any supported types (see above)
2100
+ else if (type === 'array') {
2101
+ fileName = null; // should never happen, but unset anyway to avoid funny situations
2102
+ plupload.each(file, resolveFile);
2103
+ }
2104
+ }
2105
+
2106
+ ruid = getRUID();
2107
+
2108
+ resolveFile(file);
2109
+
2110
+ if (queue.length) {
2111
+ plupload.inSeries(queue, function() {
2112
+ // if any files left after filtration, trigger FilesAdded
2113
+ if (filesAdded.length) {
2114
+ self.trigger("FilesAdded", filesAdded);
2115
+ }
2116
+ });
2117
+ }
2118
+ },
2119
+
2120
+ /**
2121
+ * Removes a specific file.
2122
+ *
2123
+ * @method removeFile
2124
+ * @param {plupload.File|String} file File to remove from queue.
2125
+ */
2126
+ removeFile : function(file) {
2127
+ var id = typeof(file) === 'string' ? file : file.id;
2128
+
2129
+ for (var i = files.length - 1; i >= 0; i--) {
2130
+ if (files[i].id === id) {
2131
+ return this.splice(i, 1)[0];
2132
+ }
2133
+ }
2134
+ },
2135
+
2136
+ /**
2137
+ * Removes part of the queue and returns the files removed. This will also trigger the
2138
+ * FilesRemoved and QueueChanged events.
2139
+ *
2140
+ * @method splice
2141
+ * @param {Number} [start=0] Start index to remove from.
2142
+ * @param {Number} [length] Number of files to remove (defaults to number of files in the queue).
2143
+ * @return {Array} Array of files that was removed.
2144
+ */
2145
+ splice : function(start, length) {
2146
+ // Splice and trigger events
2147
+ var removed = files.splice(start === undef ? 0 : start, length === undef ? files.length : length);
2148
+
2149
+ // if upload is in progress we need to stop it and restart after files are removed
2150
+ var restartRequired = false;
2151
+ if (this.state == plupload.STARTED) { // upload in progress
2152
+ plupload.each(removed, function(file) {
2153
+ if (file.status === plupload.UPLOADING) {
2154
+ restartRequired = true; // do not restart, unless file that is being removed is uploading
2155
+ return false;
2156
+ }
2157
+ });
2158
+
2159
+ if (restartRequired) {
2160
+ this.stop();
2161
+ }
2162
+ }
2163
+
2164
+ this.trigger("FilesRemoved", removed);
2165
+
2166
+ // Dispose any resources allocated by those files
2167
+ plupload.each(removed, function(file) {
2168
+ file.destroy();
2169
+ });
2170
+
2171
+ if (restartRequired) {
2172
+ this.start();
2173
+ }
2174
+
2175
+ return removed;
2176
+ },
2177
+
2178
+ /**
2179
+ Dispatches the specified event name and its arguments to all listeners.
2180
+
2181
+ @method trigger
2182
+ @param {String} name Event name to fire.
2183
+ @param {Object..} Multiple arguments to pass along to the listener functions.
2184
+ */
2185
+
2186
+ // override the parent method to match Plupload-like event logic
2187
+ dispatchEvent: function(type) {
2188
+ var list, args, result;
2189
+
2190
+ type = type.toLowerCase();
2191
+
2192
+ list = this.hasEventListener(type);
2193
+
2194
+ if (list) {
2195
+ // sort event list by priority
2196
+ list.sort(function(a, b) { return b.priority - a.priority; });
2197
+
2198
+ // first argument should be current plupload.Uploader instance
2199
+ args = [].slice.call(arguments);
2200
+ args.shift();
2201
+ args.unshift(this);
2202
+
2203
+ for (var i = 0; i < list.length; i++) {
2204
+ // Fire event, break chain if false is returned
2205
+ if (list[i].fn.apply(list[i].scope, args) === false) {
2206
+ return false;
2207
+ }
2208
+ }
2209
+ }
2210
+ return true;
2211
+ },
2212
+
2213
+ /**
2214
+ Check whether uploader has any listeners to the specified event.
2215
+
2216
+ @method hasEventListener
2217
+ @param {String} name Event name to check for.
2218
+ */
2219
+
2220
+
2221
+ /**
2222
+ Adds an event listener by name.
2223
+
2224
+ @method bind
2225
+ @param {String} name Event name to listen for.
2226
+ @param {function} fn Function to call ones the event gets fired.
2227
+ @param {Object} [scope] Optional scope to execute the specified function in.
2228
+ @param {Number} [priority=0] Priority of the event handler - handlers with higher priorities will be called first
2229
+ */
2230
+ bind: function(name, fn, scope, priority) {
2231
+ // adapt moxie EventTarget style to Plupload-like
2232
+ plupload.Uploader.prototype.bind.call(this, name, fn, priority, scope);
2233
+ },
2234
+
2235
+ /**
2236
+ Removes the specified event listener.
2237
+
2238
+ @method unbind
2239
+ @param {String} name Name of event to remove.
2240
+ @param {function} fn Function to remove from listener.
2241
+ */
2242
+
2243
+ /**
2244
+ Removes all event listeners.
2245
+
2246
+ @method unbindAll
2247
+ */
2248
+
2249
+
2250
+ /**
2251
+ * Destroys Plupload instance and cleans after itself.
2252
+ *
2253
+ * @method destroy
2254
+ */
2255
+ destroy : function() {
2256
+ this.trigger('Destroy');
2257
+ settings = total = null; // purge these exclusively
2258
+ this.unbindAll();
2259
+ }
2260
+ });
2261
+ };
2262
+
2263
+ plupload.Uploader.prototype = o.core.EventTarget.instance;
2264
+
2265
+ /**
2266
+ * Constructs a new file instance.
2267
+ *
2268
+ * @class File
2269
+ * @constructor
2270
+ *
2271
+ * @param {Object} file Object containing file properties
2272
+ * @param {String} file.name Name of the file.
2273
+ * @param {Number} file.size File size.
2274
+ */
2275
+ plupload.File = (function() {
2276
+ var filepool = {};
2277
+
2278
+ function PluploadFile(file) {
2279
+
2280
+ plupload.extend(this, {
2281
+
2282
+ /**
2283
+ * File id this is a globally unique id for the specific file.
2284
+ *
2285
+ * @property id
2286
+ * @type String
2287
+ */
2288
+ id: plupload.guid(),
2289
+
2290
+ /**
2291
+ * File name for example "myfile.gif".
2292
+ *
2293
+ * @property name
2294
+ * @type String
2295
+ */
2296
+ name: file.name || file.fileName,
2297
+
2298
+ /**
2299
+ * File type, `e.g image/jpeg`
2300
+ *
2301
+ * @property type
2302
+ * @type String
2303
+ */
2304
+ type: file.type || '',
2305
+
2306
+ /**
2307
+ * Relative path to the file inside a directory
2308
+ *
2309
+ * @property relativePath
2310
+ * @type String
2311
+ * @default ''
2312
+ */
2313
+ relativePath: file.relativePath || '',
2314
+
2315
+ /**
2316
+ * File size in bytes (may change after client-side manupilation).
2317
+ *
2318
+ * @property size
2319
+ * @type Number
2320
+ */
2321
+ size: file.fileSize || file.size,
2322
+
2323
+ /**
2324
+ * Original file size in bytes.
2325
+ *
2326
+ * @property origSize
2327
+ * @type Number
2328
+ */
2329
+ origSize: file.fileSize || file.size,
2330
+
2331
+ /**
2332
+ * Number of bytes uploaded of the files total size.
2333
+ *
2334
+ * @property loaded
2335
+ * @type Number
2336
+ */
2337
+ loaded: 0,
2338
+
2339
+ /**
2340
+ * Number of percentage uploaded of the file.
2341
+ *
2342
+ * @property percent
2343
+ * @type Number
2344
+ */
2345
+ percent: 0,
2346
+
2347
+ /**
2348
+ * Status constant matching the plupload states QUEUED, UPLOADING, FAILED, DONE.
2349
+ *
2350
+ * @property status
2351
+ * @type Number
2352
+ * @see plupload
2353
+ */
2354
+ status: plupload.QUEUED,
2355
+
2356
+ /**
2357
+ * Date of last modification.
2358
+ *
2359
+ * @property lastModifiedDate
2360
+ * @type {String}
2361
+ */
2362
+ lastModifiedDate: file.lastModifiedDate || (new Date()).toLocaleString(), // Thu Aug 23 2012 19:40:00 GMT+0400 (GET)
2363
+
2364
+
2365
+ /**
2366
+ * Set when file becomes plupload.DONE or plupload.FAILED. Is used to calculate proper plupload.QueueProgress.bytesPerSec.
2367
+ * @private
2368
+ * @property completeTimestamp
2369
+ * @type {Number}
2370
+ */
2371
+ completeTimestamp: 0,
2372
+
2373
+ /**
2374
+ * Returns native window.File object, when it's available.
2375
+ *
2376
+ * @method getNative
2377
+ * @return {window.File} or null, if plupload.File is of different origin
2378
+ */
2379
+ getNative: function() {
2380
+ var file = this.getSource().getSource();
2381
+ return plupload.inArray(plupload.typeOf(file), ['blob', 'file']) !== -1 ? file : null;
2382
+ },
2383
+
2384
+ /**
2385
+ * Returns mOxie.File - unified wrapper object that can be used across runtimes.
2386
+ *
2387
+ * @method getSource
2388
+ * @return {mOxie.File} or null
2389
+ */
2390
+ getSource: function() {
2391
+ if (!filepool[this.id]) {
2392
+ return null;
2393
+ }
2394
+ return filepool[this.id];
2395
+ },
2396
+
2397
+ /**
2398
+ * Destroys plupload.File object.
2399
+ *
2400
+ * @method destroy
2401
+ */
2402
+ destroy: function() {
2403
+ var src = this.getSource();
2404
+ if (src) {
2405
+ src.destroy();
2406
+ delete filepool[this.id];
2407
+ }
2408
+ }
2409
+ });
2410
+
2411
+ filepool[this.id] = file;
2412
+ }
2413
+
2414
+ return PluploadFile;
2415
+ }());
2416
+
2417
+
2418
+ /**
2419
+ * Constructs a queue progress.
2420
+ *
2421
+ * @class QueueProgress
2422
+ * @constructor
2423
+ */
2424
+ plupload.QueueProgress = function() {
2425
+ var self = this; // Setup alias for self to reduce code size when it's compressed
2426
+
2427
+ /**
2428
+ * Total queue file size.
2429
+ *
2430
+ * @property size
2431
+ * @type Number
2432
+ */
2433
+ self.size = 0;
2434
+
2435
+ /**
2436
+ * Total bytes uploaded.
2437
+ *
2438
+ * @property loaded
2439
+ * @type Number
2440
+ */
2441
+ self.loaded = 0;
2442
+
2443
+ /**
2444
+ * Number of files uploaded.
2445
+ *
2446
+ * @property uploaded
2447
+ * @type Number
2448
+ */
2449
+ self.uploaded = 0;
2450
+
2451
+ /**
2452
+ * Number of files failed to upload.
2453
+ *
2454
+ * @property failed
2455
+ * @type Number
2456
+ */
2457
+ self.failed = 0;
2458
+
2459
+ /**
2460
+ * Number of files yet to be uploaded.
2461
+ *
2462
+ * @property queued
2463
+ * @type Number
2464
+ */
2465
+ self.queued = 0;
2466
+
2467
+ /**
2468
+ * Total percent of the uploaded bytes.
2469
+ *
2470
+ * @property percent
2471
+ * @type Number
2472
+ */
2473
+ self.percent = 0;
2474
+
2475
+ /**
2476
+ * Bytes uploaded per second.
2477
+ *
2478
+ * @property bytesPerSec
2479
+ * @type Number
2480
+ */
2481
+ self.bytesPerSec = 0;
2482
+
2483
+ /**
2484
+ * Resets the progress to its initial values.
2485
+ *
2486
+ * @method reset
2487
+ */
2488
+ self.reset = function() {
2489
+ self.size = self.loaded = self.uploaded = self.failed = self.queued = self.percent = self.bytesPerSec = 0;
2490
+ };
2491
+ };
2492
+
2493
+ exports.plupload = plupload;
2494
+
2495
+ }(this, moxie));
2496
+
2497
+ }));