Bartosz Dziewoński has uploaded a new change for review.
https://gerrit.wikimedia.org/r/228296
Change subject: [WIP] Use mw.widgets.DateInputWidget
......................................................................
[WIP] Use mw.widgets.DateInputWidget
TODO Copying
TODO Validation?
TODO Allow arbitrary values
Bug: T97426
Change-Id: Ia7bb737bc11b0af3659552fa75d11e6663e2812e
---
M UploadWizardHooks.php
D resources/images/calendar.gif
M resources/mw.UploadWizardDetails.js
M resources/uploadWizard.css
4 files changed, 12 insertions(+), 33 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard
refs/changes/96/228296/1
diff --git a/UploadWizardHooks.php b/UploadWizardHooks.php
index a3bf594..aa7e64e 100644
--- a/UploadWizardHooks.php
+++ b/UploadWizardHooks.php
@@ -20,7 +20,6 @@
'jquery.client',
'jquery.ui.core',
'jquery.ui.dialog',
- 'jquery.ui.datepicker',
'jquery.ui.progressbar',
'jquery.spinner',
'jquery.ui.selectable',
@@ -58,6 +57,7 @@
'oojs',
'oojs-ui',
+ 'mediawiki.widgets',
),
'scripts' => array(
// jquery interface helpers
diff --git a/resources/images/calendar.gif b/resources/images/calendar.gif
deleted file mode 100644
index 2587c6f..0000000
--- a/resources/images/calendar.gif
+++ /dev/null
Binary files differ
diff --git a/resources/mw.UploadWizardDetails.js
b/resources/mw.UploadWizardDetails.js
index a1131f1..9c08ba2 100644
--- a/resources/mw.UploadWizardDetails.js
+++ b/resources/mw.UploadWizardDetails.js
@@ -145,14 +145,17 @@
dateErrorDiv = $('<div
class="mwe-upwiz-details-input-error"><label class="mwe-validator-error" for="'
+ dateInputId + '" generated="true"/></div>');
- // This field has $.datepicker applied to it later.
- this.dateInput = this.makeTextInput( dateInputId, 'date', 20 );
+ this.dateInputWidget = new mw.widgets.DateInputWidget( {
+ classes: [ 'mwe-date' ], // erk
+ id: dateInputId, // necessary?
+ name: dateInputId // necessary?
+ } );
dateInputDiv = $( '<div
class="mwe-upwiz-details-fieldname-input ui-helper-clearfix"></div>' )
.append(
dateErrorDiv,
$( '<div
class="mwe-upwiz-details-fieldname"></div>' ).text( mw.message(
'mwe-upwiz-date-created' ).text() ).requiredFieldLabel().addHint( 'date' ),
- $( '<div
class="mwe-upwiz-details-input"></div>' ).append( this.dateInput ) );
+ $( '<div
class="mwe-upwiz-details-input"></div>' ).append( this.dateInputWidget.$element
) );
moreDetailsCtrlDiv = $( '<div
class="mwe-upwiz-details-more-options"></div>' );
@@ -290,7 +293,8 @@
);
this.$form.validate();
- this.$form.find( '.mwe-date' ).rules( 'add', {
+ // FIXME Shouldn't abuse jQuery
+ this.dateInputWidget.$input.rules( 'add', {
required: true,
messages: {
required: mw.message( 'mwe-upwiz-error-blank'
).escaped()
@@ -315,16 +319,6 @@
}
} );
} );
- this.$form.find( '.mwe-date' )
- .datepicker( {
- dateFormat: 'yy-mm-dd',
- constrainInput: false,
- showOn: 'focus',
- changeMonth: true,
- changeYear: true,
- showAnim: 'slideDown',
- showButtonPanel: true
- } );
this.$latitudeInput.rules( 'add', {
min: -90,
@@ -1116,7 +1110,7 @@
flickrDateRegex = /^\d\d\d\d-\d\d-\d\d/;
matches = this.upload.file.date.match(
flickrDateRegex );
if ( !mw.isEmpty( matches ) ) {
- $( this.dateInput ).val(
this.upload.file.date );
+ this.dateInputWidget.setValue(
this.upload.file.date );
return;
}
}
@@ -1131,7 +1125,7 @@
dateStr = dateObj.getFullYear() + '-' + pad(
dateObj.getMonth() + 1 ) + '-' + pad( dateObj.getDate() );
// ok by now we should definitely have a dateObj and a
date string
- $( this.dateInput ).val( dateStr );
+ this.dateInputWidget.setValue( dateStr );
},
/**
@@ -1350,7 +1344,7 @@
}
} );
- information.date = $.trim( $( this.dateInput
).val() );
+ information.date =
this.dateInputWidget.getValue();
deed = this.upload.deedChooser.deed;
@@ -1711,8 +1705,6 @@
$moreDiv.addClass( 'mwe-upwiz-toggled' );
},
-
- dateInputCount: 0,
/**
* Apply some special cleanups for titles before adding to
model. These cleanups are not reflected in what the user sees in the title
input field.
diff --git a/resources/uploadWizard.css b/resources/uploadWizard.css
index 2c80bdd..dd82af6 100644
--- a/resources/uploadWizard.css
+++ b/resources/uploadWizard.css
@@ -684,19 +684,6 @@
padding: 0.25em;
}
-.mwe-date {
- width: 20em;
- /* @embed */
- background: #ffffff url('images/calendar.gif') no-repeat right center;
-}
-input.mwe-date {
- direction: ltr;
-}
-
-.ui-datepicker-current-day a.ui-state-active {
- background: #ffff99;
-}
-
.mwe-upwiz-hint {
/* @embed */
background: url('images/question.png') no-repeat;
--
To view, visit https://gerrit.wikimedia.org/r/228296
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia7bb737bc11b0af3659552fa75d11e6663e2812e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits