aureus 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/Gemfile.lock +14 -0
- data/Rakefile +20 -0
- data/Readme.md +3 -0
- data/app/assets/images/aureus/background.png +0 -0
- data/app/assets/images/aureus/icon-cross.png +0 -0
- data/app/assets/images/aureus/icon-eye.png +0 -0
- data/app/assets/images/aureus/icon-pencil.png +0 -0
- data/app/assets/images/aureus/icon-print.png +0 -0
- data/app/assets/images/aureus/icon-refresh.png +0 -0
- data/app/assets/images/aureus/icon-sort-abc-asc.png +0 -0
- data/app/assets/images/aureus/icon-sort-abc-desc.png +0 -0
- data/app/assets/images/aureus/icon-sort.png +0 -0
- data/app/assets/images/aureus/topbar.png +0 -0
- data/app/assets/javascripts/aureus/extensions.js +42 -0
- data/app/assets/javascripts/aureus/functions.js +18 -0
- data/app/assets/javascripts/aureus/index.js +55 -0
- data/app/assets/javascripts/aureus/plugins/jquery-calendrical.js +508 -0
- data/app/assets/javascripts/aureus/plugins/jquery-datatables.js +11838 -0
- data/app/assets/javascripts/aureus/plugins/jquery-qtip.js +15 -0
- data/app/assets/stylesheets/aureus/base.scss +43 -0
- data/app/assets/stylesheets/aureus/content.scss +124 -0
- data/app/assets/stylesheets/aureus/form.scss +73 -0
- data/app/assets/stylesheets/aureus/index.scss +38 -0
- data/app/assets/stylesheets/aureus/mixins.scss +43 -0
- data/app/assets/stylesheets/aureus/navigation.scss +44 -0
- data/app/assets/stylesheets/aureus/reset.scss +50 -0
- data/app/assets/stylesheets/aureus/table.scss +164 -0
- data/app/assets/stylesheets/aureus/topbar.scss +43 -0
- data/app/assets/stylesheets/aureus/ui.scss +98 -0
- data/aureus.gemspec +23 -0
- data/lib/aureus.rb +5 -0
- data/lib/aureus/engine.rb +5 -0
- data/lib/aureus/version.rb +3 -0
- metadata +79 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rake/testtask'
|
2
|
+
require 'highline/import'
|
3
|
+
|
4
|
+
Rake::TestTask.new do |t|
|
5
|
+
t.libs << 'test'
|
6
|
+
end
|
7
|
+
|
8
|
+
desc "build and publish"
|
9
|
+
task :build do
|
10
|
+
puts "build gem..."
|
11
|
+
`gem build aureus.gemspec`
|
12
|
+
Dir["*.gem"].each do |file|
|
13
|
+
if agree "publish gem: #{file}? (y,n)"
|
14
|
+
puts "publishing gem..."
|
15
|
+
`gem push #{file}`
|
16
|
+
end
|
17
|
+
end
|
18
|
+
puts "remove gem..."
|
19
|
+
`rm *.gem`
|
20
|
+
end
|
data/Readme.md
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,42 @@
|
|
1
|
+
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
|
2
|
+
"date-eu-pre": function ( date ) {
|
3
|
+
var date = date.replace(" ", "");
|
4
|
+
|
5
|
+
if (date.indexOf('.') > 0) {
|
6
|
+
/*date a, format dd.mn.(yyyy) ; (year is optional)*/
|
7
|
+
var eu_date = date.split('.');
|
8
|
+
} else {
|
9
|
+
/*date a, format dd/mn/(yyyy) ; (year is optional)*/
|
10
|
+
var eu_date = date.split('/');
|
11
|
+
}
|
12
|
+
|
13
|
+
/*year (optional)*/
|
14
|
+
if (eu_date[2]) {
|
15
|
+
var year = eu_date[2];
|
16
|
+
} else {
|
17
|
+
var year = 0;
|
18
|
+
}
|
19
|
+
|
20
|
+
/*month*/
|
21
|
+
var month = eu_date[1];
|
22
|
+
if (month.length == 1) {
|
23
|
+
month = 0+month;
|
24
|
+
}
|
25
|
+
|
26
|
+
/*day*/
|
27
|
+
var day = eu_date[0];
|
28
|
+
if (day.length == 1) {
|
29
|
+
day = 0+day;
|
30
|
+
}
|
31
|
+
|
32
|
+
return (year + month + day) * 1;
|
33
|
+
},
|
34
|
+
|
35
|
+
"date-eu-asc": function ( a, b ) {
|
36
|
+
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
|
37
|
+
},
|
38
|
+
|
39
|
+
"date-eu-desc": function ( a, b ) {
|
40
|
+
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
|
41
|
+
}
|
42
|
+
} );
|
@@ -0,0 +1,18 @@
|
|
1
|
+
// Column Configurator for Datatables
|
2
|
+
function datatablesColumnConf(table) {
|
3
|
+
var ret = Array();
|
4
|
+
table.children("thead").children("tr").children("th").each(function(){
|
5
|
+
if($(this).hasClass("no-sorting")) {
|
6
|
+
ret.push({ bSortable: false });
|
7
|
+
} else if($(this).hasClass("date-sorting")) {
|
8
|
+
ret.push({ sType: "date-eu" });
|
9
|
+
} else {
|
10
|
+
ret.push(null);
|
11
|
+
}
|
12
|
+
});
|
13
|
+
return ret;
|
14
|
+
}
|
15
|
+
|
16
|
+
function triggerForm(selector) {
|
17
|
+
$(selector).submit();
|
18
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
//= require jquery
|
2
|
+
//= require jquery_ujs
|
3
|
+
//= require jquery-ui
|
4
|
+
//= require_directory ./plugins
|
5
|
+
//= require ./functions
|
6
|
+
//= require ./extensions
|
7
|
+
//= require_self
|
8
|
+
|
9
|
+
var datatablesLanguageConfig = {
|
10
|
+
sSearch : "Suchen:",
|
11
|
+
sLengthMenu: "Zeige _MENU_ Einträge pro Seite",
|
12
|
+
sZeroRecords: "Keine Daten gefunden",
|
13
|
+
sInfo: "Zeige _START_ bis _END_ von _TOTAL_ Einträgen",
|
14
|
+
sInfoEmpty: "Zeige 0 Einträge",
|
15
|
+
sInfoFiltered: "(Total _MAX_ Einträge)"
|
16
|
+
};
|
17
|
+
|
18
|
+
$(document).ready(function(){
|
19
|
+
|
20
|
+
$("td.buttons a").wrapInner("<span/>");
|
21
|
+
|
22
|
+
$.fn.dataTableExt.oStdClasses.sWrapper = "datatable-wrapper";
|
23
|
+
$.fn.dataTableExt.oStdClasses.sLength = "datatable-length";
|
24
|
+
$.fn.dataTableExt.oStdClasses.sFilter = "datatable-filter";
|
25
|
+
$.fn.dataTableExt.oStdClasses.sInfo = "datatable-info";
|
26
|
+
$.fn.dataTableExt.oStdClasses.sPaging = "datatable-paging";
|
27
|
+
|
28
|
+
$('.datatable').each(function(){
|
29
|
+
$(this).dataTable({
|
30
|
+
sDom: '<"toolbar"fi>t',
|
31
|
+
oLanguage: datatablesLanguageConfig,
|
32
|
+
bPaginate: false,
|
33
|
+
aoColumns: datatablesColumnConf($(this))
|
34
|
+
});
|
35
|
+
});
|
36
|
+
|
37
|
+
$('.datatable-no-toolbar').each(function(){
|
38
|
+
$(this).dataTable({
|
39
|
+
sDom: 't',
|
40
|
+
oLanguage: datatablesLanguageConfig,
|
41
|
+
bPaginate: false,
|
42
|
+
aoColumns: datatablesColumnConf($(this))
|
43
|
+
});
|
44
|
+
});
|
45
|
+
|
46
|
+
$(".datepicker").datepicker(datepickerConfiguration);
|
47
|
+
|
48
|
+
// Prevent Bug
|
49
|
+
$("div.ui-datepicker").hide();
|
50
|
+
|
51
|
+
$(".timepicker").calendricalTime(timepickerConfiguration);
|
52
|
+
|
53
|
+
$.fn.qtip.styles.single = tooltipConfiguration;
|
54
|
+
|
55
|
+
});
|
@@ -0,0 +1,508 @@
|
|
1
|
+
(function($) {
|
2
|
+
var monthNames = ['January', 'February', 'March', 'April', 'May', 'June',
|
3
|
+
'July', 'August', 'September', 'October', 'November', 'December'];
|
4
|
+
|
5
|
+
function getToday()
|
6
|
+
{
|
7
|
+
var date = new Date();
|
8
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
9
|
+
}
|
10
|
+
|
11
|
+
function areDatesEqual(date1, date2)
|
12
|
+
{
|
13
|
+
return String(date1) == String(date2);
|
14
|
+
}
|
15
|
+
|
16
|
+
function daysInMonth(year, month)
|
17
|
+
{
|
18
|
+
if (year instanceof Date) return daysInMonth(year.getFullYear(), year.getMonth());
|
19
|
+
if (month == 1) {
|
20
|
+
var leapYear = (year % 4 == 0) &&
|
21
|
+
(!(year % 100 == 0) || (year % 400 == 0));
|
22
|
+
return leapYear ? 29 : 28;
|
23
|
+
} else if (month == 3 || month == 5 || month == 8 || month == 10) {
|
24
|
+
return 30;
|
25
|
+
} else {
|
26
|
+
return 31;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
function dayAfter(date)
|
31
|
+
{
|
32
|
+
var year = date.getFullYear();
|
33
|
+
var month = date.getMonth();
|
34
|
+
var day = date.getDate();
|
35
|
+
var lastDay = daysInMonth(date);
|
36
|
+
return (day == lastDay) ?
|
37
|
+
((month == 11) ?
|
38
|
+
new Date(year + 1, 0, 1) :
|
39
|
+
new Date(year, month + 1, 1)
|
40
|
+
) :
|
41
|
+
new Date(year, month, day + 1);
|
42
|
+
}
|
43
|
+
|
44
|
+
function dayBefore(date)
|
45
|
+
{
|
46
|
+
var year = date.getFullYear();
|
47
|
+
var month = date.getMonth();
|
48
|
+
var day = date.getDate();
|
49
|
+
return (day == 1) ?
|
50
|
+
((month == 0) ?
|
51
|
+
new Date(year - 1, 11, daysInMonth(year - 1, 11)) :
|
52
|
+
new Date(year, month - 1, daysInMonth(year, month - 1))
|
53
|
+
) :
|
54
|
+
new Date(year, month, day - 1);
|
55
|
+
}
|
56
|
+
|
57
|
+
function monthAfter(year, month)
|
58
|
+
{
|
59
|
+
return (month == 11) ?
|
60
|
+
new Date(year + 1, 0, 1) :
|
61
|
+
new Date(year, month + 1, 1);
|
62
|
+
}
|
63
|
+
|
64
|
+
function formatDate(date, usa)
|
65
|
+
{
|
66
|
+
return (usa ?
|
67
|
+
((date.getMonth() + 1) + '/' + date.getDate()) :
|
68
|
+
(date.getDate() + '/' + (date.getMonth() + 1))
|
69
|
+
) + '/' + date.getFullYear();
|
70
|
+
}
|
71
|
+
|
72
|
+
function parseDate(date, usa)
|
73
|
+
{
|
74
|
+
if (usa) return new Date(date);
|
75
|
+
a = date.split(/[\.\-\/]/);
|
76
|
+
var day = a.shift();
|
77
|
+
var month = a.shift();
|
78
|
+
a.unshift(day);
|
79
|
+
a.unshift(month);
|
80
|
+
return new Date(a.join('/'));
|
81
|
+
}
|
82
|
+
|
83
|
+
function formatTime(hour, minute, options)
|
84
|
+
{
|
85
|
+
var printMinute = minute;
|
86
|
+
if (minute < 10) printMinute = '0' + minute;
|
87
|
+
|
88
|
+
if (options.isoTime) {
|
89
|
+
var printHour = hour
|
90
|
+
if (printHour < 10) printHour = '0' + hour;
|
91
|
+
return printHour + ':' + printMinute;
|
92
|
+
} else {
|
93
|
+
var printHour = hour % 12;
|
94
|
+
if (printHour == 0) printHour = 12;
|
95
|
+
|
96
|
+
if (options.meridiemUpperCase) {
|
97
|
+
var half = (hour < 12) ? 'AM' : 'PM';
|
98
|
+
} else {
|
99
|
+
var half = (hour < 12) ? 'am' : 'pm';
|
100
|
+
}
|
101
|
+
|
102
|
+
return printHour + ':' + printMinute + half;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
function parseTime(text)
|
107
|
+
{
|
108
|
+
var match = match = /(\d+)\s*[:\-\.,]\s*(\d+)\s*(am|pm)?/i.exec(text);
|
109
|
+
if (match && match.length >= 3) {
|
110
|
+
var hour = Number(match[1]);
|
111
|
+
var minute = Number(match[2])
|
112
|
+
if (hour == 12 && match[3]) hour -= 12;
|
113
|
+
if (match[3] && match[3].toLowerCase() == 'pm') hour += 12;
|
114
|
+
return {
|
115
|
+
hour: hour,
|
116
|
+
minute: minute
|
117
|
+
};
|
118
|
+
} else {
|
119
|
+
return null;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
function timeToMinutes(time)
|
124
|
+
{
|
125
|
+
return time && (time.hour * 60 + time.minute);
|
126
|
+
}
|
127
|
+
|
128
|
+
/**
|
129
|
+
* Generates calendar header, with month name, << and >> controls, and
|
130
|
+
* initials for days of the week.
|
131
|
+
*/
|
132
|
+
function renderCalendarHeader(element, year, month, options)
|
133
|
+
{
|
134
|
+
//Prepare thead element
|
135
|
+
var thead = $('<thead />');
|
136
|
+
var titleRow = $('<tr />').appendTo(thead);
|
137
|
+
|
138
|
+
//Generate << (back a month) link
|
139
|
+
$('<th />').addClass('monthCell').append(
|
140
|
+
$('<a href="javascript:;">«</a>')
|
141
|
+
.addClass('prevMonth')
|
142
|
+
.mousedown(function(e) {
|
143
|
+
renderCalendarPage(element,
|
144
|
+
month == 0 ? (year - 1) : year,
|
145
|
+
month == 0 ? 11 : (month - 1), options
|
146
|
+
);
|
147
|
+
e.preventDefault();
|
148
|
+
})
|
149
|
+
).appendTo(titleRow);
|
150
|
+
|
151
|
+
//Generate month title
|
152
|
+
$('<th />').addClass('monthCell').attr('colSpan', 5).append(
|
153
|
+
$('<a href="javascript:;">' + monthNames[month] + ' ' +
|
154
|
+
year + '</a>').addClass('monthName')
|
155
|
+
).appendTo(titleRow);
|
156
|
+
|
157
|
+
//Generate >> (forward a month) link
|
158
|
+
$('<th />').addClass('monthCell').append(
|
159
|
+
$('<a href="javascript:;">»</a>')
|
160
|
+
.addClass('nextMonth')
|
161
|
+
.mousedown(function() {
|
162
|
+
renderCalendarPage(element,
|
163
|
+
month == 11 ? (year + 1) : year,
|
164
|
+
month == 11 ? 0 : (month + 1), options
|
165
|
+
);
|
166
|
+
})
|
167
|
+
).appendTo(titleRow);
|
168
|
+
|
169
|
+
//Generate weekday initials row
|
170
|
+
var dayNames = $('<tr />').appendTo(thead);
|
171
|
+
$.each(String('SMTWTFS').split(''), function(k, v) {
|
172
|
+
$('<td />').addClass('dayName').append(v).appendTo(dayNames);
|
173
|
+
});
|
174
|
+
|
175
|
+
return thead;
|
176
|
+
}
|
177
|
+
|
178
|
+
function renderCalendarPage(element, year, month, options)
|
179
|
+
{
|
180
|
+
options = options || {};
|
181
|
+
|
182
|
+
var today = getToday();
|
183
|
+
|
184
|
+
var date = new Date(year, month, 1);
|
185
|
+
|
186
|
+
//Wind end date forward to saturday week after month
|
187
|
+
var endDate = monthAfter(year, month);
|
188
|
+
var ff = 6 - endDate.getDay();
|
189
|
+
if (ff < 6) ff += 7;
|
190
|
+
for (var i = 0; i < ff; i++) endDate = dayAfter(endDate);
|
191
|
+
|
192
|
+
var table = $('<table />');
|
193
|
+
renderCalendarHeader(element, year, month, options).appendTo(table);
|
194
|
+
|
195
|
+
var tbody = $('<tbody />').appendTo(table);
|
196
|
+
var row = $('<tr />');
|
197
|
+
|
198
|
+
//Rewind date to monday week before month
|
199
|
+
var rewind = date.getDay() + 7;
|
200
|
+
for (var i = 0; i < rewind; i++) date = dayBefore(date);
|
201
|
+
|
202
|
+
while (date <= endDate) {
|
203
|
+
var td = $('<td />')
|
204
|
+
.addClass('day')
|
205
|
+
.append(
|
206
|
+
$('<a href="javascript:;">' +
|
207
|
+
date.getDate() + '</a>'
|
208
|
+
).click((function() {
|
209
|
+
var thisDate = date;
|
210
|
+
|
211
|
+
return function() {
|
212
|
+
if (options && options.selectDate) {
|
213
|
+
options.selectDate(thisDate);
|
214
|
+
}
|
215
|
+
}
|
216
|
+
}()))
|
217
|
+
)
|
218
|
+
.appendTo(row);
|
219
|
+
|
220
|
+
var isToday = areDatesEqual(date, today);
|
221
|
+
var isSelected = options.selected &&
|
222
|
+
areDatesEqual(options.selected, date);
|
223
|
+
|
224
|
+
if (isToday) td.addClass('today');
|
225
|
+
if (isSelected) td.addClass('selected');
|
226
|
+
if (isToday && isSelected) td.addClass('today_selected');
|
227
|
+
if (date.getMonth() != month) td.addClass('nonMonth');
|
228
|
+
|
229
|
+
dow = date.getDay();
|
230
|
+
if (dow == 6) {
|
231
|
+
tbody.append(row);
|
232
|
+
row = $('<tr />');
|
233
|
+
}
|
234
|
+
date = dayAfter(date);
|
235
|
+
}
|
236
|
+
if (row.children().length) {
|
237
|
+
tbody.append(row);
|
238
|
+
} else {
|
239
|
+
row.remove();
|
240
|
+
}
|
241
|
+
|
242
|
+
element.empty().append(table);
|
243
|
+
}
|
244
|
+
|
245
|
+
function renderTimeSelect(element, options)
|
246
|
+
{
|
247
|
+
var minTime = timeToMinutes(options.minTime);
|
248
|
+
var maxTime = timeToMinutes(options.maxTime);
|
249
|
+
var defaultTime = timeToMinutes(options.defaultTime);
|
250
|
+
var selection = options.selection && timeToMinutes(parseTime(options.selection));
|
251
|
+
|
252
|
+
//Round selection to nearest time interval so that it matches a list item
|
253
|
+
selection = selection && (
|
254
|
+
(
|
255
|
+
Math.floor((selection - minTime) / options.timeInterval) *
|
256
|
+
options.timeInterval
|
257
|
+
) + minTime
|
258
|
+
);
|
259
|
+
|
260
|
+
var scrollTo; //Element to scroll the dropdown box to when shown
|
261
|
+
var ul = $('<ul />');
|
262
|
+
|
263
|
+
for (var time = minTime; time <= maxTime; time += options.timeInterval) {
|
264
|
+
(function(time) {
|
265
|
+
var hour = Math.floor(time / 60);
|
266
|
+
var minute = time % 60;
|
267
|
+
var timeText = formatTime(hour, minute, options);
|
268
|
+
var fullText = timeText;
|
269
|
+
if (options.showDuration) {
|
270
|
+
var duration = time - minTime;
|
271
|
+
if (duration < 60) {
|
272
|
+
fullText += ' (' + duration + ' mins)';
|
273
|
+
} else if (duration == 60) {
|
274
|
+
fullText += ' (1 hr)';
|
275
|
+
} else {
|
276
|
+
//Round partial hours to 1 decimal place
|
277
|
+
fullText += ' (' + (Math.round(duration / 60.0 * 10.0) / 10.0) + ' hrs)';
|
278
|
+
}
|
279
|
+
}
|
280
|
+
var li = $('<li />').append(
|
281
|
+
$('<a href="javascript:;">' + fullText + '</a>')
|
282
|
+
.click(function() {
|
283
|
+
if (options && options.selectTime) {
|
284
|
+
options.selectTime(timeText);
|
285
|
+
}
|
286
|
+
}).mousemove(function() {
|
287
|
+
$('li.selected', ul).removeClass('selected');
|
288
|
+
})
|
289
|
+
).appendTo(ul);
|
290
|
+
|
291
|
+
//Set to scroll to the default hour, unless already set
|
292
|
+
if (!scrollTo && time == defaultTime) scrollTo = li;
|
293
|
+
|
294
|
+
if (selection == time) {
|
295
|
+
//Highlight selected item
|
296
|
+
li.addClass('selected');
|
297
|
+
|
298
|
+
//Set to scroll to the selected hour
|
299
|
+
//
|
300
|
+
//This is set even if scrollTo is already set, since
|
301
|
+
//scrolling to selected hour is more important than
|
302
|
+
//scrolling to default hour
|
303
|
+
scrollTo = li;
|
304
|
+
}
|
305
|
+
})(time);
|
306
|
+
}
|
307
|
+
if (scrollTo) {
|
308
|
+
//Set timeout of zero so code runs immediately after any calling
|
309
|
+
//functions are finished (this is needed, since box hasn't been
|
310
|
+
//added to the DOM yet)
|
311
|
+
setTimeout(function() {
|
312
|
+
//Scroll the dropdown box so that scrollTo item is in
|
313
|
+
//the middle
|
314
|
+
element[0].scrollTop =
|
315
|
+
scrollTo[0].offsetTop - scrollTo.height() * 2;
|
316
|
+
}, 0);
|
317
|
+
}
|
318
|
+
element.empty().append(ul);
|
319
|
+
}
|
320
|
+
|
321
|
+
$.fn.calendricalDate = function(options)
|
322
|
+
{
|
323
|
+
options = options || {};
|
324
|
+
options.padding = options.padding || 4;
|
325
|
+
|
326
|
+
return this.each(function() {
|
327
|
+
var element = $(this);
|
328
|
+
var div;
|
329
|
+
var within = false;
|
330
|
+
|
331
|
+
element.bind('focus click', function() {
|
332
|
+
if (div) return;
|
333
|
+
var offset = element.position();
|
334
|
+
var padding = element.css('padding-left');
|
335
|
+
div = $('<div />')
|
336
|
+
.addClass('calendricalDatePopup')
|
337
|
+
.mouseenter(function() { within = true; })
|
338
|
+
.mouseleave(function() { within = false; })
|
339
|
+
.mousedown(function(e) {
|
340
|
+
e.preventDefault();
|
341
|
+
})
|
342
|
+
.css({
|
343
|
+
position: 'absolute',
|
344
|
+
left: offset.left,
|
345
|
+
top: offset.top + element.height() +
|
346
|
+
options.padding * 2
|
347
|
+
});
|
348
|
+
element.after(div);
|
349
|
+
|
350
|
+
var selected = parseDate(element.val(), options.usa);
|
351
|
+
if (!selected.getFullYear()) selected = getToday();
|
352
|
+
|
353
|
+
renderCalendarPage(
|
354
|
+
div,
|
355
|
+
selected.getFullYear(),
|
356
|
+
selected.getMonth(), {
|
357
|
+
selected: selected,
|
358
|
+
selectDate: function(date) {
|
359
|
+
within = false;
|
360
|
+
element.val(formatDate(date, options.usa));
|
361
|
+
div.remove();
|
362
|
+
div = null;
|
363
|
+
if (options.endDate) {
|
364
|
+
var endDate = parseDate(
|
365
|
+
options.endDate.val(), options.usa
|
366
|
+
);
|
367
|
+
if (endDate >= selected) {
|
368
|
+
options.endDate.val(formatDate(
|
369
|
+
new Date(
|
370
|
+
date.getTime() +
|
371
|
+
endDate.getTime() -
|
372
|
+
selected.getTime()
|
373
|
+
),
|
374
|
+
options.usa
|
375
|
+
));
|
376
|
+
}
|
377
|
+
}
|
378
|
+
}
|
379
|
+
}
|
380
|
+
);
|
381
|
+
}).blur(function() {
|
382
|
+
if (within){
|
383
|
+
if (div) element.focus();
|
384
|
+
return;
|
385
|
+
}
|
386
|
+
if (!div) return;
|
387
|
+
div.remove();
|
388
|
+
div = null;
|
389
|
+
});
|
390
|
+
});
|
391
|
+
};
|
392
|
+
|
393
|
+
$.fn.calendricalDateRange = function(options)
|
394
|
+
{
|
395
|
+
if (this.length >= 2) {
|
396
|
+
$(this[0]).calendricalDate($.extend({
|
397
|
+
endDate: $(this[1])
|
398
|
+
}, options));
|
399
|
+
$(this[1]).calendricalDate(options);
|
400
|
+
}
|
401
|
+
return this;
|
402
|
+
};
|
403
|
+
|
404
|
+
$.fn.calendricalTime = function(options)
|
405
|
+
{
|
406
|
+
options = options || {};
|
407
|
+
options.timeInterval = options.timeInterval || 30;
|
408
|
+
options.padding = options.padding || 4;
|
409
|
+
|
410
|
+
return this.each(function() {
|
411
|
+
var element = $(this);
|
412
|
+
var div;
|
413
|
+
var within = false;
|
414
|
+
|
415
|
+
element.bind('focus click', function() {
|
416
|
+
if (div) return;
|
417
|
+
|
418
|
+
var offset = element.position();
|
419
|
+
div = $('<div />')
|
420
|
+
.addClass('calendricalTimePopup')
|
421
|
+
.mouseenter(function() { within = true; })
|
422
|
+
.mouseleave(function() { within = false; })
|
423
|
+
.mousedown(function(e) {
|
424
|
+
e.preventDefault();
|
425
|
+
})
|
426
|
+
.css({
|
427
|
+
position: 'absolute',
|
428
|
+
left: offset.left,
|
429
|
+
top: offset.top + element.height() +
|
430
|
+
options.padding * 2
|
431
|
+
});
|
432
|
+
|
433
|
+
element.after(div);
|
434
|
+
|
435
|
+
var renderOptions = {
|
436
|
+
selection: element.val(),
|
437
|
+
selectTime: function(time) {
|
438
|
+
within = false;
|
439
|
+
element.val(time);
|
440
|
+
element.trigger("change");
|
441
|
+
div.remove();
|
442
|
+
div = null;
|
443
|
+
},
|
444
|
+
isoTime: options.isoTime || false,
|
445
|
+
meridiemUpperCase: options.meridiemUpperCase || false,
|
446
|
+
defaultTime: options.defaultTime || {hour: 8, minute: 0},
|
447
|
+
minTime: options.minTime || {hour: 0, minute: 0},
|
448
|
+
maxTime: options.maxTime || {hour: 23, minute: 59},
|
449
|
+
timeInterval: options.timeInterval || 30
|
450
|
+
};
|
451
|
+
|
452
|
+
if (options.startTime) {
|
453
|
+
var startTime = parseTime(options.startTime.val());
|
454
|
+
//Don't display duration if part of a datetime range,
|
455
|
+
//and start and end times are on different days
|
456
|
+
if (options.startDate && options.endDate &&
|
457
|
+
!areDatesEqual(parseDate(options.startDate.val()),
|
458
|
+
parseDate(options.endDate.val()))) {
|
459
|
+
startTime = null;
|
460
|
+
}
|
461
|
+
if (startTime) {
|
462
|
+
renderOptions.minTime = startTime;
|
463
|
+
renderOptions.showDuration = true;
|
464
|
+
div.addClass('calendricalEndTimePopup');
|
465
|
+
}
|
466
|
+
}
|
467
|
+
|
468
|
+
renderTimeSelect(div, renderOptions);
|
469
|
+
}).blur(function() {
|
470
|
+
if (within){
|
471
|
+
if (div) element.focus();
|
472
|
+
return;
|
473
|
+
}
|
474
|
+
if (!div) return;
|
475
|
+
div.remove();
|
476
|
+
div = null;
|
477
|
+
});
|
478
|
+
});
|
479
|
+
},
|
480
|
+
|
481
|
+
$.fn.calendricalTimeRange = function(options)
|
482
|
+
{
|
483
|
+
if (this.length >= 2) {
|
484
|
+
$(this[0]).calendricalTime(options);
|
485
|
+
$(this[1]).calendricalTime($.extend({
|
486
|
+
startTime: $(this[0])
|
487
|
+
}, options));
|
488
|
+
}
|
489
|
+
return this;
|
490
|
+
};
|
491
|
+
|
492
|
+
$.fn.calendricalDateTimeRange = function(options)
|
493
|
+
{
|
494
|
+
if (this.length >= 4) {
|
495
|
+
$(this[0]).calendricalDate($.extend({
|
496
|
+
endDate: $(this[2])
|
497
|
+
}, options));
|
498
|
+
$(this[1]).calendricalTime(options);
|
499
|
+
$(this[2]).calendricalDate(options);
|
500
|
+
$(this[3]).calendricalTime($.extend({
|
501
|
+
startTime: $(this[1]),
|
502
|
+
startDate: $(this[0]),
|
503
|
+
endDate: $(this[2])
|
504
|
+
}, options));
|
505
|
+
}
|
506
|
+
return this;
|
507
|
+
};
|
508
|
+
})(jQuery);
|