mw.widgets.DateInputWidget: Ensure newly opened calendar shows current selection
authorBartosz Dziewoński <matma.rex@gmail.com>
Wed, 16 Sep 2015 16:45:22 +0000 (18:45 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Wed, 16 Sep 2015 17:48:59 +0000 (19:48 +0200)
CalendarWidget's #resetUI method was previously unused, it was clearly
implemented for this purpose.

Change-Id: I865a289b331d6163fb56f9e0ec3918cfd2b91343

resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js
resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js

index d519c0d..19dfc9a 100644 (file)
         * Reset the user interface of this widget to reflect selected date.
         */
        mw.widgets.CalendarWidget.prototype.resetUI = function () {
         * Reset the user interface of this widget to reflect selected date.
         */
        mw.widgets.CalendarWidget.prototype.resetUI = function () {
-               this.moment = moment( this.getDate(), this.getDateFormat() );
+               this.moment = this.getDate() !== null ? moment( this.getDate(), this.getDateFormat() ) : moment();
                this.displayLayer = this.getDisplayLayers()[ 0 ];
                this.updateUI();
        };
                this.displayLayer = this.getDisplayLayers()[ 0 ];
                this.updateUI();
        };
index b478c4a..657d9c5 100644 (file)
         * @private
         */
        mw.widgets.DateInputWidget.prototype.activate = function () {
         * @private
         */
        mw.widgets.DateInputWidget.prototype.activate = function () {
+               this.calendar.resetUI();
                this.$element.addClass( 'mw-widget-dateInputWidget-active' );
                this.handle.toggle( false );
                this.textInput.toggle( true );
                this.$element.addClass( 'mw-widget-dateInputWidget-active' );
                this.handle.toggle( false );
                this.textInput.toggle( true );