jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/310332 )
Change subject: Special:TranslationStats: use mediawiki.widgets.datetime if
available
......................................................................
Special:TranslationStats: use mediawiki.widgets.datetime if available
Change-Id: I22f06f264b143fd7bb5c65516d9265170974b893
---
M Resources.php
M resources/js/ext.translate.special.translationstats.js
2 files changed, 50 insertions(+), 19 deletions(-)
Approvals:
Amire80: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Resources.php b/Resources.php
index 5721ec1..aeb270d 100644
--- a/Resources.php
+++ b/Resources.php
@@ -526,10 +526,6 @@
$wgResourceModules['ext.translate.special.translationstats'] = array(
'scripts' => 'resources/js/ext.translate.special.translationstats.js',
- 'dependencies' => array(
- 'jquery.ui.datepicker',
- ),
- 'targets' => array( 'desktop' ),
) + $resourcePaths;
$wgResourceModules['ext.translate.statsbar'] = array(
diff --git a/resources/js/ext.translate.special.translationstats.js
b/resources/js/ext.translate.special.translationstats.js
index 2e55304..9c28f01 100644
--- a/resources/js/ext.translate.special.translationstats.js
+++ b/resources/js/ext.translate.special.translationstats.js
@@ -4,24 +4,59 @@
*
* @author Amir E. Aharoni
* @author Siebrand Mazeland
+ * @author Niklas Laxström
* @copyright Copyright © 2012-2013 Amir E. Aharoni, Siebrand Mazeland
* @license GPL-2.0+
*/
-jQuery( document ).ready( function ( $ ) {
+( function ( $, mw ) {
'use strict';
- // Based on UploadWizard, TranslationNotifications
- $( '#start' )
- .datepicker( {
- dateFormat: 'yy-mm-ddT00:00:00',
- constrainInput: false,
- showOn: 'focus',
- changeMonth: true,
- changeYear: true,
- showAnim: false,
- showButtonPanel: true,
- maxDate: new Date()
- } )
- .attr( 'autocomplete', 'off' );
-} );
+ $( function () {
+ var $input = $( '#start' ),
+ datepicker = mw.loader.getState(
'mediawiki.widgets.datetime' ) === null;
+
+ // Remove when MediaWiki 1.27 is no longer supported
+ if ( datepicker ) {
+ mw.loader.using( 'jquery.ui.datepicker' ).done(
function () {
+ $input.datepicker( {
+ dateFormat: 'yy-mm-ddT00:00:00',
+ constrainInput: false,
+ showOn: 'focus',
+ changeMonth: true,
+ changeYear: true,
+ showAnim: false,
+ showButtonPanel: true,
+ maxDate: new Date()
+ } )
+ .attr( 'autocomplete', 'off' );
+ } );
+ } else {
+ mw.loader.using( 'mediawiki.widgets.datetime' ).done(
function () {
+ var widget, defaultValue, defaultDate;
+
+ defaultDate = new Date();
+ defaultDate.setDate( 1 );
+
+ if ( $input.val() ) {
+ defaultValue = new Date( $input.val() );
+ }
+
+ widget = new
mw.widgets.datetime.DateTimeInputWidget( {
+ formatter: {
+ format:
'${year|0}-${month|0}-${day|0}',
+ defaultDate: defaultDate
+ },
+ type: 'date',
+ value: defaultValue,
+ max: new Date()
+ } );
+
+ $input.after( widget.$element ).hide();
+ widget.on( 'change', function ( data ) {
+ $input.val( data + 'T00:00:00' );
+ } );
+ } );
+ }
+ } );
+}( jQuery, mediaWiki ) );
--
To view, visit https://gerrit.wikimedia.org/r/310332
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I22f06f264b143fd7bb5c65516d9265170974b893
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>
Gerrit-Reviewer: Amire80 <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: KartikMistry <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits