crmUi - Fix crmPageTitle directive to work inside a modal
authorColeman Watts <coleman@civicrm.org>
Fri, 1 Jul 2022 02:12:24 +0000 (22:12 -0400)
committerColeman Watts <coleman@civicrm.org>
Wed, 6 Jul 2022 21:50:17 +0000 (17:50 -0400)
ang/crmUi.js

index 11eb5e28ef31ba75f49c5f118170d48fadeefa29..3e3132cae16b31139850b9c8b21b739aef4f6fe7 100644 (file)
             $timeout(function() {
               var newPageTitle = _.trim($el.html()),
                 newDocumentTitle = scope.crmDocumentTitle || $el.text(),
-                h1Count = 0;
-              document.title = $('title').text().replace(documentTitle, newDocumentTitle);
-              // If the CMS has already added title markup to the page, use it
-              $('h1').not('.crm-container h1').each(function() {
-                if ($(this).hasClass('crm-page-title') || _.trim($(this).html()) === pageTitle) {
-                  $(this).addClass('crm-page-title').html(newPageTitle);
-                  $el.hide();
-                  ++h1Count;
+                h1Count = 0,
+                dialog = $el.closest('.ui-dialog-content');
+              if (dialog.length) {
+                dialog.dialog('option', 'title', newDocumentTitle);
+                $el.hide();
+              } else {
+                document.title = $('title').text().replace(documentTitle, newDocumentTitle);
+                // If the CMS has already added title markup to the page, use it
+                $('h1').not('.crm-container h1').each(function () {
+                  if ($(this).hasClass('crm-page-title') || _.trim($(this).html()) === pageTitle) {
+                    $(this).addClass('crm-page-title').html(newPageTitle);
+                    $el.hide();
+                    ++h1Count;
+                  }
+                });
+                if (!h1Count) {
+                  $el.show();
                 }
-              });
-              if (!h1Count) {
-                $el.show();
+                pageTitle = newPageTitle;
+                documentTitle = newDocumentTitle;
               }
-              pageTitle = newPageTitle;
-              documentTitle = newDocumentTitle;
             });
           }