" var oDoc=idPreview.document.open("text/html", "replace"); if(obj.publishingPath!="") oDoc.write("" + sHTML); else oDoc.write(sHTML); oDoc.close(); realTime() } function realTime() { var idPreview = document.getElementById("idPreview").contentWindow; var inpCssText = document.getElementById("inpCssText"); var inpClassName = document.getElementById("inpClassName"); var selApply_to = document.getElementById("selApply_to"); var oEditor=window.opener.oUtil.oEditor; var oSel=oEditor.getSelection(); var isTextSel = window.opener.isTextSelected(oSel); var oElement; if(window.opener.oUtil.activeElement) oElement=window.opener.oUtil.activeElement else oElement = window.opener.getSelectedElement(oSel); if (!isTextSel) selApply_to.value = "Current Tag"; //selApply_to.value = (isTextSel) ? "Selected Text" : "Current Tag"; var tagName=oElement.nodeName; if(tagName=="TD") idPreview.document.getElementById("idPreviewTarget").innerHTML="" + window.opener.getOuterHTML(oElement) + "
" else idPreview.document.getElementById("idPreviewTarget").innerHTML=window.opener.getOuterHTML(oElement); inpCssText.value=oElement.style.cssText inpClassName.value=oElement.className; } function doApply() { var idPreview = document.getElementById("idPreview").contentWindow; var inpCssText = document.getElementById("inpCssText"); var inpClassName = document.getElementById("inpClassName"); var selApply_to = document.getElementById("selApply_to"); var oEditor=window.opener.oUtil.oEditor; var oSel=oEditor.getSelection(); var obj=window.opener.oUtil.obj; window.opener.oUtil.obj.saveForUndo(); var oElement; if(inpCssText.value=="" && inpClassName.value=="")//Selalu berarti me-remove style & class di CURRENT TAG! { oElement = window.opener.getSelectedElement(oSel); if(oElement) { if(oElement.tagName!="BODY") { oElement.removeAttribute("style"); oElement.removeAttribute("className"); if(oElement.tagName=="FONT" && oElement.color=="" && oElement.face=="" && oElement.size=="" && oElement.id=="") obj.doCmd('RemoveFormat'); } else { alert(getText("You're selecting BODY element.")); return; } } } else if(selApply_to.value=="Selected Text") { if (!window.opener.isTextSelected(oSel)) { alert(getText("Please select a text.")); return; } var idNewSpan=obj.applySpan(); if(idNewSpan)//if there is selected text { if(inpCssText.value=="") idNewSpan.removeAttribute("style");//jadi kalo CSS Text input dibuat empty, tetap akan melakukan remove else idNewSpan.style.cssText=inpCssText.value; if(inpClassName.value=="") idNewSpan.removeAttribute("className"); else idNewSpan.className=inpClassName.value; } } else if(selApply_to.value=="Current Tag") { if(window.opener.oUtil.activeElement) { oElement=window.opener.oUtil.activeElement } else { oElement = window.opener.getSelectedElement(oSel); } if(oElement) { if(oElement.tagName!="BODY") { if(inpCssText.value=="") oElement.removeAttribute("style"); else oElement.style.cssText=inpCssText.value; if(inpClassName.value=="") oElement.removeAttribute("className"); else oElement.className=inpClassName.value; } else { alert(getText("You're selecting BODY element.")); return; } } } realTime() } function doCssTextChange() { var idPreview = document.getElementById("idPreview").contentWindow; var inpCssText = document.getElementById("inpCssText"); var inpClassName = document.getElementById("inpClassName"); if(idPreview.document.getElementById("idPreviewTarget").innerHTML.substring(0,1)=="<")//means there is a tag for the style to be applied. Kalau tdk ada berarti BODY. { if(idPreview.document.getElementById("idPreviewTarget").innerHTML.substring(0,6)==" BODY // idPreview.document.all.idPreviewTarget.style.cssText=inpCssText.value; }
CSS Text:
Class Name:
Preview:
Apply to