editable_components 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +64 -0
  4. data/Rakefile +34 -0
  5. data/app/assets/config/editable_components_manifest.js +2 -0
  6. data/app/assets/fonts/editable_components/icomoon.eot +0 -0
  7. data/app/assets/fonts/editable_components/icomoon.svg +24 -0
  8. data/app/assets/fonts/editable_components/icomoon.ttf +0 -0
  9. data/app/assets/fonts/editable_components/icomoon.woff +0 -0
  10. data/app/assets/javascripts/editable_components/application.js +13 -0
  11. data/app/assets/javascripts/editable_components/dragula/dragula.css +22 -0
  12. data/app/assets/javascripts/editable_components/dragula/dragula.js +908 -0
  13. data/app/assets/javascripts/editable_components/dragula/dragula.min.css +1 -0
  14. data/app/assets/javascripts/editable_components/dragula/dragula.min.js +1 -0
  15. data/app/assets/javascripts/editable_components/dropzone/CONTRIBUTING.md +78 -0
  16. data/app/assets/javascripts/editable_components/dropzone/LICENSE +12 -0
  17. data/app/assets/javascripts/editable_components/dropzone/README.md +134 -0
  18. data/app/assets/javascripts/editable_components/dropzone/basic.css +39 -0
  19. data/app/assets/javascripts/editable_components/dropzone/dropzone-amd-module.js +1782 -0
  20. data/app/assets/javascripts/editable_components/dropzone/dropzone.css +388 -0
  21. data/app/assets/javascripts/editable_components/dropzone/dropzone.js +1767 -0
  22. data/app/assets/javascripts/editable_components/dropzone/min/basic.min.css +1 -0
  23. data/app/assets/javascripts/editable_components/dropzone/min/dropzone-amd-module.min.js +2 -0
  24. data/app/assets/javascripts/editable_components/dropzone/min/dropzone.min.css +1 -0
  25. data/app/assets/javascripts/editable_components/dropzone/min/dropzone.min.js +2 -0
  26. data/app/assets/javascripts/editable_components/main.js +280 -0
  27. data/app/assets/javascripts/editable_components/medium-editor/API.md +520 -0
  28. data/app/assets/javascripts/editable_components/medium-editor/CHANGES.md +1043 -0
  29. data/app/assets/javascripts/editable_components/medium-editor/CODE_OF_CONDUCT.md +13 -0
  30. data/app/assets/javascripts/editable_components/medium-editor/CONTRIBUTING.md +56 -0
  31. data/app/assets/javascripts/editable_components/medium-editor/CUSTOM-EVENTS.md +223 -0
  32. data/app/assets/javascripts/editable_components/medium-editor/LICENSE +36 -0
  33. data/app/assets/javascripts/editable_components/medium-editor/MAINTAINERS.md +33 -0
  34. data/app/assets/javascripts/editable_components/medium-editor/OPTIONS.md +663 -0
  35. data/app/assets/javascripts/editable_components/medium-editor/README.md +725 -0
  36. data/app/assets/javascripts/editable_components/medium-editor/UPGRADE-5.md +146 -0
  37. data/app/assets/javascripts/editable_components/medium-editor/medium-editor.css +230 -0
  38. data/app/assets/javascripts/editable_components/medium-editor/medium-editor.js +7876 -0
  39. data/app/assets/javascripts/editable_components/medium-editor/medium-editor.min.css +1 -0
  40. data/app/assets/javascripts/editable_components/medium-editor/medium-editor.min.js +4 -0
  41. data/app/assets/javascripts/editable_components/medium-editor/themes/beagle.css +78 -0
  42. data/app/assets/javascripts/editable_components/medium-editor/themes/beagle.min.css +1 -0
  43. data/app/assets/javascripts/editable_components/medium-editor/themes/bootstrap.css +67 -0
  44. data/app/assets/javascripts/editable_components/medium-editor/themes/bootstrap.min.css +1 -0
  45. data/app/assets/javascripts/editable_components/medium-editor/themes/default.css +63 -0
  46. data/app/assets/javascripts/editable_components/medium-editor/themes/default.min.css +1 -0
  47. data/app/assets/javascripts/editable_components/medium-editor/themes/flat.css +58 -0
  48. data/app/assets/javascripts/editable_components/medium-editor/themes/flat.min.css +1 -0
  49. data/app/assets/javascripts/editable_components/medium-editor/themes/mani.css +57 -0
  50. data/app/assets/javascripts/editable_components/medium-editor/themes/mani.min.css +1 -0
  51. data/app/assets/javascripts/editable_components/medium-editor/themes/roman.css +58 -0
  52. data/app/assets/javascripts/editable_components/medium-editor/themes/roman.min.css +1 -0
  53. data/app/assets/javascripts/editable_components/medium-editor/themes/tim.css +67 -0
  54. data/app/assets/javascripts/editable_components/medium-editor/themes/tim.min.css +1 -0
  55. data/app/assets/javascripts/editable_components/sizzle/sizzle.js +2272 -0
  56. data/app/assets/javascripts/editable_components/sizzle/sizzle.min.js +3 -0
  57. data/app/assets/javascripts/editable_components/sizzle/sizzle.min.map +1 -0
  58. data/app/assets/javascripts/editable_components/vue/README.md +124 -0
  59. data/app/assets/javascripts/editable_components/vue/vue.common.js +9320 -0
  60. data/app/assets/javascripts/editable_components/vue/vue.common.min.js +7 -0
  61. data/app/assets/javascripts/editable_components/vue/vue.esm.js +9318 -0
  62. data/app/assets/javascripts/editable_components/vue/vue.js +9316 -0
  63. data/app/assets/javascripts/editable_components/vue/vue.min.js +8 -0
  64. data/app/assets/javascripts/editable_components/vue/vue.runtime.common.js +6831 -0
  65. data/app/assets/javascripts/editable_components/vue/vue.runtime.esm.js +6829 -0
  66. data/app/assets/javascripts/editable_components/vue/vue.runtime.js +6827 -0
  67. data/app/assets/javascripts/editable_components/vue/vue.runtime.min.js +7 -0
  68. data/app/assets/stylesheets/editable_components/application.sass +65 -0
  69. data/app/assets/stylesheets/editable_components/blaze/blaze.colors.min.css +1 -0
  70. data/app/assets/stylesheets/editable_components/blaze/blaze.min.css +1 -0
  71. data/app/assets/stylesheets/editable_components/blaze/components.addresses.min.css +1 -0
  72. data/app/assets/stylesheets/editable_components/blaze/components.alerts.min.css +1 -0
  73. data/app/assets/stylesheets/editable_components/blaze/components.avatars.min.css +1 -0
  74. data/app/assets/stylesheets/editable_components/blaze/components.badges.min.css +1 -0
  75. data/app/assets/stylesheets/editable_components/blaze/components.breadcrumbs.min.css +1 -0
  76. data/app/assets/stylesheets/editable_components/blaze/components.bubbles.min.css +1 -0
  77. data/app/assets/stylesheets/editable_components/blaze/components.buttons.min.css +1 -0
  78. data/app/assets/stylesheets/editable_components/blaze/components.calendars.min.css +1 -0
  79. data/app/assets/stylesheets/editable_components/blaze/components.cards.min.css +1 -0
  80. data/app/assets/stylesheets/editable_components/blaze/components.headings.min.css +1 -0
  81. data/app/assets/stylesheets/editable_components/blaze/components.hints.min.css +1 -0
  82. data/app/assets/stylesheets/editable_components/blaze/components.input-groups.min.css +1 -0
  83. data/app/assets/stylesheets/editable_components/blaze/components.inputs.min.css +1 -0
  84. data/app/assets/stylesheets/editable_components/blaze/components.links.min.css +1 -0
  85. data/app/assets/stylesheets/editable_components/blaze/components.lists.min.css +1 -0
  86. data/app/assets/stylesheets/editable_components/blaze/components.navs.min.css +1 -0
  87. data/app/assets/stylesheets/editable_components/blaze/components.overlays.min.css +1 -0
  88. data/app/assets/stylesheets/editable_components/blaze/components.pagination.min.css +1 -0
  89. data/app/assets/stylesheets/editable_components/blaze/components.progress.min.css +1 -0
  90. data/app/assets/stylesheets/editable_components/blaze/components.ranges.min.css +1 -0
  91. data/app/assets/stylesheets/editable_components/blaze/components.tables.min.css +1 -0
  92. data/app/assets/stylesheets/editable_components/blaze/components.tabs.min.css +1 -0
  93. data/app/assets/stylesheets/editable_components/blaze/components.tags.min.css +1 -0
  94. data/app/assets/stylesheets/editable_components/blaze/components.toggles.min.css +1 -0
  95. data/app/assets/stylesheets/editable_components/blaze/components.tooltips.min.css +1 -0
  96. data/app/assets/stylesheets/editable_components/blaze/components.trees.min.css +1 -0
  97. data/app/assets/stylesheets/editable_components/blaze/components.typography.min.css +1 -0
  98. data/app/assets/stylesheets/editable_components/blaze/generics.global.min.css +1 -0
  99. data/app/assets/stylesheets/editable_components/blaze/objects.containers.min.css +1 -0
  100. data/app/assets/stylesheets/editable_components/blaze/objects.drawers.min.css +1 -0
  101. data/app/assets/stylesheets/editable_components/blaze/objects.forms.min.css +1 -0
  102. data/app/assets/stylesheets/editable_components/blaze/objects.grid.min.css +1 -0
  103. data/app/assets/stylesheets/editable_components/blaze/objects.grid.responsive.min.css +1 -0
  104. data/app/assets/stylesheets/editable_components/blaze/objects.images.min.css +1 -0
  105. data/app/assets/stylesheets/editable_components/blaze/objects.media.min.css +1 -0
  106. data/app/assets/stylesheets/editable_components/blaze/objects.modals.min.css +1 -0
  107. data/app/assets/stylesheets/editable_components/blaze/objects.panels.min.css +1 -0
  108. data/app/assets/stylesheets/editable_components/blaze/themes/blaze.example.min.css +1 -0
  109. data/app/assets/stylesheets/editable_components/blaze/utilities.alignment.min.css +1 -0
  110. data/app/assets/stylesheets/editable_components/blaze/utilities.boxing.min.css +1 -0
  111. data/app/assets/stylesheets/editable_components/blaze/utilities.elevation.min.css +1 -0
  112. data/app/assets/stylesheets/editable_components/blaze/utilities.sizes.min.css +1 -0
  113. data/app/assets/stylesheets/editable_components/dragula/dragula.css +22 -0
  114. data/app/assets/stylesheets/editable_components/dragula/dragula.js +908 -0
  115. data/app/assets/stylesheets/editable_components/dragula/dragula.min.css +1 -0
  116. data/app/assets/stylesheets/editable_components/dragula/dragula.min.js +1 -0
  117. data/app/assets/stylesheets/editable_components/main.sass +225 -0
  118. data/app/assets/stylesheets/editable_components/medium-editor/API.md +520 -0
  119. data/app/assets/stylesheets/editable_components/medium-editor/CHANGES.md +1043 -0
  120. data/app/assets/stylesheets/editable_components/medium-editor/CODE_OF_CONDUCT.md +13 -0
  121. data/app/assets/stylesheets/editable_components/medium-editor/CONTRIBUTING.md +56 -0
  122. data/app/assets/stylesheets/editable_components/medium-editor/CUSTOM-EVENTS.md +223 -0
  123. data/app/assets/stylesheets/editable_components/medium-editor/LICENSE +36 -0
  124. data/app/assets/stylesheets/editable_components/medium-editor/MAINTAINERS.md +33 -0
  125. data/app/assets/stylesheets/editable_components/medium-editor/OPTIONS.md +663 -0
  126. data/app/assets/stylesheets/editable_components/medium-editor/README.md +725 -0
  127. data/app/assets/stylesheets/editable_components/medium-editor/UPGRADE-5.md +146 -0
  128. data/app/assets/stylesheets/editable_components/medium-editor/medium-editor.css +230 -0
  129. data/app/assets/stylesheets/editable_components/medium-editor/medium-editor.js +7876 -0
  130. data/app/assets/stylesheets/editable_components/medium-editor/medium-editor.min.css +1 -0
  131. data/app/assets/stylesheets/editable_components/medium-editor/medium-editor.min.js +4 -0
  132. data/app/assets/stylesheets/editable_components/medium-editor/themes/beagle.css +78 -0
  133. data/app/assets/stylesheets/editable_components/medium-editor/themes/beagle.min.css +1 -0
  134. data/app/assets/stylesheets/editable_components/medium-editor/themes/bootstrap.css +67 -0
  135. data/app/assets/stylesheets/editable_components/medium-editor/themes/bootstrap.min.css +1 -0
  136. data/app/assets/stylesheets/editable_components/medium-editor/themes/default.css +63 -0
  137. data/app/assets/stylesheets/editable_components/medium-editor/themes/default.min.css +1 -0
  138. data/app/assets/stylesheets/editable_components/medium-editor/themes/flat.css +58 -0
  139. data/app/assets/stylesheets/editable_components/medium-editor/themes/flat.min.css +1 -0
  140. data/app/assets/stylesheets/editable_components/medium-editor/themes/mani.css +57 -0
  141. data/app/assets/stylesheets/editable_components/medium-editor/themes/mani.min.css +1 -0
  142. data/app/assets/stylesheets/editable_components/medium-editor/themes/roman.css +58 -0
  143. data/app/assets/stylesheets/editable_components/medium-editor/themes/roman.min.css +1 -0
  144. data/app/assets/stylesheets/editable_components/medium-editor/themes/tim.css +67 -0
  145. data/app/assets/stylesheets/editable_components/medium-editor/themes/tim.min.css +1 -0
  146. data/app/controllers/editable_components/blocks_controller.rb +36 -0
  147. data/app/helpers/editable_components/application_helper.rb +4 -0
  148. data/app/jobs/editable_components/application_job.rb +4 -0
  149. data/app/mailers/editable_components/application_mailer.rb +6 -0
  150. data/app/models/editable_components/application_record.rb +5 -0
  151. data/app/models/editable_components/block.rb +176 -0
  152. data/app/models/editable_components/concerns/editable.rb +34 -0
  153. data/app/models/editable_components/item.rb +50 -0
  154. data/app/models/editable_components/item_boolean.rb +23 -0
  155. data/app/models/editable_components/item_datetime.rb +14 -0
  156. data/app/models/editable_components/item_file.rb +46 -0
  157. data/app/models/editable_components/item_float.rb +23 -0
  158. data/app/models/editable_components/item_hash.rb +16 -0
  159. data/app/models/editable_components/item_integer.rb +23 -0
  160. data/app/models/editable_components/item_string.rb +29 -0
  161. data/app/models/editable_components/item_text.rb +19 -0
  162. data/app/views/editable_components/_admin_toolbar.html.erb +105 -0
  163. data/app/views/editable_components/_block.html.erb +6 -0
  164. data/app/views/editable_components/_block_image.html.erb +6 -0
  165. data/app/views/editable_components/_block_multi_text.html.erb +7 -0
  166. data/app/views/editable_components/_block_slide.html.erb +6 -0
  167. data/app/views/editable_components/_block_slider.html.erb +7 -0
  168. data/app/views/editable_components/_block_text.html.erb +5 -0
  169. data/app/views/editable_components/_block_text_with_image.html.erb +12 -0
  170. data/app/views/editable_components/_blocks.html.erb +12 -0
  171. data/config/initializers/editable_components.rb +72 -0
  172. data/config/routes.rb +4 -0
  173. data/db/migrate/20170414173603_create_editable_components_blocks.rb +18 -0
  174. data/db/migrate/20170414173610_create_editable_components_items.rb +11 -0
  175. data/db/migrate/20170414173611_add_items_booleans.rb +5 -0
  176. data/db/migrate/20170414173612_add_items_datetimes.rb +5 -0
  177. data/db/migrate/20170414173613_add_items_files.rb +5 -0
  178. data/db/migrate/20170414173614_add_items_floats.rb +5 -0
  179. data/db/migrate/20170414173615_add_items_hashes.rb +5 -0
  180. data/db/migrate/20170414173616_add_items_integers.rb +5 -0
  181. data/db/migrate/20170414173617_add_items_strings.rb +5 -0
  182. data/db/migrate/20170414173618_add_items_texts.rb +5 -0
  183. data/lib/data/img1.jpg +0 -0
  184. data/lib/editable_components.rb +87 -0
  185. data/lib/editable_components/engine.rb +21 -0
  186. data/lib/editable_components/version.rb +3 -0
  187. data/lib/tasks/editable_components_tasks.rake +4 -0
  188. metadata +264 -0
