Fixed some issues
authorAlexander Ebert <ebert@woltlab.com>
Mon, 6 Oct 2014 00:15:10 +0000 (02:15 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 6 Oct 2014 00:15:10 +0000 (02:15 +0200)
com.woltlab.wcf/templates/wysiwyg.tpl
wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js
wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js

index a477148ea6007cb876fa270e97064cf2b31f57d3..a9981ef78b28dc6babea6d5f6aeb2b32294e54cb 100644 (file)
@@ -33,31 +33,31 @@ $(function() {
                        autosave: false,
                        buttons: $buttons,
                        buttonSource: true,
-                       imageResizable: false,
-                       removeEmpty: false,
-                       replaceDivs: false,
-                       tabifier: false,
-                       
-                       {* TODO: possible outdated/deprecated options below *}
-                       convertDivs: false,
                        convertImageLinks: false,
-                       convertLinks: false,
+                       convertUrlLinks: false,
                        convertVideoLinks: false,
                        direction: '{lang}wcf.global.pageDirection{/lang}',
+                       imageResizable: false,
                        lang: '{@$__wcf->getLanguage()->getFixedLanguageCode()}',
+                       maxHeight: 500,
                        minHeight: 200,
                        plugins: [ 'wutil',  'wmonkeypatch', 'table', 'wbutton', 'wbbcode',  'wfontcolor', 'wfontfamily', 'wfontsize', 'wupload' ],
-                       wautosave: {
-                               active: (/* DEBUG ONLY $autosave*/false) ? true : false,
-                               key: ($autosave) ? '{@$__wcf->getAutosavePrefix()}_' + $autosave : '',
-                               saveOnInit: {if !$errorField|empty}true{else}false{/if}
-                       },
-                       wOriginalValue: $textarea.val()
+                       removeEmpty: false,
+                       replaceDivs: false,
+                       tabifier: false,
+                       woltlab: {
+                               autosave: {
+                                       active: ($autosave) ? true : false,
+                                       key: ($autosave) ? '{@$__wcf->getAutosavePrefix()}_' + $autosave : '',
+                                       saveOnInit: {if !$errorField|empty}true{else}false{/if}
+                               },
+                               originalValue: $textarea.val()
+                       }
                };
                
                {if MODULE_ATTACHMENT && !$attachmentHandler|empty && $attachmentHandler->canUpload()}
                        $config.plugins.push('wupload');
-                       $config.wAttachmentUrl = '{link controller='Attachment' id=987654321}thumbnail=1{/link}';
+                       $config.woltlab.attachmentUrl = '{link controller='Attachment' id=987654321}thumbnail=1{/link}';
                {/if}
                
                {event name='javascriptInit'}
index 60cf3cb55b46f58e794a265a8d31154f12701a4e..eda3ae94a9d7951ac523dd2725c46cb5bdc14b0b 100644 (file)
@@ -19,12 +19,12 @@ RedactorPlugins.wbbcode = function() {
                        
                        this.opts.initCallback = $.proxy(function() {
                                // use stored editor contents
-                               var $content = $.trim(this.wutil.getOption('wOriginalValue'));
+                               var $content = $.trim(this.wutil.getOption('woltlab.originalValue'));
                                if ($content.length) {
                                        this.wutil.replaceText($content);
                                }
                                
-                               delete this.opts.wOriginalValue;
+                               delete this.opts.woltlab.originalValue;
                                
                                $(document).trigger('resize');
                        }, this);
@@ -38,9 +38,9 @@ RedactorPlugins.wbbcode = function() {
                                return $mpCleanOnSync.call(self, html);
                        };
                        
-                       if (this.wutil.getOption('wAutosaveOnce')) {
+                       if (this.wutil.getOption('woltlab.autosaveOnce')) {
                                this.wutil._saveTextToStorage();
-                               delete this.opts.wAutosaveOnce;
+                               delete this.opts.woltlab.autosaveOnce;
                        }
                        
                        // we do not support table heads
@@ -630,7 +630,7 @@ RedactorPlugins.wbbcode = function() {
                        });
                        
                        // attachments
-                       var $attachmentUrl = this.wutil.getOption('wAttachmentUrl');
+                       var $attachmentUrl = this.wutil.getOption('woltlab.attachmentUrl');
                        if ($attachmentUrl) {
                                var $imageAttachmentIDs = this.wbbcode._getImageAttachmentIDs();
                                
@@ -909,7 +909,7 @@ RedactorPlugins.wbbcode = function() {
                 */
                insertAttachment: function(attachmentID) {
                        attachmentID = parseInt(attachmentID);
-                       var $attachmentUrl = this.getOption('wAttachmentUrl');
+                       var $attachmentUrl = this.getOption('woltlab.attachmentUrl');
                        var $bbcode = '[attach=' + attachmentID + '][/attach]';
                        
                        var $imageAttachmentIDs = this.wbbcode._getImageAttachmentIDs();
@@ -932,7 +932,7 @@ RedactorPlugins.wbbcode = function() {
                 */
                _getImageAttachmentIDs: function() {
                        // WCF.Attachment.Upload may have no been initialized yet, fallback to static data
-                       var $imageAttachmentIDs = this.wutil.getOption('wAttachmentImageIDs') || [ ];
+                       var $imageAttachmentIDs = this.wutil.getOption('woltlab.attachmentImageIDs') || [ ];
                        if ($imageAttachmentIDs.length) {
                                delete this.opts.wAttachmentImageIDs;
                                
index 00c414bc877a02b409269253cca68ff3c995aa17..09083c9da279ade647b791cb2bbde6721458fcce 100644 (file)
@@ -24,11 +24,11 @@ RedactorPlugins.wutil = function() {
                        // convert HTML to BBCode upon submit
                        this.$textarea.parents('form').submit($.proxy(this.wutil.submit, this));
                        
-                       if (this.wutil.getOption('wautosave').active) {
+                       if (this.wutil.getOption('woltlab.autosave').active) {
                                this.wutil.autosaveEnable();
                                
-                               if (this.wutil.getOption('wautosave').saveOnInit || this.$textarea.data('saveOnInit')) {
-                                       this.wutil.setOption('wAutosaveOnce', true);
+                               if (this.wutil.getOption('woltlab.autosave').saveOnInit || this.$textarea.data('saveOnInit')) {
+                                       this.wutil.setOption('woltlab.autosaveOnce', true);
                                }
                                else {
                                        this.wutil.autosaveRestore();
@@ -99,7 +99,13 @@ RedactorPlugins.wutil = function() {
                 * @param       mixed           value
                 */
                setOption: function(key, value) {
-                       this.opts[key] = value;
+                       if (key.indexOf('.') !== -1) {
+                               key = key.split('.', 2);
+                               this.opts[key[0]][key[1]] = value;
+                       }
+                       else {
+                               this.opts[key] = value;
+                       }
                },
                
                /**
@@ -109,7 +115,13 @@ RedactorPlugins.wutil = function() {
                 * @return      mixed
                 */
                getOption: function(key) {
-                       if (this.opts[key]) {
+                       if (key.indexOf('.') !== -1) {
+                               key = key.split('.', 2);
+                               if (this.opts[key[0]][key[1]]) {
+                                       return this.opts[key[0]][key[1]];
+                               }
+                       }
+                       else if (this.opts[key]) {
                                return this.opts[key];
                        }
                        
@@ -202,15 +214,15 @@ RedactorPlugins.wutil = function() {
                 * @param       string          key
                 */
                autosaveEnable: function(key) {
-                       if (!this.wutil.getOption('wautosave').active) {
-                               this.wutil.setOption('wautosave', {
+                       if (!this.wutil.getOption('woltlab.autosave').active) {
+                               this.wutil.setOption('woltlab.autosave', {
                                        active: true,
                                        key: key
                                });
                        }
                        
-                       if (this._autosaveWorker === null) {
-                               this._autosaveWorker = new WCF.PeriodicalExecuter($.proxy(this._saveTextToStorage, this), 60 * 1000);
+                       if (this.wutil._autosaveWorker === null) {
+                               this.wutil._autosaveWorker = new WCF.PeriodicalExecuter($.proxy(this.wutil._saveTextToStorage, this), 60 * 1000);
                        }
                        
                        return true;
@@ -220,21 +232,21 @@ RedactorPlugins.wutil = function() {
                 * Saves current editor text to local browser storage.
                 */
                _saveTextToStorage: function() {
-                       localStorage.setItem(this.getOption('wautosave').key, this.getText());
+                       localStorage.setItem(this.wutil.getOption('woltlab.autosave').key, this.wutil.getText());
                },
                
                /**
                 * Disables automatic saving.
                 */
                autosaveDisable: function() {
-                       if (!this.getOption('wautosave').active) {
+                       if (!this.getOption('woltlab.autosave').active) {
                                return false;
                        }
                        
-                       this._autosaveWorker.stop();
-                       this._autosaveWorker = null;
+                       this.wutil._autosaveWorker.stop();
+                       this.wutil._autosaveWorker = null;
                        
-                       this.setOption('wautosave', {
+                       this.wutil.setOption('woltlab.autosave', {
                                active: false,
                                key: ''
                        });
@@ -248,18 +260,18 @@ RedactorPlugins.wutil = function() {
                 * @param       string          key
                 */
                autosavePurge: function() {
-                       localStorage.removeItem(this.getOption('wautosave').key);
+                       localStorage.removeItem(this.wutil.getOption('woltlab.autosave').key);
                },
                
                /**
                 * Attempts to restore a saved text.
                 */
                autosaveRestore: function() {
-                       var $options = this.wutil.getOption('wautosave');
+                       var $options = this.wutil.getOption('woltlab.autosave');
                        var $text = localStorage.getItem($options.key);
                        if ($text !== null) {
                                if (this.wutil.inWysiwygMode()) {
-                                       this.wutil.setOption('wOriginalValue', $text);
+                                       this.wutil.setOption('woltlab.originalValue', $text);
                                }
                                else {
                                        this.$textarea.val($text);