tjadmin 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tjadmin/version.rb +1 -1
- data/vendor/assets/font/DXI1ORHCpsQm3Vp6mXoaTXhCUOGz7vYGh680lGh-uXM.woff +0 -0
- data/vendor/assets/font/FontAwesome.otf +0 -0
- data/vendor/assets/font/cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff +0 -0
- data/vendor/assets/font/fontawesome-webfont.eot +0 -0
- data/vendor/assets/font/fontawesome-webfont.svg +399 -0
- data/vendor/assets/font/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/font/fontawesome-webfont.woff +0 -0
- data/vendor/assets/javascripts/tjadmin/ace-elements.js +866 -0
- data/vendor/assets/javascripts/tjadmin/ace-extra.js +374 -0
- data/vendor/assets/javascripts/tjadmin/ace.js +310 -0
- data/vendor/assets/javascripts/tjadmin/additional-methods.js +617 -0
- data/vendor/assets/javascripts/tjadmin/bootbox.js +660 -0
- data/vendor/assets/javascripts/tjadmin/bootstrap-colorpicker.js +540 -0
- data/vendor/assets/javascripts/tjadmin/bootstrap-tag.js +206 -0
- data/vendor/assets/javascripts/tjadmin/bootstrap-wysiwyg.js +206 -0
- data/vendor/assets/javascripts/tjadmin/bootstrap.js +2280 -0
- data/vendor/assets/javascripts/tjadmin/chosen.jquery.js +1166 -0
- data/vendor/assets/javascripts/tjadmin/date-time/bootstrap-datepicker.js +1016 -0
- data/vendor/assets/javascripts/tjadmin/date-time/bootstrap-timepicker.js +888 -0
- data/vendor/assets/javascripts/tjadmin/date-time/daterangepicker.js +854 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.bg.js +14 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.ca.js +14 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.cs.js +15 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.da.js +14 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.de.js +16 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.el.js +13 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.es.js +14 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.fi.js +14 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.fr.js +16 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.he.js +15 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.hr.js +13 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.hu.js +16 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.id.js +13 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.is.js +14 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.it.js +16 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.ja.js +15 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.kr.js +13 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.lt.js +16 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.lv.js +16 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.ms.js +14 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.nb.js +14 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.nl.js +14 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.pl.js +15 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.pt-BR.js +14 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.pt.js +14 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.ro.js +15 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.rs-latin.js +14 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.rs.js +14 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.ru.js +14 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.sk.js +15 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.sl.js +14 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.sv.js +14 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.sw.js +15 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.th.js +14 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.tr.js +15 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.uk.js +14 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.zh-CN.js +14 -0
- data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.zh-TW.js +13 -0
- data/vendor/assets/javascripts/tjadmin/date-time/moment.js +1400 -0
- data/vendor/assets/javascripts/tjadmin/excanvas.js +1428 -0
- data/vendor/assets/javascripts/tjadmin/flot/jquery.flot.js +3061 -0
- data/vendor/assets/javascripts/tjadmin/flot/jquery.flot.pie.js +817 -0
- data/vendor/assets/javascripts/tjadmin/flot/jquery.flot.resize.js +60 -0
- data/vendor/assets/javascripts/tjadmin/fuelux/data/fuelux.tree-sampledata.js +174 -0
- data/vendor/assets/javascripts/tjadmin/fuelux/fuelux.spinner.js +201 -0
- data/vendor/assets/javascripts/tjadmin/fuelux/fuelux.tree.js +173 -0
- data/vendor/assets/javascripts/tjadmin/fuelux/fuelux.wizard.js +172 -0
- data/vendor/assets/javascripts/tjadmin/fullcalendar.js +5973 -0
- data/vendor/assets/javascripts/tjadmin/jquery-1.10.2.js +9789 -0
- data/vendor/assets/javascripts/tjadmin/jquery-2.0.3.js +8829 -0
- data/vendor/assets/javascripts/tjadmin/jquery-ui-1.10.3.custom.js +5423 -0
- data/vendor/assets/javascripts/tjadmin/jquery.autosize.js +242 -0
- data/vendor/assets/javascripts/tjadmin/jquery.colorbox.js +1063 -0
- data/vendor/assets/javascripts/tjadmin/jquery.dataTables.js +12099 -0
- data/vendor/assets/javascripts/tjadmin/jquery.easy-pie-chart.js +200 -0
- data/vendor/assets/javascripts/tjadmin/jquery.gritter.js +418 -0
- data/vendor/assets/javascripts/tjadmin/jquery.hotkeys.js +113 -0
- data/vendor/assets/javascripts/tjadmin/jquery.inputlimiter.1.3.1.js +172 -0
- data/vendor/assets/javascripts/tjadmin/jquery.knob.js +656 -0
- data/vendor/assets/javascripts/tjadmin/jquery.maskedinput.js +338 -0
- data/vendor/assets/javascripts/tjadmin/jquery.mobile.custom.js +1081 -0
- data/vendor/assets/javascripts/tjadmin/jquery.slimscroll.js +448 -0
- data/vendor/assets/javascripts/tjadmin/jquery.sparkline.js +3054 -0
- data/vendor/assets/javascripts/tjadmin/jquery.ui.touch-punch.js +160 -0
- data/vendor/assets/javascripts/tjadmin/jquery.validate.js +1231 -0
- data/vendor/assets/javascripts/tjadmin/markdown/bootstrap-markdown.js +993 -0
- data/vendor/assets/javascripts/tjadmin/markdown/markdown.js +1616 -0
- data/vendor/assets/javascripts/tjadmin/markdown/to-markdown.js +184 -0
- data/vendor/assets/javascripts/tjadmin/select2.js +3168 -0
- data/vendor/assets/javascripts/tjadmin/spin.js +349 -0
- data/vendor/assets/javascripts/tjadmin/x-editable/ace-editable.js +368 -0
- data/vendor/assets/javascripts/tjadmin/x-editable/bootstrap-editable.js +6827 -0
- data/vendor/assets/javascripts/tjadmin.js +5 -0
- data/vendor/assets/stylesheets/tjadmin/ace-fonts.css.scss +13 -0
- data/vendor/assets/stylesheets/tjadmin/ace-ie.css +293 -0
- data/vendor/assets/stylesheets/tjadmin/ace-responsive.css +1113 -0
- data/vendor/assets/stylesheets/tjadmin/ace-skins.css +1301 -0
- data/vendor/assets/stylesheets/tjadmin/ace.css +14701 -0
- data/vendor/assets/stylesheets/tjadmin/bootstrap-responsive.css +1109 -0
- data/vendor/assets/stylesheets/tjadmin/bootstrap.css +6167 -0
- data/vendor/assets/stylesheets/tjadmin/chosen.css +430 -0
- data/vendor/assets/stylesheets/tjadmin/font-awesome-ie7.css +1203 -0
- data/vendor/assets/stylesheets/tjadmin/font-awesome.css +1479 -0
- data/vendor/assets/stylesheets/tjadmin/jquery-ui-1.10.3.custom.css +223 -0
- data/vendor/assets/stylesheets/tjadmin.css +9 -0
- metadata +106 -1
@@ -0,0 +1,854 @@
|
|
1
|
+
/**
|
2
|
+
* @version: 1.2
|
3
|
+
* @author: Dan Grossman http://www.dangrossman.info/
|
4
|
+
* @date: 2013-07-25
|
5
|
+
* @copyright: Copyright (c) 2012-2013 Dan Grossman. All rights reserved.
|
6
|
+
* @license: Licensed under Apache License v2.0. See http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
* @website: http://www.improvely.com/
|
8
|
+
*/
|
9
|
+
!function ($) {
|
10
|
+
|
11
|
+
var DateRangePicker = function (element, options, cb) {
|
12
|
+
var hasOptions = typeof options == 'object';
|
13
|
+
var localeObject;
|
14
|
+
|
15
|
+
//option defaults
|
16
|
+
|
17
|
+
this.startDate = moment().startOf('day');
|
18
|
+
this.endDate = moment().startOf('day');
|
19
|
+
this.minDate = false;
|
20
|
+
this.maxDate = false;
|
21
|
+
this.dateLimit = false;
|
22
|
+
|
23
|
+
this.showDropdowns = false;
|
24
|
+
this.showWeekNumbers = false;
|
25
|
+
this.timePicker = false;
|
26
|
+
this.timePickerIncrement = 30;
|
27
|
+
this.timePicker12Hour = true;
|
28
|
+
this.ranges = {};
|
29
|
+
this.opens = 'right';
|
30
|
+
|
31
|
+
this.buttonClasses = ['btn', 'btn-small'];
|
32
|
+
this.applyClass = 'btn-success';
|
33
|
+
this.cancelClass = 'btn-default';
|
34
|
+
|
35
|
+
this.format = 'MM/DD/YYYY';
|
36
|
+
this.separator = ' - ';
|
37
|
+
|
38
|
+
this.locale = {
|
39
|
+
applyLabel: 'Apply',
|
40
|
+
cancelLabel: 'Cancel',
|
41
|
+
fromLabel: 'From',
|
42
|
+
toLabel: 'To',
|
43
|
+
weekLabel: 'W',
|
44
|
+
customRangeLabel: 'Custom Range',
|
45
|
+
daysOfWeek: moment()._lang._weekdaysMin,
|
46
|
+
monthNames: moment()._lang._monthsShort,
|
47
|
+
firstDay: 0
|
48
|
+
};
|
49
|
+
|
50
|
+
this.cb = function () { };
|
51
|
+
|
52
|
+
//element that triggered the date range picker
|
53
|
+
this.element = $(element);
|
54
|
+
|
55
|
+
if (this.element.hasClass('pull-right'))
|
56
|
+
this.opens = 'left';
|
57
|
+
|
58
|
+
if (this.element.is('input')) {
|
59
|
+
this.element.on({
|
60
|
+
click: $.proxy(this.show, this),
|
61
|
+
focus: $.proxy(this.show, this)
|
62
|
+
});
|
63
|
+
} else {
|
64
|
+
this.element.on('click', $.proxy(this.show, this));
|
65
|
+
}
|
66
|
+
|
67
|
+
localeObject = this.locale;
|
68
|
+
|
69
|
+
if (hasOptions) {
|
70
|
+
if (typeof options.locale == 'object') {
|
71
|
+
$.each(localeObject, function (property, value) {
|
72
|
+
localeObject[property] = options.locale[property] || value;
|
73
|
+
});
|
74
|
+
}
|
75
|
+
|
76
|
+
if (options.applyClass) {
|
77
|
+
this.applyClass = options.applyClass;
|
78
|
+
}
|
79
|
+
|
80
|
+
if (options.cancelClass) {
|
81
|
+
this.cancelClass = options.cancelClass;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
var DRPTemplate = '<div class="daterangepicker dropdown-menu">' +
|
86
|
+
'<div class="calendar left"></div>' +
|
87
|
+
'<div class="calendar right"></div>' +
|
88
|
+
'<div class="ranges">' +
|
89
|
+
'<div class="range_inputs">' +
|
90
|
+
'<div class="daterangepicker_start_input" style="float: left">' +
|
91
|
+
'<label for="daterangepicker_start">' + this.locale.fromLabel + '</label>' +
|
92
|
+
'<input class="input-mini" type="text" name="daterangepicker_start" value="" disabled="disabled" />' +
|
93
|
+
'</div>' +
|
94
|
+
'<div class="daterangepicker_end_input" style="float: left; padding-left: 11px">' +
|
95
|
+
'<label for="daterangepicker_end">' + this.locale.toLabel + '</label>' +
|
96
|
+
'<input class="input-mini" type="text" name="daterangepicker_end" value="" disabled="disabled" />' +
|
97
|
+
'</div>' +
|
98
|
+
'<button class="' + this.applyClass + ' applyBtn" disabled="disabled">' + this.locale.applyLabel + '</button> ' +
|
99
|
+
'<button class="' + this.cancelClass + ' cancelBtn">' + this.locale.cancelLabel + '</button>' +
|
100
|
+
'</div>' +
|
101
|
+
'</div>' +
|
102
|
+
'</div>';
|
103
|
+
|
104
|
+
this.container = $(DRPTemplate).appendTo('body');
|
105
|
+
|
106
|
+
if (hasOptions) {
|
107
|
+
|
108
|
+
if (typeof options.format == 'string')
|
109
|
+
this.format = options.format;
|
110
|
+
|
111
|
+
if (typeof options.separator == 'string')
|
112
|
+
this.separator = options.separator;
|
113
|
+
|
114
|
+
if (typeof options.startDate == 'string')
|
115
|
+
this.startDate = moment(options.startDate, this.format);
|
116
|
+
|
117
|
+
if (typeof options.endDate == 'string')
|
118
|
+
this.endDate = moment(options.endDate, this.format);
|
119
|
+
|
120
|
+
if (typeof options.minDate == 'string')
|
121
|
+
this.minDate = moment(options.minDate, this.format);
|
122
|
+
|
123
|
+
if (typeof options.maxDate == 'string')
|
124
|
+
this.maxDate = moment(options.maxDate, this.format);
|
125
|
+
|
126
|
+
if (typeof options.startDate == 'object')
|
127
|
+
this.startDate = moment(options.startDate);
|
128
|
+
|
129
|
+
if (typeof options.endDate == 'object')
|
130
|
+
this.endDate = moment(options.endDate);
|
131
|
+
|
132
|
+
if (typeof options.minDate == 'object')
|
133
|
+
this.minDate = moment(options.minDate);
|
134
|
+
|
135
|
+
if (typeof options.maxDate == 'object')
|
136
|
+
this.maxDate = moment(options.maxDate);
|
137
|
+
|
138
|
+
if (typeof options.ranges == 'object') {
|
139
|
+
for (var range in options.ranges) {
|
140
|
+
|
141
|
+
var start = moment(options.ranges[range][0]);
|
142
|
+
var end = moment(options.ranges[range][1]);
|
143
|
+
|
144
|
+
// If we have a min/max date set, bound this range
|
145
|
+
// to it, but only if it would otherwise fall
|
146
|
+
// outside of the min/max.
|
147
|
+
if (this.minDate && start.isBefore(this.minDate))
|
148
|
+
start = moment(this.minDate);
|
149
|
+
|
150
|
+
if (this.maxDate && end.isAfter(this.maxDate))
|
151
|
+
end = moment(this.maxDate);
|
152
|
+
|
153
|
+
// If the end of the range is before the minimum (if min is set) OR
|
154
|
+
// the start of the range is after the max (also if set) don't display this
|
155
|
+
// range option.
|
156
|
+
if ((this.minDate && end.isBefore(this.minDate)) || (this.maxDate && start.isAfter(this.maxDate))) {
|
157
|
+
continue;
|
158
|
+
}
|
159
|
+
|
160
|
+
this.ranges[range] = [start, end];
|
161
|
+
}
|
162
|
+
|
163
|
+
var list = '<ul>';
|
164
|
+
for (var range in this.ranges) {
|
165
|
+
list += '<li>' + range + '</li>';
|
166
|
+
}
|
167
|
+
list += '<li>' + this.locale.customRangeLabel + '</li>';
|
168
|
+
list += '</ul>';
|
169
|
+
this.container.find('.ranges').prepend(list);
|
170
|
+
}
|
171
|
+
|
172
|
+
if (typeof options.dateLimit == 'object')
|
173
|
+
this.dateLimit = options.dateLimit;
|
174
|
+
|
175
|
+
// update day names order to firstDay
|
176
|
+
if (typeof options.locale == 'object') {
|
177
|
+
if (typeof options.locale.firstDay == 'number') {
|
178
|
+
this.locale.firstDay = options.locale.firstDay;
|
179
|
+
var iterator = options.locale.firstDay;
|
180
|
+
while (iterator > 0) {
|
181
|
+
this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift());
|
182
|
+
iterator--;
|
183
|
+
}
|
184
|
+
}
|
185
|
+
}
|
186
|
+
|
187
|
+
if (typeof options.opens == 'string')
|
188
|
+
this.opens = options.opens;
|
189
|
+
|
190
|
+
if (typeof options.showWeekNumbers == 'boolean') {
|
191
|
+
this.showWeekNumbers = options.showWeekNumbers;
|
192
|
+
}
|
193
|
+
|
194
|
+
if (typeof options.buttonClasses == 'string') {
|
195
|
+
this.buttonClasses = [options.buttonClasses];
|
196
|
+
}
|
197
|
+
|
198
|
+
if (typeof options.buttonClasses == 'object') {
|
199
|
+
this.buttonClasses = options.buttonClasses;
|
200
|
+
}
|
201
|
+
|
202
|
+
if (typeof options.showDropdowns == 'boolean') {
|
203
|
+
this.showDropdowns = options.showDropdowns;
|
204
|
+
}
|
205
|
+
|
206
|
+
if (typeof options.timePicker == 'boolean') {
|
207
|
+
this.timePicker = options.timePicker;
|
208
|
+
}
|
209
|
+
|
210
|
+
if (typeof options.timePickerIncrement == 'number') {
|
211
|
+
this.timePickerIncrement = options.timePickerIncrement;
|
212
|
+
}
|
213
|
+
|
214
|
+
if (typeof options.timePicker12Hour == 'boolean') {
|
215
|
+
this.timePicker12Hour = options.timePicker12Hour;
|
216
|
+
}
|
217
|
+
|
218
|
+
}
|
219
|
+
|
220
|
+
if (!this.timePicker) {
|
221
|
+
this.startDate = this.startDate.startOf('day');
|
222
|
+
this.endDate = this.endDate.startOf('day');
|
223
|
+
}
|
224
|
+
|
225
|
+
//apply CSS classes to buttons
|
226
|
+
var c = this.container;
|
227
|
+
$.each(this.buttonClasses, function (idx, val) {
|
228
|
+
c.find('button').addClass(val);
|
229
|
+
});
|
230
|
+
|
231
|
+
if (this.opens == 'right') {
|
232
|
+
//swap calendar positions
|
233
|
+
var left = this.container.find('.calendar.left');
|
234
|
+
var right = this.container.find('.calendar.right');
|
235
|
+
left.removeClass('left').addClass('right');
|
236
|
+
right.removeClass('right').addClass('left');
|
237
|
+
}
|
238
|
+
|
239
|
+
if (typeof options == 'undefined' || typeof options.ranges == 'undefined') {
|
240
|
+
this.container.find('.calendar').show();
|
241
|
+
this.move();
|
242
|
+
}
|
243
|
+
|
244
|
+
if (typeof cb == 'function')
|
245
|
+
this.cb = cb;
|
246
|
+
|
247
|
+
this.container.addClass('opens' + this.opens);
|
248
|
+
|
249
|
+
//try parse date if in text input
|
250
|
+
if (!hasOptions || (typeof options.startDate == 'undefined' && typeof options.endDate == 'undefined')) {
|
251
|
+
if ($(this.element).is('input[type=text]')) {
|
252
|
+
var val = $(this.element).val();
|
253
|
+
var split = val.split(this.separator);
|
254
|
+
var start, end;
|
255
|
+
if (split.length == 2) {
|
256
|
+
start = moment(split[0], this.format);
|
257
|
+
end = moment(split[1], this.format);
|
258
|
+
}
|
259
|
+
if (start != null && end != null) {
|
260
|
+
this.startDate = start;
|
261
|
+
this.endDate = end;
|
262
|
+
}
|
263
|
+
}
|
264
|
+
}
|
265
|
+
|
266
|
+
//state
|
267
|
+
this.oldStartDate = this.startDate;
|
268
|
+
this.oldEndDate = this.endDate;
|
269
|
+
|
270
|
+
this.leftCalendar = {
|
271
|
+
month: moment([this.startDate.year(), this.startDate.month(), 1, this.startDate.hour(), this.startDate.minute()]),
|
272
|
+
calendar: []
|
273
|
+
};
|
274
|
+
|
275
|
+
this.rightCalendar = {
|
276
|
+
month: moment([this.endDate.year(), this.endDate.month(), 1, this.endDate.hour(), this.endDate.minute()]),
|
277
|
+
calendar: []
|
278
|
+
};
|
279
|
+
|
280
|
+
//event listeners
|
281
|
+
this.container.on('mousedown', $.proxy(this.mousedown, this));
|
282
|
+
this.container.find('.calendar').on('click', '.prev', $.proxy(this.clickPrev, this));
|
283
|
+
this.container.find('.calendar').on('click', '.next', $.proxy(this.clickNext, this));
|
284
|
+
this.container.find('.ranges').on('click', 'button.applyBtn', $.proxy(this.clickApply, this));
|
285
|
+
this.container.find('.ranges').on('click', 'button.cancelBtn', $.proxy(this.clickCancel, this));
|
286
|
+
|
287
|
+
this.container.find('.calendar').on('click', 'td.available', $.proxy(this.clickDate, this));
|
288
|
+
this.container.find('.calendar').on('mouseenter', 'td.available', $.proxy(this.enterDate, this));
|
289
|
+
this.container.find('.calendar').on('mouseleave', 'td.available', $.proxy(this.updateView, this));
|
290
|
+
|
291
|
+
this.container.find('.ranges').on('click', 'li', $.proxy(this.clickRange, this));
|
292
|
+
this.container.find('.ranges').on('mouseenter', 'li', $.proxy(this.enterRange, this));
|
293
|
+
this.container.find('.ranges').on('mouseleave', 'li', $.proxy(this.updateView, this));
|
294
|
+
|
295
|
+
this.container.find('.calendar').on('change', 'select.yearselect', $.proxy(this.updateYear, this));
|
296
|
+
this.container.find('.calendar').on('change', 'select.monthselect', $.proxy(this.updateMonth, this));
|
297
|
+
|
298
|
+
this.container.find('.calendar').on('change', 'select.hourselect', $.proxy(this.updateTime, this));
|
299
|
+
this.container.find('.calendar').on('change', 'select.minuteselect', $.proxy(this.updateTime, this));
|
300
|
+
this.container.find('.calendar').on('change', 'select.ampmselect', $.proxy(this.updateTime, this));
|
301
|
+
|
302
|
+
this.element.on('keyup', $.proxy(this.updateFromControl, this));
|
303
|
+
|
304
|
+
this.updateView();
|
305
|
+
this.updateCalendars();
|
306
|
+
|
307
|
+
};
|
308
|
+
|
309
|
+
DateRangePicker.prototype = {
|
310
|
+
|
311
|
+
constructor: DateRangePicker,
|
312
|
+
|
313
|
+
mousedown: function (e) {
|
314
|
+
e.stopPropagation();
|
315
|
+
},
|
316
|
+
|
317
|
+
updateView: function () {
|
318
|
+
this.leftCalendar.month.month(this.startDate.month()).year(this.startDate.year());
|
319
|
+
this.rightCalendar.month.month(this.endDate.month()).year(this.endDate.year());
|
320
|
+
|
321
|
+
this.container.find('input[name=daterangepicker_start]').val(this.startDate.format(this.format));
|
322
|
+
this.container.find('input[name=daterangepicker_end]').val(this.endDate.format(this.format));
|
323
|
+
|
324
|
+
if (this.startDate.isSame(this.endDate) || this.startDate.isBefore(this.endDate)) {
|
325
|
+
this.container.find('button.applyBtn').removeAttr('disabled');
|
326
|
+
} else {
|
327
|
+
this.container.find('button.applyBtn').attr('disabled', 'disabled');
|
328
|
+
}
|
329
|
+
},
|
330
|
+
|
331
|
+
updateFromControl: function () {
|
332
|
+
if (!this.element.is('input')) return;
|
333
|
+
if (!this.element.val().length) return;
|
334
|
+
|
335
|
+
var dateString = this.element.val().split(this.separator);
|
336
|
+
var start = moment(dateString[0], this.format);
|
337
|
+
var end = moment(dateString[1], this.format);
|
338
|
+
|
339
|
+
if (start == null || end == null) return;
|
340
|
+
if (end.isBefore(start)) return;
|
341
|
+
|
342
|
+
this.startDate = start;
|
343
|
+
this.endDate = end;
|
344
|
+
|
345
|
+
this.updateView();
|
346
|
+
this.cb(this.startDate, this.endDate);
|
347
|
+
this.updateCalendars();
|
348
|
+
},
|
349
|
+
|
350
|
+
notify: function () {
|
351
|
+
this.updateView();
|
352
|
+
this.cb(this.startDate, this.endDate);
|
353
|
+
},
|
354
|
+
|
355
|
+
move: function () {
|
356
|
+
var minWidth = $(this.container).find('.ranges').outerWidth();
|
357
|
+
if ($(this.container).find('.calendar').is(':visible')) {
|
358
|
+
var padding = 24; // FIXME: this works for the default styling, but isn't flexible
|
359
|
+
minWidth += $(this.container).find('.calendar').outerWidth() * 2 + padding;
|
360
|
+
}
|
361
|
+
if (this.opens == 'left') {
|
362
|
+
this.container.css({
|
363
|
+
top: this.element.offset().top + this.element.outerHeight(),
|
364
|
+
right: $(window).width() - this.element.offset().left - this.element.outerWidth(),
|
365
|
+
left: 'auto',
|
366
|
+
'min-width': minWidth
|
367
|
+
});
|
368
|
+
if (this.container.offset().left < 0) {
|
369
|
+
this.container.css({
|
370
|
+
right: 'auto',
|
371
|
+
left: 9
|
372
|
+
});
|
373
|
+
}
|
374
|
+
} else {
|
375
|
+
this.container.css({
|
376
|
+
top: this.element.offset().top + this.element.outerHeight(),
|
377
|
+
left: this.element.offset().left,
|
378
|
+
right: 'auto',
|
379
|
+
'min-width': minWidth
|
380
|
+
});
|
381
|
+
if (this.container.offset().left + this.container.outerWidth() > $(window).width()) {
|
382
|
+
this.container.css({
|
383
|
+
left: 'auto',
|
384
|
+
right: 0
|
385
|
+
});
|
386
|
+
}
|
387
|
+
}
|
388
|
+
},
|
389
|
+
|
390
|
+
show: function (e) {
|
391
|
+
this.container.show();
|
392
|
+
this.move();
|
393
|
+
|
394
|
+
if (e) {
|
395
|
+
e.stopPropagation();
|
396
|
+
e.preventDefault();
|
397
|
+
}
|
398
|
+
|
399
|
+
this.oldStartDate = this.startDate;
|
400
|
+
this.oldEndDate = this.endDate;
|
401
|
+
|
402
|
+
$(document).on('mousedown', $.proxy(this.hide, this));
|
403
|
+
this.element.trigger('shown', {target: e.target, picker: this});
|
404
|
+
},
|
405
|
+
|
406
|
+
hide: function (e) {
|
407
|
+
this.container.hide();
|
408
|
+
|
409
|
+
if (!this.startDate.isSame(this.oldStartDate) || !this.endDate.isSame(this.oldEndDate))
|
410
|
+
this.notify();
|
411
|
+
|
412
|
+
$(document).off('mousedown', this.hide);
|
413
|
+
this.element.trigger('hidden', { picker: this });
|
414
|
+
},
|
415
|
+
|
416
|
+
enterRange: function (e) {
|
417
|
+
var label = e.target.innerHTML;
|
418
|
+
if (label == this.locale.customRangeLabel) {
|
419
|
+
this.updateView();
|
420
|
+
} else {
|
421
|
+
var dates = this.ranges[label];
|
422
|
+
this.container.find('input[name=daterangepicker_start]').val(dates[0].format(this.format));
|
423
|
+
this.container.find('input[name=daterangepicker_end]').val(dates[1].format(this.format));
|
424
|
+
}
|
425
|
+
},
|
426
|
+
|
427
|
+
clickRange: function (e) {
|
428
|
+
var label = e.target.innerHTML;
|
429
|
+
if (label == this.locale.customRangeLabel) {
|
430
|
+
this.container.find('.calendar').show();
|
431
|
+
this.move();
|
432
|
+
} else {
|
433
|
+
var dates = this.ranges[label];
|
434
|
+
|
435
|
+
this.startDate = dates[0];
|
436
|
+
this.endDate = dates[1];
|
437
|
+
|
438
|
+
if (!this.timePicker) {
|
439
|
+
this.startDate.startOf('day');
|
440
|
+
this.endDate.startOf('day');
|
441
|
+
}
|
442
|
+
|
443
|
+
this.leftCalendar.month.month(this.startDate.month()).year(this.startDate.year()).hour(this.startDate.hour()).minute(this.startDate.minute());
|
444
|
+
this.rightCalendar.month.month(this.endDate.month()).year(this.endDate.year()).hour(this.endDate.hour()).minute(this.endDate.minute());
|
445
|
+
this.updateCalendars();
|
446
|
+
|
447
|
+
if (this.element.is('input'))
|
448
|
+
this.element.val(this.startDate.format(this.format) + this.separator + this.endDate.format(this.format));
|
449
|
+
|
450
|
+
this.container.find('.calendar').hide();
|
451
|
+
this.hide();
|
452
|
+
}
|
453
|
+
},
|
454
|
+
|
455
|
+
clickPrev: function (e) {
|
456
|
+
var cal = $(e.target).parents('.calendar');
|
457
|
+
if (cal.hasClass('left')) {
|
458
|
+
this.leftCalendar.month.subtract('month', 1);
|
459
|
+
} else {
|
460
|
+
this.rightCalendar.month.subtract('month', 1);
|
461
|
+
}
|
462
|
+
this.updateCalendars();
|
463
|
+
},
|
464
|
+
|
465
|
+
clickNext: function (e) {
|
466
|
+
var cal = $(e.target).parents('.calendar');
|
467
|
+
if (cal.hasClass('left')) {
|
468
|
+
this.leftCalendar.month.add('month', 1);
|
469
|
+
} else {
|
470
|
+
this.rightCalendar.month.add('month', 1);
|
471
|
+
}
|
472
|
+
this.updateCalendars();
|
473
|
+
},
|
474
|
+
|
475
|
+
enterDate: function (e) {
|
476
|
+
|
477
|
+
var title = $(e.target).attr('data-title');
|
478
|
+
var row = title.substr(1, 1);
|
479
|
+
var col = title.substr(3, 1);
|
480
|
+
var cal = $(e.target).parents('.calendar');
|
481
|
+
|
482
|
+
if (cal.hasClass('left')) {
|
483
|
+
this.container.find('input[name=daterangepicker_start]').val(this.leftCalendar.calendar[row][col].format(this.format));
|
484
|
+
} else {
|
485
|
+
this.container.find('input[name=daterangepicker_end]').val(this.rightCalendar.calendar[row][col].format(this.format));
|
486
|
+
}
|
487
|
+
|
488
|
+
},
|
489
|
+
|
490
|
+
clickDate: function (e) {
|
491
|
+
var title = $(e.target).attr('data-title');
|
492
|
+
var row = title.substr(1, 1);
|
493
|
+
var col = title.substr(3, 1);
|
494
|
+
var cal = $(e.target).parents('.calendar');
|
495
|
+
|
496
|
+
if (cal.hasClass('left')) {
|
497
|
+
var startDate = this.leftCalendar.calendar[row][col];
|
498
|
+
var endDate = this.endDate;
|
499
|
+
if (typeof this.dateLimit == 'object') {
|
500
|
+
var maxDate = moment(startDate).add(this.dateLimit).startOf('day');
|
501
|
+
if (endDate.isAfter(maxDate)) {
|
502
|
+
endDate = maxDate;
|
503
|
+
}
|
504
|
+
}
|
505
|
+
} else {
|
506
|
+
var startDate = this.startDate;
|
507
|
+
var endDate = this.rightCalendar.calendar[row][col];
|
508
|
+
if (typeof this.dateLimit == 'object') {
|
509
|
+
var minDate = moment(endDate).subtract(this.dateLimit).startOf('day');
|
510
|
+
if (startDate.isBefore(minDate)) {
|
511
|
+
startDate = minDate;
|
512
|
+
}
|
513
|
+
}
|
514
|
+
}
|
515
|
+
|
516
|
+
cal.find('td').removeClass('active');
|
517
|
+
|
518
|
+
if (startDate.isSame(endDate) || startDate.isBefore(endDate)) {
|
519
|
+
$(e.target).addClass('active');
|
520
|
+
this.startDate = startDate;
|
521
|
+
this.endDate = endDate;
|
522
|
+
} else if (startDate.isAfter(endDate)) {
|
523
|
+
$(e.target).addClass('active');
|
524
|
+
this.startDate = startDate;
|
525
|
+
this.endDate = moment(startDate).add('day', 1).startOf('day');
|
526
|
+
}
|
527
|
+
|
528
|
+
this.leftCalendar.month.month(this.startDate.month()).year(this.startDate.year());
|
529
|
+
this.rightCalendar.month.month(this.endDate.month()).year(this.endDate.year());
|
530
|
+
this.updateCalendars();
|
531
|
+
},
|
532
|
+
|
533
|
+
clickApply: function (e) {
|
534
|
+
if (this.element.is('input'))
|
535
|
+
this.element.val(this.startDate.format(this.format) + this.separator + this.endDate.format(this.format));
|
536
|
+
this.hide();
|
537
|
+
},
|
538
|
+
|
539
|
+
clickCancel: function (e) {
|
540
|
+
this.startDate = this.oldStartDate;
|
541
|
+
this.endDate = this.oldEndDate;
|
542
|
+
this.updateView();
|
543
|
+
this.updateCalendars();
|
544
|
+
this.hide();
|
545
|
+
},
|
546
|
+
|
547
|
+
updateYear: function (e) {
|
548
|
+
var year = parseInt($(e.target).val());
|
549
|
+
var isLeft = $(e.target).closest('.calendar').hasClass('left');
|
550
|
+
|
551
|
+
if (isLeft) {
|
552
|
+
this.leftCalendar.month.month(this.startDate.month()).year(year);
|
553
|
+
} else {
|
554
|
+
this.rightCalendar.month.month(this.endDate.month()).year(year);
|
555
|
+
}
|
556
|
+
|
557
|
+
this.updateCalendars();
|
558
|
+
},
|
559
|
+
|
560
|
+
updateMonth: function (e) {
|
561
|
+
var month = parseInt($(e.target).val());
|
562
|
+
var isLeft = $(e.target).closest('.calendar').hasClass('left');
|
563
|
+
|
564
|
+
if (isLeft) {
|
565
|
+
this.leftCalendar.month.month(month).year(this.startDate.year());
|
566
|
+
} else {
|
567
|
+
this.rightCalendar.month.month(month).year(this.endDate.year());
|
568
|
+
}
|
569
|
+
this.updateCalendars();
|
570
|
+
},
|
571
|
+
|
572
|
+
updateTime: function(e) {
|
573
|
+
|
574
|
+
var isLeft = $(e.target).closest('.calendar').hasClass('left');
|
575
|
+
var cal = this.container.find('.calendar.left');
|
576
|
+
if (!isLeft)
|
577
|
+
cal = this.container.find('.calendar.right');
|
578
|
+
|
579
|
+
var hour = parseInt(cal.find('.hourselect').val());
|
580
|
+
var minute = parseInt(cal.find('.minuteselect').val());
|
581
|
+
|
582
|
+
if (this.timePicker12Hour) {
|
583
|
+
var ampm = cal.find('.ampmselect').val();
|
584
|
+
if (ampm == 'PM' && hour < 12)
|
585
|
+
hour += 12;
|
586
|
+
}
|
587
|
+
|
588
|
+
if (isLeft) {
|
589
|
+
var start = this.startDate;
|
590
|
+
start.hour(hour);
|
591
|
+
start.minute(minute);
|
592
|
+
this.startDate = start;
|
593
|
+
this.leftCalendar.month.hour(hour).minute(minute);
|
594
|
+
} else {
|
595
|
+
var end = this.endDate;
|
596
|
+
end.hour(hour);
|
597
|
+
end.minute(minute);
|
598
|
+
this.endDate = end;
|
599
|
+
this.rightCalendar.month.hour(hour).minute(minute);
|
600
|
+
}
|
601
|
+
|
602
|
+
this.updateCalendars();
|
603
|
+
|
604
|
+
},
|
605
|
+
|
606
|
+
updateCalendars: function () {
|
607
|
+
this.leftCalendar.calendar = this.buildCalendar(this.leftCalendar.month.month(), this.leftCalendar.month.year(), this.leftCalendar.month.hour(), this.leftCalendar.month.minute(), 'left');
|
608
|
+
this.rightCalendar.calendar = this.buildCalendar(this.rightCalendar.month.month(), this.rightCalendar.month.year(), this.rightCalendar.month.hour(), this.rightCalendar.month.minute(), 'right');
|
609
|
+
this.container.find('.calendar.left').html(this.renderCalendar(this.leftCalendar.calendar, this.startDate, this.minDate, this.maxDate));
|
610
|
+
this.container.find('.calendar.right').html(this.renderCalendar(this.rightCalendar.calendar, this.endDate, this.startDate, this.maxDate));
|
611
|
+
|
612
|
+
this.container.find('.ranges li').removeClass('active');
|
613
|
+
var customRange = true;
|
614
|
+
var i = 0;
|
615
|
+
for (var range in this.ranges) {
|
616
|
+
if (this.timePicker) {
|
617
|
+
if (this.startDate.isSame(this.ranges[range][0]) && this.endDate.isSame(this.ranges[range][1])) {
|
618
|
+
customRange = false;
|
619
|
+
this.container.find('.ranges li:eq(' + i + ')').addClass('active');
|
620
|
+
}
|
621
|
+
} else {
|
622
|
+
//ignore times when comparing dates if time picker is not enabled
|
623
|
+
if (this.startDate.format('YYYY-MM-DD') == this.ranges[range][0].format('YYYY-MM-DD') && this.endDate.format('YYYY-MM-DD') == this.ranges[range][1].format('YYYY-MM-DD')) {
|
624
|
+
customRange = false;
|
625
|
+
this.container.find('.ranges li:eq(' + i + ')').addClass('active');
|
626
|
+
}
|
627
|
+
}
|
628
|
+
i++;
|
629
|
+
}
|
630
|
+
if (customRange)
|
631
|
+
this.container.find('.ranges li:last').addClass('active');
|
632
|
+
},
|
633
|
+
|
634
|
+
buildCalendar: function (month, year, hour, minute, side) {
|
635
|
+
|
636
|
+
var firstDay = moment([year, month, 1]);
|
637
|
+
var lastMonth = moment(firstDay).subtract('month', 1).month();
|
638
|
+
var lastYear = moment(firstDay).subtract('month', 1).year();
|
639
|
+
|
640
|
+
var daysInLastMonth = moment([lastYear, lastMonth]).daysInMonth();
|
641
|
+
|
642
|
+
var dayOfWeek = firstDay.day();
|
643
|
+
|
644
|
+
//initialize a 6 rows x 7 columns array for the calendar
|
645
|
+
var calendar = [];
|
646
|
+
for (var i = 0; i < 6; i++) {
|
647
|
+
calendar[i] = [];
|
648
|
+
}
|
649
|
+
|
650
|
+
//populate the calendar with date objects
|
651
|
+
var startDay = daysInLastMonth - dayOfWeek + this.locale.firstDay + 1;
|
652
|
+
if (startDay > daysInLastMonth)
|
653
|
+
startDay -= 7;
|
654
|
+
|
655
|
+
if (dayOfWeek == this.locale.firstDay)
|
656
|
+
startDay = daysInLastMonth - 6;
|
657
|
+
|
658
|
+
var curDate = moment([lastYear, lastMonth, startDay, hour, minute]);
|
659
|
+
for (var i = 0, col = 0, row = 0; i < 42; i++, col++, curDate = moment(curDate).add('day', 1)) {
|
660
|
+
if (i > 0 && col % 7 == 0) {
|
661
|
+
col = 0;
|
662
|
+
row++;
|
663
|
+
}
|
664
|
+
calendar[row][col] = curDate;
|
665
|
+
}
|
666
|
+
|
667
|
+
return calendar;
|
668
|
+
|
669
|
+
},
|
670
|
+
|
671
|
+
renderDropdowns: function (selected, minDate, maxDate) {
|
672
|
+
var currentMonth = selected.month();
|
673
|
+
var monthHtml = '<select class="monthselect">';
|
674
|
+
var inMinYear = false;
|
675
|
+
var inMaxYear = false;
|
676
|
+
|
677
|
+
for (var m = 0; m < 12; m++) {
|
678
|
+
if ((!inMinYear || m >= minDate.month()) && (!inMaxYear || m <= maxDate.month())) {
|
679
|
+
monthHtml += "<option value='" + m + "'" +
|
680
|
+
(m === currentMonth ? " selected='selected'" : "") +
|
681
|
+
">" + this.locale.monthNames[m] + "</option>";
|
682
|
+
}
|
683
|
+
}
|
684
|
+
monthHtml += "</select>";
|
685
|
+
|
686
|
+
var currentYear = selected.year();
|
687
|
+
var maxYear = (maxDate && maxDate.year()) || (currentYear + 5);
|
688
|
+
var minYear = (minDate && minDate.year()) || (currentYear - 50);
|
689
|
+
var yearHtml = '<select class="yearselect">'
|
690
|
+
|
691
|
+
for (var y = minYear; y <= maxYear; y++) {
|
692
|
+
yearHtml += '<option value="' + y + '"' +
|
693
|
+
(y === currentYear ? ' selected="selected"' : '') +
|
694
|
+
'>' + y + '</option>';
|
695
|
+
}
|
696
|
+
|
697
|
+
yearHtml += '</select>';
|
698
|
+
|
699
|
+
return monthHtml + yearHtml;
|
700
|
+
},
|
701
|
+
|
702
|
+
renderCalendar: function (calendar, selected, minDate, maxDate) {
|
703
|
+
|
704
|
+
var html = '<div class="calendar-date">';
|
705
|
+
html += '<table class="table-condensed">';
|
706
|
+
html += '<thead>';
|
707
|
+
html += '<tr>';
|
708
|
+
|
709
|
+
// add empty cell for week number
|
710
|
+
if (this.showWeekNumbers)
|
711
|
+
html += '<th></th>';
|
712
|
+
|
713
|
+
if (!minDate || minDate.isBefore(calendar[1][1])) {
|
714
|
+
html += '<th class="prev available"><i class="icon-arrow-left"></i></th>';
|
715
|
+
} else {
|
716
|
+
html += '<th></th>';
|
717
|
+
}
|
718
|
+
|
719
|
+
var dateHtml = this.locale.monthNames[calendar[1][1].month()] + calendar[1][1].format(" YYYY");
|
720
|
+
|
721
|
+
if (this.showDropdowns) {
|
722
|
+
dateHtml = this.renderDropdowns(calendar[1][1], minDate, maxDate);
|
723
|
+
}
|
724
|
+
|
725
|
+
html += '<th colspan="5" style="width: auto">' + dateHtml + '</th>';
|
726
|
+
if (!maxDate || maxDate.isAfter(calendar[1][1])) {
|
727
|
+
html += '<th class="next available"><i class="icon-arrow-right"></i></th>';
|
728
|
+
} else {
|
729
|
+
html += '<th></th>';
|
730
|
+
}
|
731
|
+
|
732
|
+
html += '</tr>';
|
733
|
+
html += '<tr>';
|
734
|
+
|
735
|
+
// add week number label
|
736
|
+
if (this.showWeekNumbers)
|
737
|
+
html += '<th class="week">' + this.locale.weekLabel + '</th>';
|
738
|
+
|
739
|
+
$.each(this.locale.daysOfWeek, function (index, dayOfWeek) {
|
740
|
+
html += '<th>' + dayOfWeek + '</th>';
|
741
|
+
});
|
742
|
+
|
743
|
+
html += '</tr>';
|
744
|
+
html += '</thead>';
|
745
|
+
html += '<tbody>';
|
746
|
+
|
747
|
+
for (var row = 0; row < 6; row++) {
|
748
|
+
html += '<tr>';
|
749
|
+
|
750
|
+
// add week number
|
751
|
+
if (this.showWeekNumbers)
|
752
|
+
html += '<td class="week">' + calendar[row][0].week() + '</td>';
|
753
|
+
|
754
|
+
for (var col = 0; col < 7; col++) {
|
755
|
+
var cname = 'available ';
|
756
|
+
cname += (calendar[row][col].month() == calendar[1][1].month()) ? '' : 'off';
|
757
|
+
|
758
|
+
if ((minDate && calendar[row][col].isBefore(minDate)) || (maxDate && calendar[row][col].isAfter(maxDate))) {
|
759
|
+
cname = ' off disabled ';
|
760
|
+
} else if (calendar[row][col].format('YYYY-MM-DD') == selected.format('YYYY-MM-DD')) {
|
761
|
+
cname += ' active ';
|
762
|
+
if (calendar[row][col].format('YYYY-MM-DD') == this.startDate.format('YYYY-MM-DD')) {
|
763
|
+
cname += ' start-date ';
|
764
|
+
}
|
765
|
+
if (calendar[row][col].format('YYYY-MM-DD') == this.endDate.format('YYYY-MM-DD')) {
|
766
|
+
cname += ' end-date ';
|
767
|
+
}
|
768
|
+
} else if (calendar[row][col] >= this.startDate && calendar[row][col] <= this.endDate) {
|
769
|
+
cname += ' in-range ';
|
770
|
+
if (calendar[row][col].isSame(this.startDate)) { cname += ' start-date '; }
|
771
|
+
if (calendar[row][col].isSame(this.endDate)) { cname += ' end-date '; }
|
772
|
+
}
|
773
|
+
|
774
|
+
var title = 'r' + row + 'c' + col;
|
775
|
+
html += '<td class="' + cname.replace(/\s+/g, ' ').replace(/^\s?(.*?)\s?$/, '$1') + '" data-title="' + title + '">' + calendar[row][col].date() + '</td>';
|
776
|
+
}
|
777
|
+
html += '</tr>';
|
778
|
+
}
|
779
|
+
|
780
|
+
html += '</tbody>';
|
781
|
+
html += '</table>';
|
782
|
+
html += '</div>';
|
783
|
+
|
784
|
+
if (this.timePicker) {
|
785
|
+
|
786
|
+
html += '<div class="calendar-time">';
|
787
|
+
html += '<select class="hourselect">';
|
788
|
+
var start = 0;
|
789
|
+
var end = 23;
|
790
|
+
var selected_hour = selected.hour();
|
791
|
+
if (this.timePicker12Hour) {
|
792
|
+
start = 1;
|
793
|
+
end = 12;
|
794
|
+
if (selected_hour >= 12)
|
795
|
+
selected_hour -= 12;
|
796
|
+
if (selected_hour == 0)
|
797
|
+
selected_hour = 12;
|
798
|
+
}
|
799
|
+
|
800
|
+
for (var i = start; i <= end; i++) {
|
801
|
+
if (i == selected_hour) {
|
802
|
+
html += '<option value="' + i + '" selected="selected">' + i + '</option>';
|
803
|
+
} else {
|
804
|
+
html += '<option value="' + i + '">' + i + '</option>';
|
805
|
+
}
|
806
|
+
}
|
807
|
+
|
808
|
+
html += '</select> : ';
|
809
|
+
|
810
|
+
html += '<select class="minuteselect">';
|
811
|
+
|
812
|
+
for (var i = 0; i < 60; i += this.timePickerIncrement) {
|
813
|
+
var num = i;
|
814
|
+
if (num < 10)
|
815
|
+
num = '0' + num;
|
816
|
+
if (i == selected.minute()) {
|
817
|
+
html += '<option value="' + i + '" selected="selected">' + num + '</option>';
|
818
|
+
} else {
|
819
|
+
html += '<option value="' + i + '">' + num + '</option>';
|
820
|
+
}
|
821
|
+
}
|
822
|
+
|
823
|
+
html += '</select> ';
|
824
|
+
|
825
|
+
if (this.timePicker12Hour) {
|
826
|
+
html += '<select class="ampmselect">';
|
827
|
+
if (selected.hour() >= 12) {
|
828
|
+
html += '<option value="AM">AM</option><option value="PM" selected="selected">PM</option>';
|
829
|
+
} else {
|
830
|
+
html += '<option value="AM" selected="selected">AM</option><option value="PM">PM</option>';
|
831
|
+
}
|
832
|
+
html += '</select>';
|
833
|
+
}
|
834
|
+
|
835
|
+
html += '</div>';
|
836
|
+
|
837
|
+
}
|
838
|
+
|
839
|
+
return html;
|
840
|
+
|
841
|
+
}
|
842
|
+
|
843
|
+
};
|
844
|
+
|
845
|
+
$.fn.daterangepicker = function (options, cb) {
|
846
|
+
this.each(function () {
|
847
|
+
var el = $(this);
|
848
|
+
if (!el.data('daterangepicker'))
|
849
|
+
el.data('daterangepicker', new DateRangePicker(el, options, cb));
|
850
|
+
});
|
851
|
+
return this;
|
852
|
+
};
|
853
|
+
|
854
|
+
}(window.jQuery);
|