From 254910c2f4d1e1908752a4368480ee9871d83bf8 Mon Sep 17 00:00:00 2001 From: Sebastian Klatte Date: Thu, 22 May 2014 22:22:47 +0200 Subject: [PATCH 1/4] updated day to display start time properly --- tmpls/day.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmpls/day.html b/tmpls/day.html index 6cac67c3..3c7bb2d6 100644 --- a/tmpls/day.html +++ b/tmpls/day.html @@ -45,7 +45,7 @@
<% for(i = 0; i < hours; i++){ %>
- <% for(l = 0; l < in_hour; l++){ %> + <% for(l = 0; l < cal._hour_min(i); l++){ %>
<%= cal._hour(i, l) %>
From 366584b5c110515eae804b083f7aa1e21d16dcf2 Mon Sep 17 00:00:00 2001 From: Sebastian Klatte Date: Thu, 22 May 2014 22:27:47 +0200 Subject: [PATCH 2/4] recognize time_start minutes --- js/calendar.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/js/calendar.js b/js/calendar.js index 74ca5f3c..4eb0223d 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -436,18 +436,18 @@ if(!String.prototype.formatNum) { Calendar.prototype._calculate_hour_minutes = function(data) { var $self = this; var time_split = parseInt(this.options.time_split); - data.in_hour = 60 / time_split; - data.hour_split = time_split; + var time_split_count = 60 / time_split; + var time_split_hour = Math.min(time_split_count, 1); - if(((data.in_hour >= 1) && (data.in_hour % 1 != 0)) || ((data.in_hour < 1) && (1440 / data.hour_split % 1 != 0))) { + if(((time_split_count >= 1) && (time_split_count % 1 != 0)) || ((time_split_count < 1) && (1440 / time_split % 1 != 0))) { $.error(this.locale.error_timedevide); } var time_start = this.options.time_start.split(":"); var time_end = this.options.time_end.split(":"); - data.hours = (parseInt(time_end[0]) - parseInt(time_start[0])) * Math.min(data.in_hour, 1); - var lines = data.hours * data.in_hour; + data.hours = (parseInt(time_end[0]) - parseInt(time_start[0])) * time_split_hour; + var lines = data.hours * time_split_count - parseInt(time_start[1]) / time_split; var ms_per_line = (60000 * time_split); var start = new Date(this.options.position.start.getTime()); @@ -520,15 +520,26 @@ if(!String.prototype.formatNum) { //warn(d.getTime()); }; + Calendar.prototype._hour_min = function(hour) { + var time_start = this.options.time_start.split(":"); + var time_split = parseInt(this.options.time_split); + var in_hour = 60 / time_split; + return (hour == 0) ? (in_hour - (parseInt(time_start[1]) / time_split)) : in_hour; + }; + Calendar.prototype._hour = function(hour, part) { var time_start = this.options.time_start.split(":"); var time_split = parseInt(this.options.time_split); + var time_start_h = parseInt(time_start[0]); + var time_start_m = parseInt(time_start[1]); - var hour = "" + (parseInt(time_start[0]) + hour * Math.max(time_split / 60, 1)); - var minute = "" + (time_split * part); + var r_h = time_start_h + hour * Math.max(time_split / 60, 1); + var r_m = time_split * part; + if((hour == 0)) + r_m += time_start_m; - return hour.formatNum(2) + ":" + minute.formatNum(2); - } + return r_h.toString().formatNum(2) + ":" + r_m.toString().formatNum(2); + }; Calendar.prototype._week = function(event) { this._loadTemplate('week-days'); From 709ffdb88f4e96cfc5eba5c47ee3d8169a92ad91 Mon Sep 17 00:00:00 2001 From: Sebastian Klatte Date: Thu, 22 May 2014 23:33:56 +0200 Subject: [PATCH 3/4] fix for very short events --- js/calendar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/calendar.js b/js/calendar.js index 4eb0223d..6b1880c2 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -501,7 +501,7 @@ if(!String.prototype.formatNum) { e.top = Math.abs(event_start) / ms_per_line; } - var lines_left = lines - e.top; + var lines_left = Math.abs(lines - e.top); var lines_in_event = (e.end - e.start) / ms_per_line; if(event_start >= 0) { lines_in_event = (e.end - start.getTime()) / ms_per_line; From 65f9722b3a7c12a13dbe111597109494b59e1f83 Mon Sep 17 00:00:00 2001 From: Sebastian Klatte Date: Tue, 10 Jun 2014 00:57:06 +0200 Subject: [PATCH 4/4] more compact _hour function --- js/calendar.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/js/calendar.js b/js/calendar.js index 6b1880c2..658eefc5 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -530,15 +530,10 @@ if(!String.prototype.formatNum) { Calendar.prototype._hour = function(hour, part) { var time_start = this.options.time_start.split(":"); var time_split = parseInt(this.options.time_split); - var time_start_h = parseInt(time_start[0]); - var time_start_m = parseInt(time_start[1]); + var h = "" + (parseInt(time_start[0]) + hour * Math.max(time_split / 60, 1)); + var m = "" + (time_split * part + (hour == 0) ? parseInt(time_start[1]) : 0); - var r_h = time_start_h + hour * Math.max(time_split / 60, 1); - var r_m = time_split * part; - if((hour == 0)) - r_m += time_start_m; - - return r_h.toString().formatNum(2) + ":" + r_m.toString().formatNum(2); + return h.formatNum(2) + ":" + m.formatNum(2); }; Calendar.prototype._week = function(event) {