MDL-48467 atto: Clean the textarea during submission when in HTML mode
authorEric Merrill <merrill@oakland.edu>
Fri, 27 Mar 2015 17:37:35 +0000 (13:37 -0400)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 18 May 2015 23:39:22 +0000 (01:39 +0200)
lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button-debug.js
lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button-min.js
lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button.js
lib/editor/atto/plugins/html/yui/src/button/js/button.js

index 8e19cb2..5bb7914 100644 (file)
Binary files a/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button-debug.js and b/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button-debug.js differ
index 0b9d2ea..16fb192 100644 (file)
Binary files a/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button-min.js and b/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button-min.js differ
index 8e19cb2..5bb7914 100644 (file)
Binary files a/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button.js and b/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button.js differ
index 9c65d86..b863999 100644 (file)
@@ -37,6 +37,12 @@ Y.namespace('M.atto_html').Button = Y.Base.create('button', Y.M.editor_atto.Edit
             icon: 'e/source_code',
             callback: this._toggleHTML
         });
+
+        // Attach a submit listener to the form.
+        var form = this.get('host').textarea.ancestor('form');
+        if (form) {
+            form.on('submit', this._submitClean, this);
+        }
     },
 
     /**
@@ -107,10 +113,25 @@ Y.namespace('M.atto_html').Button = Y.Base.create('button', Y.M.editor_atto.Edit
             this.editor.hide();
             host.textarea.show();
 
-
             // Focus on the textarea.
             host.textarea.focus();
         }
+    },
+
+    /**
+     * Run the textarea content through the HTML scrubber if it was form submitted in HTML mode.
+     *
+     * @method _submitClean
+     * @private
+     */
+    _submitClean: function() {
+        // If we are in HTML mode, clean the text area.
+        if (this.get('isHTML')) {
+            var host = this.get('host');
+            // Update the editor from text area then textarea from editor. This ensures all proper cleaning happens.
+            host.updateFromTextArea();
+            host.updateOriginal();
+        }
     }
 }, {
     ATTRS: {