Skip to content

Commit

Permalink
Merge pull request #313 from geskill/patch-2
Browse files Browse the repository at this point in the history
recognize time_start minutes
  • Loading branch information
Serhioromano committed Jul 1, 2014
2 parents cdd6378 + 65f9722 commit 44895f5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
26 changes: 16 additions & 10 deletions js/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -520,15 +520,21 @@ if(!String.prototype.formatNum) {
//warn(d.getTime());
};

Calendar.prototype._hour = function(hour, part) {
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;
};

var hour = "" + (parseInt(time_start[0]) + hour * Math.max(time_split / 60, 1));
var minute = "" + (time_split * part);
Calendar.prototype._hour = function(hour, part) {
var time_start = this.options.time_start.split(":");
var time_split = parseInt(this.options.time_split);
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);

return hour.formatNum(2) + ":" + minute.formatNum(2);
}
return h.formatNum(2) + ":" + m.formatNum(2);
};

Calendar.prototype._week = function(event) {
this._loadTemplate('week-days');
Expand Down
2 changes: 1 addition & 1 deletion tmpls/day.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<div id="cal-day-panel-hour">
<% for(i = 0; i < hours; i++){ %>
<div class="cal-day-hour">
<% for(l = 0; l < in_hour; l++){ %>
<% for(l = 0; l < cal._hour_min(i); l++){ %>
<div class="row-fluid cal-day-hour-part">
<div class="span1 col-xs-1"><b><%= cal._hour(i, l) %></b></div>
<div class="span11 col-xs-11"></div>
Expand Down

0 comments on commit 44895f5

Please sign in to comment.