From 835fcb5ef5620f01bb8d9008e5565e716554f0b3 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 25 Oct 2015 11:36:35 -0400 Subject: [PATCH] Set CMS page title from Angular --- ang/crmStatusPage/StatusPage.html | 4 +--- ang/crmUi.js | 30 +++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/ang/crmStatusPage/StatusPage.html b/ang/crmStatusPage/StatusPage.html index 9e5de8d4da..218d11767e 100644 --- a/ang/crmStatusPage/StatusPage.html +++ b/ang/crmStatusPage/StatusPage.html @@ -3,9 +3,7 @@
-
-

{{ts('Status Messages')}}

-
+

{{ts('CiviCRM System Status (%1)', {1: _.where(statuses, {is_visible: 1}).length})}}

{{ts('Hello')}} + .directive('crmUiTitle', function($timeout) { + return { + link: function(scope, $el, attrs) { + function update() { + $timeout(function() { + var newTitle = $el.html(); + document.title = $('title').html().replace(pageTitle, newTitle); + // If the CMS has already added title markup to the page, use it + $('h1').not('.crm-container h1').each(function() { + if (_.trim($(this).html()) === _.trim(pageTitle)) { + $(this).html(newTitle); + $el.hide(); + } + }); + pageTitle = newTitle; + }); + } + + scope.$watch(function() {return $el.html();}, update); + } + } + }) + .run(function($rootScope, $location) { /// Example: $rootScope.goto = function(path) { -- 2.25.1