text: !function(){function e(){for(var e=$G("tabHeads").children,t=0;t<e.length;t++)domUtils.on(e[t],"click",function(t){var i,a,r=t.target||t.srcElement;for(i=0;i<e.length;i++)a=e[i].getAttribute("data-content-id"),e[i]==r?(domUtils.addClass(e[i],"focus"),domUtils.addClass($G(a),"focus")):(domUtils.removeClasses(e[i],"focus"),domUtils.removeClasses($G(a),"focus"))})}function t(){u(["videoFloat","upload_alignment"]),p($G("videoUrl")),i(),function(){var e,t=editor.selection.getRange().getClosedNode();if(t&&t.className){var i="edui-faked-video"==t.className,r=-1!=t.className.indexOf("edui-upload-video");if(i||r){$G("videoUrl").value=e=t.getAttribute("_url"),$G("videoWidth").value=t.width,$G("videoHeight").value=t.height;var n=domUtils.getComputedStyle(t,"float");a("center"===domUtils.getComputedStyle(t.parentNode,"text-align")?"center":n)}r&&(b=!0)}f(e)}()}function i(){dialog.onok=function(){switch($G("preview").innerHTML="",o("tabHeads","tabSrc")){case"video":return r();case"videoSearch":return n("searchList");case"upload":return v()}},dialog.oncancel=function(){$G("preview").innerHTML=""}}function a(e){for(var t,i=$G("videoFloat").children,a=0;t=i[a++];)t.getAttribute("name")==e?"focus"!=t.className&&(t.className="focus"):"focus"==t.className&&(t.className="")}function r(){var e=$G("videoWidth"),t=$G("videoHeight"),i=$G("videoUrl").value,a=o("videoFloat","name");return!!i&&(!!l([e,t])&&void editor.execCommand("insertvideo",{url:s(i),width:e.value,height:t.value,align:a},b?"upload":null))}function n(e){for(var t,i=domUtils.getElementsByTagName($G(e),"img"),a=[],r=0;t=i[r++];)t.getAttribute("selected")&&a.push({url:t.getAttribute("ue_video_url"),width:420,height:280,align:"none"});editor.execCommand("insertvideo",a)}function o(e,t){for(var i,a,r=$G(e).children,n=0;a=r[n++];)if("focus"==a.className){i=a.getAttribute(t);break}return i}function s(e){return e?e=utils.trim(e).replace(/v\.youku\.com\/v_show\/id_([\w\-=]+)\.html/i,"player.youku.com/embed/$1").replace(/v\.qq\.com\/x\/cover\/[\w]+\/([\w]+)\.html/i,"v.qq.com/iframe/player.html?vid=$1&tiny=0&auto=0"):""}function l(e){for(var t,i=0;t=e[i++];){var a=t.value;if(!d(a)&&a)return alert(lang.numError),t.value="",t.focus(),!1}return!0}function d(e){return/(0|^[1-9]\d*$)/.test(e)}function u(e){for(var t,i=0;t=e[i++];){var a=$G(t),r={none:lang.default,left:lang.floatLeft,right:lang.floatRight,center:lang.block};for(var n in r){var o=document.createElement("div");o.setAttribute("name",n),"none"==n&&(o.className="focus"),o.style.cssText="background:url(images/"+n+"_focus.jpg);",o.setAttribute("title",r[n]),a.appendChild(o)}c(t)}}function c(e){for(var t,i=$G(e).children,a=0;t=i[a++];)domUtils.on(t,"click",function(){for(var e,t=0;e=i[t++];)e.className="",e.removeAttribute&&e.removeAttribute("class");this.className="focus"})}function p(e){browser.ie?e.onpropertychange=function(){f(this.value)}:e.addEventListener("input",function(){f(this.value)},!1)}function f(e){if(e){var t=s(e);t=utils.unhtmlForUrl(t),$G("preview").innerHTML='<div class="previewMsg"><span>'+lang.urlError+'</span></div><iframe class="previewVideo"  src="'+t+'" width="420" height="280" frameborder=0 allowfullscreen></iframe>'}}function v(){var e=[],t=editor.getOpt("videoUrlPrefix"),i=parseInt($G("upload_width").value,10)||420,a=parseInt($G("upload_height").value,10)||280,r=o("upload_alignment","name")||"none";for(var n in w){var s=w[n];e.push({url:t+s.url,width:i,height:a,align:r})}var l=h.getQueueCount();if(l)return $(".info","#queueList").html('<span style="color:red;">'+"还有2个未上传文件".replace(/[\d]/,l)+"</span>"),!1;editor.execCommand("insertvideo",e,"upload")}function m(){h=new g("queueList")}function g(e){this.$wrap=e.constructor==String?$("#"+e):$(e),this.init()}var h,w=[],b=!1;window.onload=function(){try{window.parent.callback.videoWidgetSelectVideo&&($G("videoSelect").style.display="inline-block",$G("videoSelect").addEventListener("click",function(){window.parent.callback.videoWidgetSelectVideo(function(e){$G("videoUrl").value=e[0],f(e[0])})}))}catch(e){}$focus($G("videoUrl")),e(),t(),m()},g.prototype={init:function(){this.fileList=[],this.initContainer(),this.initUploader()},initContainer:function(){this.$queue=this.$wrap.find(".filelist")},initUploader:function(){function e(e){var t=s('<li id="'+e.id+'"><p class="title">'+e.name+'</p><p class="imgWrap"></p><p class="progress"><span></span></p></li>'),i=s('<div class="file-panel"><span class="cancel">'+lang.uploadDelete+'</span><span class="rotateRight">'+lang.uploadTurnRight+'</span><span class="rotateLeft">'+lang.uploadTurnLeft+"</span></div>").appendTo(t),a=t.find("p.progress span"),r=t.find("p.imgWrap"),o=s('<p class="error"></p>').hide().appendTo(t),l=function(e){switch(e){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}o.text(text).show()};"invalid"===e.getStatus()?l(e.statusText):(r.text(lang.uploadPreview),-1=="|png|jpg|jpeg|bmp|gif|".indexOf("|"+e.ext.toLowerCase()+"|")?r.empty().addClass("notimage").append('<i class="file-preview file-type-'+e.ext.toLowerCase()+'"></i><span class="file-title">'+e.name+"</span>"):browser.ie&&browser.version<=7?r.text(lang.uploadNoPreview):n.makeThumb(e,function(e,t){if(e||!t||/^data:/.test(t)&&browser.ie&&browser.version<=7)r.text(lang.uploadNoPreview);else{var i=s('<img src="'+t+'">');r.empty().append(i),i.on("error",function(){r.text(lang.uploadNoPreview)})}},C,x),y[e.id]=[e.size,0],e.rotation=0,e.ext&&-1!=U.indexOf(e.ext.toLowerCase())||(l("not_allow_type"),n.removeFile(e))),e.on("statuschange",function(r,n){"progress"===n?a.hide().width(0):"queued"===n&&(t.off("mouseenter mouseleave"),i.remove()),"error"===r||"invalid"===r?(l(e.statusText),y[e.id][1]=1):"interrupt"===r?l("interrupt"):"queued"===r?y[e.id][1]=0:"progress"===r&&(o.hide(),a.css("display","block")),t.removeClass("state-"+n).addClass("state-"+r)}),t.on("mouseenter",function(){i.stop().animate({height:30})}),t.on("mouseleave",function(){i.stop().animate({height:0})}),i.on("click","span",function(){var t,i=s(this).index();switch(i){case 0:return void n.removeFile(e);case 1:e.rotation+=90;break;case 2:e.rotation-=90}S?(t="rotate("+e.rotation+"deg)",r.css({"-webkit-transform":t,"-mos-transform":t,"-o-transform":t,transform:t})):r.css("filter","progid:DXImageTransform.Microsoft.BasicImage(rotation="+~~(e.rotation/90%4+4)%4+")")}),t.insertBefore(f)}function t(e){var t=s("#"+e.id);delete y[e.id],i(),t.off().find(".file-panel").off().end().remove()}function i(){var e,t=0,i=0,a=m.children();s.each(y,function(e,a){i+=a[0],t+=a[0]*a[1]}),e=i?t/i:0,a.eq(0).text(Math.round(100*e)+"%"),a.eq(1).css("width",Math.round(100*e)+"%"),r()}function a(e,t){if(e!=k){var i=n.getStats();switch(p.removeClass("state-"+k),p.addClass("state-"+e),e){case"pedding":d.addClass("element-invisible"),u.addClass("element-invisible"),v.removeClass("element-invisible"),m.hide(),c.hide(),n.refresh();break;case"ready":v.addClass("element-invisible"),d.removeClass("element-invisible"),u.removeClass("element-invisible"),m.hide(),c.show(),p.text(lang.uploadStart),n.refresh();break;case"uploading":m.show(),c.hide(),p.text(lang.uploadPause);break;case"paused":m.show(),c.hide(),p.text(lang.uploadContinue);break;case"confirm":if(m.show(),c.hide(),p.text(lang.uploadStart),i=n.getStats(),i.successNum&&!i.uploadFailNum)return void a("finish");break;case"finish":m.hide(),c.show(),i.uploadFailNum?p.text(lang.uploadRetry):p.text(lang.uploadStart)}k=e,r()}o.getQueueCount()?p.removeClass("disabled"):p.addClass("disabled")}function r(){var e,t="";"ready"===k?t=lang.updateStatusReady.replace("_",g).replace("_KB",WebUploader.formatSize(h)):"confirm"===k?(e=n.getStats(),e.uploadFailNum&&(t=lang.updateStatusConfirm.replace("_",e.successNum).replace("_",e.successNum))):(e=n.getStats(),t=lang.updateStatusFinish.replace("_",g).replace("_KB",WebUploader.formatSize(h)).replace("_",e.successNum),e.uploadFailNum&&(t+=lang.updateStatusError.replace("_",e.uploadFailNum))),c.html(t)}var n,o=this,s=jQuery,l=o.$wrap,d=l.find(".filelist"),u=l.find(".statusBar"),c=u.find(".info"),p=l.find(".uploadBtn"),f=(l.find(".filePickerBtn"),l.find(".filePickerBlock")),v=l.find(".placeholder"),m=u.find(".progress").hide(),g=0,h=0,b=window.devicePixelRatio||1,C=113*b,x=113*b,k="",y={},S=function(){var e=document.createElement("p").style,t="transition"in e||"WebkitTransition"in e||"MozTransition"in e||"msTransition"in e||"OTransition"in e;return e=null,t}(),$=editor.getActionUrl(editor.getOpt("videoActionName")),N=editor.getOpt("videoMaxSize"),U=(editor.getOpt("videoAllowFiles")||[]).join("").replace(/\./g,",").replace(/^[,]/,"");return WebUploader.Uploader.support()?editor.getOpt("videoActionName")?(n=o.uploader=WebUploader.create({pick:{id:"#filePickerReady",label:lang.uploadSelectFile},swf:"../../third-party/webuploader/Uploader.swf",server:$,fileVal:editor.getOpt("videoFieldName"),duplicate:!0,fileSingleSizeLimit:N,compress:!1}),n.addButton({id:"#filePickerBlock"}),n.addButton({id:"#filePickerBtn",label:lang.uploadAddFile}),a("pedding"),n.on("fileQueued",function(t){g++,h+=t.size,1===g&&(v.addClass("element-invisible"),u.show()),e(t)}),n.on("fileDequeued",function(e){g--,h-=e.size,t(e),i()}),n.on("filesQueued",function(e){n.isInProgress()||"pedding"!=k&&"finish"!=k&&"confirm"!=k&&"ready"!=k||a("ready"),i()}),n.on("all",function(e,t){switch(e){case"uploadFinished":a("confirm",t);break;case"startUpload":var i=utils.serializeParam(editor.queryCommandValue("serverparam"))||"",r=utils.formatUrl($+(-1==$.indexOf("?")?"?":"&")+"encode=utf-8&"+i);n.option("server",r),a("uploading",t);break;case"stopUpload":a("paused",t)}}),n.on("uploadBeforeSend",function(e,t,i){i.X_Requested_With="XMLHttpRequest"}),n.on("uploadProgress",function(e,t){s("#"+e.id).find(".progress span").css("width",100*t+"%"),y[e.id][1]=t,i()}),n.on("uploadSuccess",function(e,t){var i=s("#"+e.id);try{var a=t._raw||t,r=utils.str2json(a);"SUCCESS"==r.state?(w.push({url:r.url,type:r.type,original:r.original}),i.append('<span class="success"></span>')):i.find(".error").text(r.state).show()}catch(e){i.find(".error").text(lang.errorServerUpload).show()}}),n.on("uploadError",function(e,t){}),n.on("error",function(t,i){"Q_TYPE_DENIED"!=t&&"F_EXCEED_SIZE"!=t||e(i)}),n.on("uploadComplete",function(e,t){}),p.on("click",function(){if(s(this).hasClass("disabled"))return!1;"ready"===k?n.upload():"paused"===k?n.upload():"uploading"===k&&n.stop()}),p.addClass("state-"+k),void i()):void s("#filePickerReady").after(s("<div>").html(lang.errorLoadConfig)).hide():void s("#filePickerReady").after(s("<div>").html(lang.errorNotSupport)).hide()},getQueueCount:function(){var e,t,i,a=0,r=this.uploader.getFiles();for(t=0;e=r[t++];)"queued"!=(i=e.getStatus())&&"uploading"!=i&&"progress"!=i||a++;return a},refresh:function(){this.uploader.refresh()}}}();