r102181 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102180‎ | r102181 | r102182 >
Date:15:26, 6 November 2011
Author:nikerabbit
Status:ok
Tags:
Comment:
Rewrote resources/ext.translate.special.importtranslations.js so that it actually works
Modified paths:
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/resources/ext.translate.special.importtranslations.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/Translate.php
@@ -212,6 +212,7 @@
213213
214214 $wgResourceModules['ext.translate.special.importtranslations'] = array(
215215 'scripts' => 'resources/ext.translate.special.importtranslations.js',
 216+ 'dependencies' => array( 'jquery.ui.autocomplete' ),
216217 ) + $resourcePaths;
217218
218219 $wgResourceModules['ext.translate.selecttoinput'] = array(
Index: trunk/extensions/Translate/resources/ext.translate.special.importtranslations.js
@@ -1,15 +1,19 @@
2 -/** Call this to enable suggestions on input (id=inputId), on a form (name=formName) */
3 -function translateImportInit(){
4 - os_initHandlers( 'mw-translate-up-wiki-input', 'mw-translate-import', document.getElementById('mw-translate-up-wiki-input') );
 2+jQuery( function( $ ) {
 3+ $(".mw-translate-import-inputs").change( function() {
 4+ var id = $(this).attr( "id" ).replace( /-input/, "" );
 5+ $( "input[name=upload-type]:checked" ).attr( "checked", false );
 6+ $( "#" + id ).attr( "checked", "checked" );
 7+ } );
58
6 - jQuery(".mw-translate-import-inputs").each(function(i) {
7 - os_hookEvent(this, "focus", function(event) {
8 - var srcid = os_getTarget(event).id;
9 - var inputid = srcid.replace("-input", "");
10 -
11 - jQuery("#" + inputid).attr("checked", "checked");
12 - });
13 - });
14 -}
15 -
16 -hookEvent("load", translateImportInit);
\ No newline at end of file
 9+ $( "#mw-translate-up-wiki-input" ).autocomplete( {
 10+ source: function( request, response ) {
 11+ var api = mw.util.wikiScript( "api" );
 12+ var data = { action: "opensearch", format: "json", namespace: 6, search: request.term };
 13+ var success = function( res ) {
 14+ response( res[1] );
 15+ };
 16+
 17+ $.get( api, data, success );
 18+ }
 19+ } );
 20+} );

Sign-offs

UserFlagDate
Siebrandtested22:50, 13 January 2012

Status & tagging log