14. oktober 2002 - 23:26
#9
pelkjaer >> Jeg er ikke skrap til javascript. Kan du hjælpe lidt mere - her er koden:
<script language="JavaScript">
var viewMode<%=ewp_controlId %> = 1; // WYSIWYG
function Init<%=ewp_controlId %>()
{
iView<%=ewp_controlId %>.document.designMode = 'On';
iHTML<%=ewp_controlId %> = "<%= replace(replace(ewp_value, chr(13) & chr(10), "\r\n"), """", "\""") %>";
setTimeout("iView<%=ewp_controlId %>.document.body.innerHTML = iHTML<%=ewp_controlId %>;", 0);
setTimeout("iView<%=ewp_controlId %>.focus();", 0);
}
function selOn(ctrl)
{
ctrl.style.borderColor = '#000000';
ctrl.style.backgroundColor = '#B5BED6';
ctrl.style.cursor = 'hand';
}
function selOff(ctrl)
{
ctrl.style.borderColor = '#D6D3CE';
ctrl.style.backgroundColor = '#D6D3CE';
}
function selDown(ctrl)
{
ctrl.style.backgroundColor = '#8492B5';
}
function selUp(ctrl)
{
ctrl.style.backgroundColor = '#B5BED6';
}
function doBold<%=ewp_controlId %>()
{
iView<%=ewp_controlId %>.document.execCommand('bold', false, null);
}
function doItalic<%=ewp_controlId %>()
{
iView<%=ewp_controlId %>.document.execCommand('italic', false, null);
}
function doUnderline<%=ewp_controlId %>()
{
iView<%=ewp_controlId %>.document.execCommand('underline', false, null);
}
function doLeft<%=ewp_controlId %>()
{
iView<%=ewp_controlId %>.document.execCommand('justifyleft', false, null);
}
function doCenter<%=ewp_controlId %>()
{
iView<%=ewp_controlId %>.document.execCommand('justifycenter', false, null);
}
function doRight<%=ewp_controlId %>()
{
iView<%=ewp_controlId %>.document.execCommand('justifyright', false, null);
}
function doOrdList<%=ewp_controlId %>()
{
iView<%=ewp_controlId %>.document.execCommand('insertorderedlist', false, null);
}
function doBulList<%=ewp_controlId %>()
{
iView<%=ewp_controlId %>.document.execCommand('insertunorderedlist', false, null);
}
function doForeCol<%=ewp_controlId %>()
{
var left = (screen.availWidth/2) - (293/2);
var top = (screen.availHeight/2) - (100/2);
document.all.__data<%=ewp_controlId %>.value = 'foreColor';
var colorWin = window.open("colors.ewp.asp?controlId=<%=ewp_controlId %>", 'colors', 'scrollbars=0, toolbar=0, statusbar=0, width=293, height=100, left='+left+', top='+top);
}
function doBackCol<%=ewp_controlId %>()
{
var left = (screen.availWidth/2) - (293/2);
var top = (screen.availHeight/2) - (100/2);
document.all.__data<%=ewp_controlId %>.value = 'backColor';
var colorWin = window.open('colors.ewp.asp?controlId=<%=ewp_controlId %>', 'colors', 'scrollbars=0, toolbar=0, statusbar=0, width=293, height=100, left='+left+', top='+top);
}
function doImage<%=ewp_controlId %>()
{
var left = (screen.availWidth/2) - (450/2);
var top = (screen.availHeight/2) - (429/2);
var imageWin = window.open('image.ewp.asp?controlId=<%=ewp_controlId %>&path=<%= ewp_imagePath %>', 'images', 'scrollbars=1, toolbar=0, statusbar=0, width=450, height=429, left='+left+', top='+top);
}
function doLink<%=ewp_controlId %>()
{
iView<%=ewp_controlId %>.document.execCommand('createlink');
}
function doRule<%=ewp_controlId %>()
{
iView<%=ewp_controlId %>.document.execCommand('inserthorizontalrule', false, null);
}
function doFont<%=ewp_controlId %>(fName)
{
if(fName != '')
iView<%=ewp_controlId %>.document.execCommand('fontname', false, fName);
}
function doSize<%=ewp_controlId %>(fSize)
{
if(fSize != '')
iView<%=ewp_controlId %>.document.execCommand('fontsize', false, fSize);
}
function doHead<%=ewp_controlId %>(hType)
{
if(hType != '')
{
iView<%=ewp_controlId %>.document.execCommand('formatblock', false, hType);
}
}
function doCustomInsert<%=ewp_controlId %>(iValue)
{
iView<%=ewp_controlId %>.focus();
var sel = iView<%=ewp_controlId %>.document.selection;
var theFrame = sel.createRange();
theFrame.pasteHTML(iValue);
}
function doTable<%=ewp_controlId %>()
{
var left = (screen.availWidth/2) - (450/2);
var top = (screen.availHeight/2) - (210/2);
var imageWin = window.open('table.ewp.asp?controlId=<%=ewp_controlId %>', 'table', 'scrollbars=1, toolbar=0, statusbar=0, width=450, height=210, left='+left+', top='+top);
}
function doToggleView<%=ewp_controlId %>()
{
if(viewMode<%=ewp_controlId %> == 1)
{
iHTML = iView<%=ewp_controlId %>.document.body.innerHTML;
iView<%=ewp_controlId %>.document.body.innerText = iHTML;
// Hide all controls
<% if(ewp_showBold= true) then %>
document.all.boldBut<%=ewp_controlId %>.style.display = 'none';
<% end if %>
<% if(ewp_showItal= true) then %>
document.all.italBut<%=ewp_controlId %>.style.display = 'none';
<% end if %>
<% if(ewp_showUnde= true) then %>
document.all.undeBut<%=ewp_controlId %>.style.display = 'none';
<% end if %>
<% if(ewp_showLeftAlign= true) then %>
document.all.leftBut<%=ewp_controlId %>.style.display = 'none';
<% end if %>
<% if(ewp_showCenterAlign= true) then %>
document.all.centBut<%=ewp_controlId %>.style.display = 'none';
<% end if %>
<% if(ewp_showRightAlign= true) then %>
document.all.rightBut<%=ewp_controlId %>.style.display = 'none';
<% end if %>
<% if(ewp_showOrderedList= true) then %>
document.all.ordBut<%=ewp_controlId %>.style.display = 'none';
<% end if %>
<% if(ewp_showBulletList= true) then %>
document.all.unordBut<%=ewp_controlId %>.style.display = 'none';
<% end if %>
<% if(ewp_showTextColor= true) then %>
document.all.fcolBut<%=ewp_controlId %>.style.display = 'none';
<% end if %>
<% if(ewp_showBackColor= true) then %>
document.all.bcolBut<%=ewp_controlId %>.style.display = 'none';
<% end if %>
<% if(ewp_showLink= true) then %>
document.all.linkBut<%=ewp_controlId %>.style.display = 'none';
<% end if %>
<% if(ewp_showImage= true) then %>
document.all.imageBut<%=ewp_controlId %>.style.display = 'none';
<% end if %>
<% if(ewp_showRule= true) then %>
document.all.ruleBut<%=ewp_controlId %>.style.display = 'none';
<% end if %>
<% if(ewp_showTable= true) then %>
document.all.tableBut<%=ewp_controlId %>.style.display = 'none';
<% end if %>
<% if(ewp_showFontList= true) then %>
document.all.selFont<%=ewp_controlId %>.style.display = 'none';
<% end if %>
<% if(ewp_showSizeList= true) then %>
document.all.selSize<%=ewp_controlId %>.style.display = 'none';
<% end if %>
<% if(ewp_showHeadingList= true) then %>
document.all.selHeading<%=ewp_controlId %>.style.display = 'none';
<% end if %>
<% if(ewp_showCustomInsertList = true AND ewp_numCustomInserts > 0) then %>
document.all.selCustomInsert<%=ewp_controlId %>.style.display = 'none';
<% end if %>
iView<%=ewp_controlId %>.focus();
viewMode<%=ewp_controlId %> = 2; // Code
}
else
{
iText = iView<%=ewp_controlId %>.document.body.innerText;
iView<%=ewp_controlId %>.document.body.innerHTML = iText;
// Show all controls
<% if(ewp_showBold= true) then %>
document.all.boldBut<%=ewp_controlId %>.style.display = 'inline';
<% end if %>
<% if(ewp_showItal= true) then %>
document.all.italBut<%=ewp_controlId %>.style.display = 'inline';
<% end if %>
<% if(ewp_showUnde= true) then %>
document.all.undeBut<%=ewp_controlId %>.style.display = 'inline';
<% end if %>
<% if(ewp_showLeftAlign= true) then %>
document.all.leftBut<%=ewp_controlId %>.style.display = 'inline';
<% end if %>
<% if(ewp_showCenterAlign= true) then %>
document.all.centBut<%=ewp_controlId %>.style.display = 'inline';
<% end if %>
<% if(ewp_showRightAlign= true) then %>
document.all.rightBut<%=ewp_controlId %>.style.display = 'inline';
<% end if %>
<% if(ewp_showOrderedList= true) then %>
document.all.ordBut<%=ewp_controlId %>.style.display = 'inline';
<% end if %>
<% if(ewp_showBulletList= true) then %>
document.all.unordBut<%=ewp_controlId %>.style.display = 'inline';
<% end if %>
<% if(ewp_showTextColor= true) then %>
document.all.fcolBut<%=ewp_controlId %>.style.display = 'inline';
<% end if %>
<% if(ewp_showBackColor= true) then %>
document.all.bcolBut<%=ewp_controlId %>.style.display = 'inline';
<% end if %>
<% if(ewp_showLink= true) then %>
document.all.linkBut<%=ewp_controlId %>.style.display = 'inline';
<% end if %>
<% if(ewp_showImage= true) then %>
document.all.imageBut<%=ewp_controlId %>.style.display = 'inline';
<% end if %>
<% if(ewp_showRule= true) then %>
document.all.ruleBut<%=ewp_controlId %>.style.display = 'inline';
<% end if %>
<% if(ewp_showTable= true) then %>
document.all.tableBut<%=ewp_controlId %>.style.display = 'inline';
<% end if %>
<% if(ewp_showFontList= true) then %>
document.all.selFont<%=ewp_controlId %>.style.display = 'inline';
<% end if %>
<% if(ewp_showSizeList= true) then %>
document.all.selSize<%=ewp_controlId %>.style.display = 'inline';
<% end if %>
<% if(ewp_showHeadingList= true) then %>
document.all.selHeading<%=ewp_controlId %>.style.display = 'inline';
<% end if %>
<% if(ewp_showCustomInsertList = true AND ewp_numCustomInserts > 0) then %>
document.all.selCustomInsert<%=ewp_controlId %>.style.display = 'inline';
<% end if %>
iView<%=ewp_controlId %>.focus();
viewMode<%=ewp_controlId %> = 1; // WYSIWYG
}
}
function doValueUpdate<%=ewp_controlId %>()
{
// This function updates the hidden form field value
iHTML = iView<%=ewp_controlId %>.document.body.innerHTML;
document.all.__control_<%=ewp_controlId %>.value = iHTML;
}
// Setup the control
Init<%=ewp_controlId %>();
</script>