!function(){var remoteImage,uploadImage,onlineImage,searchImage;function initTabs(){for(var C=$G("tabhead").children,B=0;B'+"还有2个未上传文件".replace(/[\d]/,A)+""),!1;break;case"online":D=onlineImage.getInsertList();break;case"search":D=searchImage.getInsertList(),B=!0}D&&(editor.execCommand("insertimage",D),B&&editor.fireEvent("catchRemoteImage"))}}function initAlign(){domUtils.on($G("alignIcon"),"click",function(C){var B=C.target||C.srcElement;B.className&&-1!=B.className.indexOf("-align")&&setAlign(B.getAttribute("data-align"))})}function setAlign(C){C=C||"none";var B=$G("alignIcon").children;for(i=0;it.offsetWidth?C:t.offsetWidth-2*A,B=E&&F?C*F/E:"",D&&(t.innerHTML='')},getInsertList:function(){var C=this.getData();return C.url?[{src:C.url,_src:C.url,width:C.width||"",height:C.height||"",border:C.border||"",floatStyle:C.align||"",vspace:C.vhSpace||"",title:C.title||"",alt:C.title||"",style:"width:"+C.width+"px;height:"+C.height+"px;"}]:[]}},UploadImage.prototype={init:function(){this.imageList=[],this.initContainer(),this.initUploader()},initContainer:function(){this.$queue=this.$wrap.find(".filelist")},initUploader:function(){var a,C,B,A=this,s=jQuery,D=A.$wrap,E=D.find(".filelist"),F=D.find(".statusBar"),e=F.find(".info"),t=D.find(".uploadBtn"),n=(D.find(".filePickerBtn"),D.find(".filePickerBlock")),i=D.find(".placeholder"),r=F.find(".progress").hide(),o=0,l=0,d=window.devicePixelRatio||1,c=113*d,u=113*d,h="",g={},p=(C=document.createElement("p").style,B="transition"in C||"WebkitTransition"in C||"MozTransition"in C||"msTransition"in C||"OTransition"in C,C=null,B),m=editor.getActionUrl(editor.getOpt("imageActionName")),f=(editor.getOpt("imageAllowFiles")||[]).join("").replace(/\./g,",").replace(/^[,]/,""),v=editor.getOpt("imageMaxSize"),b=editor.getOpt("imageCompressBorder");function w(D){function E(C){switch(C){case"exceed_size":text=lang.errorExceedSize;break;case"interrupt":text=lang.errorInterrupt;break;case"http":text=lang.errorHttp;break;case"not_allow_type":text=lang.errorFileType;break;default:text=lang.errorUploadRetry}i.text(text).show()}var F=s('
  • '+D.name+'

  • '),A=s('
    '+lang.uploadDelete+''+lang.uploadTurnRight+''+lang.uploadTurnLeft+"
    ").appendTo(F),e=F.find("p.progress span"),t=F.find("p.imgWrap"),i=s('

    ').hide().appendTo(F);"invalid"===D.getStatus()?E(D.statusText):(t.text(lang.uploadPreview),browser.ie&&browser.version<=7?t.text(lang.uploadNoPreview):a.makeThumb(D,function(C,B){if(C||!B)t.text(lang.uploadNoPreview);else{var D=s('');t.empty().append(D),D.on("error",function(){t.text(lang.uploadNoPreview)})}},c,u),g[D.id]=[D.size,0],D.rotation=0,D.ext&&-1!=f.indexOf(D.ext.toLowerCase())||(E("not_allow_type"),a.removeFile(D))),D.on("statuschange",function(C,B){"progress"===B?e.hide().width(0):"queued"===B&&(F.off("mouseenter mouseleave"),A.remove()),"error"===C||"invalid"===C?(E(D.statusText),g[D.id][1]=1):"interrupt"===C?E("interrupt"):"queued"===C?g[D.id][1]=0:"progress"===C&&(i.hide(),e.css("display","block")),F.removeClass("state-"+B).addClass("state-"+C)}),F.on("mouseenter",function(){A.stop().animate({height:30})}),F.on("mouseleave",function(){A.stop().animate({height:0})}),A.on("click","span",function(){var C;switch(s(this).index()){case 0:return void a.removeFile(D);case 1:D.rotation+=90;break;case 2:D.rotation-=90}p?(C="rotate("+D.rotation+"deg)",t.css({"-webkit-transform":C,"-mos-transform":C,"-o-transform":C,transform:C})):t.css("filter","progid:DXImageTransform.Microsoft.BasicImage(rotation="+~~(D.rotation/90%4+4)%4+")")}),F.insertBefore(n)}function I(){var C,D=0,E=0,B=r.children();s.each(g,function(C,B){E+=B[0],D+=B[0]*B[1]}),C=E?D/E:0,B.eq(0).text(Math.round(100*C)+"%"),B.eq(1).css("width",Math.round(100*C)+"%"),$()}function x(C){if(C!=h){var B=a.getStats();switch(t.removeClass("state-"+h),t.addClass("state-"+C),C){case"pedding":E.addClass("element-invisible"),F.addClass("element-invisible"),i.removeClass("element-invisible"),r.hide(),e.hide(),a.refresh();break;case"ready":i.addClass("element-invisible"),E.removeClass("element-invisible"),F.removeClass("element-invisible"),r.hide(),e.show(),t.text(lang.uploadStart),a.refresh();break;case"uploading":r.show(),e.hide(),t.text(lang.uploadPause);break;case"paused":r.show(),e.hide(),t.text(lang.uploadContinue);break;case"confirm":if(r.show(),e.hide(),t.text(lang.uploadStart),(B=a.getStats()).successNum&&!B.uploadFailNum)return void x("finish");break;case"finish":r.hide(),e.show(),B.uploadFailNum?t.text(lang.uploadRetry):t.text(lang.uploadStart)}h=C,$()}A.getQueueCount()?t.removeClass("disabled"):t.addClass("disabled")}function $(){var C,B="";"ready"===h?B=lang.updateStatusReady.replace("_",o).replace("_KB",WebUploader.formatSize(l)):"confirm"===h?(C=a.getStats()).uploadFailNum&&(B=lang.updateStatusConfirm.replace("_",C.successNum).replace("_",C.successNum)):(C=a.getStats(),B=lang.updateStatusFinish.replace("_",o).replace("_KB",WebUploader.formatSize(l)).replace("_",C.successNum),C.uploadFailNum&&(B+=lang.updateStatusError.replace("_",C.uploadFailNum))),e.html(B)}WebUploader.Uploader.support()?editor.getOpt("imageActionName")?((a=A.uploader=WebUploader.create({pick:{id:"#filePickerReady",label:lang.uploadSelectFile},accept:{title:"Images",extensions:f,mimeTypes:"image/*"},swf:"../../third-party/webuploader/Uploader.swf",server:m,fileVal:editor.getOpt("imageFieldName"),duplicate:!0,fileSingleSizeLimit:v,compress:!!editor.getOpt("imageCompressEnable")&&{width:b,height:b,quality:90,allowMagnify:!1,crop:!1,preserveHeaders:!0}})).addButton({id:"#filePickerBlock"}),a.addButton({id:"#filePickerBtn",label:lang.uploadAddFile}),x("pedding"),a.on("fileQueued",function(C){o++,l+=C.size,1===o&&(i.addClass("element-invisible"),F.show()),w(C)}),a.on("fileDequeued",function(C){var B,D;o--,l-=C.size,D=s("#"+(B=C).id),delete g[B.id],I(),D.off().find(".file-panel").off().end().remove(),I()}),a.on("filesQueued",function(C){a.isInProgress()||"pedding"!=h&&"finish"!=h&&"confirm"!=h&&"ready"!=h||x("ready"),I()}),a.on("all",function(C,B){switch(C){case"uploadFinished":x("confirm");break;case"startUpload":var D=utils.serializeParam(editor.queryCommandValue("serverparam"))||"",E=utils.formatUrl(m+(-1==m.indexOf("?")?"?":"&")+"encode=utf-8&"+D);a.option("server",E),x("uploading");break;case"stopUpload":x("paused")}}),a.on("uploadBeforeSend",function(C,B,D){D.X_Requested_With="XMLHttpRequest"}),a.on("uploadProgress",function(C,B){s("#"+C.id).find(".progress span").css("width",100*B+"%"),g[C.id][1]=B,I()}),a.on("uploadSuccess",function(C,B){var D=s("#"+C.id);try{var E=B._raw||B,F=utils.str2json(E);"SUCCESS"==F.state?(A.imageList.push(F),D.append('')):D.find(".error").text(F.state).show()}catch(C){D.find(".error").text(lang.errorServerUpload).show()}}),a.on("uploadError",function(C,B){}),a.on("error",function(C,B){"Q_TYPE_DENIED"!=C&&"F_EXCEED_SIZE"!=C||w(B)}),a.on("uploadComplete",function(C,B){}),t.on("click",function(){if(s(this).hasClass("disabled"))return!1;"ready"===h||"paused"===h?a.upload():"uploading"===h&&a.stop()}),t.addClass("state-"+h),I()):s("#filePickerReady").after(s("
    ").html(lang.errorLoadConfig)).hide():s("#filePickerReady").after(s("
    ").html(lang.errorNotSupport)).hide()},getQueueCount:function(){var C,B,D,E=0,F=this.uploader.getFiles();for(B=0;C=F[B++];)"queued"!=(D=C.getStatus())&&"uploading"!=D&&"progress"!=D||E++;return E},destroy:function(){this.$wrap.remove()},getInsertList:function(){var C,B,D=[],E=getAlign(),F=editor.getOpt("imageUrlPrefix");for(C=0;C=json.total&&(_this.listEnd=!0),_this.isLoadingData=!1)}catch(C){if(-1!=r.responseText.indexOf("ue_separate_ue")){var list=r.responseText.split(r.responseText);_this.pushData(list),_this.listIndex=parseInt(list.length),_this.listEnd=!0,_this.isLoadingData=!1}}},onerror:function(){_this.isLoadingData=!1}})}},pushData:function(C){var B,D,E,F,A=this,e=editor.getOpt("imageManagerUrlPrefix");for(B=0;B