Scribe.js/static/js/controllers/dateController.js

48 lines
1.3 KiB
JavaScript
Raw Normal View History

2014-11-11 21:20:33 +01:00
(function () {
'use strict';
2014-11-13 21:33:37 +01:00
/**
* Dates controller
*/
2014-11-11 21:20:33 +01:00
window.app.controller('dateController', [
'$scope',
'$rootScope',
'$filter',
'logs',
'dates',
function ($scope, $rootScope, $filter, logs, dates) {
2014-11-13 21:33:37 +01:00
//reset
2014-11-11 21:20:33 +01:00
$rootScope.sidebar = false;
2014-11-13 21:33:37 +01:00
//build blocks
2014-11-11 21:20:33 +01:00
$scope.blocks = dates.map(function (item) {
return {
type : 'date',
messageTop : $filter('date')(item.date, 'MMM'),
message : $filter('date')(item.date, 'd'),
messageBottom : $filter('date')(item.date, 'yyyy'),
click : function () {
2014-11-13 21:33:37 +01:00
//save files
2014-11-11 21:20:33 +01:00
logs.setLogs(item.files.map(function (el, index) {
return {
selected : index === 0, //select the first by default
name : el.name,
path : el.path
};
}));
2014-11-13 21:33:37 +01:00
//redirect
2014-11-11 21:20:33 +01:00
$rootScope.go('logs');
}
};
});
}
]);
}());