webuploader.min.js 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138
  1. /* WebUploader 0.1.2 */ ! function(a, b) {
  2. var c, d = {},
  3. e = function(a, b) {
  4. var c, d, e;
  5. if("string" == typeof a) return h(a);
  6. for(c = [], d = a.length, e = 0; d > e; e++) c.push(h(a[e]));
  7. return b.apply(null, c)
  8. },
  9. f = function(a, b, c) {
  10. 2 === arguments.length && (c = b, b = null), e(b || [], function() {
  11. g(a, c, arguments)
  12. })
  13. },
  14. g = function(a, b, c) {
  15. var f, g = {
  16. exports: b
  17. };
  18. "function" == typeof b && (c.length || (c = [e, g.exports, g]), f = b.apply(null, c), void 0 !== f && (g.exports = f)), d[a] = g.exports
  19. },
  20. h = function(b) {
  21. var c = d[b] || a[b];
  22. if(!c) throw new Error("`" + b + "` is undefined");
  23. return c
  24. },
  25. i = function(a) {
  26. var b, c, e, f, g, h;
  27. h = function(a) {
  28. return a && a.charAt(0).toUpperCase() + a.substr(1)
  29. };
  30. for(b in d)
  31. if(c = a, d.hasOwnProperty(b)) {
  32. for(e = b.split("/"), g = h(e.pop()); f = h(e.shift());) c[f] = c[f] || {}, c = c[f];
  33. c[g] = d[b]
  34. }
  35. },
  36. j = b(a, f, e);
  37. i(j), "object" == typeof module && "object" == typeof module.exports ? module.exports = j : "function" == typeof define && define.amd ? define([], j) : (c = a.WebUploader, a.WebUploader = j, a.WebUploader.noConflict = function() {
  38. a.WebUploader = c
  39. })
  40. }(this, function(a, b, c) {
  41. return b("dollar-third", [], function() {
  42. return a.jQuery || a.Zepto
  43. }), b("dollar", ["dollar-third"], function(a) {
  44. return a
  45. }), b("promise-third", ["dollar"], function(a) {
  46. return {
  47. Deferred: a.Deferred,
  48. when: a.when,
  49. isPromise: function(a) {
  50. return a && "function" == typeof a.then
  51. }
  52. }
  53. }), b("promise", ["promise-third"], function(a) {
  54. return a
  55. }), b("base", ["dollar", "promise"], function(b, c) {
  56. function d(a) {
  57. return function() {
  58. return h.apply(a, arguments)
  59. }
  60. }
  61. function e(a, b) {
  62. return function() {
  63. return a.apply(b, arguments)
  64. }
  65. }
  66. function f(a) {
  67. var b;
  68. return Object.create ? Object.create(a) : (b = function() {}, b.prototype = a, new b)
  69. }
  70. var g = function() {},
  71. h = Function.call;
  72. return {
  73. version: "0.1.2",
  74. $: b,
  75. Deferred: c.Deferred,
  76. isPromise: c.isPromise,
  77. when: c.when,
  78. browser: function(a) {
  79. var b = {},
  80. c = a.match(/WebKit\/([\d.]+)/),
  81. d = a.match(/Chrome\/([\d.]+)/) || a.match(/CriOS\/([\d.]+)/),
  82. e = a.match(/MSIE\s([\d\.]+)/) || a.match(/(?:trident)(?:.*rv:([\w.]+))?/i),
  83. f = a.match(/Firefox\/([\d.]+)/),
  84. g = a.match(/Safari\/([\d.]+)/),
  85. h = a.match(/OPR\/([\d.]+)/);
  86. return c && (b.webkit = parseFloat(c[1])), d && (b.chrome = parseFloat(d[1])), e && (b.ie = parseFloat(e[1])), f && (b.firefox = parseFloat(f[1])), g && (b.safari = parseFloat(g[1])), h && (b.opera = parseFloat(h[1])), b
  87. }(navigator.userAgent),
  88. os: function(a) {
  89. var b = {},
  90. c = a.match(/(?:Android);?[\s\/]+([\d.]+)?/),
  91. d = a.match(/(?:iPad|iPod|iPhone).*OS\s([\d_]+)/);
  92. return c && (b.android = parseFloat(c[1])), d && (b.ios = parseFloat(d[1].replace(/_/g, "."))), b
  93. }(navigator.userAgent),
  94. inherits: function(a, c, d) {
  95. var e;
  96. return "function" == typeof c ? (e = c, c = null) : e = c && c.hasOwnProperty("constructor") ? c.constructor : function() {
  97. return a.apply(this, arguments)
  98. }, b.extend(!0, e, a, d || {}), e.__super__ = a.prototype, e.prototype = f(a.prototype), c && b.extend(!0, e.prototype, c), e
  99. },
  100. noop: g,
  101. bindFn: e,
  102. log: function() {
  103. return a.console ? e(console.log, console) : g
  104. }(),
  105. nextTick: function() {
  106. return function(a) {
  107. setTimeout(a, 1)
  108. }
  109. }(),
  110. slice: d([].slice),
  111. guid: function() {
  112. var a = 0;
  113. return function(b) {
  114. for(var c = (+new Date).toString(32), d = 0; 5 > d; d++) c += Math.floor(65535 * Math.random()).toString(32);
  115. return(b || "wu_") + c + (a++).toString(32)
  116. }
  117. }(),
  118. formatSize: function(a, b, c) {
  119. var d;
  120. for(c = c || ["B", "K", "M", "G", "TB"];
  121. (d = c.shift()) && a > 1024;) a /= 1024;
  122. return("B" === d ? a : a.toFixed(b || 2)) + d
  123. }
  124. }
  125. }), b("mediator", ["base"], function(a) {
  126. function b(a, b, c, d) {
  127. return f.grep(a, function(a) {
  128. return !(!a || b && a.e !== b || c && a.cb !== c && a.cb._cb !== c || d && a.ctx !== d)
  129. })
  130. }
  131. function c(a, b, c) {
  132. f.each((a || "").split(h), function(a, d) {
  133. c(d, b)
  134. })
  135. }
  136. function d(a, b) {
  137. for(var c, d = !1, e = -1, f = a.length; ++e < f;)
  138. if(c = a[e], c.cb.apply(c.ctx2, b) === !1) {
  139. d = !0;
  140. break
  141. }
  142. return !d
  143. }
  144. var e, f = a.$,
  145. g = [].slice,
  146. h = /\s+/;
  147. return e = {
  148. on: function(a, b, d) {
  149. var e, f = this;
  150. return b ? (e = this._events || (this._events = []), c(a, b, function(a, b) {
  151. var c = {
  152. e: a
  153. };
  154. c.cb = b, c.ctx = d, c.ctx2 = d || f, c.id = e.length, e.push(c)
  155. }), this) : this
  156. },
  157. once: function(a, b, d) {
  158. var e = this;
  159. return b ? (c(a, b, function(a, b) {
  160. var c = function() {
  161. return e.off(a, c), b.apply(d || e, arguments)
  162. };
  163. c._cb = b, e.on(a, c, d)
  164. }), e) : e
  165. },
  166. off: function(a, d, e) {
  167. var g = this._events;
  168. return g ? a || d || e ? (c(a, d, function(a, c) {
  169. f.each(b(g, a, c, e), function() {
  170. delete g[this.id]
  171. })
  172. }), this) : (this._events = [], this) : this
  173. },
  174. trigger: function(a) {
  175. var c, e, f;
  176. return this._events && a ? (c = g.call(arguments, 1), e = b(this._events, a), f = b(this._events, "all"), d(e, c) && d(f, arguments)) : this
  177. }
  178. }, f.extend({
  179. installTo: function(a) {
  180. return f.extend(a, e)
  181. }
  182. }, e)
  183. }), b("uploader", ["base", "mediator"], function(a, b) {
  184. function c(a) {
  185. this.options = d.extend(!0, {}, c.options, a), this._init(this.options)
  186. }
  187. var d = a.$;
  188. return c.options = {}, b.installTo(c.prototype), d.each({
  189. upload: "start-upload",
  190. stop: "stop-upload",
  191. getFile: "get-file",
  192. getFiles: "get-files",
  193. addFile: "add-file",
  194. addFiles: "add-file",
  195. sort: "sort-files",
  196. removeFile: "remove-file",
  197. skipFile: "skip-file",
  198. retry: "retry",
  199. isInProgress: "is-in-progress",
  200. makeThumb: "make-thumb",
  201. getDimension: "get-dimension",
  202. addButton: "add-btn",
  203. getRuntimeType: "get-runtime-type",
  204. refresh: "refresh",
  205. disable: "disable",
  206. enable: "enable",
  207. reset: "reset"
  208. }, function(a, b) {
  209. c.prototype[a] = function() {
  210. return this.request(b, arguments)
  211. }
  212. }), d.extend(c.prototype, {
  213. state: "pending",
  214. _init: function(a) {
  215. var b = this;
  216. b.request("init", a, function() {
  217. b.state = "ready", b.trigger("ready")
  218. })
  219. },
  220. option: function(a, b) {
  221. var c = this.options;
  222. return arguments.length > 1 ? void(d.isPlainObject(b) && d.isPlainObject(c[a]) ? d.extend(c[a], b) : c[a] = b) : a ? c[a] : c
  223. },
  224. getStats: function() {
  225. var a = this.request("get-stats");
  226. return {
  227. successNum: a.numOfSuccess,
  228. cancelNum: a.numOfCancel,
  229. invalidNum: a.numOfInvalid,
  230. uploadFailNum: a.numOfUploadFailed,
  231. queueNum: a.numOfQueue
  232. }
  233. },
  234. trigger: function(a) {
  235. var c = [].slice.call(arguments, 1),
  236. e = this.options,
  237. f = "on" + a.substring(0, 1).toUpperCase() + a.substring(1);
  238. return b.trigger.apply(this, arguments) === !1 || d.isFunction(e[f]) && e[f].apply(this, c) === !1 || d.isFunction(this[f]) && this[f].apply(this, c) === !1 || b.trigger.apply(b, [this, a].concat(c)) === !1 ? !1 : !0
  239. },
  240. request: a.noop
  241. }), a.create = c.create = function(a) {
  242. return new c(a)
  243. }, a.Uploader = c, c
  244. }), b("runtime/runtime", ["base", "mediator"], function(a, b) {
  245. function c(b) {
  246. this.options = d.extend({
  247. container: document.body
  248. }, b), this.uid = a.guid("rt_")
  249. }
  250. var d = a.$,
  251. e = {},
  252. f = function(a) {
  253. for(var b in a)
  254. if(a.hasOwnProperty(b)) return b;
  255. return null
  256. };
  257. return d.extend(c.prototype, {
  258. getContainer: function() {
  259. var a, b, c = this.options;
  260. return this._container ? this._container : (a = d(c.container || document.body), b = d(document.createElement("div")), b.attr("id", "rt_" + this.uid), b.css({
  261. position: "absolute",
  262. top: "0px",
  263. left: "0px",
  264. width: "1px",
  265. height: "1px",
  266. overflow: "hidden"
  267. }), a.append(b), a.addClass("webuploader-container"), this._container = b, b)
  268. },
  269. init: a.noop,
  270. exec: a.noop,
  271. destroy: function() {
  272. this._container && this._container.parentNode.removeChild(this.__container), this.off()
  273. }
  274. }), c.orders = "html5,flash", c.addRuntime = function(a, b) {
  275. e[a] = b
  276. }, c.hasRuntime = function(a) {
  277. return !!(a ? e[a] : f(e))
  278. }, c.create = function(a, b) {
  279. var g, h;
  280. if(b = b || c.orders, d.each(b.split(/\s*,\s*/g), function() {
  281. return e[this] ? (g = this, !1) : void 0
  282. }), g = g || f(e), !g) throw new Error("Runtime Error");
  283. return h = new e[g](a)
  284. }, b.installTo(c.prototype), c
  285. }), b("runtime/client", ["base", "mediator", "runtime/runtime"], function(a, b, c) {
  286. function d(b, d) {
  287. var f, g = a.Deferred();
  288. this.uid = a.guid("client_"), this.runtimeReady = function(a) {
  289. return g.done(a)
  290. }, this.connectRuntime = function(b, h) {
  291. if(f) throw new Error("already connected!");
  292. return g.done(h), "string" == typeof b && e.get(b) && (f = e.get(b)), f = f || e.get(null, d), f ? (a.$.extend(f.options, b), f.__promise.then(g.resolve), f.__client++) : (f = c.create(b, b.runtimeOrder), f.__promise = g.promise(), f.once("ready", g.resolve), f.init(), e.add(f), f.__client = 1), d && (f.__standalone = d), f
  293. }, this.getRuntime = function() {
  294. return f
  295. }, this.disconnectRuntime = function() {
  296. f && (f.__client--, f.__client <= 0 && (e.remove(f), delete f.__promise, f.destroy()), f = null)
  297. }, this.exec = function() {
  298. if(f) {
  299. var c = a.slice(arguments);
  300. return b && c.unshift(b), f.exec.apply(this, c)
  301. }
  302. }, this.getRuid = function() {
  303. return f && f.uid
  304. }, this.destroy = function(a) {
  305. return function() {
  306. a && a.apply(this, arguments), this.trigger("destroy"), this.off(), this.exec("destroy"), this.disconnectRuntime()
  307. }
  308. }(this.destroy)
  309. }
  310. var e;
  311. return e = function() {
  312. var a = {};
  313. return {
  314. add: function(b) {
  315. a[b.uid] = b
  316. },
  317. get: function(b, c) {
  318. var d;
  319. if(b) return a[b];
  320. for(d in a)
  321. if(!c || !a[d].__standalone) return a[d];
  322. return null
  323. },
  324. remove: function(b) {
  325. delete a[b.uid]
  326. }
  327. }
  328. }(), b.installTo(d.prototype), d
  329. }), b("lib/dnd", ["base", "mediator", "runtime/client"], function(a, b, c) {
  330. function d(a) {
  331. a = this.options = e.extend({}, d.options, a), a.container = e(a.container), a.container.length && c.call(this, "DragAndDrop")
  332. }
  333. var e = a.$;
  334. return d.options = {
  335. accept: null,
  336. disableGlobalDnd: !1
  337. }, a.inherits(c, {
  338. constructor: d,
  339. init: function() {
  340. var a = this;
  341. a.connectRuntime(a.options, function() {
  342. a.exec("init"), a.trigger("ready")
  343. })
  344. },
  345. destroy: function() {
  346. this.disconnectRuntime()
  347. }
  348. }), b.installTo(d.prototype), d
  349. }), b("widgets/widget", ["base", "uploader"], function(a, b) {
  350. function c(a) {
  351. if(!a) return !1;
  352. var b = a.length,
  353. c = e.type(a);
  354. return 1 === a.nodeType && b ? !0 : "array" === c || "function" !== c && "string" !== c && (0 === b || "number" == typeof b && b > 0 && b - 1 in a)
  355. }
  356. function d(a) {
  357. this.owner = a, this.options = a.options
  358. }
  359. var e = a.$,
  360. f = b.prototype._init,
  361. g = {},
  362. h = [];
  363. return e.extend(d.prototype, {
  364. init: a.noop,
  365. invoke: function(a, b) {
  366. var c = this.responseMap;
  367. return c && a in c && c[a] in this && e.isFunction(this[c[a]]) ? this[c[a]].apply(this, b) : g
  368. },
  369. request: function() {
  370. return this.owner.request.apply(this.owner, arguments)
  371. }
  372. }), e.extend(b.prototype, {
  373. _init: function() {
  374. var a = this,
  375. b = a._widgets = [];
  376. return e.each(h, function(c, d) {
  377. b.push(new d(a))
  378. }), f.apply(a, arguments)
  379. },
  380. request: function(b, d, e) {
  381. var f, h, i, j, k = 0,
  382. l = this._widgets,
  383. m = l.length,
  384. n = [],
  385. o = [];
  386. for(d = c(d) ? d : [d]; m > k; k++) f = l[k], h = f.invoke(b, d), h !== g && (a.isPromise(h) ? o.push(h) : n.push(h));
  387. return e || o.length ? (i = a.when.apply(a, o), j = i.pipe ? "pipe" : "then", i[j](function() {
  388. var b = a.Deferred(),
  389. c = arguments;
  390. return setTimeout(function() {
  391. b.resolve.apply(b, c)
  392. }, 1), b.promise()
  393. })[j](e || a.noop)) : n[0]
  394. }
  395. }), b.register = d.register = function(b, c) {
  396. var f, g = {
  397. init: "init"
  398. };
  399. return 1 === arguments.length ? (c = b, c.responseMap = g) : c.responseMap = e.extend(g, b), f = a.inherits(d, c), h.push(f), f
  400. }, d
  401. }), b("widgets/filednd", ["base", "uploader", "lib/dnd", "widgets/widget"], function(a, b, c) {
  402. var d = a.$;
  403. return b.options.dnd = "", b.register({
  404. init: function(b) {
  405. if(b.dnd && "html5" === this.request("predict-runtime-type")) {
  406. var e, f = this,
  407. g = a.Deferred(),
  408. h = d.extend({}, {
  409. disableGlobalDnd: b.disableGlobalDnd,
  410. container: b.dnd,
  411. accept: b.accept
  412. });
  413. return e = new c(h), e.once("ready", g.resolve), e.on("drop", function(a) {
  414. f.request("add-file", [a])
  415. }), e.on("accept", function(a) {
  416. return f.owner.trigger("dndAccept", a)
  417. }), e.init(), g.promise()
  418. }
  419. }
  420. })
  421. }), b("lib/filepaste", ["base", "mediator", "runtime/client"], function(a, b, c) {
  422. function d(a) {
  423. a = this.options = e.extend({}, a), a.container = e(a.container || document.body), c.call(this, "FilePaste")
  424. }
  425. var e = a.$;
  426. return a.inherits(c, {
  427. constructor: d,
  428. init: function() {
  429. var a = this;
  430. a.connectRuntime(a.options, function() {
  431. a.exec("init"), a.trigger("ready")
  432. })
  433. },
  434. destroy: function() {
  435. this.exec("destroy"), this.disconnectRuntime(), this.off()
  436. }
  437. }), b.installTo(d.prototype), d
  438. }), b("widgets/filepaste", ["base", "uploader", "lib/filepaste", "widgets/widget"], function(a, b, c) {
  439. var d = a.$;
  440. return b.register({
  441. init: function(b) {
  442. if(b.paste && "html5" === this.request("predict-runtime-type")) {
  443. var e, f = this,
  444. g = a.Deferred(),
  445. h = d.extend({}, {
  446. container: b.paste,
  447. accept: b.accept
  448. });
  449. return e = new c(h), e.once("ready", g.resolve), e.on("paste", function(a) {
  450. f.owner.request("add-file", [a])
  451. }), e.init(), g.promise()
  452. }
  453. }
  454. })
  455. }), b("lib/blob", ["base", "runtime/client"], function(a, b) {
  456. function c(a, c) {
  457. var d = this;
  458. d.source = c, d.ruid = a, b.call(d, "Blob"), this.uid = c.uid || this.uid, this.type = c.type || "", this.size = c.size || 0, a && d.connectRuntime(a)
  459. }
  460. return a.inherits(b, {
  461. constructor: c,
  462. slice: function(a, b) {
  463. return this.exec("slice", a, b)
  464. },
  465. getSource: function() {
  466. return this.source
  467. }
  468. }), c
  469. }), b("lib/file", ["base", "lib/blob"], function(a, b) {
  470. function c(a, c) {
  471. var f;
  472. b.apply(this, arguments), this.name = c.name || "untitled" + d++, f = e.exec(c.name) ? RegExp.$1.toLowerCase() : "", !f && this.type && (f = /\/(jpg|jpeg|png|gif|bmp)$/i.exec(this.type) ? RegExp.$1.toLowerCase() : "", this.name += "." + f), !this.type && ~"jpg,jpeg,png,gif,bmp".indexOf(f) && (this.type = "image/" + ("jpg" === f ? "jpeg" : f)), this.ext = f, this.lastModifiedDate = c.lastModifiedDate || (new Date).toLocaleString()
  473. }
  474. var d = 1,
  475. e = /\.([^.]+)$/;
  476. return a.inherits(b, c)
  477. }), b("lib/filepicker", ["base", "runtime/client", "lib/file"], function(b, c, d) {
  478. function e(a) {
  479. if(a = this.options = f.extend({}, e.options, a), a.container = f(a.id), !a.container.length) throw new Error("按钮指定错误");
  480. a.innerHTML = a.innerHTML || a.label || a.container.html() || "", a.button = f(a.button || document.createElement("div")), a.button.html(a.innerHTML), a.container.html(a.button), c.call(this, "FilePicker", !0)
  481. }
  482. var f = b.$;
  483. return e.options = {
  484. button: null,
  485. container: null,
  486. label: null,
  487. innerHTML: null,
  488. multiple: !0,
  489. accept: null,
  490. name: "file"
  491. }, b.inherits(c, {
  492. constructor: e,
  493. init: function() {
  494. var b = this,
  495. c = b.options,
  496. e = c.button;
  497. e.addClass("webuploader-pick"), b.on("all", function(a) {
  498. var g;
  499. switch(a) {
  500. case "mouseenter":
  501. e.addClass("webuploader-pick-hover");
  502. break;
  503. case "mouseleave":
  504. e.removeClass("webuploader-pick-hover");
  505. break;
  506. case "change":
  507. g = b.exec("getFiles"), b.trigger("select", f.map(g, function(a) {
  508. return a = new d(b.getRuid(), a), a._refer = c.container, a
  509. }), c.container)
  510. }
  511. }), b.connectRuntime(c, function() {
  512. b.refresh(), b.exec("init", c), b.trigger("ready")
  513. }), f(a).on("resize", function() {
  514. b.refresh()
  515. })
  516. },
  517. refresh: function() {
  518. var a = this.getRuntime().getContainer(),
  519. b = this.options.button,
  520. c = b.outerWidth ? b.outerWidth() : b.width(),
  521. d = b.outerHeight ? b.outerHeight() : b.height(),
  522. e = b.offset();
  523. c && d && a.css({
  524. bottom: "auto",
  525. right: "auto",
  526. width: c + "px",
  527. height: d + "px"
  528. }).offset(e)
  529. },
  530. enable: function() {
  531. var a = this.options.button;
  532. a.removeClass("webuploader-pick-disable"), this.refresh()
  533. },
  534. disable: function() {
  535. var a = this.options.button;
  536. this.getRuntime().getContainer().css({
  537. top: "-99999px"
  538. }), a.addClass("webuploader-pick-disable")
  539. },
  540. destroy: function() {
  541. this.runtime && (this.exec("destroy"), this.disconnectRuntime())
  542. }
  543. }), e
  544. }), b("widgets/filepicker", ["base", "uploader", "lib/filepicker", "widgets/widget"], function(a, b, c) {
  545. var d = a.$;
  546. return d.extend(b.options, {
  547. pick: null,
  548. accept: null
  549. }), b.register({
  550. "add-btn": "addButton",
  551. refresh: "refresh",
  552. disable: "disable",
  553. enable: "enable"
  554. }, {
  555. init: function(a) {
  556. return this.pickers = [], a.pick && this.addButton(a.pick)
  557. },
  558. refresh: function() {
  559. d.each(this.pickers, function() {
  560. this.refresh()
  561. })
  562. },
  563. addButton: function(b) {
  564. var e, f, g, h = this,
  565. i = h.options,
  566. j = i.accept;
  567. if(b) return g = a.Deferred(), d.isPlainObject(b) || (b = {
  568. id: b
  569. }), e = d.extend({}, b, {
  570. accept: d.isPlainObject(j) ? [j] : j,
  571. swf: i.swf,
  572. runtimeOrder: i.runtimeOrder
  573. }), f = new c(e), f.once("ready", g.resolve), f.on("select", function(a) {
  574. h.owner.request("add-file", [a])
  575. }), f.init(), this.pickers.push(f), g.promise()
  576. },
  577. disable: function() {
  578. d.each(this.pickers, function() {
  579. this.disable()
  580. })
  581. },
  582. enable: function() {
  583. d.each(this.pickers, function() {
  584. this.enable()
  585. })
  586. }
  587. })
  588. }), b("lib/image", ["base", "runtime/client", "lib/blob"], function(a, b, c) {
  589. function d(a) {
  590. this.options = e.extend({}, d.options, a), b.call(this, "Image"), this.on("load", function() {
  591. this._info = this.exec("info"), this._meta = this.exec("meta")
  592. })
  593. }
  594. var e = a.$;
  595. return d.options = {
  596. quality: 90,
  597. crop: !1,
  598. preserveHeaders: !0,
  599. allowMagnify: !0
  600. }, a.inherits(b, {
  601. constructor: d,
  602. info: function(a) {
  603. return a ? (this._info = a, this) : this._info
  604. },
  605. meta: function(a) {
  606. return a ? (this._meta = a, this) : this._meta
  607. },
  608. loadFromBlob: function(a) {
  609. var b = this,
  610. c = a.getRuid();
  611. this.connectRuntime(c, function() {
  612. b.exec("init", b.options), b.exec("loadFromBlob", a)
  613. })
  614. },
  615. resize: function() {
  616. var b = a.slice(arguments);
  617. return this.exec.apply(this, ["resize"].concat(b))
  618. },
  619. getAsDataUrl: function(a) {
  620. return this.exec("getAsDataUrl", a)
  621. },
  622. getAsBlob: function(a) {
  623. var b = this.exec("getAsBlob", a);
  624. return new c(this.getRuid(), b)
  625. }
  626. }), d
  627. }), b("widgets/image", ["base", "uploader", "lib/image", "widgets/widget"], function(a, b, c) {
  628. var d, e = a.$;
  629. return d = function(a) {
  630. var b = 0,
  631. c = [],
  632. d = function() {
  633. for(var d; c.length && a > b;) d = c.shift(), b += d[0], d[1]()
  634. };
  635. return function(a, e, f) {
  636. c.push([e, f]), a.once("destroy", function() {
  637. b -= e, setTimeout(d, 1)
  638. }), setTimeout(d, 1)
  639. }
  640. }(5242880), e.extend(b.options, {
  641. thumb: {
  642. width: 110,
  643. height: 110,
  644. quality: 70,
  645. allowMagnify: !0,
  646. crop: !0,
  647. preserveHeaders: !1,
  648. type: "image/jpeg"
  649. },
  650. compress: {
  651. width: 1600,
  652. height: 1600,
  653. quality: 90,
  654. allowMagnify: !1,
  655. crop: !1,
  656. preserveHeaders: !0
  657. }
  658. }), b.register({
  659. "make-thumb": "makeThumb",
  660. "before-send-file": "compressImage"
  661. }, {
  662. makeThumb: function(a, b, f, g) {
  663. var h, i;
  664. return a = this.request("get-file", a), a.type.match(/^image/) ? (h = e.extend({}, this.options.thumb), e.isPlainObject(f) && (h = e.extend(h, f), f = null), f = f || h.width, g = g || h.height, i = new c(h), i.once("load", function() {
  665. a._info = a._info || i.info(), a._meta = a._meta || i.meta(), i.resize(f, g)
  666. }), i.once("complete", function() {
  667. b(!1, i.getAsDataUrl(h.type)), i.destroy()
  668. }), i.once("error", function() {
  669. b(!0), i.destroy()
  670. }), void d(i, a.source.size, function() {
  671. a._info && i.info(a._info), a._meta && i.meta(a._meta), i.loadFromBlob(a.source)
  672. })) : void b(!0)
  673. },
  674. compressImage: function(b) {
  675. var d, f, g = this.options.compress || this.options.resize,
  676. h = g && g.compressSize || 307200;
  677. return b = this.request("get-file", b), !g || !~"image/jpeg,image/jpg".indexOf(b.type) || b.size < h || b._compressed ? void 0 : (g = e.extend({}, g), f = a.Deferred(), d = new c(g), f.always(function() {
  678. d.destroy(), d = null
  679. }), d.once("error", f.reject), d.once("load", function() {
  680. b._info = b._info || d.info(), b._meta = b._meta || d.meta(), d.resize(g.width, g.height)
  681. }), d.once("complete", function() {
  682. var a, c;
  683. try {
  684. a = d.getAsBlob(g.type), c = b.size, a.size < c && (b.source = a, b.size = a.size, b.trigger("resize", a.size, c)), b._compressed = !0, f.resolve()
  685. } catch(e) {
  686. f.resolve()
  687. }
  688. }), b._info && d.info(b._info), b._meta && d.meta(b._meta), d.loadFromBlob(b.source), f.promise())
  689. }
  690. })
  691. }), b("file", ["base", "mediator"], function(a, b) {
  692. function c() {
  693. return f + g++
  694. }
  695. function d(a) {
  696. this.name = a.name || "Untitled", this.size = a.size || 0, this.type = a.type || "application", this.lastModifiedDate = a.lastModifiedDate || 1 * new Date, this.id = c(), this.ext = h.exec(this.name) ? RegExp.$1 : "", this.statusText = "", i[this.id] = d.Status.INITED, this.source = a, this.loaded = 0, this.on("error", function(a) {
  697. this.setStatus(d.Status.ERROR, a)
  698. })
  699. }
  700. var e = a.$,
  701. f = "WU_FILE_",
  702. g = 0,
  703. h = /\.([^.]+)$/,
  704. i = {};
  705. return e.extend(d.prototype, {
  706. setStatus: function(a, b) {
  707. var c = i[this.id];
  708. "undefined" != typeof b && (this.statusText = b), a !== c && (i[this.id] = a, this.trigger("statuschange", a, c))
  709. },
  710. getStatus: function() {
  711. return i[this.id]
  712. },
  713. getSource: function() {
  714. return this.source
  715. },
  716. destory: function() {
  717. delete i[this.id]
  718. }
  719. }), b.installTo(d.prototype), d.Status = {
  720. INITED: "inited",
  721. QUEUED: "queued",
  722. PROGRESS: "progress",
  723. ERROR: "error",
  724. COMPLETE: "complete",
  725. CANCELLED: "cancelled",
  726. INTERRUPT: "interrupt",
  727. INVALID: "invalid"
  728. }, d
  729. }), b("queue", ["base", "mediator", "file"], function(a, b, c) {
  730. function d() {
  731. this.stats = {
  732. numOfQueue: 0,
  733. numOfSuccess: 0,
  734. numOfCancel: 0,
  735. numOfProgress: 0,
  736. numOfUploadFailed: 0,
  737. numOfInvalid: 0
  738. }, this._queue = [], this._map = {}
  739. }
  740. var e = a.$,
  741. f = c.Status;
  742. return e.extend(d.prototype, {
  743. append: function(a) {
  744. return this._queue.push(a), this._fileAdded(a), this
  745. },
  746. prepend: function(a) {
  747. return this._queue.unshift(a), this._fileAdded(a), this
  748. },
  749. getFile: function(a) {
  750. return "string" != typeof a ? a : this._map[a]
  751. },
  752. fetch: function(a) {
  753. var b, c, d = this._queue.length;
  754. for(a = a || f.QUEUED, b = 0; d > b; b++)
  755. if(c = this._queue[b], a === c.getStatus()) return c;
  756. return null
  757. },
  758. sort: function(a) {
  759. "function" == typeof a && this._queue.sort(a)
  760. },
  761. getFiles: function() {
  762. for(var a, b = [].slice.call(arguments, 0), c = [], d = 0, f = this._queue.length; f > d; d++) a = this._queue[d], (!b.length || ~e.inArray(a.getStatus(), b)) && c.push(a);
  763. return c
  764. },
  765. _fileAdded: function(a) {
  766. var b = this,
  767. c = this._map[a.id];
  768. c || (this._map[a.id] = a, a.on("statuschange", function(a, c) {
  769. b._onFileStatusChange(a, c)
  770. })), a.setStatus(f.QUEUED)
  771. },
  772. _onFileStatusChange: function(a, b) {
  773. var c = this.stats;
  774. switch(b) {
  775. case f.PROGRESS:
  776. c.numOfProgress--;
  777. break;
  778. case f.QUEUED:
  779. c.numOfQueue--;
  780. break;
  781. case f.ERROR:
  782. c.numOfUploadFailed--;
  783. break;
  784. case f.INVALID:
  785. c.numOfInvalid--
  786. }
  787. switch(a) {
  788. case f.QUEUED:
  789. c.numOfQueue++;
  790. break;
  791. case f.PROGRESS:
  792. c.numOfProgress++;
  793. break;
  794. case f.ERROR:
  795. c.numOfUploadFailed++;
  796. break;
  797. case f.COMPLETE:
  798. c.numOfSuccess++;
  799. break;
  800. case f.CANCELLED:
  801. c.numOfCancel++;
  802. break;
  803. case f.INVALID:
  804. c.numOfInvalid++
  805. }
  806. }
  807. }), b.installTo(d.prototype), d
  808. }), b("widgets/queue", ["base", "uploader", "queue", "file", "lib/file", "runtime/client", "widgets/widget"], function(a, b, c, d, e, f) {
  809. var g = a.$,
  810. h = /\.\w+$/,
  811. i = d.Status;
  812. return b.register({
  813. "sort-files": "sortFiles",
  814. "add-file": "addFiles",
  815. "get-file": "getFile",
  816. "fetch-file": "fetchFile",
  817. "get-stats": "getStats",
  818. "get-files": "getFiles",
  819. "remove-file": "removeFile",
  820. retry: "retry",
  821. reset: "reset",
  822. "accept-file": "acceptFile"
  823. }, {
  824. init: function(b) {
  825. var d, e, h, i, j, k, l, m = this;
  826. if(g.isPlainObject(b.accept) && (b.accept = [b.accept]), b.accept) {
  827. for(j = [], h = 0, e = b.accept.length; e > h; h++) i = b.accept[h].extensions, i && j.push(i);
  828. j.length && (k = "\\." + j.join(",").replace(/,/g, "$|\\.").replace(/\*/g, ".*") + "$"), m.accept = new RegExp(k, "i")
  829. }
  830. return m.queue = new c, m.stats = m.queue.stats, "html5" === this.request("predict-runtime-type") ? (d = a.Deferred(), l = new f("Placeholder"), l.connectRuntime({
  831. runtimeOrder: "html5"
  832. }, function() {
  833. m._ruid = l.getRuid(), d.resolve()
  834. }), d.promise()) : void 0
  835. },
  836. _wrapFile: function(a) {
  837. if(!(a instanceof d)) {
  838. if(!(a instanceof e)) {
  839. if(!this._ruid) throw new Error("Can't add external files.");
  840. a = new e(this._ruid, a)
  841. }
  842. a = new d(a)
  843. }
  844. return a
  845. },
  846. acceptFile: function(a) {
  847. var b = !a || a.size < 6 || this.accept && h.exec(a.name) && !this.accept.test(a.name);
  848. return !b
  849. },
  850. _addFile: function(a) {
  851. var b = this;
  852. return a = b._wrapFile(a), b.owner.trigger("beforeFileQueued", a) ? b.acceptFile(a) ? (b.queue.append(a), b.owner.trigger("fileQueued", a), a) : void b.owner.trigger("error", "Q_TYPE_DENIED", a) : void 0
  853. },
  854. getFile: function(a) {
  855. return this.queue.getFile(a)
  856. },
  857. addFiles: function(a) {
  858. var b = this;
  859. a.length || (a = [a]), a = g.map(a, function(a) {
  860. return b._addFile(a)
  861. }), b.owner.trigger("filesQueued", a), b.options.auto && b.request("start-upload")
  862. },
  863. getStats: function() {
  864. return this.stats
  865. },
  866. removeFile: function(a) {
  867. var b = this;
  868. a = a.id ? a : b.queue.getFile(a), a.setStatus(i.CANCELLED), b.owner.trigger("fileDequeued", a)
  869. },
  870. getFiles: function() {
  871. return this.queue.getFiles.apply(this.queue, arguments)
  872. },
  873. fetchFile: function() {
  874. return this.queue.fetch.apply(this.queue, arguments)
  875. },
  876. retry: function(a, b) {
  877. var c, d, e, f = this;
  878. if(a) return a = a.id ? a : f.queue.getFile(a), a.setStatus(i.QUEUED), void(b || f.request("start-upload"));
  879. for(c = f.queue.getFiles(i.ERROR), d = 0, e = c.length; e > d; d++) a = c[d], a.setStatus(i.QUEUED);
  880. f.request("start-upload")
  881. },
  882. sortFiles: function() {
  883. return this.queue.sort.apply(this.queue, arguments)
  884. },
  885. reset: function() {
  886. this.queue = new c, this.stats = this.queue.stats
  887. }
  888. })
  889. }), b("widgets/runtime", ["uploader", "runtime/runtime", "widgets/widget"], function(a, b) {
  890. return a.support = function() {
  891. return b.hasRuntime.apply(b, arguments)
  892. }, a.register({
  893. "predict-runtime-type": "predictRuntmeType"
  894. }, {
  895. init: function() {
  896. if(!this.predictRuntmeType()) throw Error("Runtime Error")
  897. },
  898. predictRuntmeType: function() {
  899. var a, c, d = this.options.runtimeOrder || b.orders,
  900. e = this.type;
  901. if(!e)
  902. for(d = d.split(/\s*,\s*/g), a = 0, c = d.length; c > a; a++)
  903. if(b.hasRuntime(d[a])) {
  904. this.type = e = d[a];
  905. break
  906. }
  907. return e
  908. }
  909. })
  910. }), b("lib/transport", ["base", "runtime/client", "mediator"], function(a, b, c) {
  911. function d(a) {
  912. var c = this;
  913. a = c.options = e.extend(!0, {}, d.options, a || {}), b.call(this, "Transport"), this._blob = null, this._formData = a.formData || {}, this._headers = a.headers || {}, this.on("progress", this._timeout), this.on("load error", function() {
  914. c.trigger("progress", 1), clearTimeout(c._timer)
  915. })
  916. }
  917. var e = a.$;
  918. return d.options = {
  919. server: "",
  920. method: "POST",
  921. withCredentials: !1,
  922. fileVal: "file",
  923. timeout: 12e4,
  924. formData: {},
  925. headers: {},
  926. sendAsBinary: !1
  927. }, e.extend(d.prototype, {
  928. appendBlob: function(a, b, c) {
  929. var d = this,
  930. e = d.options;
  931. d.getRuid() && d.disconnectRuntime(), d.connectRuntime(b.ruid, function() {
  932. d.exec("init")
  933. }), d._blob = b, e.fileVal = a || e.fileVal, e.filename = c || e.filename
  934. },
  935. append: function(a, b) {
  936. "object" == typeof a ? e.extend(this._formData, a) : this._formData[a] = b
  937. },
  938. setRequestHeader: function(a, b) {
  939. "object" == typeof a ? e.extend(this._headers, a) : this._headers[a] = b
  940. },
  941. send: function(a) {
  942. this.exec("send", a), this._timeout()
  943. },
  944. abort: function() {
  945. return clearTimeout(this._timer), this.exec("abort")
  946. },
  947. destroy: function() {
  948. this.trigger("destroy"), this.off(), this.exec("destroy"), this.disconnectRuntime()
  949. },
  950. getResponse: function() {
  951. return this.exec("getResponse")
  952. },
  953. getResponseAsJson: function() {
  954. return this.exec("getResponseAsJson")
  955. },
  956. getStatus: function() {
  957. return this.exec("getStatus")
  958. },
  959. _timeout: function() {
  960. var a = this,
  961. b = a.options.timeout;
  962. b && (clearTimeout(a._timer), a._timer = setTimeout(function() {
  963. a.abort(), a.trigger("error", "timeout")
  964. }, b))
  965. }
  966. }), c.installTo(d.prototype), d
  967. }), b("widgets/upload", ["base", "uploader", "file", "lib/transport", "widgets/widget"], function(a, b, c, d) {
  968. function e(a, b) {
  969. for(var c, d = [], e = a.source, f = e.size, g = b ? Math.ceil(f / b) : 1, h = 0, i = 0; g > i;) c = Math.min(b, f - h), d.push({
  970. file: a,
  971. start: h,
  972. end: b ? h + c : f,
  973. total: f,
  974. chunks: g,
  975. chunk: i++
  976. }), h += c;
  977. return a.blocks = d.concat(), a.remaning = d.length, {
  978. file: a,
  979. has: function() {
  980. return !!d.length
  981. },
  982. fetch: function() {
  983. return d.shift()
  984. }
  985. }
  986. }
  987. var f = a.$,
  988. g = a.isPromise,
  989. h = c.Status;
  990. f.extend(b.options, {
  991. prepareNextFile: !1,
  992. chunked: !1,
  993. chunkSize: 5242880,
  994. chunkRetry: 2,
  995. threads: 3,
  996. formData: null
  997. }), b.register({
  998. "start-upload": "start",
  999. "stop-upload": "stop",
  1000. "skip-file": "skipFile",
  1001. "is-in-progress": "isInProgress"
  1002. }, {
  1003. init: function() {
  1004. var b = this.owner;
  1005. this.runing = !1, this.pool = [], this.pending = [], this.remaning = 0, this.__tick = a.bindFn(this._tick, this), b.on("uploadComplete", function(a) {
  1006. a.blocks && f.each(a.blocks, function(a, b) {
  1007. b.transport && (b.transport.abort(), b.transport.destroy()), delete b.transport
  1008. }), delete a.blocks, delete a.remaning
  1009. })
  1010. },
  1011. start: function() {
  1012. var b = this;
  1013. f.each(b.request("get-files", h.INVALID), function() {
  1014. b.request("remove-file", this)
  1015. }), b.runing || (b.runing = !0, f.each(b.pool, function(a, c) {
  1016. var d = c.file;
  1017. d.getStatus() === h.INTERRUPT && (d.setStatus(h.PROGRESS), b._trigged = !1, c.transport && c.transport.send())
  1018. }), b._trigged = !1, b.owner.trigger("startUpload"), a.nextTick(b.__tick))
  1019. },
  1020. stop: function(a) {
  1021. var b = this;
  1022. b.runing !== !1 && (b.runing = !1, a && f.each(b.pool, function(a, b) {
  1023. b.transport && b.transport.abort(), b.file.setStatus(h.INTERRUPT)
  1024. }), b.owner.trigger("stopUpload"))
  1025. },
  1026. isInProgress: function() {
  1027. return !!this.runing
  1028. },
  1029. getStats: function() {
  1030. return this.request("get-stats")
  1031. },
  1032. skipFile: function(a, b) {
  1033. a = this.request("get-file", a), a.setStatus(b || h.COMPLETE), a.skipped = !0, a.blocks && f.each(a.blocks, function(a, b) {
  1034. var c = b.transport;
  1035. c && (c.abort(), c.destroy(), delete b.transport)
  1036. }), this.owner.trigger("uploadSkip", a)
  1037. },
  1038. _tick: function() {
  1039. var b, c, d = this,
  1040. e = d.options;
  1041. return d._promise ? d._promise.always(d.__tick) : void(d.pool.length < e.threads && (c = d._nextBlock()) ? (d._trigged = !1, b = function(b) {
  1042. d._promise = null, b && b.file && d._startSend(b), a.nextTick(d.__tick)
  1043. }, d._promise = g(c) ? c.always(b) : b(c)) : d.remaning || d.getStats().numOfQueue || (d.runing = !1, d._trigged || a.nextTick(function() {
  1044. d.owner.trigger("uploadFinished")
  1045. }), d._trigged = !0))
  1046. },
  1047. _nextBlock: function() {
  1048. var a, b, c = this,
  1049. d = c._act,
  1050. f = c.options;
  1051. return d && d.has() && d.file.getStatus() === h.PROGRESS ? (f.prepareNextFile && !c.pending.length && c._prepareNextFile(), d.fetch()) : c.runing ? (!c.pending.length && c.getStats().numOfQueue && c._prepareNextFile(), a = c.pending.shift(), b = function(a) {
  1052. return a ? (d = e(a, f.chunked ? f.chunkSize : 0), c._act = d, d.fetch()) : null
  1053. }, g(a) ? a[a.pipe ? "pipe" : "then"](b) : b(a)) : void 0
  1054. },
  1055. _prepareNextFile: function() {
  1056. var a, b = this,
  1057. c = b.request("fetch-file"),
  1058. d = b.pending;
  1059. c && (a = b.request("before-send-file", c, function() {
  1060. return c.getStatus() === h.QUEUED ? (b.owner.trigger("uploadStart", c), c.setStatus(h.PROGRESS), c) : b._finishFile(c)
  1061. }), a.done(function() {
  1062. var b = f.inArray(a, d);
  1063. ~b && d.splice(b, 1, c)
  1064. }), a.fail(function(a) {
  1065. c.setStatus(h.ERROR, a), b.owner.trigger("uploadError", c, a), b.owner.trigger("uploadComplete", c)
  1066. }), d.push(a))
  1067. },
  1068. _popBlock: function(a) {
  1069. var b = f.inArray(a, this.pool);
  1070. this.pool.splice(b, 1), a.file.remaning--, this.remaning--
  1071. },
  1072. _startSend: function(b) {
  1073. var c, d = this,
  1074. e = b.file;
  1075. d.pool.push(b), d.remaning++, b.blob = 1 === b.chunks ? e.source : e.source.slice(b.start, b.end), c = d.request("before-send", b, function() {
  1076. e.getStatus() === h.PROGRESS ? d._doSend(b) : (d._popBlock(b), a.nextTick(d.__tick))
  1077. }), c.fail(function() {
  1078. 1 === e.remaning ? d._finishFile(e).always(function() {
  1079. b.percentage = 1, d._popBlock(b), d.owner.trigger("uploadComplete", e), a.nextTick(d.__tick)
  1080. }) : (b.percentage = 1, d._popBlock(b), a.nextTick(d.__tick))
  1081. })
  1082. },
  1083. _doSend: function(b) {
  1084. var c, e, g = this,
  1085. i = g.owner,
  1086. j = g.options,
  1087. k = b.file,
  1088. l = new d(j),
  1089. m = f.extend({}, j.formData),
  1090. n = f.extend({}, j.headers);
  1091. b.transport = l, l.on("destroy", function() {
  1092. delete b.transport, g._popBlock(b), a.nextTick(g.__tick)
  1093. }), l.on("progress", function(a) {
  1094. var c = 0,
  1095. d = 0;
  1096. c = b.percentage = a, b.chunks > 1 && (f.each(k.blocks, function(a, b) {
  1097. d += (b.percentage || 0) * (b.end - b.start)
  1098. }), c = d / k.size), i.trigger("uploadProgress", k, c || 0)
  1099. }), c = function(a) {
  1100. var c;
  1101. return e = l.getResponseAsJson() || {}, e._raw = l.getResponse(), c = function(b) {
  1102. a = b
  1103. }, i.trigger("uploadAccept", b, e, c) || (a = a || "server"), a
  1104. }, l.on("error", function(a, d) {
  1105. b.retried = b.retried || 0, b.chunks > 1 && ~"http,abort".indexOf(a) && b.retried < j.chunkRetry ? (b.retried++, l.send()) : (d || "server" !== a || (a = c(a)), k.setStatus(h.ERROR, a), i.trigger("uploadError", k, a), i.trigger("uploadComplete", k))
  1106. }), l.on("load", function() {
  1107. var a;
  1108. return(a = c()) ? void l.trigger("error", a, !0) : void(1 === k.remaning ? g._finishFile(k, e) : l.destroy())
  1109. }), m = f.extend(m, {
  1110. id: k.id,
  1111. name: k.name,
  1112. type: k.type,
  1113. lastModifiedDate: k.lastModifiedDate,
  1114. size: k.size
  1115. }), b.chunks > 1 && f.extend(m, {
  1116. chunks: b.chunks,
  1117. chunk: b.chunk
  1118. }), i.trigger("uploadBeforeSend", b, m, n), l.appendBlob(j.fileVal, b.blob, k.name), l.append(m), l.setRequestHeader(n), l.send()
  1119. },
  1120. _finishFile: function(a, b, c) {
  1121. var d = this.owner;
  1122. return d.request("after-send-file", arguments, function() {
  1123. a.setStatus(h.COMPLETE), d.trigger("uploadSuccess", a, b, c)
  1124. }).fail(function(b) {
  1125. a.getStatus() === h.PROGRESS && a.setStatus(h.ERROR, b), d.trigger("uploadError", a, b)
  1126. }).always(function() {
  1127. d.trigger("uploadComplete", a)
  1128. })
  1129. }
  1130. })
  1131. }), b("widgets/validator", ["base", "uploader", "file", "widgets/widget"], function(a, b, c) {
  1132. var d, e = a.$,
  1133. f = {};
  1134. return d = {
  1135. addValidator: function(a, b) {
  1136. f[a] = b
  1137. },
  1138. removeValidator: function(a) {
  1139. delete f[a]
  1140. }
  1141. }, b.register({
  1142. init: function() {
  1143. var a = this;
  1144. e.each(f, function() {
  1145. this.call(a.owner)
  1146. })
  1147. }
  1148. }), d.addValidator("fileNumLimit", function() {
  1149. var a = this,
  1150. b = a.options,
  1151. c = 0,
  1152. d = b.fileNumLimit >> 0,
  1153. e = !0;
  1154. d && (a.on("beforeFileQueued", function(a) {
  1155. return c >= d && e && (e = !1, this.trigger("error", "Q_EXCEED_NUM_LIMIT", d, a), setTimeout(function() {
  1156. e = !0
  1157. }, 1)), c >= d ? !1 : !0
  1158. }), a.on("fileQueued", function() {
  1159. c++
  1160. }), a.on("fileDequeued", function() {
  1161. c--
  1162. }), a.on("uploadFinished", function() {
  1163. c = 0
  1164. }))
  1165. }), d.addValidator("fileSizeLimit", function() {
  1166. var a = this,
  1167. b = a.options,
  1168. c = 0,
  1169. d = b.fileSizeLimit >> 0,
  1170. e = !0;
  1171. d && (a.on("beforeFileQueued", function(a) {
  1172. var b = c + a.size > d;
  1173. return b && e && (e = !1, this.trigger("error", "Q_EXCEED_SIZE_LIMIT", d, a), setTimeout(function() {
  1174. e = !0
  1175. }, 1)), b ? !1 : !0
  1176. }), a.on("fileQueued", function(a) {
  1177. c += a.size
  1178. }), a.on("fileDequeued", function(a) {
  1179. c -= a.size
  1180. }), a.on("uploadFinished", function() {
  1181. c = 0
  1182. }))
  1183. }), d.addValidator("fileSingleSizeLimit", function() {
  1184. var a = this,
  1185. b = a.options,
  1186. d = b.fileSingleSizeLimit;
  1187. d && a.on("beforeFileQueued", function(a) {
  1188. return a.size > d ? (a.setStatus(c.Status.INVALID, "exceed_size"), this.trigger("error", "F_EXCEED_SIZE", a), !1) : void 0
  1189. })
  1190. }), d.addValidator("duplicate", function() {
  1191. function a(a) {
  1192. for(var b, c = 0, d = 0, e = a.length; e > d; d++) b = a.charCodeAt(d), c = b + (c << 6) + (c << 16) - c;
  1193. return c
  1194. }
  1195. var b = this,
  1196. c = b.options,
  1197. d = {};
  1198. c.duplicate || (b.on("beforeFileQueued", function(b) {
  1199. var c = b.__hash || (b.__hash = a(b.name + b.size + b.lastModifiedDate));
  1200. return d[c] ? (this.trigger("error", "F_DUPLICATE", b), !1) : void 0
  1201. }), b.on("fileQueued", function(a) {
  1202. var b = a.__hash;
  1203. b && (d[b] = !0)
  1204. }), b.on("fileDequeued", function(a) {
  1205. var b = a.__hash;
  1206. b && delete d[b]
  1207. }))
  1208. }), d
  1209. }), b("runtime/compbase", [], function() {
  1210. function a(a, b) {
  1211. this.owner = a, this.options = a.options, this.getRuntime = function() {
  1212. return b
  1213. }, this.getRuid = function() {
  1214. return b.uid
  1215. }, this.trigger = function() {
  1216. return a.trigger.apply(a, arguments)
  1217. }
  1218. }
  1219. return a
  1220. }), b("runtime/html5/runtime", ["base", "runtime/runtime", "runtime/compbase"], function(b, c, d) {
  1221. function e() {
  1222. var a = {},
  1223. d = this,
  1224. e = this.destory;
  1225. c.apply(d, arguments), d.type = f, d.exec = function(c, e) {
  1226. var f, h = this,
  1227. i = h.uid,
  1228. j = b.slice(arguments, 2);
  1229. return g[c] && (f = a[i] = a[i] || new g[c](h, d), f[e]) ? f[e].apply(f, j) : void 0
  1230. }, d.destory = function() {
  1231. return e && e.apply(this, arguments)
  1232. }
  1233. }
  1234. var f = "html5",
  1235. g = {};
  1236. return b.inherits(c, {
  1237. constructor: e,
  1238. init: function() {
  1239. var a = this;
  1240. setTimeout(function() {
  1241. a.trigger("ready")
  1242. }, 1)
  1243. }
  1244. }), e.register = function(a, c) {
  1245. var e = g[a] = b.inherits(d, c);
  1246. return e
  1247. }, a.Blob && a.FileReader && a.DataView && c.addRuntime(f, e), e
  1248. }), b("runtime/html5/blob", ["runtime/html5/runtime", "lib/blob"], function(a, b) {
  1249. return a.register("Blob", {
  1250. slice: function(a, c) {
  1251. var d = this.owner.source,
  1252. e = d.slice || d.webkitSlice || d.mozSlice;
  1253. return d = e.call(d, a, c), new b(this.getRuid(), d)
  1254. }
  1255. })
  1256. }), b("runtime/html5/dnd", ["base", "runtime/html5/runtime", "lib/file"], function(a, b, c) {
  1257. var d = a.$,
  1258. e = "webuploader-dnd-";
  1259. return b.register("DragAndDrop", {
  1260. init: function() {
  1261. var b = this.elem = this.options.container;
  1262. this.dragEnterHandler = a.bindFn(this._dragEnterHandler, this), this.dragOverHandler = a.bindFn(this._dragOverHandler, this), this.dragLeaveHandler = a.bindFn(this._dragLeaveHandler, this), this.dropHandler = a.bindFn(this._dropHandler, this), this.dndOver = !1, b.on("dragenter", this.dragEnterHandler), b.on("dragover", this.dragOverHandler), b.on("dragleave", this.dragLeaveHandler), b.on("drop", this.dropHandler), this.options.disableGlobalDnd && (d(document).on("dragover", this.dragOverHandler), d(document).on("drop", this.dropHandler))
  1263. },
  1264. _dragEnterHandler: function(a) {
  1265. var b, c = this,
  1266. d = c._denied || !1;
  1267. return a = a.originalEvent || a, c.dndOver || (c.dndOver = !0, b = a.dataTransfer.items, b && b.length && (c._denied = d = !c.trigger("accept", b)), c.elem.addClass(e + "over"), c.elem[d ? "addClass" : "removeClass"](e + "denied")), a.dataTransfer.dropEffect = d ? "none" : "copy", !1
  1268. },
  1269. _dragOverHandler: function(a) {
  1270. var b = this.elem.parent().get(0);
  1271. return b && !d.contains(b, a.currentTarget) ? !1 : (clearTimeout(this._leaveTimer), this._dragEnterHandler.call(this, a), !1)
  1272. },
  1273. _dragLeaveHandler: function() {
  1274. var a, b = this;
  1275. return a = function() {
  1276. b.dndOver = !1, b.elem.removeClass(e + "over " + e + "denied")
  1277. }, clearTimeout(b._leaveTimer), b._leaveTimer = setTimeout(a, 100), !1
  1278. },
  1279. _dropHandler: function(a) {
  1280. var b = this,
  1281. f = b.getRuid(),
  1282. g = b.elem.parent().get(0);
  1283. return g && !d.contains(g, a.currentTarget) ? !1 : (b._getTansferFiles(a, function(a) {
  1284. b.trigger("drop", d.map(a, function(a) {
  1285. return new c(f, a)
  1286. }))
  1287. }), b.dndOver = !1, b.elem.removeClass(e + "over"), !1)
  1288. },
  1289. _getTansferFiles: function(b, c) {
  1290. var d, e, f, g, h, i, j, k, l = [],
  1291. m = [];
  1292. for(b = b.originalEvent || b, f = b.dataTransfer, d = f.items, e = f.files, k = !(!d || !d[0].webkitGetAsEntry), i = 0, j = e.length; j > i; i++) g = e[i], h = d && d[i], k && h.webkitGetAsEntry().isDirectory ? m.push(this._traverseDirectoryTree(h.webkitGetAsEntry(), l)) : l.push(g);
  1293. a.when.apply(a, m).done(function() {
  1294. l.length && c(l)
  1295. })
  1296. },
  1297. _traverseDirectoryTree: function(b, c) {
  1298. var d = a.Deferred(),
  1299. e = this;
  1300. return b.isFile ? b.file(function(a) {
  1301. c.push(a), d.resolve()
  1302. }) : b.isDirectory && b.createReader().readEntries(function(b) {
  1303. var f, g = b.length,
  1304. h = [],
  1305. i = [];
  1306. for(f = 0; g > f; f++) h.push(e._traverseDirectoryTree(b[f], i));
  1307. a.when.apply(a, h).then(function() {
  1308. c.push.apply(c, i), d.resolve()
  1309. }, d.reject)
  1310. }), d.promise()
  1311. },
  1312. destroy: function() {
  1313. var a = this.elem;
  1314. a.off("dragenter", this.dragEnterHandler), a.off("dragover", this.dragEnterHandler), a.off("dragleave", this.dragLeaveHandler), a.off("drop", this.dropHandler), this.options.disableGlobalDnd && (d(document).off("dragover", this.dragOverHandler), d(document).off("drop", this.dropHandler))
  1315. }
  1316. })
  1317. }), b("runtime/html5/filepaste", ["base", "runtime/html5/runtime", "lib/file"], function(a, b, c) {
  1318. return b.register("FilePaste", {
  1319. init: function() {
  1320. var b, c, d, e, f = this.options,
  1321. g = this.elem = f.container,
  1322. h = ".*";
  1323. if(f.accept) {
  1324. for(b = [], c = 0, d = f.accept.length; d > c; c++) e = f.accept[c].mimeTypes, e && b.push(e);
  1325. b.length && (h = b.join(","), h = h.replace(/,/g, "|").replace(/\*/g, ".*"))
  1326. }
  1327. this.accept = h = new RegExp(h, "i"), this.hander = a.bindFn(this._pasteHander, this), g.on("paste", this.hander)
  1328. },
  1329. _pasteHander: function(a) {
  1330. var b, d, e, f, g, h = [],
  1331. i = this.getRuid();
  1332. for(a = a.originalEvent || a, b = a.clipboardData.items, f = 0, g = b.length; g > f; f++) d = b[f], "file" === d.kind && (e = d.getAsFile()) && h.push(new c(i, e));
  1333. h.length && (a.preventDefault(), a.stopPropagation(), this.trigger("paste", h))
  1334. },
  1335. destroy: function() {
  1336. this.elem.off("paste", this.hander)
  1337. }
  1338. })
  1339. }), b("runtime/html5/filepicker", ["base", "runtime/html5/runtime"], function(a, b) {
  1340. var c = a.$;
  1341. return b.register("FilePicker", {
  1342. init: function() {
  1343. var a, b, d, e, f = this.getRuntime().getContainer(),
  1344. g = this,
  1345. h = g.owner,
  1346. i = g.options,
  1347. j = c(document.createElement("label")),
  1348. k = c(document.createElement("input"));
  1349. if(k.attr("type", "file"), k.attr("name", i.name), k.addClass("webuploader-element-invisible"), j.on("click", function() {
  1350. k.trigger("click")
  1351. }), j.css({
  1352. opacity: 0,
  1353. width: "100%",
  1354. height: "100%",
  1355. display: "block",
  1356. cursor: "pointer",
  1357. background: "#ffffff"
  1358. }), i.multiple && k.attr("multiple", "multiple"), i.accept && i.accept.length > 0) {
  1359. for(a = [], b = 0, d = i.accept.length; d > b; b++) a.push(i.accept[b].mimeTypes);
  1360. k.attr("accept", a.join(","))
  1361. }
  1362. f.append(k), f.append(j), e = function(a) {
  1363. h.trigger(a.type)
  1364. }, k.on("change", function(a) {
  1365. var b, d = arguments.callee;
  1366. g.files = a.target.files, b = this.cloneNode(!0), this.parentNode.replaceChild(b, this), k.off(), k = c(b).on("change", d).on("mouseenter mouseleave", e), h.trigger("change")
  1367. }), j.on("mouseenter mouseleave", e)
  1368. },
  1369. getFiles: function() {
  1370. return this.files
  1371. },
  1372. destroy: function() {}
  1373. })
  1374. }), b("runtime/html5/util", ["base"], function(b) {
  1375. var c = a.createObjectURL && a || a.URL && URL.revokeObjectURL && URL || a.webkitURL,
  1376. d = b.noop,
  1377. e = d;
  1378. return c && (d = function() {
  1379. return c.createObjectURL.apply(c, arguments)
  1380. }, e = function() {
  1381. return c.revokeObjectURL.apply(c, arguments)
  1382. }), {
  1383. createObjectURL: d,
  1384. revokeObjectURL: e,
  1385. dataURL2Blob: function(a) {
  1386. var b, c, d, e, f, g;
  1387. for(g = a.split(","), b = ~g[0].indexOf("base64") ? atob(g[1]) : decodeURIComponent(g[1]), d = new ArrayBuffer(b.length), c = new Uint8Array(d), e = 0; e < b.length; e++) c[e] = b.charCodeAt(e);
  1388. return f = g[0].split(":")[1].split(";")[0], this.arrayBufferToBlob(d, f)
  1389. },
  1390. dataURL2ArrayBuffer: function(a) {
  1391. var b, c, d, e;
  1392. for(e = a.split(","), b = ~e[0].indexOf("base64") ? atob(e[1]) : decodeURIComponent(e[1]), c = new Uint8Array(b.length), d = 0; d < b.length; d++) c[d] = b.charCodeAt(d);
  1393. return c.buffer
  1394. },
  1395. arrayBufferToBlob: function(b, c) {
  1396. var d, e = a.BlobBuilder || a.WebKitBlobBuilder;
  1397. return e ? (d = new e, d.append(b), d.getBlob(c)) : new Blob([b], c ? {
  1398. type: c
  1399. } : {})
  1400. },
  1401. canvasToDataUrl: function(a, b, c) {
  1402. return a.toDataURL(b, c / 100)
  1403. },
  1404. parseMeta: function(a, b) {
  1405. b(!1, {})
  1406. },
  1407. updateImageHead: function(a) {
  1408. return a
  1409. }
  1410. }
  1411. }), b("runtime/html5/imagemeta", ["runtime/html5/util"], function(a) {
  1412. var b;
  1413. return b = {
  1414. parsers: {
  1415. 65505: []
  1416. },
  1417. maxMetaDataSize: 262144,
  1418. parse: function(a, b) {
  1419. var c = this,
  1420. d = new FileReader;
  1421. d.onload = function() {
  1422. b(!1, c._parse(this.result)), d = d.onload = d.onerror = null
  1423. }, d.onerror = function(a) {
  1424. b(a.message), d = d.onload = d.onerror = null
  1425. }, a = a.slice(0, c.maxMetaDataSize), d.readAsArrayBuffer(a.getSource())
  1426. },
  1427. _parse: function(a, c) {
  1428. if(!(a.byteLength < 6)) {
  1429. var d, e, f, g, h = new DataView(a),
  1430. i = 2,
  1431. j = h.byteLength - 4,
  1432. k = i,
  1433. l = {};
  1434. if(65496 === h.getUint16(0)) {
  1435. for(; j > i && (d = h.getUint16(i), d >= 65504 && 65519 >= d || 65534 === d) && (e = h.getUint16(i + 2) + 2, !(i + e > h.byteLength));) {
  1436. if(f = b.parsers[d], !c && f)
  1437. for(g = 0; g < f.length; g += 1) f[g].call(b, h, i, e, l);
  1438. i += e, k = i
  1439. }
  1440. k > 6 && (l.imageHead = a.slice ? a.slice(2, k) : new Uint8Array(a).subarray(2, k))
  1441. }
  1442. return l
  1443. }
  1444. },
  1445. updateImageHead: function(a, b) {
  1446. var c, d, e, f = this._parse(a, !0);
  1447. return e = 2, f.imageHead && (e = 2 + f.imageHead.byteLength), d = a.slice ? a.slice(e) : new Uint8Array(a).subarray(e), c = new Uint8Array(b.byteLength + 2 + d.byteLength), c[0] = 255, c[1] = 216, c.set(new Uint8Array(b), 2), c.set(new Uint8Array(d), b.byteLength + 2), c.buffer
  1448. }
  1449. }, a.parseMeta = function() {
  1450. return b.parse.apply(b, arguments)
  1451. }, a.updateImageHead = function() {
  1452. return b.updateImageHead.apply(b, arguments)
  1453. }, b
  1454. }), b("runtime/html5/imagemeta/exif", ["base", "runtime/html5/imagemeta"], function(a, b) {
  1455. var c = {};
  1456. return c.ExifMap = function() {
  1457. return this
  1458. }, c.ExifMap.prototype.map = {
  1459. Orientation: 274
  1460. }, c.ExifMap.prototype.get = function(a) {
  1461. return this[a] || this[this.map[a]]
  1462. }, c.exifTagTypes = {
  1463. 1: {
  1464. getValue: function(a, b) {
  1465. return a.getUint8(b)
  1466. },
  1467. size: 1
  1468. },
  1469. 2: {
  1470. getValue: function(a, b) {
  1471. return String.fromCharCode(a.getUint8(b))
  1472. },
  1473. size: 1,
  1474. ascii: !0
  1475. },
  1476. 3: {
  1477. getValue: function(a, b, c) {
  1478. return a.getUint16(b, c)
  1479. },
  1480. size: 2
  1481. },
  1482. 4: {
  1483. getValue: function(a, b, c) {
  1484. return a.getUint32(b, c)
  1485. },
  1486. size: 4
  1487. },
  1488. 5: {
  1489. getValue: function(a, b, c) {
  1490. return a.getUint32(b, c) / a.getUint32(b + 4, c)
  1491. },
  1492. size: 8
  1493. },
  1494. 9: {
  1495. getValue: function(a, b, c) {
  1496. return a.getInt32(b, c)
  1497. },
  1498. size: 4
  1499. },
  1500. 10: {
  1501. getValue: function(a, b, c) {
  1502. return a.getInt32(b, c) / a.getInt32(b + 4, c)
  1503. },
  1504. size: 8
  1505. }
  1506. }, c.exifTagTypes[7] = c.exifTagTypes[1], c.getExifValue = function(b, d, e, f, g, h) {
  1507. var i, j, k, l, m, n, o = c.exifTagTypes[f];
  1508. if(!o) return void a.log("Invalid Exif data: Invalid tag type.");
  1509. if(i = o.size * g, j = i > 4 ? d + b.getUint32(e + 8, h) : e + 8, j + i > b.byteLength) return void a.log("Invalid Exif data: Invalid data offset.");
  1510. if(1 === g) return o.getValue(b, j, h);
  1511. for(k = [], l = 0; g > l; l += 1) k[l] = o.getValue(b, j + l * o.size, h);
  1512. if(o.ascii) {
  1513. for(m = "", l = 0; l < k.length && (n = k[l], "\x00" !== n); l += 1) m += n;
  1514. return m
  1515. }
  1516. return k
  1517. }, c.parseExifTag = function(a, b, d, e, f) {
  1518. var g = a.getUint16(d, e);
  1519. f.exif[g] = c.getExifValue(a, b, d, a.getUint16(d + 2, e), a.getUint32(d + 4, e), e)
  1520. }, c.parseExifTags = function(b, c, d, e, f) {
  1521. var g, h, i;
  1522. if(d + 6 > b.byteLength) return void a.log("Invalid Exif data: Invalid directory offset.");
  1523. if(g = b.getUint16(d, e), h = d + 2 + 12 * g, h + 4 > b.byteLength) return void a.log("Invalid Exif data: Invalid directory size.");
  1524. for(i = 0; g > i; i += 1) this.parseExifTag(b, c, d + 2 + 12 * i, e, f);
  1525. return b.getUint32(h, e)
  1526. }, c.parseExifData = function(b, d, e, f) {
  1527. var g, h, i = d + 10;
  1528. if(1165519206 === b.getUint32(d + 4)) {
  1529. if(i + 8 > b.byteLength) return void a.log("Invalid Exif data: Invalid segment size.");
  1530. if(0 !== b.getUint16(d + 8)) return void a.log("Invalid Exif data: Missing byte alignment offset.");
  1531. switch(b.getUint16(i)) {
  1532. case 18761:
  1533. g = !0;
  1534. break;
  1535. case 19789:
  1536. g = !1;
  1537. break;
  1538. default:
  1539. return void a.log("Invalid Exif data: Invalid byte alignment marker.")
  1540. }
  1541. if(42 !== b.getUint16(i + 2, g)) return void a.log("Invalid Exif data: Missing TIFF marker.");
  1542. h = b.getUint32(i + 4, g), f.exif = new c.ExifMap, h = c.parseExifTags(b, i, i + h, g, f)
  1543. }
  1544. }, b.parsers[65505].push(c.parseExifData), c
  1545. }), b("runtime/html5/jpegencoder", [], function() {
  1546. function a(a) {
  1547. function b(a) {
  1548. for(var b = [16, 11, 10, 16, 24, 40, 51, 61, 12, 12, 14, 19, 26, 58, 60, 55, 14, 13, 16, 24, 40, 57, 69, 56, 14, 17, 22, 29, 51, 87, 80, 62, 18, 22, 37, 56, 68, 109, 103, 77, 24, 35, 55, 64, 81, 104, 113, 92, 49, 64, 78, 87, 103, 121, 120, 101, 72, 92, 95, 98, 112, 100, 103, 99], c = 0; 64 > c; c++) {
  1549. var d = y((b[c] * a + 50) / 100);
  1550. 1 > d ? d = 1 : d > 255 && (d = 255), z[P[c]] = d
  1551. }
  1552. for(var e = [17, 18, 24, 47, 99, 99, 99, 99, 18, 21, 26, 66, 99, 99, 99, 99, 24, 26, 56, 99, 99, 99, 99, 99, 47, 66, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99], f = 0; 64 > f; f++) {
  1553. var g = y((e[f] * a + 50) / 100);
  1554. 1 > g ? g = 1 : g > 255 && (g = 255), A[P[f]] = g
  1555. }
  1556. for(var h = [1, 1.387039845, 1.306562965, 1.175875602, 1, .785694958, .5411961, .275899379], i = 0, j = 0; 8 > j; j++)
  1557. for(var k = 0; 8 > k; k++) B[i] = 1 / (z[P[i]] * h[j] * h[k] * 8), C[i] = 1 / (A[P[i]] * h[j] * h[k] * 8), i++
  1558. }
  1559. function c(a, b) {
  1560. for(var c = 0, d = 0, e = new Array, f = 1; 16 >= f; f++) {
  1561. for(var g = 1; g <= a[f]; g++) e[b[d]] = [], e[b[d]][0] = c, e[b[d]][1] = f, d++, c++;
  1562. c *= 2
  1563. }
  1564. return e
  1565. }
  1566. function d() {
  1567. t = c(Q, R), u = c(U, V), v = c(S, T), w = c(W, X)
  1568. }
  1569. function e() {
  1570. for(var a = 1, b = 2, c = 1; 15 >= c; c++) {
  1571. for(var d = a; b > d; d++) E[32767 + d] = c, D[32767 + d] = [], D[32767 + d][1] = c, D[32767 + d][0] = d;
  1572. for(var e = -(b - 1); - a >= e; e++) E[32767 + e] = c, D[32767 + e] = [], D[32767 + e][1] = c, D[32767 + e][0] = b - 1 + e;
  1573. a <<= 1, b <<= 1
  1574. }
  1575. }
  1576. function f() {
  1577. for(var a = 0; 256 > a; a++) O[a] = 19595 * a, O[a + 256 >> 0] = 38470 * a, O[a + 512 >> 0] = 7471 * a + 32768, O[a + 768 >> 0] = -11059 * a, O[a + 1024 >> 0] = -21709 * a, O[a + 1280 >> 0] = 32768 * a + 8421375, O[a + 1536 >> 0] = -27439 * a, O[a + 1792 >> 0] = -5329 * a
  1578. }
  1579. function g(a) {
  1580. for(var b = a[0], c = a[1] - 1; c >= 0;) b & 1 << c && (I |= 1 << J), c--, J--, 0 > J && (255 == I ? (h(255), h(0)) : h(I), J = 7, I = 0)
  1581. }
  1582. function h(a) {
  1583. H.push(N[a])
  1584. }
  1585. function i(a) {
  1586. h(a >> 8 & 255), h(255 & a)
  1587. }
  1588. function j(a, b) {
  1589. var c, d, e, f, g, h, i, j, k, l = 0,
  1590. m = 8,
  1591. n = 64;
  1592. for(k = 0; m > k; ++k) {
  1593. c = a[l], d = a[l + 1], e = a[l + 2], f = a[l + 3], g = a[l + 4], h = a[l + 5], i = a[l + 6], j = a[l + 7];
  1594. var o = c + j,
  1595. p = c - j,
  1596. q = d + i,
  1597. r = d - i,
  1598. s = e + h,
  1599. t = e - h,
  1600. u = f + g,
  1601. v = f - g,
  1602. w = o + u,
  1603. x = o - u,
  1604. y = q + s,
  1605. z = q - s;
  1606. a[l] = w + y, a[l + 4] = w - y;
  1607. var A = .707106781 * (z + x);
  1608. a[l + 2] = x + A, a[l + 6] = x - A, w = v + t, y = t + r, z = r + p;
  1609. var B = .382683433 * (w - z),
  1610. C = .5411961 * w + B,
  1611. D = 1.306562965 * z + B,
  1612. E = .707106781 * y,
  1613. G = p + E,
  1614. H = p - E;
  1615. a[l + 5] = H + C, a[l + 3] = H - C, a[l + 1] = G + D, a[l + 7] = G - D, l += 8
  1616. }
  1617. for(l = 0, k = 0; m > k; ++k) {
  1618. c = a[l], d = a[l + 8], e = a[l + 16], f = a[l + 24], g = a[l + 32], h = a[l + 40], i = a[l + 48], j = a[l + 56];
  1619. var I = c + j,
  1620. J = c - j,
  1621. K = d + i,
  1622. L = d - i,
  1623. M = e + h,
  1624. N = e - h,
  1625. O = f + g,
  1626. P = f - g,
  1627. Q = I + O,
  1628. R = I - O,
  1629. S = K + M,
  1630. T = K - M;
  1631. a[l] = Q + S, a[l + 32] = Q - S;
  1632. var U = .707106781 * (T + R);
  1633. a[l + 16] = R + U, a[l + 48] = R - U, Q = P + N, S = N + L, T = L + J;
  1634. var V = .382683433 * (Q - T),
  1635. W = .5411961 * Q + V,
  1636. X = 1.306562965 * T + V,
  1637. Y = .707106781 * S,
  1638. Z = J + Y,
  1639. $ = J - Y;
  1640. a[l + 40] = $ + W, a[l + 24] = $ - W, a[l + 8] = Z + X, a[l + 56] = Z - X, l++
  1641. }
  1642. var _;
  1643. for(k = 0; n > k; ++k) _ = a[k] * b[k], F[k] = _ > 0 ? _ + .5 | 0 : _ - .5 | 0;
  1644. return F
  1645. }
  1646. function k() {
  1647. i(65504), i(16), h(74), h(70), h(73), h(70), h(0), h(1), h(1), h(0), i(1), i(1), h(0), h(0)
  1648. }
  1649. function l(a, b) {
  1650. i(65472), i(17), h(8), i(b), i(a), h(3), h(1), h(17), h(0), h(2), h(17), h(1), h(3), h(17), h(1)
  1651. }
  1652. function m() {
  1653. i(65499), i(132), h(0);
  1654. for(var a = 0; 64 > a; a++) h(z[a]);
  1655. h(1);
  1656. for(var b = 0; 64 > b; b++) h(A[b])
  1657. }
  1658. function n() {
  1659. i(65476), i(418), h(0);
  1660. for(var a = 0; 16 > a; a++) h(Q[a + 1]);
  1661. for(var b = 0; 11 >= b; b++) h(R[b]);
  1662. h(16);
  1663. for(var c = 0; 16 > c; c++) h(S[c + 1]);
  1664. for(var d = 0; 161 >= d; d++) h(T[d]);
  1665. h(1);
  1666. for(var e = 0; 16 > e; e++) h(U[e + 1]);
  1667. for(var f = 0; 11 >= f; f++) h(V[f]);
  1668. h(17);
  1669. for(var g = 0; 16 > g; g++) h(W[g + 1]);
  1670. for(var j = 0; 161 >= j; j++) h(X[j])
  1671. }
  1672. function o() {
  1673. i(65498), i(12), h(3), h(1), h(0), h(2), h(17), h(3), h(17), h(0), h(63), h(0)
  1674. }
  1675. function p(a, b, c, d, e) {
  1676. for(var f, h = e[0], i = e[240], k = 16, l = 63, m = 64, n = j(a, b), o = 0; m > o; ++o) G[P[o]] = n[o];
  1677. var p = G[0] - c;
  1678. c = G[0], 0 == p ? g(d[0]) : (f = 32767 + p, g(d[E[f]]), g(D[f]));
  1679. for(var q = 63; q > 0 && 0 == G[q]; q--);
  1680. if(0 == q) return g(h), c;
  1681. for(var r, s = 1; q >= s;) {
  1682. for(var t = s; 0 == G[s] && q >= s; ++s);
  1683. var u = s - t;
  1684. if(u >= k) {
  1685. r = u >> 4;
  1686. for(var v = 1; r >= v; ++v) g(i);
  1687. u = 15 & u
  1688. }
  1689. f = 32767 + G[s], g(e[(u << 4) + E[f]]), g(D[f]), s++
  1690. }
  1691. return q != l && g(h), c
  1692. }
  1693. function q() {
  1694. for(var a = String.fromCharCode, b = 0; 256 > b; b++) N[b] = a(b)
  1695. }
  1696. function r(a) {
  1697. if(0 >= a && (a = 1), a > 100 && (a = 100), x != a) {
  1698. var c = 0;
  1699. c = Math.floor(50 > a ? 5e3 / a : 200 - 2 * a), b(c), x = a
  1700. }
  1701. }
  1702. function s() {
  1703. a || (a = 50), q(), d(), e(), f(), r(a)
  1704. }
  1705. var t, u, v, w, x, y = (Math.round, Math.floor),
  1706. z = new Array(64),
  1707. A = new Array(64),
  1708. B = new Array(64),
  1709. C = new Array(64),
  1710. D = new Array(65535),
  1711. E = new Array(65535),
  1712. F = new Array(64),
  1713. G = new Array(64),
  1714. H = [],
  1715. I = 0,
  1716. J = 7,
  1717. K = new Array(64),
  1718. L = new Array(64),
  1719. M = new Array(64),
  1720. N = new Array(256),
  1721. O = new Array(2048),
  1722. P = [0, 1, 5, 6, 14, 15, 27, 28, 2, 4, 7, 13, 16, 26, 29, 42, 3, 8, 12, 17, 25, 30, 41, 43, 9, 11, 18, 24, 31, 40, 44, 53, 10, 19, 23, 32, 39, 45, 52, 54, 20, 22, 33, 38, 46, 51, 55, 60, 21, 34, 37, 47, 50, 56, 59, 61, 35, 36, 48, 49, 57, 58, 62, 63],
  1723. Q = [0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0],
  1724. R = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
  1725. S = [0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125],
  1726. T = [1, 2, 3, 0, 4, 17, 5, 18, 33, 49, 65, 6, 19, 81, 97, 7, 34, 113, 20, 50, 129, 145, 161, 8, 35, 66, 177, 193, 21, 82, 209, 240, 36, 51, 98, 114, 130, 9, 10, 22, 23, 24, 25, 26, 37, 38, 39, 40, 41, 42, 52, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, 131, 132, 133, 134, 135, 136, 137, 138, 146, 147, 148, 149, 150, 151, 152, 153, 154, 162, 163, 164, 165, 166, 167, 168, 169, 170, 178, 179, 180, 181, 182, 183, 184, 185, 186, 194, 195, 196, 197, 198, 199, 200, 201, 202, 210, 211, 212, 213, 214, 215, 216, 217, 218, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250],
  1727. U = [0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
  1728. V = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
  1729. W = [0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 119],
  1730. X = [0, 1, 2, 3, 17, 4, 5, 33, 49, 6, 18, 65, 81, 7, 97, 113, 19, 34, 50, 129, 8, 20, 66, 145, 161, 177, 193, 9, 35, 51, 82, 240, 21, 98, 114, 209, 10, 22, 36, 52, 225, 37, 241, 23, 24, 25, 26, 38, 39, 40, 41, 42, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, 130, 131, 132, 133, 134, 135, 136, 137, 138, 146, 147, 148, 149, 150, 151, 152, 153, 154, 162, 163, 164, 165, 166, 167, 168, 169, 170, 178, 179, 180, 181, 182, 183, 184, 185, 186, 194, 195, 196, 197, 198, 199, 200, 201, 202, 210, 211, 212, 213, 214, 215, 216, 217, 218, 226, 227, 228, 229, 230, 231, 232, 233, 234, 242, 243, 244, 245, 246, 247, 248, 249, 250];
  1731. this.encode = function(a, b) {
  1732. b && r(b), H = new Array, I = 0, J = 7, i(65496), k(), m(), l(a.width, a.height), n(), o();
  1733. var c = 0,
  1734. d = 0,
  1735. e = 0;
  1736. I = 0, J = 7, this.encode.displayName = "_encode_";
  1737. for(var f, h, j, q, s, x, y, z, A, D = a.data, E = a.width, F = a.height, G = 4 * E, N = 0; F > N;) {
  1738. for(f = 0; G > f;) {
  1739. for(s = G * N + f, x = s, y = -1, z = 0, A = 0; 64 > A; A++) z = A >> 3, y = 4 * (7 & A), x = s + z * G + y, N + z >= F && (x -= G * (N + 1 + z - F)), f + y >= G && (x -= f + y - G + 4), h = D[x++], j = D[x++], q = D[x++], K[A] = (O[h] + O[j + 256 >> 0] + O[q + 512 >> 0] >> 16) - 128, L[A] = (O[h + 768 >> 0] + O[j + 1024 >> 0] + O[q + 1280 >> 0] >> 16) - 128, M[A] = (O[h + 1280 >> 0] + O[j + 1536 >> 0] + O[q + 1792 >> 0] >> 16) - 128;
  1740. c = p(K, B, c, t, v), d = p(L, C, d, u, w), e = p(M, C, e, u, w), f += 32
  1741. }
  1742. N += 8
  1743. }
  1744. if(J >= 0) {
  1745. var P = [];
  1746. P[1] = J + 1, P[0] = (1 << J + 1) - 1, g(P)
  1747. }
  1748. i(65497);
  1749. var Q = "data:image/jpeg;base64," + btoa(H.join(""));
  1750. return H = [], Q
  1751. }, s()
  1752. }
  1753. return a.encode = function(b, c) {
  1754. var d = new a(c);
  1755. return d.encode(b)
  1756. }, a
  1757. }), b("runtime/html5/androidpatch", ["runtime/html5/util", "runtime/html5/jpegencoder", "base"], function(a, b, c) {
  1758. var d, e = a.canvasToDataUrl;
  1759. a.canvasToDataUrl = function(a, f, g) {
  1760. var h, i, j, k, l;
  1761. return c.os.android ? ("image/jpeg" === f && "undefined" == typeof d && (k = e.apply(null, arguments), l = k.split(","), k = ~l[0].indexOf("base64") ? atob(l[1]) : decodeURIComponent(l[1]), k = k.substring(0, 2), d = 255 === k.charCodeAt(0) && 216 === k.charCodeAt(1)), "image/jpeg" !== f || d ? e.apply(null, arguments) : (i = a.width, j = a.height, h = a.getContext("2d"), b.encode(h.getImageData(0, 0, i, j), g))) : e.apply(null, arguments)
  1762. }
  1763. }), b("runtime/html5/image", ["base", "runtime/html5/runtime", "runtime/html5/util"], function(a, b, c) {
  1764. var d = "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D";
  1765. return b.register("Image", {
  1766. modified: !1,
  1767. init: function() {
  1768. var a = this,
  1769. b = new Image;
  1770. b.onload = function() {
  1771. a._info = {
  1772. type: a.type,
  1773. width: this.width,
  1774. height: this.height
  1775. }, a._metas || "image/jpeg" !== a.type ? a.owner.trigger("load") : c.parseMeta(a._blob, function(b, c) {
  1776. a._metas = c, a.owner.trigger("load")
  1777. })
  1778. }, b.onerror = function() {
  1779. a.owner.trigger("error")
  1780. }, a._img = b
  1781. },
  1782. loadFromBlob: function(a) {
  1783. var b = this,
  1784. d = b._img;
  1785. b._blob = a, b.type = a.type, d.src = c.createObjectURL(a.getSource()), b.owner.once("load", function() {
  1786. c.revokeObjectURL(d.src)
  1787. })
  1788. },
  1789. resize: function(a, b) {
  1790. var c = this._canvas || (this._canvas = document.createElement("canvas"));
  1791. this._resize(this._img, c, a, b), this._blob = null, this.modified = !0, this.owner.trigger("complete")
  1792. },
  1793. getAsBlob: function(a) {
  1794. var b, d = this._blob,
  1795. e = this.options;
  1796. if(a = a || this.type, this.modified || this.type !== a) {
  1797. if(b = this._canvas, "image/jpeg" === a) {
  1798. if(d = c.canvasToDataUrl(b, "image/jpeg", e.quality), e.preserveHeaders && this._metas && this._metas.imageHead) return d = c.dataURL2ArrayBuffer(d), d = c.updateImageHead(d, this._metas.imageHead), d = c.arrayBufferToBlob(d, a)
  1799. } else d = c.canvasToDataUrl(b, a);
  1800. d = c.dataURL2Blob(d)
  1801. }
  1802. return d
  1803. },
  1804. getAsDataUrl: function(a) {
  1805. var b = this.options;
  1806. return a = a || this.type, "image/jpeg" === a ? c.canvasToDataUrl(this._canvas, a, b.quality) : this._canvas.toDataURL(a)
  1807. },
  1808. getOrientation: function() {
  1809. return this._metas && this._metas.exif && this._metas.exif.get("Orientation") || 1
  1810. },
  1811. info: function(a) {
  1812. return a ? (this._info = a, this) : this._info
  1813. },
  1814. meta: function(a) {
  1815. return a ? (this._meta = a, this) : this._meta
  1816. },
  1817. destroy: function() {
  1818. var a = this._canvas;
  1819. this._img.onload = null, a && (a.getContext("2d").clearRect(0, 0, a.width, a.height), a.width = a.height = 0, this._canvas = null), this._img.src = d, this._img = this._blob = null
  1820. },
  1821. _resize: function(a, b, c, d) {
  1822. var e, f, g, h, i, j = this.options,
  1823. k = a.width,
  1824. l = a.height,
  1825. m = this.getOrientation();
  1826. ~[5, 6, 7, 8].indexOf(m) && (c ^= d, d ^= c, c ^= d), e = Math[j.crop ? "max" : "min"](c / k, d / l), j.allowMagnify || (e = Math.min(1, e)), f = k * e, g = l * e, j.crop ? (b.width = c, b.height = d) : (b.width = f, b.height = g), h = (b.width - f) / 2, i = (b.height - g) / 2, j.preserveHeaders || this._rotate2Orientaion(b, m), this._renderImageToCanvas(b, a, h, i, f, g)
  1827. },
  1828. _rotate2Orientaion: function(a, b) {
  1829. var c = a.width,
  1830. d = a.height,
  1831. e = a.getContext("2d");
  1832. switch(b) {
  1833. case 5:
  1834. case 6:
  1835. case 7:
  1836. case 8:
  1837. a.width = d, a.height = c
  1838. }
  1839. switch(b) {
  1840. case 2:
  1841. e.translate(c, 0), e.scale(-1, 1);
  1842. break;
  1843. case 3:
  1844. e.translate(c, d), e.rotate(Math.PI);
  1845. break;
  1846. case 4:
  1847. e.translate(0, d), e.scale(1, -1);
  1848. break;
  1849. case 5:
  1850. e.rotate(.5 * Math.PI), e.scale(1, -1);
  1851. break;
  1852. case 6:
  1853. e.rotate(.5 * Math.PI), e.translate(0, -d);
  1854. break;
  1855. case 7:
  1856. e.rotate(.5 * Math.PI), e.translate(c, -d), e.scale(-1, 1);
  1857. break;
  1858. case 8:
  1859. e.rotate(-.5 * Math.PI), e.translate(-c, 0)
  1860. }
  1861. },
  1862. _renderImageToCanvas: function() {
  1863. function b(a, b, c) {
  1864. var d, e, f, g = document.createElement("canvas"),
  1865. h = g.getContext("2d"),
  1866. i = 0,
  1867. j = c,
  1868. k = c;
  1869. for(g.width = 1, g.height = c, h.drawImage(a, 0, 0), d = h.getImageData(0, 0, 1, c).data; k > i;) e = d[4 * (k - 1) + 3], 0 === e ? j = k : i = k, k = j + i >> 1;
  1870. return f = k / c, 0 === f ? 1 : f
  1871. }
  1872. function c(a) {
  1873. var b, c, d = a.naturalWidth,
  1874. e = a.naturalHeight;
  1875. return d * e > 1048576 ? (b = document.createElement("canvas"), b.width = b.height = 1, c = b.getContext("2d"), c.drawImage(a, -d + 1, 0), 0 === c.getImageData(0, 0, 1, 1).data[3]) : !1
  1876. }
  1877. return a.os.ios ? a.os.ios >= 7 ? function(a, c, d, e, f, g) {
  1878. var h = c.naturalWidth,
  1879. i = c.naturalHeight,
  1880. j = b(c, h, i);
  1881. return a.getContext("2d").drawImage(c, 0, 0, h * j, i * j, d, e, f, g)
  1882. } : function(a, d, e, f, g, h) {
  1883. var i, j, k, l, m, n, o, p = d.naturalWidth,
  1884. q = d.naturalHeight,
  1885. r = a.getContext("2d"),
  1886. s = c(d),
  1887. t = "image/jpeg" === this.type,
  1888. u = 1024,
  1889. v = 0,
  1890. w = 0;
  1891. for(s && (p /= 2, q /= 2), r.save(), i = document.createElement("canvas"), i.width = i.height = u, j = i.getContext("2d"), k = t ? b(d, p, q) : 1, l = Math.ceil(u * g / p), m = Math.ceil(u * h / q / k); q > v;) {
  1892. for(n = 0, o = 0; p > n;) j.clearRect(0, 0, u, u), j.drawImage(d, -n, -v), r.drawImage(i, 0, 0, u, u, e + o, f + w, l, m), n += u, o += l;
  1893. v += u, w += m
  1894. }
  1895. r.restore(), i = j = null
  1896. } : function(a, b, c, d, e, f) {
  1897. a.getContext("2d").drawImage(b, c, d, e, f)
  1898. }
  1899. }()
  1900. })
  1901. }), b("runtime/html5/transport", ["base", "runtime/html5/runtime"], function(a, b) {
  1902. var c = a.noop,
  1903. d = a.$;
  1904. return b.register("Transport", {
  1905. init: function() {
  1906. this._status = 0, this._response = null
  1907. },
  1908. send: function() {
  1909. var b, c, e, f = this.owner,
  1910. g = this.options,
  1911. h = this._initAjax(),
  1912. i = f._blob,
  1913. j = g.server;
  1914. // h.setRequestHeader("Authorization",'Bearer ' + (window.localStorage.getItem("pro__Access-Token")?JSON.parse(window.localStorage.getItem("pro__Access-Token")).value:"")),
  1915. g.sendAsBinary ? (j += (/\?/.test(j) ? "&" : "?") + d.param(f._formData), c = i.getSource()) : (b = new FormData, d.each(f._formData, function(a, c) {
  1916. b.append(a, c)
  1917. }), b.append(g.fileVal, i.getSource(), g.filename || f._formData.name || "")), g.withCredentials && "withCredentials" in h ? (h.open(g.method, j, !0), h.withCredentials = !0) : h.open(g.method, j), this._setRequestHeader(h, g.headers), c ? (h.overrideMimeType("application/octet-stream"), a.os.android ? (e = new FileReader, e.onload = function() {
  1918. h.send(this.result), e = e.onload = null
  1919. },
  1920. e.readAsArrayBuffer(c)) : h.send(c)) : h.send(b)
  1921. },
  1922. getResponse: function() {
  1923. return this._response
  1924. },
  1925. getResponseAsJson: function() {
  1926. return this._parseJson(this._response)
  1927. },
  1928. getStatus: function() {
  1929. return this._status
  1930. },
  1931. abort: function() {
  1932. var a = this._xhr;
  1933. a && (a.upload.onprogress = c, a.onreadystatechange = c, a.abort(), this._xhr = a = null)
  1934. },
  1935. destroy: function() {
  1936. this.abort()
  1937. },
  1938. _initAjax: function() {
  1939. var a = this,
  1940. b = new XMLHttpRequest,
  1941. d = this.options;
  1942. return !d.withCredentials || "withCredentials" in b || "undefined" == typeof XDomainRequest || (b = new XDomainRequest), b.upload.onprogress = function(b) {
  1943. var c = 0;
  1944. return b.lengthComputable && (c = b.loaded / b.total), a.trigger("progress", c)
  1945. }, b.onreadystatechange = function() {
  1946. return 4 === b.readyState ? (b.upload.onprogress = c, b.onreadystatechange = c, a._xhr = null, a._status = b.status, b.status >= 200 && b.status < 300 ? (a._response = b.responseText, a.trigger("load")) : b.status >= 500 && b.status < 600 ? (a._response = b.responseText, a.trigger("error", "server")) : a.trigger("error", a._status ? "http" : "abort")) : void 0
  1947. }, a._xhr = b, b
  1948. },
  1949. _setRequestHeader: function(a, b) {
  1950. d.each(b, function(b, c) {
  1951. a.setRequestHeader(b, c)
  1952. })
  1953. a.setRequestHeader("Authorization",'Bearer ' + (window.localStorage.getItem("pro__Access-Token")?JSON.parse(window.localStorage.getItem("pro__Access-Token")).value:""))
  1954. },
  1955. _parseJson: function(a) {
  1956. var b;
  1957. try {
  1958. b = JSON.parse(a)
  1959. } catch(c) {
  1960. b = {}
  1961. }
  1962. return b
  1963. }
  1964. })
  1965. }), b("runtime/flash/runtime", ["base", "runtime/runtime", "runtime/compbase"], function(b, c, d) {
  1966. function e() {
  1967. var a;
  1968. try {
  1969. a = navigator.plugins["Shockwave Flash"], a = a.description
  1970. } catch(b) {
  1971. try {
  1972. a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version")
  1973. } catch(c) {
  1974. a = "0.0"
  1975. }
  1976. }
  1977. return a = a.match(/\d+/g), parseFloat(a[0] + "." + a[1], 10)
  1978. }
  1979. function f() {
  1980. function d(a, b) {
  1981. var c, d, e = a.type || a;
  1982. c = e.split("::"), d = c[0], e = c[1], "Ready" === e && d === j.uid ? j.trigger("ready") : f[d] && f[d].trigger(e.toLowerCase(), a, b)
  1983. }
  1984. var e = {},
  1985. f = {},
  1986. g = this.destory,
  1987. j = this,
  1988. k = b.guid("webuploader_");
  1989. c.apply(j, arguments), j.type = h, j.exec = function(a, c) {
  1990. var d, g = this,
  1991. h = g.uid,
  1992. k = b.slice(arguments, 2);
  1993. return f[h] = g, i[a] && (e[h] || (e[h] = new i[a](g, j)), d = e[h], d[c]) ? d[c].apply(d, k) : j.flashExec.apply(g, arguments)
  1994. }, a[k] = function() {
  1995. var a = arguments;
  1996. setTimeout(function() {
  1997. d.apply(null, a)
  1998. }, 1)
  1999. }, this.jsreciver = k, this.destory = function() {
  2000. return g && g.apply(this, arguments)
  2001. }, this.flashExec = function(a, c) {
  2002. var d = j.getFlash(),
  2003. e = b.slice(arguments, 2);
  2004. return d.exec(this.uid, a, c, e)
  2005. }
  2006. }
  2007. var g = b.$,
  2008. h = "flash",
  2009. i = {};
  2010. return b.inherits(c, {
  2011. constructor: f,
  2012. init: function() {
  2013. var a, c = this.getContainer(),
  2014. d = this.options;
  2015. c.css({
  2016. position: "absolute",
  2017. top: "-8px",
  2018. left: "-8px",
  2019. width: "9px",
  2020. height: "9px",
  2021. overflow: "hidden"
  2022. }), a = '<object id="' + this.uid + '" type="application/x-shockwave-flash" data="' + d.swf + '" ', b.browser.ie && (a += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '), a += 'width="100%" height="100%" style="outline:0"><param name="movie" value="' + d.swf + '" /><param name="flashvars" value="uid=' + this.uid + "&jsreciver=" + this.jsreciver + '" /><param name="wmode" value="transparent" /><param name="allowscriptaccess" value="always" /></object>', c.html(a)
  2023. },
  2024. getFlash: function() {
  2025. return this._flash ? this._flash : (this._flash = g("#" + this.uid).get(0), this._flash)
  2026. }
  2027. }), f.register = function(a, c) {
  2028. return c = i[a] = b.inherits(d, g.extend({
  2029. flashExec: function() {
  2030. var a = this.owner,
  2031. b = this.getRuntime();
  2032. return b.flashExec.apply(a, arguments)
  2033. }
  2034. }, c))
  2035. }, e() >= 11.4 && c.addRuntime(h, f), f
  2036. }), b("runtime/flash/filepicker", ["base", "runtime/flash/runtime"], function(a, b) {
  2037. var c = a.$;
  2038. return b.register("FilePicker", {
  2039. init: function(a) {
  2040. var b, d, e = c.extend({}, a);
  2041. for(b = e.accept && e.accept.length, d = 0; b > d; d++) e.accept[d].title || (e.accept[d].title = "Files");
  2042. delete e.button, delete e.container, this.flashExec("FilePicker", "init", e)
  2043. },
  2044. destroy: function() {}
  2045. })
  2046. }), b("runtime/flash/image", ["runtime/flash/runtime"], function(a) {
  2047. return a.register("Image", {
  2048. loadFromBlob: function(a) {
  2049. var b = this.owner;
  2050. b.info() && this.flashExec("Image", "info", b.info()), b.meta() && this.flashExec("Image", "meta", b.meta()), this.flashExec("Image", "loadFromBlob", a.uid)
  2051. }
  2052. })
  2053. }), b("runtime/flash/transport", ["base", "runtime/flash/runtime", "runtime/client"], function(a, b, c) {
  2054. var d = a.$;
  2055. return b.register("Transport", {
  2056. init: function() {
  2057. this._status = 0, this._response = null, this._responseJson = null
  2058. },
  2059. send: function() {
  2060. var a, b = this.owner,
  2061. c = this.options,
  2062. e = this._initAjax(),
  2063. f = b._blob,
  2064. g = c.server;
  2065. e.connectRuntime(f.ruid), c.sendAsBinary ? (g += (/\?/.test(g) ? "&" : "?") + d.param(b._formData), a = f.uid) : (d.each(b._formData, function(a, b) {
  2066. e.exec("append", a, b)
  2067. }), e.exec("appendBlob", c.fileVal, f.uid, c.filename || b._formData.name || "")), this._setRequestHeader(e, c.headers), e.exec("send", {
  2068. method: c.method,
  2069. url: g
  2070. }, a)
  2071. },
  2072. getStatus: function() {
  2073. return this._status
  2074. },
  2075. getResponse: function() {
  2076. return this._response
  2077. },
  2078. getResponseAsJson: function() {
  2079. return this._responseJson
  2080. },
  2081. abort: function() {
  2082. var a = this._xhr;
  2083. a && (a.exec("abort"), a.destroy(), this._xhr = a = null)
  2084. },
  2085. destroy: function() {
  2086. this.abort()
  2087. },
  2088. _initAjax: function() {
  2089. var a = this,
  2090. b = new c("XMLHttpRequest");
  2091. return b.on("uploadprogress progress", function(b) {
  2092. return a.trigger("progress", b.loaded / b.total)
  2093. }), b.on("load", function() {
  2094. var c = b.exec("getStatus"),
  2095. d = "";
  2096. return b.off(), a._xhr = null, c >= 200 && 300 > c ? (a._response = b.exec("getResponse"), a._responseJson = b.exec("getResponseAsJson")) : c >= 500 && 600 > c ? (a._response = b.exec("getResponse"), a._responseJson = b.exec("getResponseAsJson"), d = "server") : d = "http", b.destroy(), b = null, d ? a.trigger("error", d) : a.trigger("load")
  2097. }), b.on("error", function() {
  2098. b.off(), a._xhr = null, a.trigger("error", "http")
  2099. }), a._xhr = b, b
  2100. },
  2101. _setRequestHeader: function(a, b) {
  2102. d.each(b, function(b, c) {
  2103. a.exec("setRequestHeader", b, c)
  2104. })
  2105. a.exec("setRequestHeader", b, c)
  2106. }
  2107. })
  2108. }), b("preset/all", ["base", "widgets/filednd", "widgets/filepaste", "widgets/filepicker", "widgets/image", "widgets/queue", "widgets/runtime", "widgets/upload", "widgets/validator", "runtime/html5/blob", "runtime/html5/dnd", "runtime/html5/filepaste", "runtime/html5/filepicker", "runtime/html5/imagemeta/exif", "runtime/html5/androidpatch", "runtime/html5/image", "runtime/html5/transport", "runtime/flash/filepicker", "runtime/flash/image", "runtime/flash/transport"], function(a) {
  2109. return a
  2110. }), b("webuploader", ["preset/all"], function(a) {
  2111. return a
  2112. }), c("webuploader")
  2113. });