Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -78,14 +78,14 @@ |
79 | 79 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 19 ), |
80 | 80 | array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 96 ), |
81 | 81 | array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 11 ), |
82 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 30 ), |
| 82 | + array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 31 ), |
83 | 83 | array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 3 ), |
84 | 84 | ), |
85 | 85 | 'combined' => array( |
86 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 297 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 298 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 297 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 298 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js |
— | — | @@ -28,6 +28,10 @@ |
29 | 29 | */ |
30 | 30 | evt: { |
31 | 31 | mark: function( context, event ) { |
| 32 | + if ( $( 'body' ).hasClass( 'ns-10' ) ) { |
| 33 | + // We're in the template namespace, don't collapse any templates |
| 34 | + return; |
| 35 | + } |
32 | 36 | // Get references to the markers and tokens from the current context |
33 | 37 | var markers = context.modules.highlight.markers; |
34 | 38 | var tokenArray = context.modules.highlight.tokenArray; |
— | — | @@ -57,13 +61,6 @@ |
58 | 62 | } |
59 | 63 | }//while finding template ending |
60 | 64 | if ( endIndex != -1 ) { |
61 | | - // Create a model for the template |
62 | | - // FIXME: This is a performance hit |
63 | | - var model = new $.wikiEditor.modules.templateEditor.fn.model( |
64 | | - context.fn.getContents().substring( tokenArray[beginIndex].offset, |
65 | | - tokenArray[endIndex].offset |
66 | | - ) |
67 | | - ); |
68 | 65 | markers.push( { |
69 | 66 | start: tokenArray[beginIndex].offset, |
70 | 67 | end: tokenArray[endIndex].offset, |
— | — | @@ -72,9 +69,12 @@ |
73 | 70 | //splitPs: model.isCollapsible(), |
74 | 71 | splitPs: false, |
75 | 72 | afterWrap: function( node ) { |
76 | | - // Store model so we can compare it later |
77 | | - $( node ).data( 'model', $( node ).data( 'marker' ).model ); |
78 | | - if ( $( node ).data( 'model' ).isCollapsible() ) { |
| 73 | + // Generate model |
| 74 | + var model = new $.wikiEditor.modules.templateEditor.fn.model( |
| 75 | + $( node ).text() |
| 76 | + ); |
| 77 | + $( node ).data( 'model', model ); |
| 78 | + if ( model.isCollapsible() ) { |
79 | 79 | $.wikiEditor.modules.templateEditor.fn.wrapTemplate( $( node ) ); |
80 | 80 | } else { |
81 | 81 | $( node ).addClass( 'wikiEditor-template-text' ); |
— | — | @@ -86,26 +86,28 @@ |
87 | 87 | } |
88 | 88 | }, |
89 | 89 | onSkip: function( node ) { |
90 | | - var oldModel = $( node ).data( 'model' ); |
91 | | - var newModel = $( node ).data( 'marker' ).model; |
92 | | - if ( oldModel.getText() == newModel.getText() ) { |
| 90 | + if ( $( node ).data( 'model' ).getText() == $( node ).text() ) { |
93 | 91 | // No change |
94 | 92 | return; |
95 | 93 | } |
| 94 | + // Text changed, regenerate model |
| 95 | + var model = new $.wikiEditor.modules.templateEditor.fn.model( |
| 96 | + $( node ).text() |
| 97 | + ); |
| 98 | + $( node ).data( 'model', model ); |
96 | 99 | |
97 | | - if ( $( node ).parent().hasClass( 'wikiEditor-template' ) && !newModel.isCollapsible() ) { |
| 100 | + if ( $( node ).parent().hasClass( 'wikiEditor-template' ) && |
| 101 | + !model.isCollapsible() ) { |
98 | 102 | $.wikiEditor.modules.templateEditor.fn.unwrapTemplate( $( node ) ); |
99 | | - } else if ( !$( node ).parent().hasClass( 'wikiEditor-template' ) && newModel.isCollapsible() ) { |
| 103 | + } else if ( !$( node ).parent().hasClass( 'wikiEditor-template' ) && |
| 104 | + model.isCollapsible() ) { |
100 | 105 | $.wikiEditor.modules.templateEditor.fn.wrapTemplate( $( node ) ); |
101 | 106 | } |
102 | | - // TODO: Update table; not doing this yet because the table will probably die |
103 | 107 | }, |
104 | 108 | getAnchor: function( ca1, ca2 ) { |
105 | | - // FIXME: Relies on the current <span> structure that is likely to die |
106 | 109 | return $( ca1.parentNode ).is( 'span.wikiEditor-template-text' ) ? |
107 | 110 | ca1.parentNode : null; |
108 | 111 | }, |
109 | | - model: model, |
110 | 112 | context: context |
111 | 113 | } ); |
112 | 114 | } else { //else this was an unmatched opening |
— | — | @@ -146,7 +148,7 @@ |
147 | 149 | * @param $wrapper Wrapping <span> |
148 | 150 | */ |
149 | 151 | wrapTemplate: function( $wrapper ) { |
150 | | - var model = $wrapper.data( 'marker' ).model; |
| 152 | + var model = $wrapper.data( 'model' ); |
151 | 153 | var context = $wrapper.data( 'marker' ).context; |
152 | 154 | |
153 | 155 | var $template = $wrapper |
— | — | @@ -202,46 +204,6 @@ |
203 | 205 | |
204 | 206 | return false; |
205 | 207 | }; |
206 | | - |
207 | | - // Expand |
208 | | - // FIXME: This function is unused |
209 | | - function expandTemplate( $displayDiv ) { |
210 | | - // Housekeeping |
211 | | - $displayDiv |
212 | | - .removeClass( 'wikiEditor-template-collapsed' ) |
213 | | - .addClass( 'wikiEditor-template-expanded' ) |
214 | | - // remove mousedown hander from the entire thing |
215 | | - .unbind( 'mousedown' ); |
216 | | - //$displayDiv.text( model.getText() ); |
217 | | - $keyValueTable = $( '<table />' ) |
218 | | - .appendTo( $displayDiv ); |
219 | | - $header_row = $( '<tr />' ) |
220 | | - .appendTo( $keyValueTable ); |
221 | | - $( '<th />' ) |
222 | | - .attr( 'colspan', '2' ) |
223 | | - .text( model.getName() ) |
224 | | - .appendTo( $header_row ); |
225 | | - for( param in model.getAllParamNames() ){ |
226 | | - $keyVal_row = $( '<tr />' ) |
227 | | - .appendTo( $keyValueTable ); |
228 | | - |
229 | | - $( '<td />' ) |
230 | | - .text( param ) |
231 | | - .appendTo( $keyVal_row ); |
232 | | - $( '<td />' ) |
233 | | - .text( model.getValue( param ) ) |
234 | | - .appendTo( $keyVal_row ); |
235 | | - } |
236 | | - }; |
237 | | - // Collapse |
238 | | - // FIXME: This function is unused |
239 | | - function collapseTemplate( $displayDiv ) { |
240 | | - // Housekeeping |
241 | | - $displayDiv |
242 | | - .addClass( 'wikiEditor-template-collapsed' ) |
243 | | - .removeClass( 'wikiEditor-template-expanded' ) |
244 | | - .text( model.getName() ); |
245 | | - }; |
246 | 208 | |
247 | 209 | var dialog = { |
248 | 210 | 'titleMsg': 'wikieditor-template-editor-dialog-title', |
— | — | @@ -290,24 +252,39 @@ |
291 | 253 | // TODO: Be smart and recycle existing table |
292 | 254 | var params = templateModel.getAllInitialParams(); |
293 | 255 | var $table = $(this).find( '.wikiEditor-template-dialog-table' ).empty(); |
| 256 | + // Do some bookkeeping so we can recycle existing rows |
| 257 | + var $rows = $table.find( 'tr' ); |
294 | 258 | for ( var paramIndex in params ) { |
295 | 259 | var param = params[paramIndex]; |
296 | 260 | if ( typeof param.name == 'undefined' ) { |
297 | 261 | // param is the template name, skip it |
298 | 262 | continue; |
299 | 263 | } |
300 | | - var $paramRow = $( '<tr />' ).addClass( 'wikiEditor-template-dialog-row' ); |
301 | | - $( '<td />' ).addClass( 'wikiEditor-template-dialog-label' ).text( |
302 | | - typeof param == 'string' ? |
| 264 | + |
| 265 | + var paramText = typeof param == 'string' ? |
303 | 266 | param.name.replace( /[\_\-]/g, ' ' ) : |
304 | | - param.name |
305 | | - ).appendTo( $paramRow ); |
306 | | - $( '<td />' ).addClass( 'wikiEditor-template-dialog-value' ).append( |
307 | | - $( '<input />' ) |
308 | | - .data( 'name', param.name ) |
309 | | - .val( templateModel.getValue( param.name ) ) |
310 | | - ).appendTo( $paramRow ); |
311 | | - $table.append( $paramRow ); |
| 267 | + param.name; |
| 268 | + var paramVal = templateModel.getValue( param.name ); |
| 269 | + if ( $rows.length > 0 ) { |
| 270 | + // We have another row to recycle |
| 271 | + var $row = $rows.eq( 0 ); |
| 272 | + $row.children( '.wikiEditor-template-dialog-label' ).text( paramText ); |
| 273 | + $row.children( '.wikiEditor-template-dialog-value input' ).val( paramVal ); |
| 274 | + $rows = $rows.not( $row ); |
| 275 | + } else { |
| 276 | + // Create a new row |
| 277 | + var $paramRow = $( '<tr />' ).addClass( 'wikiEditor-template-dialog-row' ); |
| 278 | + $( '<td />' ) |
| 279 | + .addClass( 'wikiEditor-template-dialog-label' ) |
| 280 | + .text( paramText ) |
| 281 | + .appendTo( $paramRow ); |
| 282 | + $( '<td />' ).addClass( 'wikiEditor-template-dialog-value' ).append( |
| 283 | + $( '<input />' ).data( 'name', param.name ).val( paramVal ) |
| 284 | + ).appendTo( $paramRow ); |
| 285 | + $table.append( $paramRow ); |
| 286 | + } |
| 287 | + // Remove any leftover rows |
| 288 | + $rows.remove(); |
312 | 289 | } |
313 | 290 | } |
314 | 291 | } |
— | — | @@ -320,10 +297,6 @@ |
321 | 298 | .data( 'templateDiv', $templateDiv ) |
322 | 299 | .dialog( 'open' ); |
323 | 300 | } |
324 | | - |
325 | | - function noEdit() { |
326 | | - return false; |
327 | | - } |
328 | 301 | }, |
329 | 302 | /** |
330 | 303 | * Turn a complex template wrapper back into a simple one |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -9135,6 +9135,10 @@ |
9136 | 9136 | */ |
9137 | 9137 | evt: { |
9138 | 9138 | mark: function( context, event ) { |
| 9139 | + if ( $( 'body' ).hasClass( 'ns-10' ) ) { |
| 9140 | + // We're in the template namespace, don't collapse any templates |
| 9141 | + return; |
| 9142 | + } |
9139 | 9143 | // Get references to the markers and tokens from the current context |
9140 | 9144 | var markers = context.modules.highlight.markers; |
9141 | 9145 | var tokenArray = context.modules.highlight.tokenArray; |
— | — | @@ -9164,13 +9168,6 @@ |
9165 | 9169 | } |
9166 | 9170 | }//while finding template ending |
9167 | 9171 | if ( endIndex != -1 ) { |
9168 | | - // Create a model for the template |
9169 | | - // FIXME: This is a performance hit |
9170 | | - var model = new $.wikiEditor.modules.templateEditor.fn.model( |
9171 | | - context.fn.getContents().substring( tokenArray[beginIndex].offset, |
9172 | | - tokenArray[endIndex].offset |
9173 | | - ) |
9174 | | - ); |
9175 | 9172 | markers.push( { |
9176 | 9173 | start: tokenArray[beginIndex].offset, |
9177 | 9174 | end: tokenArray[endIndex].offset, |
— | — | @@ -9179,9 +9176,12 @@ |
9180 | 9177 | //splitPs: model.isCollapsible(), |
9181 | 9178 | splitPs: false, |
9182 | 9179 | afterWrap: function( node ) { |
9183 | | - // Store model so we can compare it later |
9184 | | - $( node ).data( 'model', $( node ).data( 'marker' ).model ); |
9185 | | - if ( $( node ).data( 'model' ).isCollapsible() ) { |
| 9180 | + // Generate model |
| 9181 | + var model = new $.wikiEditor.modules.templateEditor.fn.model( |
| 9182 | + $( node ).text() |
| 9183 | + ); |
| 9184 | + $( node ).data( 'model', model ); |
| 9185 | + if ( model.isCollapsible() ) { |
9186 | 9186 | $.wikiEditor.modules.templateEditor.fn.wrapTemplate( $( node ) ); |
9187 | 9187 | } else { |
9188 | 9188 | $( node ).addClass( 'wikiEditor-template-text' ); |
— | — | @@ -9193,26 +9193,28 @@ |
9194 | 9194 | } |
9195 | 9195 | }, |
9196 | 9196 | onSkip: function( node ) { |
9197 | | - var oldModel = $( node ).data( 'model' ); |
9198 | | - var newModel = $( node ).data( 'marker' ).model; |
9199 | | - if ( oldModel.getText() == newModel.getText() ) { |
| 9197 | + if ( $( node ).data( 'model' ).getText() == $( node ).text() ) { |
9200 | 9198 | // No change |
9201 | 9199 | return; |
9202 | 9200 | } |
| 9201 | + // Text changed, regenerate model |
| 9202 | + var model = new $.wikiEditor.modules.templateEditor.fn.model( |
| 9203 | + $( node ).text() |
| 9204 | + ); |
| 9205 | + $( node ).data( 'model', model ); |
9203 | 9206 | |
9204 | | - if ( $( node ).parent().hasClass( 'wikiEditor-template' ) && !newModel.isCollapsible() ) { |
| 9207 | + if ( $( node ).parent().hasClass( 'wikiEditor-template' ) && |
| 9208 | + !model.isCollapsible() ) { |
9205 | 9209 | $.wikiEditor.modules.templateEditor.fn.unwrapTemplate( $( node ) ); |
9206 | | - } else if ( !$( node ).parent().hasClass( 'wikiEditor-template' ) && newModel.isCollapsible() ) { |
| 9210 | + } else if ( !$( node ).parent().hasClass( 'wikiEditor-template' ) && |
| 9211 | + model.isCollapsible() ) { |
9207 | 9212 | $.wikiEditor.modules.templateEditor.fn.wrapTemplate( $( node ) ); |
9208 | 9213 | } |
9209 | | - // TODO: Update table; not doing this yet because the table will probably die |
9210 | 9214 | }, |
9211 | 9215 | getAnchor: function( ca1, ca2 ) { |
9212 | | - // FIXME: Relies on the current <span> structure that is likely to die |
9213 | 9216 | return $( ca1.parentNode ).is( 'span.wikiEditor-template-text' ) ? |
9214 | 9217 | ca1.parentNode : null; |
9215 | 9218 | }, |
9216 | | - model: model, |
9217 | 9219 | context: context |
9218 | 9220 | } ); |
9219 | 9221 | } else { //else this was an unmatched opening |
— | — | @@ -9253,7 +9255,7 @@ |
9254 | 9256 | * @param $wrapper Wrapping <span> |
9255 | 9257 | */ |
9256 | 9258 | wrapTemplate: function( $wrapper ) { |
9257 | | - var model = $wrapper.data( 'marker' ).model; |
| 9259 | + var model = $wrapper.data( 'model' ); |
9258 | 9260 | var context = $wrapper.data( 'marker' ).context; |
9259 | 9261 | |
9260 | 9262 | var $template = $wrapper |
— | — | @@ -9309,46 +9311,6 @@ |
9310 | 9312 | |
9311 | 9313 | return false; |
9312 | 9314 | }; |
9313 | | - |
9314 | | - // Expand |
9315 | | - // FIXME: This function is unused |
9316 | | - function expandTemplate( $displayDiv ) { |
9317 | | - // Housekeeping |
9318 | | - $displayDiv |
9319 | | - .removeClass( 'wikiEditor-template-collapsed' ) |
9320 | | - .addClass( 'wikiEditor-template-expanded' ) |
9321 | | - // remove mousedown hander from the entire thing |
9322 | | - .unbind( 'mousedown' ); |
9323 | | - //$displayDiv.text( model.getText() ); |
9324 | | - $keyValueTable = $( '<table />' ) |
9325 | | - .appendTo( $displayDiv ); |
9326 | | - $header_row = $( '<tr />' ) |
9327 | | - .appendTo( $keyValueTable ); |
9328 | | - $( '<th />' ) |
9329 | | - .attr( 'colspan', '2' ) |
9330 | | - .text( model.getName() ) |
9331 | | - .appendTo( $header_row ); |
9332 | | - for( param in model.getAllParamNames() ){ |
9333 | | - $keyVal_row = $( '<tr />' ) |
9334 | | - .appendTo( $keyValueTable ); |
9335 | | - |
9336 | | - $( '<td />' ) |
9337 | | - .text( param ) |
9338 | | - .appendTo( $keyVal_row ); |
9339 | | - $( '<td />' ) |
9340 | | - .text( model.getValue( param ) ) |
9341 | | - .appendTo( $keyVal_row ); |
9342 | | - } |
9343 | | - }; |
9344 | | - // Collapse |
9345 | | - // FIXME: This function is unused |
9346 | | - function collapseTemplate( $displayDiv ) { |
9347 | | - // Housekeeping |
9348 | | - $displayDiv |
9349 | | - .addClass( 'wikiEditor-template-collapsed' ) |
9350 | | - .removeClass( 'wikiEditor-template-expanded' ) |
9351 | | - .text( model.getName() ); |
9352 | | - }; |
9353 | 9315 | |
9354 | 9316 | var dialog = { |
9355 | 9317 | 'titleMsg': 'wikieditor-template-editor-dialog-title', |
— | — | @@ -9397,24 +9359,39 @@ |
9398 | 9360 | // TODO: Be smart and recycle existing table |
9399 | 9361 | var params = templateModel.getAllInitialParams(); |
9400 | 9362 | var $table = $(this).find( '.wikiEditor-template-dialog-table' ).empty(); |
| 9363 | + // Do some bookkeeping so we can recycle existing rows |
| 9364 | + var $rows = $table.find( 'tr' ); |
9401 | 9365 | for ( var paramIndex in params ) { |
9402 | 9366 | var param = params[paramIndex]; |
9403 | 9367 | if ( typeof param.name == 'undefined' ) { |
9404 | 9368 | // param is the template name, skip it |
9405 | 9369 | continue; |
9406 | 9370 | } |
9407 | | - var $paramRow = $( '<tr />' ).addClass( 'wikiEditor-template-dialog-row' ); |
9408 | | - $( '<td />' ).addClass( 'wikiEditor-template-dialog-label' ).text( |
9409 | | - typeof param == 'string' ? |
| 9371 | + |
| 9372 | + var paramText = typeof param == 'string' ? |
9410 | 9373 | param.name.replace( /[\_\-]/g, ' ' ) : |
9411 | | - param.name |
9412 | | - ).appendTo( $paramRow ); |
9413 | | - $( '<td />' ).addClass( 'wikiEditor-template-dialog-value' ).append( |
9414 | | - $( '<input />' ) |
9415 | | - .data( 'name', param.name ) |
9416 | | - .val( templateModel.getValue( param.name ) ) |
9417 | | - ).appendTo( $paramRow ); |
9418 | | - $table.append( $paramRow ); |
| 9374 | + param.name; |
| 9375 | + var paramVal = templateModel.getValue( param.name ); |
| 9376 | + if ( $rows.length > 0 ) { |
| 9377 | + // We have another row to recycle |
| 9378 | + var $row = $rows.eq( 0 ); |
| 9379 | + $row.children( '.wikiEditor-template-dialog-label' ).text( paramText ); |
| 9380 | + $row.children( '.wikiEditor-template-dialog-value input' ).val( paramVal ); |
| 9381 | + $rows = $rows.not( $row ); |
| 9382 | + } else { |
| 9383 | + // Create a new row |
| 9384 | + var $paramRow = $( '<tr />' ).addClass( 'wikiEditor-template-dialog-row' ); |
| 9385 | + $( '<td />' ) |
| 9386 | + .addClass( 'wikiEditor-template-dialog-label' ) |
| 9387 | + .text( paramText ) |
| 9388 | + .appendTo( $paramRow ); |
| 9389 | + $( '<td />' ).addClass( 'wikiEditor-template-dialog-value' ).append( |
| 9390 | + $( '<input />' ).data( 'name', param.name ).val( paramVal ) |
| 9391 | + ).appendTo( $paramRow ); |
| 9392 | + $table.append( $paramRow ); |
| 9393 | + } |
| 9394 | + // Remove any leftover rows |
| 9395 | + $rows.remove(); |
9419 | 9396 | } |
9420 | 9397 | } |
9421 | 9398 | } |
— | — | @@ -9427,10 +9404,6 @@ |
9428 | 9405 | .data( 'templateDiv', $templateDiv ) |
9429 | 9406 | .dialog( 'open' ); |
9430 | 9407 | } |
9431 | | - |
9432 | | - function noEdit() { |
9433 | | - return false; |
9434 | | - } |
9435 | 9408 | }, |
9436 | 9409 | /** |
9437 | 9410 | * Turn a complex template wrapper back into a simple one |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -637,18 +637,19 @@ |
638 | 638 | $('#wikiEditor-'+context.instance+'-dialog-minor').hide();else if($('#wpMinoredit').is(':checked')) |
639 | 639 | $('#wikiEditor-'+context.instance+'-dialog-minor').attr('checked','checked');if($('#wpWatchthis').size()==0) |
640 | 640 | $('#wikiEditor-'+context.instance+'-dialog-watch').hide();else if($('#wpWatchthis').is(':checked')) |
641 | | -$('#wikiEditor-'+context.instance+'-dialog-watch').attr('checked','checked');$(this).find('form').submit(function(e){$(this).closest('.ui-dialog').find('button:first').click();e.preventDefault();});},dialog:{buttons:{'wikieditor-publish-dialog-publish':function(){var minorChecked=$('#wikiEditor-'+context.instance+'-dialog-minor').is(':checked')?'checked':'';var watchChecked=$('#wikiEditor-'+context.instance+'-dialog-watch').is(':checked')?'checked':'';$('#wpMinoredit').attr('checked',minorChecked);$('#wpWatchthis').attr('checked',watchChecked);$('#wpSummary').val($j('#wikiEditor-'+context.instance+'-dialog-summary').val());$('#editform').submit();},'wikieditor-publish-dialog-goback':function(){$(this).dialog('close');}},open:function(){$('#wikiEditor-'+context.instance+'-dialog-summary').focus();},width:500},resizeme:false}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-publish','action':function(){$('#'+dialogID).dialog('open');return false;}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-cancel','action':function(){}});}}};})(jQuery);(function($){$.wikiEditor.modules.templateEditor={'browsers':{'ltr':{'msie':[['>=',8]],'firefox':[['>=',3]],'opera':[['>=',10]],'safari':[['>=',4]]},'rtl':{'msie':[['>=',8]],'firefox':[['>=',3]],'opera':[['>=',10]],'safari':[['>=',4]]}},'req':['iframe'],evt:{mark:function(context,event){var markers=context.modules.highlight.markers;var tokenArray=context.modules.highlight.tokenArray;var level=0;var tokenIndex=0;while(tokenIndex<tokenArray.length){while(tokenIndex<tokenArray.length&&tokenArray[tokenIndex].label!='TEMPLATE_BEGIN'){tokenIndex++;} |
| 641 | +$('#wikiEditor-'+context.instance+'-dialog-watch').attr('checked','checked');$(this).find('form').submit(function(e){$(this).closest('.ui-dialog').find('button:first').click();e.preventDefault();});},dialog:{buttons:{'wikieditor-publish-dialog-publish':function(){var minorChecked=$('#wikiEditor-'+context.instance+'-dialog-minor').is(':checked')?'checked':'';var watchChecked=$('#wikiEditor-'+context.instance+'-dialog-watch').is(':checked')?'checked':'';$('#wpMinoredit').attr('checked',minorChecked);$('#wpWatchthis').attr('checked',watchChecked);$('#wpSummary').val($j('#wikiEditor-'+context.instance+'-dialog-summary').val());$('#editform').submit();},'wikieditor-publish-dialog-goback':function(){$(this).dialog('close');}},open:function(){$('#wikiEditor-'+context.instance+'-dialog-summary').focus();},width:500},resizeme:false}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-publish','action':function(){$('#'+dialogID).dialog('open');return false;}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-cancel','action':function(){}});}}};})(jQuery);(function($){$.wikiEditor.modules.templateEditor={'browsers':{'ltr':{'msie':[['>=',8]],'firefox':[['>=',3]],'opera':[['>=',10]],'safari':[['>=',4]]},'rtl':{'msie':[['>=',8]],'firefox':[['>=',3]],'opera':[['>=',10]],'safari':[['>=',4]]}},'req':['iframe'],evt:{mark:function(context,event){if($('body').hasClass('ns-10')){return;} |
| 642 | +var markers=context.modules.highlight.markers;var tokenArray=context.modules.highlight.tokenArray;var level=0;var tokenIndex=0;while(tokenIndex<tokenArray.length){while(tokenIndex<tokenArray.length&&tokenArray[tokenIndex].label!='TEMPLATE_BEGIN'){tokenIndex++;} |
642 | 643 | if(tokenIndex<tokenArray.length){var beginIndex=tokenIndex;var endIndex=-1;var openTemplates=1;var templatesMatched=false;while(tokenIndex<tokenArray.length-1&&endIndex==-1){tokenIndex++;if(tokenArray[tokenIndex].label=='TEMPLATE_BEGIN'){openTemplates++;}else if(tokenArray[tokenIndex].label=='TEMPLATE_END'){openTemplates--;if(openTemplates==0){endIndex=tokenIndex;}}} |
643 | | -if(endIndex!=-1){var model=new $.wikiEditor.modules.templateEditor.fn.model(context.fn.getContents().substring(tokenArray[beginIndex].offset,tokenArray[endIndex].offset));markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,type:'template',anchor:'wrap',splitPs:false,afterWrap:function(node){$(node).data('model',$(node).data('marker').model);if($(node).data('model').isCollapsible()){$.wikiEditor.modules.templateEditor.fn.wrapTemplate($(node));}else{$(node).addClass('wikiEditor-template-text');}},beforeUnwrap:function(node){if($(node).parent().hasClass('wikiEditor-template')){$.wikiEditor.modules.templateEditor.fn.unwrapTemplate($(node));}},onSkip:function(node){var oldModel=$(node).data('model');var newModel=$(node).data('marker').model;if(oldModel.getText()==newModel.getText()){return;} |
644 | | -if($(node).parent().hasClass('wikiEditor-template')&&!newModel.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.unwrapTemplate($(node));}else if(!$(node).parent().hasClass('wikiEditor-template')&&newModel.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.wrapTemplate($(node));}},getAnchor:function(ca1,ca2){return $(ca1.parentNode).is('span.wikiEditor-template-text')?ca1.parentNode:null;},model:model,context:context});}else{tokenArray[beginIndex].label='TEMPLATE_FALSE_BEGIN';tokenIndex=beginIndex;}}}}},exp:[{'regex':/{{/,'label':"TEMPLATE_BEGIN"},{'regex':/}}/,'label':"TEMPLATE_END",'markAfter':true}],cfg:{},fn:{create:function(context,config){context.modules.templateEditor={};},wrapTemplate:function($wrapper){var model=$wrapper.data('marker').model;var context=$wrapper.data('marker').context;var $template=$wrapper.wrap('<span class="wikiEditor-template"></span>').addClass('wikiEditor-template-text wikiEditor-nodisplay').parent().addClass('wikiEditor-template-collapsed').data('model',model);var $templateName=$('<span />').addClass('wikiEditor-template-name wikiEditor-noinclude').text(model.getName()).mousedown(toggleWikiTextEditor).prependTo($template);var $templateExpand=$('<span />').addClass('wikiEditor-template-expand wikiEditor-noinclude').append('<img src="'+$.wikiEditor.autoIcon('templateEditor/expand.png')+'" width="12" height="16" />').append('<img src="'+$.wikiEditor.autoIcon('templateEditor/collapse.png')+'" width="12" height="16" style="display:none;" />').mousedown(toggleWikiTextEditor).prependTo($template);var $templateDialog=$('<span />').addClass('wikiEditor-template-dialog wikiEditor-noinclude').append('<img src="'+$.wikiEditor.autoIcon('templateEditor/dialog-collapsed.png')+'" width="22" height="16" />').append('<img src="'+$.wikiEditor.autoIcon('templateEditor/dialog-expanded.png')+'" width="22" height="16" style="display:none;" />').mousedown(function(){createDialog($template);return false;}).insertAfter($templateName);function toggleWikiTextEditor(){context.fn.purgeOffsets();var $template=$(this).closest('.wikiEditor-template');$template.toggleClass('wikiEditor-template-expanded').toggleClass('wikiEditor-template-collapsed').find('img').each(function(){$(this).toggle();});var $wikitext=$template.children('.wikiEditor-template-text');$wikitext.toggleClass('wikiEditor-nodisplay');if($template.hasClass('wikiEditor-template-collapsed')){var model=new $.wikiEditor.modules.templateEditor.fn.model($template.children('.wikiEditor-template-text').text());$template.children('.wikiEditor-template-text').data('model',model);$template.children('.wikiEditor-template-name').text(model.getName());}else{$wikitext.text($template.children('.wikiEditor-template-text').data('model').getText());} |
645 | | -return false;};function expandTemplate($displayDiv){$displayDiv.removeClass('wikiEditor-template-collapsed').addClass('wikiEditor-template-expanded').unbind('mousedown');$keyValueTable=$('<table />').appendTo($displayDiv);$header_row=$('<tr />').appendTo($keyValueTable);$('<th />').attr('colspan','2').text(model.getName()).appendTo($header_row);for(param in model.getAllParamNames()){$keyVal_row=$('<tr />').appendTo($keyValueTable);$('<td />').text(param).appendTo($keyVal_row);$('<td />').text(model.getValue(param)).appendTo($keyVal_row);}};function collapseTemplate($displayDiv){$displayDiv.addClass('wikiEditor-template-collapsed').removeClass('wikiEditor-template-expanded').text(model.getName());};var dialog={'titleMsg':'wikieditor-template-editor-dialog-title','id':'wikiEditor-template-dialog','html':'\ |
| 644 | +if(endIndex!=-1){markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,type:'template',anchor:'wrap',splitPs:false,afterWrap:function(node){var model=new $.wikiEditor.modules.templateEditor.fn.model($(node).text());$(node).data('model',model);if(model.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.wrapTemplate($(node));}else{$(node).addClass('wikiEditor-template-text');}},beforeUnwrap:function(node){if($(node).parent().hasClass('wikiEditor-template')){$.wikiEditor.modules.templateEditor.fn.unwrapTemplate($(node));}},onSkip:function(node){if($(node).data('model').getText()==$(node).text()){return;} |
| 645 | +var model=new $.wikiEditor.modules.templateEditor.fn.model($(node).text());$(node).data('model',model);if($(node).parent().hasClass('wikiEditor-template')&&!model.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.unwrapTemplate($(node));}else if(!$(node).parent().hasClass('wikiEditor-template')&&model.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.wrapTemplate($(node));}},getAnchor:function(ca1,ca2){return $(ca1.parentNode).is('span.wikiEditor-template-text')?ca1.parentNode:null;},context:context});}else{tokenArray[beginIndex].label='TEMPLATE_FALSE_BEGIN';tokenIndex=beginIndex;}}}}},exp:[{'regex':/{{/,'label':"TEMPLATE_BEGIN"},{'regex':/}}/,'label':"TEMPLATE_END",'markAfter':true}],cfg:{},fn:{create:function(context,config){context.modules.templateEditor={};},wrapTemplate:function($wrapper){var model=$wrapper.data('model');var context=$wrapper.data('marker').context;var $template=$wrapper.wrap('<span class="wikiEditor-template"></span>').addClass('wikiEditor-template-text wikiEditor-nodisplay').parent().addClass('wikiEditor-template-collapsed').data('model',model);var $templateName=$('<span />').addClass('wikiEditor-template-name wikiEditor-noinclude').text(model.getName()).mousedown(toggleWikiTextEditor).prependTo($template);var $templateExpand=$('<span />').addClass('wikiEditor-template-expand wikiEditor-noinclude').append('<img src="'+$.wikiEditor.autoIcon('templateEditor/expand.png')+'" width="12" height="16" />').append('<img src="'+$.wikiEditor.autoIcon('templateEditor/collapse.png')+'" width="12" height="16" style="display:none;" />').mousedown(toggleWikiTextEditor).prependTo($template);var $templateDialog=$('<span />').addClass('wikiEditor-template-dialog wikiEditor-noinclude').append('<img src="'+$.wikiEditor.autoIcon('templateEditor/dialog-collapsed.png')+'" width="22" height="16" />').append('<img src="'+$.wikiEditor.autoIcon('templateEditor/dialog-expanded.png')+'" width="22" height="16" style="display:none;" />').mousedown(function(){createDialog($template);return false;}).insertAfter($templateName);function toggleWikiTextEditor(){context.fn.purgeOffsets();var $template=$(this).closest('.wikiEditor-template');$template.toggleClass('wikiEditor-template-expanded').toggleClass('wikiEditor-template-collapsed').find('img').each(function(){$(this).toggle();});var $wikitext=$template.children('.wikiEditor-template-text');$wikitext.toggleClass('wikiEditor-nodisplay');if($template.hasClass('wikiEditor-template-collapsed')){var model=new $.wikiEditor.modules.templateEditor.fn.model($template.children('.wikiEditor-template-text').text());$template.children('.wikiEditor-template-text').data('model',model);$template.children('.wikiEditor-template-name').text(model.getName());}else{$wikitext.text($template.children('.wikiEditor-template-text').data('model').getText());} |
| 646 | +return false;};var dialog={'titleMsg':'wikieditor-template-editor-dialog-title','id':'wikiEditor-template-dialog','html':'\ |
646 | 647 | <fieldset>\ |
647 | 648 | <div class="wikiEditor-template-dialog-title" />\ |
648 | 649 | <table class="wikiEditor-template-dialog-table" />\ |
649 | 650 | </fieldset>',init:function(){$(this).find('[rel]').each(function(){$(this).text(mw.usability.getMsg($(this).attr('rel')));});},dialog:{width:500,dialogClass:'wikiEditor-toolbar-dialog',buttons:{'wikieditor-template-editor-dialog-submit':function(){var $templateDiv=$(this).data('templateDiv');context.fn.highlightLine($templateDiv);var $templateText=$templateDiv.children('.wikiEditor-template-text');var templateModel=$templateText.data('model');$(this).find('.wikiEditor-template-dialog-value input').each(function(){templateModel.setValue($(this).data('name'),$(this).val());});$templateText.text(templateModel.getText());$(this).dialog('close');}},open:function(){var $templateDiv=$(this).data('templateDiv');var $templateText=$templateDiv.children('.wikiEditor-template-text');var templateModel=$templateText.data('model');if(templateModel.getText()!=$templateText.text()){templateModel=new $.wikiEditor.modules.templateEditor.fn.model($templateText.text());$templateText.data('model',templateModel);} |
650 | | -var params=templateModel.getAllInitialParams();var $table=$(this).find('.wikiEditor-template-dialog-table').empty();for(var paramIndex in params){var param=params[paramIndex];if(typeof param.name=='undefined'){continue;} |
651 | | -var $paramRow=$('<tr />').addClass('wikiEditor-template-dialog-row');$('<td />').addClass('wikiEditor-template-dialog-label').text(typeof param=='string'?param.name.replace(/[\_\-]/g,' '):param.name).appendTo($paramRow);$('<td />').addClass('wikiEditor-template-dialog-value').append($('<input />').data('name',param.name).val(templateModel.getValue(param.name))).appendTo($paramRow);$table.append($paramRow);}}}};function createDialog($templateDiv){context.$textarea.wikiEditor('addDialog',{'templateEditor':dialog});$('#'+dialog.id).data('templateDiv',$templateDiv).dialog('open');} |
652 | | -function noEdit(){return false;}},unwrapTemplate:function($wrapper){$wrapper.parent().replaceWith($wrapper);},getTemplateInfo:function(templateName){var templateInfo='';return $(templateInfo);},model:function(wikitext){var collapsible=true;function Param(name,value,number,nameIndex,equalsIndex,valueIndex){this.name=name;this.value=value;this.number=number;this.nameIndex=nameIndex;this.equalsIndex=equalsIndex;this.valueIndex=valueIndex;} |
| 651 | +var params=templateModel.getAllInitialParams();var $table=$(this).find('.wikiEditor-template-dialog-table').empty();var $rows=$table.find('tr');for(var paramIndex in params){var param=params[paramIndex];if(typeof param.name=='undefined'){continue;} |
| 652 | +var paramText=typeof param=='string'?param.name.replace(/[\_\-]/g,' '):param.name;var paramVal=templateModel.getValue(param.name);if($rows.length>0){var $row=$rows.eq(0);$row.children('.wikiEditor-template-dialog-label').text(paramText);$row.children('.wikiEditor-template-dialog-value input').val(paramVal);$rows=$rows.not($row);}else{var $paramRow=$('<tr />').addClass('wikiEditor-template-dialog-row');$('<td />').addClass('wikiEditor-template-dialog-label').text(paramText).appendTo($paramRow);$('<td />').addClass('wikiEditor-template-dialog-value').append($('<input />').data('name',param.name).val(paramVal)).appendTo($paramRow);$table.append($paramRow);} |
| 653 | +$rows.remove();}}}};function createDialog($templateDiv){context.$textarea.wikiEditor('addDialog',{'templateEditor':dialog});$('#'+dialog.id).data('templateDiv',$templateDiv).dialog('open');}},unwrapTemplate:function($wrapper){$wrapper.parent().replaceWith($wrapper);},getTemplateInfo:function(templateName){var templateInfo='';return $(templateInfo);},model:function(wikitext){var collapsible=true;function Param(name,value,number,nameIndex,equalsIndex,valueIndex){this.name=name;this.value=value;this.number=number;this.nameIndex=nameIndex;this.equalsIndex=equalsIndex;this.valueIndex=valueIndex;} |
653 | 654 | function Range(begin,end){this.begin=begin;this.end=end;} |
654 | 655 | function getSetValue(name,value,original){var valueRange;var rangeIndex;var retVal;if(isNaN(name)){if(typeof paramsByName[name]=='undefined'){return"";} |
655 | 656 | rangeIndex=paramsByName[name];}else{rangeIndex=parseInt(name);} |