r79897 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79896‎ | r79897 | r79898 >
Date:13:50, 9 January 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Some improvements to the translation control html and notranslate spans
Modified paths:
  • /trunk/extensions/LiveTranslate/LiveTranslate.hooks.php (modified) (history)
  • /trunk/extensions/LiveTranslate/includes/ext.livetranslate.js (modified) (history)

Diff [purge]

Index: trunk/extensions/LiveTranslate/LiveTranslate.hooks.php
@@ -78,11 +78,12 @@
7979 && $article->exists()
8080 && ( count( $egLiveTranslateLanguages ) > 1 || ( count( $egLiveTranslateLanguages ) == 1 && $egLiveTranslateLanguages[0] != $currentLang ) ) ) {
8181 $wgOut->addHTML(
82 - '<span class="notranslate" id="livetranslatespan" style="display:inline; float:right">' .
8382 Html::rawElement(
8483 'div',
8584 array(
86 - 'id' => 'livetranslatediv'
 85+ 'id' => 'livetranslatediv',
 86+ 'style' => 'display:inline; float:right',
 87+ 'class' => 'notranslate'
8788 ),
8889 htmlspecialchars( wfMsg( 'livetranslate-translate-to' ) ) .
8990 '&#160;' .
@@ -100,7 +101,7 @@
101102 wfMsg( 'livetranslate-button-revert' )
102103 )
103104 ) .
104 - '<br /><div id="googlebranding" style="display:inline; float:right"></div></span>'
 105+ '<br /><br /><div id="googlebranding" style="display:inline; float:right"></div>'
105106 );
106107
107108 $wgOut->addScript(
Index: trunk/extensions/LiveTranslate/includes/ext.livetranslate.js
@@ -158,10 +158,8 @@
159159 function getSpecialWords() {
160160 var words = [];
161161
162 - $.each($( '.notranslate' ), function( i, v ) {
163 - if ( $(v).attr( 'id' ) != 'livetranslatespan' ) {
164 - words.push( $(v).text() );
165 - }
 162+ $.each($( 'span.notranslate' ), function( i, v ) {
 163+ words.push( $(v).text() );
166164 });
167165
168166 return words;
@@ -174,7 +172,7 @@
175173 * @param {object} translations
176174 */
177175 function replaceSpecialWords( translations ) {
178 - $.each($(".notranslate"), function(i,v) {
 176+ $.each($("span.notranslate"), function(i,v) {
179177 var currentText = $(v).text();
180178 if ( translations[currentText] ) {
181179 $(v).text( translations[currentText] );
@@ -221,7 +219,7 @@
222220 );
223221 }
224222 // If it's an html element, check to see if it should be ignored, and if not, apply function again.
225 - else if ( $.inArray( $( this ).attr( 'id' ), [ 'livetranslatediv', 'siteSub', 'jump-to-nav' ] ) == -1
 223+ else if ( $.inArray( $( this ).attr( 'id' ), [ 'siteSub', 'jump-to-nav' ] ) == -1
226224 && !$( this ).hasClass( 'notranslate' ) && !$( this ).hasClass( 'printfooter' )
227225 && $( this ).text().length > 0 ) {
228226

Status & tagging log