@@ -43,6 +43,14 @@ return $.widget( "ui.calendar", {
4343 select : null
4444 } ,
4545
46+ refreshRelatedOptions : {
47+ eachDay : true ,
48+ max : true ,
49+ min : true ,
50+ showWeek : true ,
51+ value : true
52+ } ,
53+
4654 _create : function ( ) {
4755 this . id = this . element . uniqueId ( ) . attr ( "id" ) ;
4856 this . labels = Globalize . translate ( "datepicker" ) ;
@@ -470,21 +478,21 @@ return $.widget( "ui.calendar", {
470478 } ,
471479
472480 _select : function ( event , time ) {
473- this . _setOption ( "value" , new Date ( time ) ) ;
481+ this . valueAsDate ( new Date ( time ) ) ;
474482 this . _trigger ( "select" , event ) ;
475483 } ,
476484
477485 value : function ( value ) {
478486 if ( arguments . length ) {
479- this . _setOption ( "value" , Globalize . parseDate ( value , this . options . dateFormat ) ) ;
487+ this . valueAsDate ( Globalize . parseDate ( value , this . options . dateFormat ) ) ;
480488 } else {
481489 return Globalize . format ( this . option ( "value" ) , this . options . dateFormat ) ;
482490 }
483491 } ,
484492
485493 valueAsDate : function ( value ) {
486494 if ( arguments . length ) {
487- this . _setOption ( "value" , value ) ;
495+ this . option ( "value" , value ) ;
488496 } else {
489497 return this . options . value ;
490498 }
@@ -519,20 +527,35 @@ return $.widget( "ui.calendar", {
519527 . empty ( ) ;
520528 } ,
521529
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+
522547 _setOption : function ( key , value ) {
523548 if ( key === "value" ) {
524549 if ( this . _isValid ( value ) ) {
525550 this . date . setTime ( value . getTime ( ) ) . select ( ) ;
526551 this . _super ( key , value ) ;
527- this . refresh ( ) ;
528552 }
529553 return ;
530554 }
531555
532556 if ( key === "max" || key === "min" ) {
533557 if ( $ . type ( value ) === "date" || value === null ) {
534558 this . _super ( key , value ) ;
535- this . refresh ( ) ;
536559 }
537560 return ;
538561 }
@@ -551,16 +574,11 @@ return $.widget( "ui.calendar", {
551574
552575 if ( key === "eachDay" ) {
553576 this . date . eachDay = value ;
554- this . refresh ( ) ;
555577 }
556578
557579 if ( key === "dateFormat" ) {
558580 this . date . setFormat ( value ) ;
559581 }
560-
561- if ( key === "showWeek" ) {
562- this . refresh ( ) ;
563- }
564582 }
565583} ) ;
566584
0 commit comments