From: Coleman Watts Date: Fri, 30 Oct 2015 20:04:04 +0000 (-0400) Subject: Support rich text titles + plain document title X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=826f5ace330960291212cfadae23b65ac82d957d;p=civicrm-core.git Support rich text titles + plain document title --- diff --git a/ang/crmStatusPage/StatusPage.html b/ang/crmStatusPage/StatusPage.html index 218d11767e..a48f88af80 100644 --- a/ang/crmStatusPage/StatusPage.html +++ b/ang/crmStatusPage/StatusPage.html @@ -3,14 +3,17 @@
-

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

+

+ {{ts('CiviCRM System Status')}} +

-
diff --git a/ang/crmStatusPage/StatusPageCtrl.js b/ang/crmStatusPage/StatusPageCtrl.js index bb141a8471..9b89c86185 100644 --- a/ang/crmStatusPage/StatusPageCtrl.js +++ b/ang/crmStatusPage/StatusPageCtrl.js @@ -6,7 +6,6 @@ var ts = $scope.ts = CRM.ts(); $scope.alert = CRM.alert; $scope.statuses = statusData.values; - $scope._ = _; _.each($scope.statuses, function(status) { status.severity_id = status.severity; @@ -24,6 +23,10 @@ status.is_visible = visible; }); }; + + $scope.countVisible = function(is_visible) { + return _.where($scope.statuses, {is_visible: is_visible}).length; + }; }); })(angular, CRM.$, CRM._); diff --git a/ang/crmUi.js b/ang/crmUi.js index fdd0cd6219..8540e40dd4 100644 --- a/ang/crmUi.js +++ b/ang/crmUi.js @@ -2,7 +2,8 @@ (function (angular, $, _) { var uidCount = 0, - pageTitle = 'CiviCRM'; + pageTitle = 'CiviCRM', + documentTitle = 'CiviCRM'; angular.module('crmUi', []) @@ -977,29 +978,34 @@ }; }) - // Sets the one and only page title - uses CMS title if available + // Sets document title & page title; attempts to override CMS title markup for the latter // WARNING: Use only once per route! - // Note: Title should be plain-text only - // Example:

{{ts('Hello')}}

- .directive('crmUiTitle', function($timeout) { + // Example (same title for both):

{{ts('Hello')}}

+ // Example (separate document title):

{{ts('Hello')}}

+ .directive('crmPageTitle', function($timeout) { return { + scope: { + crmDocumentTitle: '=' + }, link: function(scope, $el, attrs) { function update() { $timeout(function() { - var newTitle = $el.text(); - document.title = $('title').text().replace(pageTitle, newTitle); + var newPageTitle = _.trim($el.html()), + newDocumentTitle = scope.crmDocumentTitle || $el.text(); + 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 (_.trim($(this).text()) === _.trim(pageTitle)) { - $(this).text(newTitle); + if (_.trim($(this).html()) === pageTitle) { + $(this).html(newPageTitle); $el.hide(); } }); - pageTitle = newTitle; + pageTitle = newPageTitle; + documentTitle = newDocumentTitle; }); } - scope.$watch(function() {return $el.html();}, update); + scope.$watch(function() {return scope.crmDocumentTitle + $el.html();}, update); } }; })