From 7142d632a5f2f1d28bf439547938f1f20cbad1e9 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 26 Jun 2013 19:34:14 +0000 Subject: [PATCH] Implement htmlarea ascii mode --- etemplate/js/et2_widget_html.js | 4 ++++ etemplate/js/et2_widget_htmlarea.js | 37 +++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/etemplate/js/et2_widget_html.js b/etemplate/js/et2_widget_html.js index c9e9af0cbe..19015946c4 100644 --- a/etemplate/js/et2_widget_html.js +++ b/etemplate/js/et2_widget_html.js @@ -49,6 +49,10 @@ var et2_html = et2_valueWidget.extend([et2_IDetachedDOM], this.supportedWidgetClasses = []; this.htmlNode = $j(document.createElement("span")); + if(this._type == 'htmlarea') + { + this.htmlNode.addClass('et2_textbox_ro'); + } if(this.options.label) { this.htmlNode.append(''+this.options.label+''); diff --git a/etemplate/js/et2_widget_htmlarea.js b/etemplate/js/et2_widget_htmlarea.js index f27fab1c8c..b0166480c6 100644 --- a/etemplate/js/et2_widget_htmlarea.js +++ b/etemplate/js/et2_widget_htmlarea.js @@ -26,6 +26,8 @@ */ var et2_htmlarea = et2_inputWidget.extend( { + modes: ['ascii','simple','extended','advanced'], + attributes: { 'mode': { 'name': 'Mode', @@ -79,19 +81,37 @@ var et2_htmlarea = et2_inputWidget.extend( // Allow no child widgets this.supportedWidgetClasses = []; - - - this.htmlNode = $j(document.createElement("div")); + this.htmlNode = $j(document.createElement("textarea")) + .attr('id', this.id) + .css('height', this.options.height) + .addClass('et2_textbox_ro'); 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() { this._super.apply(this, arguments); + if(this.mode == 'ascii') return; + var self = this; var ckeditor; 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.setData(self.value); delete self.value; @@ -126,6 +146,11 @@ var et2_htmlarea = et2_inputWidget.extend( } }, set_value: function(_value) { + if(this.htmlNode.is('textarea')) + { + this.htmlNode.val(_value); + return; + } try { //this.htmlNode.ckeditorGet().setData(_value); ckeditor = CKEDITOR.instances[this.id]; @@ -137,6 +162,10 @@ var et2_htmlarea = et2_inputWidget.extend( }, getValue: function() { + if(this.htmlNode.is('textarea')) + { + return this.htmlNode.val(); + } try { //return this.htmlNode.ckeditorGet().getData();