BUG-17427 HTML Editor available for multiple Textarea controls in Dynaforms
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
function DVEditor(where,body,oHiddenInput,height,mode)
|
||||
function DVEditor(where,body,oHiddenInput,height,mode,editorId)
|
||||
{
|
||||
var me=this;
|
||||
var hiddenInput=oHiddenInput;
|
||||
@@ -12,28 +12,19 @@ function DVEditor(where,body,oHiddenInput,height,mode)
|
||||
where.appendChild(iframe);
|
||||
var head=document.childNodes[0].childNodes[0];
|
||||
var header='';
|
||||
if (iframe.contentWindow)
|
||||
{
|
||||
if (iframe.contentWindow) {
|
||||
var doc = iframe.contentWindow.document;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
var doc = iframe.contentDocument;
|
||||
}
|
||||
var _header = $dce("head");// head.cloneNode(true);
|
||||
for (var i=0;i<head.childNodes.length;i++) {
|
||||
try {
|
||||
if ((head.childNodes[i].tagName==='LINK')&&
|
||||
(head.childNodes[i].type="text/css"))
|
||||
{
|
||||
(head.childNodes[i].type="text/css")) {
|
||||
_header.appendChild(head.childNodes[i].cloneNode(true));
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
header=_header.innerHTML;
|
||||
@@ -48,50 +39,64 @@ function DVEditor(where,body,oHiddenInput,height,mode)
|
||||
doc.contentEditable=false;
|
||||
}
|
||||
this.doc=doc;
|
||||
|
||||
me.insertHTML = function (html)
|
||||
{
|
||||
var cmd = 'inserthtml';
|
||||
var bool = false;
|
||||
var value = html;
|
||||
try
|
||||
{
|
||||
try {
|
||||
doc.execCommand(cmd,bool,value);
|
||||
} catch (e) {
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
me.command = function()
|
||||
{
|
||||
var cmd = this.getAttribute('name');
|
||||
var bool = false;
|
||||
var value = this.getAttribute('cmdValue') || null;
|
||||
if (value == 'promptUser')
|
||||
if (value == 'promptUser') {
|
||||
value = prompt(
|
||||
(typeof(G_STRINGS[this.getAttribute('promptText')])!=='undefined')?
|
||||
G_STRINGS[this.getAttribute('promptText')]:
|
||||
this.getAttribute('promptText')
|
||||
);
|
||||
try
|
||||
{
|
||||
}
|
||||
try {
|
||||
if (editorId) {
|
||||
if (window.ActiveXObject && cmd == 'hilitecolor') {
|
||||
doc.selection.createRange().pasteHTML('<span style ="background-color:' + value + '">' +doc.selection.createRange().text +'</span>');
|
||||
} else {
|
||||
eval("window._editor" +editorId+".doc.execCommand(cmd,bool,value);");
|
||||
}
|
||||
} else {
|
||||
doc.execCommand(cmd,bool,value);
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
me.loadToolBar = function(uri)
|
||||
{
|
||||
var tb=WebResource(uri);
|
||||
if(editorId){ // for multi-edhtmleditor
|
||||
tb.innerHTML = tb.innerHTML.replace(/DVEditorMap/g, "DVEditorMap" + editorId);
|
||||
}
|
||||
iframe.parentNode.insertBefore(tb,iframe);
|
||||
me.setToolBar(tb);
|
||||
}
|
||||
};
|
||||
|
||||
me.setToolBar = function(toolbar)
|
||||
{
|
||||
var buttons=toolbar.getElementsByTagName('area');
|
||||
for(var b=0;b<buttons.length;b++)
|
||||
{
|
||||
for (var b=0;b<buttons.length;b++) {
|
||||
buttons[b].onclick=me.command;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
me.getHTML = function()
|
||||
{
|
||||
var body='';
|
||||
@@ -101,7 +106,7 @@ function DVEditor(where,body,oHiddenInput,height,mode)
|
||||
} catch (e) {
|
||||
}
|
||||
return body;
|
||||
}
|
||||
};
|
||||
me.setHTML = function(html)
|
||||
{
|
||||
try {
|
||||
@@ -110,7 +115,8 @@ function DVEditor(where,body,oHiddenInput,height,mode)
|
||||
} catch (e) {
|
||||
}
|
||||
return body;
|
||||
}
|
||||
};
|
||||
|
||||
me.refreshHidden = function()
|
||||
{
|
||||
if(hiddenInput)
|
||||
@@ -120,10 +126,11 @@ function DVEditor(where,body,oHiddenInput,height,mode)
|
||||
hiddenInput.value=html;
|
||||
if (raiseOnChange && hiddenInput.onchange) hiddenInput.onchange();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
me.syncHidden = function(name)
|
||||
{
|
||||
me.refreshHidden();
|
||||
setTimeout(name+".syncHidden('"+name+"')",500);
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user