refinerycms-photo-gallery 0.1.2 → 0.2.0

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