Commit 826f5ace authored by colemanw's avatar colemanw

Support rich text titles + plain document title

parent 7565f24a
......@@ -3,14 +3,17 @@
<form name="crm-system-status" crm-ui-id-scope>
<h1 crm-ui-title>{{ts('CiviCRM System Status (%1)', {1: _.where(statuses, {is_visible: 1}).length})}}</h1>
<h1 crm-page-title
crm-document-title="ts('CiviCRM System Status') + ' (' + countVisible(1) + ')'"
>
{{ts('CiviCRM System Status')}}
</h1>
<div id="crm-status-list" crm-ui-tab-set>
<div
<div crm-ui-tab
ng-repeat="tab in [{is_visible: 1, icon: 'fa-bell'}, {is_visible: 0, icon: 'fa-bell-slash-o'}]"
crm-ui-tab
id="tab-status-visible-{{tab.is_visible}}"
count="{{_.where(statuses, {is_visible: tab.is_visible}).length}}"
count="{{countVisible(tab.is_visible)}}"
crm-title="tab.is_visible ? ts('Active') : ts('Hidden')"
crm-icon="{{tab.icon}}"
>
......
......@@ -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._);
......@@ -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: <h1 crm-ui-title>{{ts('Hello')}}</h1>
.directive('crmUiTitle', function($timeout) {
// 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"></i>{{ts('Hello')}}</h1>
.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);
}
};
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment