Index: trunk/extensions/Translate/resources/ext.translate.quickedit.js |
— | — | @@ -144,7 +144,7 @@ |
145 | 145 | if ( $first.length ) { |
146 | 146 | var title = $first.data( 'title' ); |
147 | 147 | var group = $first.data( 'group' ); |
148 | | - mw.translate.loadEditor( title, group, $.noop ); |
| 148 | + mw.translate.loadEditor( null, title, group, $.noop ); |
149 | 149 | } |
150 | 150 | |
151 | 151 | var prev = null; |
— | — | @@ -185,16 +185,20 @@ |
186 | 186 | return false; |
187 | 187 | }, |
188 | 188 | |
189 | | - loadEditor: function( page, group, callback ) { |
| 189 | + loadEditor: function( $target, page, group, callback ) { |
190 | 190 | // Try if it has been cached |
191 | 191 | var id = 'preload-' + page.replace( /[^a-zA-Z0-9_]/g, '_' ); |
192 | 192 | var preload = preloads[id]; |
193 | 193 | 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(); |
196 | 199 | return; |
197 | 200 | } |
198 | 201 | |
| 202 | + // Load the editor into provided target or cache it locally |
199 | 203 | var url = mw.util.wikiScript(); |
200 | 204 | var params = { |
201 | 205 | title: 'Special:Translate/editpage', |
— | — | @@ -202,10 +206,15 @@ |
203 | 207 | page: page, |
204 | 208 | loadgroup: group |
205 | 209 | }; |
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 | + |
210 | 219 | }, |
211 | 220 | |
212 | 221 | openEditor: function( element, page, group, callbacks ) { |
— | — | @@ -213,8 +222,7 @@ |
214 | 223 | var spinner = $( '<div>' ).attr( 'class', 'mw-ajax-loader' ); |
215 | 224 | $target.html( $( '<div>' ).attr( 'class', 'mw-ajax-dialog' ).html( spinner ) ); |
216 | 225 | |
217 | | - mw.translate.loadEditor( page, group, function() { |
218 | | - $target.html( this ); |
| 226 | + mw.translate.loadEditor( $target, page, group, function() { |
219 | 227 | callbacks.load && callbacks.load( $target ); |
220 | 228 | var form = $target.find( 'form' ); |
221 | 229 | registerFeatures( callbacks, form, page, group ); |
— | — | @@ -297,7 +305,7 @@ |
298 | 306 | // Preload the next item |
299 | 307 | var ntitle = next.data( 'title' ); |
300 | 308 | var ngroup = next.data( 'group' ); |
301 | | - mw.translate.loadEditor( ntitle, ngroup, $.noop ); |
| 309 | + mw.translate.loadEditor( null, ntitle, ngroup, $.noop ); |
302 | 310 | } |
303 | 311 | mw.translate.openEditor( $target, page, group, callbacks ); |
304 | 312 | |