31389b9974
- Fixing the title and description (meta) to only respond to a rootScope watch, rather than using a timer - Change the tabs listening code to be completely self contained
40 lines
914 B
JavaScript
40 lines
914 B
JavaScript
/**
|
|
* Service which helps set the contents of the <meta> tags (and the <title> of a page).
|
|
*/
|
|
angular.module('quay').factory('MetaService', ['$interpolate', 'Config', '$rootScope', '$interval',
|
|
function($interpolate, Config, $rootScope, $interval) {
|
|
var metaService = {};
|
|
|
|
var interpolate = function(page, expr) {
|
|
if (!expr) {
|
|
return null;
|
|
}
|
|
|
|
var inter = $interpolate(expr, true, null, true);
|
|
if (!inter) {
|
|
return null;
|
|
}
|
|
|
|
return inter(page.scope);
|
|
};
|
|
|
|
metaService.getTitle = function(page) {
|
|
if (!page || !page.$$route) {
|
|
return null;
|
|
}
|
|
|
|
var route = page.$$route;
|
|
return interpolate(page, route && route.title);
|
|
};
|
|
|
|
metaService.getDescription = function(page) {
|
|
if (!page || !page.$$route) {
|
|
return null;
|
|
}
|
|
|
|
var route = page.$$route;
|
|
return interpolate(route && route.description);
|
|
};
|
|
|
|
return metaService;
|
|
}]);
|