r60936 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60935‎ | r60936 | r60937 >
Date:18:55, 11 January 2010
Author:adam
Status:ok
Tags:
Comment:
wikiEditor templateEditor - implimenting wikitext mode and improving dom structure. A few dialog tweaks as well.
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/css/combined.css (modified) (history)
  • /trunk/extensions/UsabilityInitiative/css/combined.min.css (modified) (history)
  • /trunk/extensions/UsabilityInitiative/css/wikiEditor.dialogs.css (modified) (history)
  • /trunk/extensions/UsabilityInitiative/images/wikiEditor/templateEditor (added) (history)
  • /trunk/extensions/UsabilityInitiative/images/wikiEditor/templateEditor/wiki-text.png (added) (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.highlight.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.html (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -23,6 +23,7 @@
2424 array( 'src' => 'css/wikiEditor.css', 'version' => 7 ),
2525 array( 'src' => 'css/wikiEditor.dialogs.css', 'version' => 10 ),
2626 array( 'src' => 'css/wikiEditor.preview.css', 'version' => 1 ),
 27+ array( 'src' => 'css/wikiEditor.templateEditor.css', 'version' => 1 ),
2728 array( 'src' => 'css/wikiEditor.toc.css', 'version' => 25 ),
2829 array( 'src' => 'css/wikiEditor.toolbar.css', 'version' => 8 ),
2930 array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2y' ),
Index: trunk/extensions/UsabilityInitiative/images/wikiEditor/templateEditor/wiki-text.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/UsabilityInitiative/images/wikiEditor/templateEditor/wiki-text.png
___________________________________________________________________
Name: svn:mime-type
3031 + application/octet-stream
Index: trunk/extensions/UsabilityInitiative/css/wikiEditor.dialogs.css
@@ -22,6 +22,13 @@
2323 padding: 2px 1px;
2424 }
2525
 26+
 27+.ui-dialog .ui-dialog-titlebar {
 28+ padding: 0.75em 20px !important;
 29+}
 30+.ui-widget table td {
 31+ padding: 0 !important;
 32+}
2633 .ui-dialog .ui-dialog-buttonpane button.disabled {
2734 color: #7f7f7f;
2835 background: #f2f2f2;
Index: trunk/extensions/UsabilityInitiative/css/combined.css
@@ -231,6 +231,13 @@
232232 padding: 2px 1px;
233233 }
234234
 235+
 236+.ui-dialog .ui-dialog-titlebar {
 237+ padding: 0.75em 20px !important;
 238+}
 239+.ui-widget table td {
 240+ padding: 0 !important;
 241+}
235242 .ui-dialog .ui-dialog-buttonpane button.disabled {
236243 color: #7f7f7f;
237244 background: #f2f2f2;
Index: trunk/extensions/UsabilityInitiative/css/combined.min.css
@@ -216,6 +216,12 @@
217217 border:2px solid red;
218218 padding:2px 1px;
219219 }
 220+.ui-dialog .ui-dialog-titlebar{
 221+padding:0.75em 20px !important;
 222+}
 223+.ui-widget table td{
 224+padding:0 !important;
 225+}
220226 .ui-dialog .ui-dialog-buttonpane button.disabled{
221227 color:#7f7f7f;
222228 background:#f2f2f2;
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js
@@ -65,6 +65,11 @@
6666 { 'regex': /}}/, 'label': "TEMPLATE_END", 'markAfter': true }
6767 ],
6868 /**
 69+ * Configuration
 70+ */
 71+cfg: {
 72+},
 73+/**
6974 * Internally used functions
7075 */
7176 fn: {
@@ -83,17 +88,40 @@
8489 // We have a model, so all this init stuff has already happened
8590 return;
8691 }
87 - // Hide this
88 - $(this).addClass( 'wikiEditor-nodisplay wikiEditor-template' );
8992 // Build a model for this
90 - $(this).data( 'model' , new $.wikiEditor.modules.templateEditor.fn.model( $(this).text() ) );
91 - var model = $(this).data( 'model' );
 93+ var model = new $.wikiEditor.modules.templateEditor.fn.model( $( this ).text() );
 94+ var $template = $( this )
 95+ .wrap( '<div class="wikiEditor-template"></div>' )
 96+ .addClass( 'wikiEditor-template-text wikiEditor-nodisplay' )
 97+ .html(
 98+ // Wrap the start and end of the wikitext in spans so we can bind events to them
 99+ $( this ).html()
 100+ .replace( /\{\{/, '<span class="wikiEditor-template-start">{{</span>' )
 101+ .replace( /\}\}/, '<span class="wikiEditor-template-end">}}</span>' ) )
 102+ .parent()
 103+ .addClass( 'wikiEditor-template-collapsed' )
 104+ .data( 'model', model );
 105+ $( '<span />' )
 106+ .addClass( 'wikiEditor-template-name wikiEditor-noinclude' )
 107+ .text( model.getName() )
 108+ .mousedown( noEdit )
 109+ .prependTo( $template );
 110+ $template.find( '.wikiEditor-template-end, .wikiEditor-template-start' ).mousedown( toggleWikiText );
 111+ $( '<ul />' )
 112+ .addClass( 'wikiEditor-template-modes wikiEditor-noinclude' )
 113+ .append( $( '<li />' )
 114+ .addClass( 'wikiEditor-template-action-wikiText' )
 115+ .append( $( '<img />' ).attr( 'src',
 116+ $.wikiEditor.imgPath + 'templateEditor/' + 'wiki-text.png' ) )
 117+ .mousedown( toggleWikiText ) )
 118+ .insertAfter( $template.find( '.wikiEditor-template-name' ) );
