Merge "Use HTTPS instead of HTTP for interwiki"
[lhc/web/wiklou.git] / resources / src / mediawiki.widgets / mw.widgets.DateInputWidget.js
index ce9cf36..2265132 100644 (file)
@@ -89,7 +89,7 @@
         *     calendar uses relative positioning.
         */
        mw.widgets.DateInputWidget = function MWWDateInputWidget( config ) {
-               var placeholderDateFormat, mustBeAfter, mustBeBefore;
+               var placeholderDateFormat, mustBeAfter, mustBeBefore, $overlay;
 
                // Config initialization
                config = $.extend( {
                        .addClass( 'mw-widget-dateInputWidget' )
                        .append( this.$handle, this.textInput.$element, this.calendar.$element );
 
-               // config.overlay is the selector to be used for config.$overlay, specified from PHP
-               if ( config.overlay ) {
-                       config.$overlay = $( config.overlay );
-               }
+               $overlay = config.$overlay === true ? OO.ui.getDefaultOverlay() : config.$overlay;
 
-               if ( config.$overlay ) {
+               if ( $overlay ) {
                        this.calendar.setFloatableContainer( this.$element );
-                       config.$overlay.append( this.calendar.$element );
+                       $overlay.append( this.calendar.$element );
 
                        // The text input and calendar are not in DOM order, so fix up focus transitions.
                        this.textInput.$input.on( 'keydown', function ( e ) {
                        format = llll.replace( lll.replace( ll, '' ), '' );
 
                        if ( this.longDisplayFormat ) {
-                               format = format.replace( 'MMM', 'MMMM' ).replace( 'ddd', 'dddd' );
+                               // Replace MMM to MMMM and ddd to dddd but don't change MMMM and dddd
+                               format = format.replace( /MMMM?/, 'MMMM' ).replace( /dddd?/, 'dddd' );
                        }
 
                        return format;
         * @return {boolean} False to cancel the default event
         */
        mw.widgets.DateInputWidget.prototype.onCalendarClick = function ( e ) {
+               var targetClass = this.calendar.getPrecision() === 'month' ?
+                       'mw-widget-calendarWidget-month' :
+                       'mw-widget-calendarWidget-day';
                if (
                        !this.isDisabled() &&
                        e.which === 1 &&
-                       (
-                               $( e.target ).hasClass( 'mw-widget-calendarWidget-day' ) ||
-                               $( e.target ).hasClass( 'mw-widget-calendarWidget-month' )
-                       )
+                       $( e.target ).hasClass( targetClass )
                ) {
                        this.deactivate( true );
                        return false;