@@ -14,28 +14,39 @@ var EntryEditor = function($form) {
1414 $form . find ( '.struct .hashint' ) . tooltip ( ) ;
1515
1616 /**
17- * Attach datepicker to date types
17+ * Attach datepicker to date types.
18+ * Only if browser does not support HTML5 date input.
1819 */
19- $form . find ( 'input.struct_date' ) . datepicker ( {
20- dateFormat : 'yy-mm-dd'
21- } ) ;
20+ var testelem = document . createElement ( 'input' ) ;
21+ testelem . setAttribute ( "type" , "date" ) ;
22+ if ( testelem . type === "text" ) {
23+ $form . find ( 'input.struct_date' ) . datepicker ( {
24+ dateFormat : 'yyyy-mm-dd' ,
25+ changeYear : true ,
26+ } ) ;
27+ }
2228
2329 /**
24- * Attach datepicker to datetype types, keeps time part
30+ * Attach datepicker to datetype types, keeps time part.
31+ * Only if browser does not support HTML5 datetime-local input.
2532 */
26- $form . find ( 'input.struct_datetime' ) . datepicker ( {
27- dateFormat : 'yy-mm-dd' ,
28- onSelect : function ( date , inst ) {
29- var $input = jQuery ( this ) ;
30- var both = inst . lastVal . split ( ' ' , 2 ) ;
31- if ( both . length == 2 ) {
32- date += ' ' + both [ 1 ] ;
33- } else {
34- date += ' 00:00:00' ;
33+ testelem . setAttribute ( "type" , "datetime-local" ) ;
34+ if ( testelem . type === "text" ) {
35+ $form . find ( 'input.struct_datetime' ) . datepicker ( {
36+ dateFormat : 'yyyy-mm-dd' ,
37+ changeYear : true ,
38+ onSelect : function ( date , inst ) {
39+ var $input = jQuery ( this ) ;
40+ var both = inst . lastVal . split ( ' ' , 2 ) ;
41+ if ( both . length == 2 ) {
42+ date += ' ' + both [ 1 ] ;
43+ } else {
44+ date += ' 00:00:00' ;
45+ }
46+ $input . val ( date ) ;
3547 }
36- $input . val ( date ) ;
37- }
38- } ) ;
48+ } ) ;
49+ }
3950
4051 /**
4152 * Attach image dialog to image types
0 commit comments