r96110 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96109‎ | r96110 | r96111 >
Date:15:54, 2 September 2011
Author:nikerabbit
Status:deferred (Comments)
Tags:
Comment:
Moved import.js to RL - the script itself needs to be rewritten (I could use help on that!)
Modified paths:
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/resources/ext.translate.special.importtranslations.js (added) (history)
  • /trunk/extensions/Translate/resources/import.js (deleted) (history)
  • /trunk/extensions/Translate/specials/SpecialImportTranslations.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/Translate.php
@@ -164,6 +164,10 @@
165165 'styles' => 'resources/ext.translate.special.supportedlanguages.css',
166166 ) + $resourcePaths;
167167
 168+$wgResourceModules['ext.translate.special.importtranslations'] = array(
 169+ 'scripts' => 'resources/ext.translate.special.importtranslations.js',
 170+) + $resourcePaths;
 171+
168172 $wgResourceModules['jquery.autoresize'] = array(
169173 'scripts' => 'resources/jquery.autoresize.js',
170174 ) + $resourcePaths;
Index: trunk/extensions/Translate/specials/SpecialImportTranslations.php
@@ -117,8 +117,7 @@
118118 protected function outputForm() {
119119 global $wgOut;
120120
121 - $wgOut->includeJQuery();
122 - $this->out->addScriptFile( TranslateUtils::assetPath( 'js/import.js' ) );
 121+ $wgOut->addModules( 'ext.translate.special.importtranslations' );
123122
124123 /**
125124 * Ugly but necessary form building ahead, ohoy
Index: trunk/extensions/Translate/resources/import.js
@@ -1,15 +0,0 @@
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') );
5 -
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
Index: trunk/extensions/Translate/resources/ext.translate.special.importtranslations.js
@@ -0,0 +1,15 @@
 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') );
 5+
 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
Property changes on: trunk/extensions/Translate/resources/ext.translate.special.importtranslations.js
___________________________________________________________________
Added: svn:eol-style
117 + native

Comments

#Comment by Santhosh.thottingal (talk | contribs)   10:04, 5 September 2011

Shall we use '$' instead of 'jQuery' consistently?

#Comment by Dantman (talk | contribs)   10:15, 5 September 2011

Wrap it in a (function($) { [...] })(jQuery);

#Comment by Nikerabbit (talk | contribs)   13:47, 5 September 2011

This script is broken. It needs to be rewritten, but I don't know how to enable autocompletion on input fields on trunk.

Status & tagging log