[BUGFIX] Fix t3js-trigger-modal feature 76/44376/2
authorMarkus Klein <markus.klein@typo3.org>
Thu, 29 Oct 2015 20:47:44 +0000 (21:47 +0100)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Thu, 29 Oct 2015 21:31:30 +0000 (22:31 +0100)
The event handler registration must be repeated per iframe and
the default action for the OK button must be executed on the
originating document.

Resolves: #71145
Releases: master
Change-Id: Ic99134a80beebd26aa057d5298fb97bae5a9af37
Reviewed-on: https://review.typo3.org/44376
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
typo3/sysext/backend/Resources/Public/JavaScript/Modal.js

index 868112f..8c7f0e7 100644 (file)
@@ -21,11 +21,15 @@ define(['jquery', 'TYPO3/CMS/Backend/Notification', 'bootstrap'], function($) {
 
        // fetch from parent
        if (parent && parent.window.TYPO3 && parent.window.TYPO3.Modal) {
+               // we need to trigger the event capturing again, in order to make sure this works inside iframes
+               parent.window.TYPO3.Modal.initializeMarkupTrigger(document);
                return parent.window.TYPO3.Modal;
        }
 
        // fetch object from outer frame
        if (top && top.TYPO3.Modal) {
+               // we need to trigger the event capturing again, in order to make sure this works inside iframes
+               top.TYPO3.Modal.initializeMarkupTrigger(document);
                return top.TYPO3.Modal;
        }
 
@@ -284,9 +288,11 @@ define(['jquery', 'TYPO3/CMS/Backend/Notification', 'bootstrap'], function($) {
 
        /**
         * Initialize markup with data attributes
+        *
+        * @param {object} theDocument
         */
-       Modal.initializeMarkupTrigger = function() {
-               $(document).on('click', '.t3js-modal-trigger', function(evt) {
+       Modal.initializeMarkupTrigger = function(theDocument) {
+               $(theDocument).on('click', '.t3js-modal-trigger', function(evt) {
                        evt.preventDefault();
                        var $element = $(this);
                        var url = $element.data('url') || null;
@@ -299,15 +305,15 @@ define(['jquery', 'TYPO3/CMS/Backend/Notification', 'bootstrap'], function($) {
                                        active: true,
                                        btnClass: 'btn-default',
                                        trigger: function() {
-                                               Modal.trigger('modal-dismiss');
+                                               Modal.currentModal.trigger('modal-dismiss');
                                        }
                                },
                                {
                                        text: $element.data('button-ok-text') || 'OK',
                                        btnClass: 'btn-' + Modal.getSeverityClass(severity),
                                        trigger: function() {
-                                               Modal.trigger('modal-dismiss');
-                                               self.location.href = $element.data('href') || $element.attr('href');
+                                               Modal.currentModal.trigger('modal-dismiss');
+                                               evt.target.ownerDocument.location.href = $element.data('href') || $element.attr('href');
                                        }
                                }
                        ];
@@ -326,7 +332,7 @@ define(['jquery', 'TYPO3/CMS/Backend/Notification', 'bootstrap'], function($) {
         */
        $(document).on('modal-dismiss', Modal.dismiss);
 
-       Modal.initializeMarkupTrigger();
+       Modal.initializeMarkupTrigger(document);
 
        // expose as global object
        TYPO3.Modal = Modal;