92119 // Expand
93120 function expandTemplate( $displayDiv ) {
94121 // Housekeeping
95122 $displayDiv.removeClass( 'wikiEditor-template-collapsed' );
96123 $displayDiv.addClass( 'wikiEditor-template-expanded' );
97 -
 124+ // remove mousedown hander from the entire thing
 125+ $displayDiv.unbind( 'mousedown' );
98126 //$displayDiv.text( model.getText() );
99127 $keyValueTable = $( '<table />' )
100128 .appendTo( $displayDiv );
@@ -122,23 +150,23 @@
123151 $displayDiv.removeClass( 'wikiEditor-template-expanded' );
124152 $displayDiv.text( model.getName() );
125153 };
126 - // Build the collapsed version of this template
127 - var $visibleDiv = $( "<div />" ).addClass( 'wikiEditor-noinclude' );
128 - // Let these two know about each other
129 - $(this).data( 'display', $visibleDiv );
130 - $visibleDiv.data( 'wikitext', $(this) );
131 - $(this).after( $visibleDiv );
132 - // Add click handler
133 - $visibleDiv.mousedown( function() {
134 - // Is collapsed, switch to expand
135 - if ( $(this).hasClass( 'wikiEditor-template-collapsed' ) ) {
136 - expandTemplate( $(this) );
137 - } else {
138 - collapseTemplate( $(this) );
139 - }
140 - });
141 - collapseTemplate( $visibleDiv );
 154+ function toggleWikiText( ) {
 155+ var $template = $( this ).closest( '.wikiEditor-template' );
 156+ $template
 157+ .toggleClass( 'wikiEditor-template-collapsed' )
 158+ .toggleClass( 'wikiEditor-template-expanded' )
 159+ .children( '.wikiEditor-template-text, .wikiEditor-template-name, .wikiEditor-template-modes' )
 160+ .toggleClass( 'wikiEditor-nodisplay' );
 161+ return false;
 162+ }
 163+ function noEdit() {
 164+ return false;
 165+ }
142166 });
 167+
 168+ function toggleWikiText ( context, template ) {
 169+
 170+ }
