angular.module('homepage').
directive('timelineTemplate', function () {
return {
controller: 'TimelineTemplateController',
link: TimelineTemplateLinkerFn,
restrict: 'E',
scope: {
item: '='
},
replace: true,
transclude: true,
templateUrl: 'components/content-components/timeline/timeline-template.html'
};
function TimelineTemplateLinkerFn(scope, element, attributes) {
var itemType = getItemTypeText(scope.item.type);
scope.itemType = itemType;
// Path of card template to be included using <ng-include src="template">
// !important: With this approach, controllers on the template would not be active
scope.template = 'components/feature-components/' + itemType + '/' + itemType + '-card.html';
}
function getItemTypeText(type) {
var title = '';
switch(type) {
case 'ACTY': title = 'activity'; break;
case 'NOTE': title = 'note'; break;
case 'LIST': title = 'list'; break;
case 'FOOD': title = 'food'; break;
case 'HLTH': title = 'fitness'; break;
case 'PLCS':
case 'CKIN': title = 'place'; break;
case 'MNEY': title = 'finance'; break;
case 'HABT': title = 'habit'; break;
case 'CLDR': title = 'calendar'; break;
case 'MOOD': title = 'mood'; break;
}
return title;
}
}).
controller('TimelineTemplateController', function ($scope, MobileType) {
$scope.iconOffset = MobileType.any() ? "32" : "48";
});