/************************************************ * CFDEV.COM Activedit Java Script Functions * * Authors: Pete Freitag * Matt Finn * URL: http://www.cfdev.com * Email: support@cfdev.com * Current Version: 2.5 * * Notes: * Modification of source requires an open source license * Reverse Engineering of this code is prohibited * All Rights Reserved Copyright 1999-2001 CFDEV.COM, NETDesign Inc. * * ************************************************/ /************************************************* * TODO: * User Defined Functions (AEAPI) * ************************************************/ //////////////////////////// // global variables // //////////////////////////// //debugging parameter errlevel = 0; var ae_olddocmd; //saves the old ondocument click function pointer aeObjects = new Array(); //needs to be global for spell checker var aeFieldnames = new Array(); var DHTMLSafe; // This is the active editor var ae_count; var ae_hot; //This tells which Activedit the context menu is for var ae_sourceview=false; //Are we viewing source? var ae_oldfontfamily=''; //Store the old font family for inline view source var ae_oldfontsize=''; //Store the old font size for inline view source var ae_HTMLMode = new Array(); //true if current control is in html mode var tableparamobj=new ActiveXObject("DEInsertTableParam.DEInsertTableParam"); tableparamobj.NumRows=3; tableparamobj.NumCols=3; tableparamobj.Caption=""; tableparamobj.TableAttrs="border=0 cellpadding=0 cellspacing=0 width=75%"; tableparamobj.CellAttrs=""; var is_ie4 = ((parseInt(navigator.appVersion) == 4) && (navigator.userAgent.toLowerCase().indexOf("msie 5")==-1) && (navigator.userAgent.toLowerCase().indexOf("msie 6")==-1) ); //////////////////////////// //initialization function // //////////////////////////// function ae_initialize(num) { //initializes the control ae_count=num; thisContentItem=eval("document.all.ae_tx_content"+num); thisForm=thisContentItem; while(thisForm.tagName!="FORM"&&thisForm.tagName!="HTML") { thisForm=thisForm.parentElement; } if(thisForm.tagName!="HTML") { DHTMLSafe = eval("thisForm.DHTMLSafe"+num); aeObjects[num] = DHTMLSafe; aeObjects[thisContentItem.name] = DHTMLSafe; aeFieldnames[num] = thisContentItem.name; //bind onSubmit event to ae_onSubmit() thisForm.onsubmit = ae_onSubmit; } else { alert("Activedit must be contained in a form.", "", true); return; } DHTMLSafe.NewDocument(); DHTMLSafe.BaseURL=ae_baseurl[num]; set_tbstates(num); ae_onLoad(num); ae_HTMLMode[num] = false; } function ae_onLoad(num) { DHTMLSafe=aeObjects[num]; if(DHTMLSafe.Busy) { setTimeout("ae_onLoad("+num+");", 100); return; } if(num==1) window.onunload = ae_onUnload; if(ae_defaultfont[num].length) DHTMLSafe.DOM.body.style.font=ae_defaultfont[num]; if(oSel=eval('document.all.oQuickFormat'+num)) { //Populate QuickFormat Box var f=new ActiveXObject("DEGetBlockFmtNamesParam.DEGetBlockFmtNamesParam"); DHTMLSafe.ExecCommand(DECMD_GETBLOCKFMTNAMES,OLECMDEXECOPT_DODEFAULT,f); vbarr = new VBArray(f.Names); arr = vbarr.toArray(); for (var i=0;i and ctrl+enter insert