143171 },
144172
145173
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.html
@@ -13,7 +13,7 @@
1414
1515 /* Wikitext that's folded away and shouldn't be displayed */
1616 .wikiEditor-nodisplay {
17 - display: none;
 17+ display: none !important;
1818 }
1919
2020 /* A collapsed template */
@@ -21,19 +21,36 @@
2222 background-color:#DDEEFF;
2323 border:1px outset #DDEEFF;
2424 color:#333333;
25 - cursor:pointer;
26 - display:inline;
27 - padding:0 0.25em;
 25+ padding:0 0 0 0.25em;
 26+ display: inline;
 27+ margin:0 0.25em;
2828 text-decoration:none;
2929 }
30 -
 30+ ul.wikiEditor-template-modes,
 31+ ul.wikiEditor-template-modes li {
 32+ display: inline;
 33+ list-style: none;
 34+ margin: 0;
 35+ padding: 0;
 36+ }
 37+ ul.wikiEditor-template-modes {
 38+ padding: 0 0 0 0.15em;
 39+ }
 40+ ul.wikiEditor-template-modes li {
 41+ border-left: 1px solid #79848e;
 42+ margin: 0 1px;
 43+ cursor: pointer;
 44+ }
 45+ ul.wikiEditor-template-modes li img {
 46+ vertical-align: middle;
 47+ cursor: pointer !important;
 48+ }
3149 /* An expanded template */
3250 .wikiEditor-template-expanded {
3351 background:#DDEEFF none repeat scroll 0 0;
3452 border:1px inset #DDEEFF;
3553 color:black;
36 - cursor:pointer;
37 - display:inline;
 54+ margin:3px;
3855 padding:0 0.25em;
3956 }
4057
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js
@@ -5,7 +5,7 @@
66 * Configuration
77 */
88 cfg: {
9 - 'styleVersion': 2
 9+ 'styleVersion': 3
1010 },
1111 /**
1212 * Internally used event handlers
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -7241,7 +7241,7 @@
72427242 * Configuration
72437243 */
72447244 cfg: {
7245 - 'styleVersion': 2
 7245+ 'styleVersion': 3
72467246 },
72477247 /**
72487248 * Internally used event handlers
@@ -7903,6 +7903,11 @@
79047904 { 'regex': /}}/, 'label': "TEMPLATE_END", 'markAfter': true }
79057905 ],
79067906 /**
 7907+ * Configuration
 7908+ */
 7909+cfg: {
 7910+},
 7911+/**
79077912 * Internally used functions
79087913 */
79097914 fn: {
@@ -7921,17 +7926,40 @@
79227927 // We have a model, so all this init stuff has already happened
79237928 return;
79247929 }
7925 - // Hide this
7926 - $(this).addClass( 'wikiEditor-nodisplay wikiEditor-template' );
79277930 // Build a model for this
7928 - $(this).data( 'model' , new $.wikiEditor.modules.templateEditor.fn.model( $(this).text() ) );
7929 - var model = $(this).data( 'model' );
 7931+ var model = new $.wikiEditor.modules.templateEditor.fn.model( $( this ).text() );
 7932+ var $template = $( this )
 7933+ .wrap( '<div class="wikiEditor-template"></div>' )
 7934+ .addClass( 'wikiEditor-template-text wikiEditor-nodisplay' )
 7935+ .html(
 7936+ // Wrap the start and end of the wikitext in spans so we can bind events to them
 7937+ $( this ).html()
 7938+ .replace( /\{\{/, '<span class="wikiEditor-template-start">{{</span>' )
 7939+ .replace( /\}\}/, '<span class="wikiEditor-template-end">}}</span>' ) )
 7940+ .parent()
 7941+ .addClass( 'wikiEditor-template-collapsed' )
 7942+ .data( 'model', model );
 7943+ $( '<span />' )
 7944+ .addClass( 'wikiEditor-template-name wikiEditor-noinclude' )
 7945+ .text( model.getName() )
 7946+ .mousedown( noEdit )
 7947+ .prependTo( $template );
 7948+ $template.find( '.wikiEditor-template-end, .wikiEditor-template-start' ).mousedown( toggleWikiText );
 7949+ $( '<ul />' )
 7950+ .addClass( 'wikiEditor-template-modes wikiEditor-noinclude' )
 7951+ .append( $( '<li />' )
 7952+ .addClass( 'wikiEditor-template-action-wikiText' )
 7953+ .append( $( '<img />' ).attr( 'src',
 7954+ $.wikiEditor.imgPath + 'templateEditor/' + 'wiki-text.png' ) )
 7955+ .mousedown( toggleWikiText ) )
 7956+ .insertAfter( $template.find( '.wikiEditor-template-name' ) );
