diff --git a/gulliver/js/dveditor/core/dveditor.js b/gulliver/js/dveditor/core/dveditor.js index 20a2770ab..03aeebace 100755 --- a/gulliver/js/dveditor/core/dveditor.js +++ b/gulliver/js/dveditor/core/dveditor.js @@ -1,129 +1,136 @@ -function DVEditor(where,body,oHiddenInput,height,mode) +function DVEditor(where,body,oHiddenInput,height,mode,editorId) { - var me=this; - var hiddenInput=oHiddenInput; - var iframe=$dce("iframe"); - //NOTE: className no funciona en FIREFOX - iframe.style.width="100%"; - iframe.style.height=height; - iframe.style.margin="0px"; - iframe.style.padding="0px"; - iframe.style.border="none"; - where.appendChild(iframe); - var head=document.childNodes[0].childNodes[0]; - var header=''; - if (iframe.contentWindow) - { - var doc=iframe.contentWindow.document; - } - else - { - var doc=iframe.contentDocument; - } - var _header=$dce("head");// head.cloneNode(true); - for(var i=0;i'+header+''+body+''); + doc.close(); + doc.designMode="on"; + if (mode=="edit") { + doc.contentEditable=true; + } else { + doc.contentEditable=false; + } + this.doc=doc; + + me.insertHTML = function (html) { - } - } - header=_header.innerHTML; - //alert(header); - doc.open(); - doc.write(''+header+''+body+''); - doc.close(); - doc.designMode="on"; - if(mode=="edit"){ - doc.contentEditable=true; - }else{ - doc.contentEditable=false; - } - this.doc=doc; - me.insertHTML=function (html) - { - var cmd = 'inserthtml'; - var bool = false; - var value = html; - try + var cmd = 'inserthtml'; + var bool = false; + var value = html; + try { + doc.execCommand(cmd,bool,value); + } catch (e) { + } + return false; + }; + + me.command = function() { - 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') - value = prompt( - (typeof(G_STRINGS[this.getAttribute('promptText')])!=='undefined')? - G_STRINGS[this.getAttribute('promptText')]: - this.getAttribute('promptText') - ); - try + var cmd = this.getAttribute('name'); + var bool = false; + var value = this.getAttribute('cmdValue') || null; + if (value == 'promptUser') { + value = prompt( + (typeof(G_STRINGS[this.getAttribute('promptText')])!=='undefined')? + G_STRINGS[this.getAttribute('promptText')]: + this.getAttribute('promptText') + ); + } + try { + if (editorId) { + if (window.ActiveXObject && cmd == 'hilitecolor') { + doc.selection.createRange().pasteHTML('' +doc.selection.createRange().text +''); + } else { + eval("window._editor" +editorId+".doc.execCommand(cmd,bool,value);"); + } + } else { + doc.execCommand(cmd,bool,value); + } + } catch (e) { + } + return false; + }; + + me.loadToolBar = function(uri) { - doc.execCommand(cmd,bool,value); - } catch (e) { - } - return false; - } - me.loadToolBar=function(uri) - { - var tb=WebResource(uri); - iframe.parentNode.insertBefore(tb,iframe); - me.setToolBar(tb); - } - me.setToolBar=function(toolbar) - { - var buttons=toolbar.getElementsByTagName('area'); - for(var b=0;b