You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
99 KiB
1 line
99 KiB
5 months ago
|
!function(){var remoteImage,uploadImage,onlineImage,searchImage;function initTabs(){for(var C=$G("tabhead").children,B=0;B<C.length;B++)domUtils.on(C[B],"click",function(C){setTabFocus((C.target||C.srcElement).getAttribute("data-content-id"))});var D=editor.selection.getRange().getClosedNode();D&&D.tagName&&"img"==D.tagName.toLowerCase()?setTabFocus("remote"):setTabFocus("upload")}function setTabFocus(C){if(C){var B,D,E=$G("tabhead").children;for(B=0;B<E.length;B++)(D=E[B].getAttribute("data-content-id"))==C?(domUtils.addClass(E[B],"focus"),domUtils.addClass($G(D),"focus")):(domUtils.removeClasses(E[B],"focus"),domUtils.removeClasses($G(D),"focus"));switch(C){case"remote":remoteImage=remoteImage||new RemoteImage;break;case"upload":setAlign(editor.getOpt("imageInsertAlign")),uploadImage=uploadImage||new UploadImage("queueList");break;case"online":setAlign(editor.getOpt("imageManagerInsertAlign")),(onlineImage=onlineImage||new OnlineImage("imageList")).reset();break;case"search":setAlign(editor.getOpt("imageManagerInsertAlign")),searchImage=searchImage||new SearchImage}}}function initButtons(){dialog.onok=function(){for(var C,B=!1,D=[],E=$G("tabhead").children,F=0;F<E.length;F++)if(domUtils.hasClass(E[F],"focus")){C=E[F].getAttribute("data-content-id");break}switch(C){case"remote":D=remoteImage.getInsertList();break;case"upload":D=uploadImage.getInsertList();var A=uploadImage.getQueueCount();if(A)return $(".info","#queueList").html('<span style="color:red;">'+"还有2个未上传文件".replace(/[\d]/,A)+"</span>"),!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;i<B.length;i++)B[i].getAttribute("data-align")==C?(domUtils.addClass(B[i],"focus"),$G("align").value=B[i].getAttribute("data-align")):domUtils.removeClasses(B[i],"focus")}function getAlign(){var C=$G("align").value||"none";return"none"==C?"":C}function RemoteImage(C){this.container=utils.isString(C)?document.getElementById(C):C,this.init()}function UploadImage(C){this.$wrap=C.constructor==String?$("#"+C):$(C),this.init()}function OnlineImage(C){this.container=utils.isString(C)?document.getElementById(C):C,this.init()}function SearchImage(){this.init()}window.onload=function(){initTabs(),initAlign(),initButtons()},RemoteImage.prototype={init:function(){this.initContainer(),this.initEvents()},initContainer:function(){this.dom={url:$G("url"),width:$G("width"),height:$G("height"),border:$G("border"),vhSpace:$G("vhSpace"),title:$G("title"),align:$G("align")};var C=editor.selection.getRange().getClosedNode();C&&this.setImage(C)},initEvents:function(){var B=this,D=$G("lock");function E(){B.setPreview()}domUtils.on($G("url"),"keyup",E),domUtils.on($G("border"),"keyup",E),domUtils.on($G("title"),"keyup",E),domUtils.on($G("width"),"keyup",function(){if(E(),D.checked){var C=D.getAttribute("data-proportion");$G("height").value=Math.round(this.value/C)}else B.updateLocker()}),domUtils.on($G("height"),"keyup",function(){if(E(),D.checked){var C=D.getAttribute("data-proportion");$G("width").value=Math.round(this.value*C)}else B.updateLocker()}),domUtils.on($G("lock"),"change",function(){var C=parseInt($G("width").value)/parseInt($G("height").value);D.setAttribute("data-proportion",C)})},updateLocker:function(){var C=$G("width").value,B=$G("height").value,D=$G("lock");C&&B&&C==parseInt(C)&&B==parseInt(B)?(D.disabled=!1,D.title=""):(D.checked=!1,D.disabled="disabled",D.title=lang.remoteLockError)},setImage:function(C){if(C.tagName&&("img"==C.tagName.toLowerCase()||C.getAttribute("src"))&&C.src){var B=C.getAttribute("word_img"),D=B?B.replace("&","&"):C.getAttribute("_src")||C.getAttribute("src",2).replace("&","&"),E=editor.queryCommandValue("imageFloat");D!==$G("url").value&&($G("url
|