// Append a floating field to a text object // Author: John Brinkman // August, 2011 // Get the list of selected nodes // We're expecting to have 2 items selected: [rich] text object and a field var selection = designer.getSelection(); var richText, newRichText; var validSelection = false; var field = null; var text = null; var lastP, object, i; if (selection.length === 2) { for (i = 0; i < 2; i++) { object = selection.item(i); if (object.className === "field" && object.ui.oneOfChild.className !== "imageEdit" && object.ui.oneOfChild.className !== "exObject") { field = object; } if (object.className === "draw") { if (object.value.oneOfChild.className === "exData" || object.value.oneOfChild.className === "text") { text = object; } } if (field !== null && text !== null) { validSelection = true; } } if (validSelection) { if (text.value.oneOfChild.className === "text") { richText = '

' + text.rawValue.replace(/&/g, "&").replace(/'; text.value.nodes.remove(text.value.text); text.value.nodes.append(xfa.template.createNode("exData")); text.value.exData.contentType="text/html"; } else { richText = text.value.exData.saveXML(); } lastP = richText.lastIndexOf("" + richText.substr(lastP); text.value.exData.loadXML(newRichText, true, true); bComplete = true; } } } if (!validSelection) { designer.alert("Invalid selection. Select a text object and a field"); }