r63580 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63579‎ | r63580 | r63581 >
Date:00:00, 11 March 2010
Author:adam
Status:ok
Tags:
Comment:
Template Editor: Seperating the template wrapping code from the event binding code
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -78,14 +78,14 @@
7979 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 21 ),
8080 array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 97 ),
8181 array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 11 ),
82 - array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 47 ),
 82+ array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 48 ),
8383 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 3 ),
8484 ),
8585 'combined' => array(
86 - array( 'src' => 'js/plugins.combined.js', 'version' => 322 ),
 86+ array( 'src' => 'js/plugins.combined.js', 'version' => 323 ),
8787 ),
8888 'minified' => array(
89 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 322 ),
 89+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 323 ),
9090 ),
9191 ),
9292 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js
@@ -67,6 +67,7 @@
6868 var model = $.wikiEditor.modules.templateEditor.fn.updateModel( $( node ) );
6969 if ( model.isCollapsible() ) {
7070 $.wikiEditor.modules.templateEditor.fn.wrapTemplate( $( node ) );
 71+ $.wikiEditor.modules.templateEditor.fn.bindTemplateEvents( $( node ) );
7172 } else {
7273 $( node ).addClass( 'wikiEditor-template-text' );
7374 }
@@ -100,6 +101,7 @@
101102 } else if ( !$( node ).parent().hasClass( 'wikiEditor-template' ) &&
102103 model.isCollapsible() ) {
103104 $.wikiEditor.modules.templateEditor.fn.wrapTemplate( $( node ) );
 105+ $.wikiEditor.modules.templateEditor.fn.bindTemplateEvents( $( node ) );
104106 }
105107 },
106108 getAnchor: function( ca1, ca2 ) {
@@ -148,43 +150,66 @@
149151 wrapTemplate: function( $wrapper ) {
150152 var model = $wrapper.data( 'model' );
151153 var context = $wrapper.data( 'marker' ).context;
152 -
153154 var $template = $wrapper
154155 .wrap( '<span class="wikiEditor-template"></span>' )
155156 .addClass( 'wikiEditor-template-text wikiEditor-nodisplay' )
156157 .parent()
157158 .addClass( 'wikiEditor-template-collapsed' );
158 -
159159 var $templateName = $( '<span />' )
160160 .addClass( 'wikiEditor-template-name wikiEditor-noinclude' )
161161 .text( model.getName() )
162 - .click( function() { createDialog( $template ); return false; } )
163 - .mousedown( function() { return false; } )
164162 .prependTo( $template );
165 -
166163 var $templateExpand = $( '<span />' )
167164 .addClass( 'wikiEditor-template-expand wikiEditor-noinclude' )
168 - .click( toggleWikiTextEditor )
169 - .mousedown( function() { return false; } )
170165 .prependTo( $template );
171 -
172166 var $templateDialog = $( '<span />' )
173167 .addClass( 'wikiEditor-template-dialog wikiEditor-noinclude' )
174 - .click( function() { createDialog( $template ); return false; } )
175 - .mousedown( function() { return false; } )
176168 .appendTo( $templateName );
177 -
178 - function toggleWikiTextEditor() {
179 - context.fn.purgeOffsets();
180 - $(this)
181 - .closest( '.wikiEditor-template' )
182 - .toggleClass( 'wikiEditor-template-expanded' )
183 - .toggleClass( 'wikiEditor-template-collapsed' )
184 - .find( '.wikiEditor-template-text' )
185 - .toggleClass( 'wikiEditor-nodisplay' );
186 - return false;
187 - };
188 -
 169+ },
 170+ /**
 171+ * Turn a complex template wrapper back into a simple one
 172+ * @param $wrapper Wrapping <span>
 173+ */
 174+ unwrapTemplate: function( $wrapper ) {
 175+ $wrapper.parent().replaceWith( $wrapper );
 176+ },
 177+ /**
 178+ * Bind events to a template
 179+ * @param $wrapper Original wrapper for the template to bind events to
 180+ */
 181+ bindTemplateEvents: function( $wrapper ) {
 182+ var $template = $wrapper.parent( '.wikiEditor-template' );
 183+ $template.find( '.wikiEditor-template-name' )
 184+ .click( function() { $.wikiEditor.modules.templateEditor.fn.createDialog( $wrapper ); return false; } )
 185+ .mousedown( function() { return false; } );
 186+ $template.find( '.wikiEditor-template-expand' )
 187+ .click( function() { $.wikiEditor.modules.templateEditor.fn.toggleWikiTextEditor( $wrapper ); return false; } )
 188+ .mousedown( function() { return false; } );
 189+ $template.find( '.wikiEditor-template-dialog' )
 190+ .click( function() { $.wikiEditor.modules.templateEditor.fn.createDialog( $wrapper ); return false; } )
 191+ .mousedown( function() { return false; } );
 192+ },
 193+ /**
 194+ * Toggle the visisbilty of the wikitext for a given template
 195+ * @param $wrapper The origianl wrapper we want expand/collapse
 196+ */
 197+ toggleWikiTextEditor: function( $wrapper ) {
 198+ var context = $wrapper.data( 'marker' ).context;
 199+ var $template = $wrapper.parent( '.wikiEditor-template' );
 200+ context.fn.purgeOffsets();
 201+ $template
 202+ .toggleClass( 'wikiEditor-template-expanded' )
 203+ .toggleClass( 'wikiEditor-template-collapsed' )
 204+ .find( '.wikiEditor-template-text' )
 205+ .toggleClass( 'wikiEditor-nodisplay' );
 206+ },
 207+ /**
 208+ * Create a dialog for editing a given template and open it
 209+ * @param $wrapper The origianl wrapper for which to create the dialog
 210+ */
 211+ createDialog: function( $wrapper ) {
 212+ var context = $wrapper.data( 'marker' ).context;
 213+ var $template = $wrapper.parent( '.wikiEditor-template' );
189214 var dialog = {
190215 'titleMsg': 'wikieditor-template-editor-dialog-title',
191216 'id': 'wikiEditor-template-dialog',
@@ -207,7 +232,7 @@
208233 // More user feedback
209234 var $templateDiv = $( this ).data( 'templateDiv' );
210235 context.fn.highlightLine( $templateDiv );
211 -
 236+
212237 var $templateText = $templateDiv.children( '.wikiEditor-template-text' );
213238 var templateModel = $templateText.data( 'model' );
214239 $( this ).find( '.wikiEditor-template-dialog-field-wrapper textarea' ).each( function() {
@@ -216,7 +241,7 @@
217242 });
218243 //keep text consistent
219244 $.wikiEditor.modules.templateEditor.fn.updateModel( $templateText, templateModel );
220 -
 245+
221246 $( this ).dialog( 'close' );
222247 },
223248 'wikieditor-template-editor-dialog-cancel': function() {
@@ -231,7 +256,7 @@
232257 if ( $templateText.html() != $templateText.data( 'oldHTML' ) ) {
233258 templateModel = $.wikiEditor.modules.templateEditor.fn.updateModel( $templateText );
234259 }
235 -
 260+
236261 // Build the table
237262 // TODO: Be smart and recycle existing table
238263 var params = templateModel.getAllInitialParams();
@@ -294,7 +319,7 @@
295320 .appendTo( $fields );
296321 }
297322 }
298 -
 323+
299324 // Remove any leftover rows
300325 $rows.remove();
301326 $fields.find( 'label' ).autoEllipsis();
@@ -304,24 +329,13 @@
305330 }
306331 }
307332 };
308 -
309 - function createDialog( $templateDiv ) {
310 - // Lazy-create the dialog at this time
311 - context.$textarea.wikiEditor( 'addDialog', { 'templateEditor': dialog } );
312 - $( '#' + dialog.id )
313 - .data( 'templateDiv', $templateDiv )
314 - .dialog( 'open' );
315 - }
 333+ // Lazy-create the dialog at this time
 334+ context.$textarea.wikiEditor( 'addDialog', { 'templateEditor': dialog } );
 335+ $( '#' + dialog.id )
 336+ .data( 'templateDiv', $template )
 337+ .dialog( 'open' );
