angular.module("yds").directive("ydsTimeSlider", ["$timeout", "DashboardService", "Data",
    function ($timeout, DashboardService, Data) {
        return {
            restrict: "E",
            scope: {
                type: "@",          // One of year, day, time, for selecting a year, a day of the week, or specific time
                minYear: "@",       // Minimum year of the slider (for year selection)
                maxYear: "@",       // Maximum year of the slider (for year selection)
                dashboardId: "@",   // ID to use for saving the value in DashboardService
                selectionType: "@", // Selection type for DashboardService
                height: "@",        // Height of the slider (optional)
                title: "@"          // Title to show above slider (optional)
            },
            templateUrl: Data.templatePath + "templates/dashboard/time-slider-selector.html",
            link: function (scope, element, attrs) {
                scope.initialized = false;

                var type = scope.type;
                var minYear = parseInt(scope.minYear);
                var maxYear = parseInt(scope.maxYear);
                var height = parseInt(scope.height);
                var dashboardId = scope.dashboardId;
                var vertical = scope.vertical;

                // Check if type attribute is set correctly
                if (_.isUndefined(type) || (type !== "year" && type !== "day" && type !== "time")) {
                    console.error("Type is wrong or undefined! Using 'year' as a default.");
                    type = "year";
                }

                // Check if minYear attribute is defined, else assign default value
                if (_.isUndefined(minYear) || _.isNaN(minYear))
                    minYear = 1970;

                // Check if maxYear attribute is defined, else assign default value
                if (_.isUndefined(maxYear) || _.isNaN(maxYear))
                    maxYear = 2050;

                // Check if dashboardId attribute is defined, else assign default value
                if (_.isUndefined(dashboardId) || dashboardId.length === 0)
                    dashboardId = "default";

                if (!_.isUndefined(height) && !_.isNaN(height)) {
                    scope.containerStyle = {
                        height: height + "px"
                    }
                }

                var options = {};
                switch (type) {
                    case "year":
                        break;
                    case "day":
                        options.stepsArray = [
                            "Monday",
                            "Tuesday",
                            "Wednesday",
                            "Thursday",
                            "Friday",
                            "Saturday",
                            "Sunday"
                        ];
                        break;
                    case "time":
                        break;
                }

                // Set slider options
                scope.yearSlider = {
                    value: minYear,
                    options: options
                };

                // Show angular slider after options are set
                scope.initialized = true;
            }
        };
    }
]);

@@ -1270,55 +1270,8 @@
 dId;
-%0A                var vertical = scope.vertical;
 %0A%0A  
@@ -2374,248 +2374,1075 @@
     
-var options = %7B%7D;%0A                switch (type) %7B%0A                    case %22year%22:%0A                        break;%0A                    case %22day%22:%0A                        options.stepsArray = %5B%0A                            %22Monday%22,%0A         
+// Set names for the days of the week%0A                var weekDays = %5B%0A                    %22Monday%22,%0A                    %22Tuesday%22,%0A                    %22Wednesday%22,%0A                    %22Thursday%22,%0A                    %22Friday%22,%0A                    %22Saturday%22,%0A                    %22Sunday%22%0A                %5D;%0A%0A                // Set common options for all sliders%0A                var options = %7B%7D;%0A                var defaultValue = null;%0A%0A                // Set options that depend on the slider's type%0A                var specificOptions;%0A                switch (type) %7B%0A                    case %22year%22:%0A                        specificOptions = %7B%0A                            floor: minYear,%0A                            ceil: maxYear%0A                        %7D;%0A%0A                        defaultValue = minYear;%0A                        break;%0A                    case %22day%22:%0A                        specificOptions = %7B%0A                            stepsArray: weekDays%0A                        %7D;%0A%0A                        defaultValue = 0;%0A                        break;%0A
     
@@ -3452,34 +3452,37 @@
             
-%22Tuesday%22,
+ case %22time%22:
 %0A           
@@ -3490,39 +3490,80 @@
             
-    %22Wednesday%22
+specificOptions = %7B%0A                            floor: 0
 ,%0A          
@@ -3576,34 +3576,31 @@
             
-%22Thursday%22
+step: 5
 ,%0A          
@@ -3613,33 +3613,70 @@
             
-%22Fri
+ceil: 1439, // There are 1440 minutes in a 
 day
-%22,
 %0A           
@@ -3696,147 +3696,412 @@
     
-%22Saturday%22,%0A                            %22Sunday%22%0A                        %5D;%0A                        break;%0A                    case %22time%22:
+translate: function (value) %7B%0A                                // Transform the minutes into a time format%0A                                var hours = Math.floor(value / 60);%0A                                var minutes = value %25 60;%0A                                return (hours %3C 10 ? %220%22 : %22%22) + hours + %22:%22 + (minutes %3C 10 ? %220%22 : %22%22) + minutes;%0A                            %7D%0A                        %7D;
 %0A   
@@ -4249,23 +4249,28 @@
  value: 
-minYear
+defaultValue
 ,%0A      
@@ -4292,23 +4292,50 @@
 ptions: 
-options
+_.extend(options, specificOptions)
 %0A       

Add year and time selection to the slider