gantt_rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +1 -0
- data/app/assets/javascripts/ganttDrawerSVG.js +992 -0
- data/app/assets/javascripts/ganttGridEditor.js +666 -0
- data/app/assets/javascripts/ganttMaster.js +1131 -0
- data/app/assets/javascripts/ganttTask.js +1034 -0
- data/app/assets/javascripts/ganttUtilities.js +304 -0
- data/app/assets/javascripts/libs/JST/jquery.JST.js +167 -0
- data/app/assets/javascripts/libs/date.js +584 -0
- data/app/assets/javascripts/libs/dateField/jquery.dateField.js +213 -0
- data/app/assets/javascripts/libs/i18nJs.js +139 -0
- data/app/assets/javascripts/libs/jquery.1.8.js +9472 -0
- data/app/assets/javascripts/libs/jquery.livequery.min.js +11 -0
- data/app/assets/javascripts/libs/jquery.svg.js +1394 -0
- data/app/assets/javascripts/libs/jquery.svg.min.js +7 -0
- data/app/assets/javascripts/libs/jquery.svgdom.1.8.js +406 -0
- data/app/assets/javascripts/libs/jquery.svgdom.js +406 -0
- data/app/assets/javascripts/libs/jquery.svgdom.pack.js +7 -0
- data/app/assets/javascripts/libs/jquery.timers.js +142 -0
- data/app/assets/javascripts/libs/platform.js +954 -0
- data/gantt_rails.gemspec +21 -0
- data/lib/gantt_rails/version.rb +3 -0
- data/lib/gantt_rails.rb +8 -0
- metadata +98 -0
@@ -0,0 +1,213 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2009 Open Lab
|
3
|
+
Written by Roberto Bicchierai http://roberto.open-lab.com
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
*/
|
23
|
+
|
24
|
+
jQuery.fn.dateField = function(options) {
|
25
|
+
|
26
|
+
//check if the input field is passed correctly
|
27
|
+
if (!options.inputField){
|
28
|
+
console.error("You must supply an input field");
|
29
|
+
return false;
|
30
|
+
}
|
31
|
+
|
32
|
+
// -------------------------- start default option values --------------------------
|
33
|
+
|
34
|
+
if (typeof(options.firstDayOfWeek) == "undefined")
|
35
|
+
options.firstDayOfWeek=Date.firstDayOfWeek;
|
36
|
+
|
37
|
+
if (typeof(options.useWheel) == "undefined")
|
38
|
+
options.useWheel=true;
|
39
|
+
|
40
|
+
if (typeof(options.dateFormat) == "undefined")
|
41
|
+
options.dateFormat=Date.defaultFormat;
|
42
|
+
// -------------------------- end default option values --------------------------
|
43
|
+
|
44
|
+
|
45
|
+
// ------------------ start
|
46
|
+
if(options.inputField.is("[readonly]") || options.inputField.is("[disabled]"))
|
47
|
+
return;
|
48
|
+
|
49
|
+
var calendar = {currentDate: new Date()};
|
50
|
+
calendar.options = options;
|
51
|
+
|
52
|
+
//build the calendar on the first element in the set of matched elements.
|
53
|
+
var theOpener = this.eq(0);
|
54
|
+
var theDiv=$("<div>").addClass("calBox");
|
55
|
+
|
56
|
+
|
57
|
+
//create calendar elements elements
|
58
|
+
var divNavBar = $("<div>").addClass("calNavBar");
|
59
|
+
var divDays = $("<div>").addClass("calDay");
|
60
|
+
|
61
|
+
divDays.addClass("calFullMonth");
|
62
|
+
theDiv.append(divNavBar).append(divDays);
|
63
|
+
|
64
|
+
|
65
|
+
if (options.isSearchField){
|
66
|
+
var divShortcuts=$("<div>").addClass("shortCuts").html("<span title='last quarter'>LQ</span> <span title='last month'>LM</span> <span title='this month'>M</span> <span title='last week'>LW</span> <span title='this week'>W</span> <span title='yesterday'>Y</span> <span title='today'>T</span><span title='tomorrow'>TO</span> <span title='next week'>NW</span> <span title='next month'>NM</span> <span title='this quarter'>Q</span> <span title='next quarter'>NQ</span>");
|
67
|
+
divShortcuts.click(function(ev){
|
68
|
+
var el=$(ev.target);
|
69
|
+
if(el.is("span")){
|
70
|
+
if (!options.isSearchField)
|
71
|
+
options.inputField.val(Date.parseString(el.text().trim(),options.dateFormat).format(options.dateFormat),true);
|
72
|
+
else
|
73
|
+
options.inputField.val(el.text().trim());
|
74
|
+
theDiv.remove();
|
75
|
+
}
|
76
|
+
});
|
77
|
+
theDiv.append(divShortcuts);
|
78
|
+
}
|
79
|
+
|
80
|
+
|
81
|
+
$("body").append(theDiv);
|
82
|
+
nearBestPosition(theOpener,theDiv);
|
83
|
+
theDiv.bringToFront();
|
84
|
+
|
85
|
+
|
86
|
+
//register for click outside. Delayed to avoid it run immediately
|
87
|
+
$("body").oneTime(100, "regclibodcal", function() {
|
88
|
+
$("body").bind("click.dateField", function() {
|
89
|
+
$(this).unbind("click.dateField");
|
90
|
+
theDiv.remove();
|
91
|
+
});
|
92
|
+
});
|
93
|
+
|
94
|
+
|
95
|
+
calendar.drawCalendar = function(date) {
|
96
|
+
calendar.currentDate = date;
|
97
|
+
|
98
|
+
var fillNavBar = function(date) {
|
99
|
+
var t = new Date(date.getTime());
|
100
|
+
divNavBar.empty();
|
101
|
+
|
102
|
+
t.setMonth(t.getMonth()-1);
|
103
|
+
var spanPrev = $("<span>").addClass("calElement noCallback prev").attr("millis", t.getTime());
|
104
|
+
t.setMonth(t.getMonth()+1);
|
105
|
+
var spanMonth = $("<span>").html(t.format("MMMM yyyy"));
|
106
|
+
t.setMonth(t.getMonth()+1);
|
107
|
+
var spanNext = $("<span>").addClass("calElement noCallback next").attr("millis", t.getTime());
|
108
|
+
|
109
|
+
divNavBar.append(spanPrev).append(spanMonth).append(spanNext);
|
110
|
+
};
|
111
|
+
|
112
|
+
var fillDaysFullMonth = function(date) {
|
113
|
+
divDays.empty();
|
114
|
+
var t = new Date();//today
|
115
|
+
var w = parseInt((theDiv.width()-4-(4*7))/7)+"px";
|
116
|
+
// draw day headers
|
117
|
+
var d = new Date(date);
|
118
|
+
d.setFirstDayOfThisWeek(options.firstDayOfWeek);
|
119
|
+
for (var i = 0; i < 7; i++) {
|
120
|
+
var span = $("<span>").addClass("calDayHeader").attr("day", d.getDay());
|
121
|
+
span.css("width",w);
|
122
|
+
span.html(Date.dayAbbreviations[d.getDay()]);
|
123
|
+
|
124
|
+
//call the dayHeaderRenderer
|
125
|
+
if (typeof(options.dayHeaderRenderer) == "function")
|
126
|
+
options.dayHeaderRenderer(span,d.getDay());
|
127
|
+
|
128
|
+
divDays.append(span);
|
129
|
+
d.setDate(d.getDate()+1);
|
130
|
+
}
|
131
|
+
|
132
|
+
//draw cells
|
133
|
+
d = new Date(date);
|
134
|
+
d.setDate(1); // set day to start of month
|
135
|
+
d.setFirstDayOfThisWeek(options.firstDayOfWeek);//go to first day of week
|
136
|
+
|
137
|
+
var i=0;
|
138
|
+
|
139
|
+
while ((d.getMonth()<=date.getMonth() && d.getFullYear()<=date.getFullYear()) || d.getFullYear()<date.getFullYear() || (i%7!=0)) {
|
140
|
+
var span = $("<span>").addClass("calElement day").attr("millis", d.getTime());
|
141
|
+
|
142
|
+
span.html("<span class=dayNumber>" + d.getDate() + "</span>").css("width",w);
|
143
|
+
if (d.getYear() == t.getYear() && d.getMonth() == t.getMonth() && d.getDate() == t.getDate())
|
144
|
+
span.addClass("today");
|
145
|
+
if (d.getYear() == date.getYear() && d.getMonth() == date.getMonth() && d.getDate() == date.getDate())
|
146
|
+
span.addClass("selected");
|
147
|
+
|
148
|
+
if(d.getMonth()!=date.getMonth())
|
149
|
+
span.addClass("calOutOfScope");
|
150
|
+
|
151
|
+
//call the dayRenderer
|
152
|
+
if (typeof(options.dayRenderer) == "function")
|
153
|
+
options.dayRenderer(span,d);
|
154
|
+
|
155
|
+
divDays.append(span);
|
156
|
+
d.setDate(d.getDate()+1);
|
157
|
+
i++;
|
158
|
+
}
|
159
|
+
|
160
|
+
};
|
161
|
+
|
162
|
+
fillNavBar(date);
|
163
|
+
fillDaysFullMonth(date);
|
164
|
+
};
|
165
|
+
|
166
|
+
|
167
|
+
theDiv.click(function(ev) {
|
168
|
+
var el = $(ev.target).closest(".calElement");
|
169
|
+
if (el.size() > 0) {
|
170
|
+
var date = new Date(parseInt(el.attr("millis")));
|
171
|
+
if (el.hasClass("day")) {
|
172
|
+
theDiv.remove();
|
173
|
+
if (!el.is(".noCallback")) {
|
174
|
+
options.inputField.val(date.format(options.dateFormat)).attr("millis", date.getTime()).focus();
|
175
|
+
if (typeof(options.callback) == "function")
|
176
|
+
options.callback(date);
|
177
|
+
}
|
178
|
+
} else {
|
179
|
+
calendar.drawCalendar(date);
|
180
|
+
}
|
181
|
+
}
|
182
|
+
ev.stopPropagation();
|
183
|
+
});
|
184
|
+
|
185
|
+
|
186
|
+
//if mousewheel
|
187
|
+
if ($.event.special.mousewheel && options.useWheel) {
|
188
|
+
divDays.mousewheel(function(event, delta) {
|
189
|
+
var d = new Date(calendar.currentDate.getTime());
|
190
|
+
d.setMonth(d.getMonth() + delta);
|
191
|
+
calendar.drawCalendar(d);
|
192
|
+
return false;
|
193
|
+
});
|
194
|
+
}
|
195
|
+
|
196
|
+
|
197
|
+
// start calendar to the date in the input
|
198
|
+
var dateStr=options.inputField.val();
|
199
|
+
|
200
|
+
|
201
|
+
if (!dateStr || !Date.isValid(dateStr,options.dateFormat,true)){
|
202
|
+
calendar.drawCalendar(new Date());
|
203
|
+
} else {
|
204
|
+
var date = Date.parseString(dateStr,options.dateFormat,true);
|
205
|
+
//set date string formatted
|
206
|
+
if (!options.isSearchField)
|
207
|
+
options.inputField.val(date.format(options.dateFormat)).attr("millis",date.getTime());
|
208
|
+
|
209
|
+
calendar.drawCalendar(date);
|
210
|
+
}
|
211
|
+
|
212
|
+
return calendar;
|
213
|
+
};
|
@@ -0,0 +1,139 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
function dateToRelative(localTime){
|
5
|
+
var diff=new Date().getTime()-localTime;
|
6
|
+
var ret="";
|
7
|
+
|
8
|
+
var min=60000;
|
9
|
+
var hour=3600000;
|
10
|
+
var day=86400000;
|
11
|
+
var wee=604800000;
|
12
|
+
var mon=2629800000;
|
13
|
+
var yea=31557600000;
|
14
|
+
|
15
|
+
if (diff<-yea*2)
|
16
|
+
ret ="in ## years".replace("##",(-diff/yea).toFixed(0));
|
17
|
+
|
18
|
+
else if (diff<-mon*9)
|
19
|
+
ret ="in ## months".replace("##",(-diff/mon).toFixed(0));
|
20
|
+
|
21
|
+
else if (diff<-wee*5)
|
22
|
+
ret ="in ## weeks".replace("##",(-diff/wee).toFixed(0));
|
23
|
+
|
24
|
+
else if (diff<-day*2)
|
25
|
+
ret ="in ## days".replace("##",(-diff/day).toFixed(0));
|
26
|
+
|
27
|
+
else if (diff<-hour)
|
28
|
+
ret ="in ## hours".replace("##",(-diff/hour).toFixed(0));
|
29
|
+
|
30
|
+
else if (diff<-min*35)
|
31
|
+
ret ="in about one hour";
|
32
|
+
|
33
|
+
else if (diff<-min*25)
|
34
|
+
ret ="in about half hour";
|
35
|
+
|
36
|
+
else if (diff<-min*10)
|
37
|
+
ret ="in some minutes";
|
38
|
+
|
39
|
+
else if (diff<-min*2)
|
40
|
+
ret ="in few minutes";
|
41
|
+
|
42
|
+
else if (diff<=min)
|
43
|
+
ret ="just now";
|
44
|
+
|
45
|
+
else if (diff<=min*5)
|
46
|
+
ret ="few minutes ago";
|
47
|
+
|
48
|
+
else if (diff<=min*15)
|
49
|
+
ret ="some minutes ago";
|
50
|
+
|
51
|
+
else if (diff<=min*35)
|
52
|
+
ret ="about half hour ago";
|
53
|
+
|
54
|
+
else if (diff<=min*75)
|
55
|
+
ret ="about an hour ago";
|
56
|
+
|
57
|
+
else if (diff<=hour*5)
|
58
|
+
ret ="few hours ago";
|
59
|
+
|
60
|
+
else if (diff<=hour*24)
|
61
|
+
ret ="## hours ago".replace("##",(diff/hour).toFixed(0));
|
62
|
+
|
63
|
+
else if (diff<=day*7)
|
64
|
+
ret ="## days ago".replace("##",(diff/day).toFixed(0));
|
65
|
+
|
66
|
+
else if (diff<=wee*5)
|
67
|
+
ret ="## weeks ago".replace("##",(diff/wee).toFixed(0));
|
68
|
+
|
69
|
+
else if (diff<=mon*12)
|
70
|
+
ret ="## months ago".replace("##",(diff/mon).toFixed(0));
|
71
|
+
|
72
|
+
else
|
73
|
+
ret ="## years ago".replace("##",(diff/yea).toFixed(0));
|
74
|
+
|
75
|
+
return ret;
|
76
|
+
}
|
77
|
+
|
78
|
+
//override date format i18n
|
79
|
+
|
80
|
+
Date.monthNames = ["January","February","March","April","May","June","July","August","September","October","November","December"];
|
81
|
+
// Month abbreviations. Change this for local month names
|
82
|
+
Date.monthAbbreviations = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
|
83
|
+
// Full day names. Change this for local month names
|
84
|
+
Date.dayNames =["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
|
85
|
+
// Day abbreviations. Change this for local month names
|
86
|
+
Date.dayAbbreviations = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];
|
87
|
+
// Used for parsing ambiguous dates like 1/2/2000 - default to preferring 'American' format meaning Jan 2.
|
88
|
+
// Set to false to prefer 'European' format meaning Feb 1
|
89
|
+
Date.preferAmericanFormat = false;
|
90
|
+
|
91
|
+
Date.firstDayOfWeek =1;
|
92
|
+
Date.defaultFormat = "dd/MM/yyyy";
|
93
|
+
|
94
|
+
|
95
|
+
Number.decimalSeparator = ".";
|
96
|
+
Number.groupingSeparator = ",";
|
97
|
+
Number.minusSign = "-";
|
98
|
+
Number.currencyFormat = "##0.00";
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
var millisInWorkingDay =36000000;
|
103
|
+
var workingDaysPerWeek =5;
|
104
|
+
|
105
|
+
function isHoliday(date) {
|
106
|
+
var friIsHoly =false;
|
107
|
+
var satIsHoly =true;
|
108
|
+
var sunIsHoly =true;
|
109
|
+
|
110
|
+
pad = function (val) {
|
111
|
+
val = "0" + val;
|
112
|
+
return val.substr(val.length - 2);
|
113
|
+
};
|
114
|
+
|
115
|
+
var holidays = "#01_01#04_25#08_15#11_01#12_25#12_26#06_02#12_08#05_01#2010_04_05#2010_10_19#2010_05_15#2011_04_04#";
|
116
|
+
|
117
|
+
var ymd = "#" + date.getFullYear() + "_" + pad(date.getMonth() + 1) + "_" + pad(date.getDate()) + "#";
|
118
|
+
var md = "#" + pad(date.getMonth() + 1) + "_" + pad(date.getDate()) + "#";
|
119
|
+
var day = date.getDay();
|
120
|
+
|
121
|
+
return (day == 5 && friIsHoly) || (day == 6 && satIsHoly) || (day == 0 && sunIsHoly) || holidays.indexOf(ymd) > -1 || holidays.indexOf(md) > -1;
|
122
|
+
}
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
var i18n = {
|
127
|
+
FORM_IS_CHANGED:"You have some unsaved data on the page!",
|
128
|
+
YES:"yes",
|
129
|
+
NO:"no",
|
130
|
+
FLD_CONFIRM_DELETE:"confirm the deletion?",
|
131
|
+
INVALID_DATA:"The data inserted are invalid for the field format.",
|
132
|
+
ERROR_ON_FIELD:"Error on field",
|
133
|
+
CLOSE_ALL_CONTAINERS:"close all?",
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
DO_YOU_CONFIRM:"Do you confirm?"
|
138
|
+
};
|
139
|
+
|