79307957 // Expand
79317958 function expandTemplate( $displayDiv ) {
79327959 // Housekeeping
79337960 $displayDiv.removeClass( 'wikiEditor-template-collapsed' );
79347961 $displayDiv.addClass( 'wikiEditor-template-expanded' );
7935 -
 7962+ // remove mousedown hander from the entire thing
 7963+ $displayDiv.unbind( 'mousedown' );
79367964 //$displayDiv.text( model.getText() );
79377965 $keyValueTable = $( '<table />' )
79387966 .appendTo( $displayDiv );
@@ -7960,23 +7988,23 @@
79617989 $displayDiv.removeClass( 'wikiEditor-template-expanded' );
79627990 $displayDiv.text( model.getName() );
79637991 };
7964 - // Build the collapsed version of this template
7965 - var $visibleDiv = $( "<div />" ).addClass( 'wikiEditor-noinclude' );
7966 - // Let these two know about each other
7967 - $(this).data( 'display', $visibleDiv );
7968 - $visibleDiv.data( 'wikitext', $(this) );
7969 - $(this).after( $visibleDiv );
7970 - // Add click handler
7971 - $visibleDiv.mousedown( function() {
7972 - // Is collapsed, switch to expand
7973 - if ( $(this).hasClass( 'wikiEditor-template-collapsed' ) ) {
7974 - expandTemplate( $(this) );
7975 - } else {
7976 - collapseTemplate( $(this) );
7977 - }
7978 - });
7979 - collapseTemplate( $visibleDiv );
 7992+ function toggleWikiText( ) {
 7993+ var $template = $( this ).closest( '.wikiEditor-template' );
 7994+ $template
 7995+ .toggleClass( 'wikiEditor-template-collapsed' )
 7996+ .toggleClass( 'wikiEditor-template-expanded' )
 7997+ .children( '.wikiEditor-template-text, .wikiEditor-template-name, .wikiEditor-template-modes' )
 7998+ .toggleClass( 'wikiEditor-nodisplay' );
 7999+ return false;
 8000+ }
 8001+ function noEdit() {
 8002+ return false;
 8003+ }
79808004 });
 8005+
 8006+ function toggleWikiText ( context, template ) {
 8007+
 8008+ }
