Strip `data-title` in HTML view
authorAlexander Ebert <ebert@woltlab.com>
Fri, 6 Jan 2017 10:58:13 +0000 (11:58 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 6 Jan 2017 10:58:19 +0000 (11:58 +0100)
This is a dynamic property used for visual purposes only and is computed
on-the-fly when editing the other `data`-attributes.

wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSource.js

index 66ffc4f6a14a6df52dd4518ec4244b42676c01f2..bd57c711b74ba3fb46a7c08f1cd050089d7e8fd2 100644 (file)
@@ -3,6 +3,8 @@ $.Redactor.prototype.WoltLabSource = function() {
        
        return {
                init: function () {
+                       var id = this.$element[0].id;
+                       
                        var fixQuotes = function(container) {
                                // fix empty quotes suffering from a superfluous <p></p>
                                elBySelAll('woltlab-quote', container, function(quote) {
@@ -24,6 +26,14 @@ $.Redactor.prototype.WoltLabSource = function() {
                                });
                        };
                        
+                       var stripIntermediateCode = function(div) {
+                               elBySelAll('pre, woltlab-quote, woltlab-spoiler', div, function (element) {
+                                       element.removeAttribute('data-title');
+                               });
+                               
+                               WCF.System.Event.fireEvent('com.woltlab.wcf.redactor2', 'source_' + stripIntermediateCode + '_' + id, { div: div });
+                       };
+                       
                        function stripIcons(div) {
                                elBySelAll('.icon, .fa', div, function (element) {
                                        var classNames = element.className.split(' ');
@@ -88,13 +98,14 @@ $.Redactor.prototype.WoltLabSource = function() {
                                var div = elCreate('div');
                                div.innerHTML = textarea.value;
                                fixQuotes(div);
+                               stripIntermediateCode(div);
                                
                                textarea.value = this.WoltLabSource.format(div.innerHTML);
                                
                                textarea.selectionStart = textarea.selectionEnd = textarea.value.length;
                        }).bind(this);
                        
-                       WCF.System.Event.addListener('com.woltlab.wcf.redactor2', 'validate_' + this.$element[0].id, (function (data) {
+                       WCF.System.Event.addListener('com.woltlab.wcf.redactor2', 'validate_' + id, (function (data) {
                                if (textarea.clientHeight) {
                                        data.api.throwError(this.$element[0], WCF.Language.get('wcf.editor.source.error.active'));
                                        data.valid = false;