@@ -43,6 +43,14 @@ return $.widget( "ui.calendar", {
43
43
select : null
44
44
} ,
45
45
46
+ refreshRelatedOptions : {
47
+ eachDay : true ,
48
+ max : true ,
49
+ min : true ,
50
+ showWeek : true ,
51
+ value : true
52
+ } ,
53
+
46
54
_create : function ( ) {
47
55
this . id = this . element . uniqueId ( ) . attr ( "id" ) ;
48
56
this . labels = Globalize . translate ( "datepicker" ) ;
@@ -470,21 +478,21 @@ return $.widget( "ui.calendar", {
470
478
} ,
471
479
472
480
_select : function ( event , time ) {
473
- this . _setOption ( "value" , new Date ( time ) ) ;
481
+ this . valueAsDate ( new Date ( time ) ) ;
474
482
this . _trigger ( "select" , event ) ;
475
483
} ,
476
484
477
485
value : function ( value ) {
478
486
if ( arguments . length ) {
479
- this . _setOption ( "value" , Globalize . parseDate ( value , this . options . dateFormat ) ) ;
487
+ this . valueAsDate ( Globalize . parseDate ( value , this . options . dateFormat ) ) ;
480
488
} else {
481
489
return Globalize . format ( this . option ( "value" ) , this . options . dateFormat ) ;
482
490
}
483
491
} ,
484
492
485
493
valueAsDate : function ( value ) {
486
494
if ( arguments . length ) {
487
- this . _setOption ( "value" , value ) ;
495
+ this . option ( "value" , value ) ;
488
496
} else {
489
497
return this . options . value ;
490
498
}
@@ -519,20 +527,35 @@ return $.widget( "ui.calendar", {
519
527
. empty ( ) ;
520
528
} ,
521
529
530
+ _setOptions : function ( options ) {
531
+ var that = this ,
532
+ refresh = false ;
533
+
534
+ $ . each ( options , function ( key , value ) {
535
+ that . _setOption ( key , value ) ;
536
+
537
+ if ( key in that . refreshRelatedOptions ) {
538
+ refresh = true ;
539
+ }
540
+ } ) ;
541
+
542
+ if ( refresh ) {
543
+ this . refresh ( ) ;
544
+ }
545
+ } ,
546
+
522
547
_setOption : function ( key , value ) {
523
548
if ( key === "value" ) {
524
549
if ( this . _isValid ( value ) ) {
525
550
this . date . setTime ( value . getTime ( ) ) . select ( ) ;
526
551
this . _super ( key , value ) ;
527
- this . refresh ( ) ;
528
552
}
529
553
return ;
530
554
}
531
555
532
556
if ( key === "max" || key === "min" ) {
533
557
if ( $ . type ( value ) === "date" || value === null ) {
534
558
this . _super ( key , value ) ;
535
- this . refresh ( ) ;
536
559
}
537
560
return ;
538
561
}
@@ -551,16 +574,11 @@ return $.widget( "ui.calendar", {
551
574
552
575
if ( key === "eachDay" ) {
553
576
this . date . eachDay = value ;
554
- this . refresh ( ) ;
555
577
}
556
578
557
579
if ( key === "dateFormat" ) {
558
580
this . date . setFormat ( value ) ;
559
581
}
560
-
561
- if ( key === "showWeek" ) {
562
- this . refresh ( ) ;
563
- }
564
582
}
565
583
} ) ;
566
584
0 commit comments