iotgateway/IoTGateway/wwwroot/layuiadmin/ueditor/dialogs/background/background.js

2 lines
6.9 KiB
JavaScript
Raw Permalink Normal View History

2021-12-12 06:55:48 +00:00
/** layuiAdmin.pro-v1.2.1 LPPL License By http://www.layui.com/admin/ */
;!function(){function initTabs(){for(var t=$G("tabHeads").children,e=0;e<t.length;e++)domUtils.on(t[e],"click",function(e){for(var i=e.target||e.srcElement,o=0;o<t.length;o++)if(t[o]==i){t[o].className="focus";var n=t[o].getAttribute("data-content-id");$G(n).style.display="block","imgManager"==n&&initImagePanel()}else t[o].className="",$G(t[o].getAttribute("data-content-id")).style.display="none"})}function initColorSelector(){var t=editor.queryCommandValue("background");if(t){var e=t["background-color"],i=t["background-repeat"]||"repeat",o=t["background-image"]||"",n=t["background-position"]||"center center",a=n.split(" "),r=parseInt(a[0])||0,s=parseInt(a[1])||0;"no-repeat"==i&&(r||s)&&(i="self"),o=o.match(/url[\s]*\(([^\)]*)\)/),o=o?o[1]:"",updateFormState("colored",e,o,i,r,s)}else updateFormState();var l=function(){updateFormState(),updateBackground()};domUtils.on($G("nocolorRadio"),"click",updateBackground),domUtils.on($G("coloredRadio"),"click",l),domUtils.on($G("url"),"keyup",function(){$G("url").value&&"none"==$G("alignment").style.display&&utils.each($G("repeatType").children,function(t){t.selected="repeat"==t.getAttribute("value")&&"selected"}),l()}),domUtils.on($G("repeatType"),"change",l),domUtils.on($G("x"),"keyup",updateBackground),domUtils.on($G("y"),"keyup",updateBackground),initColorPicker()}function initColorPicker(){var t=editor,e=$G("colorPicker"),i=new UE.ui.Popup({content:new UE.ui.ColorPicker({noColorText:t.getLang("clearColor"),editor:t,onpickcolor:function(t,e){updateFormState("colored",e),updateBackground(),UE.ui.Popup.postHide()},onpicknocolor:function(t,e){updateFormState("colored","transparent"),updateBackground(),UE.ui.Popup.postHide()}}),editor:t,onhide:function(){}});domUtils.on(e,"click",function(){i.showAnchor(this)}),domUtils.on(document,"mousedown",function(t){var e=t.target||t.srcElement;UE.ui.Popup.postHide(e)}),domUtils.on(window,"scroll",function(){UE.ui.Popup.postHide()})}function initImagePanel(){onlineImage=onlineImage||new OnlineImage("imageList")}function updateFormState(t,e,i,o,n,a){var r=$G("nocolorRadio"),s=$G("coloredRadio");if(t&&(r.checked="colored"!=t&&"checked",s.checked="colored"==t&&"checked"),e&&domUtils.setStyle($G("colorPicker"),"background-color",e),i&&/^\//.test(i)){var l=document.createElement("a");l.href=i,browser.ie&&(l.href=l.href),i=browser.ie?l.href:l.protocol+"//"+l.host+l.pathname+l.search+l.hash}(i||""===i)&&($G("url").value=i),o&&utils.each($G("repeatType").children,function(t){t.selected=o==t.getAttribute("value")&&"selected"}),(n||a)&&($G("x").value=parseInt(n)||0,$G("y").value=parseInt(a)||0),$G("alignment").style.display=s.checked&&$G("url").value?"":"none",$G("custom").style.display=s.checked&&$G("url").value&&"self"==$G("repeatType").value?"":"none"}function updateBackground(){if($G("coloredRadio").checked){var t=domUtils.getStyle($G("colorPicker"),"background-color"),e=$G("url").value,i=$G("repeatType").value,o={"background-repeat":"no-repeat","background-position":"center center"};t&&(o["background-color"]=t),e&&(o["background-image"]="url("+e+")"),"self"==i?o["background-position"]=$G("x").value+"px "+$G("y").value+"px":"repeat-x"!=i&&"repeat-y"!=i&&"repeat"!=i||(o["background-repeat"]=i),editor.execCommand("background",o)}else editor.execCommand("background",null)}function OnlineImage(t){this.container=utils.isString(t)?document.getElementById(t):t,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 t=this;domUtils.on($G("imageList"),"scroll",function(e){var i=this;i.scrollHeight-(i.offsetHeight+i.scrollTop)<10&&t.getImageData()}),domUtils.on(t