forked from stevebooks/jquery-datetime-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication.js
More file actions
35 lines (30 loc) · 912 Bytes
/
application.js
File metadata and controls
35 lines (30 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function isTouchDevice() {
return !!('ontouchstart' in window);
}
$(document).ready(function(){
if(!isTouchDevice()){
//Mouse powered calendar
$('.datetimepicker').datetimepicker({});
//Disable the user from manually entering values on the text field
$('.datetimepicker').bind('keydown',function(e){
$(this).attr('readonly', 'readonly');
//Extra fun for working with backspace
//we don't want the browser to go back in history if backspace is pressed
if(e.keyCode == 8){
e.preventDefault();
}
});
//Remove readonly on keyup, so the form doesn't look weird
$('.datetimepicker').bind('keyup',function(){
$(this).removeAttr('readonly');
});
}else{
//Touch powered calendar
$('.datetimepicker').scroller({
preset: 'datetime',
theme: 'android',
display: 'modal',
mode: 'scroller'
});
}
});