r54667 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54666‎ | r54667 | r54668 >
Date:16:04, 9 August 2009
Author:nikerabbit
Status:deferred
Tags:
Comment:
* Support the new script loader
Modified paths:
  • /trunk/extensions/LanguageSelector/LanguageSelector.js (added) (history)
  • /trunk/extensions/LanguageSelector/LanguageSelector.php (modified) (history)
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/utils/JsSelectToInput.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LanguageSelector/LanguageSelector.js
@@ -0,0 +1,24 @@
 2+addOnloadHook(function() {
 3+ var i = 1;
 4+ while ( true ) {
 5+ var btn = document.getElementById("languageselector-commit-"+i);
 6+ var sel = document.getElementById("languageselector-select-"+i);
 7+ var idx = i;
 8+
 9+ if (!btn) break;
 10+
 11+ btn.style.display = "none";
 12+ sel.onchange = function() {
 13+ node = this.parentNode;
 14+ while( true ) {
 15+ if( node.tagName.toLowerCase() == "form" ) {
 16+ node.submit();
 17+ break;
 18+ }
 19+ node = node.parentNode;
 20+ }
 21+ };
 22+
 23+ i++;
 24+ }
 25+});
\ No newline at end of file
Property changes on: trunk/extensions/LanguageSelector/LanguageSelector.js
___________________________________________________________________
Name: svn:eol-style
126 + native
Index: trunk/extensions/LanguageSelector/LanguageSelector.php
@@ -71,6 +71,7 @@
7272
7373 $dir = dirname(__FILE__) . '/';
7474 $wgExtensionMessagesFiles['LanguageSelector'] = $dir . 'LanguageSelector.i18n.php';
 75+$wgJSAutoloadClasses['LanguageSelector'] = "extensions/LanguageSelector/LanguageSelector.js";
7576
7677 function wgLanguageSelectorSetHook() {
7778 global $wgParser;
@@ -166,32 +167,14 @@
167168 }
168169 }
169170
170 - $wgOut->addScript('<script type="'.$wgJsMimeType.'">
171 - addOnloadHook(function() {
172 - var i = 1;
173 - while ( true ) {
174 - var btn = document.getElementById("languageselector-commit-"+i);
175 - var sel = document.getElementById("languageselector-select-"+i);
176 - var idx = i;
177 -
178 - if (!btn) break;
179 -
180 - btn.style.display = "none";
181 - sel.onchange = function() {
182 - node = this.parentNode;
183 - while( true ) {
184 - if( node.tagName.toLowerCase() == "form" ) {
185 - node.submit();
186 - break;
187 - }
188 - node = node.parentNode;
189 - }
190 - };
191 -
192 - i++;
193 - }
194 - });
195 - </script>');
 171+ if ( method_exists( $wgOut, 'addScriptClass' ) ) {
 172+ $wgOut->addScriptClass( 'LanguageSelector' );
 173+ } else {
 174+ $wgOut->addScript( "<script type=\"$wgJsMimeType\">" .
 175+ file_get_contents( dirname( __FILE__ ) . '/LanguageSelector.js' ) .
 176+ '</script>'
 177+ );
 178+ }
196179 }
197180
198181 function wfLanguageSelectorBeforePageDisplay( &$out ) {
Index: trunk/extensions/Translate/Translate.php
@@ -67,6 +67,7 @@
6868 $wgHooks['SkinTemplateToolboxEnd'][] = 'TranslateToolbox::toolboxAllTranslations';
6969
7070 $wgJSAutoloadClasses['TranslateImport'] = "extensions/Translate/js/import.js";
 71+$wgJSAutoloadClasses['JsSelectToInput'] = "extensions/Translate/utils/JsSelectToInput.js";
7172
7273
7374 $wgEnablePageTranslation = false;
Index: trunk/extensions/Translate/utils/JsSelectToInput.php
@@ -68,7 +68,11 @@
6969 if ( $done ) return;
7070
7171 global $wgOut, $wgScriptPath;
72 - $wgOut->addScriptFile( "$wgScriptPath/extensions/Translate/utils/JsSelectToInput.js" );
 72+ if ( method_exists( $wgOut, 'addScriptClass' ) ) {
 73+ $wgOut->addScriptClass( 'JsSelectToInput' );
 74+ } else {
 75+ $wgOut->addScriptFile( "$wgScriptPath/extensions/Translate/utils/JsSelectToInput.js" );
 76+ }
7377 }
7478
7579 }
\ No newline at end of file

Status & tagging log