diff --git a/app/assets/javascripts/angular/controllers/timelines_controller.js b/app/assets/javascripts/angular/controllers/timelines_controller.js index 4e5c81111a..5025bd1af0 100644 --- a/app/assets/javascripts/angular/controllers/timelines_controller.js +++ b/app/assets/javascripts/angular/controllers/timelines_controller.js @@ -4,28 +4,41 @@ timelinesApp.controller('TimelinesController', ['$scope', '$window', 'TimelineSe $window.location.href = $scope.timelines[$scope.currentTimelineId].path; }; - // setup - + // Setup $scope.timelineContainerNo = 1; // formerly rand(10**75), TODO increment after each timeline startup + $scope.currentOutlineLevel = 'level3'; + $scope.currentScale = 'monthly'; - $scope.timelines = gon.timelines; + // Get server-side stuff into scope $scope.currentTimelineId = gon.current_timeline_id; + $scope.timelines = gon.timelines; $scope.timelineOptions = angular.extend(gon.timeline_options, { i18n: gon.timeline_translations }); + + // Get timelines stuff into scope $scope.Timeline = Timeline; - // $scope.timeline = TimelineService.loadTimeline($scope.timelineOptions); + // Load timeline + $scope.timeline = TimelineService.loadTimeline($scope.timelineOptions); + // Slider + // TODO integrate angular-ui-slider + $scope.getCurrentScaleLevel = function() { + return jQuery('#zoom-slider').slider('value'); + }; + $scope.setCurrentScaleLevel = function(value) { + jQuery('#zoom-slider').slider('value', value); + }; + + // Container for timeline rendering $scope.getTimelineContainerElementId = function() { return 'timeline-container-' + $scope.timelineContainerNo; }; - $scope.getTimelineContainer = function() { return angular.element(document.querySelector('#' + $scope.getTimelineContainerElementId())); }; angular.element(document).ready(function() { // start timeline - // $scope.timeline = TimelineService.startTimeline($scope.timelineOptions, $scope.getTimelineContainer()); - $scope.timeline = TimelineService.loadTimeline($scope.timelineOptions); + TimelineService.startTimeline($scope.timelineOptions, $scope.getTimelineContainer()); }); }]); diff --git a/app/assets/javascripts/angular/directives/timelines/zoom_slider_directive.js b/app/assets/javascripts/angular/directives/timelines/zoom_slider_directive.js new file mode 100644 index 0000000000..f2fb9538fd --- /dev/null +++ b/app/assets/javascripts/angular/directives/timelines/zoom_slider_directive.js @@ -0,0 +1,24 @@ +timelinesApp.directive('zoomSlider', function() { + return { + restrict: 'A', + link: function(scope, element, attributes) { + zooms = jQuery('select[name="zooms"]'); + element.slider({ + min: 1, + max: Timeline.ZOOM_SCALES.length, + range: 'min', + value: zooms[0].selectedIndex + 1, + slide: function(event, ui) { + zooms[0].selectedIndex = ui.value - 1; + }, + change: function(event, ui) { + zooms[0].selectedIndex = ui.value - 1; + timeline.zoom(ui.value - 1); + } + }).css({ + // top right bottom left + 'margin': '4px 6px 3px' + }); + } + }; +}); diff --git a/app/views/timelines/_timeline.html.erb b/app/views/timelines/_timeline.html.erb index 45896dcd98..0d2782f5d3 100644 --- a/app/views/timelines/_timeline.html.erb +++ b/app/views/timelines/_timeline.html.erb @@ -27,7 +27,9 @@ See doc/COPYRIGHT.rdoc for more details. ++#%> -
+ + +<%= render 'toolbar' %> <% unless User.current.impaired? %> <%# TODO: Require autocompleter inside select_boxes.js diff --git a/app/views/timelines/_toolbar.html.erb b/app/views/timelines/_toolbar.html.erb new file mode 100644 index 0000000000..807ff48d5c --- /dev/null +++ b/app/views/timelines/_toolbar.html.erb @@ -0,0 +1,42 @@ +