%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/bitrix/www/bitrix/js/main/core/core_uploader/
Upload File :
Create Path :
Current File : /home/bitrix/www/bitrix/js/main/core/core_uploader/file.min.js

(function(e){if(e.BX["UploaderFile"])return false;var t=function(){var t={tags:{274:"Orientation"},getStringFromDB:function(e,t,i){var s="",a;for(a=t;a<t+i;a++){s+=String.fromCharCode(e.getUint8(a))}return s},readTags:function(e,i,s,a,r){var n=e.getUint16(s,!r),h={},l,o,d,u=0;for(d in a){if(a.hasOwnProperty(d))u++}for(d=0;d<n;d++){l=s+d*12+2;o=a[e.getUint16(l,!r)];h[o]=t.readTagValue(e,l,i,s,r);u--;if(u<=0)break}return h},readTagValue:function(e,i,s,a,r){var n=e.getUint16(i+2,!r),h=e.getUint32(i+4,!r),l=e.getUint32(i+8,!r)+s,o,d,u,m,p,f;switch(n){case 1:case 7:if(h==1){return e.getUint8(i+8,!r)}else{o=h>4?l:i+8;d=[];for(m=0;m<h;m++){d[m]=e.getUint8(o+m)}return d}case 2:o=h>4?l:i+8;return t.getStringFromDB(e,o,h-1);case 3:if(h==1){return e.getUint16(i+8,!r)}else{o=h>2?l:i+8;d=[];for(m=0;m<h;m++){d[m]=e.getUint16(o+2*m,!r)}return d}case 4:if(h==1){return e.getUint32(i+8,!r)}else{d=[];for(m=0;m<h;m++){d[m]=e.getUint32(l+4*m,!r)}return d}case 5:if(h==1){p=e.getUint32(l,!r);f=e.getUint32(l+4,!r);u=new Number(p/f);u.numerator=p;u.denominator=f;return u}else{d=[];for(m=0;m<h;m++){p=e.getUint32(l+8*m,!r);f=e.getUint32(l+4+8*m,!r);d[m]=new Number(p/f);d[m].numerator=p;d[m].denominator=f}return d}case 9:if(h==1){return e.getInt32(i+8,!r)}else{d=[];for(m=0;m<h;m++){d[m]=e.getInt32(l+4*m,!r)}return d}case 10:if(h==1){return e.getInt32(l,!r)/e.getInt32(l+4,!r)}else{d=[];for(m=0;m<h;m++){d[m]=e.getInt32(l+8*m,!r)/e.getInt32(l+4+8*m,!r)}return d}}},readData:function(e,i){if(t.getStringFromDB(e,i,4)!="Exif"){return false}var s,a=i+6;if(e.getUint16(a)==18761){s=false}else if(e.getUint16(a)==19789){s=true}else{return false}if(e.getUint16(a+2,!s)!=42){return false}var r=e.getUint32(a+4,!s);if(r<8){return false}return t.readTags(e,a,a+r,t.tags,s)},readBase64:function(i){i=i.replace(/^data\:([^\;]+)\;base64,/gim,"");var s=e.atob(i),a=s.length,r=new Uint8Array(a);for(var n=0;n<a;n++){r[n]=s.charCodeAt(n)}var h=new DataView(r.buffer);if(h.getUint8(0)!=255||h.getUint8(1)!=216){return false}var l=2,o=r.buffer.byteLength,d,u=false;while(l<o){if(h.getUint8(l)!=255){break}d=h.getUint8(l+1);if(d==225){u=t.readData(h,l+4,h.getUint16(l+2)-2);break}else{l+=2+h.getUint16(l+2)}}return u}};return function(e){if(s.type.isString(e)){try{var i=t.readBase64(e);if(i&&i["Orientation"])return i["Orientation"]}catch(e){}}return false}}(),i=function(e,t,i,a){var r=e.width,n=e.height;if([5,6,7,8].indexOf(a)>=0){r=e.height;n=e.width}s.adjust(t,{props:{width:r,height:n}});i.save();switch(a){case 2:i.scale(-1,1);i.translate(-t.width,0);break;case 3:i.translate(t.width,t.height);i.rotate(Math.PI);break;case 4:i.scale(-1,1);i.translate(0,t.height);i.rotate(Math.PI);break;case 5:i.scale(-1,1);i.translate(0,0);i.rotate(Math.PI/2);break;case 6:i.translate(t.width,0);i.rotate(Math.PI/2);break;case 7:i.scale(-1,1);i.translate(-t.width,t.height);i.rotate(Math.PI*3/2);break;case 8:i.translate(0,t.height);i.rotate(Math.PI*3/2);break}i.drawImage(e,0,0);i.restore()};var s=e.BX,a={new:0,ready:1,preparing:2,inprogress:3,done:4,failed:5,stopped:6,changed:7,uploaded:8},r=function(){var i=function(e){this.timeLimit=typeof e==="number"&&e>0?e:50;this.status=a.ready;this.queue=new s.UploaderUtils.Hash;this.id=(new Date).getTime()};i.prototype={counter:0,active:null,image:null,getImage:function(){if(!this.image)this.image=new Image;return this.image},canvas:null,getCanvas:function(){if(!this.canvas){this.canvas=s.create("CANVAS",{style:{display:"none"}});document.body.appendChild(this.canvas)}return this.canvas},context:null,getContext:function(){if(!this.context&&this.getCanvas()["getContext"])this.context=this.getCanvas().getContext("2d");return this.context},reader:null,getReader:function(){if(!this.reader&&e["FileReader"])this.reader=new FileReader;return this.reader},load:function(i,a,r,n){if(this.active!==null||this.getReader()&&this.getReader().readyState==1)return;this.counter++;this.active=i;var h=this.getImage();s.unbindAll(h);h.onload=function(){};h.onerror=function(){};if(!s.browser.IsFirefox())h.src="/bitrix/images/1.gif";this.onload=null;delete this.onload;this.onerror=null;delete this.onerror;this.onload=s.delegate(function(e){if(e&&e.target&&e.target.src&&e.target.src.substr(-20)=="/bitrix/images/1.gif")return;if(!!a){try{a(s.proxy_context,this.getCanvas(),this.getContext(),t(e&&e.target&&e.target.src?e.target.src:s.proxy_context||null))}catch(e){s.debug(e)}}if(!!r){this.queue.removeItem(r);setTimeout(s.proxy(function(){this.active=null;this.exec()},this),this.timeLimit)}else this.active=null},this);this.onerror=s.delegate(function(){if(!!n){try{n(s.proxy_context)}catch(e){s.debug(e)}}if(!!r){this.queue.removeItem(r);setTimeout(s.proxy(function(){this.active=null;this.exec()},this),this.timeLimit)}else this.active=null},this);h.name=i.name;h.onload=this.onload;h.onerror=this.onerror;var l=Object.prototype.toString.call(i);if(i["tmp_url"]){h.src=i["tmp_url"]+(i["tmp_url"].indexOf("?")>0?"&":"?")+"imageUploader"+this.id+this.counter}else if(l!=="[object File]"&&l!=="[object Blob]"){this.onerror(null)}else if(e["URL"]){h.src=e["URL"]["createObjectURL"](i)}else if(this.getReader()!==null){this.__readerOnLoad=null;delete this.__readerOnLoad;this.__readerOnLoad=s.delegate(function(e){this.__readerOnLoad=null;delete this.__readerOnLoad;h.src=e.target.result},this);this.getReader().onloadend=this.__readerOnLoad;this.getReader().onerror=s.proxy(function(e){this.onerror(null)},this);this.getReader().readAsDataURL(i)}},push:function(e,t,i){var a=s.UploaderUtils.getId();this.queue.setItem(a,[a,e,t,i]);this.exec()},exec:function(){var e=this.queue.getFirst();if(!!e)this.load(e[1],e[2],e[0],e[3])},pack:function(e){return s.UploaderUtils.dataURLToBlob(this.getCanvas().toDataURL(e))}};return i}();s.UploaderFileCnvConstr=r;s.UploaderFileFileLoader=function(){var e=function(e){this.timeLimit=typeof e==="number"&&e>0?e:50;this.status=a.ready;this.queue=new s.UploaderUtils.Hash;this._exec=s.delegate(this.exec,this)};e.prototype={xhr:null,goToNext:function(e){delete this.xhr;this.xhr=null;this.queue.removeItem(e);this.status=a.ready;setTimeout(this._exec,this.timeLimit)},load:function(e,t,i,r){if(this.status!=a.ready)return;this.status=a.inprogress;var n=this;this.xhr=s.ajax({method:"GET",data:"",url:t,onsuccess:function(t){if(t===null){r(t)}else{i(t)}n.goToNext(e)},onfailure:function(t){r(t);n.goToNext(e)},start:false,preparePost:false,processData:false});this.xhr.withCredentials=true;this.xhr.responseType="blob";this.xhr.send()},push:function(e,t,i){var a=s.UploaderUtils.getId();this.queue.setItem(a,[a,e,t,i]);this.exec()},exec:function(){var e=this.queue.getFirst();if(!!e)this.load(e[0],e[1],e[2],e[3])}};return e}();var n=new r,h=new r,l=new r,o=s.create("CANVAS"),d;var u={};s.UploaderFile=function(e,t,i,r){this.dialogName=this.dialogName?this.dialogName:"BX.UploaderFile";this.file=e;this.id=e["id"]||"file"+s.UploaderUtils.getId();this.name=e.name;this.isNode=false;if(s.type.isDomNode(e)){this.isNode=true;this.name=s.UploaderUtils.getFileNameOnly(e.value);if(/\[(.+?)\]/.test(e.name)){var n=/\[(.+?)\]/.exec(e.name);this.id=n[1]}this.file.bxuHandler=this}else if(e["tmp_url"]&&!e["name"]){this.name=s.UploaderUtils.getFileNameOnly(e["tmp_url"])}this.preview='<span id="'+this.id+'Canvas" class="bx-bxu-canvas"></span>';this.nameWithoutExt=this.name.lastIndexOf(".")>0?this.name.substr(0,this.name.lastIndexOf(".")):this.name;this.ext=this.name.substr(this.nameWithoutExt.length+1);if(/iPhone|iPad|iPod/i.test(navigator.userAgent)&&this.nameWithoutExt=="image"){var h="mobile_"+s.date.format("Ymd_His");u[h]=u[h]||0;this.nameWithoutExt=h+(u[h]>0?"_"+u[h]:"");this.name=this.nameWithoutExt+(s.type.isNotEmptyString(this.ext)?"."+this.ext:"");u[h]++}this.size="";if(e.size)this.size=s.UploaderUtils.getFormattedSize(e.size,0);this.type=e.type;this.status=a["new"];this.limits=i;this.caller=r;this.fields={thumb:{tagName:"SPAN",template:'<div class="someclass">#preview#<div>#name#</div>',editorTemplate:'<div class="someeditorclass"><div>#name#</div>',className:"bx-bxu-thumb-thumb",placeHolder:null},preview:{params:{width:400,height:400},template:"#preview#",editorParams:{width:1024,height:860},editorTemplate:"<span>#preview#</span>",className:"bx-bxu-thumb-preview",placeHolder:null,events:{click:s.delegate(this.clickFile,this)},type:"html"},name:{template:"#name#",editorTemplate:'<span><input type="text" name="name" value="#name#" /></span>',className:"bx-bxu-thumb-name",placeHolder:null},type:{template:"#type#",editorTemplate:"#type#",className:"bx-bxu-thumb-type",placeHolder:null}};if(!!t["fields"]){var l,o;for(var d in t["fields"]){if(t["fields"].hasOwnProperty(d)){if(!!this.fields[d]){for(l in t["fields"][d]){if(t["fields"][d].hasOwnProperty(l)){this.fields[d][l]=t["fields"][d][l]}}}else this.fields[d]=t["fields"][d];o=d+"";if(o.toLowerCase()!="thumb"&&o.toLowerCase()!="preview"){this[o.toLowerCase()]=!!t["fields"][d]["value"]?t["fields"][d]["value"]:"";this.log(o.toLowerCase()+": "+this[o.toLowerCase()])}}}}s.onCustomEvent(this,"onFileIsCreated",[this.id,this,this.caller]);s.onCustomEvent(this.caller,"onFileIsCreated",[this.id,this,this.caller]);this.makePreview();this.preparationStatus=a.done;return this};s.UploaderFile.prototype={log:function(e){s.UploaderUtils.log("file "+this.name,e)},makeThumb:function(){var e=this.fields.thumb.template,t,i,a={},r,n;for(i in this.fields){if(this.fields.hasOwnProperty(i)){if(this.fields[i].template&&this.fields[i].template.indexOf("#"+i+"#")>=0){t=this.id+i.toUpperCase().substr(0,1)+i.substr(1);r=this.setProps(i,this[i],true);e=e.replace("#"+i+"#",'<span id="'+t+'" class="'+this.fields[i]["className"]+'">'+(s.type.isNotEmptyString(r.html)?r.html.replace("#","<>"):r.html)+"</span>");for(n in r.events){if(r.events.hasOwnProperty(n)){a[n]=r.events[n]}}if(!!this.fields[i].events)a[t]=this.fields[i].events}}}var h,l=[],o=[],d;while((h=/#([^\\<\\>\\"\\']+?)#/gi.exec(e))&&!!h){if(this[h[1]]!==undefined){e=e.replace(h[0],s.type.isNotEmptyString(this[h[1]])?this[h[1]].replace("#","<>"):this[h[1]])}else{d="<"+l.length+">";l.push(d);o.push(h[0]);e=e.replace(h[0],d)}}while((h=l.shift())&&h){d=o.shift();e=e.replace(h,d)}e=e.replace("<>","#");if(!!this.fields.thumb.tagName){h=s.create(this.fields.thumb.tagName,{attrs:{id:this.id+"Thumb",className:this.fields.thumb.className},events:this.fields.thumb.events,html:e})}else{h=e}this.__makeThumbEventsObj=a;this.__makeThumbEvents=s.delegate(function(){var e,t;for(e in a){if(a.hasOwnProperty(e)&&s(e)){for(t in a[e]){if(a[e].hasOwnProperty(t)){s.bind(s(e),t,a[e][t])}}}}this.__makeThumbEvents=null;delete this.__makeThumbEvents},this);s.addCustomEvent(this,"onFileIsAppended",this.__makeThumbEvents);if(s.type.isDomNode(this.file)){if(s.type.isString(e)){this.__bindFileNode=s.delegate(function(e){var t=s(e+"Item");if(t.tagName=="TR")t.cells[0].appendChild(this.file);else if(t.tagName=="TABLE")t.rows[0].cells[0].appendChild(this.file);else s(e+"Item").appendChild(this.file);this.__bindFileNode=null;delete this.__bindFileNode},this);s.addCustomEvent(this,"onFileIsAppended",this.__bindFileNode)}else{h.appendChild(this.file)}}return h},checkProps:function(){var e=s.UploaderUtils.FormToArray({elements:[s.proxy_context]}),t;for(t in e.data){if(e.data.hasOwnProperty(t))this[t]=e.data[t]}},setProps:function(e,t,i){if(typeof e=="string"){if(e=="size")t=s.UploaderUtils.getFormattedSize(this.file.size,0);if(typeof this[e]!="undefined"&&typeof this.fields[e]!="undefined"){this[e]=t;var a=this.fields[e].template.replace("#"+e+"#",this.fields[e]["type"]==="html"?t||"":s.util.htmlspecialchars(t||"")).replace(/#id#/gi,this.id),r,n,h,l={html:a,events:{}};this.hiddenForm=!!this.hiddenForm?this.hiddenForm:s.create("FORM",{style:{display:"none"}});this._checkProps=!!this._checkProps?this._checkProps:s.delegate(this.checkProps,this);this.hiddenForm.innerHTML=a;if(this.hiddenForm.elements.length>0){for(r=0;r<this.hiddenForm.elements.length;r++){h=this.hiddenForm.elements[r];if(typeof this[h.name]!="undefined"){if(!h.hasAttribute("id"))h.setAttribute("id",this.id+e+s.UploaderUtils.getId());l.events[h.id]={blur:this._checkProps}}}l.html=this.hiddenForm.innerHTML}if(s(this.hiddenForm))s.remove(this.hiddenForm);this.hiddenForm=null;delete this.hiddenForm;if(i)return l;var o=this.getPH(e);if(!!o){o.innerHTML=l.html;for(r in l.events){if(l.events.hasOwnProperty(r)){for(n in l.events[r]){if(l.events[r].hasOwnProperty(n)){s.bind(s(r),n,l.events[r][n])}}}}}}}else if(!!e){for(var d in e){if(e.hasOwnProperty(d)){if(this.fields.hasOwnProperty(d)&&d!=="preview")this.setProps(d,e[d])}}}return true},getProps:function(e){if(e=="canvas"){return s(this.id+"ProperCanvas")}else if(typeof e=="string"){return this[e]}var t={};for(var i in this.fields){if(this.fields.hasOwnProperty(i)&&(i!=="preview"&&i!=="thumb")){t[i]=this[i]}}t["size"]=this.file["size"];t["type"]=this["type"];if(!!this.copies){var a;t["canvases"]={};while((a=this.copies.getNext())&&!!a){t["canvases"][a.id]={width:a.width,height:a.height,name:a.name}}}return t},getThumbs:function(){return null},getPH:function(e){e=typeof e==="string"?e:"";e=e.toLowerCase();if(this.fields.hasOwnProperty(e)){var t=e.substr(0,1).toUpperCase()+e.substr(1);this.fields[e]["placeHolder"]=s(this.id+t);return this.fields[e]["placeHolder"]}return null},clickFile:function(){return false},makePreview:function(){this.status=a.ready;s.onCustomEvent(this,"onFileIsInited",[this.id,this,this.caller]);s.onCustomEvent(this.caller,"onFileIsInited",[this.id,this,this.caller]);this.log("is initialized as a file")},preparationStatus:a.ready,deleteFile:function(){var e,t=this.__makeThumbEventsObj;for(e in this.fields){if(this.fields.hasOwnProperty(e)){if(!!this.fields[e]["placeHolder"]){this.fields[e]["placeHolder"]=null;s.unbindAll(this.fields[e]["placeHolder"]);delete this.fields[e]["placeHolder"]}}}for(e in t){if(t.hasOwnProperty(e)&&s(e)){s.unbindAll(s(e))}}this.file=null;delete this.file;s.remove(this.canvas);this.canvas=null;delete this.canvas;s.onCustomEvent(this.caller,"onFileIsDeleted",[this.id,this,this.caller]);s.onCustomEvent(this,"onFileIsDeleted",[this,this.caller])}};s.UploaderImage=function(e,t,i,r){this.dialogName="BX.UploaderImage";s.UploaderImage.superclass.constructor.apply(this,arguments);this.isImage=true;this.copies=new s.UploaderUtils.Hash;this.caller=r;if(!this.isNode&&s.Uploader.getInstanceName()=="BX.Uploader"){if(!!t["copies"]){var n=t["copies"],l;for(var o in n){if(n.hasOwnProperty(o)&&!!n[o]){l={width:parseInt(n[o]["width"]),height:parseInt(n[o]["height"]),id:o};if(l["width"]>0&&l["height"]>0){this.copies.setItem(o,l)}}}}this.preparationStatus=a["new"];s.addCustomEvent(this,"onFileHasToBePrepared",s.delegate(function(){this.preparationStatus=a.inprogress;if(this.status!=a["new"]){h.push(this.file,s.delegate(this.makeCopies,this))}},this));s.addCustomEvent(this,"onUploadDone",s.delegate(function(){var e;while((e=this.copies.getNext())&&!!e){e.file=null;delete e.file}this.preparationStatus=a["new"]},this));this.canvas=s.create("CANVAS",{attrs:{id:this.id+"ProperCanvas"}})}else{this.preparationStatus=a.done;this.canvas=null}return this};s.extend(s.UploaderImage,s.UploaderFile);s.UploaderImage.prototype.makePreviewImageWork=function(e,t,a,r){r=parseInt(r);var n=null,h=t.width,l=t.height;if(this.file){this.file.width=t.width;this.file.height=t.height}if(!!this.canvas){i(e,t,a,r);if(this.file){this.file.width=t.width;this.file.height=t.height;if(r){this.file.exif={Orientation:r}}}this.applyFile(t,false);n=this.canvas}else if(s(this.id+"Canvas")){var o=s.UploaderUtils.scaleImage({width:h,height:l},this.fields.preview.params),d={props:{width:o.destin.width,height:o.destin.height,src:e.src},attrs:{className:this.file.width>this.file.height?"landscape":"portrait"}};switch(r){case 2:d.attrs.className+=" flip";break;case 3:d.attrs.className+=" rotate-180";break;case 4:d.attrs.className+=" flip-and-rotate-180";break;case 5:d.attrs.className+=" flip-and-rotate-270";break;case 6:d.attrs.className+=" rotate-90";break;case 7:d.attrs.className+=" flip-and-rotate-90";break;case 8:d.attrs.className+=" rotate-270";break}n=s.create("IMG",d)}s.onCustomEvent(this,"onFileCanvasIsLoaded",[this.id,this,this.caller,e]);s.onCustomEvent(this.caller,"onFileCanvasIsLoaded",[this.id,this,this.caller,e]);if(s(this.id+"Canvas"))s(this.id+"Canvas").appendChild(n);return n};s.UploaderImage.prototype.makePreviewImageLoadHandler=function(e,t,i,r){this.makePreviewImageWork(e,t,i,r);this.status=a.ready;s.onCustomEvent(this,"onFileIsInited",[this.id,this,this.caller]);s.onCustomEvent(this.caller,"onFileIsInited",[this.id,this,this.caller]);this.log("is initialized as an image with preview");if(this.preparationStatus==a.inprogress)this.makeCopies(e,t,i,r);if(this["_makePreviewImageLoadHandler"]){this._makePreviewImageLoadHandler=null;delete this._makePreviewImageLoadHandler}if(this["_makePreviewImageFailedHandler"]){this._makePreviewImageFailedHandler=null;delete this._makePreviewImageFailedHandler}};s.UploaderImage.prototype.makePreviewImageFailedHandler=function(){this.status=a.ready;this.preparationStatus=a.done;s.onCustomEvent(this,"onFileIsInited",[this.id,this,this.caller]);s.onCustomEvent(this.caller,"onFileIsInited",[this.id,this,this.caller]);this.log("is initialized without canvas");if(this["_makePreviewImageLoadHandler"]){this._makePreviewImageLoadHandler=null;delete this._makePreviewImageLoadHandler}if(this["_makePreviewImageFailedHandler"]){this._makePreviewImageFailedHandler=null;delete this._makePreviewImageFailedHandler}};s.UploaderImage.prototype.makePreview=function(){if(!this.isNode){this._makePreviewImageLoadHandler=s.delegate(this.makePreviewImageLoadHandler,this);this._makePreviewImageFailedHandler=s.delegate(this.makePreviewImageFailedHandler,this);n.push(this.file,this._makePreviewImageLoadHandler,this._makePreviewImageFailedHandler)}else{this.status=a.ready;s.onCustomEvent(this,"onFileIsInited",[this.id,this,this.caller]);s.onCustomEvent(this.caller,"onFileIsInited",[this.id,this,this.caller]);this.log("is initialized as an image without preview");if(this.caller.queue.placeHolder){this._onFileHasGotPreview=s.delegate(function(e,t){s.removeCustomEvent(this,"onFileHasGotPreview",this._onFileHasGotPreview);s.removeCustomEvent(this,"onFileHasNotGotPreview",this._onFileHasNotGotPreview);this._makePreviewImageLoadHandler=s.delegate(function(e){e=this.makePreviewImageWork(e);s.onCustomEvent(this,"onFileHasPreview",[t.id,t,e]);delete this._makePreviewImageLoadHandler;delete this._makePreviewImageFailedHandler},this);this._makePreviewImageFailedHandler=s.delegate(function(e){delete this._makePreviewImageLoadHandler;delete this._makePreviewImageFailedHandler},this);n.push({tmp_url:t.file.url},this._makePreviewImageLoadHandler,this._makePreviewImageFailedHandler)},this);this._onFileHasNotGotPreview=s.delegate(function(e){if(e==this.id){s.removeCustomEvent(this,"onFileHasGotPreview",this._onFileHasGotPreview);s.removeCustomEvent(this,"onFileHasNotGotPreview",this._onFileHasNotGotPreview)}},this);s.addCustomEvent(this,"onFileHasGotPreview",this._onFileHasGotPreview);s.addCustomEvent(this,"onFileHasNotGotPreview",this._onFileHasNotGotPreview);s.onCustomEvent(this.caller,"onFileNeedsPreview",[this.id,this,this.caller])}}return true};s.UploaderImage.prototype.checkPreview=function(){};s.UploaderImage.prototype.applyFile=function(e,t){this.checkPreview();if(!!t&&t.data)this.setProps(t.data);var i=s.UploaderUtils.scaleImage(e,{width:this.limits["uploadFileWidth"],height:this.limits["uploadFileHeight"]}),r=s.UploaderUtils.scaleImage(e,this.fields.preview.params),n={props:{width:r.destin.width,height:r.destin.height},attrs:{className:"bx-bxu-proper-canvas"+(r.destin.width>r.destin.height?" landscape":" portrait")}};if(i.bNeedCreatePicture||!!t){s.adjust(o,{props:{width:i.destin.width,height:i.destin.height}});d=o.getContext("2d");d.drawImage(e,i.source.x,i.source.y,i.source.width,i.source.height,i.destin.x,i.destin.y,i.destin.width,i.destin.height);var h=o.toDataURL(this.file.type);this.file=s.UploaderUtils.dataURLToBlob(h)}this.file.name=this.name;this.file.width=i.destin.width;this.file.height=i.destin.height;s.adjust(this.canvas,n);d=this.canvas.getContext("2d");d.drawImage(e,r.source.x,r.source.y,r.source.width,r.source.height,r.destin.x,r.destin.y,r.destin.width,r.destin.height);d=null;e=null;this.setProps("size");this.status=a.changed};s.UploaderImage.prototype.clickFile=function(){if(!this.canvas||!s["CanvasEditor"]||this.status==a["new"])return false;if(!this.__showEditor){this.__showEditor=s.delegate(this.showEditor,this);this.eFunc={apply:s.delegate(this.applyFile,this),delete:s.delegate(this.deleteFile,this),clear:s.delegate(function(){s.removeCustomEvent(r,"onApplyCanvas",this.eFunc["apply"]);s.removeCustomEvent(r,"onDeleteCanvas",this.eFunc["delete"]);s.removeCustomEvent(r,"onClose",this.eFunc["clear"])},this)}}var e=this.fields.thumb.editorTemplate,t;for(var i in this.fields){if(this.fields.hasOwnProperty(i)){t=i.substr(0,1).toUpperCase()+i.substr(1);e=e.replace("#"+i+"#",i==="preview"?"":'<span id="'+this.id+t+'Editor" class="'+this.fields[i]["className"]+'">'+this.fields[i]["editorTemplate"].replace("#"+i+"#",!!this[i]?s.util.htmlspecialchars(this[i]):"")+"</span>")}}s.adjust(l.getCanvas(),{props:{width:this.file.width,height:this.file.height}});l.getContext().drawImage(this.canvas,0,0,this.canvas.width,this.canvas.height,0,0,l.getCanvas().width,l.getCanvas().height);var r=s.CanvasEditor.show(l.getCanvas(),{title:this.name,template:e});s.addCustomEvent(r,"onApplyCanvas",this.eFunc["apply"]);s.addCustomEvent(r,"onDeleteCanvas",this.eFunc["delete"]);s.addCustomEvent(r,"onClose",this.eFunc["clear"]);s.onCustomEvent(this,"onCanvasEditorIsCreated",[r,this]);l.push(this.file,this.__showEditor);this.editor=r;return false};s.UploaderImage.prototype.showEditor=function(e,t,a,r){s.adjust(t,{props:{width:this.file.width,height:this.file.height}});i(e,t,a,r);this.editor.copyCanvas(t)};s.UploaderImage.prototype.makeCopies=function(e,t,r,n){var h,l,d,u,m=o.getContext("2d");i(e,o,m,n);while((h=this.copies.getNext())&&!!h){l=s.UploaderUtils.scaleImage(o,h);s.adjust(t,{props:{width:l.destin.width,height:l.destin.height}});r.drawImage(o,l.source.x,l.source.y,l.source.width,l.source.height,l.destin.x,l.destin.y,l.destin.width,l.destin.height);d=t.toDataURL(this.file.type);u=s.UploaderUtils.dataURLToBlob(d);u.width=t.width;u.height=t.height;u.name=this.name;u.thumb=h.id;u.canvases=this.copies.length;u.canvas=this.copies.pointer-1;h.file=u}this.preparationStatus=a.done};s.UploaderImage.prototype.getThumbs=function(e){if(e=="getCount")return this.copies.length;var t=typeof e=="string"?this.copies.getItem(e):this.copies.getNext();if(!!t)return t.file;return null};return true})(window);

Zerion Mini Shell 1.0