parent
574d3db6c5
commit
ed0e5a939f
@ -0,0 +1,31 @@ |
||||
timelinesApp.controller('TimelinesController', ['$scope', '$window', 'TimelineService', function($scope, $window, TimelineService){ |
||||
|
||||
$scope.switchTimeline = function() { |
||||
$window.location.href = $scope.timelines[$scope.currentTimelineId].path; |
||||
}; |
||||
|
||||
$scope.timelineContainerNo = 1; // formerly rand(10**75), TODO increment after each timeline startup
|
||||
|
||||
$scope.timelines = gon.timelines; |
||||
$scope.currentTimelineId = gon.current_timeline_id; |
||||
|
||||
$scope.getTimelineContainerElementId = function() { |
||||
return 'timeline-container-' + $scope.timelineContainerNo; |
||||
}; |
||||
|
||||
$scope.getTimelineContainer = function() { |
||||
return angular.element(document.querySelector('#' + $scope.getTimelineContainerElementId())); |
||||
}; |
||||
|
||||
angular.element(document).ready(function () { |
||||
// aggregate timeline options
|
||||
$scope.timelineTranslations = gon.timeline_translations; |
||||
$scope.timelineOptions = angular.extend(gon.timeline_options, { |
||||
ui_root: $scope.getTimelineContainer(), |
||||
i18n: $scope.timelineTranslations |
||||
}); |
||||
|
||||
// load timeline
|
||||
$scope.timeline = TimelineService.loadTimeline($scope.timelineOptions); |
||||
}); |
||||
}]); |
@ -0,0 +1,10 @@ |
||||
timelinesApp.service('TimelineService',['$rootScope', '$http', function($rootScope, $http) { |
||||
TimelineService = { |
||||
|
||||
loadTimeline: function(timelineOptions) { |
||||
return Timeline.startup(timelineOptions); |
||||
} |
||||
}; |
||||
|
||||
return TimelineService; |
||||
}]); |
@ -1,13 +0,0 @@ |
||||
timelinesApp = angular.module('openproject.timelines', ['ui.select2']) |
||||
|
||||
// .run(function($rootScope){
|
||||
// })
|
||||
|
||||
.controller('TimelinesController', ['$scope', '$window', function($scope, $window){ |
||||
$scope.timelines = gon.timelines; |
||||
$scope.currentTimelineId = gon.current_timeline_id; |
||||
|
||||
$scope.loadTimeline = function() { |
||||
$window.location.href = $scope.timelines[$scope.currentTimelineId].path; |
||||
}; |
||||
}]); |
@ -0,0 +1,4 @@ |
||||
var timelinesApp = angular.module('openproject.timelines', ['ui.select2']); |
||||
|
||||
// .run(function($rootScope){
|
||||
// })
|
Loading…
Reference in new issue