From c0ba497625ea0653cee86d30d70d866823ef3c60 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 12 Jul 2014 16:16:38 +0200 Subject: [PATCH] Improved editor and scroll on init --- .../js/3rdParty/redactor/plugins/wutil.js | 2 +- wcfsetup/install/files/js/WCF.Attachment.js | 25 +++++++++++++++++++ wcfsetup/install/files/js/WCF.Message.js | 15 +++++------ .../message/QuickReplyManager.class.php | 6 ++++- 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js index a480aa7dd5..487da18005 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js @@ -177,7 +177,7 @@ RedactorPlugins.wutil = { this.$source.val(''); } - WCF.System.Event.fireEvent('com.woltlab.wcf.redactor', 'reset'); + WCF.System.Event.fireEvent('com.woltlab.wcf.redactor', 'reset', { wysiwygContainerID: this.$source.wcfIdentify() }); }, /** diff --git a/wcfsetup/install/files/js/WCF.Attachment.js b/wcfsetup/install/files/js/WCF.Attachment.js index 526c420bca..fedf10c8c3 100644 --- a/wcfsetup/install/files/js/WCF.Attachment.js +++ b/wcfsetup/install/files/js/WCF.Attachment.js @@ -70,6 +70,31 @@ WCF.Attachment.Upload = WCF.Upload.extend({ if (this._fileListSelector.children('li:not(.uploadFailed)').length) { this._insertAllButton.show(); } + + if (this._wysiwygContainerID) { + WCF.System.Event.addListener('com.woltlab.wcf.messageOptionsInline', 'submit_' + this._wysiwygContainerID, $.proxy(this._submitInline, this)); + WCF.System.Event.addListener('com.woltlab.wcf.redactor', 'reset', $.proxy(this._reset, this)); + } + }, + + /** + * Adds parameters for the inline editor. + * + * @param object data + */ + _submitInline: function(data) { + if (this._tmpHash) { + data.tmpHash = this._tmpHash; + } + }, + + /** + * Resets the attachment container. + */ + _reset: function() { + this._fileListSelector.hide().empty(); + this._insertAllButton.hide(); + this._validateLimit(); }, /** diff --git a/wcfsetup/install/files/js/WCF.Message.js b/wcfsetup/install/files/js/WCF.Message.js index 5652fa7c65..5128ef800b 100644 --- a/wcfsetup/install/files/js/WCF.Message.js +++ b/wcfsetup/install/files/js/WCF.Message.js @@ -135,11 +135,11 @@ WCF.Message.EditHistory = Class.extend({ _initInputs: function() { var self = this; this._newIDInputs.change(function(event) { - var newID = parseInt($(this).val()) + var newID = parseInt($(this).val()); if ($(this).val() === 'current') newID = Infinity; self._oldIDInputs.each(function(event) { - var oldID = parseInt($(this).val()) + var oldID = parseInt($(this).val()); if ($(this).val() === 'current') oldID = Infinity; if (oldID >= newID) { @@ -156,7 +156,7 @@ WCF.Message.EditHistory = Class.extend({ if ($(this).val() === 'current') oldID = Infinity; self._newIDInputs.each(function(event) { - var newID = parseInt($(this).val()) + var newID = parseInt($(this).val()); if ($(this).val() === 'current') newID = Infinity; if (newID <= oldID) { @@ -827,8 +827,8 @@ WCF.Message.QuickReply = Class.extend({ if (this._container.is(':visible')) { this._quickReplyButtons.hide(); - // TODO: Scrolling is anything but smooth, better use the init callback - this._scroll.scrollTo(this._container, true); + var self = this; + window.setTimeout(function() { self._scroll.scrollTo(self._container, true); }, 100); WCF.Message.Submit.registerButton('text', this._container.find('.formSubmit button[data-type=save]')); @@ -964,8 +964,7 @@ WCF.Message.QuickReply = Class.extend({ }, lastPostTime: this._container.data('lastPostTime'), pageNo: this._container.data('pageNo'), - removeQuoteIDs: (this._quoteManager === null ? [ ] : this._quoteManager.getQuotesMarkedForRemoval()), - tmpHash: this._container.data('tmpHash') || '' + removeQuoteIDs: (this._quoteManager === null ? [ ] : this._quoteManager.getQuotesMarkedForRemoval()) }; if (this._container.data('anchor')) { $parameters.anchor = this._container.data('anchor'); @@ -1489,6 +1488,8 @@ WCF.Message.InlineEditor = Class.extend({ if (this._quoteManager) { this._quoteManager.setAlternativeEditor($element); } + + new WCF.Effect.Scroll().scrollTo(this._container[this._activeElementID], true); }, this), 250); } else { diff --git a/wcfsetup/install/files/lib/system/message/QuickReplyManager.class.php b/wcfsetup/install/files/lib/system/message/QuickReplyManager.class.php index 2bb68353e0..5ced53d9e0 100644 --- a/wcfsetup/install/files/lib/system/message/QuickReplyManager.class.php +++ b/wcfsetup/install/files/lib/system/message/QuickReplyManager.class.php @@ -155,7 +155,11 @@ class QuickReplyManager extends SingletonFactory { $parameters['removeQuoteIDs'] = (isset($parameters['removeQuoteIDs']) && is_array($parameters['removeQuoteIDs'])) ? ArrayUtil::trim($parameters['removeQuoteIDs']) : array(); // check for tmp hash (attachments) - $parameters['tmpHash'] = (isset($parameters['tmpHash'])) ? StringUtil::trim($parameters['tmpHash']) : ''; + $parameters['tmpHash'] = ''; + if (isset($parameters['data']['tmpHash'])) { + $parameters['tmpHash'] = StringUtil::trim($parameters['data']['tmpHash']); + unset($parameters['data']['tmpHash']); + } // message settings $parameters['data'] = array_merge($parameters['data'], MessageFormSettingsHandler::getSettings($parameters)); -- 2.20.1