@@ -14,39 +14,32 @@ var EntryEditor = function($form) {
14
14
$form . find ( '.struct .hashint' ) . tooltip ( ) ;
15
15
16
16
/**
17
- * Attach datepicker to date types.
18
- * Only if browser does not support HTML5 date input.
17
+ * Attach datepicker to date types, if lacking HTML5 support.
19
18
*/
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
- }
19
+ var ftypetext = function ( ) { return this . type === 'text' ; } ;
20
+ $form . find ( 'input.struct_date' ) . filter ( ftypetext ) . datepicker ( {
21
+ dateFormat : 'yyyy-mm-dd' ,
22
+ changeYear : true ,
23
+ } ) ;
28
24
29
25
/**
30
26
* Attach datepicker to datetype types, keeps time part.
31
27
* Only if browser does not support HTML5 datetime-local input.
32
28
*/
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 ) ;
29
+ $form . find ( 'input.struct_datetime' ) . filter ( ftypetext ) . datepicker ( {
30
+ dateFormat : 'yyyy-mm-dd' ,
31
+ changeYear : true ,
32
+ onSelect : function ( date , inst ) {
33
+ var $input = jQuery ( this ) ;
34
+ var both = inst . lastVal . split ( ' ' , 2 ) ;
35
+ if ( both . length == 2 ) {
36
+ date += ' ' + both [ 1 ] ;
37
+ } else {
38
+ date += ' 00:00:00' ;
47
39
}
48
- } ) ;
49
- }
40
+ $input . val ( date ) ;
41
+ }
42
+ } ) ;
50
43
51
44
/**
52
45
* Attach image dialog to image types
0 commit comments