Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Add rootElement option to ensure there is always html and not just text
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Mitchell authored and cheeaun committed Nov 15, 2009
1 parent ef3628c commit 976c196
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Source/MooEditable/MooEditable.js
Expand Up @@ -60,7 +60,8 @@ this.MooEditable = new Class({
baseCSS: 'html{ height: 100%; cursor: text; } body{ font-family: sans-serif; }',
extraCSS: '',
externalCSS: '',
html: '<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><style>{BASECSS} {EXTRACSS}</style>{EXTERNALCSS}</head><body>{CONTENT}</body></html>'
html: '<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><style>{BASECSS} {EXTRACSS}</style>{EXTERNALCSS}</head><body>{CONTENT}</body></html>',
rootElement: 'p'
},

initialize: function(el, options){
Expand Down Expand Up @@ -455,12 +456,17 @@ this.MooEditable = new Class({
},

setContent: function(newContent){
if(newContent.charAt(0) != '<') newContent = '<' + this.options.rootElement + '>' + newContent + '</' + this.options.rootElement + '>';
this.doc.body.set('html', newContent);
return this;
},

saveContent: function(){
if (this.mode == 'iframe') this.textarea.set('value', this.getContent());
if (this.mode == 'iframe'){
var val = this.getContent();
if(val.charAt(0) != '<') val = '<' + this.options.rootElement + '>' + val + '</' + this.options.rootElement + '>';
this.textarea.set('value', val);
}
return this;
},

Expand Down

0 comments on commit 976c196

Please sign in to comment.