Force page title to plain text
authorColeman Watts <coleman@civicrm.org>
Sun, 25 Oct 2015 15:50:43 +0000 (11:50 -0400)
committerColeman Watts <coleman@civicrm.org>
Fri, 30 Oct 2015 19:09:40 +0000 (15:09 -0400)
ang/crmUi.js

index c8b2400ccda3ea076425690a329c4536943a6eb1..fdd0cd62193a3606622446ea42ffe4920df4f22e 100644 (file)
 
     // Sets the one and only page title - uses CMS title if available
     // 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) {
       return {
         link: function(scope, $el, attrs) {
           function update() {
             $timeout(function() {
-              var newTitle = $el.html();
-              document.title = $('title').html().replace(pageTitle, newTitle);
+              var newTitle = $el.text();
+              document.title = $('title').text().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);
+                if (_.trim($(this).text()) === _.trim(pageTitle)) {
+                  $(this).text(newTitle);
                   $el.hide();
                 }
               });
 
           scope.$watch(function() {return $el.html();}, update);
         }
-      }
+      };
     })
 
     .run(function($rootScope, $location) {