From: Alexander Ebert Date: Thu, 29 May 2014 22:53:52 +0000 (+0200) Subject: Fixed WYSIWYG editor in user profile editor X-Git-Tag: 2.1.0_Alpha_1~779^2~4 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c5099b6673e06c913bdfa049a6949c7b8098b165;p=GitHub%2FWoltLab%2FWCF.git Fixed WYSIWYG editor in user profile editor --- diff --git a/wcfsetup/install/files/js/WCF.User.js b/wcfsetup/install/files/js/WCF.User.js index 8e346c67c5..b7ff6393d0 100644 --- a/wcfsetup/install/files/js/WCF.User.js +++ b/wcfsetup/install/files/js/WCF.User.js @@ -698,18 +698,27 @@ WCF.User.Profile.Editor = Class.extend({ var $values = { }; this._tab.find('input, textarea, select').each(function(index, element) { var $element = $(element); + var $value = null; - if ($element.getTagName() === 'input') { - var $type = $element.attr('type'); + switch ($element.getTagName()) { + case 'input': + var $type = $element.attr('type'); + + if (($type === 'radio' || $type === 'checkbox') && !$element.prop('checked')) { + return; + } + break; - if (($type === 'radio' || $type === 'checkbox') && !$element.prop('checked')) { - return; - } + case 'textarea': + if ($element.data('redactor')) { + $value = $element.redactor('getText'); + } + break; } var $name = $element.attr('name'); if ($regExp.test($name)) { - $values[RegExp.$1] = $element.val(); + $values[RegExp.$1] = ($value === null) ? $element.val() : $value; } }); @@ -731,7 +740,7 @@ WCF.User.Profile.Editor = Class.extend({ this._actionName = 'restore'; this._buttons.beginEdit.show(); - this._destroyCKEditor(); + this._destroyEditor(); this._tab.html(this._cachedTemplate).children().css({ height: 'auto' }); }, @@ -769,7 +778,7 @@ WCF.User.Profile.Editor = Class.extend({ * @param boolean disableCache */ _prepareEdit: function(data, disableCache) { - this._destroyCKEditor(); + this._destroyEditor(); // update template var self = this; @@ -788,7 +797,7 @@ WCF.User.Profile.Editor = Class.extend({ this._tab.find('.formSubmit > button[data-type=save]').click($.proxy(this._save, this)); this._tab.find('.formSubmit > button[data-type=restore]').click($.proxy(this._restore, this)); this._tab.find('input').keyup(function(event) { - if (event.which === 13) { // Enter + if (event.which === $.ui.keyCode.ENTER) { self._save(); event.preventDefault(); @@ -798,14 +807,14 @@ WCF.User.Profile.Editor = Class.extend({ }, /** - * Destroys all CKEditor instances within current tab. + * Destroys all editor instances within current tab. */ - _destroyCKEditor: function() { - // destroy all CKEditor instances - this._tab.find('textarea + .cke').each(function(index, container) { - var $instanceName = $(container).attr('id').replace(/cke_/, ''); - if (CKEDITOR.instances[$instanceName]) { - CKEDITOR.instances[$instanceName].destroy(); + _destroyEditor: function() { + // destroy all editor instances + this._tab.find('textarea').each(function(index, container) { + var $container = $(container); + if ($container.data('redactor')) { + $container.redactor('destroy'); } }); }