From 1858c2fb02275fa1c262e98c69897194fd48b4f8 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 6 Oct 2014 02:15:10 +0200 Subject: [PATCH] Fixed some issues --- com.woltlab.wcf/templates/wysiwyg.tpl | 30 ++++++------ .../js/3rdParty/redactor/plugins/wbbcode.js | 14 +++--- .../js/3rdParty/redactor/plugins/wutil.js | 46 ++++++++++++------- 3 files changed, 51 insertions(+), 39 deletions(-) diff --git a/com.woltlab.wcf/templates/wysiwyg.tpl b/com.woltlab.wcf/templates/wysiwyg.tpl index a477148ea6..a9981ef78b 100644 --- a/com.woltlab.wcf/templates/wysiwyg.tpl +++ b/com.woltlab.wcf/templates/wysiwyg.tpl @@ -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'} diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js index 60cf3cb55b..eda3ae94a9 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js @@ -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; diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js index 00c414bc87..09083c9da2 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js @@ -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); -- 2.20.1