rails_medium_editor_insert_plugin 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +86 -0
- data/LICENSE.txt +21 -0
- data/README.md +139 -0
- data/Rakefile +6 -0
- data/app/assets/javascripts/medium-editor-js.js +1 -0
- data/app/assets/stylesheets/medium-editor-style.scss +3 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/rails_medium_editor_insert_plugin.rb +7 -0
- data/lib/rails_medium_editor_insert_plugin/version.rb +3 -0
- data/rails_medium_editor_insert_plugin.gemspec +31 -0
- data/vendor/assets/javascripts/medium_editor_js/handlebars.js +29 -0
- data/vendor/assets/javascripts/medium_editor_js/jquery-fileupload.js +1477 -0
- data/vendor/assets/javascripts/medium_editor_js/jquery-iframe-transport.js +217 -0
- data/vendor/assets/javascripts/medium_editor_js/jquery-sortable.js +693 -0
- data/vendor/assets/javascripts/medium_editor_js/jquery-ui-widget.js +572 -0
- data/vendor/assets/javascripts/medium_editor_js/medium-editor-insert-plugin.js +2091 -0
- data/vendor/assets/javascripts/medium_editor_js/medium-editor.js +7054 -0
- data/vendor/assets/javascripts/rails-medium-editor-insert-plugin.js +7 -0
- data/vendor/assets/stylesheets/medium-editor.scss +3 -0
- data/vendor/assets/stylesheets/medium_editor_style/_flat.scss +62 -0
- data/vendor/assets/stylesheets/medium_editor_style/_medium-editor.scss +182 -0
- data/vendor/assets/stylesheets/medium_editor_style/medium-editor-insert-plugin-frontend.scss +72 -0
- data/vendor/assets/stylesheets/medium_editor_style/medium-editor-insert-plugin.scss +209 -0
- data/vendor/assets/stylesheets/medium_editor_style/medium-editor-style.scss +4 -0
- metadata +130 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
/**!
|
2
|
+
|
3
|
+
@license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat
|
4
|
+
handlebars v5.0.0-alpha.1
|
5
|
+
|
6
|
+
Copyright (C) 2011-2017 by Yehuda Katz
|
7
|
+
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
10
|
+
in the Software without restriction, including without limitation the rights
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
13
|
+
furnished to do so, subject to the following conditions:
|
14
|
+
|
15
|
+
The above copyright notice and this permission notice shall be included in
|
16
|
+
all copies or substantial portions of the Software.
|
17
|
+
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
24
|
+
THE SOFTWARE.
|
25
|
+
|
26
|
+
*/
|
27
|
+
!function(a,b){"object"==typeof exports&&"object"==typeof module?module.exports=b():"function"==typeof define&&define.amd?define([],b):"object"==typeof exports?exports.Handlebars=b():a.Handlebars=b()}(this,function(){return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={exports:{},id:d,loaded:!1};return a[d].call(e.exports,e,e.exports,b),e.loaded=!0,e.exports}var c={};return b.m=a,b.c=c,b.p="",b(0)}([function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(){var a=r();return a.compile=function(b,c){return k.compile(b,c,a)},a.precompile=function(b,c){return k.precompile(b,c,a)},a.AST=i["default"],a.Compiler=k.Compiler,a.JavaScriptCompiler=m["default"],a.Parser=j.parser,a.parse=j.parse,a}b.__esModule=!0;var f=c(1),g=d(f),h=c(19),i=d(h),j=c(20),k=c(25),l=c(26),m=d(l),n=c(23),o=d(n),p=c(18),q=d(p),r=g["default"].create,s=e();s.create=e,q["default"](s),s.Visitor=o["default"],s["default"]=s,b["default"]=s,a.exports=b["default"]},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[c]=a[c]);return b["default"]=a,b}function f(){var a=new h.HandlebarsEnvironment;return n.extend(a,h),a.SafeString=j["default"],a.Exception=l["default"],a.Utils=n,a.escapeExpression=n.escapeExpression,a.VM=p,a.template=function(b){return p.template(b,a)},a}b.__esModule=!0;var g=c(2),h=e(g),i=c(16),j=d(i),k=c(4),l=d(k),m=c(3),n=e(m),o=c(17),p=e(o),q=c(18),r=d(q),s=f();s.create=f,r["default"](s),s["default"]=s,b["default"]=s,a.exports=b["default"]},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b,c){this.helpers=a||{},this.partials=b||{},this.decorators=c||{},i.registerDefaultHelpers(this),j.registerDefaultDecorators(this)}b.__esModule=!0,b.HandlebarsEnvironment=e;var f=c(3),g=c(4),h=d(g),i=c(5),j=c(13),k=c(15),l=d(k),m="4.0.11";b.VERSION=m;var n=7;b.COMPILER_REVISION=n;var o={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:"== 1.x.x",5:"== 2.0.0-alpha.x",6:">= 2.0.0-beta.1",7:">= 4.0.0"};b.REVISION_CHANGES=o;var p="[object Object]";e.prototype={constructor:e,logger:l["default"],log:l["default"].log,registerHelper:function(a,b){if(f.toString.call(a)===p){if(b)throw new h["default"]("Arg not supported with multiple helpers");f.extend(this.helpers,a)}else this.helpers[a]=b},unregisterHelper:function(a){delete this.helpers[a]},registerPartial:function(a,b){if(f.toString.call(a)===p)f.extend(this.partials,a);else{if("undefined"==typeof b)throw new h["default"]('Attempting to register a partial called "'+a+'" as undefined');this.partials[a]=b}},unregisterPartial:function(a){delete this.partials[a]},registerDecorator:function(a,b){if(f.toString.call(a)===p){if(b)throw new h["default"]("Arg not supported with multiple decorators");f.extend(this.decorators,a)}else this.decorators[a]=b},unregisterDecorator:function(a){delete this.decorators[a]}};var q=l["default"].log;b.log=q,b.createFrame=f.createFrame,b.logger=l["default"]},function(a,b){"use strict";function c(a){return i[a]}function d(a){for(var b=1;b<arguments.length;b++)for(var c in arguments[b])Object.prototype.hasOwnProperty.call(arguments[b],c)&&(a[c]=arguments[b][c]);return a}function e(a,b){for(var c=0,d=a.length;c<d;c++)if(a[c]===b)return c;return-1}function f(a){if("string"!=typeof a){if(a&&a.toHTML)return a.toHTML();if(null==a)return"";if(!a)return a+"";a=""+a}return k.test(a)?a.replace(j,c):a}function g(a){return!a&&0!==a||!(!n(a)||0!==a.length)}function h(a){var b=d({},a);return b._parent=a,b}b.__esModule=!0,b.extend=d,b.indexOf=e,b.escapeExpression=f,b.isEmpty=g,b.createFrame=h;var i={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`","=":"="},j=/[&<>"'`=]/g,k=/[&<>"'`=]/,l=Object.prototype.toString;b.toString=l;var m=function(a){return"function"==typeof a};m(/x/)&&(b.isFunction=m=function(a){return"function"==typeof a&&"[object Function]"===l.call(a)}),b.isFunction=m;var n=Array.isArray||function(a){return!(!a||"object"!=typeof a)&&"[object Array]"===l.call(a)};b.isArray=n},function(a,b){"use strict";function c(a,b){var e=b&&b.loc,f=void 0,g=void 0;e&&(f=e.start.line,g=e.start.column,a+=" - "+f+":"+g);for(var h=Error.prototype.constructor.call(this,a),i=0;i<d.length;i++)this[d[i]]=h[d[i]];Error.captureStackTrace&&Error.captureStackTrace(this,c);try{e&&(this.lineNumber=f,Object.defineProperty?Object.defineProperty(this,"column",{value:g,enumerable:!0}):this.column=g)}catch(j){}}b.__esModule=!0;var d=["description","fileName","lineNumber","message","name","number","stack"];c.prototype=new Error,b["default"]=c,a.exports=b["default"]},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a){g["default"](a),i["default"](a),k["default"](a),m["default"](a),o["default"](a),q["default"](a),s["default"](a)}b.__esModule=!0,b.registerDefaultHelpers=e;var f=c(6),g=d(f),h=c(7),i=d(h),j=c(8),k=d(j),l=c(9),m=d(l),n=c(10),o=d(n),p=c(11),q=d(p),r=c(12),s=d(r)},function(a,b,c){"use strict";b.__esModule=!0;var d=c(3);b["default"]=function(a){a.registerHelper("blockHelperMissing",function(b,c){var e=c.inverse,f=c.fn;return b===!0?f(this):b===!1||null==b?e(this):d.isArray(b)?b.length>0?a.helpers.each(b,c):e(this):f(b,c)})},a.exports=b["default"]},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}b.__esModule=!0;var e=c(3),f=c(4),g=d(f);b["default"]=function(a){a.registerHelper("each",function(a,b){function c(b,c,e){j&&(j.key=b,j.index=c,j.first=0===c,j.last=!!e),i+=d(a[b],{data:j,blockParams:[a[b],b]})}if(!b)throw new g["default"]("Must pass iterator to #each");var d=b.fn,f=b.inverse,h=0,i="",j=void 0;if(e.isFunction(a)&&(a=a.call(this)),b.data&&(j=e.createFrame(b.data)),a&&"object"==typeof a)if(e.isArray(a))for(var k=a.length;h<k;h++)h in a&&c(h,h,h===a.length-1);else{var l=void 0;for(var m in a)a.hasOwnProperty(m)&&(void 0!==l&&c(l,h-1),l=m,h++);void 0!==l&&c(l,h-1,!0)}return 0===h&&(i=f(this)),i})},a.exports=b["default"]},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}b.__esModule=!0;var e=c(4),f=d(e);b["default"]=function(a){a.registerHelper("helperMissing",function(){if(1!==arguments.length)throw new f["default"]('Missing helper: "'+arguments[arguments.length-1].name+'"')})},a.exports=b["default"]},function(a,b,c){"use strict";b.__esModule=!0;var d=c(3);b["default"]=function(a){a.registerHelper("if",function(a,b){return d.isFunction(a)&&(a=a.call(this)),!b.hash.includeZero&&!a||d.isEmpty(a)?b.inverse(this):b.fn(this)}),a.registerHelper("unless",function(b,c){return a.helpers["if"].call(this,b,{fn:c.inverse,inverse:c.fn,hash:c.hash})})},a.exports=b["default"]},function(a,b){"use strict";b.__esModule=!0,b["default"]=function(a){a.registerHelper("log",function(){for(var b=[void 0],c=arguments[arguments.length-1],d=0;d<arguments.length-1;d++)b.push(arguments[d]);var e=1;null!=c.hash.level?e=c.hash.level:c.data&&null!=c.data.level&&(e=c.data.level),b[0]=e,a.log.apply(a,b)})},a.exports=b["default"]},function(a,b){"use strict";b.__esModule=!0,b["default"]=function(a){a.registerHelper("lookup",function(a,b){return a&&a[b]})},a.exports=b["default"]},function(a,b,c){"use strict";b.__esModule=!0;var d=c(3);b["default"]=function(a){a.registerHelper("with",function(a,b){d.isFunction(a)&&(a=a.call(this));var c=b.fn;if(d.isEmpty(a))return b.inverse(this);var e=b.data;return c(a,{data:e,blockParams:[a]})})},a.exports=b["default"]},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a){g["default"](a)}b.__esModule=!0,b.registerDefaultDecorators=e;var f=c(14),g=d(f)},function(a,b,c){"use strict";b.__esModule=!0;var d=c(3);b["default"]=function(a){a.registerDecorator("inline",function(a,b,c,e){var f=a;return b.partials||(b.partials={},f=function(e,f){var g=c.partials;c.partials=d.extend({},g,b.partials);var h=a(e,f);return c.partials=g,h}),b.partials[e.args[0]]=e.fn,f})},a.exports=b["default"]},function(a,b,c){"use strict";b.__esModule=!0;var d=c(3),e={methodMap:["debug","info","warn","error"],level:"info",lookupLevel:function(a){if("string"==typeof a){var b=d.indexOf(e.methodMap,a.toLowerCase());a=b>=0?b:parseInt(a,10)}return a},log:function(a){if(a=e.lookupLevel(a),"undefined"!=typeof console&&e.lookupLevel(e.level)<=a){var b=e.methodMap[a];console[b]||(b="log");for(var c=arguments.length,d=Array(c>1?c-1:0),f=1;f<c;f++)d[f-1]=arguments[f];console[b].apply(console,d)}}};b["default"]=e,a.exports=b["default"]},function(a,b){"use strict";function c(a){this.string=a}b.__esModule=!0,c.prototype.toString=c.prototype.toHTML=function(){return""+this.string},b["default"]=c,a.exports=b["default"]},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[c]=a[c]);return b["default"]=a,b}function f(a){var b=a&&a[0]||1,c=r.COMPILER_REVISION;if(b!==c){if(b<c){var d=r.REVISION_CHANGES[c],e=r.REVISION_CHANGES[b];throw new q["default"]("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+d+") or downgrade your runtime to an older version ("+e+").")}throw new q["default"]("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+a[1]+").")}}function g(a,b){function c(c,d,e){e.hash&&(d=o.extend({},d,e.hash)),c=b.VM.resolvePartial.call(this,c,d,e);var f=b.VM.invokePartial.call(this,c,d,e);if(null==f&&b.compile&&(e.partials[e.name]=b.compile(c,a.compilerOptions,b),f=e.partials[e.name](d,e)),null!=f){if(e.indent){for(var g=f.split("\n"),h=0,i=g.length;h<i&&(g[h]||h+1!==i);h++)g[h]=e.indent+g[h];f=g.join("\n")}return f}throw new q["default"]("The partial "+e.name+" could not be compiled when running in runtime-only mode")}function d(b){function c(b){return""+a.main(f,b,f.helpers,f.partials,g,i,h)}var d=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],g=d.data;e(d),!d.partial&&a.useData&&(g=l(b,g));var h=void 0,i=a.useBlockParams?[]:void 0;return a.useDepths&&(h=d.depths?b!=d.depths[0]?[b].concat(d.depths):d.depths:[b]),(c=m(a.main,c,f,d.depths||[],g,i))(b,d)}function e(c){c.partial?(f.helpers=c.helpers,f.partials=c.partials,f.decorators=c.decorators):(f.helpers=f.merge(c.helpers,b.helpers),a.usePartial&&(f.partials=f.merge(c.partials,b.partials)),(a.usePartial||a.useDecorators)&&(f.decorators=f.merge(c.decorators,b.decorators)))}if(!b)throw new q["default"]("No environment passed to template");if(!a||!a.main)throw new q["default"]("Unknown template object: "+typeof a);a.main.decorator=a.main_d,b.VM.checkRevision(a.compiler);var f={strict:function(a,b){if(!(b in a))throw new q["default"]('"'+b+'" not defined in '+a);return a[b]},lookup:function(a,b){for(var c=a.length,d=0;d<c;d++)if(a[d]&&null!=a[d][b])return a[d][b]},lambda:function(a,b){return"function"==typeof a?a.call(b):a},escapeExpression:o.escapeExpression,invokePartial:c,fn:function(b){var c=a[b];return c.decorator=a[b+"_d"],c},programs:[],program:function(a,b,c,d,e){var f=this.programs[a],g=this.fn(a);return b||e||d||c?f=h(this,a,g,b,c,d,e):f||(f=this.programs[a]=h(this,a,g)),f},data:function(a,b){for(;a&&b--;)a=a._parent;return a},merge:function(a,b){var c=a||b;return a&&b&&a!==b&&(c=o.extend({},b,a)),c},nullContext:Object.seal({}),noop:b.VM.noop,compilerInfo:a.compiler};return d.isTop=!0,d}function h(a,b,c,d,e,f,g){function h(b){var e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],h=g;return!g||b==g[0]||b===a.nullContext&&null===g[0]||(h=[b].concat(g)),c(a,b,a.helpers,a.partials,e.data||d,f&&[e.blockParams].concat(f),h)}return h=m(c,h,a,g,d,f),h.program=b,h.depth=g?g.length:0,h.blockParams=e||0,h}function i(a,b,c){return a?a.call||c.name||(c.name=a,a=c.partials[a]):a="@partial-block"===c.name?c.data["partial-block"]:c.partials[c.name],a}function j(a,b,c){var d=c.data&&c.data["partial-block"];c.partial=!0;var e=void 0;if(c.fn&&c.fn!==k&&!function(){c.data=r.createFrame(c.data);var a=c.fn;e=c.data["partial-block"]=function(b){var c=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return c.data=r.createFrame(c.data),c.data["partial-block"]=d,a(b,c)},a.partials&&(c.partials=o.extend({},c.partials,a.partials))}(),void 0===a&&e&&(a=e),void 0===a)throw new q["default"]("The partial "+c.name+" could not be found");if(a instanceof Function)return a(b,c)}function k(){return""}function l(a,b){return b&&"root"in b||(b=b?r.createFrame(b):{},b.root=a),b}function m(a,b,c,d,e,f){if(a.decorator){var g={};b=a.decorator(b,g,c,d&&d[0],e,f,d),o.extend(b,g)}return b}b.__esModule=!0,b.checkRevision=f,b.template=g,b.wrapProgram=h,b.resolvePartial=i,b.invokePartial=j,b.noop=k;var n=c(3),o=e(n),p=c(4),q=d(p),r=c(2)},function(a,b){(function(c){"use strict";b.__esModule=!0,b["default"]=function(a){var b="undefined"!=typeof c?c:window,d=b.Handlebars;a.noConflict=function(){return b.Handlebars===a&&(b.Handlebars=d),a}},a.exports=b["default"]}).call(b,function(){return this}())},function(a,b){"use strict";b.__esModule=!0;var c={helpers:{helperExpression:function(a){return"SubExpression"===a.type||("MustacheStatement"===a.type||"BlockStatement"===a.type)&&!!(a.params&&a.params.length||a.hash)},scopedId:function(a){return/^\.|this\b/.test(a.original)},simpleId:function(a){return 1===a.parts.length&&!c.helpers.scopedId(a)&&!a.depth}}};b["default"]=c,a.exports=b["default"]},function(a,b,c){"use strict";function d(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[c]=a[c]);return b["default"]=a,b}function e(a){return a&&a.__esModule?a:{"default":a}}function f(a,b){if("Program"===a.type)return a;h["default"].yy=n,n.locInfo=function(a){return new n.SourceLocation(b&&b.srcName,a)};var c=new j["default"](b);return c.accept(h["default"].parse(a))}b.__esModule=!0,b.parse=f;var g=c(21),h=e(g),i=c(22),j=e(i),k=c(24),l=d(k),m=c(3);b.parser=h["default"];var n={};m.extend(n,l)},function(a,b){"use strict";b.__esModule=!0;var c=function(){function a(){this.yy={}}var b=function(a,b,c,d){for(c=c||{},d=a.length;d--;c[a[d]]=b);return c},c=[2,46],d=[1,20],e=[5,14,15,19,29,34,39,44,47,48,51,55,60],f=[1,35],g=[1,28],h=[1,29],i=[1,30],j=[1,31],k=[1,32],l=[1,34],m=[14,15,19,29,34,39,44,47,48,51,55,60],n=[14,15,19,29,34,44,47,48,51,55,60],o=[1,44],p=[14,15,19,29,34,47,48,51,55,60],q=[33,65,72,80,81,82,83,84,85],r=[23,33,54,65,68,72,75,80,81,82,83,84,85],s=[1,51],t=[23,33,54,65,68,72,75,80,81,82,83,84,85,87],u=[2,45],v=[54,65,72,80,81,82,83,84,85],w=[1,58],x=[1,59],y=[15,18],z=[1,67],A=[33,65,72,75,80,81,82,83,84,85],B=[23,65,72,80,81,82,83,84,85],C=[1,79],D=[65,68,72,80,81,82,83,84,85],E=[33,75],F=[23,33,54,68,72,75],G=[1,109],H=[1,121],I=[72,77],J={trace:function(){},yy:{},symbols_:{error:2,root:3,program:4,EOF:5,program_repetition0:6,statement:7,mustache:8,block:9,rawBlock:10,partial:11,partialBlock:12,content:13,COMMENT:14,CONTENT:15,openRawBlock:16,rawBlock_repetition_plus0:17,END_RAW_BLOCK:18,OPEN_RAW_BLOCK:19,helperName:20,openRawBlock_repetition0:21,openRawBlock_option0:22,CLOSE_RAW_BLOCK:23,openBlock:24,block_option0:25,closeBlock:26,openInverse:27,block_option1:28,OPEN_BLOCK:29,openBlock_repetition0:30,openBlock_option0:31,openBlock_option1:32,CLOSE:33,OPEN_INVERSE:34,openInverse_repetition0:35,openInverse_option0:36,openInverse_option1:37,openInverseChain:38,OPEN_INVERSE_CHAIN:39,openInverseChain_repetition0:40,openInverseChain_option0:41,openInverseChain_option1:42,inverseAndProgram:43,INVERSE:44,inverseChain:45,inverseChain_option0:46,OPEN_ENDBLOCK:47,OPEN:48,mustache_repetition0:49,mustache_option0:50,OPEN_UNESCAPED:51,mustache_repetition1:52,mustache_option1:53,CLOSE_UNESCAPED:54,OPEN_PARTIAL:55,partialName:56,partial_repetition0:57,partial_option0:58,openPartialBlock:59,OPEN_PARTIAL_BLOCK:60,openPartialBlock_repetition0:61,openPartialBlock_option0:62,param:63,sexpr:64,OPEN_SEXPR:65,sexpr_repetition0:66,sexpr_option0:67,CLOSE_SEXPR:68,hash:69,hash_repetition_plus0:70,hashSegment:71,ID:72,EQUALS:73,blockParams:74,OPEN_BLOCK_PARAMS:75,blockParams_repetition_plus0:76,CLOSE_BLOCK_PARAMS:77,path:78,dataName:79,STRING:80,NUMBER:81,BOOLEAN:82,UNDEFINED:83,NULL:84,DATA:85,pathSegments:86,SEP:87,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",14:"COMMENT",15:"CONTENT",18:"END_RAW_BLOCK",19:"OPEN_RAW_BLOCK",23:"CLOSE_RAW_BLOCK",29:"OPEN_BLOCK",33:"CLOSE",34:"OPEN_INVERSE",39:"OPEN_INVERSE_CHAIN",44:"INVERSE",47:"OPEN_ENDBLOCK",48:"OPEN",51:"OPEN_UNESCAPED",54:"CLOSE_UNESCAPED",55:"OPEN_PARTIAL",60:"OPEN_PARTIAL_BLOCK",65:"OPEN_SEXPR",68:"CLOSE_SEXPR",72:"ID",73:"EQUALS",75:"OPEN_BLOCK_PARAMS",77:"CLOSE_BLOCK_PARAMS",80:"STRING",81:"NUMBER",82:"BOOLEAN",83:"UNDEFINED",84:"NULL",85:"DATA",87:"SEP"},productions_:[0,[3,2],[4,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[13,1],[10,3],[16,5],[9,4],[9,4],[24,6],[27,6],[38,6],[43,2],[45,3],[45,1],[26,3],[8,5],[8,5],[11,5],[12,3],[59,5],[63,1],[63,1],[64,5],[69,1],[71,3],[74,3],[20,1],[20,1],[20,1],[20,1],[20,1],[20,1],[20,1],[56,1],[56,1],[79,2],[78,1],[86,3],[86,1],[6,0],[6,2],[17,1],[17,2],[21,0],[21,2],[22,0],[22,1],[25,0],[25,1],[28,0],[28,1],[30,0],[30,2],[31,0],[31,1],[32,0],[32,1],[35,0],[35,2],[36,0],[36,1],[37,0],[37,1],[40,0],[40,2],[41,0],[41,1],[42,0],[42,1],[46,0],[46,1],[49,0],[49,2],[50,0],[50,1],[52,0],[52,2],[53,0],[53,1],[57,0],[57,2],[58,0],[58,1],[61,0],[61,2],[62,0],[62,1],[66,0],[66,2],[67,0],[67,1],[70,1],[70,2],[76,1],[76,2]],performAction:function(a,b,c,d,e,f,g){var h=f.length-1;switch(e){case 1:return f[h-1];case 2:this.$=d.prepareProgram(f[h]);break;case 3:case 4:case 5:case 6:case 7:case 8:case 20:case 27:case 28:case 33:case 34:case 40:case 41:this.$=f[h];break;case 9:this.$={type:"CommentStatement",value:d.stripComment(f[h]),strip:d.stripFlags(f[h],f[h]),loc:d.locInfo(this._$)};break;case 10:this.$={type:"ContentStatement",original:f[h],value:f[h],loc:d.locInfo(this._$)};break;case 11:this.$=d.prepareRawBlock(f[h-2],f[h-1],f[h],this._$);break;case 12:this.$={path:f[h-3],params:f[h-2],hash:f[h-1]};break;case 13:this.$=d.prepareBlock(f[h-3],f[h-2],f[h-1],f[h],!1,this._$);break;case 14:this.$=d.prepareBlock(f[h-3],f[h-2],f[h-1],f[h],!0,this._$);break;case 15:this.$={open:f[h-5],path:f[h-4],params:f[h-3],hash:f[h-2],blockParams:f[h-1],strip:d.stripFlags(f[h-5],f[h])};break;case 16:case 17:this.$={path:f[h-4],params:f[h-3],hash:f[h-2],blockParams:f[h-1],strip:d.stripFlags(f[h-5],f[h])};break;case 18:this.$={strip:d.stripFlags(f[h-1],f[h-1]),program:f[h]};break;case 19:var i=d.prepareBlock(f[h-2],f[h-1],f[h],f[h],!1,this._$),j=d.prepareProgram([i],f[h-1].loc);j.chained=!0,this.$={strip:f[h-2].strip,program:j,chain:!0};break;case 21:this.$={path:f[h-1],strip:d.stripFlags(f[h-2],f[h])};break;case 22:case 23:this.$=d.prepareMustache(f[h-3],f[h-2],f[h-1],f[h-4],d.stripFlags(f[h-4],f[h]),this._$);break;case 24:this.$={type:"PartialStatement",name:f[h-3],params:f[h-2],hash:f[h-1],indent:"",strip:d.stripFlags(f[h-4],f[h]),loc:d.locInfo(this._$)};break;case 25:this.$=d.preparePartialBlock(f[h-2],f[h-1],f[h],this._$);break;case 26:this.$={path:f[h-3],params:f[h-2],hash:f[h-1],strip:d.stripFlags(f[h-4],f[h])};break;case 29:this.$={type:"SubExpression",path:f[h-3],params:f[h-2],hash:f[h-1],loc:d.locInfo(this._$)};break;case 30:this.$={type:"Hash",pairs:f[h],loc:d.locInfo(this._$)};break;case 31:this.$={type:"HashPair",key:d.id(f[h-2]),value:f[h],loc:d.locInfo(this._$)};break;case 32:this.$=d.id(f[h-1]);break;case 35:this.$={type:"StringLiteral",value:f[h],original:f[h],loc:d.locInfo(this._$)};break;case 36:this.$={type:"NumberLiteral",value:Number(f[h]),original:Number(f[h]),loc:d.locInfo(this._$)};break;case 37:this.$={type:"BooleanLiteral",value:"true"===f[h],original:"true"===f[h],loc:d.locInfo(this._$)};break;case 38:this.$={type:"UndefinedLiteral",original:void 0,value:void 0,loc:d.locInfo(this._$)};break;case 39:this.$={type:"NullLiteral",original:null,value:null,loc:d.locInfo(this._$)};break;case 42:this.$=d.preparePath(!0,f[h],this._$);break;case 43:this.$=d.preparePath(!1,f[h],this._$);break;case 44:f[h-2].push({part:d.id(f[h]),original:f[h],separator:f[h-1]}),this.$=f[h-2];break;case 45:this.$=[{part:d.id(f[h]),original:f[h]}];break;case 46:case 50:case 58:case 64:case 70:case 78:case 82:case 86:case 90:case 94:this.$=[];break;case 47:case 49:case 51:case 59:case 65:case 71:case 79:case 83:case 87:case 91:case 95:case 99:case 101:f[h-1].push(f[h]);break;case 48:case 98:case 100:this.$=[f[h]]}},table:[b([5,14,15,19,29,34,48,51,55,60],c,{3:1,4:2,6:3}),{1:[3]},{5:[1,4]},b([5,39,44,47],[2,2],{7:5,8:6,9:7,10:8,11:9,12:10,13:11,24:15,27:16,16:17,59:19,14:[1,12],15:d,19:[1,23],29:[1,21],34:[1,22],48:[1,13],51:[1,14],55:[1,18],60:[1,24]}),{1:[2,1]},b(e,[2,47]),b(e,[2,3]),b(e,[2,4]),b(e,[2,5]),b(e,[2,6]),b(e,[2,7]),b(e,[2,8]),b(e,[2,9]),{20:25,72:f,78:26,79:27,80:g,81:h,82:i,83:j,84:k,85:l,86:33},{20:36,72:f,78:26,79:27,80:g,81:h,82:i,83:j,84:k,85:l,86:33},b(m,c,{6:3,4:37}),b(n,c,{6:3,4:38}),{13:40,15:d,17:39},{20:42,56:41,64:43,65:o,72:f,78:26,79:27,80:g,81:h,82:i,83:j,84:k,85:l,86:33},b(p,c,{6:3,4:45}),b([5,14,15,18,19,29,34,39,44,47,48,51,55,60],[2,10]),{20:46,72:f,78:26,79:27,80:g,81:h,82:i,83:j,84:k,85:l,86:33},{20:47,72:f,78:26,79:27,80:g,81:h,82:i,83:j,84:k,85:l,86:33},{20:48,72:f,78:26,79:27,80:g,81:h,82:i,83:j,84:k,85:l,86:33},{20:42,56:49,64:43,65:o,72:f,78:26,79:27,80:g,81:h,82:i,83:j,84:k,85:l,86:33},b(q,[2,78],{49:50}),b(r,[2,33]),b(r,[2,34]),b(r,[2,35]),b(r,[2,36]),b(r,[2,37]),b(r,[2,38]),b(r,[2,39]),b(r,[2,43],{87:s}),{72:f,86:52},b(t,u),b(v,[2,82],{52:53}),{25:54,38:56,39:w,43:57,44:x,45:55,47:[2,54]},{28:60,43:61,44:x,47:[2,56]},{13:63,15:d,18:[1,62]},b(y,[2,48]),b(q,[2,86],{57:64}),b(q,[2,40]),b(q,[2,41]),{20:65,72:f,78:26,79:27,80:g,81:h,82:i,83:j,84:k,85:l,86:33},{26:66,47:z},b(A,[2,58],{30:68}),b(A,[2,64],{35:69}),b(B,[2,50],{21:70}),b(q,[2,90],{61:71}),{20:75,33:[2,80],50:72,63:73,64:76,65:o,69:74,70:77,71:78,72:C,78:26,79:27,80:g,81:h,82:i,83:j,84:k,85:l,86:33},{72:[1,80]},b(r,[2,42],{87:s}),{20:75,53:81,54:[2,84],63:82,64:76,65:o,69:83,70:77,71:78,72:C,78:26,79:27,80:g,81:h,82:i,83:j,84:k,85:l,86:33},{26:84,47:z},{47:[2,55]},b(m,c,{6:3,4:85}),{47:[2,20]},{20:86,72:f,78:26,79:27,80:g,81:h,82:i,83:j,84:k,85:l,86:33},b(p,c,{6:3,4:87}),{26:88,47:z},{47:[2,57]},b(e,[2,11]),b(y,[2,49]),{20:75,33:[2,88],58:89,63:90,64:76,65:o,69:91,70:77,71:78,72:C,78:26,79:27,80:g,81:h,82:i,83:j,84:k,85:l,86:33},b(D,[2,94],{66:92}),b(e,[2,25]),{20:93,72:f,78:26,79:27,80:g,81:h,82:i,83:j,84:k,85:l,86:33},b(E,[2,60],{78:26,79:27,86:33,20:75,64:76,70:77,71:78,31:94,63:95,69:96,65:o,72:C,80:g,81:h,82:i,83:j,84:k,85:l}),b(E,[2,66],{78:26,79:27,86:33,20:75,64:76,70:77,71:78,36:97,63:98,69:99,65:o,72:C,80:g,81:h,82:i,83:j,84:k,85:l}),{20:75,22:100,23:[2,52],63:101,64:76,65:o,69:102,70:77,71:78,72:C,78:26,79:27,80:g,81:h,82:i,83:j,84:k,85:l,86:33},{20:75,33:[2,92],62:103,63:104,64:76,65:o,69:105,70:77,71:78,72:C,78:26,79:27,80:g,81:h,82:i,83:j,84:k,85:l,86:33},{33:[1,106]},b(q,[2,79]),{33:[2,81]},b(r,[2,27]),b(r,[2,28]),b([23,33,54,68,75],[2,30],{71:107,72:[1,108]}),b(F,[2,98]),b(t,u,{73:G}),b(t,[2,44]),{54:[1,110]},b(v,[2,83]),{54:[2,85]},b(e,[2,13]),{38:56,39:w,43:57,44:x,45:112,46:111,47:[2,76]},b(A,[2,70],{40:113}),{47:[2,18]},b(e,[2,14]),{33:[1,114]},b(q,[2,87]),{33:[2,89]},{20:75,63:116,64:76,65:o,67:115,68:[2,96],69:117,70:77,71:78,72:C,78:26,79:27,80:g,81:h,82:i,83:j,84:k,85:l,86:33},{33:[1,118]},{32:119,33:[2,62],74:120,75:H},b(A,[2,59]),b(E,[2,61]),{33:[2,68],37:122,74:123,75:H},b(A,[2,65]),b(E,[2,67]),{23:[1,124]},b(B,[2,51]),{23:[2,53]},{33:[1,125]},b(q,[2,91]),{33:[2,93]},b(e,[2,22]),b(F,[2,99]),{73:G},{20:75,63:126,64:76,65:o,72:f,78:26,79:27,80:g,81:h,82:i,83:j,84:k,85:l,86:33},b(e,[2,23]),{47:[2,19]},{47:[2,77]},b(E,[2,72],{78:26,79:27,86:33,20:75,64:76,70:77,71:78,41:127,63:128,69:129,65:o,72:C,80:g,81:h,82:i,83:j,84:k,85:l}),b(e,[2,24]),{68:[1,130]},b(D,[2,95]),{68:[2,97]},b(e,[2,21]),{33:[1,131]},{33:[2,63]},{72:[1,133],76:132},{33:[1,134]},{33:[2,69]},{15:[2,12]},b(p,[2,26]),b(F,[2,31]),{33:[2,74],42:135,74:136,75:H},b(A,[2,71]),b(E,[2,73]),b(r,[2,29]),b(m,[2,15]),{72:[1,138],77:[1,137]},b(I,[2,100]),b(n,[2,16]),{33:[1,139]},{33:[2,75]},{33:[2,32]},b(I,[2,101]),b(m,[2,17])],defaultActions:{4:[2,1],55:[2,55],57:[2,20],61:[2,57],74:[2,81],83:[2,85],87:[2,18],91:[2,89],102:[2,53],105:[2,93],111:[2,19],112:[2,77],117:[2,97],120:[2,63],123:[2,69],124:[2,12],136:[2,75],137:[2,32]},parseError:function(a,b){if(!b.recoverable){var c=function(a,b){this.message=a,this.hash=b};throw c.prototype=new Error,new c(a,b)}this.trace(a)},parse:function(a){var b=this,c=[0],d=[null],e=[],f=this.table,g="",h=0,i=0,j=0,k=2,l=1,m=e.slice.call(arguments,1),n=Object.create(this.lexer),o={yy:{}};for(var p in this.yy)Object.prototype.hasOwnProperty.call(this.yy,p)&&(o.yy[p]=this.yy[p]);n.setInput(a,o.yy),o.yy.lexer=n,o.yy.parser=this,"undefined"==typeof n.yylloc&&(n.yylloc={});var q=n.yylloc;e.push(q);var r=n.options&&n.options.ranges;"function"==typeof o.yy.parseError?this.parseError=o.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var s,t,u,v,w,x,y,z,A,B=function(){var a;return a=n.lex()||l,"number"!=typeof a&&(a=b.symbols_[a]||a),a},C={};;){if(u=c[c.length-1],this.defaultActions[u]?v=this.defaultActions[u]:(null!==s&&"undefined"!=typeof s||(s=B()),v=f[u]&&f[u][s]),"undefined"==typeof v||!v.length||!v[0]){var D="";A=[];for(x in f[u])this.terminals_[x]&&x>k&&A.push("'"+this.terminals_[x]+"'");D=n.showPosition?"Parse error on line "+(h+1)+":\n"+n.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[s]||s)+"'":"Parse error on line "+(h+1)+": Unexpected "+(s==l?"end of input":"'"+(this.terminals_[s]||s)+"'"),this.parseError(D,{text:n.match,token:this.terminals_[s]||s,line:n.yylineno,loc:q,expected:A})}if(v[0]instanceof Array&&v.length>1)throw new Error("Parse Error: multiple actions possible at state: "+u+", token: "+s);switch(v[0]){case 1:c.push(s),d.push(n.yytext),e.push(n.yylloc),c.push(v[1]),s=null,t?(s=t,t=null):(i=n.yyleng,g=n.yytext,h=n.yylineno,q=n.yylloc,j>0&&j--);break;case 2:if(y=this.productions_[v[1]][1],C.$=d[d.length-y],C._$={first_line:e[e.length-(y||1)].first_line,last_line:e[e.length-1].last_line,first_column:e[e.length-(y||1)].first_column,last_column:e[e.length-1].last_column},r&&(C._$.range=[e[e.length-(y||1)].range[0],e[e.length-1].range[1]]),w=this.performAction.apply(C,[g,i,h,o.yy,v[1],d,e].concat(m)),"undefined"!=typeof w)return w;y&&(c=c.slice(0,-1*y*2),d=d.slice(0,-1*y),e=e.slice(0,-1*y)),c.push(this.productions_[v[1]][0]),d.push(C.$),e.push(C._$),z=f[c[c.length-2]][c[c.length-1]],c.push(z);break;case 3:return!0}}return!0}},K=function(){var a={EOF:1,parseError:function(a,b){if(!this.yy.parser)throw new Error(a);this.yy.parser.parseError(a,b)},setInput:function(a,b){return this.yy=b||this.yy||{},this._input=a,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.offset++,this.match+=a,this.matched+=a;var b=a.match(/(?:\r\n?|\n).*/g);return b?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),a},unput:function(a){var b=a.length,c=a.split(/(?:\r\n?|\n)/g);this._input=a+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-b),this.offset-=b;var d=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),c.length-1&&(this.yylineno-=c.length-1);var e=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:c?(c.length===d.length?this.yylloc.first_column:0)+d[d.length-c.length].length-c[0].length:this.yylloc.first_column-b},this.options.ranges&&(this.yylloc.range=[e[0],e[0]+this.yyleng-b]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(a){this.unput(this.match.slice(a))},pastInput:function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var a=this.match;return a.length<20&&(a+=this._input.substr(0,20-a.length)),(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var a=this.pastInput(),b=new Array(a.length+1).join("-");return a+this.upcomingInput()+"\n"+b+"^"},test_match:function(a,b){var c,d,e;if(this.options.backtrack_lexer&&(e={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(e.yylloc.range=this.yylloc.range.slice(0))),d=a[0].match(/(?:\r\n?|\n).*/g),d&&(this.yylineno+=d.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:d?d[d.length-1].length-d[d.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+a[0].length},this.yytext+=a[0],this.match+=a[0],this.matches=a,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(a[0].length),this.matched+=a[0],c=this.performAction.call(this,this.yy,this,b,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),c)return c;if(this._backtrack){for(var f in e)this[f]=e[f];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,b,c,d;this._more||(this.yytext="",this.match="");for(var e=this._currentRules(),f=0;f<e.length;f++)if(c=this._input.match(this.rules[e[f]]),c&&(!b||c[0].length>b[0].length)){if(b=c,d=f,this.options.backtrack_lexer){if(a=this.test_match(c,e[f]),a!==!1)return a;if(this._backtrack){b=!1;continue}return!1}if(!this.options.flex)break}return b?(a=this.test_match(b,e[d]),a!==!1&&a):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var a=this.next();return a?a:this.lex()},begin:function(a){this.conditionStack.push(a)},popState:function(){var a=this.conditionStack.length-1;return a>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(a){return a=this.conditionStack.length-1-Math.abs(a||0),a>=0?this.conditionStack[a]:"INITIAL"},pushState:function(a){this.begin(a)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(a,b,c,d){function e(a,c){return b.yytext=b.yytext.substr(a,b.yyleng-c)}switch(c){case 0:if("\\\\"===b.yytext.slice(-2)?(e(0,1),this.begin("mu")):"\\"===b.yytext.slice(-1)?(e(0,1),this.begin("emu")):this.begin("mu"),b.yytext)return 15;
|
28
|
+
break;case 1:return 15;case 2:return this.popState(),15;case 3:return this.begin("raw"),15;case 4:return this.popState(),"raw"===this.conditionStack[this.conditionStack.length-1]?15:(b.yytext=b.yytext.substr(5,b.yyleng-9),18);case 5:return 15;case 6:return this.popState(),14;case 7:return 65;case 8:return 68;case 9:return 19;case 10:return this.popState(),this.begin("raw"),23;case 11:return 55;case 12:return 60;case 13:return 29;case 14:return 47;case 15:return this.popState(),44;case 16:return this.popState(),44;case 17:return 34;case 18:return 39;case 19:return 51;case 20:return 48;case 21:this.unput(b.yytext),this.popState(),this.begin("com");break;case 22:return this.popState(),14;case 23:return 48;case 24:return 73;case 25:return 72;case 26:return 72;case 27:return 87;case 28:break;case 29:return this.popState(),54;case 30:return this.popState(),33;case 31:return b.yytext=e(1,2).replace(/\\"/g,'"'),80;case 32:return b.yytext=e(1,2).replace(/\\'/g,"'"),80;case 33:return 85;case 34:return 82;case 35:return 82;case 36:return 83;case 37:return 84;case 38:return 81;case 39:return 75;case 40:return 77;case 41:return 72;case 42:return b.yytext=b.yytext.replace(/\\([\\\]])/g,"$1"),72;case 43:return"INVALID";case 44:return 5}},rules:[/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/,/^(?:\{\{\{\{(?=[^\/]))/,/^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/,/^(?:[^\x00]*?(?=(\{\{\{\{)))/,/^(?:[\s\S]*?--(~)?\}\})/,/^(?:\()/,/^(?:\))/,/^(?:\{\{\{\{)/,/^(?:\}\}\}\})/,/^(?:\{\{(~)?>)/,/^(?:\{\{(~)?#>)/,/^(?:\{\{(~)?#\*?)/,/^(?:\{\{(~)?\/)/,/^(?:\{\{(~)?\^\s*(~)?\}\})/,/^(?:\{\{(~)?\s*else\s*(~)?\}\})/,/^(?:\{\{(~)?\^)/,/^(?:\{\{(~)?\s*else\b)/,/^(?:\{\{(~)?\{)/,/^(?:\{\{(~)?&)/,/^(?:\{\{(~)?!--)/,/^(?:\{\{(~)?![\s\S]*?\}\})/,/^(?:\{\{(~)?\*?)/,/^(?:=)/,/^(?:\.\.)/,/^(?:\.(?=([=~}\s\/.)|])))/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}(~)?\}\})/,/^(?:(~)?\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=([~}\s)])))/,/^(?:false(?=([~}\s)])))/,/^(?:undefined(?=([~}\s)])))/,/^(?:null(?=([~}\s)])))/,/^(?:-?[0-9]+(?:\.[0-9]+)?(?=([~}\s)])))/,/^(?:as\s+\|)/,/^(?:\|)/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)|]))))/,/^(?:\[(\\\]|[^\]])*\])/,/^(?:.)/,/^(?:$)/],conditions:{mu:{rules:[7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44],inclusive:!1},emu:{rules:[2],inclusive:!1},com:{rules:[6],inclusive:!1},raw:{rules:[3,4,5],inclusive:!1},INITIAL:{rules:[0,1,44],inclusive:!0}}};return a}();return J.lexer=K,a.prototype=J,J.Parser=a,new a}();b["default"]=c,a.exports=b["default"]},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(){var a=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.options=a}function f(a,b,c){void 0===b&&(b=a.length);var d=a[b-1],e=a[b-2];return d?"ContentStatement"===d.type?(e||!c?/\r?\n\s*?$/:/(^|\r?\n)\s*?$/).test(d.original):void 0:c}function g(a,b,c){void 0===b&&(b=-1);var d=a[b+1],e=a[b+2];return d?"ContentStatement"===d.type?(e||!c?/^\s*?\r?\n/:/^\s*?(\r?\n|$)/).test(d.original):void 0:c}function h(a,b,c){var d=a[null==b?0:b+1];if(d&&"ContentStatement"===d.type&&(c||!d.rightStripped)){var e=d.value;d.value=d.value.replace(c?/^\s+/:/^[ \t]*\r?\n?/,""),d.rightStripped=d.value!==e}}function i(a,b,c){var d=a[null==b?a.length-1:b-1];if(d&&"ContentStatement"===d.type&&(c||!d.leftStripped)){var e=d.value;return d.value=d.value.replace(c?/\s+$/:/[ \t]+$/,""),d.leftStripped=d.value!==e,d.leftStripped}}b.__esModule=!0;var j=c(23),k=d(j);e.prototype=new k["default"],e.prototype.Program=function(a){var b=!this.options.ignoreStandalone,c=!this.isRootSeen;this.isRootSeen=!0;for(var d=a.body,e=0,j=d.length;e<j;e++){var k=d[e],l=this.accept(k);if(l){var m=f(d,e,c),n=g(d,e,c),o=l.openStandalone&&m,p=l.closeStandalone&&n,q=l.inlineStandalone&&m&&n;l.close&&h(d,e,!0),l.open&&i(d,e,!0),b&&q&&(h(d,e),i(d,e)&&"PartialStatement"===k.type&&(k.indent=/([ \t]+$)/.exec(d[e-1].original)[1])),b&&o&&(h((k.program||k.inverse).body),i(d,e)),b&&p&&(h(d,e),i((k.inverse||k.program).body))}}return a},e.prototype.BlockStatement=e.prototype.DecoratorBlock=e.prototype.PartialBlockStatement=function(a){this.accept(a.program),this.accept(a.inverse);var b=a.program||a.inverse,c=a.program&&a.inverse,d=c,e=c;if(c&&c.chained)for(d=c.body[0].program;e.chained;)e=e.body[e.body.length-1].program;var j={open:a.openStrip.open,close:a.closeStrip.close,openStandalone:g(b.body),closeStandalone:f((d||b).body)};if(a.openStrip.close&&h(b.body,null,!0),c){var k=a.inverseStrip;k.open&&i(b.body,null,!0),k.close&&h(d.body,null,!0),a.closeStrip.open&&i(e.body,null,!0),!this.options.ignoreStandalone&&f(b.body)&&g(d.body)&&(i(b.body),h(d.body))}else a.closeStrip.open&&i(b.body,null,!0);return j},e.prototype.Decorator=e.prototype.MustacheStatement=function(a){return a.strip},e.prototype.PartialStatement=e.prototype.CommentStatement=function(a){var b=a.strip||{};return{inlineStandalone:!0,open:b.open,close:b.close}},b["default"]=e,a.exports=b["default"]},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(){this.parents=[]}function f(a){this.acceptRequired(a,"path"),this.acceptArray(a.params),this.acceptKey(a,"hash")}function g(a){f.call(this,a),this.acceptKey(a,"program"),this.acceptKey(a,"inverse")}function h(a){this.acceptRequired(a,"name"),this.acceptArray(a.params),this.acceptKey(a,"hash")}b.__esModule=!0;var i=c(4),j=d(i);e.prototype={constructor:e,mutating:!1,acceptKey:function(a,b){var c=this.accept(a[b]);if(this.mutating){if(c&&!e.prototype[c.type])throw new j["default"]('Unexpected node type "'+c.type+'" found when accepting '+b+" on "+a.type);a[b]=c}},acceptRequired:function(a,b){if(this.acceptKey(a,b),!a[b])throw new j["default"](a.type+" requires "+b)},acceptArray:function(a){for(var b=0,c=a.length;b<c;b++)this.acceptKey(a,b),a[b]||(a.splice(b,1),b--,c--)},accept:function(a){if(a){if(!this[a.type])throw new j["default"]("Unknown type: "+a.type,a);this.current&&this.parents.unshift(this.current),this.current=a;var b=this[a.type](a);return this.current=this.parents.shift(),!this.mutating||b?b:b!==!1?a:void 0}},Program:function(a){this.acceptArray(a.body)},MustacheStatement:f,Decorator:f,BlockStatement:g,DecoratorBlock:g,PartialStatement:h,PartialBlockStatement:function(a){h.call(this,a),this.acceptKey(a,"program")},ContentStatement:function(){},CommentStatement:function(){},SubExpression:f,PathExpression:function(){},StringLiteral:function(){},NumberLiteral:function(){},BooleanLiteral:function(){},UndefinedLiteral:function(){},NullLiteral:function(){},Hash:function(a){this.acceptArray(a.pairs)},HashPair:function(a){this.acceptRequired(a,"value")}},b["default"]=e,a.exports=b["default"]},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b){if(b=b.path?b.path.original:b,a.path.original!==b){var c={loc:a.path.loc};throw new q["default"](a.path.original+" doesn't match "+b,c)}}function f(a,b){this.source=a,this.start={line:b.first_line,column:b.first_column},this.end={line:b.last_line,column:b.last_column}}function g(a){return/^\[.*\]$/.test(a)?a.substr(1,a.length-2):a}function h(a,b){return{open:"~"===a.charAt(2),close:"~"===b.charAt(b.length-3)}}function i(a){return a.replace(/^\{\{~?!-?-?/,"").replace(/-?-?~?\}\}$/,"")}function j(a,b,c){c=this.locInfo(c);for(var d=a?"@":"",e=[],f=0,g=0,h=b.length;g<h;g++){var i=b[g].part,j=b[g].original!==i;if(d+=(b[g].separator||"")+i,j||".."!==i&&"."!==i&&"this"!==i)e.push(i);else{if(e.length>0)throw new q["default"]("Invalid path: "+d,{loc:c});".."===i&&f++}}return{type:"PathExpression",data:a,depth:f,parts:e,original:d,loc:c}}function k(a,b,c,d,e,f){var g=d.charAt(3)||d.charAt(2),h="{"!==g&&"&"!==g,i=/\*/.test(d);return{type:i?"Decorator":"MustacheStatement",path:a,params:b,hash:c,escaped:h,strip:e,loc:this.locInfo(f)}}function l(a,b,c,d){e(a,c),d=this.locInfo(d);var f={type:"Program",body:b,strip:{},loc:d};return{type:"BlockStatement",path:a.path,params:a.params,hash:a.hash,program:f,openStrip:{},inverseStrip:{},closeStrip:{},loc:d}}function m(a,b,c,d,f,g){d&&d.path&&e(a,d);var h=/\*/.test(a.open);b.blockParams=a.blockParams;var i=void 0,j=void 0;if(c){if(h)throw new q["default"]("Unexpected inverse block on decorator",c);c.chain&&(c.program.body[0].closeStrip=d.strip),j=c.strip,i=c.program}return f&&(f=i,i=b,b=f),{type:h?"DecoratorBlock":"BlockStatement",path:a.path,params:a.params,hash:a.hash,program:b,inverse:i,openStrip:a.strip,inverseStrip:j,closeStrip:d&&d.strip,loc:this.locInfo(g)}}function n(a,b){if(!b&&a.length){var c=a[0].loc,d=a[a.length-1].loc;c&&d&&(b={source:c.source,start:{line:c.start.line,column:c.start.column},end:{line:d.end.line,column:d.end.column}})}return{type:"Program",body:a,strip:{},loc:b}}function o(a,b,c,d){return e(a,c),{type:"PartialBlockStatement",name:a.path,params:a.params,hash:a.hash,program:b,openStrip:a.strip,closeStrip:c&&c.strip,loc:this.locInfo(d)}}b.__esModule=!0,b.SourceLocation=f,b.id=g,b.stripFlags=h,b.stripComment=i,b.preparePath=j,b.prepareMustache=k,b.prepareRawBlock=l,b.prepareBlock=m,b.prepareProgram=n,b.preparePartialBlock=o;var p=c(4),q=d(p)},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(){}function f(a,b,c){void 0===b&&(b={}),h(a,b);var d=i(a,b,c);return(new c.JavaScriptCompiler).compile(d,b)}function g(a,b,c){function d(){var d=i(a,b,c),e=(new c.JavaScriptCompiler).compile(d,b,void 0,!0);return c.template(e)}void 0===b&&(b={}),b=n.extend({},b),h(a,b);var e=void 0;return function(a,b){return e||(e=d()),e.call(this,a,b)}}function h(a,b){if(null==a||"string"!=typeof a&&"Program"!==a.type)throw new m["default"]("You must pass a string or Handlebars AST to Handlebars.compile. You passed "+a);if(b.trackIds||b.stringParams)throw new m["default"]("TrackIds and stringParams are no longer supported. See Github #1145");"data"in b||(b.data=!0),b.compat&&(b.useDepths=!0)}function i(a,b,c){var d=c.parse(a,b);return(new c.Compiler).compile(d,b)}function j(a,b){if(a===b)return!0;if(n.isArray(a)&&n.isArray(b)&&a.length===b.length){for(var c=0;c<a.length;c++)if(!j(a[c],b[c]))return!1;return!0}}function k(a){if(!a.path.parts){var b=a.path;a.path={type:"PathExpression",data:!1,depth:0,parts:[b.original+""],original:b.original+"",loc:b.loc}}}b.__esModule=!0,b.Compiler=e,b.precompile=f,b.compile=g;var l=c(4),m=d(l),n=c(3),o=c(19),p=d(o),q=[].slice;e.prototype={compiler:e,equals:function(a){var b=this.opcodes.length;if(a.opcodes.length!==b)return!1;for(var c=0;c<b;c++){var d=this.opcodes[c],e=a.opcodes[c];if(d.opcode!==e.opcode||!j(d.args,e.args))return!1}b=this.children.length;for(var c=0;c<b;c++)if(!this.children[c].equals(a.children[c]))return!1;return!0},guid:0,compile:function(a,b){this.sourceNode=[],this.opcodes=[],this.children=[],this.options=b,b.blockParams=b.blockParams||[];var c=b.knownHelpers;if(b.knownHelpers={helperMissing:!0,blockHelperMissing:!0,each:!0,"if":!0,unless:!0,"with":!0,log:!0,lookup:!0},c)for(var d in c)this.options.knownHelpers[d]=c[d];return this.accept(a)},compileProgram:function(a){var b=new this.compiler,c=b.compile(a,this.options),d=this.guid++;return this.usePartial=this.usePartial||c.usePartial,this.children[d]=c,this.useDepths=this.useDepths||c.useDepths,d},accept:function(a){if(!this[a.type])throw new m["default"]("Unknown type: "+a.type,a);this.sourceNode.unshift(a);var b=this[a.type](a);return this.sourceNode.shift(),b},Program:function(a){this.options.blockParams.unshift(a.blockParams);for(var b=a.body,c=b.length,d=0;d<c;d++)this.accept(b[d]);return this.options.blockParams.shift(),this.isSimple=1===c,this.blockParams=a.blockParams?a.blockParams.length:0,this},BlockStatement:function(a){k(a);var b=a.program,c=a.inverse;b=b&&this.compileProgram(b),c=c&&this.compileProgram(c);var d=this.classifySexpr(a);"helper"===d?this.helperSexpr(a,b,c):"simple"===d?(this.simpleSexpr(a),this.opcode("pushProgram",b),this.opcode("pushProgram",c),this.opcode("emptyHash"),this.opcode("blockValue",a.path.original)):(this.ambiguousSexpr(a,b,c),this.opcode("pushProgram",b),this.opcode("pushProgram",c),this.opcode("emptyHash"),this.opcode("ambiguousBlockValue")),this.opcode("append")},DecoratorBlock:function(a){var b=a.program&&this.compileProgram(a.program),c=this.setupFullMustacheParams(a,b,void 0),d=a.path;this.useDecorators=!0,this.opcode("registerDecorator",c.length,d.original)},PartialStatement:function(a){this.usePartial=!0;var b=a.program;b&&(b=this.compileProgram(a.program));var c=a.params;if(c.length>1)throw new m["default"]("Unsupported number of partial arguments: "+c.length,a);c.length||(this.options.explicitPartialContext?this.opcode("pushLiteral","undefined"):c.push({type:"PathExpression",parts:[],depth:0}));var d=a.name.original,e="SubExpression"===a.name.type;e&&this.accept(a.name),this.setupFullMustacheParams(a,b,void 0,!0);var f=a.indent||"";this.options.preventIndent&&f&&(this.opcode("appendContent",f),f=""),this.opcode("invokePartial",e,d,f),this.opcode("append")},PartialBlockStatement:function(a){this.PartialStatement(a)},MustacheStatement:function(a){this.SubExpression(a),a.escaped&&!this.options.noEscape?this.opcode("appendEscaped"):this.opcode("append")},Decorator:function(a){this.DecoratorBlock(a)},ContentStatement:function(a){a.value&&this.opcode("appendContent",a.value)},CommentStatement:function(){},SubExpression:function(a){k(a);var b=this.classifySexpr(a);"simple"===b?this.simpleSexpr(a):"helper"===b?this.helperSexpr(a):this.ambiguousSexpr(a)},ambiguousSexpr:function(a,b,c){var d=a.path,e=d.parts[0],f=null!=b||null!=c;this.opcode("getContext",d.depth),this.opcode("pushProgram",b),this.opcode("pushProgram",c),d.strict=!0,this.accept(d),this.opcode("invokeAmbiguous",e,f)},simpleSexpr:function(a){var b=a.path;b.strict=!0,this.accept(b),this.opcode("resolvePossibleLambda")},helperSexpr:function(a,b,c){var d=this.setupFullMustacheParams(a,b,c),e=a.path,f=e.parts[0];if(this.options.knownHelpers[f])this.opcode("invokeKnownHelper",d.length,f);else{if(this.options.knownHelpersOnly)throw new m["default"]("You specified knownHelpersOnly, but used the unknown helper "+f,a);e.strict=!0,e.falsy=!0,this.accept(e),this.opcode("invokeHelper",d.length,e.original,p["default"].helpers.simpleId(e))}},PathExpression:function(a){this.addDepth(a.depth),this.opcode("getContext",a.depth);var b=a.parts[0],c=p["default"].helpers.scopedId(a),d=!a.depth&&!c&&this.blockParamIndex(b);d?this.opcode("lookupBlockParam",d,a.parts):b?a.data?(this.options.data=!0,this.opcode("lookupData",a.depth,a.parts,a.strict)):this.opcode("lookupOnContext",a.parts,a.falsy,a.strict,c):this.opcode("pushContext")},StringLiteral:function(a){this.opcode("pushString",a.value)},NumberLiteral:function(a){this.opcode("pushLiteral",a.value)},BooleanLiteral:function(a){this.opcode("pushLiteral",a.value)},UndefinedLiteral:function(){this.opcode("pushLiteral","undefined")},NullLiteral:function(){this.opcode("pushLiteral","null")},Hash:function(a){var b=a.pairs,c=0,d=b.length;for(this.opcode("pushHash");c<d;c++)this.pushParam(b[c].value);for(;c--;)this.opcode("assignToHash",b[c].key);this.opcode("popHash")},opcode:function(a){this.opcodes.push({opcode:a,args:q.call(arguments,1),loc:this.sourceNode[0].loc})},addDepth:function(a){a&&(this.useDepths=!0)},classifySexpr:function(a){var b=p["default"].helpers.simpleId(a.path),c=b&&!!this.blockParamIndex(a.path.parts[0]),d=!c&&p["default"].helpers.helperExpression(a),e=!c&&(d||b);if(e&&!d){var f=a.path.parts[0],g=this.options;g.knownHelpers[f]?d=!0:g.knownHelpersOnly&&(e=!1)}return d?"helper":e?"ambiguous":"simple"},pushParams:function(a){for(var b=0,c=a.length;b<c;b++)this.pushParam(a[b])},pushParam:function(a){this.accept(a)},setupFullMustacheParams:function(a,b,c,d){var e=a.params;return this.pushParams(e),this.opcode("pushProgram",b),this.opcode("pushProgram",c),a.hash?this.accept(a.hash):this.opcode("emptyHash",d),e},blockParamIndex:function(a){for(var b=0,c=this.options.blockParams.length;b<c;b++){var d=this.options.blockParams[b],e=d&&n.indexOf(d,a);if(d&&e>=0)return[b,e]}}}},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a){this.value=a}function f(){}function g(a,b,c,d){var e=b.popStack(),f=0,g=c.length;for(a&&g--;f<g;f++)e=b.nameLookup(e,c[f],d);return a?[b.aliasable("container.strict"),"(",e,", ",b.quotedString(c[f]),")"]:e}b.__esModule=!0;var h=c(2),i=c(4),j=d(i),k=c(3),l=c(27),m=d(l);f.prototype={nameLookup:function(a,b){return f.isValidJavaScriptVariableName(b)?[a,".",b]:[a,"[",JSON.stringify(b),"]"]},depthedLookup:function(a){return[this.aliasable("container.lookup"),'(depths, "',a,'")']},compilerInfo:function(){var a=h.COMPILER_REVISION,b=h.REVISION_CHANGES[a];return[a,b]},appendToBuffer:function(a,b,c){return k.isArray(a)||(a=[a]),a=this.source.wrap(a,b),this.environment.isSimple?["return ",a,";"]:c?["buffer += ",a,";"]:(a.appendToBuffer=!0,a)},initializeBuffer:function(){return this.quotedString("")},compile:function(a,b,c,d){this.environment=a,this.options=b,this.precompile=!d,this.name=this.environment.name,this.isChild=!!c,this.context=c||{decorators:[],programs:[],environments:[]},this.preamble(),this.stackSlot=0,this.stackVars=[],this.aliases={},this.registers={list:[]},this.hashes=[],this.compileStack=[],this.inlineStack=[],this.blockParams=[],this.compileChildren(a,b),this.useDepths=this.useDepths||a.useDepths||a.useDecorators||this.options.compat,this.useBlockParams=this.useBlockParams||a.useBlockParams;var e=a.opcodes,f=void 0,g=void 0,h=void 0,i=void 0;for(h=0,i=e.length;h<i;h++)f=e[h],this.source.currentLocation=f.loc,g=g||f.loc,this[f.opcode].apply(this,f.args);if(this.source.currentLocation=g,this.pushSource(""),this.stackSlot||this.inlineStack.length||this.compileStack.length)throw new j["default"]("Compile completed with content left on stack");this.decorators.isEmpty()?this.decorators=void 0:(this.useDecorators=!0,this.decorators.prepend("var decorators = container.decorators;\n"),this.decorators.push("return fn;"),d?this.decorators=Function.apply(this,["fn","props","container","depth0","data","blockParams","depths",this.decorators.merge()]):(this.decorators.prepend("function(fn, props, container, depth0, data, blockParams, depths) {\n"),this.decorators.push("}\n"),this.decorators=this.decorators.merge()));var k=this.createFunctionContext(d);if(this.isChild)return k;var l={compiler:this.compilerInfo(),main:k};this.decorators&&(l.main_d=this.decorators,l.useDecorators=!0);var m=this.context,n=m.programs,o=m.decorators;for(h=0,i=n.length;h<i;h++)n[h]&&(l[h]=n[h],o[h]&&(l[h+"_d"]=o[h],l.useDecorators=!0));return this.environment.usePartial&&(l.usePartial=!0),this.options.data&&(l.useData=!0),this.useDepths&&(l.useDepths=!0),this.useBlockParams&&(l.useBlockParams=!0),this.options.compat&&(l.compat=!0),d?l.compilerOptions=this.options:(l.compiler=JSON.stringify(l.compiler),this.source.currentLocation={start:{line:1,column:0}},l=this.objectLiteral(l),b.srcName?(l=l.toStringWithSourceMap({file:b.destName}),l.map=l.map&&l.map.toString()):l=l.toString()),l},preamble:function(){this.lastContext=0,this.source=new m["default"](this.options.srcName),this.decorators=new m["default"](this.options.srcName)},createFunctionContext:function(a){var b="",c=this.stackVars.concat(this.registers.list);c.length>0&&(b+=", "+c.join(", "));var d=0;for(var e in this.aliases){var f=this.aliases[e];this.aliases.hasOwnProperty(e)&&f.children&&f.referenceCount>1&&(b+=", alias"+ ++d+"="+e,f.children[0]="alias"+d)}var g=["container","depth0","helpers","partials","data"];(this.useBlockParams||this.useDepths)&&g.push("blockParams"),this.useDepths&&g.push("depths");var h=this.mergeSource(b);return a?(g.push(h),Function.apply(this,g)):this.source.wrap(["function(",g.join(","),") {\n ",h,"}"])},mergeSource:function(a){var b=this.environment.isSimple,c=!this.forceBuffer,d=void 0,e=void 0,f=void 0,g=void 0;return this.source.each(function(a){a.appendToBuffer?(f?a.prepend(" + "):f=a,g=a):(f&&(e?f.prepend("buffer += "):d=!0,g.add(";"),f=g=void 0),e=!0,b||(c=!1))}),c?f?(f.prepend("return "),g.add(";")):e||this.source.push('return "";'):(a+=", buffer = "+(d?"":this.initializeBuffer()),f?(f.prepend("return buffer + "),g.add(";")):this.source.push("return buffer;")),a&&this.source.prepend("var "+a.substring(2)+(d?"":";\n")),this.source.merge()},blockValue:function(a){var b=this.aliasable("helpers.blockHelperMissing"),c=[this.contextName(0)];this.setupHelperArgs(a,0,c);var d=this.popStack();c.splice(1,0,d),this.push(this.source.functionCall(b,"call",c))},ambiguousBlockValue:function(){var a=this.aliasable("helpers.blockHelperMissing"),b=[this.contextName(0)];this.setupHelperArgs("",0,b,!0),this.flushInline();var c=this.topStack();b.splice(1,0,c),this.pushSource(["if (!",this.lastHelper,") { ",c," = ",this.source.functionCall(a,"call",b),"}"])},appendContent:function(a){this.pendingContent?a=this.pendingContent+a:this.pendingLocation=this.source.currentLocation,this.pendingContent=a},append:function(){if(this.isInline())this.replaceStack(function(a){return[" != null ? ",a,' : ""']}),this.pushSource(this.appendToBuffer(this.popStack()));else{var a=this.popStack();this.pushSource(["if (",a," != null) { ",this.appendToBuffer(a,void 0,!0)," }"]),this.environment.isSimple&&this.pushSource(["else { ",this.appendToBuffer("''",void 0,!0)," }"])}},appendEscaped:function(){this.pushSource(this.appendToBuffer([this.aliasable("container.escapeExpression"),"(",this.popStack(),")"]))},getContext:function(a){this.lastContext=a},pushContext:function(){this.pushStackLiteral(this.contextName(this.lastContext))},lookupOnContext:function(a,b,c,d){var e=0;d||!this.options.compat||this.lastContext?this.pushContext():this.push(this.depthedLookup(a[e++])),this.resolvePath("context",a,e,b,c)},lookupBlockParam:function(a,b){this.useBlockParams=!0,this.push(["blockParams[",a[0],"][",a[1],"]"]),this.resolvePath("context",b,1)},lookupData:function(a,b,c){a?this.pushStackLiteral("container.data(data, "+a+")"):this.pushStackLiteral("data"),this.resolvePath("data",b,0,!0,c)},resolvePath:function(a,b,c,d,e){var f=this;if(this.options.strict||this.options.assumeObjects)return void this.push(g(this.options.strict&&e,this,b,a));for(var h=b.length;c<h;c++)this.replaceStack(function(e){var g=f.nameLookup(e,b[c],a);return d?[" && ",g]:[" != null ? ",g," : ",e]})},resolvePossibleLambda:function(){this.push([this.aliasable("container.lambda"),"(",this.popStack(),", ",this.contextName(0),")"])},emptyHash:function(a){this.pushStackLiteral(a?"undefined":"{}")},pushHash:function(){this.hash&&this.hashes.push(this.hash),this.hash={values:{}}},popHash:function(){var a=this.hash;this.hash=this.hashes.pop(),this.push(this.objectLiteral(a.values))},pushString:function(a){this.pushStackLiteral(this.quotedString(a))},pushLiteral:function(a){this.pushStackLiteral(a)},pushProgram:function(a){null!=a?this.pushStackLiteral(this.programExpression(a)):this.pushStackLiteral(null)},registerDecorator:function(a,b){var c=this.nameLookup("decorators",b,"decorator"),d=this.setupHelperArgs(b,a);this.decorators.push(["fn = ",this.decorators.functionCall(c,"",["fn","props","container",d])," || fn;"])},invokeHelper:function(a,b,c){var d=this.popStack(),e=this.setupHelper(a,b),f=c?[e.name," || "]:"",g=["("].concat(f,d);this.options.strict||g.push(" || ",this.aliasable("helpers.helperMissing")),g.push(")"),this.push(this.source.functionCall(g,"call",e.callParams))},invokeKnownHelper:function(a,b){var c=this.setupHelper(a,b);this.push(this.source.functionCall(c.name,"call",c.callParams))},invokeAmbiguous:function(a,b){this.useRegister("helper");var c=this.popStack();this.emptyHash();var d=this.setupHelper(0,a,b),e=this.lastHelper=this.nameLookup("helpers",a,"helper"),f=["(","(helper = ",e," || ",c,")"];this.options.strict||(f[0]="(helper = ",f.push(" != null ? helper : ",this.aliasable("helpers.helperMissing"))),this.push(["(",f,d.paramsInit?["),(",d.paramsInit]:[],"),","(typeof helper === ",this.aliasable('"function"')," ? ",this.source.functionCall("helper","call",d.callParams)," : helper))"])},invokePartial:function(a,b,c){var d=[],e=this.setupParams(b,1,d);a&&(b=this.popStack(),delete e.name),c&&(e.indent=JSON.stringify(c)),e.helpers="helpers",e.partials="partials",e.decorators="container.decorators",a?d.unshift(b):d.unshift(this.nameLookup("partials",b,"partial")),this.options.compat&&(e.depths="depths"),e=this.objectLiteral(e),d.push(e),this.push(this.source.functionCall("container.invokePartial","",d))},assignToHash:function(a){this.hash.values[a]=this.popStack()},compiler:f,compileChildren:function(a,b){for(var c=a.children,d=void 0,e=void 0,f=0,g=c.length;f<g;f++){d=c[f],e=new this.compiler;var h=this.matchExistingProgram(d);if(null==h){this.context.programs.push("");var i=this.context.programs.length;d.index=i,d.name="program"+i,this.context.programs[i]=e.compile(d,b,this.context,!this.precompile),this.context.decorators[i]=e.decorators,this.context.environments[i]=d,this.useDepths=this.useDepths||e.useDepths,this.useBlockParams=this.useBlockParams||e.useBlockParams,d.useDepths=this.useDepths,d.useBlockParams=this.useBlockParams}else d.index=h.index,d.name="program"+h.index,this.useDepths=this.useDepths||h.useDepths,this.useBlockParams=this.useBlockParams||h.useBlockParams}},matchExistingProgram:function(a){for(var b=0,c=this.context.environments.length;b<c;b++){var d=this.context.environments[b];if(d&&d.equals(a))return d}},programExpression:function(a){var b=this.environment.children[a],c=[b.index,"data",b.blockParams];return(this.useBlockParams||this.useDepths)&&c.push("blockParams"),this.useDepths&&c.push("depths"),"container.program("+c.join(", ")+")"},useRegister:function(a){this.registers[a]||(this.registers[a]=!0,this.registers.list.push(a))},push:function(a){return a instanceof e||(a=this.source.wrap(a)),this.inlineStack.push(a),a},pushStackLiteral:function(a){this.push(new e(a))},pushSource:function(a){this.pendingContent&&(this.source.push(this.appendToBuffer(this.source.quotedString(this.pendingContent),this.pendingLocation)),this.pendingContent=void 0),a&&this.source.push(a)},replaceStack:function(a){var b=["("],c=void 0,d=void 0,f=void 0;if(!this.isInline())throw new j["default"]("replaceStack on non-inline");var g=this.popStack(!0);if(g instanceof e)c=[g.value],b=["(",c],f=!0;else{d=!0;var h=this.incrStack();b=["((",this.push(h)," = ",g,")"],c=this.topStack()}var i=a.call(this,c);f||this.popStack(),d&&this.stackSlot--,this.push(b.concat(i,")"))},incrStack:function(){return this.stackSlot++,this.stackSlot>this.stackVars.length&&this.stackVars.push("stack"+this.stackSlot),this.topStackName()},topStackName:function(){return"stack"+this.stackSlot},flushInline:function(){var a=this.inlineStack;this.inlineStack=[];for(var b=0,c=a.length;b<c;b++){var d=a[b];if(d instanceof e)this.compileStack.push(d);else{var f=this.incrStack();this.pushSource([f," = ",d,";"]),this.compileStack.push(f)}}},isInline:function(){return this.inlineStack.length},popStack:function(a){var b=this.isInline(),c=(b?this.inlineStack:this.compileStack).pop();if(!a&&c instanceof e)return c.value;if(!b){if(!this.stackSlot)throw new j["default"]("Invalid stack pop");this.stackSlot--}return c},topStack:function(){var a=this.isInline()?this.inlineStack:this.compileStack,b=a[a.length-1];return b instanceof e?b.value:b},contextName:function(a){return this.useDepths&&a?"depths["+a+"]":"depth"+a},quotedString:function(a){return this.source.quotedString(a)},objectLiteral:function(a){return this.source.objectLiteral(a)},aliasable:function(a){var b=this.aliases[a];return b?(b.referenceCount++,b):(b=this.aliases[a]=this.source.wrap(a),b.aliasable=!0,b.referenceCount=1,b)},setupHelper:function(a,b,c){var d=[],e=this.setupHelperArgs(b,a,d,c),f=this.nameLookup("helpers",b,"helper"),g=this.aliasable(this.contextName(0)+" != null ? "+this.contextName(0)+" : (container.nullContext || {})");return{params:d,paramsInit:e,name:f,callParams:[g].concat(d)}},setupParams:function(a,b,c){var d={},e=!c,f=void 0;e&&(c=[]),d.name=this.quotedString(a),d.hash=this.popStack();var g=this.popStack(),h=this.popStack();(h||g)&&(d.fn=h||"container.noop",d.inverse=g||"container.noop");for(var i=b;i--;)f=this.popStack(),c[i]=f;return e&&(d.args=this.source.generateArray(c)),this.options.data&&(d.data="data"),this.useBlockParams&&(d.blockParams="blockParams"),d},setupHelperArgs:function(a,b,c,d){var e=this.setupParams(a,b,c);return e=this.objectLiteral(e),d?(this.useRegister("options"),c.push("options"),["options=",e]):c?(c.push(e),""):e}},function(){for(var a="break else new var case finally return void catch for switch while continue function this with default if throw delete in try do instanceof typeof abstract enum int short boolean export interface static byte extends long super char final native synchronized class float package throws const goto private transient debugger implements protected volatile double import public let yield await null true false".split(" "),b=f.RESERVED_WORDS={},c=0,d=a.length;c<d;c++)b[a[c]]=!0}(),f.isValidJavaScriptVariableName=function(a){return!f.RESERVED_WORDS[a]&&/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(a)},b["default"]=f,a.exports=b["default"]},function(a,b,c){"use strict";function d(a,b,c){if(f.isArray(a)){for(var d=[],e=0,g=a.length;e<g;e++)d.push(b.wrap(a[e],c));return d}return"boolean"==typeof a||"number"==typeof a?a+"":a}function e(a){this.srcFile=a,this.source=[]}b.__esModule=!0;var f=c(3),g=void 0;try{}catch(h){}g||(g=function(a,b,c,d){this.src="",d&&this.add(d)},g.prototype={add:function(a){f.isArray(a)&&(a=a.join("")),this.src+=a},prepend:function(a){f.isArray(a)&&(a=a.join("")),this.src=a+this.src},toStringWithSourceMap:function(){return{code:this.toString()}},toString:function(){return this.src}}),e.prototype={isEmpty:function(){return!this.source.length},prepend:function(a,b){this.source.unshift(this.wrap(a,b))},push:function(a,b){this.source.push(this.wrap(a,b))},merge:function(){var a=this.empty();return this.each(function(b){a.add([" ",b,"\n"])}),a},each:function(a){for(var b=0,c=this.source.length;b<c;b++)a(this.source[b])},empty:function(){var a=this.currentLocation||{start:{}};return new g(a.start.line,a.start.column,this.srcFile)},wrap:function(a){var b=arguments.length<=1||void 0===arguments[1]?this.currentLocation||{start:{}}:arguments[1];return a instanceof g?a:(a=d(a,this,b),new g(b.start.line,b.start.column,this.srcFile,a))},functionCall:function(a,b,c){return c=this.generateList(c),this.wrap([a,b?"."+b+"(":"(",c,")"])},quotedString:function(a){return'"'+(a+"").replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")+'"'},objectLiteral:function(a){var b=[];for(var c in a)if(a.hasOwnProperty(c)){var e=d(a[c],this);"undefined"!==e&&b.push([this.quotedString(c),":",e])}var f=this.generateList(b);return f.prepend("{"),f.add("}"),f},generateList:function(a){for(var b=this.empty(),c=0,e=a.length;c<e;c++)c&&b.add(","),b.add(d(a[c],this));return b},generateArray:function(a){var b=this.generateList(a);return b.prepend("["),b.add("]"),b}},b["default"]=e,a.exports=b["default"]}])});
|
29
|
+
// @license-end
|
@@ -0,0 +1,1477 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery File Upload Plugin
|
3
|
+
* https://github.com/blueimp/jQuery-File-Upload
|
4
|
+
*
|
5
|
+
* Copyright 2010, Sebastian Tschan
|
6
|
+
* https://blueimp.net
|
7
|
+
*
|
8
|
+
* Licensed under the MIT license:
|
9
|
+
* http://www.opensource.org/licenses/MIT
|
10
|
+
*/
|
11
|
+
|
12
|
+
/* jshint nomen:false */
|
13
|
+
/* global define, require, window, document, location, Blob, FormData */
|
14
|
+
|
15
|
+
(function (factory) {
|
16
|
+
'use strict';
|
17
|
+
if (typeof define === 'function' && define.amd) {
|
18
|
+
// Register as an anonymous AMD module:
|
19
|
+
define([
|
20
|
+
'jquery',
|
21
|
+
'jquery.ui.widget'
|
22
|
+
], factory);
|
23
|
+
} else if (typeof exports === 'object') {
|
24
|
+
// Node/CommonJS:
|
25
|
+
factory(
|
26
|
+
require('jquery'),
|
27
|
+
require('./vendor/jquery.ui.widget')
|
28
|
+
);
|
29
|
+
} else {
|
30
|
+
// Browser globals:
|
31
|
+
factory(window.jQuery);
|
32
|
+
}
|
33
|
+
}(function ($) {
|
34
|
+
'use strict';
|
35
|
+
|
36
|
+
// Detect file input support, based on
|
37
|
+
// http://viljamis.com/blog/2012/file-upload-support-on-mobile/
|
38
|
+
$.support.fileInput = !(new RegExp(
|
39
|
+
// Handle devices which give false positives for the feature detection:
|
40
|
+
'(Android (1\\.[0156]|2\\.[01]))' +
|
41
|
+
'|(Windows Phone (OS 7|8\\.0))|(XBLWP)|(ZuneWP)|(WPDesktop)' +
|
42
|
+
'|(w(eb)?OSBrowser)|(webOS)' +
|
43
|
+
'|(Kindle/(1\\.0|2\\.[05]|3\\.0))'
|
44
|
+
).test(window.navigator.userAgent) ||
|
45
|
+
// Feature detection for all other devices:
|
46
|
+
$('<input type="file">').prop('disabled'));
|
47
|
+
|
48
|
+
// The FileReader API is not actually used, but works as feature detection,
|
49
|
+
// as some Safari versions (5?) support XHR file uploads via the FormData API,
|
50
|
+
// but not non-multipart XHR file uploads.
|
51
|
+
// window.XMLHttpRequestUpload is not available on IE10, so we check for
|
52
|
+
// window.ProgressEvent instead to detect XHR2 file upload capability:
|
53
|
+
$.support.xhrFileUpload = !!(window.ProgressEvent && window.FileReader);
|
54
|
+
$.support.xhrFormDataFileUpload = !!window.FormData;
|
55
|
+
|
56
|
+
// Detect support for Blob slicing (required for chunked uploads):
|
57
|
+
$.support.blobSlice = window.Blob && (Blob.prototype.slice ||
|
58
|
+
Blob.prototype.webkitSlice || Blob.prototype.mozSlice);
|
59
|
+
|
60
|
+
// Helper function to create drag handlers for dragover/dragenter/dragleave:
|
61
|
+
function getDragHandler(type) {
|
62
|
+
var isDragOver = type === 'dragover';
|
63
|
+
return function (e) {
|
64
|
+
e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer;
|
65
|
+
var dataTransfer = e.dataTransfer;
|
66
|
+
if (dataTransfer && $.inArray('Files', dataTransfer.types) !== -1 &&
|
67
|
+
this._trigger(
|
68
|
+
type,
|
69
|
+
$.Event(type, {delegatedEvent: e})
|
70
|
+
) !== false) {
|
71
|
+
e.preventDefault();
|
72
|
+
if (isDragOver) {
|
73
|
+
dataTransfer.dropEffect = 'copy';
|
74
|
+
}
|
75
|
+
}
|
76
|
+
};
|
77
|
+
}
|
78
|
+
|
79
|
+
// The fileupload widget listens for change events on file input fields defined
|
80
|
+
// via fileInput setting and paste or drop events of the given dropZone.
|
81
|
+
// In addition to the default jQuery Widget methods, the fileupload widget
|
82
|
+
// exposes the "add" and "send" methods, to add or directly send files using
|
83
|
+
// the fileupload API.
|
84
|
+
// By default, files added via file input selection, paste, drag & drop or
|
85
|
+
// "add" method are uploaded immediately, but it is possible to override
|
86
|
+
// the "add" callback option to queue file uploads.
|
87
|
+
$.widget('blueimp.fileupload', {
|
88
|
+
|
89
|
+
options: {
|
90
|
+
// The drop target element(s), by the default the complete document.
|
91
|
+
// Set to null to disable drag & drop support:
|
92
|
+
dropZone: $(document),
|
93
|
+
// The paste target element(s), by the default undefined.
|
94
|
+
// Set to a DOM node or jQuery object to enable file pasting:
|
95
|
+
pasteZone: undefined,
|
96
|
+
// The file input field(s), that are listened to for change events.
|
97
|
+
// If undefined, it is set to the file input fields inside
|
98
|
+
// of the widget element on plugin initialization.
|
99
|
+
// Set to null to disable the change listener.
|
100
|
+
fileInput: undefined,
|
101
|
+
// By default, the file input field is replaced with a clone after
|
102
|
+
// each input field change event. This is required for iframe transport
|
103
|
+
// queues and allows change events to be fired for the same file
|
104
|
+
// selection, but can be disabled by setting the following option to false:
|
105
|
+
replaceFileInput: true,
|
106
|
+
// The parameter name for the file form data (the request argument name).
|
107
|
+
// If undefined or empty, the name property of the file input field is
|
108
|
+
// used, or "files[]" if the file input name property is also empty,
|
109
|
+
// can be a string or an array of strings:
|
110
|
+
paramName: undefined,
|
111
|
+
// By default, each file of a selection is uploaded using an individual
|
112
|
+
// request for XHR type uploads. Set to false to upload file
|
113
|
+
// selections in one request each:
|
114
|
+
singleFileUploads: true,
|
115
|
+
// To limit the number of files uploaded with one XHR request,
|
116
|
+
// set the following option to an integer greater than 0:
|
117
|
+
limitMultiFileUploads: undefined,
|
118
|
+
// The following option limits the number of files uploaded with one
|
119
|
+
// XHR request to keep the request size under or equal to the defined
|
120
|
+
// limit in bytes:
|
121
|
+
limitMultiFileUploadSize: undefined,
|
122
|
+
// Multipart file uploads add a number of bytes to each uploaded file,
|
123
|
+
// therefore the following option adds an overhead for each file used
|
124
|
+
// in the limitMultiFileUploadSize configuration:
|
125
|
+
limitMultiFileUploadSizeOverhead: 512,
|
126
|
+
// Set the following option to true to issue all file upload requests
|
127
|
+
// in a sequential order:
|
128
|
+
sequentialUploads: false,
|
129
|
+
// To limit the number of concurrent uploads,
|
130
|
+
// set the following option to an integer greater than 0:
|
131
|
+
limitConcurrentUploads: undefined,
|
132
|
+
// Set the following option to true to force iframe transport uploads:
|
133
|
+
forceIframeTransport: false,
|
134
|
+
// Set the following option to the location of a redirect url on the
|
135
|
+
// origin server, for cross-domain iframe transport uploads:
|
136
|
+
redirect: undefined,
|
137
|
+
// The parameter name for the redirect url, sent as part of the form
|
138
|
+
// data and set to 'redirect' if this option is empty:
|
139
|
+
redirectParamName: undefined,
|
140
|
+
// Set the following option to the location of a postMessage window,
|
141
|
+
// to enable postMessage transport uploads:
|
142
|
+
postMessage: undefined,
|
143
|
+
// By default, XHR file uploads are sent as multipart/form-data.
|
144
|
+
// The iframe transport is always using multipart/form-data.
|
145
|
+
// Set to false to enable non-multipart XHR uploads:
|
146
|
+
multipart: true,
|
147
|
+
// To upload large files in smaller chunks, set the following option
|
148
|
+
// to a preferred maximum chunk size. If set to 0, null or undefined,
|
149
|
+
// or the browser does not support the required Blob API, files will
|
150
|
+
// be uploaded as a whole.
|
151
|
+
maxChunkSize: undefined,
|
152
|
+
// When a non-multipart upload or a chunked multipart upload has been
|
153
|
+
// aborted, this option can be used to resume the upload by setting
|
154
|
+
// it to the size of the already uploaded bytes. This option is most
|
155
|
+
// useful when modifying the options object inside of the "add" or
|
156
|
+
// "send" callbacks, as the options are cloned for each file upload.
|
157
|
+
uploadedBytes: undefined,
|
158
|
+
// By default, failed (abort or error) file uploads are removed from the
|
159
|
+
// global progress calculation. Set the following option to false to
|
160
|
+
// prevent recalculating the global progress data:
|
161
|
+
recalculateProgress: true,
|
162
|
+
// Interval in milliseconds to calculate and trigger progress events:
|
163
|
+
progressInterval: 100,
|
164
|
+
// Interval in milliseconds to calculate progress bitrate:
|
165
|
+
bitrateInterval: 500,
|
166
|
+
// By default, uploads are started automatically when adding files:
|
167
|
+
autoUpload: true,
|
168
|
+
|
169
|
+
// Error and info messages:
|
170
|
+
messages: {
|
171
|
+
uploadedBytes: 'Uploaded bytes exceed file size'
|
172
|
+
},
|
173
|
+
|
174
|
+
// Translation function, gets the message key to be translated
|
175
|
+
// and an object with context specific data as arguments:
|
176
|
+
i18n: function (message, context) {
|
177
|
+
message = this.messages[message] || message.toString();
|
178
|
+
if (context) {
|
179
|
+
$.each(context, function (key, value) {
|
180
|
+
message = message.replace('{' + key + '}', value);
|
181
|
+
});
|
182
|
+
}
|
183
|
+
return message;
|
184
|
+
},
|
185
|
+
|
186
|
+
// Additional form data to be sent along with the file uploads can be set
|
187
|
+
// using this option, which accepts an array of objects with name and
|
188
|
+
// value properties, a function returning such an array, a FormData
|
189
|
+
// object (for XHR file uploads), or a simple object.
|
190
|
+
// The form of the first fileInput is given as parameter to the function:
|
191
|
+
formData: function (form) {
|
192
|
+
return form.serializeArray();
|
193
|
+
},
|
194
|
+
|
195
|
+
// The add callback is invoked as soon as files are added to the fileupload
|
196
|
+
// widget (via file input selection, drag & drop, paste or add API call).
|
197
|
+
// If the singleFileUploads option is enabled, this callback will be
|
198
|
+
// called once for each file in the selection for XHR file uploads, else
|
199
|
+
// once for each file selection.
|
200
|
+
//
|
201
|
+
// The upload starts when the submit method is invoked on the data parameter.
|
202
|
+
// The data object contains a files property holding the added files
|
203
|
+
// and allows you to override plugin options as well as define ajax settings.
|
204
|
+
//
|
205
|
+
// Listeners for this callback can also be bound the following way:
|
206
|
+
// .bind('fileuploadadd', func);
|
207
|
+
//
|
208
|
+
// data.submit() returns a Promise object and allows to attach additional
|
209
|
+
// handlers using jQuery's Deferred callbacks:
|
210
|
+
// data.submit().done(func).fail(func).always(func);
|
211
|
+
add: function (e, data) {
|
212
|
+
if (e.isDefaultPrevented()) {
|
213
|
+
return false;
|
214
|
+
}
|
215
|
+
if (data.autoUpload || (data.autoUpload !== false &&
|
216
|
+
$(this).fileupload('option', 'autoUpload'))) {
|
217
|
+
data.process().done(function () {
|
218
|
+
data.submit();
|
219
|
+
});
|
220
|
+
}
|
221
|
+
},
|
222
|
+
|
223
|
+
// Other callbacks:
|
224
|
+
|
225
|
+
// Callback for the submit event of each file upload:
|
226
|
+
// submit: function (e, data) {}, // .bind('fileuploadsubmit', func);
|
227
|
+
|
228
|
+
// Callback for the start of each file upload request:
|
229
|
+
// send: function (e, data) {}, // .bind('fileuploadsend', func);
|
230
|
+
|
231
|
+
// Callback for successful uploads:
|
232
|
+
// done: function (e, data) {}, // .bind('fileuploaddone', func);
|
233
|
+
|
234
|
+
// Callback for failed (abort or error) uploads:
|
235
|
+
// fail: function (e, data) {}, // .bind('fileuploadfail', func);
|
236
|
+
|
237
|
+
// Callback for completed (success, abort or error) requests:
|
238
|
+
// always: function (e, data) {}, // .bind('fileuploadalways', func);
|
239
|
+
|
240
|
+
// Callback for upload progress events:
|
241
|
+
// progress: function (e, data) {}, // .bind('fileuploadprogress', func);
|
242
|
+
|
243
|
+
// Callback for global upload progress events:
|
244
|
+
// progressall: function (e, data) {}, // .bind('fileuploadprogressall', func);
|
245
|
+
|
246
|
+
// Callback for uploads start, equivalent to the global ajaxStart event:
|
247
|
+
// start: function (e) {}, // .bind('fileuploadstart', func);
|
248
|
+
|
249
|
+
// Callback for uploads stop, equivalent to the global ajaxStop event:
|
250
|
+
// stop: function (e) {}, // .bind('fileuploadstop', func);
|
251
|
+
|
252
|
+
// Callback for change events of the fileInput(s):
|
253
|
+
// change: function (e, data) {}, // .bind('fileuploadchange', func);
|
254
|
+
|
255
|
+
// Callback for paste events to the pasteZone(s):
|
256
|
+
// paste: function (e, data) {}, // .bind('fileuploadpaste', func);
|
257
|
+
|
258
|
+
// Callback for drop events of the dropZone(s):
|
259
|
+
// drop: function (e, data) {}, // .bind('fileuploaddrop', func);
|
260
|
+
|
261
|
+
// Callback for dragover events of the dropZone(s):
|
262
|
+
// dragover: function (e) {}, // .bind('fileuploaddragover', func);
|
263
|
+
|
264
|
+
// Callback for the start of each chunk upload request:
|
265
|
+
// chunksend: function (e, data) {}, // .bind('fileuploadchunksend', func);
|
266
|
+
|
267
|
+
// Callback for successful chunk uploads:
|
268
|
+
// chunkdone: function (e, data) {}, // .bind('fileuploadchunkdone', func);
|
269
|
+
|
270
|
+
// Callback for failed (abort or error) chunk uploads:
|
271
|
+
// chunkfail: function (e, data) {}, // .bind('fileuploadchunkfail', func);
|
272
|
+
|
273
|
+
// Callback for completed (success, abort or error) chunk upload requests:
|
274
|
+
// chunkalways: function (e, data) {}, // .bind('fileuploadchunkalways', func);
|
275
|
+
|
276
|
+
// The plugin options are used as settings object for the ajax calls.
|
277
|
+
// The following are jQuery ajax settings required for the file uploads:
|
278
|
+
processData: false,
|
279
|
+
contentType: false,
|
280
|
+
cache: false,
|
281
|
+
timeout: 0
|
282
|
+
},
|
283
|
+
|
284
|
+
// A list of options that require reinitializing event listeners and/or
|
285
|
+
// special initialization code:
|
286
|
+
_specialOptions: [
|
287
|
+
'fileInput',
|
288
|
+
'dropZone',
|
289
|
+
'pasteZone',
|
290
|
+
'multipart',
|
291
|
+
'forceIframeTransport'
|
292
|
+
],
|
293
|
+
|
294
|
+
_blobSlice: $.support.blobSlice && function () {
|
295
|
+
var slice = this.slice || this.webkitSlice || this.mozSlice;
|
296
|
+
return slice.apply(this, arguments);
|
297
|
+
},
|
298
|
+
|
299
|
+
_BitrateTimer: function () {
|
300
|
+
this.timestamp = ((Date.now) ? Date.now() : (new Date()).getTime());
|
301
|
+
this.loaded = 0;
|
302
|
+
this.bitrate = 0;
|
303
|
+
this.getBitrate = function (now, loaded, interval) {
|
304
|
+
var timeDiff = now - this.timestamp;
|
305
|
+
if (!this.bitrate || !interval || timeDiff > interval) {
|
306
|
+
this.bitrate = (loaded - this.loaded) * (1000 / timeDiff) * 8;
|
307
|
+
this.loaded = loaded;
|
308
|
+
this.timestamp = now;
|
309
|
+
}
|
310
|
+
return this.bitrate;
|
311
|
+
};
|
312
|
+
},
|
313
|
+
|
314
|
+
_isXHRUpload: function (options) {
|
315
|
+
return !options.forceIframeTransport &&
|
316
|
+
((!options.multipart && $.support.xhrFileUpload) ||
|
317
|
+
$.support.xhrFormDataFileUpload);
|
318
|
+
},
|
319
|
+
|
320
|
+
_getFormData: function (options) {
|
321
|
+
var formData;
|
322
|
+
if ($.type(options.formData) === 'function') {
|
323
|
+
return options.formData(options.form);
|
324
|
+
}
|
325
|
+
if ($.isArray(options.formData)) {
|
326
|
+
return options.formData;
|
327
|
+
}
|
328
|
+
if ($.type(options.formData) === 'object') {
|
329
|
+
formData = [];
|
330
|
+
$.each(options.formData, function (name, value) {
|
331
|
+
formData.push({name: name, value: value});
|
332
|
+
});
|
333
|
+
return formData;
|
334
|
+
}
|
335
|
+
return [];
|
336
|
+
},
|
337
|
+
|
338
|
+
_getTotal: function (files) {
|
339
|
+
var total = 0;
|
340
|
+
$.each(files, function (index, file) {
|
341
|
+
total += file.size || 1;
|
342
|
+
});
|
343
|
+
return total;
|
344
|
+
},
|
345
|
+
|
346
|
+
_initProgressObject: function (obj) {
|
347
|
+
var progress = {
|
348
|
+
loaded: 0,
|
349
|
+
total: 0,
|
350
|
+
bitrate: 0
|
351
|
+
};
|
352
|
+
if (obj._progress) {
|
353
|
+
$.extend(obj._progress, progress);
|
354
|
+
} else {
|
355
|
+
obj._progress = progress;
|
356
|
+
}
|
357
|
+
},
|
358
|
+
|
359
|
+
_initResponseObject: function (obj) {
|
360
|
+
var prop;
|
361
|
+
if (obj._response) {
|
362
|
+
for (prop in obj._response) {
|
363
|
+
if (obj._response.hasOwnProperty(prop)) {
|
364
|
+
delete obj._response[prop];
|
365
|
+
}
|
366
|
+
}
|
367
|
+
} else {
|
368
|
+
obj._response = {};
|
369
|
+
}
|
370
|
+
},
|
371
|
+
|
372
|
+
_onProgress: function (e, data) {
|
373
|
+
if (e.lengthComputable) {
|
374
|
+
var now = ((Date.now) ? Date.now() : (new Date()).getTime()),
|
375
|
+
loaded;
|
376
|
+
if (data._time && data.progressInterval &&
|
377
|
+
(now - data._time < data.progressInterval) &&
|
378
|
+
e.loaded !== e.total) {
|
379
|
+
return;
|
380
|
+
}
|
381
|
+
data._time = now;
|
382
|
+
loaded = Math.floor(
|
383
|
+
e.loaded / e.total * (data.chunkSize || data._progress.total)
|
384
|
+
) + (data.uploadedBytes || 0);
|
385
|
+
// Add the difference from the previously loaded state
|
386
|
+
// to the global loaded counter:
|
387
|
+
this._progress.loaded += (loaded - data._progress.loaded);
|
388
|
+
this._progress.bitrate = this._bitrateTimer.getBitrate(
|
389
|
+
now,
|
390
|
+
this._progress.loaded,
|
391
|
+
data.bitrateInterval
|
392
|
+
);
|
393
|
+
data._progress.loaded = data.loaded = loaded;
|
394
|
+
data._progress.bitrate = data.bitrate = data._bitrateTimer.getBitrate(
|
395
|
+
now,
|
396
|
+
loaded,
|
397
|
+
data.bitrateInterval
|
398
|
+
);
|
399
|
+
// Trigger a custom progress event with a total data property set
|
400
|
+
// to the file size(s) of the current upload and a loaded data
|
401
|
+
// property calculated accordingly:
|
402
|
+
this._trigger(
|
403
|
+
'progress',
|
404
|
+
$.Event('progress', {delegatedEvent: e}),
|
405
|
+
data
|
406
|
+
);
|
407
|
+
// Trigger a global progress event for all current file uploads,
|
408
|
+
// including ajax calls queued for sequential file uploads:
|
409
|
+
this._trigger(
|
410
|
+
'progressall',
|
411
|
+
$.Event('progressall', {delegatedEvent: e}),
|
412
|
+
this._progress
|
413
|
+
);
|
414
|
+
}
|
415
|
+
},
|
416
|
+
|
417
|
+
_initProgressListener: function (options) {
|
418
|
+
var that = this,
|
419
|
+
xhr = options.xhr ? options.xhr() : $.ajaxSettings.xhr();
|
420
|
+
// Accesss to the native XHR object is required to add event listeners
|
421
|
+
// for the upload progress event:
|
422
|
+
if (xhr.upload) {
|
423
|
+
$(xhr.upload).bind('progress', function (e) {
|
424
|
+
var oe = e.originalEvent;
|
425
|
+
// Make sure the progress event properties get copied over:
|
426
|
+
e.lengthComputable = oe.lengthComputable;
|
427
|
+
e.loaded = oe.loaded;
|
428
|
+
e.total = oe.total;
|
429
|
+
that._onProgress(e, options);
|
430
|
+
});
|
431
|
+
options.xhr = function () {
|
432
|
+
return xhr;
|
433
|
+
};
|
434
|
+
}
|
435
|
+
},
|
436
|
+
|
437
|
+
_isInstanceOf: function (type, obj) {
|
438
|
+
// Cross-frame instanceof check
|
439
|
+
return Object.prototype.toString.call(obj) === '[object ' + type + ']';
|
440
|
+
},
|
441
|
+
|
442
|
+
_initXHRData: function (options) {
|
443
|
+
var that = this,
|
444
|
+
formData,
|
445
|
+
file = options.files[0],
|
446
|
+
// Ignore non-multipart setting if not supported:
|
447
|
+
multipart = options.multipart || !$.support.xhrFileUpload,
|
448
|
+
paramName = $.type(options.paramName) === 'array' ?
|
449
|
+
options.paramName[0] : options.paramName;
|
450
|
+
options.headers = $.extend({}, options.headers);
|
451
|
+
if (options.contentRange) {
|
452
|
+
options.headers['Content-Range'] = options.contentRange;
|
453
|
+
}
|
454
|
+
if (!multipart || options.blob || !this._isInstanceOf('File', file)) {
|
455
|
+
options.headers['Content-Disposition'] = 'attachment; filename="' +
|
456
|
+
encodeURI(file.name) + '"';
|
457
|
+
}
|
458
|
+
if (!multipart) {
|
459
|
+
options.contentType = file.type || 'application/octet-stream';
|
460
|
+
options.data = options.blob || file;
|
461
|
+
} else if ($.support.xhrFormDataFileUpload) {
|
462
|
+
if (options.postMessage) {
|
463
|
+
// window.postMessage does not allow sending FormData
|
464
|
+
// objects, so we just add the File/Blob objects to
|
465
|
+
// the formData array and let the postMessage window
|
466
|
+
// create the FormData object out of this array:
|
467
|
+
formData = this._getFormData(options);
|
468
|
+
if (options.blob) {
|
469
|
+
formData.push({
|
470
|
+
name: paramName,
|
471
|
+
value: options.blob
|
472
|
+
});
|
473
|
+
} else {
|
474
|
+
$.each(options.files, function (index, file) {
|
475
|
+
formData.push({
|
476
|
+
name: ($.type(options.paramName) === 'array' &&
|
477
|
+
options.paramName[index]) || paramName,
|
478
|
+
value: file
|
479
|
+
});
|
480
|
+
});
|
481
|
+
}
|
482
|
+
} else {
|
483
|
+
if (that._isInstanceOf('FormData', options.formData)) {
|
484
|
+
formData = options.formData;
|
485
|
+
} else {
|
486
|
+
formData = new FormData();
|
487
|
+
$.each(this._getFormData(options), function (index, field) {
|
488
|
+
formData.append(field.name, field.value);
|
489
|
+
});
|
490
|
+
}
|
491
|
+
if (options.blob) {
|
492
|
+
formData.append(paramName, options.blob, file.name);
|
493
|
+
} else {
|
494
|
+
$.each(options.files, function (index, file) {
|
495
|
+
// This check allows the tests to run with
|
496
|
+
// dummy objects:
|
497
|
+
if (that._isInstanceOf('File', file) ||
|
498
|
+
that._isInstanceOf('Blob', file)) {
|
499
|
+
formData.append(
|
500
|
+
($.type(options.paramName) === 'array' &&
|
501
|
+
options.paramName[index]) || paramName,
|
502
|
+
file,
|
503
|
+
file.uploadName || file.name
|
504
|
+
);
|
505
|
+
}
|
506
|
+
});
|
507
|
+
}
|
508
|
+
}
|
509
|
+
options.data = formData;
|
510
|
+
}
|
511
|
+
// Blob reference is not needed anymore, free memory:
|
512
|
+
options.blob = null;
|
513
|
+
},
|
514
|
+
|
515
|
+
_initIframeSettings: function (options) {
|
516
|
+
var targetHost = $('<a></a>').prop('href', options.url).prop('host');
|
517
|
+
// Setting the dataType to iframe enables the iframe transport:
|
518
|
+
options.dataType = 'iframe ' + (options.dataType || '');
|
519
|
+
// The iframe transport accepts a serialized array as form data:
|
520
|
+
options.formData = this._getFormData(options);
|
521
|
+
// Add redirect url to form data on cross-domain uploads:
|
522
|
+
if (options.redirect && targetHost && targetHost !== location.host) {
|
523
|
+
options.formData.push({
|
524
|
+
name: options.redirectParamName || 'redirect',
|
525
|
+
value: options.redirect
|
526
|
+
});
|
527
|
+
}
|
528
|
+
},
|
529
|
+
|
530
|
+
_initDataSettings: function (options) {
|
531
|
+
if (this._isXHRUpload(options)) {
|
532
|
+
if (!this._chunkedUpload(options, true)) {
|
533
|
+
if (!options.data) {
|
534
|
+
this._initXHRData(options);
|
535
|
+
}
|
536
|
+
this._initProgressListener(options);
|
537
|
+
}
|
538
|
+
if (options.postMessage) {
|
539
|
+
// Setting the dataType to postmessage enables the
|
540
|
+
// postMessage transport:
|
541
|
+
options.dataType = 'postmessage ' + (options.dataType || '');
|
542
|
+
}
|
543
|
+
} else {
|
544
|
+
this._initIframeSettings(options);
|
545
|
+
}
|
546
|
+
},
|
547
|
+
|
548
|
+
_getParamName: function (options) {
|
549
|
+
var fileInput = $(options.fileInput),
|
550
|
+
paramName = options.paramName;
|
551
|
+
if (!paramName) {
|
552
|
+
paramName = [];
|
553
|
+
fileInput.each(function () {
|
554
|
+
var input = $(this),
|
555
|
+
name = input.prop('name') || 'files[]',
|
556
|
+
i = (input.prop('files') || [1]).length;
|
557
|
+
while (i) {
|
558
|
+
paramName.push(name);
|
559
|
+
i -= 1;
|
560
|
+
}
|
561
|
+
});
|
562
|
+
if (!paramName.length) {
|
563
|
+
paramName = [fileInput.prop('name') || 'files[]'];
|
564
|
+
}
|
565
|
+
} else if (!$.isArray(paramName)) {
|
566
|
+
paramName = [paramName];
|
567
|
+
}
|
568
|
+
return paramName;
|
569
|
+
},
|
570
|
+
|
571
|
+
_initFormSettings: function (options) {
|
572
|
+
// Retrieve missing options from the input field and the
|
573
|
+
// associated form, if available:
|
574
|
+
if (!options.form || !options.form.length) {
|
575
|
+
options.form = $(options.fileInput.prop('form'));
|
576
|
+
// If the given file input doesn't have an associated form,
|
577
|
+
// use the default widget file input's form:
|
578
|
+
if (!options.form.length) {
|
579
|
+
options.form = $(this.options.fileInput.prop('form'));
|
580
|
+
}
|
581
|
+
}
|
582
|
+
options.paramName = this._getParamName(options);
|
583
|
+
if (!options.url) {
|
584
|
+
options.url = options.form.prop('action') || location.href;
|
585
|
+
}
|
586
|
+
// The HTTP request method must be "POST" or "PUT":
|
587
|
+
options.type = (options.type ||
|
588
|
+
($.type(options.form.prop('method')) === 'string' &&
|
589
|
+
options.form.prop('method')) || ''
|
590
|
+
).toUpperCase();
|
591
|
+
if (options.type !== 'POST' && options.type !== 'PUT' &&
|
592
|
+
options.type !== 'PATCH') {
|
593
|
+
options.type = 'POST';
|
594
|
+
}
|
595
|
+
if (!options.formAcceptCharset) {
|
596
|
+
options.formAcceptCharset = options.form.attr('accept-charset');
|
597
|
+
}
|
598
|
+
},
|
599
|
+
|
600
|
+
_getAJAXSettings: function (data) {
|
601
|
+
var options = $.extend({}, this.options, data);
|
602
|
+
this._initFormSettings(options);
|
603
|
+
this._initDataSettings(options);
|
604
|
+
return options;
|
605
|
+
},
|
606
|
+
|
607
|
+
// jQuery 1.6 doesn't provide .state(),
|
608
|
+
// while jQuery 1.8+ removed .isRejected() and .isResolved():
|
609
|
+
_getDeferredState: function (deferred) {
|
610
|
+
if (deferred.state) {
|
611
|
+
return deferred.state();
|
612
|
+
}
|
613
|
+
if (deferred.isResolved()) {
|
614
|
+
return 'resolved';
|
615
|
+
}
|
616
|
+
if (deferred.isRejected()) {
|
617
|
+
return 'rejected';
|
618
|
+
}
|
619
|
+
return 'pending';
|
620
|
+
},
|
621
|
+
|
622
|
+
// Maps jqXHR callbacks to the equivalent
|
623
|
+
// methods of the given Promise object:
|
624
|
+
_enhancePromise: function (promise) {
|
625
|
+
promise.success = promise.done;
|
626
|
+
promise.error = promise.fail;
|
627
|
+
promise.complete = promise.always;
|
628
|
+
return promise;
|
629
|
+
},
|
630
|
+
|
631
|
+
// Creates and returns a Promise object enhanced with
|
632
|
+
// the jqXHR methods abort, success, error and complete:
|
633
|
+
_getXHRPromise: function (resolveOrReject, context, args) {
|
634
|
+
var dfd = $.Deferred(),
|
635
|
+
promise = dfd.promise();
|
636
|
+
context = context || this.options.context || promise;
|
637
|
+
if (resolveOrReject === true) {
|
638
|
+
dfd.resolveWith(context, args);
|
639
|
+
} else if (resolveOrReject === false) {
|
640
|
+
dfd.rejectWith(context, args);
|
641
|
+
}
|
642
|
+
promise.abort = dfd.promise;
|
643
|
+
return this._enhancePromise(promise);
|
644
|
+
},
|
645
|
+
|
646
|
+
// Adds convenience methods to the data callback argument:
|
647
|
+
_addConvenienceMethods: function (e, data) {
|
648
|
+
var that = this,
|
649
|
+
getPromise = function (args) {
|
650
|
+
return $.Deferred().resolveWith(that, args).promise();
|
651
|
+
};
|
652
|
+
data.process = function (resolveFunc, rejectFunc) {
|
653
|
+
if (resolveFunc || rejectFunc) {
|
654
|
+
data._processQueue = this._processQueue =
|
655
|
+
(this._processQueue || getPromise([this])).pipe(
|
656
|
+
function () {
|
657
|
+
if (data.errorThrown) {
|
658
|
+
return $.Deferred()
|
659
|
+
.rejectWith(that, [data]).promise();
|
660
|
+
}
|
661
|
+
return getPromise(arguments);
|
662
|
+
}
|
663
|
+
).pipe(resolveFunc, rejectFunc);
|
664
|
+
}
|
665
|
+
return this._processQueue || getPromise([this]);
|
666
|
+
};
|
667
|
+
data.submit = function () {
|
668
|
+
if (this.state() !== 'pending') {
|
669
|
+
data.jqXHR = this.jqXHR =
|
670
|
+
(that._trigger(
|
671
|
+
'submit',
|
672
|
+
$.Event('submit', {delegatedEvent: e}),
|
673
|
+
this
|
674
|
+
) !== false) && that._onSend(e, this);
|
675
|
+
}
|
676
|
+
return this.jqXHR || that._getXHRPromise();
|
677
|
+
};
|
678
|
+
data.abort = function () {
|
679
|
+
if (this.jqXHR) {
|
680
|
+
return this.jqXHR.abort();
|
681
|
+
}
|
682
|
+
this.errorThrown = 'abort';
|
683
|
+
that._trigger('fail', null, this);
|
684
|
+
return that._getXHRPromise(false);
|
685
|
+
};
|
686
|
+
data.state = function () {
|
687
|
+
if (this.jqXHR) {
|
688
|
+
return that._getDeferredState(this.jqXHR);
|
689
|
+
}
|
690
|
+
if (this._processQueue) {
|
691
|
+
return that._getDeferredState(this._processQueue);
|
692
|
+
}
|
693
|
+
};
|
694
|
+
data.processing = function () {
|
695
|
+
return !this.jqXHR && this._processQueue && that
|
696
|
+
._getDeferredState(this._processQueue) === 'pending';
|
697
|
+
};
|
698
|
+
data.progress = function () {
|
699
|
+
return this._progress;
|
700
|
+
};
|
701
|
+
data.response = function () {
|
702
|
+
return this._response;
|
703
|
+
};
|
704
|
+
},
|
705
|
+
|
706
|
+
// Parses the Range header from the server response
|
707
|
+
// and returns the uploaded bytes:
|
708
|
+
_getUploadedBytes: function (jqXHR) {
|
709
|
+
var range = jqXHR.getResponseHeader('Range'),
|
710
|
+
parts = range && range.split('-'),
|
711
|
+
upperBytesPos = parts && parts.length > 1 &&
|
712
|
+
parseInt(parts[1], 10);
|
713
|
+
return upperBytesPos && upperBytesPos + 1;
|
714
|
+
},
|
715
|
+
|
716
|
+
// Uploads a file in multiple, sequential requests
|
717
|
+
// by splitting the file up in multiple blob chunks.
|
718
|
+
// If the second parameter is true, only tests if the file
|
719
|
+
// should be uploaded in chunks, but does not invoke any
|
720
|
+
// upload requests:
|
721
|
+
_chunkedUpload: function (options, testOnly) {
|
722
|
+
options.uploadedBytes = options.uploadedBytes || 0;
|
723
|
+
var that = this,
|
724
|
+
file = options.files[0],
|
725
|
+
fs = file.size,
|
726
|
+
ub = options.uploadedBytes,
|
727
|
+
mcs = options.maxChunkSize || fs,
|
728
|
+
slice = this._blobSlice,
|
729
|
+
dfd = $.Deferred(),
|
730
|
+
promise = dfd.promise(),
|
731
|
+
jqXHR,
|
732
|
+
upload;
|
733
|
+
if (!(this._isXHRUpload(options) && slice && (ub || mcs < fs)) ||
|
734
|
+
options.data) {
|
735
|
+
return false;
|
736
|
+
}
|
737
|
+
if (testOnly) {
|
738
|
+
return true;
|
739
|
+
}
|
740
|
+
if (ub >= fs) {
|
741
|
+
file.error = options.i18n('uploadedBytes');
|
742
|
+
return this._getXHRPromise(
|
743
|
+
false,
|
744
|
+
options.context,
|
745
|
+
[null, 'error', file.error]
|
746
|
+
);
|
747
|
+
}
|
748
|
+
// The chunk upload method:
|
749
|
+
upload = function () {
|
750
|
+
// Clone the options object for each chunk upload:
|
751
|
+
var o = $.extend({}, options),
|
752
|
+
currentLoaded = o._progress.loaded;
|
753
|
+
o.blob = slice.call(
|
754
|
+
file,
|
755
|
+
ub,
|
756
|
+
ub + mcs,
|
757
|
+
file.type
|
758
|
+
);
|
759
|
+
// Store the current chunk size, as the blob itself
|
760
|
+
// will be dereferenced after data processing:
|
761
|
+
o.chunkSize = o.blob.size;
|
762
|
+
// Expose the chunk bytes position range:
|
763
|
+
o.contentRange = 'bytes ' + ub + '-' +
|
764
|
+
(ub + o.chunkSize - 1) + '/' + fs;
|
765
|
+
// Process the upload data (the blob and potential form data):
|
766
|
+
that._initXHRData(o);
|
767
|
+
// Add progress listeners for this chunk upload:
|
768
|
+
that._initProgressListener(o);
|
769
|
+
jqXHR = ((that._trigger('chunksend', null, o) !== false && $.ajax(o)) ||
|
770
|
+
that._getXHRPromise(false, o.context))
|
771
|
+
.done(function (result, textStatus, jqXHR) {
|
772
|
+
ub = that._getUploadedBytes(jqXHR) ||
|
773
|
+
(ub + o.chunkSize);
|
774
|
+
// Create a progress event if no final progress event
|
775
|
+
// with loaded equaling total has been triggered
|
776
|
+
// for this chunk:
|
777
|
+
if (currentLoaded + o.chunkSize - o._progress.loaded) {
|
778
|
+
that._onProgress($.Event('progress', {
|
779
|
+
lengthComputable: true,
|
780
|
+
loaded: ub - o.uploadedBytes,
|
781
|
+
total: ub - o.uploadedBytes
|
782
|
+
}), o);
|
783
|
+
}
|
784
|
+
options.uploadedBytes = o.uploadedBytes = ub;
|
785
|
+
o.result = result;
|
786
|
+
o.textStatus = textStatus;
|
787
|
+
o.jqXHR = jqXHR;
|
788
|
+
that._trigger('chunkdone', null, o);
|
789
|
+
that._trigger('chunkalways', null, o);
|
790
|
+
if (ub < fs) {
|
791
|
+
// File upload not yet complete,
|
792
|
+
// continue with the next chunk:
|
793
|
+
upload();
|
794
|
+
} else {
|
795
|
+
dfd.resolveWith(
|
796
|
+
o.context,
|
797
|
+
[result, textStatus, jqXHR]
|
798
|
+
);
|
799
|
+
}
|
800
|
+
})
|
801
|
+
.fail(function (jqXHR, textStatus, errorThrown) {
|
802
|
+
o.jqXHR = jqXHR;
|
803
|
+
o.textStatus = textStatus;
|
804
|
+
o.errorThrown = errorThrown;
|
805
|
+
that._trigger('chunkfail', null, o);
|
806
|
+
that._trigger('chunkalways', null, o);
|
807
|
+
dfd.rejectWith(
|
808
|
+
o.context,
|
809
|
+
[jqXHR, textStatus, errorThrown]
|
810
|
+
);
|
811
|
+
});
|
812
|
+
};
|
813
|
+
this._enhancePromise(promise);
|
814
|
+
promise.abort = function () {
|
815
|
+
return jqXHR.abort();
|
816
|
+
};
|
817
|
+
upload();
|
818
|
+
return promise;
|
819
|
+
},
|
820
|
+
|
821
|
+
_beforeSend: function (e, data) {
|
822
|
+
if (this._active === 0) {
|
823
|
+
// the start callback is triggered when an upload starts
|
824
|
+
// and no other uploads are currently running,
|
825
|
+
// equivalent to the global ajaxStart event:
|
826
|
+
this._trigger('start');
|
827
|
+
// Set timer for global bitrate progress calculation:
|
828
|
+
this._bitrateTimer = new this._BitrateTimer();
|
829
|
+
// Reset the global progress values:
|
830
|
+
this._progress.loaded = this._progress.total = 0;
|
831
|
+
this._progress.bitrate = 0;
|
832
|
+
}
|
833
|
+
// Make sure the container objects for the .response() and
|
834
|
+
// .progress() methods on the data object are available
|
835
|
+
// and reset to their initial state:
|
836
|
+
this._initResponseObject(data);
|
837
|
+
this._initProgressObject(data);
|
838
|
+
data._progress.loaded = data.loaded = data.uploadedBytes || 0;
|
839
|
+
data._progress.total = data.total = this._getTotal(data.files) || 1;
|
840
|
+
data._progress.bitrate = data.bitrate = 0;
|
841
|
+
this._active += 1;
|
842
|
+
// Initialize the global progress values:
|
843
|
+
this._progress.loaded += data.loaded;
|
844
|
+
this._progress.total += data.total;
|
845
|
+
},
|
846
|
+
|
847
|
+
_onDone: function (result, textStatus, jqXHR, options) {
|
848
|
+
var total = options._progress.total,
|
849
|
+
response = options._response;
|
850
|
+
if (options._progress.loaded < total) {
|
851
|
+
// Create a progress event if no final progress event
|
852
|
+
// with loaded equaling total has been triggered:
|
853
|
+
this._onProgress($.Event('progress', {
|
854
|
+
lengthComputable: true,
|
855
|
+
loaded: total,
|
856
|
+
total: total
|
857
|
+
}), options);
|
858
|
+
}
|
859
|
+
response.result = options.result = result;
|
860
|
+
response.textStatus = options.textStatus = textStatus;
|
861
|
+
response.jqXHR = options.jqXHR = jqXHR;
|
862
|
+
this._trigger('done', null, options);
|
863
|
+
},
|
864
|
+
|
865
|
+
_onFail: function (jqXHR, textStatus, errorThrown, options) {
|
866
|
+
var response = options._response;
|
867
|
+
if (options.recalculateProgress) {
|
868
|
+
// Remove the failed (error or abort) file upload from
|
869
|
+
// the global progress calculation:
|
870
|
+
this._progress.loaded -= options._progress.loaded;
|
871
|
+
this._progress.total -= options._progress.total;
|
872
|
+
}
|
873
|
+
response.jqXHR = options.jqXHR = jqXHR;
|
874
|
+
response.textStatus = options.textStatus = textStatus;
|
875
|
+
response.errorThrown = options.errorThrown = errorThrown;
|
876
|
+
this._trigger('fail', null, options);
|
877
|
+
},
|
878
|
+
|
879
|
+
_onAlways: function (jqXHRorResult, textStatus, jqXHRorError, options) {
|
880
|
+
// jqXHRorResult, textStatus and jqXHRorError are added to the
|
881
|
+
// options object via done and fail callbacks
|
882
|
+
this._trigger('always', null, options);
|
883
|
+
},
|
884
|
+
|
885
|
+
_onSend: function (e, data) {
|
886
|
+
if (!data.submit) {
|
887
|
+
this._addConvenienceMethods(e, data);
|
888
|
+
}
|
889
|
+
var that = this,
|
890
|
+
jqXHR,
|
891
|
+
aborted,
|
892
|
+
slot,
|
893
|
+
pipe,
|
894
|
+
options = that._getAJAXSettings(data),
|
895
|
+
send = function () {
|
896
|
+
that._sending += 1;
|
897
|
+
// Set timer for bitrate progress calculation:
|
898
|
+
options._bitrateTimer = new that._BitrateTimer();
|
899
|
+
jqXHR = jqXHR || (
|
900
|
+
((aborted || that._trigger(
|
901
|
+
'send',
|
902
|
+
$.Event('send', {delegatedEvent: e}),
|
903
|
+
options
|
904
|
+
) === false) &&
|
905
|
+
that._getXHRPromise(false, options.context, aborted)) ||
|
906
|
+
that._chunkedUpload(options) || $.ajax(options)
|
907
|
+
).done(function (result, textStatus, jqXHR) {
|
908
|
+
that._onDone(result, textStatus, jqXHR, options);
|
909
|
+
}).fail(function (jqXHR, textStatus, errorThrown) {
|
910
|
+
that._onFail(jqXHR, textStatus, errorThrown, options);
|
911
|
+
}).always(function (jqXHRorResult, textStatus, jqXHRorError) {
|
912
|
+
that._onAlways(
|
913
|
+
jqXHRorResult,
|
914
|
+
textStatus,
|
915
|
+
jqXHRorError,
|
916
|
+
options
|
917
|
+
);
|
918
|
+
that._sending -= 1;
|
919
|
+
that._active -= 1;
|
920
|
+
if (options.limitConcurrentUploads &&
|
921
|
+
options.limitConcurrentUploads > that._sending) {
|
922
|
+
// Start the next queued upload,
|
923
|
+
// that has not been aborted:
|
924
|
+
var nextSlot = that._slots.shift();
|
925
|
+
while (nextSlot) {
|
926
|
+
if (that._getDeferredState(nextSlot) === 'pending') {
|
927
|
+
nextSlot.resolve();
|
928
|
+
break;
|
929
|
+
}
|
930
|
+
nextSlot = that._slots.shift();
|
931
|
+
}
|
932
|
+
}
|
933
|
+
if (that._active === 0) {
|
934
|
+
// The stop callback is triggered when all uploads have
|
935
|
+
// been completed, equivalent to the global ajaxStop event:
|
936
|
+
that._trigger('stop');
|
937
|
+
}
|
938
|
+
});
|
939
|
+
return jqXHR;
|
940
|
+
};
|
941
|
+
this._beforeSend(e, options);
|
942
|
+
if (this.options.sequentialUploads ||
|
943
|
+
(this.options.limitConcurrentUploads &&
|
944
|
+
this.options.limitConcurrentUploads <= this._sending)) {
|
945
|
+
if (this.options.limitConcurrentUploads > 1) {
|
946
|
+
slot = $.Deferred();
|
947
|
+
this._slots.push(slot);
|
948
|
+
pipe = slot.pipe(send);
|
949
|
+
} else {
|
950
|
+
this._sequence = this._sequence.pipe(send, send);
|
951
|
+
pipe = this._sequence;
|
952
|
+
}
|
953
|
+
// Return the piped Promise object, enhanced with an abort method,
|
954
|
+
// which is delegated to the jqXHR object of the current upload,
|
955
|
+
// and jqXHR callbacks mapped to the equivalent Promise methods:
|
956
|
+
pipe.abort = function () {
|
957
|
+
aborted = [undefined, 'abort', 'abort'];
|
958
|
+
if (!jqXHR) {
|
959
|
+
if (slot) {
|
960
|
+
slot.rejectWith(options.context, aborted);
|
961
|
+
}
|
962
|
+
return send();
|
963
|
+
}
|
964
|
+
return jqXHR.abort();
|
965
|
+
};
|
966
|
+
return this._enhancePromise(pipe);
|
967
|
+
}
|
968
|
+
return send();
|
969
|
+
},
|
970
|
+
|
971
|
+
_onAdd: function (e, data) {
|
972
|
+
var that = this,
|
973
|
+
result = true,
|
974
|
+
options = $.extend({}, this.options, data),
|
975
|
+
files = data.files,
|
976
|
+
filesLength = files.length,
|
977
|
+
limit = options.limitMultiFileUploads,
|
978
|
+
limitSize = options.limitMultiFileUploadSize,
|
979
|
+
overhead = options.limitMultiFileUploadSizeOverhead,
|
980
|
+
batchSize = 0,
|
981
|
+
paramName = this._getParamName(options),
|
982
|
+
paramNameSet,
|
983
|
+
paramNameSlice,
|
984
|
+
fileSet,
|
985
|
+
i,
|
986
|
+
j = 0;
|
987
|
+
if (!filesLength) {
|
988
|
+
return false;
|
989
|
+
}
|
990
|
+
if (limitSize && files[0].size === undefined) {
|
991
|
+
limitSize = undefined;
|
992
|
+
}
|
993
|
+
if (!(options.singleFileUploads || limit || limitSize) ||
|
994
|
+
!this._isXHRUpload(options)) {
|
995
|
+
fileSet = [files];
|
996
|
+
paramNameSet = [paramName];
|
997
|
+
} else if (!(options.singleFileUploads || limitSize) && limit) {
|
998
|
+
fileSet = [];
|
999
|
+
paramNameSet = [];
|
1000
|
+
for (i = 0; i < filesLength; i += limit) {
|
1001
|
+
fileSet.push(files.slice(i, i + limit));
|
1002
|
+
paramNameSlice = paramName.slice(i, i + limit);
|
1003
|
+
if (!paramNameSlice.length) {
|
1004
|
+
paramNameSlice = paramName;
|
1005
|
+
}
|
1006
|
+
paramNameSet.push(paramNameSlice);
|
1007
|
+
}
|
1008
|
+
} else if (!options.singleFileUploads && limitSize) {
|
1009
|
+
fileSet = [];
|
1010
|
+
paramNameSet = [];
|
1011
|
+
for (i = 0; i < filesLength; i = i + 1) {
|
1012
|
+
batchSize += files[i].size + overhead;
|
1013
|
+
if (i + 1 === filesLength ||
|
1014
|
+
((batchSize + files[i + 1].size + overhead) > limitSize) ||
|
1015
|
+
(limit && i + 1 - j >= limit)) {
|
1016
|
+
fileSet.push(files.slice(j, i + 1));
|
1017
|
+
paramNameSlice = paramName.slice(j, i + 1);
|
1018
|
+
if (!paramNameSlice.length) {
|
1019
|
+
paramNameSlice = paramName;
|
1020
|
+
}
|
1021
|
+
paramNameSet.push(paramNameSlice);
|
1022
|
+
j = i + 1;
|
1023
|
+
batchSize = 0;
|
1024
|
+
}
|
1025
|
+
}
|
1026
|
+
} else {
|
1027
|
+
paramNameSet = paramName;
|
1028
|
+
}
|
1029
|
+
data.originalFiles = files;
|
1030
|
+
$.each(fileSet || files, function (index, element) {
|
1031
|
+
var newData = $.extend({}, data);
|
1032
|
+
newData.files = fileSet ? element : [element];
|
1033
|
+
newData.paramName = paramNameSet[index];
|
1034
|
+
that._initResponseObject(newData);
|
1035
|
+
that._initProgressObject(newData);
|
1036
|
+
that._addConvenienceMethods(e, newData);
|
1037
|
+
result = that._trigger(
|
1038
|
+
'add',
|
1039
|
+
$.Event('add', {delegatedEvent: e}),
|
1040
|
+
newData
|
1041
|
+
);
|
1042
|
+
return result;
|
1043
|
+
});
|
1044
|
+
return result;
|
1045
|
+
},
|
1046
|
+
|
1047
|
+
_replaceFileInput: function (data) {
|
1048
|
+
var input = data.fileInput,
|
1049
|
+
inputClone = input.clone(true),
|
1050
|
+
restoreFocus = input.is(document.activeElement);
|
1051
|
+
// Add a reference for the new cloned file input to the data argument:
|
1052
|
+
data.fileInputClone = inputClone;
|
1053
|
+
$('<form></form>').append(inputClone)[0].reset();
|
1054
|
+
// Detaching allows to insert the fileInput on another form
|
1055
|
+
// without loosing the file input value:
|
1056
|
+
input.after(inputClone).detach();
|
1057
|
+
// If the fileInput had focus before it was detached,
|
1058
|
+
// restore focus to the inputClone.
|
1059
|
+
if (restoreFocus) {
|
1060
|
+
inputClone.focus();
|
1061
|
+
}
|
1062
|
+
// Avoid memory leaks with the detached file input:
|
1063
|
+
$.cleanData(input.unbind('remove'));
|
1064
|
+
// Replace the original file input element in the fileInput
|
1065
|
+
// elements set with the clone, which has been copied including
|
1066
|
+
// event handlers:
|
1067
|
+
this.options.fileInput = this.options.fileInput.map(function (i, el) {
|
1068
|
+
if (el === input[0]) {
|
1069
|
+
return inputClone[0];
|
1070
|
+
}
|
1071
|
+
return el;
|
1072
|
+
});
|
1073
|
+
// If the widget has been initialized on the file input itself,
|
1074
|
+
// override this.element with the file input clone:
|
1075
|
+
if (input[0] === this.element[0]) {
|
1076
|
+
this.element = inputClone;
|
1077
|
+
}
|
1078
|
+
},
|
1079
|
+
|
1080
|
+
_handleFileTreeEntry: function (entry, path) {
|
1081
|
+
var that = this,
|
1082
|
+
dfd = $.Deferred(),
|
1083
|
+
errorHandler = function (e) {
|
1084
|
+
if (e && !e.entry) {
|
1085
|
+
e.entry = entry;
|
1086
|
+
}
|
1087
|
+
// Since $.when returns immediately if one
|
1088
|
+
// Deferred is rejected, we use resolve instead.
|
1089
|
+
// This allows valid files and invalid items
|
1090
|
+
// to be returned together in one set:
|
1091
|
+
dfd.resolve([e]);
|
1092
|
+
},
|
1093
|
+
successHandler = function (entries) {
|
1094
|
+
that._handleFileTreeEntries(
|
1095
|
+
entries,
|
1096
|
+
path + entry.name + '/'
|
1097
|
+
).done(function (files) {
|
1098
|
+
dfd.resolve(files);
|
1099
|
+
}).fail(errorHandler);
|
1100
|
+
},
|
1101
|
+
readEntries = function () {
|
1102
|
+
dirReader.readEntries(function (results) {
|
1103
|
+
if (!results.length) {
|
1104
|
+
successHandler(entries);
|
1105
|
+
} else {
|
1106
|
+
entries = entries.concat(results);
|
1107
|
+
readEntries();
|
1108
|
+
}
|
1109
|
+
}, errorHandler);
|
1110
|
+
},
|
1111
|
+
dirReader, entries = [];
|
1112
|
+
path = path || '';
|
1113
|
+
if (entry.isFile) {
|
1114
|
+
if (entry._file) {
|
1115
|
+
// Workaround for Chrome bug #149735
|
1116
|
+
entry._file.relativePath = path;
|
1117
|
+
dfd.resolve(entry._file);
|
1118
|
+
} else {
|
1119
|
+
entry.file(function (file) {
|
1120
|
+
file.relativePath = path;
|
1121
|
+
dfd.resolve(file);
|
1122
|
+
}, errorHandler);
|
1123
|
+
}
|
1124
|
+
} else if (entry.isDirectory) {
|
1125
|
+
dirReader = entry.createReader();
|
1126
|
+
readEntries();
|
1127
|
+
} else {
|
1128
|
+
// Return an empy list for file system items
|
1129
|
+
// other than files or directories:
|
1130
|
+
dfd.resolve([]);
|
1131
|
+
}
|
1132
|
+
return dfd.promise();
|
1133
|
+
},
|
1134
|
+
|
1135
|
+
_handleFileTreeEntries: function (entries, path) {
|
1136
|
+
var that = this;
|
1137
|
+
return $.when.apply(
|
1138
|
+
$,
|
1139
|
+
$.map(entries, function (entry) {
|
1140
|
+
return that._handleFileTreeEntry(entry, path);
|
1141
|
+
})
|
1142
|
+
).pipe(function () {
|
1143
|
+
return Array.prototype.concat.apply(
|
1144
|
+
[],
|
1145
|
+
arguments
|
1146
|
+
);
|
1147
|
+
});
|
1148
|
+
},
|
1149
|
+
|
1150
|
+
_getDroppedFiles: function (dataTransfer) {
|
1151
|
+
dataTransfer = dataTransfer || {};
|
1152
|
+
var items = dataTransfer.items;
|
1153
|
+
if (items && items.length && (items[0].webkitGetAsEntry ||
|
1154
|
+
items[0].getAsEntry)) {
|
1155
|
+
return this._handleFileTreeEntries(
|
1156
|
+
$.map(items, function (item) {
|
1157
|
+
var entry;
|
1158
|
+
if (item.webkitGetAsEntry) {
|
1159
|
+
entry = item.webkitGetAsEntry();
|
1160
|
+
if (entry) {
|
1161
|
+
// Workaround for Chrome bug #149735:
|
1162
|
+
entry._file = item.getAsFile();
|
1163
|
+
}
|
1164
|
+
return entry;
|
1165
|
+
}
|
1166
|
+
return item.getAsEntry();
|
1167
|
+
})
|
1168
|
+
);
|
1169
|
+
}
|
1170
|
+
return $.Deferred().resolve(
|
1171
|
+
$.makeArray(dataTransfer.files)
|
1172
|
+
).promise();
|
1173
|
+
},
|
1174
|
+
|
1175
|
+
_getSingleFileInputFiles: function (fileInput) {
|
1176
|
+
fileInput = $(fileInput);
|
1177
|
+
var entries = fileInput.prop('webkitEntries') ||
|
1178
|
+
fileInput.prop('entries'),
|
1179
|
+
files,
|
1180
|
+
value;
|
1181
|
+
if (entries && entries.length) {
|
1182
|
+
return this._handleFileTreeEntries(entries);
|
1183
|
+
}
|
1184
|
+
files = $.makeArray(fileInput.prop('files'));
|
1185
|
+
if (!files.length) {
|
1186
|
+
value = fileInput.prop('value');
|
1187
|
+
if (!value) {
|
1188
|
+
return $.Deferred().resolve([]).promise();
|
1189
|
+
}
|
1190
|
+
// If the files property is not available, the browser does not
|
1191
|
+
// support the File API and we add a pseudo File object with
|
1192
|
+
// the input value as name with path information removed:
|
1193
|
+
files = [{name: value.replace(/^.*\\/, '')}];
|
1194
|
+
} else if (files[0].name === undefined && files[0].fileName) {
|
1195
|
+
// File normalization for Safari 4 and Firefox 3:
|
1196
|
+
$.each(files, function (index, file) {
|
1197
|
+
file.name = file.fileName;
|
1198
|
+
file.size = file.fileSize;
|
1199
|
+
});
|
1200
|
+
}
|
1201
|
+
return $.Deferred().resolve(files).promise();
|
1202
|
+
},
|
1203
|
+
|
1204
|
+
_getFileInputFiles: function (fileInput) {
|
1205
|
+
if (!(fileInput instanceof $) || fileInput.length === 1) {
|
1206
|
+
return this._getSingleFileInputFiles(fileInput);
|
1207
|
+
}
|
1208
|
+
return $.when.apply(
|
1209
|
+
$,
|
1210
|
+
$.map(fileInput, this._getSingleFileInputFiles)
|
1211
|
+
).pipe(function () {
|
1212
|
+
return Array.prototype.concat.apply(
|
1213
|
+
[],
|
1214
|
+
arguments
|
1215
|
+
);
|
1216
|
+
});
|
1217
|
+
},
|
1218
|
+
|
1219
|
+
_onChange: function (e) {
|
1220
|
+
var that = this,
|
1221
|
+
data = {
|
1222
|
+
fileInput: $(e.target),
|
1223
|
+
form: $(e.target.form)
|
1224
|
+
};
|
1225
|
+
this._getFileInputFiles(data.fileInput).always(function (files) {
|
1226
|
+
data.files = files;
|
1227
|
+
if (that.options.replaceFileInput) {
|
1228
|
+
that._replaceFileInput(data);
|
1229
|
+
}
|
1230
|
+
if (that._trigger(
|
1231
|
+
'change',
|
1232
|
+
$.Event('change', {delegatedEvent: e}),
|
1233
|
+
data
|
1234
|
+
) !== false) {
|
1235
|
+
that._onAdd(e, data);
|
1236
|
+
}
|
1237
|
+
});
|
1238
|
+
},
|
1239
|
+
|
1240
|
+
_onPaste: function (e) {
|
1241
|
+
var items = e.originalEvent && e.originalEvent.clipboardData &&
|
1242
|
+
e.originalEvent.clipboardData.items,
|
1243
|
+
data = {files: []};
|
1244
|
+
if (items && items.length) {
|
1245
|
+
$.each(items, function (index, item) {
|
1246
|
+
var file = item.getAsFile && item.getAsFile();
|
1247
|
+
if (file) {
|
1248
|
+
data.files.push(file);
|
1249
|
+
}
|
1250
|
+
});
|
1251
|
+
if (this._trigger(
|
1252
|
+
'paste',
|
1253
|
+
$.Event('paste', {delegatedEvent: e}),
|
1254
|
+
data
|
1255
|
+
) !== false) {
|
1256
|
+
this._onAdd(e, data);
|
1257
|
+
}
|
1258
|
+
}
|
1259
|
+
},
|
1260
|
+
|
1261
|
+
_onDrop: function (e) {
|
1262
|
+
e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer;
|
1263
|
+
var that = this,
|
1264
|
+
dataTransfer = e.dataTransfer,
|
1265
|
+
data = {};
|
1266
|
+
if (dataTransfer && dataTransfer.files && dataTransfer.files.length) {
|
1267
|
+
e.preventDefault();
|
1268
|
+
this._getDroppedFiles(dataTransfer).always(function (files) {
|
1269
|
+
data.files = files;
|
1270
|
+
if (that._trigger(
|
1271
|
+
'drop',
|
1272
|
+
$.Event('drop', {delegatedEvent: e}),
|
1273
|
+
data
|
1274
|
+
) !== false) {
|
1275
|
+
that._onAdd(e, data);
|
1276
|
+
}
|
1277
|
+
});
|
1278
|
+
}
|
1279
|
+
},
|
1280
|
+
|
1281
|
+
_onDragOver: getDragHandler('dragover'),
|
1282
|
+
|
1283
|
+
_onDragEnter: getDragHandler('dragenter'),
|
1284
|
+
|
1285
|
+
_onDragLeave: getDragHandler('dragleave'),
|
1286
|
+
|
1287
|
+
_initEventHandlers: function () {
|
1288
|
+
if (this._isXHRUpload(this.options)) {
|
1289
|
+
this._on(this.options.dropZone, {
|
1290
|
+
dragover: this._onDragOver,
|
1291
|
+
drop: this._onDrop,
|
1292
|
+
// event.preventDefault() on dragenter is required for IE10+:
|
1293
|
+
dragenter: this._onDragEnter,
|
1294
|
+
// dragleave is not required, but added for completeness:
|
1295
|
+
dragleave: this._onDragLeave
|
1296
|
+
});
|
1297
|
+
this._on(this.options.pasteZone, {
|
1298
|
+
paste: this._onPaste
|
1299
|
+
});
|
1300
|
+
}
|
1301
|
+
if ($.support.fileInput) {
|
1302
|
+
this._on(this.options.fileInput, {
|
1303
|
+
change: this._onChange
|
1304
|
+
});
|
1305
|
+
}
|
1306
|
+
},
|
1307
|
+
|
1308
|
+
_destroyEventHandlers: function () {
|
1309
|
+
this._off(this.options.dropZone, 'dragenter dragleave dragover drop');
|
1310
|
+
this._off(this.options.pasteZone, 'paste');
|
1311
|
+
this._off(this.options.fileInput, 'change');
|
1312
|
+
},
|
1313
|
+
|
1314
|
+
_setOption: function (key, value) {
|
1315
|
+
var reinit = $.inArray(key, this._specialOptions) !== -1;
|
1316
|
+
if (reinit) {
|
1317
|
+
this._destroyEventHandlers();
|
1318
|
+
}
|
1319
|
+
this._super(key, value);
|
1320
|
+
if (reinit) {
|
1321
|
+
this._initSpecialOptions();
|
1322
|
+
this._initEventHandlers();
|
1323
|
+
}
|
1324
|
+
},
|
1325
|
+
|
1326
|
+
_initSpecialOptions: function () {
|
1327
|
+
var options = this.options;
|
1328
|
+
if (options.fileInput === undefined) {
|
1329
|
+
options.fileInput = this.element.is('input[type="file"]') ?
|
1330
|
+
this.element : this.element.find('input[type="file"]');
|
1331
|
+
} else if (!(options.fileInput instanceof $)) {
|
1332
|
+
options.fileInput = $(options.fileInput);
|
1333
|
+
}
|
1334
|
+
if (!(options.dropZone instanceof $)) {
|
1335
|
+
options.dropZone = $(options.dropZone);
|
1336
|
+
}
|
1337
|
+
if (!(options.pasteZone instanceof $)) {
|
1338
|
+
options.pasteZone = $(options.pasteZone);
|
1339
|
+
}
|
1340
|
+
},
|
1341
|
+
|
1342
|
+
_getRegExp: function (str) {
|
1343
|
+
var parts = str.split('/'),
|
1344
|
+
modifiers = parts.pop();
|
1345
|
+
parts.shift();
|
1346
|
+
return new RegExp(parts.join('/'), modifiers);
|
1347
|
+
},
|
1348
|
+
|
1349
|
+
_isRegExpOption: function (key, value) {
|
1350
|
+
return key !== 'url' && $.type(value) === 'string' &&
|
1351
|
+
/^\/.*\/[igm]{0,3}$/.test(value);
|
1352
|
+
},
|
1353
|
+
|
1354
|
+
_initDataAttributes: function () {
|
1355
|
+
var that = this,
|
1356
|
+
options = this.options,
|
1357
|
+
data = this.element.data();
|
1358
|
+
// Initialize options set via HTML5 data-attributes:
|
1359
|
+
$.each(
|
1360
|
+
this.element[0].attributes,
|
1361
|
+
function (index, attr) {
|
1362
|
+
var key = attr.name.toLowerCase(),
|
1363
|
+
value;
|
1364
|
+
if (/^data-/.test(key)) {
|
1365
|
+
// Convert hyphen-ated key to camelCase:
|
1366
|
+
key = key.slice(5).replace(/-[a-z]/g, function (str) {
|
1367
|
+
return str.charAt(1).toUpperCase();
|
1368
|
+
});
|
1369
|
+
value = data[key];
|
1370
|
+
if (that._isRegExpOption(key, value)) {
|
1371
|
+
value = that._getRegExp(value);
|
1372
|
+
}
|
1373
|
+
options[key] = value;
|
1374
|
+
}
|
1375
|
+
}
|
1376
|
+
);
|
1377
|
+
},
|
1378
|
+
|
1379
|
+
_create: function () {
|
1380
|
+
this._initDataAttributes();
|
1381
|
+
this._initSpecialOptions();
|
1382
|
+
this._slots = [];
|
1383
|
+
this._sequence = this._getXHRPromise(true);
|
1384
|
+
this._sending = this._active = 0;
|
1385
|
+
this._initProgressObject(this);
|
1386
|
+
this._initEventHandlers();
|
1387
|
+
},
|
1388
|
+
|
1389
|
+
// This method is exposed to the widget API and allows to query
|
1390
|
+
// the number of active uploads:
|
1391
|
+
active: function () {
|
1392
|
+
return this._active;
|
1393
|
+
},
|
1394
|
+
|
1395
|
+
// This method is exposed to the widget API and allows to query
|
1396
|
+
// the widget upload progress.
|
1397
|
+
// It returns an object with loaded, total and bitrate properties
|
1398
|
+
// for the running uploads:
|
1399
|
+
progress: function () {
|
1400
|
+
return this._progress;
|
1401
|
+
},
|
1402
|
+
|
1403
|
+
// This method is exposed to the widget API and allows adding files
|
1404
|
+
// using the fileupload API. The data parameter accepts an object which
|
1405
|
+
// must have a files property and can contain additional options:
|
1406
|
+
// .fileupload('add', {files: filesList});
|
1407
|
+
add: function (data) {
|
1408
|
+
var that = this;
|
1409
|
+
if (!data || this.options.disabled) {
|
1410
|
+
return;
|
1411
|
+
}
|
1412
|
+
if (data.fileInput && !data.files) {
|
1413
|
+
this._getFileInputFiles(data.fileInput).always(function (files) {
|
1414
|
+
data.files = files;
|
1415
|
+
that._onAdd(null, data);
|
1416
|
+
});
|
1417
|
+
} else {
|
1418
|
+
data.files = $.makeArray(data.files);
|
1419
|
+
this._onAdd(null, data);
|
1420
|
+
}
|
1421
|
+
},
|
1422
|
+
|
1423
|
+
// This method is exposed to the widget API and allows sending files
|
1424
|
+
// using the fileupload API. The data parameter accepts an object which
|
1425
|
+
// must have a files or fileInput property and can contain additional options:
|
1426
|
+
// .fileupload('send', {files: filesList});
|
1427
|
+
// The method returns a Promise object for the file upload call.
|
1428
|
+
send: function (data) {
|
1429
|
+
if (data && !this.options.disabled) {
|
1430
|
+
if (data.fileInput && !data.files) {
|
1431
|
+
var that = this,
|
1432
|
+
dfd = $.Deferred(),
|
1433
|
+
promise = dfd.promise(),
|
1434
|
+
jqXHR,
|
1435
|
+
aborted;
|
1436
|
+
promise.abort = function () {
|
1437
|
+
aborted = true;
|
1438
|
+
if (jqXHR) {
|
1439
|
+
return jqXHR.abort();
|
1440
|
+
}
|
1441
|
+
dfd.reject(null, 'abort', 'abort');
|
1442
|
+
return promise;
|
1443
|
+
};
|
1444
|
+
this._getFileInputFiles(data.fileInput).always(
|
1445
|
+
function (files) {
|
1446
|
+
if (aborted) {
|
1447
|
+
return;
|
1448
|
+
}
|
1449
|
+
if (!files.length) {
|
1450
|
+
dfd.reject();
|
1451
|
+
return;
|
1452
|
+
}
|
1453
|
+
data.files = files;
|
1454
|
+
jqXHR = that._onSend(null, data);
|
1455
|
+
jqXHR.then(
|
1456
|
+
function (result, textStatus, jqXHR) {
|
1457
|
+
dfd.resolve(result, textStatus, jqXHR);
|
1458
|
+
},
|
1459
|
+
function (jqXHR, textStatus, errorThrown) {
|
1460
|
+
dfd.reject(jqXHR, textStatus, errorThrown);
|
1461
|
+
}
|
1462
|
+
);
|
1463
|
+
}
|
1464
|
+
);
|
1465
|
+
return this._enhancePromise(promise);
|
1466
|
+
}
|
1467
|
+
data.files = $.makeArray(data.files);
|
1468
|
+
if (data.files.length) {
|
1469
|
+
return this._onSend(null, data);
|
1470
|
+
}
|
1471
|
+
}
|
1472
|
+
return this._getXHRPromise(false, data && data.context);
|
1473
|
+
}
|
1474
|
+
|
1475
|
+
});
|
1476
|
+
|
1477
|
+
}));
|