[TASK] Optimize markup trigger for modals and streamline buttons 09/41509/3
authorFrank Nägler <typo3@naegler.net>
Thu, 16 Jul 2015 20:15:59 +0000 (22:15 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Fri, 17 Jul 2015 08:07:30 +0000 (10:07 +0200)
Resolves: #68258
Releases: master
Change-Id: Ic79ba6ca35c3acd294a6e5f41b7e56fab9074b07
Reviewed-on: http://review.typo3.org/41509
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Resources/Public/JavaScript/Modal.js

index 467e333..0d45dd2 100644 (file)
@@ -89,17 +89,17 @@ define('TYPO3/CMS/Backend/Modal', ['jquery', 'TYPO3/CMS/Backend/Notification', '
        Modal.confirm = function(title, content, severity, buttons) {
                severity = (typeof severity !== 'undefined' ? severity : top.TYPO3.Severity.warning);
                buttons = buttons || [
-                       {
-                               text: $(this).data('button-close-text') || TYPO3.lang['button.cancel'] || 'Cancel',
-                               active: true,
-                               name: 'cancel'
-                       },
-                       {
-                               text: $(this).data('button-ok-text') || TYPO3.lang['button.ok'] || 'OK',
-                               btnClass: 'btn-' + Modal.getSeverityClass(severity),
-                               name: 'ok'
-                       }
-               ];
+                               {
+                                       text: $(this).data('button-close-text') || TYPO3.lang['button.cancel'] || 'Cancel',
+                                       active: true,
+                                       name: 'cancel'
+                               },
+                               {
+                                       text: $(this).data('button-ok-text') || TYPO3.lang['button.ok'] || 'OK',
+                                       btnClass: 'btn-' + Modal.getSeverityClass(severity),
+                                       name: 'ok'
+                               }
+                       ];
                $modal = Modal.show(title, content, severity, buttons);
                $modal.on('button.clicked', function(e) {
                        if (e.target.name === 'cancel') {
@@ -266,14 +266,22 @@ define('TYPO3/CMS/Backend/Modal', ['jquery', 'TYPO3/CMS/Backend/Notification', '
                                        active: true,
                                        btnClass: 'btn-default',
                                        trigger: function() {
-                                               $element.trigger('modal-dismiss');
+                                               if (typeof top.TYPO3 !== 'undefined' && typeof top.TYPO3.Modal !== 'undefined') {
+                                                       top.TYPO3.Modal.currentModal.trigger('modal-dismiss');
+                                               } else {
+                                                       Modal.trigger('modal-dismiss');
+                                               }
                                        }
                                },
                                {
                                        text: $element.data('button-ok-text') || 'OK',
-                                       btnClass: 'btn-primary',
+                                       btnClass: 'btn-' + Modal.getSeverityClass(severity),
                                        trigger: function() {
-                                               $element.trigger('modal-dismiss');
+                                               if (typeof top.TYPO3 !== 'undefined' && typeof top.TYPO3.Modal !== 'undefined') {
+                                                       top.TYPO3.Modal.currentModal.trigger('modal-dismiss');
+                                               } else {
+                                                       Modal.trigger('modal-dismiss');
+                                               }
                                                self.location.href = $element.data('href') || $element.attr('href');
                                        }
                                }
@@ -281,9 +289,17 @@ define('TYPO3/CMS/Backend/Modal', ['jquery', 'TYPO3/CMS/Backend/Notification', '
                        if (url !== null) {
                                var separator = (url.indexOf('?') > -1) ? '&' : '?';
                                var params = $.param({data: $element.data()});
-                               Modal.loadUrl(title, severity, buttons, url + separator + params);
+                               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);
+                               }
                        } else {
-                               Modal.show(title, content, severity, buttons);
+                               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);
+                               }
                        }
                });
        };