| 776 |
lars |
1 |
var ComponentsDateTimePickers = function () {
|
|
|
2 |
|
|
|
3 |
var handleDatePickers = function () {
|
|
|
4 |
|
|
|
5 |
if (jQuery().datepicker) {
|
|
|
6 |
$('.date-picker').datepicker({
|
|
|
7 |
rtl: App.isRTL(),
|
|
|
8 |
orientation: "left",
|
|
|
9 |
autoclose: true
|
|
|
10 |
});
|
|
|
11 |
//$('body').removeClass("modal-open"); // fix bug when inline picker is used in modal
|
|
|
12 |
}
|
|
|
13 |
|
|
|
14 |
/* Workaround to restrict daterange past date select: http://stackoverflow.com/questions/11933173/how-to-restrict-the-selectable-date-ranges-in-bootstrap-datepicker */
|
|
|
15 |
|
|
|
16 |
// Workaround to fix datepicker position on window scroll
|
|
|
17 |
$( document ).scroll(function(){
|
|
|
18 |
$('#form_modal2 .date-picker').datepicker('place'); //#modal is the id of the modal
|
|
|
19 |
});
|
|
|
20 |
}
|
|
|
21 |
|
|
|
22 |
var handleTimePickers = function () {
|
|
|
23 |
|
|
|
24 |
if (jQuery().timepicker) {
|
|
|
25 |
$('.timepicker-default').timepicker({
|
|
|
26 |
autoclose: true,
|
|
|
27 |
showSeconds: true,
|
|
|
28 |
minuteStep: 1
|
|
|
29 |
});
|
|
|
30 |
|
|
|
31 |
$('.timepicker-no-seconds').timepicker({
|
|
|
32 |
autoclose: true,
|
|
|
33 |
minuteStep: 5
|
|
|
34 |
});
|
|
|
35 |
|
|
|
36 |
$('.timepicker-24').timepicker({
|
|
|
37 |
autoclose: true,
|
|
|
38 |
minuteStep: 5,
|
|
|
39 |
showSeconds: false,
|
|
|
40 |
showMeridian: false
|
|
|
41 |
});
|
|
|
42 |
|
|
|
43 |
// handle input group button click
|
|
|
44 |
$('.timepicker').parent('.input-group').on('click', '.input-group-btn', function(e){
|
|
|
45 |
e.preventDefault();
|
|
|
46 |
$(this).parent('.input-group').find('.timepicker').timepicker('showWidget');
|
|
|
47 |
});
|
|
|
48 |
|
|
|
49 |
// Workaround to fix timepicker position on window scroll
|
|
|
50 |
$( document ).scroll(function(){
|
|
|
51 |
$('#form_modal4 .timepicker-default, #form_modal4 .timepicker-no-seconds, #form_modal4 .timepicker-24').timepicker('place'); //#modal is the id of the modal
|
|
|
52 |
});
|
|
|
53 |
}
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
var handleDateRangePickers = function () {
|
|
|
57 |
if (!jQuery().daterangepicker) {
|
|
|
58 |
return;
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
$('#defaultrange').daterangepicker({
|
|
|
62 |
opens: (App.isRTL() ? 'left' : 'right'),
|
|
|
63 |
format: 'MM/DD/YYYY',
|
|
|
64 |
separator: ' to ',
|
|
|
65 |
startDate: moment().subtract('days', 29),
|
|
|
66 |
endDate: moment(),
|
|
|
67 |
ranges: {
|
|
|
68 |
'Today': [moment(), moment()],
|
|
|
69 |
'Yesterday': [moment().subtract('days', 1), moment().subtract('days', 1)],
|
|
|
70 |
'Last 7 Days': [moment().subtract('days', 6), moment()],
|
|
|
71 |
'Last 30 Days': [moment().subtract('days', 29), moment()],
|
|
|
72 |
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
|
|
73 |
'Last Month': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')]
|
|
|
74 |
},
|
|
|
75 |
minDate: '01/01/2012',
|
|
|
76 |
maxDate: '12/31/2018',
|
|
|
77 |
},
|
|
|
78 |
function (start, end) {
|
|
|
79 |
$('#defaultrange input').val(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
|
|
|
80 |
}
|
|
|
81 |
);
|
|
|
82 |
|
|
|
83 |
$('#defaultrange_modal').daterangepicker({
|
|
|
84 |
opens: (App.isRTL() ? 'left' : 'right'),
|
|
|
85 |
format: 'MM/DD/YYYY',
|
|
|
86 |
separator: ' to ',
|
|
|
87 |
startDate: moment().subtract('days', 29),
|
|
|
88 |
endDate: moment(),
|
|
|
89 |
minDate: '01/01/2012',
|
|
|
90 |
maxDate: '12/31/2018',
|
|
|
91 |
},
|
|
|
92 |
function (start, end) {
|
|
|
93 |
$('#defaultrange_modal input').val(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
|
|
|
94 |
}
|
|
|
95 |
);
|
|
|
96 |
|
|
|
97 |
// this is very important fix when daterangepicker is used in modal. in modal when daterange picker is opened and mouse clicked anywhere bootstrap modal removes the modal-open class from the body element.
|
|
|
98 |
// so the below code will fix this issue.
|
|
|
99 |
$('#defaultrange_modal').on('click', function(){
|
|
|
100 |
if ($('#daterangepicker_modal').is(":visible") && $('body').hasClass("modal-open") == false) {
|
|
|
101 |
$('body').addClass("modal-open");
|
|
|
102 |
}
|
|
|
103 |
});
|
|
|
104 |
|
|
|
105 |
$('#reportrange').daterangepicker({
|
|
|
106 |
opens: (App.isRTL() ? 'left' : 'right'),
|
|
|
107 |
startDate: moment().subtract('days', 29),
|
|
|
108 |
endDate: moment(),
|
|
|
109 |
//minDate: '01/01/2012',
|
|
|
110 |
//maxDate: '12/31/2014',
|
|
|
111 |
dateLimit: {
|
|
|
112 |
days: 60
|
|
|
113 |
},
|
|
|
114 |
showDropdowns: true,
|
|
|
115 |
showWeekNumbers: true,
|
|
|
116 |
timePicker: false,
|
|
|
117 |
timePickerIncrement: 1,
|
|
|
118 |
timePicker12Hour: true,
|
|
|
119 |
ranges: {
|
|
|
120 |
'Today': [moment(), moment()],
|
|
|
121 |
'Yesterday': [moment().subtract('days', 1), moment().subtract('days', 1)],
|
|
|
122 |
'Last 7 Days': [moment().subtract('days', 6), moment()],
|
|
|
123 |
'Last 30 Days': [moment().subtract('days', 29), moment()],
|
|
|
124 |
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
|
|
125 |
'Last Month': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')]
|
|
|
126 |
},
|
|
|
127 |
buttonClasses: ['btn'],
|
|
|
128 |
applyClass: 'green',
|
|
|
129 |
cancelClass: 'default',
|
|
|
130 |
format: 'MM/DD/YYYY',
|
|
|
131 |
separator: ' to ',
|
|
|
132 |
locale: {
|
|
|
133 |
applyLabel: 'Apply',
|
|
|
134 |
fromLabel: 'From',
|
|
|
135 |
toLabel: 'To',
|
|
|
136 |
customRangeLabel: 'Custom Range',
|
|
|
137 |
daysOfWeek: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
|
|
|
138 |
monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
|
|
139 |
firstDay: 1
|
|
|
140 |
}
|
|
|
141 |
},
|
|
|
142 |
function (start, end) {
|
|
|
143 |
$('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
|
|
|
144 |
}
|
|
|
145 |
);
|
|
|
146 |
//Set the initial state of the picker label
|
|
|
147 |
$('#reportrange span').html(moment().subtract('days', 29).format('MMMM D, YYYY') + ' - ' + moment().format('MMMM D, YYYY'));
|
|
|
148 |
}
|
|
|
149 |
|
|
|
150 |
var handleDatetimePicker = function () {
|
|
|
151 |
|
|
|
152 |
if (!jQuery().datetimepicker) {
|
|
|
153 |
return;
|
|
|
154 |
}
|
|
|
155 |
|
|
|
156 |
$(".form_datetime").datetimepicker({
|
|
|
157 |
autoclose: true,
|
|
|
158 |
isRTL: App.isRTL(),
|
|
|
159 |
format: "dd MM yyyy - hh:ii",
|
|
|
160 |
pickerPosition: (App.isRTL() ? "bottom-right" : "bottom-left")
|
|
|
161 |
});
|
|
|
162 |
|
|
|
163 |
$(".form_advance_datetime").datetimepicker({
|
|
|
164 |
isRTL: App.isRTL(),
|
|
|
165 |
format: "dd MM yyyy - hh:ii",
|
|
|
166 |
autoclose: true,
|
|
|
167 |
todayBtn: true,
|
|
|
168 |
startDate: "2013-02-14 10:00",
|
|
|
169 |
pickerPosition: (App.isRTL() ? "bottom-right" : "bottom-left"),
|
|
|
170 |
minuteStep: 10
|
|
|
171 |
});
|
|
|
172 |
|
|
|
173 |
$(".form_meridian_datetime").datetimepicker({
|
|
|
174 |
isRTL: App.isRTL(),
|
|
|
175 |
format: "dd MM yyyy - HH:ii P",
|
|
|
176 |
showMeridian: true,
|
|
|
177 |
autoclose: true,
|
|
|
178 |
pickerPosition: (App.isRTL() ? "bottom-right" : "bottom-left"),
|
|
|
179 |
todayBtn: true
|
|
|
180 |
});
|
|
|
181 |
|
|
|
182 |
$('body').removeClass("modal-open"); // fix bug when inline picker is used in modal
|
|
|
183 |
|
|
|
184 |
// Workaround to fix datetimepicker position on window scroll
|
|
|
185 |
$( document ).scroll(function(){
|
|
|
186 |
$('#form_modal1 .form_datetime, #form_modal1 .form_advance_datetime, #form_modal1 .form_meridian_datetime').datetimepicker('place'); //#modal is the id of the modal
|
|
|
187 |
});
|
|
|
188 |
}
|
|
|
189 |
|
|
|
190 |
var handleClockfaceTimePickers = function () {
|
|
|
191 |
|
|
|
192 |
if (!jQuery().clockface) {
|
|
|
193 |
return;
|
|
|
194 |
}
|
|
|
195 |
|
|
|
196 |
$('.clockface_1').clockface();
|
|
|
197 |
|
|
|
198 |
$('#clockface_2').clockface({
|
|
|
199 |
format: 'HH:mm',
|
|
|
200 |
trigger: 'manual'
|
|
|
201 |
});
|
|
|
202 |
|
|
|
203 |
$('#clockface_2_toggle').click(function (e) {
|
|
|
204 |
e.stopPropagation();
|
|
|
205 |
$('#clockface_2').clockface('toggle');
|
|
|
206 |
});
|
|
|
207 |
|
|
|
208 |
$('#clockface_2_modal').clockface({
|
|
|
209 |
format: 'HH:mm',
|
|
|
210 |
trigger: 'manual'
|
|
|
211 |
});
|
|
|
212 |
|
|
|
213 |
$('#clockface_2_modal_toggle').click(function (e) {
|
|
|
214 |
e.stopPropagation();
|
|
|
215 |
$('#clockface_2_modal').clockface('toggle');
|
|
|
216 |
});
|
|
|
217 |
|
|
|
218 |
$('.clockface_3').clockface({
|
|
|
219 |
format: 'H:mm'
|
|
|
220 |
}).clockface('show', '14:30');
|
|
|
221 |
|
|
|
222 |
// Workaround to fix clockface position on window scroll
|
|
|
223 |
$( document ).scroll(function(){
|
|
|
224 |
$('#form_modal5 .clockface_1, #form_modal5 #clockface_2_modal').clockface('place'); //#modal is the id of the modal
|
|
|
225 |
});
|
|
|
226 |
}
|
|
|
227 |
|
|
|
228 |
return {
|
|
|
229 |
//main function to initiate the module
|
|
|
230 |
init: function () {
|
|
|
231 |
handleDatePickers();
|
|
|
232 |
handleTimePickers();
|
|
|
233 |
handleDatetimePicker();
|
|
|
234 |
handleDateRangePickers();
|
|
|
235 |
handleClockfaceTimePickers();
|
|
|
236 |
}
|
|
|
237 |
};
|
|
|
238 |
|
|
|
239 |
}();
|
|
|
240 |
|
|
|
241 |
if (App.isAngularJsApp() === false) {
|
|
|
242 |
jQuery(document).ready(function() {
|
|
|
243 |
ComponentsDateTimePickers.init();
|
|
|
244 |
});
|
|
|
245 |
}
|