[BUGFIX] Use Modals via dependencies only 05/44005/2
authorMarkus Klein <markus.klein@typo3.org>
Mon, 12 Oct 2015 09:41:34 +0000 (11:41 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Mon, 12 Oct 2015 11:18:33 +0000 (13:18 +0200)
Makes sure that AMD modules do not use top.TYPO3.Modal, but access
the Modal via a normal dependency only.
The Modal modules takes care of correctly registering and returning
the necessary object.

Resolves: #70614
Releases: master
Change-Id: I52c41325a6363cf78d9bfb601d7dd5df67473a07
Reviewed-on: http://review.typo3.org/44005
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Resources/Public/JavaScript/AjaxDataHandler.js
typo3/sysext/backend/Resources/Public/JavaScript/DragUploader.js
typo3/sysext/backend/Resources/Public/JavaScript/FormEngine.js
typo3/sysext/backend/Resources/Public/JavaScript/ImageManipulation.js
typo3/sysext/backend/Resources/Public/JavaScript/Modal.js
typo3/sysext/backend/Resources/Public/JavaScript/OnlineMedia.js
typo3/sysext/backend/Resources/Public/JavaScript/Toolbar/ShortcutMenu.js
typo3/sysext/extensionmanager/Resources/Public/JavaScript/Main.js
typo3/sysext/impexp/Resources/Public/JavaScript/ImportExport.js
typo3/sysext/recycler/Resources/Public/JavaScript/Recycler.js
typo3/sysext/sys_action/Resources/Public/JavaScript/ActionTask.js

index 0ed59a2..71479ae 100644 (file)
@@ -14,7 +14,7 @@
 /**
  * AjaxDataHandler - Javascript functions to work with AJAX and interacting with tce_db.php
  */
-define(['jquery', 'TYPO3/CMS/Backend/Notification', 'TYPO3/CMS/Backend/Modal'], function ($) {
+define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Notification'], function ($, Modal) {
        'use strict';
 
        var AjaxDataHandler = {};
@@ -66,7 +66,7 @@ define(['jquery', 'TYPO3/CMS/Backend/Notification', 'TYPO3/CMS/Backend/Modal'],
                $(document).on('click', '.t3js-record-delete', function(evt) {
                        evt.preventDefault();
                        var $anchorElement = $(this);
-                       var $modal = top.TYPO3.Modal.confirm($anchorElement.data('title'), $anchorElement.data('message'), top.TYPO3.Severity.warning, [
+                       var $modal = Modal.confirm($anchorElement.data('title'), $anchorElement.data('message'), top.TYPO3.Severity.warning, [
                                {
                                        text: $(this).data('button-close-text') || TYPO3.lang['button.cancel'] || 'Cancel',
                                        active: true,
@@ -80,9 +80,9 @@ define(['jquery', 'TYPO3/CMS/Backend/Notification', 'TYPO3/CMS/Backend/Modal'],
                        ]);
                        $modal.on('button.clicked', function(e) {
                                if (e.target.name === 'cancel') {
-                                       top.TYPO3.Modal.dismiss();
+                                       Modal.dismiss();
                                } else if (e.target.name === 'delete') {
-                                       top.TYPO3.Modal.dismiss();
+                                       Modal.dismiss();
                                        AjaxDataHandler.deleteRecord($anchorElement);
                                }
                        });
index 32c9789..24de4bc 100644 (file)
@@ -15,7 +15,7 @@
  * JavaScript RequireJS module called "TYPO3/CMS/Backend/DragUploader"
  *
  */
-define(['jquery', 'moment', 'nprogress', 'TYPO3/CMS/Lang/Lang', 'TYPO3/CMS/Backend/Modal'], function($, moment, NProgress) {
+define(['jquery', 'moment', 'nprogress', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Lang/Lang'], function($, moment, NProgress, Modal) {
 
        /**
         * Array of files which are asked for being overridden
@@ -284,7 +284,7 @@ define(['jquery', 'moment', 'nprogress', 'TYPO3/CMS/Lang/Lang', 'TYPO3/CMS/Backe
                                $modalContent.find('table').append($record);
                        }
 
-                       var $modal = top.TYPO3.Modal.confirm(TYPO3.lang['file_upload.existingfiles.title'], $modalContent, top.TYPO3.Severity.warning, [
+                       var $modal = Modal.confirm(TYPO3.lang['file_upload.existingfiles.title'], $modalContent, top.TYPO3.Severity.warning, [
                                {
                                        text: $(this).data('button-close-text') || TYPO3.lang['file_upload.button.cancel'] || 'Cancel',
                                        active: true,
@@ -333,7 +333,7 @@ define(['jquery', 'moment', 'nprogress', 'TYPO3/CMS/Lang/Lang', 'TYPO3/CMS/Backe
                        }).on('button.clicked', function(e) {
                                if (e.target.name === 'cancel') {
                                        askForOverride = [];
-                                       top.TYPO3.Modal.dismiss();
+                                       Modal.dismiss();
                                } else if (e.target.name === 'continue') {
                                        $.each(askForOverride, function(key, fileInfo) {
                                                if (fileInfo.action === actions.USE_EXISTING) {
@@ -346,7 +346,7 @@ define(['jquery', 'moment', 'nprogress', 'TYPO3/CMS/Lang/Lang', 'TYPO3/CMS/Backe
                                                }
                                        });
                                        askForOverride = [];
-                                       top.TYPO3.Modal.dismiss();
+                                       Modal.dismiss();
                                }
                        }).on('hidden.bs.modal', function() {
                                askForOverride = [];
@@ -580,10 +580,12 @@ define(['jquery', 'moment', 'nprogress', 'TYPO3/CMS/Lang/Lang', 'TYPO3/CMS/Backe
                                if (typeof option === 'string') {
                                        data[option]();
                                }
-                       })
+                       });
                };
 
-               $('.t3js-drag-uploader').dragUploader();
+               $(function() {
+                       $('.t3js-drag-uploader').dragUploader();
+               });
        };
 
 
index cb55043..47cc40c 100644 (file)
@@ -28,7 +28,8 @@ var setFormValueOpenBrowser
        ,setFormValue_getFObj;
 
 
-define(['jquery'], function ($) {
+define(['jquery', 'TYPO3/CMS/Backend/Modal'], function ($, Modal) {
+
 
        // main options
        var FormEngine = {
@@ -596,7 +597,7 @@ define(['jquery'], function ($) {
                        var title = TYPO3.lang['label.confirm.delete_record.title'] || 'Delete this record?';
                        var content = TYPO3.lang['label.confirm.delete_record.content'] || 'Are you sure you want to delete this record?';
                        var $anchorElement = $(this);
-                       var $modal = top.TYPO3.Modal.confirm(title, content, top.TYPO3.Severity.warning, [
+                       var $modal = Modal.confirm(title, content, top.TYPO3.Severity.warning, [
                                {
                                        text: TYPO3.lang['buttons.confirm.delete_record.no'] || 'Cancel',
                                        active: true,
@@ -610,10 +611,10 @@ define(['jquery'], function ($) {
                        ]);
                        $modal.on('button.clicked', function(e) {
                                if (e.target.name === 'no') {
-                                       top.TYPO3.Modal.dismiss();
+                                       Modal.dismiss();
                                } else if (e.target.name === 'yes') {
                                        deleteRecord($anchorElement.data('table'), $anchorElement.data('uid'), $anchorElement.data('return-url'));
-                                       top.TYPO3.Modal.dismiss();
+                                       Modal.dismiss();
                                }
                        });
                });
@@ -623,7 +624,7 @@ define(['jquery'], function ($) {
                        var title = TYPO3.lang['label.confirm.delete_record.title'] || 'Delete this record?';
                        var content = TYPO3.lang['label.confirm.delete_record.content'] || 'Are you sure you want to delete this record?';
                        var $anchorElement = $(this);
-                       var $modal = top.TYPO3.Modal.confirm(title, content, top.TYPO3.Severity.warning, [
+                       var $modal = Modal.confirm(title, content, top.TYPO3.Severity.warning, [
                                {
                                        text: TYPO3.lang['buttons.confirm.delete_record.no'] || 'Cancel',
                                        active: true,
@@ -637,11 +638,11 @@ define(['jquery'], function ($) {
                        ]);
                        $modal.on('button.clicked', function(e) {
                                if (e.target.name === 'no') {
-                                       top.TYPO3.Modal.dismiss();
+                                       Modal.dismiss();
                                } else if (e.target.name === 'yes') {
                                        var objectId = $anchorElement.data('objectid');
                                        inline.deleteRecord(objectId);
-                                       top.TYPO3.Modal.dismiss();
+                                       Modal.dismiss();
                                }
                        });
                });
@@ -836,7 +837,7 @@ define(['jquery'], function ($) {
                if ($('.has-change').length > 0) {
                        var title = TYPO3.lang['label.confirm.close_without_save.title'] || 'Do you want to quit without saving?';
                        var content = TYPO3.lang['label.confirm.close_without_save.content'] || 'You have currently unsaved changes. Are you sure that you want to discard all changes?';
-                       $modal = top.TYPO3.Modal.confirm(title, content, top.TYPO3.Severity.warning, [
+                       $modal = Modal.confirm(title, content, top.TYPO3.Severity.warning, [
                                {
                                        text: TYPO3.lang['buttons.confirm.close_without_save.no'] || 'No, I will continue editing',
                                        active: true,
@@ -850,9 +851,9 @@ define(['jquery'], function ($) {
                        ]);
                        $modal.on('button.clicked', function(e) {
                                if (e.target.name === 'no') {
-                                       top.TYPO3.Modal.dismiss();
+                                       Modal.dismiss();
                                } else if (e.target.name === 'yes') {
-                                       top.TYPO3.Modal.dismiss();
+                                       Modal.dismiss();
                                        FormEngine.closeDocument();
                                }
                        });
@@ -868,7 +869,7 @@ define(['jquery'], function ($) {
                if ($('.has-error').length > 0) {
                        var title = TYPO3.lang['label.alert.save_with_error.title'] || 'You have errors in your form!';
                        var content = TYPO3.lang['label.alert.save_with_error.content'] || 'Please check the form, there is at least one error in your form.';
-                       $modal = top.TYPO3.Modal.confirm(title, content, top.TYPO3.Severity.error, [
+                       $modal = Modal.confirm(title, content, top.TYPO3.Severity.error, [
                                {
                                        text: TYPO3.lang['buttons.alert.save_with_error.ok'] || 'OK',
                                        btnClass: 'btn-danger',
@@ -877,7 +878,7 @@ define(['jquery'], function ($) {
                        ]);
                        $modal.on('button.clicked', function(e) {
                                if (e.target.name === 'ok') {
-                                       top.TYPO3.Modal.dismiss();
+                                       Modal.dismiss();
                                }
                        });
                        return false;
index 5e2cbb3..e985f4c 100644 (file)
@@ -14,7 +14,7 @@
 /**
  * contains all logic for the image crop GUI
  */
-define(['jquery', 'TYPO3/CMS/Backend/Modal'], function ($) {
+define(['jquery', 'TYPO3/CMS/Backend/Modal'], function ($, Modal) {
 
        var ImageManipulation = {
                margin: 20,
@@ -53,7 +53,7 @@ define(['jquery', 'TYPO3/CMS/Backend/Modal'], function ($) {
         * Open modal with image to crop
         */
        ImageManipulation.show = function() {
-               ImageManipulation.currentModal = top.TYPO3.Modal.loadUrl(
+               ImageManipulation.currentModal = Modal.loadUrl(
                        ImageManipulation.$trigger.data('image-name'),
                        TYPO3.Severity.notice,
                        [],
@@ -107,7 +107,7 @@ define(['jquery', 'TYPO3/CMS/Backend/Modal'], function ($) {
                                                $modal.css({marginLeft: 'auto', marginRight: 'auto'});
 
                                                // Center modal vertical
-                                               top.TYPO3.Modal.center();
+                                               Modal.center();
 
                                                // Wait a few microseconds to let the modal resize
                                                setTimeout(ImageManipulation.initializeCropper, 100);
index 1118795..c72c9d5 100644 (file)
  * This module depends on TYPO3/CMS/Backend/Notification due to top.TYPO3.Severity.
  */
 define(['jquery', 'TYPO3/CMS/Backend/Notification', 'bootstrap'], function($) {
+       "use strict";
+
+       // fetch from parent
+       if (parent && parent.window.TYPO3 && parent.window.TYPO3.Modal) {
+               return parent.window.TYPO3.Modal;
+       }
+
+       // fetch object from outer frame
+       if (top && top.TYPO3.Modal) {
+               return top.TYPO3.Modal;
+       }
 
        /**
         * The main object of the modal API
@@ -102,7 +113,7 @@ define(['jquery', 'TYPO3/CMS/Backend/Notification', 'bootstrap'], function($) {
                                }
                        ];
                additionalCssClasses = additionalCssClasses || [];
-               $modal = Modal.show(title, content, severity, buttons, additionalCssClasses);
+               var $modal = Modal.show(title, content, severity, buttons, additionalCssClasses);
                $modal.on('button.clicked', function(e) {
                        if (e.target.name === 'cancel') {
                                $(this).trigger('confirm.button.cancel');
@@ -148,13 +159,15 @@ define(['jquery', 'TYPO3/CMS/Backend/Notification', 'bootstrap'], function($) {
         * @param {array} additionalCssClasses additional css classes to add to the modal
         */
        Modal.show = function(title, content, severity, buttons, additionalCssClasses) {
+               var i;
+
                severity = (typeof severity !== 'undefined' ? severity : top.TYPO3.Severity.info);
                buttons = buttons || [];
                additionalCssClasses = additionalCssClasses || [];
 
                var currentModal = Modal.template.clone();
                if (additionalCssClasses.length) {
-                       for (var i=0; i < additionalCssClasses.length; i++) {
+                       for (i = 0; i < additionalCssClasses.length; i++) {
                                currentModal.addClass(additionalCssClasses[i]);
                        }
                }
@@ -176,7 +189,7 @@ define(['jquery', 'TYPO3/CMS/Backend/Notification', 'bootstrap'], function($) {
 
                currentModal.addClass('t3-modal-' + Modal.getSeverityClass(severity));
                if (buttons.length > 0) {
-                       for (var i=0; i<buttons.length; i++) {
+                       for (i = 0; i<buttons.length; i++) {
                                var button = buttons[i];
                                var $button = $('<button />', {class: 'btn'});
                                $button.html(button.text);
@@ -283,22 +296,14 @@ define(['jquery', 'TYPO3/CMS/Backend/Notification', 'bootstrap'], function($) {
                                        active: true,
                                        btnClass: 'btn-default',
                                        trigger: function() {
-                                               if (typeof top.TYPO3 !== 'undefined' && typeof top.TYPO3.Modal !== 'undefined') {
-                                                       top.TYPO3.Modal.currentModal.trigger('modal-dismiss');
-                                               } else {
-                                                       Modal.trigger('modal-dismiss');
-                                               }
+                                               Modal.trigger('modal-dismiss');
                                        }
                                },
                                {
                                        text: $element.data('button-ok-text') || 'OK',
                                        btnClass: 'btn-' + Modal.getSeverityClass(severity),
                                        trigger: function() {
-                                               if (typeof top.TYPO3 !== 'undefined' && typeof top.TYPO3.Modal !== 'undefined') {
-                                                       top.TYPO3.Modal.currentModal.trigger('modal-dismiss');
-                                               } else {
-                                                       Modal.trigger('modal-dismiss');
-                                               }
+                                               Modal.trigger('modal-dismiss');
                                                self.location.href = $element.data('href') || $element.attr('href');
                                        }
                                }
@@ -306,17 +311,9 @@ define(['jquery', 'TYPO3/CMS/Backend/Notification', 'bootstrap'], function($) {
                        if (url !== null) {
                                var separator = (url.indexOf('?') > -1) ? '&' : '?';
                                var params = $.param({data: $element.data()});
-                               if (typeof top.TYPO3 !== 'undefined' && typeof top.TYPO3.Modal !== 'undefined') {
-                                       top.TYPO3.Modal.loadUrl(title, severity, buttons, url + separator + params);
-                               } else {
-                                       Modal.loadUrl(title, severity, buttons, url + separator + params);
-                               }
+                               Modal.loadUrl(title, severity, buttons, url + separator + params);
                        } else {
-                               if (typeof top.TYPO3 !== 'undefined' && typeof top.TYPO3.Modal !== 'undefined') {
-                                       top.TYPO3.Modal.show(title, content, severity, buttons);
-                               } else {
-                                       Modal.show(title, content, severity, buttons);
-                               }
+                               Modal.show(title, content, severity, buttons);
                        }
                });
        };
@@ -326,12 +323,10 @@ define(['jquery', 'TYPO3/CMS/Backend/Notification', 'bootstrap'], function($) {
         */
        $(document).on('modal-dismiss', Modal.dismiss);
 
-       /**
-        * Return the Modal object
-        */
-       return function() {
-               Modal.initializeMarkupTrigger();
-               TYPO3.Modal = Modal;
-               return Modal;
-       }();
+       Modal.initializeMarkupTrigger();
+
+       // expose as global object
+       TYPO3.Modal = Modal;
+
+       return Modal;
 });
index dc02d01..85d2ad6 100644 (file)
@@ -14,7 +14,7 @@
 /**
  * Javascript for show the online media dialog
  */
-define(['jquery', 'nprogress', 'TYPO3/CMS/Lang/Lang', 'TYPO3/CMS/Backend/Modal'], function($, NProgress) {
+define(['jquery', 'nprogress', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Lang/Lang'], function($, NProgress, Modal) {
        "use strict";
 
        var OnlineMediaPlugin = function(element) {
@@ -49,13 +49,13 @@ define(['jquery', 'nprogress', 'TYPO3/CMS/Lang/Lang', 'TYPO3/CMS/Backend/Modal']
                                                        'file'
                                                );
                                        } else {
-                                               var $confirm = top.TYPO3.Modal.confirm(
+                                               var $confirm = Modal.confirm(
                                                        'ERROR',
                                                        data.error,
                                                        top.TYPO3.Severity.error,
                                                        [{
                                                                text: TYPO3.lang['button.ok'] || 'OK',
-                                                               btnClass: 'btn-' + top.TYPO3.Modal.getSeverityClass(top.TYPO3.Severity.error),
+                                                               btnClass: 'btn-' + Modal.getSeverityClass(top.TYPO3.Severity.error),
                                                                name: 'ok'
                                                        }]
                                                ).on('confirm.button.ok', function() {
@@ -71,7 +71,7 @@ define(['jquery', 'nprogress', 'TYPO3/CMS/Lang/Lang', 'TYPO3/CMS/Backend/Modal']
                me.$btn.on('click', function(evt) {
                        evt.preventDefault();
 
-                       var $modal = top.TYPO3.Modal.show(
+                       var $modal = Modal.show(
                                me.$btn.attr('title'),
                                '<div class="form-control-wrap">' +
                                        '<input type="text" class="form-control online-media-url" placeholder="' + me.placeholder + '" />' +
index 87adf09..0ce6b7b 100644 (file)
@@ -15,7 +15,7 @@
  * shortcut menu logic to add new shortcut, remove a shortcut
  * and edit a shortcut
  */
-define(['jquery'], function($) {
+define(['jquery', 'TYPO3/CMS/Backend/Modal'], function($, Modal) {
 
        var ShortcutMenu = {
                $spinnerElement: $('<span>', {
@@ -76,7 +76,7 @@ define(['jquery'], function($) {
         */
        ShortcutMenu.deleteShortcut = function($shortcutRecord) {
                // @todo: translations
-               top.TYPO3.Modal.confirm('Delete bookmark', 'Do you really want to remove this bookmark?')
+               Modal.confirm('Delete bookmark', 'Do you really want to remove this bookmark?')
                        .on('confirm.button.ok', function() {
                                $.ajax({
                                        url: TYPO3.settings.ajaxUrls['shortcut_remove'],
@@ -105,7 +105,7 @@ define(['jquery'], function($) {
        ShortcutMenu.createShortcut = function(moduleName, url, confirmationText, motherModule, shortcutButton) {
                if (typeof confirmationText !== 'undefined') {
                        // @todo: translations
-                       top.TYPO3.Modal.confirm('Create bookmark', confirmationText)
+                       Modal.confirm('Create bookmark', confirmationText)
                                .on('confirm.button.ok', function() {
                                        var $toolbarItemIcon = $(ShortcutMenu.options.toolbarIconSelector, ShortcutMenu.options.containerSelector);
                                        var $spinner = ShortcutMenu.$spinnerElement.clone();
index 7422fd1..cbc84f5 100644 (file)
@@ -17,7 +17,7 @@
  * ExtensionManager.Update => Various AJAX functions to display updates
  * ExtensionManager.uploadForm => helper to show the upload form
  */
-define(['jquery', 'nprogress', 'datatables', 'TYPO3/CMS/Backend/jquery.clearable'], function($, NProgress) {
+define(['jquery', 'nprogress', 'TYPO3/CMS/Backend/Modal', 'datatables', 'TYPO3/CMS/Backend/jquery.clearable'], function($, NProgress, Modal) {
        var ExtensionManager = {
                identifier: {
                        extensionlist: '#typo3-extension-list',
@@ -73,7 +73,7 @@ define(['jquery', 'nprogress', 'datatables', 'TYPO3/CMS/Backend/jquery.clearable
                        $me.attr('href', '#');
                        $me.addClass('transformed');
                        $me.click(function() {
-                               top.TYPO3.Modal.confirm(
+                               Modal.confirm(
                                        TYPO3.lang['extensionList.removalConfirmation.title'],
                                        TYPO3.lang['extensionList.removalConfirmation.question'],
                                        top.TYPO3.Severity.error,
@@ -82,14 +82,14 @@ define(['jquery', 'nprogress', 'datatables', 'TYPO3/CMS/Backend/jquery.clearable
                                                        text: TYPO3.lang['button.cancel'],
                                                        active: true,
                                                        trigger: function() {
-                                                               top.TYPO3.Modal.dismiss();
+                                                               Modal.dismiss();
                                                        }
                                                }, {
                                                        text: TYPO3.lang['button.remove'],
                                                        btnClass: 'btn-danger',
                                                        trigger: function() {
                                                                ExtensionManager.removeExtensionFromDisk($me);
-                                                               top.TYPO3.Modal.dismiss();
+                                                               Modal.dismiss();
                                                        }
                                                }
                                        ]
@@ -189,7 +189,7 @@ define(['jquery', 'nprogress', 'datatables', 'TYPO3/CMS/Backend/jquery.clearable
                NProgress.done();
                $extManager.unmask();
 
-               top.TYPO3.Modal.confirm(
+               Modal.confirm(
                        TYPO3.lang['extensionList.updateConfirmation.questionVersionComments'],
                        message,
                        top.TYPO3.Severity.warning,
@@ -198,7 +198,7 @@ define(['jquery', 'nprogress', 'datatables', 'TYPO3/CMS/Backend/jquery.clearable
                                        text: TYPO3.lang['button.cancel'],
                                        active: true,
                                        trigger: function() {
-                                               top.TYPO3.Modal.dismiss();
+                                               Modal.dismiss();
                                        }
                                }, {
                                        text: TYPO3.lang['button.updateExtension'],
@@ -208,7 +208,7 @@ define(['jquery', 'nprogress', 'datatables', 'TYPO3/CMS/Backend/jquery.clearable
                                                        url: data.url,
                                                        data: {
                                                                tx_extensionmanager_tools_extensionmanagerextensionmanager: {
-                                                                       version: $('input:radio[name=version]:checked', top.TYPO3.Modal.currentModal).val()
+                                                                       version: $('input:radio[name=version]:checked', Modal.currentModal).val()
                                                                }
                                                        },
                                                        dataType: 'json',
@@ -220,7 +220,7 @@ define(['jquery', 'nprogress', 'datatables', 'TYPO3/CMS/Backend/jquery.clearable
                                                                location.reload();
                                                        }
                                                });
-                                               top.TYPO3.Modal.dismiss();
+                                               Modal.dismiss();
                                        }
                                }
                        ]
@@ -382,19 +382,19 @@ define(['jquery', 'nprogress', 'datatables', 'TYPO3/CMS/Backend/jquery.clearable
                NProgress.done();
                $extManager.unmask();
                if (data.hasDependencies) {
-                       top.TYPO3.Modal.confirm(data.title, data.message, top.TYPO3.Severity.info, [
+                       Modal.confirm(data.title, data.message, top.TYPO3.Severity.info, [
                                {
                                        text: TYPO3.lang['button.cancel'],
                                        active: true,
                                        trigger: function() {
-                                               top.TYPO3.Modal.dismiss();
+                                               Modal.dismiss();
                                        }
                                }, {
                                        text: TYPO3.lang['button.resolveDependencies'],
                                        btnClass: 'btn-info',
                                        trigger: function() {
                                                Repository.getResolveDependenciesAndInstallResult(data.url + '&tx_extensionmanager_tools_extensionmanagerextensionmanager[downloadPath]=' + Repository.downloadPath);
-                                               top.TYPO3.Modal.dismiss();
+                                               Modal.dismiss();
                                        }
                                }
                        ]);
@@ -419,24 +419,24 @@ define(['jquery', 'nprogress', 'datatables', 'TYPO3/CMS/Backend/jquery.clearable
                        },
                        success: function (data) {
                                if (data.errorCount > 0) {
-                                       top.TYPO3.Modal.confirm(data.errorTitle, data.errorMessage, top.TYPO3.Severity.error, [
+                                       Modal.confirm(data.errorTitle, data.errorMessage, top.TYPO3.Severity.error, [
                                                {
                                                        text: TYPO3.lang['button.cancel'],
                                                        active: true,
                                                        trigger: function() {
-                                                               top.TYPO3.Modal.dismiss();
+                                                               Modal.dismiss();
                                                        }
                                                }, {
                                                        text: TYPO3.lang['button.resolveDependenciesIgnore'],
                                                        btnClass: 'btn-danger disabled t3js-dependencies',
                                                        trigger: function() {
                                                                Repository.getResolveDependenciesAndInstallResult(data.skipDependencyUri);
-                                                               top.TYPO3.Modal.dismiss();
+                                                               Modal.dismiss();
                                                        }
                                                }
                                        ]);
-                                       top.TYPO3.Modal.currentModal.on('shown.bs.modal', function() {
-                                               var $actionButton = top.TYPO3.Modal.currentModal.find('.t3js-dependencies');
+                                       Modal.currentModal.on('shown.bs.modal', function() {
+                                               var $actionButton = Modal.currentModal.find('.t3js-dependencies');
                                                top.TYPO3.jQuery('input[name=unlockDependencyIgnoreButton]').on('change', function() {
                                                        $actionButton.toggleClass('disabled', !$(this).prop('checked'));
                                                });
index 67d452f..c1cdd95 100644 (file)
 /**
  * JavaScript to handle confirm windows in the Import/Export module
  */
-define(['jquery'], function ($) {
+define(['jquery', 'TYPO3/CMS/Backend/Modal'], function ($, Modal) {
+       "use strict";
+
        $(function() {
                $(document).on('click', '.t3js-confirm-trigger', function() {
-                       $button = $(this);
-                       top.TYPO3.Modal.confirm($button.data('title'), $button.data('message'))
+                       var $button = $(this);
+                       Modal.confirm($button.data('title'), $button.data('message'))
                                .on('confirm.button.ok', function() {
                                        $('#t3js-submit-field')
                                                .attr('name', $button.attr('name'))
                                                .closest('form').submit();
-                                       top.TYPO3.Modal.currentModal.trigger('modal-dismiss');
+                                       Modal.currentModal.trigger('modal-dismiss');
                                })
                                .on('confirm.button.cancel', function() {
-                                       top.TYPO3.Modal.currentModal.trigger('modal-dismiss');
+                                       Modal.currentModal.trigger('modal-dismiss');
                                });
                });
        });
index 6bf9433..f72cefe 100644 (file)
@@ -14,7 +14,7 @@
 /**
  * RequireJS module for Recycler
  */
-define(['jquery', 'nprogress', 'TYPO3/CMS/Backend/jquery.clearable'], function($, NProgress) {
+define(['jquery', 'nprogress', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/jquery.clearable'], function($, NProgress, Modal) {
        var Recycler = {
                identifiers: {
                        searchForm: '#recycler-form',
@@ -333,23 +333,24 @@ define(['jquery', 'nprogress', 'TYPO3/CMS/Backend/jquery.clearable'], function($
                var $tr = $(this).parents('tr'),
                        isMassDelete = $tr.parent().prop('tagName') !== 'TBODY'; // deleteRecord() was invoked by the mass delete button
 
+               var records, message;
                if (isMassDelete) {
-                       var records = Recycler.markedRecordsForMassAction,
-                               message = TYPO3.lang['modal.massdelete.text'];
+                       records = Recycler.markedRecordsForMassAction;
+                       message = TYPO3.lang['modal.massdelete.text'];
                } else {
                        var uid = $tr.data('uid'),
                                table = $tr.data('table'),
-                               records = table + ':' + uid,
-                               recordTitle = $tr.data('recordtitle'),
-                               message = table === 'pages' ? TYPO3.lang['modal.deletepage.text'] : TYPO3.lang['modal.deletecontent.text'];
-                               message = Recycler.createMessage(message, [recordTitle, '[' + records + ']']);
+                               recordTitle = $tr.data('recordtitle');
+                       records = table + ':' + uid;
+                       message = table === 'pages' ? TYPO3.lang['modal.deletepage.text'] : TYPO3.lang['modal.deletecontent.text'];
+                       message = Recycler.createMessage(message, [recordTitle, '[' + records + ']']);
                }
 
-               top.TYPO3.Modal.confirm(TYPO3.lang['modal.delete.header'], message, top.TYPO3.Severity.error, [
+               Modal.confirm(TYPO3.lang['modal.delete.header'], message, top.TYPO3.Severity.error, [
                        {
                                text: TYPO3.lang['button.cancel'],
                                trigger: function() {
-                                       top.TYPO3.Modal.dismiss();
+                                       Modal.dismiss();
                                }
                        }, {
                                text: TYPO3.lang['button.delete'],
@@ -365,21 +366,23 @@ define(['jquery', 'nprogress', 'TYPO3/CMS/Backend/jquery.clearable'], function($
                var $tr = $(this).parents('tr'),
                        isMassUndo = $tr.parent().prop('tagName') !== 'TBODY'; // undoRecord() was invoked by the mass delete button
 
+               var records, messageText, recoverPages;
                if (isMassUndo) {
-                       var records = Recycler.markedRecordsForMassAction,
-                               messageText = TYPO3.lang['modal.massundo.text'],
-                               recoverPages = true;
+                       records = Recycler.markedRecordsForMassAction;
+                       messageText = TYPO3.lang['modal.massundo.text'];
+                       recoverPages = true;
                } else {
                        var uid = $tr.data('uid'),
                                table = $tr.data('table'),
-                               records = table + ':' + uid,
-                               recordTitle = $tr.data('recordtitle'),
-                               $message = null,
-                               recoverPages = table === 'pages',
-                               messageText = recoverPages ? TYPO3.lang['modal.undopage.text'] : TYPO3.lang['modal.undocontent.text'];
-                               messageText = Recycler.createMessage(messageText, [recordTitle, '[' + records + ']']);
+                               recordTitle = $tr.data('recordtitle');
+
+                       records = table + ':' + uid;
+                       recoverPages = table === 'pages';
+                       messageText = recoverPages ? TYPO3.lang['modal.undopage.text'] : TYPO3.lang['modal.undocontent.text'];
+                       messageText = Recycler.createMessage(messageText, [recordTitle, '[' + records + ']']);
                }
 
+               var $message;
                if (recoverPages) {
                        $message = $('<div />').append(
                                $('<p />').text(messageText),
@@ -391,11 +394,11 @@ define(['jquery', 'nprogress', 'TYPO3/CMS/Backend/jquery.clearable'], function($
                        $message = messageText;
                }
 
-               top.TYPO3.Modal.confirm(TYPO3.lang['modal.undo.header'], $message, top.TYPO3.Severity.ok, [
+               Modal.confirm(TYPO3.lang['modal.undo.header'], $message, top.TYPO3.Severity.ok, [
                        {
                                text: TYPO3.lang['button.cancel'],
                                trigger: function() {
-                                       top.TYPO3.Modal.dismiss();
+                                       Modal.dismiss();
                                }
                        }, {
                                text: TYPO3.lang['button.undo'],
@@ -457,7 +460,7 @@ define(['jquery', 'nprogress', 'TYPO3/CMS/Backend/jquery.clearable'], function($
                                Recycler.allToggled = false;
                        },
                        complete: function() {
-                               top.TYPO3.Modal.dismiss();
+                               Modal.dismiss();
                                NProgress.done();
                        }
                });
@@ -548,15 +551,9 @@ define(['jquery', 'nprogress', 'TYPO3/CMS/Backend/jquery.clearable'], function($
                $(this).addClass('disabled').find('.t3-icon').unwrap().wrap($('<span />'));
        };
 
-       /**
-        * return the main Recycler object
-        * initialize once on document ready
-        */
-       return function() {
-               $(document).ready(function() {
-                       Recycler.initialize();
-               });
+       $(document).ready(function() {
+               Recycler.initialize();
+       });
 
-               return Recycler;
-       }();
+       return Recycler;
 });
index c8b898e..f3eab53 100644 (file)
 /**
  * JavaScript to handle confirm windows in the task center module
  */
-define(['jquery'], function ($) {
+define(['jquery', 'TYPO3/CMS/Backend/Modal'], function ($, Modal) {
        $(function() {
                $(document).on('click', '.t3js-confirm-trigger', function(e) {
                        e.preventDefault();
                        var $link = $(this);
-                       top.TYPO3.Modal.confirm($link.data('title'), $link.data('message'))
+                       Modal.confirm($link.data('title'), $link.data('message'))
                                .on('confirm.button.ok', function() {
                                        self.location.href = $link.attr('href');
-                                       top.TYPO3.Modal.currentModal.trigger('modal-dismiss');
+                                       Modal.currentModal.trigger('modal-dismiss');
                                })
                                .on('confirm.button.cancel', function() {
-                                       top.TYPO3.Modal.currentModal.trigger('modal-dismiss');
+                                       Modal.currentModal.trigger('modal-dismiss');
                                });
                        return false;
                });