Improved editor and scroll on init
authorAlexander Ebert <ebert@woltlab.com>
Sat, 12 Jul 2014 14:16:38 +0000 (16:16 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 12 Jul 2014 14:16:38 +0000 (16:16 +0200)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js
wcfsetup/install/files/js/WCF.Attachment.js
wcfsetup/install/files/js/WCF.Message.js
wcfsetup/install/files/lib/system/message/QuickReplyManager.class.php

index a480aa7dd524f0285b9b483e6c345681d22e1e48..487da1800516a2dde7895a5130ba782a7f9785c3 100644 (file)
@@ -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() });
        },
        
        /**
index 526c420bcac26617db14a57a9cd424c0dbb4623c..fedf10c8c3eebb4befcc004908bed66c163f22eb 100644 (file)
@@ -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();
        },
        
        /**
index 5652fa7c65cf94d488ad39a1e971722546f6dd66..5128ef800b7a2947bc59b2850abf02e65035b1a2 100644 (file)
@@ -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 {
index 2bb68353e04867e10feff4fb6f6f7325a1839c58..5ced53d9e06389eee377f51061643bc08822f17b 100644 (file)
@@ -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));