Files

2 lines
12 KiB
JavaScript
Raw Permalink Normal View History

/*! UEditorPlus v2.0.0*/
!function(){function a(){for(var a=$G("tabHeads").children,b=0;b<a.length;b++)domUtils.on(a[b],"click",function(b){var c,d,e=b.target||b.srcElement;for(c=0;c<a.length;c++)d=a[c].getAttribute("data-content-id"),a[c]==e?(domUtils.addClass(a[c],"focus"),domUtils.addClass($G(d),"focus")):(domUtils.removeClasses(a[c],"focus"),domUtils.removeClasses($G(d),"focus"))});u.disableUpload||($G("tabHeads").querySelector('[data-content-id="upload"]').style.display="inline-block"),u.selectCallback&&($G("videoSelect").style.display="inline-block",domUtils.on($G("videoSelect"),"click",function(a){u.selectCallback(editor,function(a){a&&($G("videoUrl").value=a.path,n(a.path))})}))}function b(){k(["videoFloat","upload_alignment"]),m($G("videoUrl")),c(),function(){var a,b=editor.selection.getRange().getClosedNode();if(b&&b.className){var c="edui-faked-video"==b.className,e=b.className.indexOf("edui-upload-video")!=-1;if(c||e){$G("videoUrl").value=a=b.getAttribute("_url"),$G("videoWidth").value=b.width,$G("videoHeight").value=b.height;var f=domUtils.getComputedStyle(b,"float"),g=domUtils.getComputedStyle(b.parentNode,"text-align");d("center"===g?"center":f)}e&&(t=!0)}n(a)}()}function c(){dialog.onok=function(){$G("preview").innerHTML="";var a=g("tabHeads","tabSrc");switch(a){case"video":return e();case"videoSearch":return f("searchList");case"upload":return o()}},dialog.oncancel=function(){$G("preview").innerHTML=""}}function d(a){for(var b,c=$G("videoFloat").children,d=0;b=c[d++];)b.getAttribute("name")==a?"focus"!=b.className&&(b.className="focus"):"focus"==b.className&&(b.className="")}function e(){var a=$G("videoWidth"),b=$G("videoHeight"),c=$G("videoUrl").value,d=g("videoFloat","name");return!!c&&(!!i([a,b])&&void editor.execCommand("insertvideo",{url:h(c),width:a.value,height:b.value,align:d},t?"upload":null))}function f(a){for(var b,c=domUtils.getElementsByTagName($G(a),"img"),d=[],e=0;b=c[e++];)b.getAttribute("selected")&&d.push({url:b.getAttribute("ue_video_url"),width:420,height:280,align:"none"});editor.execCommand("insertvideo",d)}function g(a,b){for(var c,d,e=$G(a).children,f=0;d=e[f++];)if("focus"==d.className){c=d.getAttribute(b);break}return c}function h(a){return a?a=utils.trim(a).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").replace(/v\.qq\.com\/x\/page\/([\w]+)\.html/i,"v.qq.com/iframe/player.html?vid=$1&tiny=0&auto=0").replace(/www\.bilibili\.com\/video\/([a-zA-Z0-9]+)\/?.*$/i,"player.bilibili.com/player.html?bvid=$1"):""}function i(a){for(var b,c=0;b=a[c++];){var d=b.value;if(!j(d)&&d)return alert(lang.numError),b.value="",b.focus(),!1}return!0}function j(a){return/(0|^[1-9]\d*$)/.test(a)}function k(a){for(var b,c=0;b=a[c++];){var d=$G(b),e={none:lang["default"],left:lang.floatLeft,right:lang.floatRight,center:lang.block};for(var f in e){var g=document.createElement("div");g.setAttribute("name",f),"none"==f&&(g.className="focus"),g.style.cssText="background:url(images/"+f+"_focus.jpg);",g.setAttribute("title",e[f]),d.appendChild(g)}l(b)}}function l(a){for(var b,c=$G(a).children,d=0;b=c[d++];)domUtils.on(b,"click",function(){for(var a,b=0;a=c[b++];)a.className="",a.removeAttribute&&a.removeAttribute("class");this.className="focus"})}function m(a){browser.ie?a.onpropertychange=function(){n(this.value)}:a.addEventListener("input",function(){n(this.value)},!1)}function n(a){if(a){var b=h(a);b=utils.unhtml(b),$G("preview").innerHTML='<div class="previewMsg"><span>'+lang.urlError+'</span></div><iframe class="previewVideo" src="'+b+'" width="420" height="280" frameborder=0 allowfullscreen></iframe>'}}function o(){var a=[],b=editor.getOpt("videoUrlPrefix"),c=$G("upload_width").value||420,d=$G("upload_height").value||280,e=g("upload_alignment","name")||"none";for(var f in s){var h=s[f];a.push({url:b+h.url,width:c,height:d,align:e})}var i=r.getQueueCount();return i?($(".info","#queueList").html('<span style="color:red;">'+"还有2个未上传文件".replace(/[\d]/,i)+"</span>"),!1):void ed