316338 },
317339 /**
318 - * Turn a complex template wrapper back into a simple one
319 - * @param $wrapper Wrapping <span>
320 - */
321 - unwrapTemplate: function( $wrapper ) {
322 - $wrapper.parent().replaceWith( $wrapper );
323 - },
324 -
325 - /**
326340 * Update a template's model and HTML
327341 * @param $templateText Wrapper <span> containing the template text
328342 * @param model Template model to use, will be generated if not set
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -9310,6 +9310,7 @@
93119311 var model = $.wikiEditor.modules.templateEditor.fn.updateModel( $( node ) );
93129312 if ( model.isCollapsible() ) {
93139313 $.wikiEditor.modules.templateEditor.fn.wrapTemplate( $( node ) );
 9314+ $.wikiEditor.modules.templateEditor.fn.bindTemplateEvents( $( node ) );
93149315 } else {
93159316 $( node ).addClass( 'wikiEditor-template-text' );
93169317 }
@@ -9343,6 +9344,7 @@
93449345 } else if ( !$( node ).parent().hasClass( 'wikiEditor-template' ) &&
93459346 model.isCollapsible() ) {
93469347 $.wikiEditor.modules.templateEditor.fn.wrapTemplate( $( node ) );
 9348+ $.wikiEditor.modules.templateEditor.fn.bindTemplateEvents( $( node ) );
93479349 }
93489350 },
93499351 getAnchor: function( ca1, ca2 ) {
@@ -9391,43 +9393,66 @@
93929394 wrapTemplate: function( $wrapper ) {
93939395 var model = $wrapper.data( 'model' );
93949396 var context = $wrapper.data( 'marker' ).context;
9395 -
93969397 var $template = $wrapper
93979398 .wrap( '<span class="wikiEditor-template"></span>' )
93989399 .addClass( 'wikiEditor-template-text wikiEditor-nodisplay' )
93999400 .parent()
94009401 .addClass( 'wikiEditor-template-collapsed' );
9401 -
94029402 var $templateName = $( '<span />' )
94039403 .addClass( 'wikiEditor-template-name wikiEditor-noinclude' )
94049404 .text( model.getName() )
9405 - .click( function() { createDialog( $template ); return false; } )
9406 - .mousedown( function() { return false; } )
94079405 .prependTo( $template );
9408 -
94099406 var $templateExpand = $( '<span />' )
94109407 .addClass( 'wikiEditor-template-expand wikiEditor-noinclude' )
9411 - .click( toggleWikiTextEditor )
9412 - .mousedown( function() { return false; } )
94139408 .prependTo( $template );
9414 -
94159409 var $templateDialog = $( '<span />' )
94169410 .addClass( 'wikiEditor-template-dialog wikiEditor-noinclude' )
9417 - .click( function() { createDialog( $template ); return false; } )
9418 - .mousedown( function() { return false; } )
94199411 .appendTo( $templateName );
9420 -
9421 - function toggleWikiTextEditor() {
9422 - context.fn.purgeOffsets();
9423 - $(this)
9424 - .closest( '.wikiEditor-template' )
9425 - .toggleClass( 'wikiEditor-template-expanded' )
9426 - .toggleClass( 'wikiEditor-template-collapsed' )
9427 - .find( '.wikiEditor-template-text' )
9428 - .toggleClass( 'wikiEditor-nodisplay' );
9429 - return false;
9430 - };
9431 -
 9412+ },
 9413+ /**
 9414+ * Turn a complex template wrapper back into a simple one
 9415+ * @param $wrapper Wrapping <span>
 9416+ */
 9417+ unwrapTemplate: function( $wrapper ) {
 9418+ $wrapper.parent().replaceWith( $wrapper );
 9419+ },
 9420+ /**
 9421+ * Bind events to a template
 9422+ * @param $wrapper Original wrapper for the template to bind events to
 9423+ */
 9424+ bindTemplateEvents: function( $wrapper ) {
 9425+ var $template = $wrapper.parent( '.wikiEditor-template' );
 9426+ $template.find( '.wikiEditor-template-name' )
 9427+ .click( function() { $.wikiEditor.modules.templateEditor.fn.createDialog( $wrapper ); return false; } )
 9428+ .mousedown( function() { return false; } );
 9429+ $template.find( '.wikiEditor-template-expand' )
 9430+ .click( function() { $.wikiEditor.modules.templateEditor.fn.toggleWikiTextEditor( $wrapper ); return false; } )
 9431+ .mousedown( function() { return false; } );
 9432+ $template.find( '.wikiEditor-template-dialog' )
 9433+ .click( function() { $.wikiEditor.modules.templateEditor.fn.createDialog( $wrapper ); return false; } )
 9434+ .mousedown( function() { return false; } );
 9435+ },
 9436+ /**
 9437+ * Toggle the visisbilty of the wikitext for a given template
 9438+ * @param $wrapper The origianl wrapper we want expand/collapse
 9439+ */
 9440+ toggleWikiTextEditor: function( $wrapper ) {
 9441+ var context = $wrapper.data( 'marker' ).context;
 9442+ var $template = $wrapper.parent( '.wikiEditor-template' );
 9443+ context.fn.purgeOffsets();
 9444+ $template
 9445+ .toggleClass( 'wikiEditor-template-expanded' )
 9446+ .toggleClass( 'wikiEditor-template-collapsed' )
 9447+ .find( '.wikiEditor-template-text' )
 9448+ .toggleClass( 'wikiEditor-nodisplay' );
 9449+ },
 9450+ /**
 9451+ * Create a dialog for editing a given template and open it
 9452+ * @param $wrapper The origianl wrapper for which to create the dialog
 9453+ */
 9454+ createDialog: function( $wrapper ) {
 9455+ var context = $wrapper.data( 'marker' ).context;
 9456+ var $template = $wrapper.parent( '.wikiEditor-template' );
94329457 var dialog = {
94339458 'titleMsg': 'wikieditor-template-editor-dialog-title',
94349459 'id': 'wikiEditor-template-dialog',
@@ -9450,7 +9475,7 @@
94519476 // More user feedback
94529477 var $templateDiv = $( this ).data( 'templateDiv' );
94539478 context.fn.highlightLine( $templateDiv );
9454 -
 9479+
94559480 var $templateText = $templateDiv.children( '.wikiEditor-template-text' );
94569481 var templateModel = $templateText.data( 'model' );
94579482 $( this ).find( '.wikiEditor-template-dialog-field-wrapper textarea' ).each( function() {
@@ -9459,7 +9484,7 @@
94609485 });
94619486 //keep text consistent
94629487 $.wikiEditor.modules.templateEditor.fn.updateModel( $templateText, templateModel );
9463 -
 9488+
94649489 $( this ).dialog( 'close' );
94659490 },
94669491 'wikieditor-template-editor-dialog-cancel': function() {
@@ -9474,7 +9499,7 @@
94759500 if ( $templateText.html() != $templateText.data( 'oldHTML' ) ) {
94769501 templateModel = $.wikiEditor.modules.templateEditor.fn.updateModel( $templateText );
94779502 }
9478 -
 9503+
94799504 // Build the table
94809505 // TODO: Be smart and recycle existing table
94819506 var params = templateModel.getAllInitialParams();
@@ -9537,7 +9562,7 @@
95389563 .appendTo( $fields );
95399564 }
95409565 }
9541 -
 9566+