@@ -0,0 +1 @@
1
+ .gu-mirror{position:fixed!important;margin:0!important;z-index:9999!important;opacity:.8;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";filter:alpha(opacity=80)}.gu-hide{display:none!important}.gu-unselectable{-webkit-user-select:none!important;-moz-user-select:none!important;-ms-user-select:none!important;user-select:none!important}.gu-transit{opacity:.2;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=20)";filter:alpha(opacity=20)}
@@ -0,0 +1 @@
1
+ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.dragula=e()}}(function(){return function e(n,t,r){function o(u,c){if(!t[u]){if(!n[u]){var a="function"==typeof require&&require;if(!c&&a)return a(u,!0);if(i)return i(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var l=t[u]={exports:{}};n[u][0].call(l.exports,function(e){var t=n[u][1][e];return o(t?t:e)},l,l.exports,e,n,t,r)}return t[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(e,n,t){"use strict";function r(e){var n=u[e];return n?n.lastIndex=0:u[e]=n=new RegExp(c+e+a,"g"),n}function o(e,n){var t=e.className;t.length?r(n).test(t)||(e.className+=" "+n):e.className=n}function i(e,n){e.className=e.className.replace(r(n)," ").trim()}var u={},c="(?:^|\\s)",a="(?:\\s|$)";n.exports={add:o,rm:i}},{}],2:[function(e,n,t){(function(t){"use strict";function r(e,n){function t(e){return-1!==le.containers.indexOf(e)||fe.isContainer(e)}function r(e){var n=e?"remove":"add";o(S,n,"mousedown",O),o(S,n,"mouseup",L)}function c(e){var n=e?"remove":"add";o(S,n,"mousemove",N)}function m(e){var n=e?"remove":"add";w[n](S,"selectstart",C),w[n](S,"click",C)}function h(){r(!0),L({})}function C(e){ce&&e.preventDefault()}function O(e){ne=e.clientX,te=e.clientY;var n=1!==i(e)||e.metaKey||e.ctrlKey;if(!n){var t=e.target,r=T(t);r&&(ce=r,c(),"mousedown"===e.type&&(p(t)?t.focus():e.preventDefault()))}}function N(e){if(ce){if(0===i(e))return void L({});if(void 0===e.clientX||e.clientX!==ne||void 0===e.clientY||e.clientY!==te){if(fe.ignoreInputTextSelection){var n=y("clientX",e),t=y("clientY",e),r=x.elementFromPoint(n,t);if(p(r))return}var o=ce;c(!0),m(),D(),B(o);var a=u(W);Z=y("pageX",e)-a.left,ee=y("pageY",e)-a.top,E.add(ie||W,"gu-transit"),K(),U(e)}}}function T(e){if(!(le.dragging&&J||t(e))){for(var n=e;v(e)&&t(v(e))===!1;){if(fe.invalid(e,n))return;if(e=v(e),!e)return}var r=v(e);if(r&&!fe.invalid(e,n)){var o=fe.moves(e,r,n,g(e));if(o)return{item:e,source:r}}}}function X(e){return!!T(e)}function Y(e){var n=T(e);n&&B(n)}function B(e){$(e.item,e.source)&&(ie=e.item.cloneNode(!0),le.emit("cloned",ie,e.item,"copy")),Q=e.source,W=e.item,re=oe=g(e.item),le.dragging=!0,le.emit("drag",W,Q)}function P(){return!1}function D(){if(le.dragging){var e=ie||W;M(e,v(e))}}function I(){ce=!1,c(!0),m(!0)}function L(e){if(I(),le.dragging){var n=ie||W,t=y("clientX",e),r=y("clientY",e),o=a(J,t,r),i=q(o,t,r);i&&(ie&&fe.copySortSource||!ie||i!==Q)?M(n,i):fe.removeOnSpill?R():A()}}function M(e,n){var t=v(e);ie&&fe.copySortSource&&n===Q&&t.removeChild(W),k(n)?le.emit("cancel",e,Q,Q):le.emit("drop",e,n,Q,oe),j()}function R(){if(le.dragging){var e=ie||W,n=v(e);n&&n.removeChild(e),le.emit(ie?"cancel":"remove",e,n,Q),j()}}function A(e){if(le.dragging){var n=arguments.length>0?e:fe.revertOnSpill,t=ie||W,r=v(t),o=k(r);o===!1&&n&&(ie?r&&r.removeChild(ie):Q.insertBefore(t,re)),o||n?le.emit("cancel",t,Q,Q):le.emit("drop",t,r,Q,oe),j()}}function j(){var e=ie||W;I(),z(),e&&E.rm(e,"gu-transit"),ue&&clearTimeout(ue),le.dragging=!1,ae&&le.emit("out",e,ae,Q),le.emit("dragend",e),Q=W=ie=re=oe=ue=ae=null}function k(e,n){var t;return t=void 0!==n?n:J?oe:g(ie||W),e===Q&&t===re}function q(e,n,r){function o(){var o=t(i);if(o===!1)return!1;var u=H(i,e),c=V(i,u,n,r),a=k(i,c);return a?!0:fe.accepts(W,i,Q,c)}for(var i=e;i&&!o();)i=v(i);return i}function U(e){function n(e){le.emit(e,f,ae,Q)}function t(){s&&n("over")}function r(){ae&&n("out")}if(J){e.preventDefault();var o=y("clientX",e),i=y("clientY",e),u=o-Z,c=i-ee;J.style.left=u+"px",J.style.top=c+"px";var f=ie||W,l=a(J,o,i),d=q(l,o,i),s=null!==d&&d!==ae;(s||null===d)&&(r(),ae=d,t());var p=v(f);if(d===Q&&ie&&!fe.copySortSource)return void(p&&p.removeChild(f));var m,h=H(d,l);if(null!==h)m=V(d,h,o,i);else{if(fe.revertOnSpill!==!0||ie)return void(ie&&p&&p.removeChild(f));m=re,d=Q}(null===m&&s||m!==f&&m!==g(f))&&(oe=m,d.insertBefore(f,m),le.emit("shadow",f,d,Q))}}function _(e){E.rm(e,"gu-hide")}function F(e){le.dragging&&E.add(e,"gu-hide")}function K(){if(!J){var e=W.getBoundingClientRect();J=W.cloneNode(!0),J.style.width=d(e)+"px",J.style.height=s(e)+"px",E.rm(J,"gu-transit"),E.add(J,"gu-mirror"),fe.mirrorContainer.appendChild(J),o(S,"add","mousemove",U),E.add(fe.mirrorContainer,"gu-unselectable"),le.emit("cloned",J,W,"mirror")}}function z(){J&&(E.rm(fe.mirrorContainer,"gu-unselectable"),o(S,"remove","mousemove",U),v(J).removeChild(J),J=null)}function H(e,n){for(var t=n;t!==e&&v(t)!==e;)t=v(t);return t===S?null:t}function V(e,n,t,r){function o(){var n,o,i,u=e.children.length;for(n=0;u>n;n++){if(o=e.children[n],i=o.getBoundingClientRect(),c&&i.left+i.width/2>t)return o;if(!c&&i.top+i.height/2>r)return o}return null}function i(){var e=n.getBoundingClientRect();return u(c?t>e.left+d(e)/2:r>e.top+s(e)/2)}function u(e){return e?g(n):n}var c="horizontal"===fe.direction,a=n!==e?i():o();return a}function $(e,n){return"boolean"==typeof fe.copy?fe.copy:fe.copy(e,n)}var G=arguments.length;1===G&&Array.isArray(e)===!1&&(n=e,e=[]);var J,Q,W,Z,ee,ne,te,re,oe,ie,ue,ce,ae=null,fe=n||{};void 0===fe.moves&&(fe.moves=l),void 0===fe.accepts&&(fe.accepts=l),void 0===fe.invalid&&(fe.invalid=P),void 0===fe.containers&&(fe.containers=e||[]),void 0===fe.isContainer&&(fe.isContainer=f),void 0===fe.copy&&(fe.copy=!1),void 0===fe.copySortSource&&(fe.copySortSource=!1),void 0===fe.revertOnSpill&&(fe.revertOnSpill=!1),void 0===fe.removeOnSpill&&(fe.removeOnSpill=!1),void 0===fe.direction&&(fe.direction="vertical"),void 0===fe.ignoreInputTextSelection&&(fe.ignoreInputTextSelection=!0),void 0===fe.mirrorContainer&&(fe.mirrorContainer=x.body);var le=b({containers:fe.containers,start:Y,end:D,cancel:A,remove:R,destroy:h,canMove:X,dragging:!1});return fe.removeOnSpill===!0&&le.on("over",_).on("out",F),r(),le}function o(e,n,r,o){var i={mouseup:"touchend",mousedown:"touchstart",mousemove:"touchmove"},u={mouseup:"pointerup",mousedown:"pointerdown",mousemove:"pointermove"},c={mouseup:"MSPointerUp",mousedown:"MSPointerDown",mousemove:"MSPointerMove"};t.navigator.pointerEnabled?w[n](e,u[r],o):t.navigator.msPointerEnabled?w[n](e,c[r],o):(w[n](e,i[r],o),w[n](e,r,o))}function i(e){if(void 0!==e.touches)return e.touches.length;if(void 0!==e.which&&0!==e.which)return e.which;if(void 0!==e.buttons)return e.buttons;var n=e.button;return void 0!==n?1&n?1:2&n?3:4&n?2:0:void 0}function u(e){var n=e.getBoundingClientRect();return{left:n.left+c("scrollLeft","pageXOffset"),top:n.top+c("scrollTop","pageYOffset")}}function c(e,n){return"undefined"!=typeof t[n]?t[n]:S.clientHeight?S[e]:x.body[e]}function a(e,n,t){var r,o=e||{},i=o.className;return o.className+=" gu-hide",r=x.elementFromPoint(n,t),o.className=i,r}function f(){return!1}function l(){return!0}function d(e){return e.width||e.right-e.left}function s(e){return e.height||e.bottom-e.top}function v(e){return e.parentNode===x?null:e.parentNode}function p(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName||"SELECT"===e.tagName||m(e)}function m(e){return e?"false"===e.contentEditable?!1:"true"===e.contentEditable?!0:m(v(e)):!1}function g(e){function n(){var n=e;do n=n.nextSibling;while(n&&1!==n.nodeType);return n}return e.nextElementSibling||n()}function h(e){return e.targetTouches&&e.targetTouches.length?e.targetTouches[0]:e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:e}function y(e,n){var t=h(n),r={pageX:"clientX",pageY:"clientY"};return e in r&&!(e in t)&&r[e]in t&&(e=r[e]),t[e]}var b=e("contra/emitter"),w=e("crossvent"),E=e("./classes"),x=document,S=x.documentElement;n.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./classes":1,"contra/emitter":5,crossvent:6}],3:[function(e,n,t){n.exports=function(e,n){return Array.prototype.slice.call(e,n)}},{}],4:[function(e,n,t){"use strict";var r=e("ticky");n.exports=function(e,n,t){e&&r(function(){e.apply(t||null,n||[])})}},{ticky:9}],5:[function(e,n,t){"use strict";var r=e("atoa"),o=e("./debounce");n.exports=function(e,n){var t=n||{},i={};return void 0===e&&(e={}),e.on=function(n,t){return i[n]?i[n].push(t):i[n]=[t],e},e.once=function(n,t){return t._once=!0,e.on(n,t),e},e.off=function(n,t){var r=arguments.length;if(1===r)delete i[n];else if(0===r)i={};else{var o=i[n];if(!o)return e;o.splice(o.indexOf(t),1)}return e},e.emit=function(){var n=r(arguments);return e.emitterSnapshot(n.shift()).apply(this,n)},e.emitterSnapshot=function(n){var u=(i[n]||[]).slice(0);return function(){var i=r(arguments),c=this||e;if("error"===n&&t["throws"]!==!1&&!u.length)throw 1===i.length?i[0]:i;return u.forEach(function(r){t.async?o(r,i,c):r.apply(c,i),r._once&&e.off(n,r)}),e}},e}},{"./debounce":4,atoa:3}],6:[function(e,n,t){(function(t){"use strict";function r(e,n,t,r){return e.addEventListener(n,t,r)}function o(e,n,t){return e.attachEvent("on"+n,f(e,n,t))}function i(e,n,t,r){return e.removeEventListener(n,t,r)}function u(e,n,t){var r=l(e,n,t);return r?e.detachEvent("on"+n,r):void 0}function c(e,n,t){function r(){var e;return p.createEvent?(e=p.createEvent("Event"),e.initEvent(n,!0,!0)):p.createEventObject&&(e=p.createEventObject()),e}function o(){return new s(n,{detail:t})}var i=-1===v.indexOf(n)?o():r();e.dispatchEvent?e.dispatchEvent(i):e.fireEvent("on"+n,i)}function a(e,n,r){return function(n){var o=n||t.event;o.target=o.target||o.srcElement,o.preventDefault=o.preventDefault||function(){o.returnValue=!1},o.stopPropagation=o.stopPropagation||function(){o.cancelBubble=!0},o.which=o.which||o.keyCode,r.call(e,o)}}function f(e,n,t){var r=l(e,n,t)||a(e,n,t);return h.push({wrapper:r,element:e,type:n,fn:t}),r}function l(e,n,t){var r=d(e,n,t);if(r){var o=h[r].wrapper;return h.splice(r,1),o}}function d(e,n,t){var r,o;for(r=0;r<h.length;r++)if(o=h[r],o.element===e&&o.type===n&&o.fn===t)return r}var s=e("custom-event"),v=e("./eventmap"),p=t.document,m=r,g=i,h=[];t.addEventListener||(m=o,g=u),n.exports={add:m,remove:g,fabricate:c}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./eventmap":7,"custom-event":8}],7:[function(e,n,t){(function(e){"use strict";var t=[],r="",o=/^on/;for(r in e)o.test(r)&&t.push(r.slice(2));n.exports=t}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],8:[function(e,n,t){(function(e){function t(){try{var e=new r("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(n){}return!1}var r=e.CustomEvent;n.exports=t()?r:"function"==typeof document.createEvent?function(e,n){var t=document.createEvent("CustomEvent");return n?t.initCustomEvent(e,n.bubbles,n.cancelable,n.detail):t.initCustomEvent(e,!1,!1,void 0),t}:function(e,n){var t=document.createEventObject();return t.type=e,n?(t.bubbles=Boolean(n.bubbles),t.cancelable=Boolean(n.cancelable),t.detail=n.detail):(t.bubbles=!1,t.cancelable=!1,t.detail=void 0),t}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],9:[function(e,n,t){var r,o="function"==typeof setImmediate;r=o?function(e){setImmediate(e)}:function(e){setTimeout(e,0)},n.exports=r},{}]},{},[2])(2)});
@@ -0,0 +1,78 @@
1
+ Contribute
2
+ ==========
3
+
4
+
5
+ > I have changed my branching model recently (November 2013)! Previously
6
+ > the latest version was always in develop, and pull request had to be
7
+ > made on this branch. This is no longer the case!
8
+
9
+
10
+ The latest version is always in the **[master](https://github.com/enyo/dropzone)**
11
+ branch.
12
+
13
+
14
+ > Please provide a test for any new feature (see the [testing section](#testing) below).
15
+
16
+
17
+ Communicate
18
+ -----------
19
+
20
+ Before you start implementing new features, please create an issue about
21
+ it first and discuss your intent.
22
+
23
+ It might be something that someone else is already implementing or that
24
+ goes against the concepts of Dropzone, and I really hate rejecting pull
25
+ requests others spent hours writing on.
26
+
27
+
28
+ Developer Dependencies
29
+ ----------------------
30
+
31
+ The first thing you need to do, is to install the developer dependencies:
32
+
33
+ ```bash
34
+ $ npm install
35
+ ```
36
+
37
+ This will install all the tools you need to compile the source files and to test
38
+ the library.
39
+
40
+
41
+ Coffeescript & Sass (-> Javascript & CSS)
42
+ ------------------------------------------
43
+
44
+ Dropzone is written in [Coffeescript](http://coffeescript.org) and
45
+ [Sass](http://sass-lang.com/) so *do not* make
46
+ changes to the Javascript or CSS files
47
+
48
+ **I will not merge requests written in Javascript or CSS.**
49
+
50
+ Please don't include compiled `.js` or `.css` files in your pull requests but only
51
+ `.coffee` or `.scss` files. That way pull requests aren't polluted and I can see
52
+ immediately what you changed.
53
+
54
+
55
+ To build the library use [grunt](http://gruntjs.com).
56
+
57
+ ```bash
58
+ $ grunt -h # Displays available options
59
+ $ grunt # compiles all coffeescript and stylus files
60
+ $ grunt watch # watches for changes and builds on the fly
61
+ ```
62
+
63
+ > I recommend using `grunt watch` when you begin developing. This way you can't
64
+ > forget to compile the source files and will avoid headaches.
65
+
66
+
67
+ Testing
68
+ -------
69
+
70
+ To test the library, open `test/test.html` in your browser or type `npm test`
71
+ which will run the tests in your console in a headless browser.
72
+
73
+ The tests are also written in coffeescript in the `test/test.coffee` file,
74
+ and compiled with `grunt js` or `grunt watch`.
75
+
76
+
77
+ * Thanks for contributing!*
78
+
@@ -0,0 +1,12 @@
1
+ License
2
+
3
+ (The MIT License)
4
+
5
+ Copyright (c) 2012 Matias Meno <m@tias.me>
6
+ Logo & Website Design (c) 2015 "1910" www.weare1910.com
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,134 @@
1
+ <img alt="Dropzone.js" src="http://www.dropzonejs.com/images/new-logo.svg" />
2
+
3
+ [ ![Codeship Status for enyo/dropzone](https://codeship.com/projects/3fc90800-74e0-0132-38ce-22ab3bab314c/status?branch=master)](https://codeship.com/projects/55087)
4
+
5
+ Dropzone.js is a light weight JavaScript library that turns an HTML element into a dropzone.
6
+ This means that a user can drag and drop a file onto it, and the file gets uploaded to the server via AJAX.
7
+
8
+ * * *
9
+
10
+ _If you want support, please use [stackoverflow](http://stackoverflow.com/) with the `dropzone.js` tag and not the
11
+ GitHub issues tracker. Only post an issue here if you think you discovered a bug or have a feature request._
12
+
13
+ * * *
14
+
15
+ **Please read the [contributing guidelines](CONTRIBUTING.md) before you start working on Dropzone!**
16
+
17
+ <br>
18
+ <div align="center">
19
+ <a href="https://github.com/enyo/dropzone/releases/latest"><strong>&gt;&gt; Download &lt;&lt;</strong></a>
20
+ </div>
21
+ <br>
22
+ <br>
23
+
24
+
25
+ Starting with version 2.0.0 this library does no longer depend on jQuery (but
26
+ it still works as a jQuery module).
27
+
28
+ Dropzone is compatible with [component](https://github.com/component/component),
29
+ there's a standalone version and an [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD)
30
+ module that's compatible with [RequireJS](http://requirejs.org) in the downloads
31
+ folder.
32
+
33
+ <img slt="Dropzone Screenshot" width="585" src="http://i.imgur.com/Xf7QvVG.png" />
34
+
35
+
36
+
37
+ ## Main features
38
+
39
+ - Image thumbnail previews. Simply register the callback `thumbnail(file, data)` and display the image wherever you like
40
+ - Retina enabled
41
+ - Multiple files and synchronous uploads
42
+ - Progress updates
43
+ - Support for large files
44
+ - Complete theming. The look and feel of Dropzone is just the default theme. You
45
+ can define everything yourself by overwriting the default event listeners.
46
+ - Well tested
47
+
48
+ ## Documentation
49
+
50
+ For the full documentation and installation please visit www.dropzonejs.com
51
+
52
+ Please also refer to the [FAQ](https://github.com/enyo/dropzone/wiki/FAQ).
53
+
54
+ ## Examples
55
+
56
+ For examples, please see the [GitHub wiki](https://github.com/enyo/dropzone/wiki).
57
+
58
+ ## Usage
59
+
60
+ Implicit creation:
61
+
62
+ ```html
63
+ <form id="my-awesome-dropzone" action="/target" class="dropzone"></form>
64
+ ```
65
+
66
+ That's it. Really!
67
+
68
+ Dropzone will automatically attach to it, and handle file drops.
69
+
70
+ Want more control? You can configure dropzones like this:
71
+
72
+ ```js
73
+ // "myAwesomeDropzone" is the camelized version of the ID of your HTML element
74
+ Dropzone.options.myAwesomeDropzone = { maxFilesize: 1 };
75
+ ```
76
+
77
+ ...or instantiate dropzone manually like this:
78
+
79
+ ```js
80
+ new Dropzone("div#my-dropzone", { /* options */ });
81
+ ```
82
+
83
+ > Note that dropzones don't have to be forms. But if you choose another element you have to pass the `url` parameter in the options.
84
+
85
+ For configuration options please look at the [documentation on the website](http://www.dropzonejs.com/#configuration)
86
+ or at the [source](https://github.com/enyo/dropzone/blob/master/src/dropzone.coffee#L90).
87
+
88
+
89
+
90
+ ### Register for events
91
+
92
+ If you want to register to some event you can do so on the `dropzone` object itself:
93
+
94
+ ```js
95
+ Dropzone.options.myDropzone({
96
+ init: function() {
97
+ this.on("error", function(file, message) { alert(message); });
98
+ }
99
+ });
100
+ // or if you need to access a Dropzone somewhere else:
101
+ var myDropzone = Dropzone.forElement("div#my-dropzone");
102
+ myDropzone.on("error", function(file, message) { alert(message); });
103
+ ```
104
+
105
+ For a list of all events, please look at the chapter
106
+ [»Events«](http://www.dropzonejs.com/#events) in the documentation
107
+ or at the [source](src/dropzone.coffee#L43).
108
+
109
+
110
+ ## Browser support
111
+
112
+ - Chrome 7+
113
+ - Firefox 4+
114
+ - IE 10+
115
+ - Opera 12+ (Version 12 for MacOS is disabled because their API is buggy)
116
+ - Safari 6+
117
+
118
+ For all the other browsers, dropzone provides an oldschool file input fallback.
119
+
120
+ ## Why another library?
121
+
122
+ I realize that there [are](http://valums.com/ajax-upload/) [already](http://tutorialzine.com/2011/09/html5-file-upload-jquery-php/) [other](http://code.google.com/p/html5uploader/) [libraries](http://blueimp.github.com/jQuery-File-Upload/) out there but the reason I decided to write my own are the following:
123
+
124
+ - I didn't want it to be too big, and to cumbersome to dive into.
125
+ - I want to design my own elements. I only want to register callbacks so I can update my elements accordingly.
126
+ - Big files should get uploaded without a problem.
127
+ - I wanted a callback for image previews, that don't kill the browser if too many too big images are viewed.
128
+ - I want to use the latest API of browsers. I don't care if it falls back to the normal upload form if the browser is too old.
129
+ - I don't think that it's necessary anymore to depend on libraries such as jQuery (especially when providing functionality that isn't available in old browsers anyway).
130
+
131
+ MIT License
132
+ -----------
133
+
134
+ See LICENSE file
@@ -0,0 +1,39 @@
1
+ /*
2
+ * The MIT License
3
+ * Copyright (c) 2012 Matias Meno <m@tias.me>
4
+ */
5
+ .dropzone, .dropzone * {
6
+ box-sizing: border-box; }
7
+
8
+ .dropzone {
9
+ position: relative; }
10
+ .dropzone .dz-preview {
11
+ position: relative;
12
+ display: inline-block;
13
+ width: 120px;
14
+ margin: 0.5em; }
15
+ .dropzone .dz-preview .dz-progress {
16
+ display: block;
17
+ height: 15px;
18
+ border: 1px solid #aaa; }
19
+ .dropzone .dz-preview .dz-progress .dz-upload {
20
+ display: block;
21
+ height: 100%;
22
+ width: 0;
23
+ background: green; }
24
+ .dropzone .dz-preview .dz-error-message {
25
+ color: red;
26
+ display: none; }
27
+ .dropzone .dz-preview.dz-error .dz-error-message, .dropzone .dz-preview.dz-error .dz-error-mark {
28
+ display: block; }
29
+ .dropzone .dz-preview.dz-success .dz-success-mark {
30
+ display: block; }
31
+ .dropzone .dz-preview .dz-error-mark, .dropzone .dz-preview .dz-success-mark {
32
+ position: absolute;
33
+ display: none;
34
+ left: 30px;
35
+ top: 30px;
36
+ width: 54px;
37
+ height: 58px;
38
+ left: 50%;
39
+ margin-left: -27px; }
@@ -0,0 +1,1782 @@
1
+ // Uses AMD or browser globals to create a jQuery plugin.
2
+ (function (factory) {
3
+ if (typeof define === 'function' && define.amd) {
4
+ // AMD. Register as an anonymous module.
5
+ define(['jquery'], factory);
6
+ } else {
7
+ // Browser globals
8
+ factory(jQuery);
9
+ }
10
+ } (function (jQuery) {
11
+ var module = { exports: { } }; // Fake component
12
+
13
+
14
+ /*
15
+ *
16
+ * More info at [www.dropzonejs.com](http://www.dropzonejs.com)
17
+ *
18
+ * Copyright (c) 2012, Matias Meno
19
+ *
20
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
21
+ * of this software and associated documentation files (the "Software"), to deal
22
+ * in the Software without restriction, including without limitation the rights
23
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
24
+ * copies of the Software, and to permit persons to whom the Software is
25
+ * furnished to do so, subject to the following conditions:
26
+ *
27
+ * The above copyright notice and this permission notice shall be included in
28
+ * all copies or substantial portions of the Software.
29
+ *
30
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
36
+ * THE SOFTWARE.
37
+ *
38
+ */
39
+
40
+ (function() {
41
+ var Dropzone, Emitter, camelize, contentLoaded, detectVerticalSquash, drawImageIOSFix, noop, without,
42
+ __slice = [].slice,
43
+ __hasProp = {}.hasOwnProperty,
44
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
45
+
46
+ noop = function() {};
47
+
48
+ Emitter = (function() {
49
+ function Emitter() {}
50
+
51
+ Emitter.prototype.addEventListener = Emitter.prototype.on;
52
+
53
+ Emitter.prototype.on = function(event, fn) {
54
+ this._callbacks = this._callbacks || {};
55
+ if (!this._callbacks[event]) {
56
+ this._callbacks[event] = [];
57
+ }
58
+ this._callbacks[event].push(fn);
59
+ return this;
60
+ };
61
+
62
+ Emitter.prototype.emit = function() {
63
+ var args, callback, callbacks, event, _i, _len;
64
+ event = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
65
+ this._callbacks = this._callbacks || {};
66
+ callbacks = this._callbacks[event];
67
+ if (callbacks) {
68
+ for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
69
+ callback = callbacks[_i];
70
+ callback.apply(this, args);
71
+ }
72
+ }
73
+ return this;
74
+ };
75
+
76
+ Emitter.prototype.removeListener = Emitter.prototype.off;
77
+
78
+ Emitter.prototype.removeAllListeners = Emitter.prototype.off;
79
+
80
+ Emitter.prototype.removeEventListener = Emitter.prototype.off;
81
+
82
+ Emitter.prototype.off = function(event, fn) {
83
+ var callback, callbacks, i, _i, _len;
84
+ if (!this._callbacks || arguments.length === 0) {
85
+ this._callbacks = {};
86
+ return this;
87
+ }
88
+ callbacks = this._callbacks[event];
89
+ if (!callbacks) {
90
+ return this;
91
+ }
92
+ if (arguments.length === 1) {
93
+ delete this._callbacks[event];
94
+ return this;
95
+ }
96
+ for (i = _i = 0, _len = callbacks.length; _i < _len; i = ++_i) {
97
+ callback = callbacks[i];
98
+ if (callback === fn) {
99
+ callbacks.splice(i, 1);
100
+ break;
101
+ }
102
+ }
103
+ return this;
104
+ };
105
+
106
+ return Emitter;
107
+
108
+ })();
109
+
110
+ Dropzone = (function(_super) {
111
+ var extend, resolveOption;
112
+
113
+ __extends(Dropzone, _super);
114
+
115
+ Dropzone.prototype.Emitter = Emitter;
116
+
117
+
118
+ /*
119
+ This is a list of all available events you can register on a dropzone object.
120
+
121
+ You can register an event handler like this:
122
+
123
+ dropzone.on("dragEnter", function() { });
124
+ */
125
+
126
+ Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "addedfile", "addedfiles", "removedfile", "thumbnail", "error", "errormultiple", "processing", "processingmultiple", "uploadprogress", "totaluploadprogress", "sending", "sendingmultiple", "success", "successmultiple", "canceled", "canceledmultiple", "complete", "completemultiple", "reset", "maxfilesexceeded", "maxfilesreached", "queuecomplete"];
127
+
128
+ Dropzone.prototype.defaultOptions = {
129
+ url: null,
130
+ method: "post",
131
+ withCredentials: false,
132
+ parallelUploads: 2,
133
+ uploadMultiple: false,
134
+ maxFilesize: 256,
135
+ paramName: "file",
136
+ createImageThumbnails: true,
137
+ maxThumbnailFilesize: 10,
138
+ thumbnailWidth: 120,
139
+ thumbnailHeight: 120,
140
+ filesizeBase: 1000,
141
+ maxFiles: null,
142
+ params: {},
143
+ clickable: true,
144
+ ignoreHiddenFiles: true,
145
+ acceptedFiles: null,
146
+ acceptedMimeTypes: null,
147
+ autoProcessQueue: true,
148
+ autoQueue: true,
149
+ addRemoveLinks: false,
150
+ previewsContainer: null,
151
+ hiddenInputContainer: "body",
152
+ capture: null,
153
+ renameFilename: null,
154
+ dictDefaultMessage: "Drop files here to upload",
155
+ dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.",
156
+ dictFallbackText: "Please use the fallback form below to upload your files like in the olden days.",
157
+ dictFileTooBig: "File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.",
158
+ dictInvalidFileType: "You can't upload files of this type.",
159
+ dictResponseError: "Server responded with {{statusCode}} code.",
160
+ dictCancelUpload: "Cancel upload",
161
+ dictCancelUploadConfirmation: "Are you sure you want to cancel this upload?",
162
+ dictRemoveFile: "Remove file",
163
+ dictRemoveFileConfirmation: null,
164
+ dictMaxFilesExceeded: "You can not upload any more files.",
165
+ accept: function(file, done) {
166
+ return done();
167
+ },
168
+ init: function() {
169
+ return noop;
170
+ },
171
+ forceFallback: false,
172
+ fallback: function() {
173
+ var child, messageElement, span, _i, _len, _ref;
174
+ this.element.className = "" + this.element.className + " dz-browser-not-supported";
175
+ _ref = this.element.getElementsByTagName("div");
176
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
177
+ child = _ref[_i];
178
+ if (/(^| )dz-message($| )/.test(child.className)) {
179
+ messageElement = child;
180
+ child.className = "dz-message";
181
+ continue;
182
+ }
183
+ }
184
+ if (!messageElement) {
185
+ messageElement = Dropzone.createElement("<div class=\"dz-message\"><span></span></div>");
186
+ this.element.appendChild(messageElement);
187
+ }
188
+ span = messageElement.getElementsByTagName("span")[0];
189
+ if (span) {
190
+ if (span.textContent != null) {
191
+ span.textContent = this.options.dictFallbackMessage;
192
+ } else if (span.innerText != null) {
193
+ span.innerText = this.options.dictFallbackMessage;
194
+ }
195
+ }
196
+ return this.element.appendChild(this.getFallbackForm());
197
+ },
198
+ resize: function(file) {
199
+ var info, srcRatio, trgRatio;
200
+ info = {
201
+ srcX: 0,
202
+ srcY: 0,
203
+ srcWidth: file.width,
204
+ srcHeight: file.height
205
+ };
206
+ srcRatio = file.width / file.height;
207
+ info.optWidth = this.options.thumbnailWidth;
208
+ info.optHeight = this.options.thumbnailHeight;
209
+ if ((info.optWidth == null) && (info.optHeight == null)) {
210
+ info.optWidth = info.srcWidth;
211
+ info.optHeight = info.srcHeight;
212
+ } else if (info.optWidth == null) {
213
+ info.optWidth = srcRatio * info.optHeight;
214
+ } else if (info.optHeight == null) {
215
+ info.optHeight = (1 / srcRatio) * info.optWidth;
216
+ }
217
+ trgRatio = info.optWidth / info.optHeight;
218
+ if (file.height < info.optHeight || file.width < info.optWidth) {
219
+ info.trgHeight = info.srcHeight;
220
+ info.trgWidth = info.srcWidth;
221
+ } else {
222
+ if (srcRatio > trgRatio) {
223
+ info.srcHeight = file.height;
224
+ info.srcWidth = info.srcHeight * trgRatio;
225
+ } else {
226
+ info.srcWidth = file.width;
227
+ info.srcHeight = info.srcWidth / trgRatio;
228
+ }
229
+ }
230
+ info.srcX = (file.width - info.srcWidth) / 2;
231
+ info.srcY = (file.height - info.srcHeight) / 2;
232
+ return info;
233
+ },
234
+
235
+ /*
236
+ Those functions register themselves to the events on init and handle all
237
+ the user interface specific stuff. Overwriting them won't break the upload
238
+ but can break the way it's displayed.
239
+ You can overwrite them if you don't like the default behavior. If you just
240
+ want to add an additional event handler, register it on the dropzone object
241
+ and don't overwrite those options.
242
+ */
243
+ drop: function(e) {
244
+ return this.element.classList.remove("dz-drag-hover");
245
+ },
246
+ dragstart: noop,
247
+ dragend: function(e) {
248
+ return this.element.classList.remove("dz-drag-hover");
249
+ },
250
+ dragenter: function(e) {
251
+ return this.element.classList.add("dz-drag-hover");
252
+ },
253
+ dragover: function(e) {
254
+ return this.element.classList.add("dz-drag-hover");
255
+ },
256
+ dragleave: function(e) {
257
+ return this.element.classList.remove("dz-drag-hover");
258
+ },
259
+ paste: noop,
260
+ reset: function() {
261
+ return this.element.classList.remove("dz-started");
262
+ },
263
+ addedfile: function(file) {
264
+ var node, removeFileEvent, removeLink, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _results;
265
+ if (this.element === this.previewsContainer) {
266
+ this.element.classList.add("dz-started");
267
+ }
268
+ if (this.previewsContainer) {
269
+ file.previewElement = Dropzone.createElement(this.options.previewTemplate.trim());
270
+ file.previewTemplate = file.previewElement;
271
+ this.previewsContainer.appendChild(file.previewElement);
272
+ _ref = file.previewElement.querySelectorAll("[data-dz-name]");
273
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
274
+ node = _ref[_i];
275
+ node.textContent = this._renameFilename(file.name);
276
+ }
277
+ _ref1 = file.previewElement.querySelectorAll("[data-dz-size]");
278
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
279
+ node = _ref1[_j];
280
+ node.innerHTML = this.filesize(file.size);
281
+ }
282
+ if (this.options.addRemoveLinks) {
283
+ file._removeLink = Dropzone.createElement("<a class=\"dz-remove\" href=\"javascript:undefined;\" data-dz-remove>" + this.options.dictRemoveFile + "</a>");
284
+ file.previewElement.appendChild(file._removeLink);
285
+ }
286
+ removeFileEvent = (function(_this) {
287
+ return function(e) {
288
+ e.preventDefault();
289
+ e.stopPropagation();
290
+ if (file.status === Dropzone.UPLOADING) {
291
+ return Dropzone.confirm(_this.options.dictCancelUploadConfirmation, function() {
292
+ return _this.removeFile(file);
293
+ });
294
+ } else {
295
+ if (_this.options.dictRemoveFileConfirmation) {
296
+ return Dropzone.confirm(_this.options.dictRemoveFileConfirmation, function() {
297
+ return _this.removeFile(file);
298
+ });
299
+ } else {
300
+ return _this.removeFile(file);
301
+ }
302
+ }
303
+ };
304
+ })(this);
305
+ _ref2 = file.previewElement.querySelectorAll("[data-dz-remove]");
306
+ _results = [];
307
+ for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
308
+ removeLink = _ref2[_k];
309
+ _results.push(removeLink.addEventListener("click", removeFileEvent));
310
+ }
311
+ return _results;
312
+ }
313
+ },
314
+ removedfile: function(file) {
315
+ var _ref;
316
+ if (file.previewElement) {
317
+ if ((_ref = file.previewElement) != null) {
318
+ _ref.parentNode.removeChild(file.previewElement);
319
+ }
320
+ }
321
+ return this._updateMaxFilesReachedClass();
322
+ },
323
+ thumbnail: function(file, dataUrl) {
324
+ var thumbnailElement, _i, _len, _ref;
325
+ if (file.previewElement) {
326
+ file.previewElement.classList.remove("dz-file-preview");
327
+ _ref = file.previewElement.querySelectorAll("[data-dz-thumbnail]");
328
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
329
+ thumbnailElement = _ref[_i];
330
+ thumbnailElement.alt = file.name;
331
+ thumbnailElement.src = dataUrl;
332
+ }
333
+ return setTimeout(((function(_this) {
334
+ return function() {
335
+ return file.previewElement.classList.add("dz-image-preview");
336
+ };
337
+ })(this)), 1);
338
+ }
339
+ },
340
+ error: function(file, message) {
341
+ var node, _i, _len, _ref, _results;
342
+ if (file.previewElement) {
343
+ file.previewElement.classList.add("dz-error");
344
+ if (typeof message !== "String" && message.error) {
345
+ message = message.error;
346
+ }
347
+ _ref = file.previewElement.querySelectorAll("[data-dz-errormessage]");
348
+ _results = [];
349
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
350
+ node = _ref[_i];
351
+ _results.push(node.textContent = message);
352
+ }
353
+ return _results;
354
+ }
355
+ },
356
+ errormultiple: noop,
357
+ processing: function(file) {
358
+ if (file.previewElement) {
359
+ file.previewElement.classList.add("dz-processing");
360
+ if (file._removeLink) {
361
+ return file._removeLink.textContent = this.options.dictCancelUpload;
362
+ }
363
+ }
364
+ },
365
+ processingmultiple: noop,
366
+ uploadprogress: function(file, progress, bytesSent) {
367
+ var node, _i, _len, _ref, _results;
368
+ if (file.previewElement) {
369
+ _ref = file.previewElement.querySelectorAll("[data-dz-uploadprogress]");
370
+ _results = [];
371
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
372
+ node = _ref[_i];
373
+ if (node.nodeName === 'PROGRESS') {
374
+ _results.push(node.value = progress);
375
+ } else {
376
+ _results.push(node.style.width = "" + progress + "%");
377
+ }
378
+ }
379
+ return _results;
380
+ }
381
+ },
382
+ totaluploadprogress: noop,
383
+ sending: noop,
384
+ sendingmultiple: noop,
385
+ success: function(file) {
386
+ if (file.previewElement) {
387
+ return file.previewElement.classList.add("dz-success");
388
+ }
389
+ },
390
+ successmultiple: noop,
391
+ canceled: function(file) {
392
+ return this.emit("error", file, "Upload canceled.");
393
+ },
394
+ canceledmultiple: noop,
395
+ complete: function(file) {
396
+ if (file._removeLink) {
397
+ file._removeLink.textContent = this.options.dictRemoveFile;
398
+ }
399
+ if (file.previewElement) {
400
+ return file.previewElement.classList.add("dz-complete");
401
+ }
402
+ },
403
+ completemultiple: noop,
404
+ maxfilesexceeded: noop,
405
+ maxfilesreached: noop,
406
+ queuecomplete: noop,
407
+ addedfiles: noop,
408
+ previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n <div class=\"dz-image\"><img data-dz-thumbnail /></div>\n <div class=\"dz-details\">\n <div class=\"dz-size\"><span data-dz-size></span></div>\n <div class=\"dz-filename\"><span data-dz-name></span></div>\n </div>\n <div class=\"dz-progress\"><span class=\"dz-upload\" data-dz-uploadprogress></span></div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n <div class=\"dz-success-mark\">\n <svg width=\"54px\" height=\"54px\" viewBox=\"0 0 54 54\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:sketch=\"http://www.bohemiancoding.com/sketch/ns\">\n <title>Check</title>\n <defs></defs>\n <g id=\"Page-1\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\" sketch:type=\"MSPage\">\n <path d=\"M23.5,31.8431458 L17.5852419,25.9283877 C16.0248253,24.3679711 13.4910294,24.366835 11.9289322,25.9289322 C10.3700136,27.4878508 10.3665912,30.0234455 11.9283877,31.5852419 L20.4147581,40.0716123 C20.5133999,40.1702541 20.6159315,40.2626649 20.7218615,40.3488435 C22.2835669,41.8725651 24.794234,41.8626202 26.3461564,40.3106978 L43.3106978,23.3461564 C44.8771021,21.7797521 44.8758057,19.2483887 43.3137085,17.6862915 C41.7547899,16.1273729 39.2176035,16.1255422 37.6538436,17.6893022 L23.5,31.8431458 Z M27,53 C41.3594035,53 53,41.3594035 53,27 C53,12.6405965 41.3594035,1 27,1 C12.6405965,1 1,12.6405965 1,27 C1,41.3594035 12.6405965,53 27,53 Z\" id=\"Oval-2\" stroke-opacity=\"0.198794158\" stroke=\"#747474\" fill-opacity=\"0.816519475\" fill=\"#FFFFFF\" sketch:type=\"MSShapeGroup\"></path>\n </g>\n </svg>\n </div>\n <div class=\"dz-error-mark\">\n <svg width=\"54px\" height=\"54px\" viewBox=\"0 0 54 54\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:sketch=\"http://www.bohemiancoding.com/sketch/ns\">\n <title>Error</title>\n <defs></defs>\n <g id=\"Page-1\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\" sketch:type=\"MSPage\">\n <g id=\"Check-+-Oval-2\" sketch:type=\"MSLayerGroup\" stroke=\"#747474\" stroke-opacity=\"0.198794158\" fill=\"#FFFFFF\" fill-opacity=\"0.816519475\">\n <path d=\"M32.6568542,29 L38.3106978,23.3461564 C39.8771021,21.7797521 39.8758057,19.2483887 38.3137085,17.6862915 C36.7547899,16.1273729 34.2176035,16.1255422 32.6538436,17.6893022 L27,23.3431458 L21.3461564,17.6893022 C19.7823965,16.1255422 17.2452101,16.1273729 15.6862915,17.6862915 C14.1241943,19.2483887 14.1228979,21.7797521 15.6893022,23.3461564 L21.3431458,29 L15.6893022,34.6538436 C14.1228979,36.2202479 14.1241943,38.7516113 15.6862915,40.3137085 C17.2452101,41.8726271 19.7823965,41.8744578 21.3461564,40.3106978 L27,34.6568542 L32.6538436,40.3106978 C34.2176035,41.8744578 36.7547899,41.8726271 38.3137085,40.3137085 C39.8758057,38.7516113 39.8771021,36.2202479 38.3106978,34.6538436 L32.6568542,29 Z M27,53 C41.3594035,53 53,41.3594035 53,27 C53,12.6405965 41.3594035,1 27,1 C12.6405965,1 1,12.6405965 1,27 C1,41.3594035 12.6405965,53 27,53 Z\" id=\"Oval-2\" sketch:type=\"MSShapeGroup\"></path>\n </g>\n </g>\n </svg>\n </div>\n</div>"
409
+ };
410
+
411
+ extend = function() {
412
+ var key, object, objects, target, val, _i, _len;
413
+ target = arguments[0], objects = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
414
+ for (_i = 0, _len = objects.length; _i < _len; _i++) {
415
+ object = objects[_i];
416
+ for (key in object) {
417
+ val = object[key];
418
+ target[key] = val;
419
+ }
420
+ }
421
+ return target;
422
+ };
423
+
424
+ function Dropzone(element, options) {
425
+ var elementOptions, fallback, _ref;
426
+ this.element = element;
427
+ this.version = Dropzone.version;
428
+ this.defaultOptions.previewTemplate = this.defaultOptions.previewTemplate.replace(/\n*/g, "");
429
+ this.clickableElements = [];
430
+ this.listeners = [];
431
+ this.files = [];
432
+ if (typeof this.element === "string") {
433
+ this.element = document.querySelector(this.element);
434
+ }
435
+ if (!(this.element && (this.element.nodeType != null))) {
436
+ throw new Error("Invalid dropzone element.");
437
+ }
438
+ if (this.element.dropzone) {
439
+ throw new Error("Dropzone already attached.");
440
+ }
441
+ Dropzone.instances.push(this);
442
+ this.element.dropzone = this;
443
+ elementOptions = (_ref = Dropzone.optionsForElement(this.element)) != null ? _ref : {};
444
+ this.options = extend({}, this.defaultOptions, elementOptions, options != null ? options : {});
445
+ if (this.options.forceFallback || !Dropzone.isBrowserSupported()) {
446
+ return this.options.fallback.call(this);
447
+ }
448
+ if (this.options.url == null) {
449
+ this.options.url = this.element.getAttribute("action");
450
+ }
451
+ if (!this.options.url) {
452
+ throw new Error("No URL provided.");
453
+ }
454
+ if (this.options.acceptedFiles && this.options.acceptedMimeTypes) {
455
+ throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated.");
456
+ }
457
+ if (this.options.acceptedMimeTypes) {
458
+ this.options.acceptedFiles = this.options.acceptedMimeTypes;
459
+ delete this.options.acceptedMimeTypes;
460
+ }
461
+ this.options.method = this.options.method.toUpperCase();
462
+ if ((fallback = this.getExistingFallback()) && fallback.parentNode) {
463
+ fallback.parentNode.removeChild(fallback);
464
+ }
465
+ if (this.options.previewsContainer !== false) {
466
+ if (this.options.previewsContainer) {
467
+ this.previewsContainer = Dropzone.getElement(this.options.previewsContainer, "previewsContainer");
468
+ } else {
469
+ this.previewsContainer = this.element;
470
+ }
471
+ }
472
+ if (this.options.clickable) {
473
+ if (this.options.clickable === true) {
474
+ this.clickableElements = [this.element];
475
+ } else {
476
+ this.clickableElements = Dropzone.getElements(this.options.clickable, "clickable");
477
+ }
478
+ }
479
+ this.init();
480
+ }
481
+
482
+ Dropzone.prototype.getAcceptedFiles = function() {
483
+ var file, _i, _len, _ref, _results;
484
+ _ref = this.files;
485
+ _results = [];
486
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
487
+ file = _ref[_i];
488
+ if (file.accepted) {
489
+ _results.push(file);
490
+ }
491
+ }
492
+ return _results;
493
+ };
494
+
495
+ Dropzone.prototype.getRejectedFiles = function() {
496
+ var file, _i, _len, _ref, _results;
497
+ _ref = this.files;
498
+ _results = [];
499
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
500
+ file = _ref[_i];
501
+ if (!file.accepted) {
502
+ _results.push(file);
503
+ }
504
+ }
505
+ return _results;
506
+ };
507
+
508
+ Dropzone.prototype.getFilesWithStatus = function(status) {
509
+ var file, _i, _len, _ref, _results;
510
+ _ref = this.files;
511
+ _results = [];
512
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
513
+ file = _ref[_i];
514
+ if (file.status === status) {
515
+ _results.push(file);
516
+ }
517
+ }
518
+ return _results;
519
+ };
520
+
521
+ Dropzone.prototype.getQueuedFiles = function() {
522
+ return this.getFilesWithStatus(Dropzone.QUEUED);
523
+ };
524
+
525
+ Dropzone.prototype.getUploadingFiles = function() {
526
+ return this.getFilesWithStatus(Dropzone.UPLOADING);
527
+ };
528
+
529
+ Dropzone.prototype.getAddedFiles = function() {
530
+ return this.getFilesWithStatus(Dropzone.ADDED);
531
+ };
532
+
533
+ Dropzone.prototype.getActiveFiles = function() {
534
+ var file, _i, _len, _ref, _results;
535
+ _ref = this.files;
536
+ _results = [];
537
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
538
+ file = _ref[_i];
539
+ if (file.status === Dropzone.UPLOADING || file.status === Dropzone.QUEUED) {
540
+ _results.push(file);
541
+ }
542
+ }
543
+ return _results;
544
+ };
545
+
546
+ Dropzone.prototype.init = function() {
547
+ var eventName, noPropagation, setupHiddenFileInput, _i, _len, _ref, _ref1;
548
+ if (this.element.tagName === "form") {
549
+ this.element.setAttribute("enctype", "multipart/form-data");
550
+ }
551
+ if (this.element.classList.contains("dropzone") && !this.element.querySelector(".dz-message")) {
552
+ this.element.appendChild(Dropzone.createElement("<div class=\"dz-default dz-message\"><span>" + this.options.dictDefaultMessage + "</span></div>"));
553
+ }
554
+ if (this.clickableElements.length) {
555
+ setupHiddenFileInput = (function(_this) {
556
+ return function() {
557
+ if (_this.hiddenFileInput) {
558
+ _this.hiddenFileInput.parentNode.removeChild(_this.hiddenFileInput);
559
+ }
560
+ _this.hiddenFileInput = document.createElement("input");
561
+ _this.hiddenFileInput.setAttribute("type", "file");
562
+ if ((_this.options.maxFiles == null) || _this.options.maxFiles > 1) {
563
+ _this.hiddenFileInput.setAttribute("multiple", "multiple");
564
+ }
565
+ _this.hiddenFileInput.className = "dz-hidden-input";
566
+ if (_this.options.acceptedFiles != null) {
567
+ _this.hiddenFileInput.setAttribute("accept", _this.options.acceptedFiles);
568
+ }
569
+ if (_this.options.capture != null) {
570
+ _this.hiddenFileInput.setAttribute("capture", _this.options.capture);
571
+ }
572
+ _this.hiddenFileInput.style.visibility = "hidden";
573
+ _this.hiddenFileInput.style.position = "absolute";
574
+ _this.hiddenFileInput.style.top = "0";
575
+ _this.hiddenFileInput.style.left = "0";
576
+ _this.hiddenFileInput.style.height = "0";
577
+ _this.hiddenFileInput.style.width = "0";
578
+ document.querySelector(_this.options.hiddenInputContainer).appendChild(_this.hiddenFileInput);
579
+ return _this.hiddenFileInput.addEventListener("change", function() {
580
+ var file, files, _i, _len;
581
+ files = _this.hiddenFileInput.files;
582
+ if (files.length) {
583
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
584
+ file = files[_i];
585
+ _this.addFile(file);
586
+ }
587
+ }
588
+ _this.emit("addedfiles", files);
589
+ return setupHiddenFileInput();
590
+ });
591
+ };
592
+ })(this);
593
+ setupHiddenFileInput();
594
+ }
595
+ this.URL = (_ref = window.URL) != null ? _ref : window.webkitURL;
596
+ _ref1 = this.events;
597
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
598
+ eventName = _ref1[_i];
599
+ this.on(eventName, this.options[eventName]);
600
+ }
601
+ this.on("uploadprogress", (function(_this) {
602
+ return function() {
603
+ return _this.updateTotalUploadProgress();
604
+ };
605
+ })(this));
606
+ this.on("removedfile", (function(_this) {
607
+ return function() {
608
+ return _this.updateTotalUploadProgress();
609
+ };
610
+ })(this));
611
+ this.on("canceled", (function(_this) {
612
+ return function(file) {
613
+ return _this.emit("complete", file);
614
+ };
615
+ })(this));
616
+ this.on("complete", (function(_this) {
617
+ return function(file) {
618
+ if (_this.getAddedFiles().length === 0 && _this.getUploadingFiles().length === 0 && _this.getQueuedFiles().length === 0) {
619
+ return setTimeout((function() {
620
+ return _this.emit("queuecomplete");
621
+ }), 0);
622
+ }
623
+ };
624
+ })(this));
625
+ noPropagation = function(e) {
626
+ e.stopPropagation();
627
+ if (e.preventDefault) {
628
+ return e.preventDefault();
629
+ } else {
630
+ return e.returnValue = false;
631
+ }
632
+ };
633
+ this.listeners = [
634
+ {
635
+ element: this.element,
636
+ events: {
637
+ "dragstart": (function(_this) {
638
+ return function(e) {
639
+ return _this.emit("dragstart", e);
640
+ };
641
+ })(this),
642
+ "dragenter": (function(_this) {
643
+ return function(e) {
644
+ noPropagation(e);
645
+ return _this.emit("dragenter", e);
646
+ };
647
+ })(this),
648
+ "dragover": (function(_this) {
649
+ return function(e) {
650
+ var efct;
651
+ try {
652
+ efct = e.dataTransfer.effectAllowed;
653
+ } catch (_error) {}
654
+ e.dataTransfer.dropEffect = 'move' === efct || 'linkMove' === efct ? 'move' : 'copy';
655
+ noPropagation(e);
656
+ return _this.emit("dragover", e);
657
+ };
658
+ })(this),
659
+ "dragleave": (function(_this) {
660
+ return function(e) {
661
+ return _this.emit("dragleave", e);
662
+ };
663
+ })(this),
664
+ "drop": (function(_this) {
665
+ return function(e) {
666
+ noPropagation(e);
667
+ return _this.drop(e);
668
+ };
669
+ })(this),
670
+ "dragend": (function(_this) {
671
+ return function(e) {
672
+ return _this.emit("dragend", e);
673
+ };
674
+ })(this)
675
+ }
676
+ }
677
+ ];
678
+ this.clickableElements.forEach((function(_this) {
679
+ return function(clickableElement) {
680
+ return _this.listeners.push({
681
+ element: clickableElement,
682
+ events: {
683
+ "click": function(evt) {
684
+ if ((clickableElement !== _this.element) || (evt.target === _this.element || Dropzone.elementInside(evt.target, _this.element.querySelector(".dz-message")))) {
685
+ _this.hiddenFileInput.click();
686
+ }
687
+ return true;
688
+ }
689
+ }
690
+ });
691
+ };
692
+ })(this));
693
+ this.enable();
694
+ return this.options.init.call(this);
695
+ };
696
+
697
+ Dropzone.prototype.destroy = function() {
698
+ var _ref;
699
+ this.disable();
700
+ this.removeAllFiles(true);
701
+ if ((_ref = this.hiddenFileInput) != null ? _ref.parentNode : void 0) {
702
+ this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput);
703
+ this.hiddenFileInput = null;
704
+ }
705
+ delete this.element.dropzone;
706
+ return Dropzone.instances.splice(Dropzone.instances.indexOf(this), 1);
707
+ };
708
+
709
+ Dropzone.prototype.updateTotalUploadProgress = function() {
710
+ var activeFiles, file, totalBytes, totalBytesSent, totalUploadProgress, _i, _len, _ref;
711
+ totalBytesSent = 0;
712
+ totalBytes = 0;
713
+ activeFiles = this.getActiveFiles();
714
+ if (activeFiles.length) {
715
+ _ref = this.getActiveFiles();
716
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
717
+ file = _ref[_i];
718
+ totalBytesSent += file.upload.bytesSent;
719
+ totalBytes += file.upload.total;
720
+ }
721
+ totalUploadProgress = 100 * totalBytesSent / totalBytes;
722
+ } else {
723
+ totalUploadProgress = 100;
724
+ }
725
+ return this.emit("totaluploadprogress", totalUploadProgress, totalBytes, totalBytesSent);
726
+ };
727
+
728
+ Dropzone.prototype._getParamName = function(n) {
729
+ if (typeof this.options.paramName === "function") {
730
+ return this.options.paramName(n);
731
+ } else {
732
+ return "" + this.options.paramName + (this.options.uploadMultiple ? "[" + n + "]" : "");
733
+ }
734
+ };
735
+
736
+ Dropzone.prototype._renameFilename = function(name) {
737
+ if (typeof this.options.renameFilename !== "function") {
738
+ return name;
739
+ }
740
+ return this.options.renameFilename(name);
741
+ };
742
+
743
+ Dropzone.prototype.getFallbackForm = function() {
744
+ var existingFallback, fields, fieldsString, form;
745
+ if (existingFallback = this.getExistingFallback()) {
746
+ return existingFallback;
747
+ }
748
+ fieldsString = "<div class=\"dz-fallback\">";
749
+ if (this.options.dictFallbackText) {
750
+ fieldsString += "<p>" + this.options.dictFallbackText + "</p>";
751
+ }
752
+ fieldsString += "<input type=\"file\" name=\"" + (this._getParamName(0)) + "\" " + (this.options.uploadMultiple ? 'multiple="multiple"' : void 0) + " /><input type=\"submit\" value=\"Upload!\"></div>";
753
+ fields = Dropzone.createElement(fieldsString);
754
+ if (this.element.tagName !== "FORM") {
755
+ form = Dropzone.createElement("<form action=\"" + this.options.url + "\" enctype=\"multipart/form-data\" method=\"" + this.options.method + "\"></form>");
756
+ form.appendChild(fields);
757
+ } else {
758
+ this.element.setAttribute("enctype", "multipart/form-data");
759
+ this.element.setAttribute("method", this.options.method);
760
+ }
761
+ return form != null ? form : fields;
762
+ };
763
+
764
+ Dropzone.prototype.getExistingFallback = function() {
765
+ var fallback, getFallback, tagName, _i, _len, _ref;
766
+ getFallback = function(elements) {
767
+ var el, _i, _len;
768
+ for (_i = 0, _len = elements.length; _i < _len; _i++) {
769
+ el = elements[_i];
770
+ if (/(^| )fallback($| )/.test(el.className)) {
771
+ return el;
772
+ }
773
+ }
774
+ };
775
+ _ref = ["div", "form"];
776
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
777
+ tagName = _ref[_i];
778
+ if (fallback = getFallback(this.element.getElementsByTagName(tagName))) {
779
+ return fallback;
780
+ }
781
+ }
782
+ };
783
+
784
+ Dropzone.prototype.setupEventListeners = function() {
785
+ var elementListeners, event, listener, _i, _len, _ref, _results;
786
+ _ref = this.listeners;
787
+ _results = [];
788
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
789
+ elementListeners = _ref[_i];
790
+ _results.push((function() {
791
+ var _ref1, _results1;
792
+ _ref1 = elementListeners.events;
793
+ _results1 = [];
794
+ for (event in _ref1) {
795
+ listener = _ref1[event];
796
+ _results1.push(elementListeners.element.addEventListener(event, listener, false));
797
+ }
798
+ return _results1;
799
+ })());
800
+ }
801
+ return _results;
802
+ };
803
+
804
+ Dropzone.prototype.removeEventListeners = function() {
805
+ var elementListeners, event, listener, _i, _len, _ref, _results;
806
+ _ref = this.listeners;
807
+ _results = [];
808
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
809
+ elementListeners = _ref[_i];
810
+ _results.push((function() {
811
+ var _ref1, _results1;
812
+ _ref1 = elementListeners.events;
813
+ _results1 = [];
814
+ for (event in _ref1) {
815
+ listener = _ref1[event];
816
+ _results1.push(elementListeners.element.removeEventListener(event, listener, false));
817
+ }
818
+ return _results1;
819
+ })());
820
+ }
821
+ return _results;
822
+ };
823
+
824
+ Dropzone.prototype.disable = function() {
825
+ var file, _i, _len, _ref, _results;
826
+ this.clickableElements.forEach(function(element) {
827
+ return element.classList.remove("dz-clickable");
828
+ });
829
+ this.removeEventListeners();
830
+ _ref = this.files;
831
+ _results = [];
832
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
833
+ file = _ref[_i];
834
+ _results.push(this.cancelUpload(file));
835
+ }
836
+ return _results;
837
+ };
838
+
839
+ Dropzone.prototype.enable = function() {
840
+ this.clickableElements.forEach(function(element) {
841
+ return element.classList.add("dz-clickable");
842
+ });
843
+ return this.setupEventListeners();
844
+ };
845
+
846
+ Dropzone.prototype.filesize = function(size) {
847
+ var cutoff, i, selectedSize, selectedUnit, unit, units, _i, _len;
848
+ selectedSize = 0;
849
+ selectedUnit = "b";
850
+ if (size > 0) {
851
+ units = ['TB', 'GB', 'MB', 'KB', 'b'];
852
+ for (i = _i = 0, _len = units.length; _i < _len; i = ++_i) {
853
+ unit = units[i];
854
+ cutoff = Math.pow(this.options.filesizeBase, 4 - i) / 10;
855
+ if (size >= cutoff) {
856
+ selectedSize = size / Math.pow(this.options.filesizeBase, 4 - i);
857
+ selectedUnit = unit;
858
+ break;
859
+ }
860
+ }
861
+ selectedSize = Math.round(10 * selectedSize) / 10;
862
+ }
863
+ return "<strong>" + selectedSize + "</strong> " + selectedUnit;
864
+ };
865
+
866
+ Dropzone.prototype._updateMaxFilesReachedClass = function() {
867
+ if ((this.options.maxFiles != null) && this.getAcceptedFiles().length >= this.options.maxFiles) {
868
+ if (this.getAcceptedFiles().length === this.options.maxFiles) {
869
+ this.emit('maxfilesreached', this.files);
870
+ }
871
+ return this.element.classList.add("dz-max-files-reached");
872
+ } else {
873
+ return this.element.classList.remove("dz-max-files-reached");
874
+ }
875
+ };
876
+
877
+ Dropzone.prototype.drop = function(e) {
878
+ var files, items;
879
+ if (!e.dataTransfer) {
880
+ return;
881
+ }
882
+ this.emit("drop", e);
883
+ files = e.dataTransfer.files;
884
+ this.emit("addedfiles", files);
885
+ if (files.length) {
886
+ items = e.dataTransfer.items;
887
+ if (items && items.length && (items[0].webkitGetAsEntry != null)) {
888
+ this._addFilesFromItems(items);
889
+ } else {
890
+ this.handleFiles(files);
891
+ }
892
+ }
893
+ };
894
+
895
+ Dropzone.prototype.paste = function(e) {
896
+ var items, _ref;
897
+ if ((e != null ? (_ref = e.clipboardData) != null ? _ref.items : void 0 : void 0) == null) {
898
+ return;
899
+ }
900
+ this.emit("paste", e);
901
+ items = e.clipboardData.items;
902
+ if (items.length) {
903
+ return this._addFilesFromItems(items);
904
+ }
905
+ };
906
+
907
+ Dropzone.prototype.handleFiles = function(files) {
908
+ var file, _i, _len, _results;
909
+ _results = [];
910
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
911
+ file = files[_i];
912
+ _results.push(this.addFile(file));
913
+ }
914
+ return _results;
915
+ };
916
+
917
+ Dropzone.prototype._addFilesFromItems = function(items) {
918
+ var entry, item, _i, _len, _results;
919
+ _results = [];
920
+ for (_i = 0, _len = items.length; _i < _len; _i++) {
921
+ item = items[_i];
922
+ if ((item.webkitGetAsEntry != null) && (entry = item.webkitGetAsEntry())) {
923
+ if (entry.isFile) {
924
+ _results.push(this.addFile(item.getAsFile()));
925
+ } else if (entry.isDirectory) {
926
+ _results.push(this._addFilesFromDirectory(entry, entry.name));
927
+ } else {
928
+ _results.push(void 0);
929
+ }
930
+ } else if (item.getAsFile != null) {
931
+ if ((item.kind == null) || item.kind === "file") {
932
+ _results.push(this.addFile(item.getAsFile()));
933
+ } else {
934
+ _results.push(void 0);
935
+ }
936
+ } else {
937
+ _results.push(void 0);
938
+ }
939
+ }
940
+ return _results;
941
+ };
942
+
943
+ Dropzone.prototype._addFilesFromDirectory = function(directory, path) {
944
+ var dirReader, errorHandler, readEntries;
945
+ dirReader = directory.createReader();
946
+ errorHandler = function(error) {
947
+ return typeof console !== "undefined" && console !== null ? typeof console.log === "function" ? console.log(error) : void 0 : void 0;
948
+ };
949
+ readEntries = (function(_this) {
950
+ return function() {
951
+ return dirReader.readEntries(function(entries) {
952
+ var entry, _i, _len;
953
+ if (entries.length > 0) {
954
+ for (_i = 0, _len = entries.length; _i < _len; _i++) {
955
+ entry = entries[_i];
956
+ if (entry.isFile) {
957
+ entry.file(function(file) {
958
+ if (_this.options.ignoreHiddenFiles && file.name.substring(0, 1) === '.') {
959
+ return;
960
+ }
961
+ file.fullPath = "" + path + "/" + file.name;
962
+ return _this.addFile(file);
963
+ });
964
+ } else if (entry.isDirectory) {
965
+ _this._addFilesFromDirectory(entry, "" + path + "/" + entry.name);
966
+ }
967
+ }
968
+ readEntries();
969
+ }
970
+ return null;
971
+ }, errorHandler);
972
+ };
973
+ })(this);
974
+ return readEntries();
975
+ };
976
+
977
+ Dropzone.prototype.accept = function(file, done) {
978
+ if (file.size > this.options.maxFilesize * 1024 * 1024) {
979
+ return done(this.options.dictFileTooBig.replace("{{filesize}}", Math.round(file.size / 1024 / 10.24) / 100).replace("{{maxFilesize}}", this.options.maxFilesize));
980
+ } else if (!Dropzone.isValidFile(file, this.options.acceptedFiles)) {
981
+ return done(this.options.dictInvalidFileType);
982
+ } else if ((this.options.maxFiles != null) && this.getAcceptedFiles().length >= this.options.maxFiles) {
983
+ done(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}", this.options.maxFiles));
984
+ return this.emit("maxfilesexceeded", file);
985
+ } else {
986
+ return this.options.accept.call(this, file, done);
987
+ }
988
+ };
989
+
990
+ Dropzone.prototype.addFile = function(file) {
991
+ file.upload = {
992
+ progress: 0,
993
+ total: file.size,
994
+ bytesSent: 0
995
+ };
996
+ this.files.push(file);
997
+ file.status = Dropzone.ADDED;
998
+ this.emit("addedfile", file);
999
+ this._enqueueThumbnail(file);
1000
+ return this.accept(file, (function(_this) {
1001
+ return function(error) {
1002
+ if (error) {
1003
+ file.accepted = false;
1004
+ _this._errorProcessing([file], error);
1005
+ } else {
1006
+ file.accepted = true;
1007
+ if (_this.options.autoQueue) {
1008
+ _this.enqueueFile(file);
1009
+ }
1010
+ }
1011
+ return _this._updateMaxFilesReachedClass();
1012
+ };
1013
+ })(this));
1014
+ };
1015
+
1016
+ Dropzone.prototype.enqueueFiles = function(files) {
1017
+ var file, _i, _len;
1018
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
1019
+ file = files[_i];
1020
+ this.enqueueFile(file);
1021
+ }
1022
+ return null;
1023
+ };
1024
+
1025
+ Dropzone.prototype.enqueueFile = function(file) {
1026
+ if (file.status === Dropzone.ADDED && file.accepted === true) {
1027
+ file.status = Dropzone.QUEUED;
1028
+ if (this.options.autoProcessQueue) {
1029
+ return setTimeout(((function(_this) {
1030
+ return function() {
1031
+ return _this.processQueue();
1032
+ };
1033
+ })(this)), 0);
1034
+ }
1035
+ } else {
1036
+ throw new Error("This file can't be queued because it has already been processed or was rejected.");
1037
+ }
1038
+ };
1039
+
1040
+ Dropzone.prototype._thumbnailQueue = [];
1041
+
1042
+ Dropzone.prototype._processingThumbnail = false;
1043
+
1044
+ Dropzone.prototype._enqueueThumbnail = function(file) {
1045
+ if (this.options.createImageThumbnails && file.type.match(/image.*/) && file.size <= this.options.maxThumbnailFilesize * 1024 * 1024) {
1046
+ this._thumbnailQueue.push(file);
1047
+ return setTimeout(((function(_this) {
1048
+ return function() {
1049
+ return _this._processThumbnailQueue();
1050
+ };
1051
+ })(this)), 0);
1052
+ }
1053
+ };
1054
+
1055
+ Dropzone.prototype._processThumbnailQueue = function() {
1056
+ if (this._processingThumbnail || this._thumbnailQueue.length === 0) {
1057
+ return;
1058
+ }
1059
+ this._processingThumbnail = true;
1060
+ return this.createThumbnail(this._thumbnailQueue.shift(), (function(_this) {
1061
+ return function() {
1062
+ _this._processingThumbnail = false;
1063
+ return _this._processThumbnailQueue();
1064
+ };
1065
+ })(this));
1066
+ };
1067
+
1068
+ Dropzone.prototype.removeFile = function(file) {
1069
+ if (file.status === Dropzone.UPLOADING) {
1070
+ this.cancelUpload(file);
1071
+ }
1072
+ this.files = without(this.files, file);
1073
+ this.emit("removedfile", file);
1074
+ if (this.files.length === 0) {
1075
+ return this.emit("reset");
1076
+ }
1077
+ };
1078
+
1079
+ Dropzone.prototype.removeAllFiles = function(cancelIfNecessary) {
1080
+ var file, _i, _len, _ref;
1081
+ if (cancelIfNecessary == null) {
1082
+ cancelIfNecessary = false;
1083
+ }
1084
+ _ref = this.files.slice();
1085
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1086
+ file = _ref[_i];
1087
+ if (file.status !== Dropzone.UPLOADING || cancelIfNecessary) {
1088
+ this.removeFile(file);
1089
+ }
1090
+ }
1091
+ return null;
1092
+ };
1093
+
1094
+ Dropzone.prototype.createThumbnail = function(file, callback) {
1095
+ var fileReader;
1096
+ fileReader = new FileReader;
1097
+ fileReader.onload = (function(_this) {
1098
+ return function() {
1099
+ if (file.type === "image/svg+xml") {
1100
+ _this.emit("thumbnail", file, fileReader.result);
1101
+ if (callback != null) {
1102
+ callback();
1103
+ }
1104
+ return;
1105
+ }
1106
+ return _this.createThumbnailFromUrl(file, fileReader.result, callback);
1107
+ };
1108
+ })(this);
1109
+ return fileReader.readAsDataURL(file);
1110
+ };
1111
+
1112
+ Dropzone.prototype.createThumbnailFromUrl = function(file, imageUrl, callback, crossOrigin) {
1113
+ var img;
1114
+ img = document.createElement("img");
1115
+ if (crossOrigin) {
1116
+ img.crossOrigin = crossOrigin;
1117
+ }
1118
+ img.onload = (function(_this) {
1119
+ return function() {
1120
+ var canvas, ctx, resizeInfo, thumbnail, _ref, _ref1, _ref2, _ref3;
1121
+ file.width = img.width;
1122
+ file.height = img.height;
1123
+ resizeInfo = _this.options.resize.call(_this, file);
1124
+ if (resizeInfo.trgWidth == null) {
1125
+ resizeInfo.trgWidth = resizeInfo.optWidth;
1126
+ }
1127
+ if (resizeInfo.trgHeight == null) {
1128
+ resizeInfo.trgHeight = resizeInfo.optHeight;
1129
+ }
1130
+ canvas = document.createElement("canvas");
1131
+ ctx = canvas.getContext("2d");
1132
+ canvas.width = resizeInfo.trgWidth;
1133
+ canvas.height = resizeInfo.trgHeight;
1134
+ drawImageIOSFix(ctx, img, (_ref = resizeInfo.srcX) != null ? _ref : 0, (_ref1 = resizeInfo.srcY) != null ? _ref1 : 0, resizeInfo.srcWidth, resizeInfo.srcHeight, (_ref2 = resizeInfo.trgX) != null ? _ref2 : 0, (_ref3 = resizeInfo.trgY) != null ? _ref3 : 0, resizeInfo.trgWidth, resizeInfo.trgHeight);
1135
+ thumbnail = canvas.toDataURL("image/png");
1136
+ _this.emit("thumbnail", file, thumbnail);
1137
+ if (callback != null) {
1138
+ return callback();
1139
+ }
1140
+ };
1141
+ })(this);
1142
+ if (callback != null) {
1143
+ img.onerror = callback;
1144
+ }
1145
+ return img.src = imageUrl;
1146
+ };
1147
+
1148
+ Dropzone.prototype.processQueue = function() {
1149
+ var i, parallelUploads, processingLength, queuedFiles;
1150
+ parallelUploads = this.options.parallelUploads;
1151
+ processingLength = this.getUploadingFiles().length;
1152
+ i = processingLength;
1153
+ if (processingLength >= parallelUploads) {
1154
+ return;
1155
+ }
1156
+ queuedFiles = this.getQueuedFiles();
1157
+ if (!(queuedFiles.length > 0)) {
1158
+ return;
1159
+ }
1160
+ if (this.options.uploadMultiple) {
1161
+ return this.processFiles(queuedFiles.slice(0, parallelUploads - processingLength));
1162
+ } else {
1163
+ while (i < parallelUploads) {
1164
+ if (!queuedFiles.length) {
1165
+ return;
1166
+ }
1167
+ this.processFile(queuedFiles.shift());
1168
+ i++;
1169
+ }
1170
+ }
1171
+ };
1172
+
1173
+ Dropzone.prototype.processFile = function(file) {
1174
+ return this.processFiles([file]);
1175
+ };
1176
+
1177
+ Dropzone.prototype.processFiles = function(files) {
1178
+ var file, _i, _len;
1179
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
1180
+ file = files[_i];
1181
+ file.processing = true;
1182
+ file.status = Dropzone.UPLOADING;
1183
+ this.emit("processing", file);
1184
+ }
1185
+ if (this.options.uploadMultiple) {
1186
+ this.emit("processingmultiple", files);
1187
+ }
1188
+ return this.uploadFiles(files);
1189
+ };
1190
+
1191
+ Dropzone.prototype._getFilesWithXhr = function(xhr) {
1192
+ var file, files;
1193
+ return files = (function() {
1194
+ var _i, _len, _ref, _results;
1195
+ _ref = this.files;
1196
+ _results = [];
1197
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1198
+ file = _ref[_i];
1199
+ if (file.xhr === xhr) {
1200
+ _results.push(file);
1201
+ }
1202
+ }
1203
+ return _results;
1204
+ }).call(this);
1205
+ };
1206
+
1207
+ Dropzone.prototype.cancelUpload = function(file) {
1208
+ var groupedFile, groupedFiles, _i, _j, _len, _len1, _ref;
1209
+ if (file.status === Dropzone.UPLOADING) {
1210
+ groupedFiles = this._getFilesWithXhr(file.xhr);
1211
+ for (_i = 0, _len = groupedFiles.length; _i < _len; _i++) {
1212
+ groupedFile = groupedFiles[_i];
1213
+ groupedFile.status = Dropzone.CANCELED;
1214
+ }
1215
+ file.xhr.abort();
1216
+ for (_j = 0, _len1 = groupedFiles.length; _j < _len1; _j++) {
1217
+ groupedFile = groupedFiles[_j];
1218
+ this.emit("canceled", groupedFile);
1219
+ }
1220
+ if (this.options.uploadMultiple) {
1221
+ this.emit("canceledmultiple", groupedFiles);
1222
+ }
1223
+ } else if ((_ref = file.status) === Dropzone.ADDED || _ref === Dropzone.QUEUED) {
1224
+ file.status = Dropzone.CANCELED;
1225
+ this.emit("canceled", file);
1226
+ if (this.options.uploadMultiple) {
1227
+ this.emit("canceledmultiple", [file]);
1228
+ }
1229
+ }
1230
+ if (this.options.autoProcessQueue) {
1231
+ return this.processQueue();
1232
+ }
1233
+ };
1234
+
1235
+ resolveOption = function() {
1236
+ var args, option;
1237
+ option = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
1238
+ if (typeof option === 'function') {
1239
+ return option.apply(this, args);
1240
+ }
1241
+ return option;
1242
+ };
1243
+
1244
+ Dropzone.prototype.uploadFile = function(file) {
1245
+ return this.uploadFiles([file]);
1246
+ };
1247
+
1248
+ Dropzone.prototype.uploadFiles = function(files) {
1249
+ var file, formData, handleError, headerName, headerValue, headers, i, input, inputName, inputType, key, method, option, progressObj, response, updateProgress, url, value, xhr, _i, _j, _k, _l, _len, _len1, _len2, _len3, _m, _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
1250
+ xhr = new XMLHttpRequest();
1251
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
1252
+ file = files[_i];
1253
+ file.xhr = xhr;
1254
+ }
1255
+ method = resolveOption(this.options.method, files);
1256
+ url = resolveOption(this.options.url, files);
1257
+ xhr.open(method, url, true);
1258
+ xhr.withCredentials = !!this.options.withCredentials;
1259
+ response = null;
1260
+ handleError = (function(_this) {
1261
+ return function() {
1262
+ var _j, _len1, _results;
1263
+ _results = [];
1264
+ for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
1265
+ file = files[_j];
1266
+ _results.push(_this._errorProcessing(files, response || _this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr));
1267
+ }
1268
+ return _results;
1269
+ };
1270
+ })(this);
1271
+ updateProgress = (function(_this) {
1272
+ return function(e) {
1273
+ var allFilesFinished, progress, _j, _k, _l, _len1, _len2, _len3, _results;
1274
+ if (e != null) {
1275
+ progress = 100 * e.loaded / e.total;
1276
+ for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
1277
+ file = files[_j];
1278
+ file.upload = {
1279
+ progress: progress,
1280
+ total: e.total,
1281
+ bytesSent: e.loaded
1282
+ };
1283
+ }
1284
+ } else {
1285
+ allFilesFinished = true;
1286
+ progress = 100;
1287
+ for (_k = 0, _len2 = files.length; _k < _len2; _k++) {
1288
+ file = files[_k];
1289
+ if (!(file.upload.progress === 100 && file.upload.bytesSent === file.upload.total)) {
1290
+ allFilesFinished = false;
1291
+ }
1292
+ file.upload.progress = progress;
1293
+ file.upload.bytesSent = file.upload.total;
1294
+ }
1295
+ if (allFilesFinished) {
1296
+ return;
1297
+ }
1298
+ }
1299
+ _results = [];
1300
+ for (_l = 0, _len3 = files.length; _l < _len3; _l++) {
1301
+ file = files[_l];
1302
+ _results.push(_this.emit("uploadprogress", file, progress, file.upload.bytesSent));
1303
+ }
1304
+ return _results;
1305
+ };
1306
+ })(this);
1307
+ xhr.onload = (function(_this) {
1308
+ return function(e) {
1309
+ var _ref;
1310
+ if (files[0].status === Dropzone.CANCELED) {
1311
+ return;
1312
+ }
1313
+ if (xhr.readyState !== 4) {
1314
+ return;
1315
+ }
1316
+ response = xhr.responseText;
1317
+ if (xhr.getResponseHeader("content-type") && ~xhr.getResponseHeader("content-type").indexOf("application/json")) {
1318
+ try {
1319
+ response = JSON.parse(response);
1320
+ } catch (_error) {
1321
+ e = _error;
1322
+ response = "Invalid JSON response from server.";
1323
+ }
1324
+ }
1325
+ updateProgress();
1326
+ if (!((200 <= (_ref = xhr.status) && _ref < 300))) {
1327
+ return handleError();
1328
+ } else {
1329
+ return _this._finished(files, response, e);
1330
+ }
1331
+ };
1332
+ })(this);
1333
+ xhr.onerror = (function(_this) {
1334
+ return function() {
1335
+ if (files[0].status === Dropzone.CANCELED) {
1336
+ return;
1337
+ }
1338
+ return handleError();
1339
+ };
1340
+ })(this);
1341
+ progressObj = (_ref = xhr.upload) != null ? _ref : xhr;
1342
+ progressObj.onprogress = updateProgress;
1343
+ headers = {
1344
+ "Accept": "application/json",
1345
+ "Cache-Control": "no-cache",
1346
+ "X-Requested-With": "XMLHttpRequest"
1347
+ };
1348
+ if (this.options.headers) {
1349
+ extend(headers, this.options.headers);
1350
+ }
1351
+ for (headerName in headers) {
1352
+ headerValue = headers[headerName];
1353
+ if (headerValue) {
1354
+ xhr.setRequestHeader(headerName, headerValue);
1355
+ }
1356
+ }
1357
+ formData = new FormData();
1358
+ if (this.options.params) {
1359
+ _ref1 = this.options.params;
1360
+ for (key in _ref1) {
1361
+ value = _ref1[key];
1362
+ formData.append(key, value);
1363
+ }
1364
+ }
1365
+ for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
1366
+ file = files[_j];
1367
+ this.emit("sending", file, xhr, formData);
1368
+ }
1369
+ if (this.options.uploadMultiple) {
1370
+ this.emit("sendingmultiple", files, xhr, formData);
1371
+ }
1372
+ if (this.element.tagName === "FORM") {
1373
+ _ref2 = this.element.querySelectorAll("input, textarea, select, button");
1374
+ for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
1375
+ input = _ref2[_k];
1376
+ inputName = input.getAttribute("name");
1377
+ inputType = input.getAttribute("type");
1378
+ if (input.tagName === "SELECT" && input.hasAttribute("multiple")) {
1379
+ _ref3 = input.options;
1380
+ for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
1381
+ option = _ref3[_l];
1382
+ if (option.selected) {
1383
+ formData.append(inputName, option.value);
1384
+ }
1385
+ }
1386
+ } else if (!inputType || ((_ref4 = inputType.toLowerCase()) !== "checkbox" && _ref4 !== "radio") || input.checked) {
1387
+ formData.append(inputName, input.value);
1388
+ }
1389
+ }
1390
+ }
1391
+ for (i = _m = 0, _ref5 = files.length - 1; 0 <= _ref5 ? _m <= _ref5 : _m >= _ref5; i = 0 <= _ref5 ? ++_m : --_m) {
1392
+ formData.append(this._getParamName(i), files[i], this._renameFilename(files[i].name));
1393
+ }
1394
+ return this.submitRequest(xhr, formData, files);
1395
+ };
1396
+
1397
+ Dropzone.prototype.submitRequest = function(xhr, formData, files) {
1398
+ return xhr.send(formData);
1399
+ };
1400
+
1401
+ Dropzone.prototype._finished = function(files, responseText, e) {
1402
+ var file, _i, _len;
1403
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
1404
+ file = files[_i];
1405
+ file.status = Dropzone.SUCCESS;
1406
+ this.emit("success", file, responseText, e);
1407
+ this.emit("complete", file);
1408
+ }
1409
+ if (this.options.uploadMultiple) {
1410
+ this.emit("successmultiple", files, responseText, e);
1411
+ this.emit("completemultiple", files);
1412
+ }
1413
+ if (this.options.autoProcessQueue) {
1414
+ return this.processQueue();
1415
+ }
1416
+ };
1417
+
1418
+ Dropzone.prototype._errorProcessing = function(files, message, xhr) {
1419
+ var file, _i, _len;
1420
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
1421
+ file = files[_i];
1422
+ file.status = Dropzone.ERROR;
1423
+ this.emit("error", file, message, xhr);
1424
+ this.emit("complete", file);
1425
+ }
1426
+ if (this.options.uploadMultiple) {
1427
+ this.emit("errormultiple", files, message, xhr);
1428
+ this.emit("completemultiple", files);
1429
+ }
1430
+ if (this.options.autoProcessQueue) {
1431
+ return this.processQueue();
1432
+ }
1433
+ };
1434
+
1435
+ return Dropzone;
1436
+
1437
+ })(Emitter);
1438
+
1439
+ Dropzone.version = "4.3.0";
1440
+
1441
+ Dropzone.options = {};
1442
+
1443
+ Dropzone.optionsForElement = function(element) {
1444
+ if (element.getAttribute("id")) {
1445
+ return Dropzone.options[camelize(element.getAttribute("id"))];
1446
+ } else {
1447
+ return void 0;
1448
+ }
1449
+ };
1450
+
1451
+ Dropzone.instances = [];
1452
+
1453
+ Dropzone.forElement = function(element) {
1454
+ if (typeof element === "string") {
1455
+ element = document.querySelector(element);
1456
+ }
1457
+ if ((element != null ? element.dropzone : void 0) == null) {
1458
+ throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone.");
1459
+ }
1460
+ return element.dropzone;
1461
+ };
1462
+
1463
+ Dropzone.autoDiscover = true;
1464
+
1465
+ Dropzone.discover = function() {
1466
+ var checkElements, dropzone, dropzones, _i, _len, _results;
1467
+ if (document.querySelectorAll) {
1468
+ dropzones = document.querySelectorAll(".dropzone");
1469
+ } else {
1470
+ dropzones = [];
1471
+ checkElements = function(elements) {
1472
+ var el, _i, _len, _results;
1473
+ _results = [];
1474
+ for (_i = 0, _len = elements.length; _i < _len; _i++) {
1475
+ el = elements[_i];
1476
+ if (/(^| )dropzone($| )/.test(el.className)) {
1477
+ _results.push(dropzones.push(el));
1478
+ } else {
1479
+ _results.push(void 0);
1480
+ }
1481
+ }
1482
+ return _results;
1483
+ };
1484
+ checkElements(document.getElementsByTagName("div"));
1485
+ checkElements(document.getElementsByTagName("form"));
1486
+ }
1487
+ _results = [];
1488
+ for (_i = 0, _len = dropzones.length; _i < _len; _i++) {
1489
+ dropzone = dropzones[_i];
1490
+ if (Dropzone.optionsForElement(dropzone) !== false) {
1491
+ _results.push(new Dropzone(dropzone));
1492
+ } else {
1493
+ _results.push(void 0);
1494
+ }
1495
+ }
1496
+ return _results;
1497
+ };
1498
+
1499
+ Dropzone.blacklistedBrowsers = [/opera.*Macintosh.*version\/12/i];
1500
+
1501
+ Dropzone.isBrowserSupported = function() {
1502
+ var capableBrowser, regex, _i, _len, _ref;
1503
+ capableBrowser = true;
1504
+ if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) {
1505
+ if (!("classList" in document.createElement("a"))) {
1506
+ capableBrowser = false;
1507
+ } else {
1508
+ _ref = Dropzone.blacklistedBrowsers;
1509
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1510
+ regex = _ref[_i];
1511
+ if (regex.test(navigator.userAgent)) {
1512
+ capableBrowser = false;
1513
+ continue;
1514
+ }
1515
+ }
1516
+ }
1517
+ } else {
1518
+ capableBrowser = false;
1519
+ }
1520
+ return capableBrowser;
1521
+ };
1522
+
1523
+ without = function(list, rejectedItem) {
1524
+ var item, _i, _len, _results;
1525
+ _results = [];
1526
+ for (_i = 0, _len = list.length; _i < _len; _i++) {
1527
+ item = list[_i];
1528
+ if (item !== rejectedItem) {
1529
+ _results.push(item);
1530
+ }
1531
+ }
1532
+ return _results;
1533
+ };
1534
+
1535
+ camelize = function(str) {
1536
+ return str.replace(/[\-_](\w)/g, function(match) {
1537
+ return match.charAt(1).toUpperCase();
1538
+ });
1539
+ };
1540
+
1541
+ Dropzone.createElement = function(string) {
1542
+ var div;
1543
+ div = document.createElement("div");
1544
+ div.innerHTML = string;
1545
+ return div.childNodes[0];
1546
+ };
1547
+
1548
+ Dropzone.elementInside = function(element, container) {
1549
+ if (element === container) {
1550
+ return true;
1551
+ }
1552
+ while (element = element.parentNode) {
1553
+ if (element === container) {
1554
+ return true;
1555
+ }
1556
+ }
1557
+ return false;
1558
+ };
1559
+
1560
+ Dropzone.getElement = function(el, name) {
1561
+ var element;
1562
+ if (typeof el === "string") {
1563
+ element = document.querySelector(el);
1564
+ } else if (el.nodeType != null) {
1565
+ element = el;
1566
+ }
1567
+ if (element == null) {
1568
+ throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector or a plain HTML element.");
1569
+ }
1570
+ return element;
1571
+ };
1572
+
1573
+ Dropzone.getElements = function(els, name) {
1574
+ var e, el, elements, _i, _j, _len, _len1, _ref;
1575
+ if (els instanceof Array) {
1576
+ elements = [];
1577
+ try {
1578
+ for (_i = 0, _len = els.length; _i < _len; _i++) {
1579
+ el = els[_i];
1580
+ elements.push(this.getElement(el, name));
1581
+ }
1582
+ } catch (_error) {
1583
+ e = _error;
1584
+ elements = null;
1585
+ }
1586
+ } else if (typeof els === "string") {
1587
+ elements = [];
1588
+ _ref = document.querySelectorAll(els);
1589
+ for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
1590
+ el = _ref[_j];
1591
+ elements.push(el);
1592
+ }
1593
+ } else if (els.nodeType != null) {
1594
+ elements = [els];
1595
+ }
1596
+ if (!((elements != null) && elements.length)) {
1597
+ throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector, a plain HTML element or a list of those.");
1598
+ }
1599
+ return elements;
1600
+ };
1601
+
1602
+ Dropzone.confirm = function(question, accepted, rejected) {
1603
+ if (window.confirm(question)) {
1604
+ return accepted();
1605
+ } else if (rejected != null) {
1606
+ return rejected();
1607
+ }
1608
+ };
1609
+
1610
+ Dropzone.isValidFile = function(file, acceptedFiles) {
1611
+ var baseMimeType, mimeType, validType, _i, _len;
1612
+ if (!acceptedFiles) {
1613
+ return true;
1614
+ }
1615
+ acceptedFiles = acceptedFiles.split(",");
1616
+ mimeType = file.type;
1617
+ baseMimeType = mimeType.replace(/\/.*$/, "");
1618
+ for (_i = 0, _len = acceptedFiles.length; _i < _len; _i++) {
1619
+ validType = acceptedFiles[_i];
1620
+ validType = validType.trim();
1621
+ if (validType.charAt(0) === ".") {
1622
+ if (file.name.toLowerCase().indexOf(validType.toLowerCase(), file.name.length - validType.length) !== -1) {
1623
+ return true;
1624
+ }
1625
+ } else if (/\/\*$/.test(validType)) {
1626
+ if (baseMimeType === validType.replace(/\/.*$/, "")) {
1627
+ return true;
1628
+ }
1629
+ } else {
1630
+ if (mimeType === validType) {
1631
+ return true;
1632
+ }
1633
+ }
1634
+ }
1635
+ return false;
1636
+ };
1637
+
1638
+ if (typeof jQuery !== "undefined" && jQuery !== null) {
1639
+ jQuery.fn.dropzone = function(options) {
1640
+ return this.each(function() {
1641
+ return new Dropzone(this, options);
1642
+ });
1643
+ };
1644
+ }
1645
+
1646
+ if (typeof module !== "undefined" && module !== null) {
1647
+ module.exports = Dropzone;
1648
+ } else {
1649
+ window.Dropzone = Dropzone;
1650
+ }
1651
+
1652
+ Dropzone.ADDED = "added";
1653
+
1654
+ Dropzone.QUEUED = "queued";
1655
+
1656
+ Dropzone.ACCEPTED = Dropzone.QUEUED;
1657
+
1658
+ Dropzone.UPLOADING = "uploading";
1659
+
1660
+ Dropzone.PROCESSING = Dropzone.UPLOADING;
1661
+
1662
+ Dropzone.CANCELED = "canceled";
1663
+
1664
+ Dropzone.ERROR = "error";
1665
+
1666
+ Dropzone.SUCCESS = "success";
1667
+
1668
+
1669
+ /*
1670
+
1671
+ Bugfix for iOS 6 and 7
1672
+ Source: http://stackoverflow.com/questions/11929099/html5-canvas-drawimage-ratio-bug-ios
1673
+ based on the work of https://github.com/stomita/ios-imagefile-megapixel
1674
+ */
1675
+
1676
+ detectVerticalSquash = function(img) {
1677
+ var alpha, canvas, ctx, data, ey, ih, iw, py, ratio, sy;
1678
+ iw = img.naturalWidth;
1679
+ ih = img.naturalHeight;
1680
+ canvas = document.createElement("canvas");
1681
+ canvas.width = 1;
1682
+ canvas.height = ih;
1683
+ ctx = canvas.getContext("2d");
1684
+ ctx.drawImage(img, 0, 0);
1685
+ data = ctx.getImageData(0, 0, 1, ih).data;
1686
+ sy = 0;
1687
+ ey = ih;
1688
+ py = ih;
1689
+ while (py > sy) {
1690
+ alpha = data[(py - 1) * 4 + 3];
1691
+ if (alpha === 0) {
1692
+ ey = py;
1693
+ } else {
1694
+ sy = py;
1695
+ }
1696
+ py = (ey + sy) >> 1;
1697
+ }
1698
+ ratio = py / ih;
1699
+ if (ratio === 0) {
1700
+ return 1;
1701
+ } else {
1702
+ return ratio;
1703
+ }
1704
+ };
1705
+
1706
+ drawImageIOSFix = function(ctx, img, sx, sy, sw, sh, dx, dy, dw, dh) {
1707
+ var vertSquashRatio;
1708
+ vertSquashRatio = detectVerticalSquash(img);
1709
+ return ctx.drawImage(img, sx, sy, sw, sh, dx, dy, dw, dh / vertSquashRatio);
1710
+ };
1711
+
1712
+
1713
+ /*
1714
+ * contentloaded.js
1715
+ *
1716
+ * Author: Diego Perini (diego.perini at gmail.com)
1717
+ * Summary: cross-browser wrapper for DOMContentLoaded
1718
+ * Updated: 20101020
1719
+ * License: MIT
1720
+ * Version: 1.2
1721
+ *
1722
+ * URL:
1723
+ * http://javascript.nwbox.com/ContentLoaded/
1724
+ * http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE
1725
+ */
1726
+
1727
+ contentLoaded = function(win, fn) {
1728
+ var add, doc, done, init, poll, pre, rem, root, top;
1729
+ done = false;
1730
+ top = true;
1731
+ doc = win.document;
1732
+ root = doc.documentElement;
1733
+ add = (doc.addEventListener ? "addEventListener" : "attachEvent");
1734
+ rem = (doc.addEventListener ? "removeEventListener" : "detachEvent");
1735
+ pre = (doc.addEventListener ? "" : "on");
1736
+ init = function(e) {
1737
+ if (e.type === "readystatechange" && doc.readyState !== "complete") {
1738
+ return;
1739
+ }
1740
+ (e.type === "load" ? win : doc)[rem](pre + e.type, init, false);
1741
+ if (!done && (done = true)) {
1742
+ return fn.call(win, e.type || e);
1743
+ }
1744
+ };
1745
+ poll = function() {
1746
+ var e;
1747
+ try {
1748
+ root.doScroll("left");
1749
+ } catch (_error) {
1750
+ e = _error;
1751
+ setTimeout(poll, 50);
1752
+ return;
1753
+ }
1754
+ return init("poll");
1755
+ };
1756
+ if (doc.readyState !== "complete") {
1757
+ if (doc.createEventObject && root.doScroll) {
1758
+ try {
1759
+ top = !win.frameElement;
1760
+ } catch (_error) {}
1761
+ if (top) {
1762
+ poll();
1763
+ }
1764
+ }
1765
+ doc[add](pre + "DOMContentLoaded", init, false);
1766
+ doc[add](pre + "readystatechange", init, false);
1767
+ return win[add](pre + "load", init, false);
1768
+ }
1769
+ };
1770
+
1771
+ Dropzone._autoDiscoverFunction = function() {
1772
+ if (Dropzone.autoDiscover) {
1773
+ return Dropzone.discover();
1774
+ }
1775
+ };
1776
+
1777
+ contentLoaded(window, Dropzone._autoDiscoverFunction);
1778
+
1779
+ }).call(this);
1780
+
1781
+ return module.exports;
1782
+ }));