Implement htmlarea ascii mode

This commit is contained in:
Nathan Gray 2013-06-26 19:34:14 +00:00
parent 8f2248b6ab
commit 7142d632a5
2 changed files with 37 additions and 4 deletions

View File

@ -49,6 +49,10 @@ var et2_html = et2_valueWidget.extend([et2_IDetachedDOM],
this.supportedWidgetClasses = []; this.supportedWidgetClasses = [];
this.htmlNode = $j(document.createElement("span")); this.htmlNode = $j(document.createElement("span"));
if(this._type == 'htmlarea')
{
this.htmlNode.addClass('et2_textbox_ro');
}
if(this.options.label) if(this.options.label)
{ {
this.htmlNode.append('<span class="et2_label">'+this.options.label+'</span>'); this.htmlNode.append('<span class="et2_label">'+this.options.label+'</span>');

View File

@ -26,6 +26,8 @@
*/ */
var et2_htmlarea = et2_inputWidget.extend( var et2_htmlarea = et2_inputWidget.extend(
{ {
modes: ['ascii','simple','extended','advanced'],
attributes: { attributes: {
'mode': { 'mode': {
'name': 'Mode', 'name': 'Mode',
@ -79,19 +81,37 @@ var et2_htmlarea = et2_inputWidget.extend(
// Allow no child widgets // Allow no child widgets
this.supportedWidgetClasses = []; this.supportedWidgetClasses = [];
this.htmlNode = $j(document.createElement("textarea"))
.attr('id', this.id)
this.htmlNode = $j(document.createElement("div")); .css('height', this.options.height)
.addClass('et2_textbox_ro');
this.setDOMNode(this.htmlNode[0]); this.setDOMNode(this.htmlNode[0]);
}, },
transformAttributes: function(_attrs) {
// Check mode, some apps jammed everything in there
if(jQuery.inArray(_attrs['mode'], this.modes) < 0)
{
this.egw().debug("warn", "Invalid mode for '%s': %s Valid options:", _attrs['id'],_attrs['mode'], this.modes);
var list = _attrs['mode'].split(',');
for(var i = 0; i < list.length && i < this.legacyOptions.length; i++)
{
_attrs[this.legacyOptions[i]] = list[i];
}
}
this._super.apply(this, arguments);
},
doLoadingFinished: function() { doLoadingFinished: function() {
this._super.apply(this, arguments); this._super.apply(this, arguments);
if(this.mode == 'ascii') return;
var self = this; var self = this;
var ckeditor; var ckeditor;
try try
{ {
CKEDITOR.replace(this.id,this.options.config); CKEDITOR.replace(this.id,jQuery.extend({},this.options.config,this.options));
ckeditor = CKEDITOR.instances[this.id]; ckeditor = CKEDITOR.instances[this.id];
ckeditor.setData(self.value); ckeditor.setData(self.value);
delete self.value; delete self.value;
@ -126,6 +146,11 @@ var et2_htmlarea = et2_inputWidget.extend(
} }
}, },
set_value: function(_value) { set_value: function(_value) {
if(this.htmlNode.is('textarea'))
{
this.htmlNode.val(_value);
return;
}
try { try {
//this.htmlNode.ckeditorGet().setData(_value); //this.htmlNode.ckeditorGet().setData(_value);
ckeditor = CKEDITOR.instances[this.id]; ckeditor = CKEDITOR.instances[this.id];
@ -137,6 +162,10 @@ var et2_htmlarea = et2_inputWidget.extend(
}, },
getValue: function() { getValue: function() {
if(this.htmlNode.is('textarea'))
{
return this.htmlNode.val();
}
try try
{ {
//return this.htmlNode.ckeditorGet().getData(); //return this.htmlNode.ckeditorGet().getData();