12 |
- webpackJsonp([1],{1:function(e,t,i){"use strict";i(20),i(10)},10:function(e,t,i){"use strict";i(16),i(15),$(".comment-imgs-box ul").on("click","li .close",function(){$(this).parent().remove()})},15:function(module,exports,__webpack_require__){"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function($,window,document,undefined){function regist(e,t){void 0===window.brickjs&&(window.brickjs={}),brickjs[e]=t}function Upload(e,t){this.cfgs={url:"http://imgsys.self.com.cn/interfaces",params:{},useCanvas:!0,size:0,limit:0,width:640,quality:100,error:"",errorMsg:{overnum:"超出上传数量限制",invalidLarge:"太大了",invalidSmall:"太小了",invalidType:"是不支持的图片类型",forbidden:"图片上传中或者图片上传被禁用"},autoUpload:!1,uploadBtn:"",tpl:"",tplContainer:"",autoHide:!0,onSelect:function(e){},onUploading:function(){},onProgress:function(e,t){},onSuccess:function(e,t){},onFailure:function(e,t){},onDelete:function(e){},onComplete:function(e,t){},onError:null},$.extend(!0,this.cfgs,t),this._init(e)}var BinaryFile=function(e,t,i){var r=e,n=t||0,o=0;this.getRawData=function(){return r},"string"==typeof e?(o=i||r.length,this.getByteAt=function(e){return 255&r.charCodeAt(e+n)},this.getBytesAt=function(e,t){for(var i=[],o=0;o<t;o++)i[o]=255&r.charCodeAt(e+o+n);return i}):"unknown"==typeof e&&(o=i||IEBinary_getLength(r),this.getByteAt=function(e){return IEBinary_getByteAt(r,e+n)},this.getBytesAt=function(e,t){return new VBArray(IEBinary_getBytesAt(r,e+n,t)).toArray()}),this.getLength=function(){return o},this.getSByteAt=function(e){var t=this.getByteAt(e);return t>127?t-256:t},this.getShortAt=function(e,t){var i=t?(this.getByteAt(e)<<8)+this.getByteAt(e+1):(this.getByteAt(e+1)<<8)+this.getByteAt(e);return i<0&&(i+=65536),i},this.getSShortAt=function(e,t){var i=this.getShortAt(e,t);return i>32767?i-65536:i},this.getLongAt=function(e,t){var i=this.getByteAt(e),r=this.getByteAt(e+1),n=this.getByteAt(e+2),o=this.getByteAt(e+3),s=t?(((i<<8)+r<<8)+n<<8)+o:(((o<<8)+n<<8)+r<<8)+i;return s<0&&(s+=4294967296),s},this.getSLongAt=function(e,t){var i=this.getLongAt(e,t);return i>2147483647?i-4294967296:i},this.getStringAt=function(e,t){for(var i=[],r=this.getBytesAt(e,t),n=0;n<t;n++)i[n]=String.fromCharCode(r[n]);return i.join("")},this.getCharAt=function(e){return String.fromCharCode(this.getByteAt(e))},this.toBase64=function(){return window.btoa(r)},this.fromBase64=function(e){r=window.atob(e)}},BinaryAjax=function(){function e(){var e=null;return window.ActiveXObject?e=new ActiveXObject("Microsoft.XMLHTTP"):window.XMLHttpRequest&&(e=new XMLHttpRequest),e}function t(t,i,r){var n=e();n?(i&&(void 0!==n.onload?n.onload=function(){"200"==n.status?i(this):r&&r(),n=null}:n.onreadystatechange=function(){4==n.readyState&&("200"==n.status?i(this):r&&r(),n=null)}),n.open("HEAD",t,!0),n.send(null)):r&&r()}function i(t,i,r,n,o,s){var a=e();if(a){var d=0;n&&!o&&(d=n[0]);var l=0;n&&(l=n[1]-n[0]+1),i&&(void 0!==a.onload?a.onload=function(){"200"==a.status||"206"==a.status||"0"==a.status?(a.binaryResponse=new BinaryFile(a.responseText,d,l),a.fileSize=s||a.getResponseHeader("Content-Length"),i(a)):r&&r(),a=null}:a.onreadystatechange=function(){if(4==a.readyState){if("200"==a.status||"206"==a.status||"0"==a.status){var e={status:a.status,binaryResponse:new BinaryFile("unknown"==typeof a.responseBody?a.responseBody:a.responseText,d,l),fileSize:s||a.getResponseHeader("Content-Length")};i(e)}else r&&r();a=null}}),a.open("GET",t,!0),a.overrideMimeType&&a.overrideMimeType("text/plain; charset=x-user-defined"),n&&o&&a.setRequestHeader("Range","bytes="+n[0]+"-"+n[1]),a.setRequestHeader("If-Modified-Since","Sat, 1 Jan 1970 00:00:00 GMT"),a.send(null)}else r&&r()}return function(e,r,n,o){o?t(e,function(t){var s,a,d=parseInt(t.getResponseHeader("Content-Length"),10),l=t.getResponseHeader("Accept-Ranges");s=o[0],o[0]<0&&(s+=d),a=s+o[1]-1,i(e,r,n,[s,a],"bytes"==l,d)}):i(e,r,n)}}();!function(e){function t(e,t){this.file=e,this.options=r.extend({},n,t),this._defaults=n,this._name=i,this.init()}var i="canvasResize",r={newsize:function(e,t,i,r,n){var o=n?"h":"";if(i&&e>i||r&&t>r){var s=e/t;(s>=1||0===r)&&i&&!n?(e=i,t=i/s>>0):n&&s<=i/r?(e=i,t=i/s>>0,o="w"):(e=r*s>>0,t=r)}return{width:e,height:t,cropped:o}},dataURLtoBlob:function(e){for(var t=e.split(",")[0].split(":")[1].split(";")[0],i=atob(e.split(",")[1]),r=new ArrayBuffer(i.length),n=new Uint8Array(r),o=0;o<i.length;o++)n[o]=i.charCodeAt(o);var s=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;return s?(s=new(window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder),s.append(r),s.getBlob(t)):s=new Blob([r],{type:t})},detectSubsampling:function(e){var t=e.width;if(t*e.height>1048576){var i=document.createElement("canvas");i.width=i.height=1;var r=i.getContext("2d");return r.drawImage(e,1-t,0),0===r.getImageData(0,0,1,1).data[3]}return!1},rotate:function(e,t){var i={1:{90:6,180:3,270:8},2:{90:7,180:4,270:5},3:{90:8,180:1,270:6},4:{90:5,180:2,270:7},5:{90:2,180:7,270:4},6:{90:3,180:8,270:1},7:{90:4,180:5,270:2},8:{90:1,180:6,270:3}};return i[e][t]?i[e][t]:e},transformCoordinate:function(e,t,i,r){switch(r){case 5:case 6:case 7:case 8:e.width=i,e.height=t;break;default:e.width=t,e.height=i}var n=e.getContext("2d");switch(r){case 1:break;case 2:n.translate(t,0),n.scale(-1,1);break;case 3:n.translate(t,i),n.rotate(Math.PI);break;case 4:n.translate(0,i),n.scale(1,-1);break;case 5:n.rotate(.5*Math.PI),n.scale(1,-1);break;case 6:n.rotate(.5*Math.PI),n.translate(0,-i);break;case 7:n.rotate(.5*Math.PI),n.translate(t,-i),n.scale(-1,1);break;case 8:n.rotate(-.5*Math.PI),n.translate(-t,0)}},detectVerticalSquash:function(e,t,i){var r=document.createElement("canvas");r.width=1,r.height=i;var n=r.getContext("2d");n.drawImage(e,0,0);for(var o=n.getImageData(0,0,1,i).data,s=0,a=i,d=i;d>s;){0===o[4*(d-1)+3]?a=d:s=d,d=a+s>>1}var l=d/i;return 0===l?1:l},callback:function(e){return e},extend:function(){var e=arguments[0]||{},t=1,i=arguments.length,n=!1;e.constructor===Boolean&&(n=e,e=arguments[1]||{}),1===i&&(e=this,t=0);for(var o;t<i;t++)if(null!==(o=arguments[t]))for(var s in o)e!==o[s]&&(n&&"object"===_typeof(o[s])&&e[s]?r.extend(e[s],o[s]):o[s]!==undefined&&(e[s]=o[s]));return e}},n={width:300,height:0,crop:!1,quality:80,rotate:0,callback:r.callback};t.prototype={init:function(){var e=this,t=this.file,i=new FileReader;i.onloadend=function(i){var n=i.target.result,o=atob(n.split(",")[1]),s=new BinaryFile(o,0,o.length),a=EXIF.readFromBinaryFile(s),d=new Image;d.onload=function(i){var n=a.Orientation||1;n=r.rotate(n,e.options.rotate);var o=n>=5&&n<=8?r.newsize(d.height,d.width,e.options.width,e.options.height,e.options.crop):r.newsize(d.width,d.height,e.options.width,e.options.height,e.options.crop),s=d.width,l=d.height,c=o.width,h=o.height,u=document.createElement("canvas"),f=u.getContext("2d");f.save(),r.transformCoordinate(u,c,h,n),r.detectSubsampling(d)&&(s/=2,l/=2);var g=1024,p=document.createElement("canvas");p.width=p.height=g;for(var m=p.getContext("2d"),w=r.detectVerticalSquash(d,s,l),b=0;b<l;){for(var y=b+g>l?l-b:g,S=0;S<s;){var v=S+g>s?s-S:g;m.clearRect(0,0,g,g),m.drawImage(d,-S,-b);var x=Math.floor(S*c/s),_=Math.ceil(v*c/s),F=Math.floor(b*h/l/w),A=Math.ceil(y*h/l/w);f.drawImage(p,0,0,v,y,x,F,_,A),S+=g}b+=g}f.restore(),p=m=null;var P=document.createElement("canvas");P.width="h"===o.cropped?h:c,P.height="w"===o.cropped?c:h;var C="h"===o.cropped?.5*(h-c):0,R="w"===o.cropped?.5*(c-h):0;if(P.getContext("2d").drawImage(u,C,R,c,h),"image/png"===t.type)var k=P.toDataURL(t.type);else var k=P.toDataURL("image/jpeg",.01*e.options.quality);e.options.callback(k,P.width,P.height)},d.src=n},i.readAsDataURL(t)}},e[i]=function(e,i){if("string"==typeof e)return r[e](i);new t(e,i)}}(window);var EXIF=function(){function e(e){return!!e.exifdata}function t(e,t){BinaryAjax(e.src,function(r){var n=i(r.binaryResponse);e.exifdata=n||{},t&&t.call(e)})}function i(e){if(255!=e.getByteAt(0)||216!=e.getByteAt(1))return!1;for(var t,i=2,r=e.getLength();i<r;){if(255!=e.getByteAt(i))return h&&console.log("Not a valid marker at offset "+i+", found: "+e.getByteAt(i)),!1;if(22400==(t=e.getByteAt(i+1)))return h&&console.log("Found 0xFFE1 marker"),o(e,i+4,e.getShortAt(i+2,!0));if(225==t)return h&&console.log("Found 0xFFE1 marker"),o(e,i+4,e.getShortAt(i+2,!0));i+=2+e.getShortAt(i+2,!0)}}function r(e,t,i,r,o){var s,a,d,l=e.getShortAt(i,o),c={};for(d=0;d<l;d++)s=i+12*d+2,a=r[e.getShortAt(s,o)],!a&&h&&console.log("Unknown tag: "+e.getShortAt(s,o)),c[a]=n(e,s,t,i,o);return c}function n(e,t,i,r,n){var o,s,a,d,l,c,h=e.getShortAt(t+2,n),u=e.getLongAt(t+4,n),f=e.getLongAt(t+8,n)+i;switch(h){case 1:case 7:if(1==u)return e.getByteAt(t+8,n);for(o=u>4?f:t+8,s=[],d=0;d<u;d++)s[d]=e.getByteAt(o+d);return s;case 2:return o=u>4?f:t+8,e.getStringAt(o,u-1);case 3:if(1==u)return e.getShortAt(t+8,n);for(o=u>2?f:t+8,s=[],d=0;d<u;d++)s[d]=e.getShortAt(o+2*d,n);return s;case 4:if(1==u)return e.getLongAt(t+8,n);s=[];for(var d=0;d<u;d++)s[d]=e.getLongAt(f+4*d,n);return s;case 5:if(1==u)return l=e.getLongAt(f,n),c=e.getLongAt(f+4,n),a=new Number(l/c),a.numerator=l,a.denominator=c,a;for(s=[],d=0;d<u;d++)l=e.getLongAt(f+8*d,n),c=e.getLongAt(f+4+8*d,n),s[d]=new Number(l/c),s[d].numerator=l,s[d].denominator=c;return s;case 9:if(1==u)return e.getSLongAt(t+8,n);for(s=[],d=0;d<u;d++)s[d]=e.getSLongAt(f+4*d,n);return s;case 10:if(1==u)return e.getSLongAt(f,n)/e.getSLongAt(f+4,n);for(s=[],d=0;d<u;d++)s[d]=e.getSLongAt(f+8*d,n)/e.getSLongAt(f+4+8*d,n);return s}}function o(e,t){if("Exif"!=e.getStringAt(t,4))return h&&console.log("Not valid EXIF data! "+e.getStringAt(t,4)),!1;var i,n,o,s,a,d=t+6;if(18761==e.getShortAt(d))i=!1;else{if(19789!=e.getShortAt(d))return h&&console.log("Not valid TIFF data! (no 0x4949 or 0x4D4D)"),!1;i=!0}if(42!=e.getShortAt(d+2,i))return h&&console.log("Not valid TIFF data! (no 0x002A)"),!1;if(8!=e.getLongAt(d+4,i))return h&&console.log("Not valid TIFF data! (First offset not 8)",e.getShortAt(d+4,i)),!1;if(n=r(e,d,d+8,f,i),n.ExifIFDPointer){s=r(e,d,d+n.ExifIFDPointer,u,i);for(o in s){switch(o){case"LightSource":case"Flash":case"MeteringMode":case"ExposureProgram":case"SensingMethod":case"SceneCaptureType":case"SceneType":case"CustomRendered":case"WhiteBalance":case"GainControl":case"Contrast":case"Saturation":case"Sharpness":case"SubjectDistanceRange":case"FileSource":s[o]=p[o][s[o]];break;case"ExifVersion":case"FlashpixVersion":s[o]=String.fromCharCode(s[o][0],s[o][1],s[o][2],s[o][3]);break;case"ComponentsConfiguration":s[o]=p.Components[s[o][0]]+p.Components[s[o][1]]+p.Components[s[o][2]]+p.Components[s[o][3]]}n[o]=s[o]}}if(n.GPSInfoIFDPointer){a=r(e,d,d+n.GPSInfoIFDPointer,g,i);for(o in a){switch(o){case"GPSVersionID":a[o]=a[o][0]+"."+a[o][1]+"."+a[o][2]+"."+a[o][3]}n[o]=a[o]}}return n}function s(i,r){return!!i.complete&&(e(i)?r&&r.call(i):t(i,r),!0)}function a(t,i){if(e(t))return t.exifdata[i]}function d(t){if(!e(t))return{};var i,r=t.exifdata,n={};for(i in r)r.hasOwnProperty(i)&&(n[i]=r[i]);return n}function l(t){if(!e(t))return"";var i,r=t.exifdata,n="";for(i in r)r.hasOwnProperty(i)&&("object"==_typeof(r[i])?r[i]instanceof Number?n+=i+" : "+r[i]+" ["+r[i].numerator+"/"+r[i].denominator+"]\r\n":n+=i+" : ["+r[i].length+" values]\r\n":n+=i+" : "+r[i]+"\r\n");return n}function c(e){return i(e)}var h=!1,u={36864:"ExifVersion",40960:"FlashpixVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",37121:"ComponentsConfiguration",37122:"CompressedBitsPerPixel",37500:"MakerNote",37510:"UserComment",40964:"RelatedSoundFile",36867:"DateTimeOriginal",36868:"DateTimeDigitized",37520:"SubsecTime",37521:"SubsecTimeOriginal",37522:"SubsecTimeDigitized",33434:"ExposureTime",33437:"FNumber",34850:"ExposureProgram",34852:"SpectralSensitivity",34855:"ISOSpeedRatings",34856:"OECF",37377:"ShutterSpeedValue",37378:"ApertureValue",37379:"BrightnessValue",37380:"ExposureBias",37381:"MaxApertureValue",37382:"SubjectDistance",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37396:"SubjectArea",37386:"FocalLength",41483:"FlashEnergy",41484:"SpatialFrequencyResponse",41486:"FocalPlaneXResolution",41487:"FocalPlaneYResolution",41488:"FocalPlaneResolutionUnit",41492:"SubjectLocation",41493:"ExposureIndex",41495:"SensingMethod",41728:"FileSource",41729:"SceneType",41730:"CFAPattern",41985:"CustomRendered",41986:"ExposureMode",41987:"WhiteBalance",41988:"DigitalZoomRation",41989:"FocalLengthIn35mmFilm",41990:"SceneCaptureType",41991:"GainControl",41992:"Contrast",41993:"Saturation",41994:"Sharpness",41995:"DeviceSettingDescription",41996:"SubjectDistanceRange",40965:"InteroperabilityIFDPointer",42016:"ImageUniqueID"},f={256:"ImageWidth",257:"ImageHeight",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer",40965:"InteroperabilityIFDPointer",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",274:"Orientation",277:"SamplesPerPixel",284:"PlanarConfiguration",530:"YCbCrSubSampling",531:"YCbCrPositioning",282:"XResolution",283:"YResolution",296:"ResolutionUnit",273:"StripOffsets",278:"RowsPerStrip",279:"StripByteCounts",513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength",301:"TransferFunction",318:"WhitePoint",319:"PrimaryChromaticities",529:"YCbCrCoefficients",532:"ReferenceBlackWhite",306:"DateTime",270:"ImageDescription",271:"Make",272:"Model",305:"Software",315:"Artist",33432:"Copyright"},g={0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude",5:"GPSAltitudeRef",6:"GPSAltitude",7:"GPSTimeStamp",8:"GPSSatellites",9:"GPSStatus",10:"GPSMeasureMode",11:"GPSDOP",12:"GPSSpeedRef",13:"GPSSpeed",14:"GPSTrackRef",15:"GPSTrack",16:"GPSImgDirectionRef",17:"GPSImgDirection",18:"GPSMapDatum",19:"GPSDestLatitudeRef",20:"GPSDestLatitude",21:"GPSDestLongitudeRef",22:"GPSDestLongitude",23:"GPSDestBearingRef",24:"GPSDestBearing",25:"GPSDestDistanceRef",26:"GPSDestDistance",27:"GPSProcessingMethod",28:"GPSAreaInformation",29:"GPSDateStamp",30:"GPSDifferential"},p={ExposureProgram:{0:"Not defined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},SensingMethod:{1:"Not defined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},SceneType:{1:"Directly photographed"},CustomRendered:{0:"Normal process",1:"Custom process"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},GainControl:{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},SubjectDistanceRange:{0:"Unknown",1:"Macro",2:"Close view",3:"Distant view"},FileSource:{3:"DSC"},Components:{0:"",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"}};return{readFromBinaryFile:c,pretty:l,getTag:a,getAllTags:d,getData:s,Tags:u,TiffTags:f,GPSTags:g,StringValues:p}}();Upload.prototype={_init:function(e){var t=this;t.container=$(e),t.input=t.container.find('[type="file"]'),t.tplContainer=t.container.find(t.cfgs.tplContainer),t.error=t.container.find(t.cfgs.error),t.uploadBtn=t.container.find(t.cfgs.uploadBtn),t.tpl=t.cfgs.tpl||"",t.disabled=!0,t.files=[],t.filesFilter=[],t.failFiles=[],t.count=0,t.compress=0,t._bind()},_bind:function(){var e=this,t=[];e.input.change(function(i){if(!e.disabled)return void e._showError(e.error,e.cfgs.errorMsg.forbidden);e.error.length&&e.error.html("").hide(),e.failFiles=[],t=[],t.push(i.target.files);var r=t[0].length;if($.each(t,function(t,i){$.each(i,function(t,i){e.files.push(i)})}),e.cfgs.limit>0&&e.files.length>e.cfgs.limit){for(var n=0;n<r;n++)e.files.pop();e._showError(e.error,e.cfgs.errorMsg.overnum+e.cfgs.limit)}else e.filesFilter=e._filter(e.files),e.count=e.filesFilter.length,e.cfgs.onSelect(e.filesFilter),"string"==typeof e.cfgs.tpl&&e.tplContainer.length&&e.filesFilter.length&&e._createTpl(e.filesFilter),e.cfgs.autoUpload&&e._upload()}),e.uploadBtn.length&&e.uploadBtn.click(function(){if(!e.disabled)return void e._showError(e.error,e.cfgs.errorMsg.forbidden);if("string"==typeof e.cfgs.tpl&&e.tplContainer.length&&e.filesFilter.length){var t=e.tplContainer.find('[node-status="failure"]');t.find('[node-type="result"]').hide(),t.find('[node-type="progress"]').css("width",0),t.find('[node-type="reupload"]').hide()}e.count=e.filesFilter.length,e.failFiles=[],e._upload()})},_filter:function(e){var t=this,i=[],r=[];return $.each(e,function(e,n){var o=parseFloat(t.cfgs.size),s=n.name?n.name:"";n.type?0===n.type.indexOf("image")?!t.cfgs.useCanvas&&o>0&&n.size>=1048576*o?r.push(s+t.cfgs.errorMsg.invalidLarge):(n.index=e,n.aborted=!1,i.push(n)):r.push(s+t.cfgs.errorMsg.invalidType):!t.cfgs.useCanvas&&o>0&&n.size>=1048576*o?r.push(s+t.cfgs.errorMsg.invalidLarge):(n.index=e,n.aborted=!1,i.push(n))}),r.length&&t._showError(t.error,r.join("\n")),i},_createTpl:function(e){var t=this,i="",r="",n=[],o=null;if(i=t.cfgs.tpl?t.cfgs.tpl:'<li node-id=$fileIndex> \t\t<p node-type="preview" style="background-image:url($preview);"></p> \t\t<p node-type="result"></p> \t<p node-type="name">$name</p> \t<p node-type="size">$size</p> \t<p node-type="progress"></p> \t<p node-type="reupload" node-data=$fileIndex>^</p> \t<p node-type="close" node-data=$fileIndex>x</p> \t</li>',brickjs.UserAgent.isiOS)return void $.each(e,function(n,o){var s=o.size/1024,a={name:o.name,size:s>=1024?(s/1024).toFixed(1)+"M":s.toFixed(1)+"KB",fileIndex:o.index};canvasResize(o,{width:t.cfgs.width,height:0,crop:!1,quality:t.cfgs.quality,callback:function(o,s,d){a.preview=o,r+=t._templ(i,a),n===e.length-1&&(t.tplContainer.html(r).show(),t._bindTpl())}})});$.each(e,function(e,o){var s=o.size/1024,a={name:o.name,size:s>=1024?(s/1024).toFixed(1)+"M":s.toFixed(1)+"KB",fileIndex:o.index};a.preview=t._dealObjectURL(o,!0),r+=t._templ(i,a),n.push(a.preview)}),o=setTimeout(function(){$.each(n,function(e,i){t._dealObjectURL(i)}),clearTimeout(o)},5e3),t.tplContainer.html(r).show(),t._bindTpl()},_bindTpl:function(){var e=this;e.tplContainer.on("click",'[node-type="close"]',function(){e._delete($(this).attr("node-data"))}),e.tplContainer.on("click",'[node-type="reupload"]',function(){var t=$(this).hide().attr("node-data"),i=[],r="";$.each(e.filesFilter,function(n,o){if(o.index==t)return r=e.tplContainer.find('[node-id="'+t+'"]'),r.find('[node-type="result"]').hide(),r.find('[node-type="progress"]').css("width",0),i.push(o),e._upload(i),!1})})},_watchTpl:function(e,t,i,r){var n=this,o="";if("string"==typeof n.cfgs.tpl&&n.tplContainer.length)switch(o=n.container.find('[node-id="'+t+'"]'),e){case"progress":o.find('[node-type="progress"]').animate({width:i/r*100+"%"});break;case"success":o.attr("node-status","success").find('[node-type="result"]').html("上传成功").show(),o.find('[node-type="progress"]').css("width","100%");break;case"failure":o.attr("node-status","failure").find('[node-type="result"]').html(i||"上传失败").show(),o.find('[node-type="reupload"]').show()}},_templ:function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e=e.replace(new RegExp("\\$"+i,"ig"),t[i]));return e},_dealObjectURL:function(e,t){if(window.URL){if(t)return window.URL.createObjectURL(e);window.URL.revokeObjectURL(e)}else if(window.webkitURL){if(t)return window.webkitURL.createObjectURL(e);window.webkitURL.revokeObjectURL(e)}},_upload:function _upload(target){var self=this,filesFilter=self.filesFilter;target&&(filesFilter=target),0!==filesFilter.length&&(self.cfgs.onUploading(),self.disable(),$.each(filesFilter,function(index,file){var xhr=new XMLHttpRequest,fileIndex=file.index,fileName=file.name?file.name:"";if(xhr.upload.addEventListener("progress",function(e){self._watchTpl("progress",fileIndex,e.loaded,e.total),self.cfgs.onProgress(e.loaded,e.total,file)},!1),xhr.addEventListener("error",function(e){self._checkPogress(target,file),self._watchTpl("failure",fileIndex),self.cfgs.onFailure("上传失败",file),self.cfgs.autoUpload&&self._delete(file,target)},!1),xhr.addEventListener("load",function(e){var response=eval("("+xhr.responseText+")"),fileAborted=file.aborted;fileAborted||(response&&1==response.status?(self._watchTpl("success",fileIndex),self.cfgs.onSuccess(response,file),self._delete(file,target)):(self._checkPogress(target,file),self._watchTpl("failure",fileIndex,response?response.message:"上传失败"),self.cfgs.onFailure(response?response.message:"上传失败",file)))},!1),self.cfgs.useCanvas||brickjs.UserAgent.isiOS)brickjs.UserAgent.isiOS?self._resizeIos(file,1,1,xhr):self._resize(file,1,1,xhr);else{var formData=new FormData;formData.append("Filedata",file);for(var p in self.cfgs.params)self.cfgs.params.hasOwnProperty(p)&&formData.append(p,self.cfgs.params[p]);xhr.open("POST",self.cfgs.url,!0),xhr.send(formData)}}))},_resize:function(e,t,i,r){var n=this,o=document.createElement("canvas"),s=o.getContext("2d"),a=new FileReader,d=new Image,l=1,c=null,h=parseFloat(n.cfgs.size)||1e3;a.onload=function(a){d.onload=function(){l=this.width>n.cfgs.width?n.cfgs.width/this.width:1,o.width=this.width*l*t,o.height=this.height*l*t,s.drawImage(d,0,0,o.width,o.height),c="image/png"===e.type?o.toDataURL(e.type):o.toDataURL("image/jpeg",n.cfgs.quality/100*i),c.length<1024*h*1024?(r.open("POST",n.cfgs.url,!0),r.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),r.send("Filedata="+encodeURIComponent(c)+"&title="+n.cfgs.params.title+"&uploadtype="+n.cfgs.params.uploadtype)):(n.compress++,"image/png"===e.type||brickjs.UserAgent.isAndroid&&!brickjs.UserAgent.chrome?n._resize(e,Math.pow(.8,n.compress),1,r):n._resize(e,1,Math.pow(.8,n.compress),r))},d.src=a.target.result},a.readAsDataURL(e)},_resizeIos:function(e,t,i,r){var n=this,o=parseFloat(n.cfgs.size)||1e3;canvasResize(e,{width:n.cfgs.width*t,height:0,crop:!1,quality:n.cfgs.quality*i,callback:function(t,i,s){t.length<1024*o*1024?(r.open("POST",n.cfgs.url,!0),r.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),r.send("Filedata="+encodeURIComponent(t)+"&title="+n.cfgs.params.title+"&uploadtype="+n.cfgs.params.uploadtype)):(n.compress++,"image/png"===e.type?n._resizeIos(e,Math.pow(.8,n.compress),1,r):n._resizeIos(e,1,Math.pow(.8,n.compress),r))}})},_delete:function(e,t){var i=this,r=[];if(!i.filesFilter.length&&"string"==typeof e)return void i._hidePreview(e);$.each(i.filesFilter,function(t,n){"string"==typeof e?n.index!=e?r.push(n):(i._hidePreview(e),n.aborted=!0,i.cfgs.onDelete(n)):n!=e?r.push(n):"string"==typeof i.cfgs.tpl&&i.tplContainer.length&&i.cfgs.autoHide&&i._hidePreview(n.index)}),i.filesFilter=r,i.files=r,i._checkPogress(t)},_hidePreview:function(e){var t=this,i=0;t.container.find('[node-id="'+e+'"]').fadeOut("slow",function(){$(this).remove(),(i=t.container.find("[node-id]").length)||t.tplContainer.html("").hide()})},_checkPogress:function(e,t){var i=this;i.count--,t&&i.failFiles.push(t),i.filesFilter.length?!i.count&&i.failFiles.length?(i.cfgs.onComplete("部分图片未上传成功,请重新上传",i.failFiles),i.enable()):e&&i.enable():(i.disabled||i.cfgs.onComplete("全部图片上传成功"),i.enable())},_showError:function(e,t,i){if("function"==typeof this.cfgs.onError)return void this.cfgs.onError(t);e.length?i?e.append(t).show():e.html(t).show():setTimeout(function(){alert(t)},0)},disable:function(){this.disabled=!1},enable:function(){this.disabled=!0}},regist("Upload",Upload)}("undefined"!=typeof Zepto?Zepto:jQuery,window,document)},16:function(e,t,i){"use strict";!function(e,t,i,r){var n={isDesktop:!1,isWindows:!1,isLinux:!1,isMac:!1,isTablet:!1,isiPad:!1,isAndroidTablet:!1,isMobile:!1,isiOS:!1,isAndroid:!1,isiPhone:!1,isWindowsPhone:!1,isWeChat:!1,isWeibo:!1,ie:0,firefox:0,chrome:0,safari:0,opera:0,uc:0,mqq:0,baidu:0,androidBrowser:0,browser:"",engine:"",osVersion:0,_versions:{ie:/msie\s([\d\.]+[\d])|trident\/\d+\.\d+;\s+[rv:]+(\d+\.\d)/i,firefox:/firefox\/([\d\w\.\-]+)/i,chrome:/(chrome|crios)\/([\d\w\.\-]+)/i,safari:/version\/([\d\w\.\-]+)/i,opera:/version\/([\d\w\.\-]+)/i,uc:/ucbrowser\/([\d\w\.\-]+)/i,mqq:/mqqbrowser\/([\d\w\.\-]+)/i,baidu:/baidubrowser\/([\d\w\.\-]+)/i,androidBrowser:/version\/([\d\w\.\-]+)/i},_browsers:{ie:/msie|trident/i,firefox:/firefox/i,chrome:/chrome|crios/i,safari:/safari/i,opera:/opera/i,uc:/ucbrowser/i,mqq:/mqqbrowser/i,baidu:/baidubrowser/i,weibo:/weibo/i,wechat:/micromessenger/i},_platforms:{windows:/windows nt/i,windowsPhone:/windows phone/i,mac:/macintosh/i,linux:/linux/i,iPad:/ipad/i,iPod:/ipod/i,iPhone:/iphone/i,android:/android/i},_osVersion:{iOS:/(iphone\sos|cpu\sos)\s([\d\w\_\-]+)/i,android:/android\s([\d\w\.\-]+)/i},_engine:{trident:/trident/i,gecko:/gecko/i,applewebkit:/applewebkit/i,presto:/presto/i},_init:function(){this.ua=navigator.userAgent.toLowerCase(),this._getPlatform(),this.browser=this._getBrowser(),this._getBroserVersion(),this.isAndroidTablet=this.isAndroid&&new RegExp("tablet","i").test(this.ua),this._testMobile(),this._getOSVersion(),this._getEngine()},_toFixedVersion:function(e,t){var e=(""+e).replace(/_/g,"."),t=t||1;return e=String(e).split("."),e=e[0]+"."+(e[1]||"0"),e=Number(e).toFixed(t)},_getBrowser:function(){var e=this.ua;switch(!0){case this._browsers.ie.test(e):return this.ie=!0,"IE";case this._browsers.firefox.test(e):return this.firefox=!0,"Firefox";case this._browsers.opera.test(e):return this.opera=!0,"Opera";case this._browsers.uc.test(e):return this.uc=!0,"UC";case this._browsers.baidu.test(e):return this.baidu=!0,"Baidu";case this._browsers.weibo.test(e):return this.isWeibo=!0,"Weibo";case this._browsers.wechat.test(e):return this.isWeChat=!0,"MicroMessenger";case this._browsers.mqq.test(e):return this.mqq=!0,"MQQ";case this._browsers.chrome.test(e):return this.chrome=!0,"Chrome";case!this.isAndroid&&this._browsers.safari.test(e):return this.safari=!0,"Safari";case this.isAndroid:return this.androidBrowser=!0,"Android";default:return"unknown"}},_getBroserVersion:function(){var e=this.ua;switch(!0){case this.ie:this._versions.ie.test(e),this.ie=RegExp.$2?this._toFixedVersion(RegExp.$2,1):this._toFixedVersion(RegExp.$1,1);break;case this.firefox:this._versions.firefox.test(e),this.firefox=RegExp.$1?this._toFixedVersion(RegExp.$1,1):0;break;case this.opera:this._versions.opera.test(e),this.opera=RegExp.$1?this._toFixedVersion(RegExp.$1,1):0;break;case this.uc:this._versions.uc.test(e),this.uc=RegExp.$1?this._toFixedVersion(RegExp.$1,1):0;break;case this.baidu:this._versions.baidu.test(e),this.baidu=RegExp.$1?this._toFixedVersion(RegExp.$1,1):0;break;case this.mqq:this._versions.mqq.test(e),this.mqq=RegExp.$1?this._toFixedVersion(RegExp.$1,1):0;break;case this.chrome:this._versions.chrome.test(e),this.chrome=RegExp.$2?this._toFixedVersion(RegExp.$2,1):0;break;case this.safari:this._versions.safari.test(e),this.safari=RegExp.$1?this._toFixedVersion(RegExp.$1,1):0;break;case this.androidBrowser:this._versions.androidBrowser.test(e),this.androidBrowser=RegExp.$1?this._toFixedVersion(RegExp.$1,1):0}},_getOSVersion:function(){var e=this.ua;switch(!0){case this._osVersion.iOS.test(e):this.osVersion=RegExp.$2.replace(/_/g,"."),this.isiOS=!0;break;case this._osVersion.android.test(e):this.osVersion=RegExp.$1}},_getPlatform:function(){var e=this.ua;switch(!0){case this._platforms.windows.test(e):this.isWindows=!0;break;case this._platforms.windowsPhone.test(e):this.isWindowsPhone=!0;break;case this._platforms.mac.test(e):this.isMac=!0;break;case this._platforms.iPad.test(e):this.isiPad=!0;break;case this._platforms.iPhone.test(e)||this._platforms.iPod.test(e):this.isiPhone=!0;break;case this._platforms.android.test(e):this.isAndroid=!0;break;case this._platforms.linux.test(e):this.isLinux=!0}},_testMobile:function(){var e=this.ua;switch(!0){case this.isWindows:case this.isLinux:case this.isMac:this.isDesktop=!0;break;case this.isiPad:case this.isAndroidTablet:this.isTablet=!0;break;case this.isAndroid:case this.isiPhone:case this.isWindowsPhone:this.isMobile=!0}/mobile/i.test(e)&&!this.isTablet&&(this.isMobile=!0,this.isDesktop=!1,this.isTablet=!1)},_getEngine:function(){var e=this.ua;switch(!0){case this._engine.trident.test(e):this.engine="trident";break;case this._engine.applewebkit.test(e):this.engine="applewebkit";break;case this._engine.presto.test(e):this.engine="presto";break;case this._engine.gecko.test(e):this.engine="gecko"}},contains:function(e){return new RegExp(e,"i").test(this.ua)},getUserAgent:function(){return this.ua}};n._init(),function(e,i){void 0===t.brickjs&&(t.brickjs={}),brickjs[e]=i}("UserAgent",n)}("undefined"!=typeof Zepto?Zepto:jQuery,window,document)},20:function(e,t){},29:function(e,t,i){e.exports=i(1)}},[29]);
- //# sourceMappingURL=comment.js.map?v=76e6ae63
|