Files

2 lines
6.7 KiB
JavaScript
Raw Permalink Normal View History

/*! UEditorPlus v2.0.0*/
!function(){function initTabs(){for(var a=$G("tabHeads").children,b=0;b<a.length;b++)domUtils.on(a[b],"click",function(b){for(var c=b.target||b.srcElement,d=0;d<a.length;d++)if(a[d]==c){a[d].className="focus";var e=a[d].getAttribute("data-content-id");$G(e).style.display="block"}else a[d].className="",$G(a[d].getAttribute("data-content-id")).style.display="none"})}function initColorSelector(){var a=editor.queryCommandValue("background");if(a){var b=a["background-color"],c=a["background-repeat"]||"repeat",d=a["background-image"]||"",e=a["background-position"]||"center center",f=e.split(" "),g=parseInt(f[0])||0,h=parseInt(f[1])||0;"no-repeat"==c&&(g||h)&&(c="self"),d=d.match(/url[\s]*\(([^\)]*)\)/),d=d?d[1]:"",updateFormState("colored",b,d,c,g,h)}else updateFormState();var i=function(){updateFormState(),updateBackground()};domUtils.on($G("nocolorRadio"),"click",updateBackground),domUtils.on($G("coloredRadio"),"click",i),domUtils.on($G("url"),"keyup",function(){$G("url").value&&"none"==$G("alignment").style.display&&utils.each($G("repeatType").children,function(a){a.selected="repeat"==a.getAttribute("value")&&"selected"}),i()}),domUtils.on($G("repeatType"),"change",i),domUtils.on($G("x"),"keyup",updateBackground),domUtils.on($G("y"),"keyup",updateBackground),initColorPicker()}function initColorPicker(){var a=editor,b=$G("colorPicker"),c=new UE.ui.Popup({content:new UE.ui.ColorPicker({noColorText:a.getLang("clearColor"),editor:a,onpickcolor:function(a,b){updateFormState("colored",b),updateBackground(),UE.ui.Popup.postHide()},onpicknocolor:function(a,b){updateFormState("colored","transparent"),updateBackground(),UE.ui.Popup.postHide()}}),editor:a,onhide:function(){}});domUtils.on(b,"click",function(){c.showAnchor(this)}),domUtils.on(document,"mousedown",function(a){var b=a.target||a.srcElement;UE.ui.Popup.postHide(b)}),domUtils.on(window,"scroll",function(){UE.ui.Popup.postHide()})}function updateFormState(a,b,c,d,e,f){var g=$G("nocolorRadio"),h=$G("coloredRadio");if(a&&(g.checked="colored"!=a&&"checked",h.checked="colored"==a&&"checked"),b&&domUtils.setStyle($G("colorPicker"),"background-color",b),c&&/^\//.test(c)){var i=document.createElement("a");i.href=c,browser.ie&&(i.href=i.href),c=browser.ie?i.href:i.protocol+"//"+i.host+i.pathname+i.search+i.hash}(c||""===c)&&($G("url").value=c),d&&utils.each($G("repeatType").children,function(a){a.selected=d==a.getAttribute("value")&&"selected"}),(e||f)&&($G("x").value=parseInt(e)||0,$G("y").value=parseInt(f)||0),$G("alignment").style.display=h.checked&&$G("url").value?"":"none",$G("custom").style.display=h.checked&&$G("url").value&&"self"==$G("repeatType").value?"":"none"}function updateBackground(){if($G("coloredRadio").checked){var a=domUtils.getStyle($G("colorPicker"),"background-color"),b=$G("url").value,c=$G("repeatType").value,d={"background-repeat":"no-repeat","background-position":"center center"};a&&(d["background-color"]=a),b&&(d["background-image"]="url("+b+")"),"self"==c?d["background-position"]=$G("x").value+"px "+$G("y").value+"px":"repeat-x"!=c&&"repeat-y"!=c&&"repeat"!=c||(d["background-repeat"]=c),editor.execCommand("background",d)}else editor.execCommand("background",null)}function OnlineImage(a){this.container=utils.isString(a)?document.getElementById(a):a,this.init()}var onlineImage,backupStyle=editor.queryCommandValue("background");window.onload=function(){initTabs(),initColorSelector()},OnlineImage.prototype={init:function(){this.reset(),this.initEvents()},initContainer:function(){this.container.innerHTML="",this.list=document.createElement("ul"),this.clearFloat=document.createElement("li"),domUtils.addClass(this.list,"list"),domUtils.addClass(this.clearFloat,"clearFloat"),this.list.id="imageListUl",this.list.appendChild(this.clearFloat),this.container.appendChild(this.list)},initEvents:function(){var a=this;domUtils.on($G("imageList"),"scroll",function(b){var c=this;c.scrollHeight-(c.offsetHeight+c.scrollTop)<10&&a.getImageData()}),domUtils.on(this.container,"click",function(a){var b=a.target||a.srcElement,c=b.parentNode,d=$G("imageListUl").childNodes;if("li"