[TASK] t3editor: Remove Prototype and Scriptaculous 81/41281/6
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Wed, 15 Jul 2015 11:57:21 +0000 (13:57 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Wed, 15 Jul 2015 13:25:38 +0000 (15:25 +0200)
Resolves: #68165
Releases: master
Change-Id: I0fcf3a90913ded4e827cb31fc76152b89b534a5f
Reviewed-on: http://review.typo3.org/41281
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/t3editor/Classes/T3editor.php
typo3/sysext/t3editor/Resources/Public/JavaScript/T3editor.js

index c01d6ce..eb2ff55 100644 (file)
@@ -181,10 +181,6 @@ class T3editor implements \TYPO3\CMS\Core\SingletonInterface {
                /** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */
                $pageRenderer = $this->getPageRenderer();
 
-               // Include needed javascript-frameworks
-               $pageRenderer->loadPrototype();
-               $pageRenderer->loadScriptaculous();
-
                // Include editor-css
                $cssFile = GeneralUtility::createVersionNumberedFilename($GLOBALS['BACK_PATH'] . $this->relExtPath . 'res/css/t3editor.css');
                $doc->addStyleSheet('t3editor', $cssFile);
index 42f17b7..3be8140 100644 (file)
@@ -85,8 +85,9 @@ define('TYPO3/CMS/T3editor/T3editor', ['jquery'], function ($) {
        T3editor.setAjaxSavetypeCallback = function(codemirror) {
                if (codemirror.options.ajaxSaveType !== '') {
                        $(document).on('t3editor:save', function(e, data) {
-                               var params = Object.extend({
-                                       t3editor_savetype: codemirror.options.ajaxSaveType
+                               var params = $.extend({
+                                       t3editor_savetype: codemirror.options.ajaxSaveType,
+                                       submit: true
                                }, data.parameters);
 
                                $.ajax({
@@ -115,9 +116,8 @@ define('TYPO3/CMS/T3editor/T3editor', ['jquery'], function ($) {
                }
 
                codemirror.options.originalTextarea.val(codemirror.getCode());
-
-               var params = codemirror.options.originalTextarea.get(0).form.serialize(true);
-               params = Object.extend({t3editor_disableEditor: 'false'}, params);
+               var params = codemirror.options.originalTextarea.closest('form').serializeObject();
+               params = $.extend({t3editor_disableEditor: 'false'}, params);
 
                $(document).trigger('t3editor:save', {parameters: params, t3editor: this});
        };
@@ -130,9 +130,9 @@ define('TYPO3/CMS/T3editor/T3editor', ['jquery'], function ($) {
                        this.textModified = false;
                } else {
                        if (typeof returnedData.exceptionMessage !== 'undefined') {
-                               top.TYPO3.Notification.error(codemirror.labels.errorWhileSaving[0]['target'], returnedData.exceptionMessage);
+                               top.TYPO3.Notification.error(codemirror.options.labels.errorWhileSaving[0]['target'], returnedData.exceptionMessage);
                        } else {
-                               top.TYPO3.Notification.error(codemirror.labels.errorWhileSaving[0]['target'], '');
+                               top.TYPO3.Notification.error(codemirror.options.labels.errorWhileSaving[0]['target'], '');
                        }
                }
        };
@@ -195,6 +195,28 @@ define('TYPO3/CMS/T3editor/T3editor', ['jquery'], function ($) {
        };
 
        /**
+        * Serialize a form to a JavaScript object
+        *
+        * @see http://stackoverflow.com/a/1186309/4828813
+        * @returns {Object}
+        */
+       $.fn.serializeObject = function() {
+               var o = {};
+               var a = this.serializeArray();
+               $.each(a, function() {
+                       if (typeof o[this.name] !== 'undefined') {
+                               if (!o[this.name].push) {
+                                       o[this.name] = [o[this.name]];
+                               }
+                               o[this.name].push(this.value || '');
+                       } else {
+                               o[this.name] = this.value || '';
+                       }
+               });
+               return o;
+       };
+
+       /**
         * Initialize and return the T3editor object
         */
        $(document).ready(function() {
@@ -204,4 +226,4 @@ define('TYPO3/CMS/T3editor/T3editor', ['jquery'], function ($) {
 
        TYPO3.T3editor = T3editor;
        return T3editor;
-});
+});
\ No newline at end of file