95429567 // Remove any leftover rows
95439568 $rows.remove();
95449569 $fields.find( 'label' ).autoEllipsis();
@@ -9547,24 +9572,13 @@
95489573 }
95499574 }
95509575 };
9551 -
9552 - function createDialog( $templateDiv ) {
9553 - // Lazy-create the dialog at this time
9554 - context.$textarea.wikiEditor( 'addDialog', { 'templateEditor': dialog } );
9555 - $( '#' + dialog.id )
9556 - .data( 'templateDiv', $templateDiv )
9557 - .dialog( 'open' );
9558 - }
 9576+ // Lazy-create the dialog at this time
 9577+ context.$textarea.wikiEditor( 'addDialog', { 'templateEditor': dialog } );
 9578+ $( '#' + dialog.id )
 9579+ .data( 'templateDiv', $template )
 9580+ .dialog( 'open' );
95599581 },
95609582 /**
9561 - * Turn a complex template wrapper back into a simple one
9562 - * @param $wrapper Wrapping <span>
9563 - */
9564 - unwrapTemplate: function( $wrapper ) {
9565 - $wrapper.parent().replaceWith( $wrapper );
9566 - },
9567 -
9568 - /**
95699583 * Update a template's model and HTML
95709584 * @param $templateText Wrapper <span> containing the template text
95719585 * @param model Template model to use, will be generated if not set
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -645,16 +645,16 @@
646646 $('#wikiEditor-'+context.instance+'-dialog-watch').hide();else if($('#wpWatchthis').is(':checked'))
647647 $('#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++;}
648648 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;}}}
649 -if(endIndex!=-1){markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,type:'template',anchor:'wrap',afterWrap:function(node){var model=$.wikiEditor.modules.templateEditor.fn.updateModel($(node));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).html()==$(node).data('oldHTML')){return;}
 649+if(endIndex!=-1){markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,type:'template',anchor:'wrap',afterWrap:function(node){var model=$.wikiEditor.modules.templateEditor.fn.updateModel($(node));if(model.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.wrapTemplate($(node));$.wikiEditor.modules.templateEditor.fn.bindTemplateEvents($(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).html()==$(node).data('oldHTML')){return;}
650650 var model=$.wikiEditor.modules.templateEditor.fn.updateModel($(node));if($(node).parent().hasClass('wikiEditor-template')){var $name=$(node).parent().children('.wikiEditor-template-name');if($name.text()!=model.getName()){$name.text(model.getName());}}
651 -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');var $templateName=$('<span />').addClass('wikiEditor-template-name wikiEditor-noinclude').text(model.getName()).click(function(){createDialog($template);return false;}).mousedown(function(){return false;}).prependTo($template);var $templateExpand=$('<span />').addClass('wikiEditor-template-expand wikiEditor-noinclude').click(toggleWikiTextEditor).mousedown(function(){return false;}).prependTo($template);var $templateDialog=$('<span />').addClass('wikiEditor-template-dialog wikiEditor-noinclude').click(function(){createDialog($template);return false;}).mousedown(function(){return false;}).appendTo($templateName);function toggleWikiTextEditor(){context.fn.purgeOffsets();$(this).closest('.wikiEditor-template').toggleClass('wikiEditor-template-expanded').toggleClass('wikiEditor-template-collapsed').find('.wikiEditor-template-text').toggleClass('wikiEditor-nodisplay');return false;};var dialog={'titleMsg':'wikieditor-template-editor-dialog-title','id':'wikiEditor-template-dialog','html':'\
 651+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));$.wikiEditor.modules.templateEditor.fn.bindTemplateEvents($(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');var $templateName=$('<span />').addClass('wikiEditor-template-name wikiEditor-noinclude').text(model.getName()).prependTo($template);var $templateExpand=$('<span />').addClass('wikiEditor-template-expand wikiEditor-noinclude').prependTo($template);var $templateDialog=$('<span />').addClass('wikiEditor-template-dialog wikiEditor-noinclude').appendTo($templateName);},unwrapTemplate:function($wrapper){$wrapper.parent().replaceWith($wrapper);},bindTemplateEvents:function($wrapper){var $template=$wrapper.parent('.wikiEditor-template');$template.find('.wikiEditor-template-name').click(function(){$.wikiEditor.modules.templateEditor.fn.createDialog($wrapper);return false;}).mousedown(function(){return false;});$template.find('.wikiEditor-template-expand').click(function(){$.wikiEditor.modules.templateEditor.fn.toggleWikiTextEditor($wrapper);return false;}).mousedown(function(){return false;});$template.find('.wikiEditor-template-dialog').click(function(){$.wikiEditor.modules.templateEditor.fn.createDialog($wrapper);return false;}).mousedown(function(){return false;});},toggleWikiTextEditor:function($wrapper){var context=$wrapper.data('marker').context;var $template=$wrapper.parent('.wikiEditor-template');context.fn.purgeOffsets();$template.toggleClass('wikiEditor-template-expanded').toggleClass('wikiEditor-template-collapsed').find('.wikiEditor-template-text').toggleClass('wikiEditor-nodisplay');},createDialog:function($wrapper){var context=$wrapper.data('marker').context;var $template=$wrapper.parent('.wikiEditor-template');var dialog={'titleMsg':'wikieditor-template-editor-dialog-title','id':'wikiEditor-template-dialog','html':'\
652652 <fieldset>\
653653 <div class="wikiEditor-template-dialog-title" />\
654654 <div class="wikiEditor-template-dialog-fields" />\
655655 </fieldset>',init:function(){$(this).find('[rel]').each(function(){$(this).text(mw.usability.getMsg($(this).attr('rel')));});},dialog:{width:600,height:400,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-field-wrapper textarea').each(function(){templateModel.setValue($(this).data('name'),$(this).val());});$.wikiEditor.modules.templateEditor.fn.updateModel($templateText,templateModel);$(this).dialog('close');},'wikieditor-template-editor-dialog-cancel':function(){$j(this).dialog('close');}},open:function(){var $templateDiv=$(this).data('templateDiv');var $templateText=$templateDiv.children('.wikiEditor-template-text');var templateModel=$templateText.data('model');if($templateText.html()!=$templateText.data('oldHTML')){templateModel=$.wikiEditor.modules.templateEditor.fn.updateModel($templateText);}
656656 var params=templateModel.getAllInitialParams();var $fields=$(this).find('.wikiEditor-template-dialog-fields');var $rows=$fields.find('.wikiEditor-template-dialog-field-wrapper');for(var paramIndex in params){var param=params[paramIndex];if(typeof param.name=='undefined'){continue;}
657657 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('label').text(paramText);$row.children('textarea').data('name',param.name).val(paramVal).change();$rows=$rows.not($row);}else{var $paramRow=$('<div />').addClass('wikiEditor-template-dialog-field-wrapper');$('<label />').text(paramText).appendTo($paramRow);$('<textarea />').data('name',param.name).val(paramVal).css('height',$(this).val().length>24?'4.5em':'1.5em').data('expanded',false).bind('cut paste keypress click change',function(e){if(e.keyCode=='9')return true;var $this=$(this);setTimeout(function(){var expanded=$this.data('expanded');if($this.val().indexOf('\n')!=-1||$this.val().length>24){if(!expanded){$this.animate({'height':'4.5em'},'fast');$this.data('expanded',true);}}else{if(expanded){$this.animate({'height':'1.5em'},'fast');$this.data('expanded',false);}}},0);}).appendTo($paramRow);$paramRow.append('<div style="clear:both"></div>').appendTo($fields);}}
658 -$rows.remove();$fields.find('label').autoEllipsis();$(this).parent('.ui-dialog').find('.ui-dialog-titlebar-close').removeClass('ui-state-focus');}}};function createDialog($templateDiv){context.$textarea.wikiEditor('addDialog',{'templateEditor':dialog});$('#'+dialog.id).data('templateDiv',$templateDiv).dialog('open');}},unwrapTemplate:function($wrapper){$wrapper.parent().replaceWith($wrapper);},updateModel:function($templateText,model){var context=$templateText.data('marker').context;var text;if(typeof model=='undefined'){text=context.fn.htmlToText($templateText.html());}else{text=model.getText();}
 658+$rows.remove();$fields.find('label').autoEllipsis();$(this).parent('.ui-dialog').find('.ui-dialog-titlebar-close').removeClass('ui-state-focus');}}};context.$textarea.wikiEditor('addDialog',{'templateEditor':dialog});$('#'+dialog.id).data('templateDiv',$template).dialog('open');},updateModel:function($templateText,model){var context=$templateText.data('marker').context;var text;if(typeof model=='undefined'){text=context.fn.htmlToText($templateText.html());}else{text=model.getText();}
659659 $templateText.text(text);$templateText.html($templateText.html().replace(/\n/g,'<br />'));$templateText.data('oldHTML',$templateText.html());if(typeof model=='undefined'){model=new $.wikiEditor.modules.templateEditor.fn.model(text);$templateText.data('model',model);}
660660 return model;},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;}
661661 function Range(begin,end){this.begin=begin;this.end=end;}

Status & tagging log