Fixed BBCodes on init, properly clear storage on edit cancel
authorAlexander Ebert <ebert@woltlab.com>
Thu, 27 Mar 2014 19:08:18 +0000 (20:08 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 27 Mar 2014 19:08:18 +0000 (20:08 +0100)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js
wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js
wcfsetup/install/files/js/WCF.Message.js

index 7fc2e3808d7ea6ec39117a554f68cfe56e5917c7..0ec0169f8c6331d398ce89284992b8d1c28a55d1 100644 (file)
@@ -18,6 +18,13 @@ RedactorPlugins.wbbcode = {
                        this.dropdownShow(e, btnName);
                }, this));
                this.buttonAwesome('wsmiley', 'fa-smile-o');
+               
+               this.opts.initCallback = $.proxy(function() {
+                       if (this.$source.val().length) {
+                               this.toggle();
+                               this.toggle();
+                       }
+               }, this);
        },
        
        /**
@@ -89,17 +96,6 @@ RedactorPlugins.wbbcode = {
                return true;
        },
        
-       /**
-        * Overwrites $.Redactor.buildContent() to handle BBCode -> HTML on init
-        */
-       buildContent: function() {
-               if (this.opts.textareamode) this.content = $.trim(this.$source.val());
-               else {
-                       this._convertToHtml();
-                       this.content = $.trim(this.$source.html());
-               }
-       },
-       
        /**
         * Overwrites $.Redactor.toggle() to transform the source mode into a BBCode view.
         * 
index 2d5b59c097132860b70173a8727deea65fe386a4..9ea65907f7a44201fd6816fbdf128acc1ae59a9b 100644 (file)
@@ -34,6 +34,14 @@ RedactorPlugins.wutil = {
                
                // prevent Redactor's own autosave
                this.setOption('autosave', false);
+               
+               // disable autosave on destroy
+               var $mpDestroy = this.destroy;
+               var self = this;
+               this.destroy = function() {
+                       self.autosaveDisable();
+                       $mpDestroy.call(self);
+               };
        },
        
        /**
index f36592e3705165a7638055cfefe237a1c2f15cb7..2dea0f1d9ae718c14b4d3da46fb5fec19280ba73 100644 (file)
@@ -1219,14 +1219,10 @@ WCF.Message.InlineEditor = Class.extend({
        _cancel: function() {
                var $container = this._container[this._activeElementID].removeClass('jsInvalidQuoteTarget');
                
-               // remove ckEditor
-               try {
-                       var $ckEditor = $('#' + this._messageEditorIDPrefix + $container.data('objectID')).ckeditorGet();
-                       $ckEditor.destroy();
-               }
-               catch (e) {
-                       // CKEditor might be not initialized yet, ignore
-               }
+               // remove editor
+               var $target = $('#' + this._messageEditorIDPrefix + $container.data('objectID'));
+               $target.redactor('autosavePurge');
+               $target.redactor('destroy');
                
                // restore message
                var $messageBody = $container.find('.messageBody');