Skip to content

Commit

Permalink
Merge pull request #28560 from artfulrobot/artfulrobot-core-4831-foll…
Browse files Browse the repository at this point in the history
…owup-pr2871

standalone: fix double <h1> and padding on select2 drops dev/core#4831
  • Loading branch information
colemanw authored Dec 12, 2023
2 parents c7cf2ee + e98988c commit 4efe0d5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
21 changes: 8 additions & 13 deletions ang/crmUi.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(function (angular, $, _) {

var uidCount = 0,
pageTitle = 'CiviCRM',
pageTitleHTML = 'CiviCRM',
documentTitle = 'CiviCRM';

angular.module('crmUi', CRM.angRequires('crmUi'))
Expand Down Expand Up @@ -1190,7 +1190,7 @@
// WARNING: Use only once per route!
// WARNING: This directive works only if your AngularJS base page does not
// set a custom title (i.e., it has an initial title of "CiviCRM"). See the
// global variables pageTitle and documentTitle.
// global variables pageTitleHTML and documentTitle.
// Example (same title for both): <h1 crm-page-title>{{ts('Hello')}}</h1>
// Example (separate document title): <h1 crm-document-title="ts('Hello')" crm-page-title><i class="crm-i fa-flag" aria-hidden="true"></i>{{ts('Hello')}}</h1>
.directive('crmPageTitle', function($timeout) {
Expand All @@ -1201,27 +1201,22 @@
link: function(scope, $el, attrs) {
function update() {
$timeout(function() {
var newPageTitle = _.trim($el.html()),
var newPageTitleHTML = $el.html().trim(),
newDocumentTitle = scope.crmDocumentTitle || $el.text(),
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);
[].forEach.call(document.querySelectorAll('h1:not(.crm-container h1), .crm-page-title-wrapper>h1'), h1 => {
if (h1.classList.contains('crm-page-title') || h1.innerHTML.trim() === pageTitleHTML) {
h1.classList.add('crm-page-title');
h1.innerHTML = newPageTitleHTML;
$el.hide();
++h1Count;
}
});
if (!h1Count) {
$el.show();
}
pageTitle = newPageTitle;
pageTitleHTML = newPageTitleHTML;
documentTitle = newDocumentTitle;
}
});
Expand Down
2 changes: 1 addition & 1 deletion ext/standaloneusers/css/standalone.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
html.crm-standalone body>.crm-container {
.standalone-page-padding {
padding: 1px 3vw 1rem;
}

Expand Down
6 changes: 3 additions & 3 deletions templates/CRM/common/standalone.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{include file="CRM/common/debug.tpl"}
{/if}

<div id="crm-container" class="crm-container" lang="{$config->lcMessages|substr:0:2}" xml:lang="{$config->lcMessages|substr:0:2}">
<div id="crm-container" class="crm-container standalone-page-padding" lang="{$config->lcMessages|substr:0:2}" xml:lang="{$config->lcMessages|substr:0:2}">
{if $breadcrumb}
<nav aria-label="{ts}Breadcrumb{/ts}" class="breadcrumb"><ol>
<li><a href="/civicrm/dashboard?reset=1" >{ts}Home{/ts}</a></li>
Expand All @@ -39,8 +39,8 @@
{/if}

{if $pageTitle}
<div class="crm-title">
<h1 class="title">{if $isDeleted}<del>{/if}{$pageTitle}{if $isDeleted}</del>{/if}</h1>
<div class="crm-page-title-wrapper">
<h1 class="crm-page-title">{$pageTitle}</h1>
</div>
{/if}

Expand Down

0 comments on commit 4efe0d5

Please sign in to comment.