switch(DHTMLSafe.DOM.parentWindow.event.keyCode) { case 10: DHTMLSafe.DOM.parentWindow.event.keyCode = 13; break; case 13: if(DHTMLSafe.QueryStatus(DECMD_UNORDERLIST)!=DECMDF_LATCHED) { DHTMLSafe.DOM.parentWindow.event.returnValue = false; sel = DHTMLSafe.DOM.selection.createRange(); sel.pasteHTML("
"); sel.collapse(false); sel.select(); } break; default: break; } } } // cancels the table selector when you click on DHTMLSafe function ae_onmousedown(num) { if(typeof(document.all.frame1) != "undefined") { if(document.all.frame1.style.visibility == "visible") { cancelTable(false); return; } } } function ae_onclick(num) { set_tbstates(num); } function ae_ondisplaychange(num) { //if(DHTMLSafe.Busy) return; set_tbstates(num); } function ae_onmenuaction(itemIndex, num) { ae_onCommand(ContextMenu[itemIndex].cmdId, num); } //////////////////////////// // member functions // //////////////////////////// //perform basic operational commands function ae_onCommand(cmdId, num) { //no buttons should work in html mode if (ae_HTMLMode[num]) { return; } if(typeof(num)=="undefined") { num=ae_hot; } DHTMLSafe=aeObjects[num]; if(cmdId==null) cmdid=eval(window.event.srcElement.cid); else cmdid=cmdId; doFocus=true; switch(parseInt(cmdid)) { case DECMD_IMAGE: DHTMLSafe.DOM.selection.createRange().collapse(false); onImagewin(num); doFocus=false; break; case DECMD_INSERTTABLE: onTableWin(num); doFocus=false; break; case DECMD_EDITSOURCE: if(tabview[num]) ae_editsourceinline(num); else { ae_editsource(num); doFocus=false; } break; case DECMD_ABOUT: ae_about(); doFocus=false; break; case DECMD_HELP: ae_help(); doFocus=false; break; case DECMD_TOGGLE_DETAILS: ae_onToggleDetails(null, num); break; case DECMD_SAVE: ae_submit_form('ae_form', '#attributes.fieldname#'); break; case DECMD_EDITTABLE: editTableWin(num); doFocus=false; break; case DECMD_HYPERLINK: ae_hyperlinkwin(num); doFocus=false; break; case DECMD_SPELLCHECK: ae_spellcheckwin(num); doFocus=false; break; case DECMD_SPECIAL_CHARS: ae_specialchars(); doFocus=false; break; default: if(DHTMLSafe.QueryStatus(cmdid)!=DECMDF_DISABLED) { DHTMLSafe.ExecCommand(cmdid, OLECMDEXECOPT_DODEFAULT); } break; } if (doFocus) { DHTMLSafe.focus(); DHTMLSafe.DOM.body.focus(); } } function ae_onToggleDetails(bVal, num) { //Show hidden Tags as glyphs DHTMLSafe=aeObjects[num]; if (bVal == null) { DHTMLSafe.ShowDetails = !(DHTMLSafe.ShowDetails); } else { DHTMLSafe.ShowDetails = bVal; } } function editTableWin(num) { editTbl = window.open(inc + 'edittable.htm', "editTbl", "directories=no,height=310,width=350,location=no,menubar=no,status=no,toolbar=no"); editTbl.focus(); } function onTableWin(num) { DHTMLSafe=aeObjects[num]; if(DHTMLSafe.QueryStatus(DECMD_INSERTTABLE) == DECMDF_DISABLED) { DHTMLSafe.focus(); DHTMLSafe.DOM.body.focus(); return; } ae_hot = num; arr = window.open(inc + "table.htm", "arr", "Width=450, Height=225"); arr.focus(); } //dropdown table selector function onTable(num) { //open's table dialog window //if it's in a table //no buttons should work in html mode if (ae_HTMLMode[num]) { return; } DHTMLSafe=aeObjects[num]; if(DHTMLSafe.QueryStatus(DECMD_INSERTTABLE) == DECMDF_DISABLED) { DHTMLSafe.focus(); DHTMLSafe.DOM.body.focus(); return; } if( document.all.frame1.style.visibility == "visible" ) { cancelTable(); return; } var str = "

"; str = str + makeTable(4, 5); str = str + "
1 by 1 Table
"; var ifrm = document.frames("frame1"); var obj=eval("document.all.ae_tbtn"+num); var x=0; var y=0; ifrm.document.body.innerHTML=str; while(obj.tagName!="BODY") { x+=obj.offsetLeft; y+=obj.offsetTop; obj=obj.offsetParent; } document.all.frame1.style.pixelTop = y + 24; document.all.frame1.style.pixelLeft = x; document.all.frame1.style.pixelWidth = 0; document.all.frame1.style.pixelHeight = 0; document.all.frame1.style.visibility = "visible"; //bind events ae_hot=num; document.frames("frame1").document.body.onmouseover = paintTable; document.frames("frame1").document.body.onclick = insertTable; if(typeof(document.onmousedown)=="function") ae_olddocmd = document.onmousedown; else ae_olddoccmd=null; document.onmousedown = cancelTable; DHTMLSafe.onmousedown = cancelTable; event.cancelBubble = true; ifrm.document.body.onselectstart=new Function("return false;"); document.all.frame1.style.pixelWidth = ifrm.document.all.oTable.offsetWidth + 3 document.all.frame1.style.pixelHeight = ifrm.document.all.oTable.offsetHeight + 3 + ifrm.document.all.tblstat.offsetHeight; } // Does the insert table for table selector function insertTable(rows, cols, attrs, num) { //drop down table implementation if(typeof(num)=="undefined") num=ae_hot; DHTMLSafe=aeObjects[num]; if (typeof(rows) == "undefined") { var se = document.frames('frame1').window.event.srcElement; if(se.tagName!='TD') { cancelTable(); return; } tableparamobj.NumRows = se.parentElement.rowIndex + 1; tableparamobj.NumCols = se.cellIndex + 1; tableparamobj.TableAttrs = "border=1 cellPadding=0 cellSpacing=0 width=75%"; cancelTable(); } else { tableparamobj.NumRows = rows; tableparamobj.NumCols = cols; tableparamobj.TableAttrs = attrs; } DHTMLSafe.ExecCommand(DECMD_INSERTTABLE,OLECMDEXECOPT_DODEFAULT, tableparamobj); DHTMLSafe.focus(); DHTMLSafe.DOM.body.focus(); } //Paints the table selector function paintTable() { var se = document.frames('frame1').window.event.srcElement; var sr, sc, tbl, fAll; fAll = document.frames('frame1').document.all; if(se.tagName!='TD') { sr = 0; sc = 0; var str=" Cancel"; fAll.tblsel.style.width = 0; fAll.tblsel.style.height = 0; return; } tbl=fAll.oTable; sr=se.parentElement.rowIndex; sc=se.cellIndex; //Expand the table selector if its too small if(!is_ie4) { if(tbl.rows.length == sr+1) { var r = tbl.insertRow(-1); var td; for(var i=0;i\n"; for (a=0;a\n"; for(b=0;b" str = str + " \n"; } str = str + "\n"; } str = str + "" return str; } //Closes table selector iframe and replaces document mousedown function cancelTable(a) { document.onmousedown=null; document.all.frame1.style.visibility = "hidden"; document.all.frame1.style.pixelWidth = 0; document.all.frame1.style.pixelHeight = 0; if(a==false) return; if(typeof(ae_olddocmd)=="function") { ae_olddocmd(false); document.onmousedown = ae_olddocmd; } ae_olddocmd = null; //Set DropDownTable IFrame to small document.all.frame1.style.pixelWidth = 10; document.all.frame1.style.pixelHeight = 10; } function onImagewin(num) { //if the focus never touched the control, you get an error, so lets touch the control DHTMLSafe=aeObjects[num]; DHTMLSafe.focus(); DHTMLSafe.DOM.body.focus(); if (typeof(ae_imgwin) == "undefined" || ae_imgwin.closed) { //short circuit eval //spawn image window var szURL; szURL=inc + "image.cfm?instance=" + num; szURL+="&imagedata="; szURL+=ae_imagedata[num]; szURL+="&imageurl="; szURL+=ae_imageurl[num]; ae_imgwin = window.open(szURL ,"ae_imgwin","scrollbars=yes,width=490,height=340, resizable=yes"); } ae_imgwin.focus(); } function onImage(u, base_url, iborder, ialign, ialt, num) { //insert the image //DHTMLSafe.ExecCommand(DECMD_IMAGE,OLECMDEXECOPT_DONTPROMPTUSER,u); DHTMLSafe=aeObjects[num]; var img = "\"""; DHTMLSafe.DOM.selection.createRange().pasteHTML(img); ae_imgwin.close(); DHTMLSafe.focus(); DHTMLSafe.DOM.body.focus(); } function ae_onBeforeSave(aeObject) { //for images for (var i=0;i)+)/ig; document.images["normaltab"+num].src=img_normaltaboff.src; document.images["htmltab"+num].src=img_htmltabon.src; // Set the font to fixed width DHTMLSafe.DOM.body.style.fontFamily = "Courier New"; DHTMLSafe.DOM.body.style.fontSize = "10pt"; thisContentItem.value=DHTMLSafe.DOM.body.innerHTML; DHTMLSafe.DOM.body.innerHTML = ""; DHTMLSafe.DOM.body.createTextRange().text = thisContentItem.value.replace(re, "$1\n"); ae_HTMLMode[num] = true; } } function ae_specialchars() { var szURL = inc + "specialchars.htm"; ae_specialwin = window.open(szURL ,"ae_specialwin",",width=390,height=260, resizable=yes",true); } function ae_quickfont(num) { //no buttons should work in html mode if (ae_HTMLMode[num]) { return; } DHTMLSafe=aeObjects[num]; oSel=eval('document.all.oQuickFont'+num); DHTMLSafe.ExecCommand(DECMD_SETFONTNAME, OLECMDEXECOPT_DODEFAULT, oSel.options[oSel.selectedIndex].name); DHTMLSafe.focus(); DHTMLSafe.DOM.body.focus(); } function ae_quickfontsize(num) { //no buttons should work in html mode if (ae_HTMLMode[num]) { return; } DHTMLSafe=aeObjects[num]; oSel=eval('document.all.oQuickFontSize'+num); DHTMLSafe.ExecCommand(DECMD_SETFONTSIZE, OLECMDEXECOPT_DODEFAULT, oSel.options[oSel.selectedIndex].value); DHTMLSafe.focus(); DHTMLSafe.DOM.body.focus(); } function ae_quickformat(num) { //no buttons should work in html mode if (ae_HTMLMode[num]) { return; } DHTMLSafe=aeObjects[num]; oSel=eval('document.all.oQuickFormat'+num); DHTMLSafe.ExecCommand(DECMD_SETBLOCKFMT, OLECMDEXECOPT_DODEFAULT, oSel.options[oSel.selectedIndex].name); DHTMLSafe.focus(); DHTMLSafe.DOM.body.focus(); } function ae_hyperlinkwin(num) { ae_hot=num; DHTMLSafe=aeObjects[num]; DHTMLSafe.focus(); DHTMLSafe.DOM.body.focus(); //DHTMLSafe.ExecCommand(cmdid, OLECMDEXECOPT_DODEFAULT); return; if(DHTMLSafe.DOM.selection.type=="Control") { var el=DHTMLSafe.DOM.selection.createRange().commonParentElement(); var tr = DHTMLSafe.DOM.body.createTextRange(); tr.moveToElementText(el); tr.select(); } if (typeof(ae_linkwin) == "undefined" || ae_linkwin.closed) { //short circuit eval //spawn image window var szURL=inc + "hyperlink.htm"; ae_linkwin = window.open(szURL ,"ae_linkwin","scrollbars=auto,width=360,height=190, resizable=yes",true); } ae_linkwin.focus(); } function ae_hyperlink(num, iHref, iTarget, iStyle, iClass, iName) { DHTMLSafe=aeObjects[num]; var uid="ae"+Math.random().toString(); if(iHref=="" && !iName.length) { // Unlink if(DHTMLSafe.QueryStatus(DECMD_UNLINK)==DECMDF_ENABLED) DHTMLSafe.ExecCommand(DECMD_UNLINK); } else { var trSel=DHTMLSafe.DOM.selection.createRange(); if(trSel.compareEndPoints("StartToEnd",trSel)==0) { // Need a brand new link txtHTML=""; trSel.pasteHTML(txtHTML); } else { //Update existing link or link plain text DHTMLSafe.ExecCommand(DECMD_HYPERLINK,OLECMDEXECOPT_DONTPROMPTUSER,uid); var coll=DHTMLSafe.DOM.all.tags("A"); for(i=0;i