79818009 },
79828010
79838011
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -470,7 +470,7 @@
471471 configuration.newButtons[gM(msg)]=configuration.buttons[msg];configuration.buttons=configuration.newButtons;var dialogDiv=$('<div /> ').attr('id',module.id).html(module.html).data('context',context).appendTo($('body')).each(module.init).dialog(configuration);if(!('resizeme'in module)||module.resizeme){dialogDiv.bind('dialogopen',$.wikiEditor.modules.dialogs.fn.resize).find('.ui-tabs').bind('tabsshow',function(){$(this).closest('.ui-dialog-content').each($.wikiEditor.modules.dialogs.fn.resize);});}
472472 var maxTI=0;$j('[tabindex]').each(function(){var ti=parseInt($j(this).attr('tabindex'));if(ti>maxTI)
473473 maxTI=ti;});var tabIndex=maxTI+1;$j('.ui-dialog input, .ui-dialog button').not('[tabindex]').each(function(){$j(this).attr('tabindex',tabIndex++);});}}});},resize:function(){var wrapper=$(this).closest('.ui-dialog');var oldWidth=wrapper.width();var oldHidden=$(this).find('*').not(':visible');oldHidden.each(function(){$(this).data('oldstyle',$(this).attr('style'));});oldHidden.show();var oldWS=$(this).css('white-space');$(this).css('white-space','nowrap');if(wrapper.width()<=$(this).get(0).scrollWidth){var thisWidth=$(this).data('thisWidth')?$(this).data('thisWidth'):0;thisWidth=Math.max($(this).get(0).scrollWidth,thisWidth);$(this).width(thisWidth);$(this).data('thisWidth',thisWidth);var wrapperWidth=$(this).data('wrapperWidth')?$(this).data('wrapperWidth'):0;wrapperWidth=Math.max(wrapper.get(0).scrollWidth,wrapperWidth);wrapper.width(wrapperWidth);$(this).data('wrapperWidth',wrapperWidth);$(this).dialog({'width':wrapper.width()});wrapper.css('left',parseInt(wrapper.css('left'))-(wrapper.width()-oldWidth)/2);}
474 -$(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={cfg:{'styleVersion':2},evt:{delayedChange:function(context,event){if(event.data.scope=='none'){$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},ready:function(context,event){if($.browser.msie&&$.browser.version>=8){if(!this.isSecondRun){this.isSecondRun=true;return;}}
 474+$(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={cfg:{'styleVersion':3},evt:{delayedChange:function(context,event){if(event.data.scope=='none'){$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},ready:function(context,event){if($.browser.msie&&$.browser.version>=8){if(!this.isSecondRun){this.isSecondRun=true;return;}}
475475 $.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},fn:{create:function(context,config){},divide:function(context){},isolate:function(context){return[];},strip:function(context,division){return $('<div />').html(division.html().replace(/\<br[^\>]*\>/g,"\n")).text();},scan:function(context,division){function Token(offset,label,tokenStart,match){this.offset=offset;this.label=label;this.tokenStart=tokenStart;this.match=match;}
476476 var tokenArray=context.modules.highlight.tokenArray=[];var text=context.fn.getContents();for(module in $.wikiEditor.modules){if('exp'in $.wikiEditor.modules[module]){for(var i=0;i<$.wikiEditor.modules[module].exp.length;i++){var regex=$.wikiEditor.modules[module].exp[i].regex;var label=$.wikiEditor.modules[module].exp[i].label;var markAfter=false;if(typeof $.wikiEditor.modules[module].exp[i].markAfter!='undefined'){markAfter=true;}
477477 match=text.match(regex);var oldOffset=0;while(match!=null){var markOffset=0;var tokenStart=match.index+oldOffset+markOffset;if(markAfter){markOffset+=match[0].length;}
@@ -527,8 +527,9 @@
528528 $('#wikiEditor-'+context.instance+'-dialog-watch').hide();else if($('#wpWatchthis').is(':checked'))
529529 $('#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={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++;}
530530 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;}}}
531 -if(endIndex!=-1){markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,afterWrap:$.wikiEditor.modules.templateEditor.fn.stylize,beforeUnwrap:function(node){$(node).data('display').remove();},getWrapper:function(ca1,ca2){return $(ca1.parentNode).is('div.wikiEditor-template')&&ca1.previousSibling==null&&ca1.nextSibling==null?ca1.parentNode:null;}});}else{tokenArray[beginIndex].label='TEMPLATE_FALSE_BEGIN';tokenIndex=beginIndex;}}}}},exp:[{'regex':/{{/,'label':"TEMPLATE_BEGIN"},{'regex':/}}/,'label':"TEMPLATE_END",'markAfter':true}],fn:{create:function(context,config){context.modules.templateEditor={};},stylize:function(wrappedTemplate){$(wrappedTemplate).each(function(){if(typeof $(this).data('model')!='undefined'){return;}
532 -$(this).addClass('wikiEditor-nodisplay wikiEditor-template');$(this).data('model',new $.wikiEditor.modules.templateEditor.fn.model($(this).text()));var model=$(this).data('model');function expandTemplate($displayDiv){$displayDiv.removeClass('wikiEditor-template-collapsed');$displayDiv.addClass('wikiEditor-template-expanded');$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');$displayDiv.removeClass('wikiEditor-template-expanded');$displayDiv.text(model.getName());};var $visibleDiv=$("<div />").addClass('wikiEditor-noinclude');$(this).data('display',$visibleDiv);$visibleDiv.data('wikitext',$(this));$(this).after($visibleDiv);$visibleDiv.mousedown(function(){if($(this).hasClass('wikiEditor-template-collapsed')){expandTemplate($(this));}else{collapseTemplate($(this));}});collapseTemplate($visibleDiv);});},getTemplateInfo:function(templateName){var templateInfo='';return $(templateInfo);},model:function(wikitext){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;}
 531+if(endIndex!=-1){markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,afterWrap:$.wikiEditor.modules.templateEditor.fn.stylize,beforeUnwrap:function(node){$(node).data('display').remove();},getWrapper:function(ca1,ca2){return $(ca1.parentNode).is('div.wikiEditor-template')&&ca1.previousSibling==null&&ca1.nextSibling==null?ca1.parentNode:null;}});}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={};},stylize:function(wrappedTemplate){$(wrappedTemplate).each(function(){if(typeof $(this).data('model')!='undefined'){return;}
 532+var model=new $.wikiEditor.modules.templateEditor.fn.model($(this).text());var $template=$(this).wrap('<div class="wikiEditor-template"></div>').addClass('wikiEditor-template-text wikiEditor-nodisplay').html($(this).html().replace(/\{\{/,'<span class="wikiEditor-template-start">{{</span>').replace(/\}\}/,'<span class="wikiEditor-template-end">}}</span>')).parent().addClass('wikiEditor-template-collapsed').data('model',model);$('<span />').addClass('wikiEditor-template-name wikiEditor-noinclude').text(model.getName()).mousedown(noEdit).prependTo($template);$template.find('.wikiEditor-template-end, .wikiEditor-template-start').mousedown(toggleWikiText);$('<ul />').addClass('wikiEditor-template-modes wikiEditor-noinclude').append($('<li />').addClass('wikiEditor-template-action-wikiText').append($('<img />').attr('src',$.wikiEditor.imgPath+'templateEditor/'+'wiki-text.png')).mousedown(toggleWikiText)).insertAfter($template.find('.wikiEditor-template-name'));function expandTemplate($displayDiv){$displayDiv.removeClass('wikiEditor-template-collapsed');$displayDiv.addClass('wikiEditor-template-expanded');$displayDiv.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');$displayDiv.removeClass('wikiEditor-template-expanded');$displayDiv.text(model.getName());};function toggleWikiText(){var $template=$(this).closest('.wikiEditor-template');$template.toggleClass('wikiEditor-template-collapsed').toggleClass('wikiEditor-template-expanded').children('.wikiEditor-template-text, .wikiEditor-template-name, .wikiEditor-template-modes').toggleClass('wikiEditor-nodisplay');return false;}
 533+function noEdit(){return false;}});function toggleWikiText(context,template){}},getTemplateInfo:function(templateName){var templateInfo='';return $(templateInfo);},model:function(wikitext){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;}
533534 function Range(begin,end){this.begin=begin;this.end=end;}
534535 function getSetValue(name,value,original){var valueRange;var rangeIndex;var retVal;if(isNaN(name)){if(typeof paramsByName[name]=='undefined'){return"";}
535536 rangeIndex=paramsByName[name];}else{rangeIndex=parseInt(name);}

Follow-up revisions

RevisionCommit summaryAuthorDate
r61386UsabilityInitiative: Remove reference to nonexistent file added in r60936catrope20:00, 22 January 2010

Status & tagging log