diff options
Diffstat (limited to 'framework/Web/Javascripts/source/prado')
5 files changed, 69 insertions, 2 deletions
diff --git a/framework/Web/Javascripts/source/prado/controls/htmlarea.js b/framework/Web/Javascripts/source/prado/controls/htmlarea.js index 30bb82dd..5cba4f6c 100644 --- a/framework/Web/Javascripts/source/prado/controls/htmlarea.js +++ b/framework/Web/Javascripts/source/prado/controls/htmlarea.js @@ -124,7 +124,11 @@ Prado.WebUI.THtmlArea = Class.create(Prado.WebUI.Control, try { tinyMCE.execCommand('mceFocus', false, this.ID); + // when removed, tinyMCE restores its content to the textarea. If the textarea content has been + // updated in this same callback, it will be overwritten with the old content. Workaround this. + var curtext = $(this.ID).value; tinyMCE.execCommand('mceRemoveControl', false, this.ID); + $(this.ID).value = curtext; } catch (e) { diff --git a/framework/Web/Javascripts/source/prado/controls/htmlarea4.js b/framework/Web/Javascripts/source/prado/controls/htmlarea4.js new file mode 100644 index 00000000..cd3c6a0e --- /dev/null +++ b/framework/Web/Javascripts/source/prado/controls/htmlarea4.js @@ -0,0 +1,58 @@ + +/* + * + * HtmlArea (tinyMCE 4) wrapper + * + * @author Gabor Berczi <gabor.berczi@devworx.hu> + * +*/ + + +Prado.WebUI.THtmlArea4 = Class.create(Prado.WebUI.Control, +{ + initialize: function($super, options) + { + options.ID = options.EditorOptions.elements; + $super(options); + }, + + onInit : function(options) + { + this.options = options; + tinyMCE.init(this.options.EditorOptions); + }, + + removePreviousInstance: function() + { + for(var i=0;i<tinyMCE.editors.length;i++) + if (tinyMCE.editors[i].id==this.ID) + { + tinyMCE.editors.splice(i,1); // ugly hack, but works + i--; + } + }, + + onDone: function() + { + // check for previous tinyMCE registration, and try to remove it gracefully first + var prev = tinyMCE.get(this.ID); + if (prev) + try + { + tinyMCE.execCommand('mceFocus', false, this.ID); + // when removed, tinyMCE restores its content to the textarea. If the textarea content has been + // updated in this same callback, it will be overwritten with the old content. Workaround this. + // var curtext = $(this.ID).html(); + tinyMCE.execCommand('mceRemoveControl', false, this.ID); + // $(this.ID).html(curtext); + } + catch (e) + { + // suppress error here in case editor can't be properly removed + // (happens when <textarea> has been removed from DOM tree without deinitialzing the tinyMCE editor first) + } + + // doublecheck editor instance here and remove manually from tinyMCE-registry if neccessary + this.removePreviousInstance(); + } +}); diff --git a/framework/Web/Javascripts/source/prado/datepicker/datepicker.js b/framework/Web/Javascripts/source/prado/datepicker/datepicker.js index ad7eb019..ae1ad4b9 100644 --- a/framework/Web/Javascripts/source/prado/datepicker/datepicker.js +++ b/framework/Web/Javascripts/source/prado/datepicker/datepicker.js @@ -496,7 +496,10 @@ Prado.WebUI.TDatePicker = Class.create(Prado.WebUI.Control, for(var i = 0; i < years.length; i++) years[i].selected = years[i].value.toInteger() == currentYear; } - this.fireChangeEvent(day || month || year, capevents); + + day && this.fireChangeEvent(day, capevents); + month && this.fireChangeEvent(month, capevents); + year && this.fireChangeEvent(year, capevents); } }, diff --git a/framework/Web/Javascripts/source/prado/scriptaculous-adapter.js b/framework/Web/Javascripts/source/prado/scriptaculous-adapter.js index febe6ad9..1b9b2909 100644 --- a/framework/Web/Javascripts/source/prado/scriptaculous-adapter.js +++ b/framework/Web/Javascripts/source/prado/scriptaculous-adapter.js @@ -362,7 +362,7 @@ Prado.Element = } var opt = document.createElement('option'); opt.text = option[0]; - opt.innerText = option[0]; + opt.innerHTML = option[0]; opt.value = option[1]; if(optgroup!=null) optgroup.appendChild(opt); diff --git a/framework/Web/Javascripts/source/prado/validator/validation3.js b/framework/Web/Javascripts/source/prado/validator/validation3.js index 97fff053..0361389f 100644 --- a/framework/Web/Javascripts/source/prado/validator/validation3.js +++ b/framework/Web/Javascripts/source/prado/validator/validation3.js @@ -1148,6 +1148,7 @@ Prado.WebUI.TBaseValidator = Class.create(Prado.WebUI.Control, return Prado.WebUI.TDatePicker.getDropDownDate(control);//.getTime(); } case 'THtmlArea': + case 'THtmlArea4': if(typeof tinyMCE != "undefined") tinyMCE.triggerSave(); return $F(control); @@ -1180,6 +1181,7 @@ Prado.WebUI.TBaseValidator = Class.create(Prado.WebUI.Control, case 'TDatePicker': return value; case 'THtmlArea': + case 'THtmlArea4': return this.trim(value); case 'TRadioButton': return value; |