r111743 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111742‎ | r111743 | r111744 >
Date:10:55, 17 February 2012
Author:nikerabbit
Status:ok
Tags:i18nreview 
Comment:
Made the new changes not break in older browser like Firefox 3.5.3 ;)
Modified paths:
  • /trunk/extensions/Translate/resources/ext.translate.quickedit.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/resources/ext.translate.quickedit.js
@@ -144,7 +144,7 @@
145145 if ( $first.length ) {
146146 var title = $first.data( 'title' );
147147 var group = $first.data( 'group' );
148 - mw.translate.loadEditor( title, group, $.noop );
 148+ mw.translate.loadEditor( null, title, group, $.noop );
149149 }
150150
151151 var prev = null;
@@ -185,16 +185,20 @@
186186 return false;
187187 },
188188
189 - loadEditor: function( page, group, callback ) {
 189+ loadEditor: function( $target, page, group, callback ) {
190190 // Try if it has been cached
191191 var id = 'preload-' + page.replace( /[^a-zA-Z0-9_]/g, '_' );
192192 var preload = preloads[id];
193193 if ( preload !== undefined ) {
194 - callback.call( preload );
195 - delete preloads[id];
 194+ if ( $target ) {
 195+ $target.html( preloads[id] );
 196+ delete preloads[id];
 197+ }
 198+ callback();
196199 return;
197200 }
198201
 202+ // Load the editor into provided target or cache it locally
199203 var url = mw.util.wikiScript();
200204 var params = {
201205 title: 'Special:Translate/editpage',
@@ -202,10 +206,15 @@
203207 page: page,
204208 loadgroup: group
205209 };
206 - $.get( url, params, function ( data ) {
207 - preloads[id] = data;
208 - callback.call( data );
209 - } );
 210+ if ( $target ) {
 211+ $target.load( url, params, callback );
 212+ delete preloads[id];
 213+ } else {
 214+ $.get( url, params, function ( data ) {
 215+ preloads[id] = data;
 216+ } );
 217+ }
 218+
210219 },
211220
212221 openEditor: function( element, page, group, callbacks ) {
@@ -213,8 +222,7 @@
214223 var spinner = $( '<div>' ).attr( 'class', 'mw-ajax-loader' );
215224 $target.html( $( '<div>' ).attr( 'class', 'mw-ajax-dialog' ).html( spinner ) );
216225
217 - mw.translate.loadEditor( page, group, function() {
218 - $target.html( this );
 226+ mw.translate.loadEditor( $target, page, group, function() {
219227 callbacks.load && callbacks.load( $target );
220228 var form = $target.find( 'form' );
221229 registerFeatures( callbacks, form, page, group );
@@ -297,7 +305,7 @@
298306 // Preload the next item
299307 var ntitle = next.data( 'title' );
300308 var ngroup = next.data( 'group' );
301 - mw.translate.loadEditor( ntitle, ngroup, $.noop );
 309+ mw.translate.loadEditor( null, ntitle, ngroup, $.noop );
302310 }
303311 mw.translate.openEditor( $target, page, group, callbacks );
304312

Status & tagging log