r61103 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61102‎ | r61103 | r61104 >
Date:22:29, 15 January 2010
Author:tparscal
Status:ok
Tags:
Comment:
Fixed some IE issues, but getContents is still causing parser issues.
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/Vector/Vector.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/Vector/Vector.combined.min.js (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.html (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/Vector/Vector.combined.js
@@ -120,8 +120,8 @@
121121 /* JavaScript for EditWarning extension */
122122
123123 mw.ready( function() {
124 - // Check if EditWarning is enabled
125 - if ( !wgVectorEnabledModules.editwarning ) {
 124+ // Check if EditWarning is enabled and if we need it
 125+ if ( !wgVectorEnabledModules.editwarning || $j( '#wpTextbox1' ).size() == 0 ) {
126126 return true;
127127 }
128128 // Get the original values of some form elements
Index: trunk/extensions/UsabilityInitiative/Vector/Vector.combined.min.js
@@ -3,7 +3,7 @@
44 $j('#panel').addClass('collapsible-nav');$j('#panel > div.portal:first').addClass('expanded').find('div.body').show();$j('#panel > div.portal:not(:first)').each(function(){if($j.cookie('vector-nav-'+$j(this).attr('id'))=='true'){$j(this).addClass('expanded').find('div.body').show();}else{$j(this).addClass('collapsed');}});$j('#panel > div.portal > h5').click(function(){$j.cookie('vector-nav-'+$j(this).parent().attr('id'),$j(this).parent().is('.collapsed'));$j(this).parent().toggleClass('expanded').toggleClass('collapsed').find('div.body').slideToggle('fast');return false;});});mw.ready(function(){if(!wgVectorEnabledModules.collapsibletabs){return true;}
55 var rtl=$j('body').is('.rtl');$j.collapsibleTabs.moveToCollapsed=function(ele){var $moving=$j(ele);$j($moving.data('collapsibleTabsSettings').expandedContainer).data('collapsibleTabsSettings').shifting=true;var data=$moving.data('collapsibleTabsSettings');var target=$moving.data('collapsibleTabsSettings').collapsedContainer;$moving.css("position","relative").css((rtl?'left':'right'),0).animate({width:'1px'},"normal",function(){$j(this).hide();$j('<span class="placeholder" style="display:none;"></span>').insertAfter(this);$j(this).remove().prependTo(target).data('collapsibleTabsSettings',data);$j(this).attr('style','display:list-item;');$j($j(ele).data('collapsibleTabsSettings').expandedContainer).data('collapsibleTabsSettings').shifting=false;$j.collapsibleTabs.handleResize();});};$j.collapsibleTabs.moveToExpanded=function(ele){var $moving=$j(ele);$j($moving.data('collapsibleTabsSettings').expandedContainer).data('collapsibleTabsSettings').shifting=true;var data=$moving.data('collapsibleTabsSettings');var $target=$j($moving.data('collapsibleTabsSettings').expandedContainer).find('span.placeholder:first');var expandedWidth=$moving.data('collapsibleTabsSettings').expandedWidth;$moving.css("position","relative").css((rtl?'right':'left'),0).css('width','1px');$target.replaceWith($moving.remove().css('width','1px').data('collapsibleTabsSettings',data).animate({width:expandedWidth+"px"},"normal",function(){$j(this).attr('style','display:block;');$j($moving.data('collapsibleTabsSettings').expandedContainer).data('collapsibleTabsSettings').shifting=false;$j.collapsibleTabs.handleResize();}));};$j('#p-views ul').bind("beforeTabCollapse",function(){if($j('#p-cactions').css('display')=='none')
66 $j("#p-cactions").addClass("filledPortlet").removeClass("emptyPortlet").find('h5').css('width','1px').animate({'width':'26px'},390);}).bind("beforeTabExpand",function(){if($j('#p-cactions li').length==1)
7 -$j("#p-cactions h5").animate({'width':'1px'},370,function(){$j(this).attr('style','').parent().addClass("emptyPortlet").removeClass("filledPortlet");});}).collapsibleTabs({expandCondition:function(eleWidth){if(rtl){return($j('#right-navigation').position().left+$j('#right-navigation').width()+1)<($j('#left-navigation').position().left-eleWidth);}else{return($j('#left-navigation').position().left+$j('#left-navigation').width()+1)<($j('#right-navigation').position().left-eleWidth);}},collapseCondition:function(){if(rtl){return($j('#right-navigation').position().left+$j('#right-navigation').width())>$j('#left-navigation').position().left;}else{return($j('#left-navigation').position().left+$j('#left-navigation').width())>$j('#right-navigation').position().left;}}});});mw.ready(function(){if(!wgVectorEnabledModules.editwarning){return true;}
 7+$j("#p-cactions h5").animate({'width':'1px'},370,function(){$j(this).attr('style','').parent().addClass("emptyPortlet").removeClass("filledPortlet");});}).collapsibleTabs({expandCondition:function(eleWidth){if(rtl){return($j('#right-navigation').position().left+$j('#right-navigation').width()+1)<($j('#left-navigation').position().left-eleWidth);}else{return($j('#left-navigation').position().left+$j('#left-navigation').width()+1)<($j('#right-navigation').position().left-eleWidth);}},collapseCondition:function(){if(rtl){return($j('#right-navigation').position().left+$j('#right-navigation').width())>$j('#left-navigation').position().left;}else{return($j('#left-navigation').position().left+$j('#left-navigation').width())>$j('#right-navigation').position().left;}}});});mw.ready(function(){if(!wgVectorEnabledModules.editwarning||$j('#wpTextbox1').size()==0){return true;}
88 $j('#wpTextbox1, #wpSummary').each(function(){$j(this).data('origtext',$j(this).val());});fallbackWindowOnBeforeUnload=window.onbeforeunload;window.onbeforeunload=function(){var fallbackResult=null;if(fallbackWindowOnBeforeUnload){fallbackResult=fallbackWindowOnBeforeUnload();}
99 if(fallbackResult!==null){return fallbackResult;}
1010 if(wgAction=='submit'||$j('#wpTextbox1').data('origtext')!=$j('#wpTextbox1').val()||$j('#wpSummary').data('origtext')!=$j('#wpSummary').val()){return gM('vector-editwarning-warning');}}
Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -84,7 +84,7 @@
8585 array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ),
8686 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 7 ),
8787 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 22 ),
88 - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 44 ),
 88+ array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 45 ),
8989 array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 12 ),
9090 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 41 ),
9191 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 10 ),
@@ -94,10 +94,10 @@
9595 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 1 ),
9696 ),
9797 'combined' => array(
98 - array( 'src' => 'js/plugins.combined.js', 'version' => 142 ),
 98+ array( 'src' => 'js/plugins.combined.js', 'version' => 143 ),
9999 ),
100100 'minified' => array(
101 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 142 ),
 101+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 143 ),
102102 ),
103103 ),
104104 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.html
@@ -10,9 +10,14 @@
1111 width: 100%;
1212 height: 100%;
1313 font-family: monospace;
14 - white-space: pre-wrap;
1514 font-size: 9.5pt;
16 - line-height:16px;
 15+ line-height: 1.5em;
 16+ overflow-x: auto; /* Use horizontal scroller if needed; for Firefox 2, not needed in Firefox 3 */
 17+ white-space: pre-wrap; /* css-3 */
 18+ white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
 19+ white-space: -pre-wrap; /* Opera 4-6 */
 20+ white-space: -o-pre-wrap; /* Opera 7 */
 21+ word-wrap: break-word; /* Internet Explorer 5.5+ */
1722 }
1823 /* Wikitext that's folded away and shouldn't be displayed */
1924 .wikiEditor-nodisplay {
@@ -73,7 +78,6 @@
7479 }
7580 </style>
7681 <script type="text/javascript">
77 -
7882 parent.inherit( window )( function() {
7983 function get( name ) {
8084 // Extracts the value of a given URL parameter from the current window location
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -388,9 +388,10 @@
389389 if ( $.browser.name == 'msie' ) {
390390 return context.$content.text();
391391 }
392 - // Get rid of the noincludes when getting text - we use .html() instead of .text() so HTML entities are
393 - // handled right - setting the HTML of the textarea doesn't work on all browsers, use a dummy <div> instead
394 - var $dummyDiv = $( '<div />' ).html( context.$content.html().replace( /\<br\>/g, "\n" ) );
 392+ // We use .html() instead of .text() so HTML entities are handled right - setting the HTML of the textarea
 393+ // doesn't work on all browsers, use a dummy <div> instead
 394+ var $dummyDiv = $( '<div />' ).html( context.$content.html().replace( /\<br[^\>]*\>/g, "\n" ) );
 395+ // Get rid of the noincludes when getting text
395396 $dummyDiv.find( ".wikiEditor-noinclude" ).each( function() { $( this ).remove(); } );
396397 return $dummyDiv.text();
397398
@@ -684,6 +685,8 @@
685686 context.$content.append(
686687 context.$textarea.val().replace( /\</g, '&lt;' ).replace( /\>/g, '&gt;' ).replace( /\n/g, '<br />' )
687688 );
 689+ //context.$content[0].innerText = context.$textarea.val().replace( /\n/g, '\n\n' );
 690+ //context.$content.text( context.$textarea.val() );
688691 // Reflect direction of parent frame into child
689692 if ( $( 'body' ).is( '.rtl' ) ) {
690693 context.$content.addClass( 'rtl' ).attr( 'dir', 'rtl' );
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -5850,7 +5850,7 @@
58515851 if ( args.length > 0 ) {
58525852 if ( typeof args[0] == 'object' ) {
58535853 // Apply set of properties
5854 - for ( key in args[0] ) {
 5854+ for ( var key in args[0] ) {
58555855 $.suggestions.configure( context, key, args[0][key] );
58565856 }
58575857 } else if ( typeof args[0] == 'string' ) {
@@ -6551,7 +6551,6 @@
65526552 // The wikiEditor context is stored in the element's data, so when this function gets called again we can pick up right
65536553 // where we left off
65546554 var context = $(this).data( 'wikiEditor-context' );
6555 -
65566555 // On first call, we need to set things up, but on all following calls we can skip right to the API handling
65576556 if ( typeof context == 'undefined' ) {
65586557
@@ -6741,11 +6740,11 @@
67426741 .appendTo( context.$ui );
67436742 },
67446743
6745 - /**
6746 - * FIXME: This section is a bit of a "wonky" section given it's supposed to keep compatibility with the
6747 - * textSelection plugin, which works on character-based manipulations as opposed to the node-based manipulations
6748 - * we use for the iframe. It's debatable whether compatibility with this plugin is even being done well, or for
6749 - * that matter should be done at all.
 6744+ /*
 6745+ * FIXME: This section needs attention! It doesn't really make sense given it's supposed to keep compatibility
 6746+ * with the textSelection plugin, which works on character-based manipulations as opposed to the node-based
 6747+ * manipulations we use for the iframe. It's debatable whether compatibility with this plugin is even being done
 6748+ * well, or for that matter should be done at all.
67506749 */
67516750
67526751 /**
@@ -6756,12 +6755,10 @@
67576756 if ( $.browser.name == 'msie' ) {
67586757 return context.$content.text();
67596758 }
6760 - // We use .html() instead of .text() so HTML entities are handled right
6761 - // Setting the HTML of the textarea doesn't work on all browsers, use a dummy <div> instead
6762 -
6763 -
6764 - //get rid of the noincludes when getting text
6765 - var $dummyDiv = $( '<div />' ).html( context.$content.html().replace( /\<br\>/g, "\n" ) );
 6759+ // We use .html() instead of .text() so HTML entities are handled right - setting the HTML of the textarea
 6760+ // doesn't work on all browsers, use a dummy <div> instead
 6761+ var $dummyDiv = $( '<div />' ).html( context.$content.html().replace( /\<br[^\>]*\>/g, "\n" ) );
 6762+ // Get rid of the noincludes when getting text
67666763 $dummyDiv.find( ".wikiEditor-noinclude" ).each( function() { $( this ).remove(); } );
67676764 return $dummyDiv.text();
67686765
@@ -6831,9 +6828,8 @@
68326829 var insertText = pre + selText + post;
68336830 var insertLines = insertText.split( "\n" );
68346831 range.extractContents();
6835 - // Insert the contents one line at a time
6836 - // insertNode() inserts at the beginning, so this has
6837 - // to happen in reverse order
 6832+ // Insert the contents one line at a time - insertNode() inserts at the beginning, so this has to happen
 6833+ // in reverse order
68386834 var lastNode;
68396835 for ( var i = insertLines.length - 1; i >= 0; i-- ) {
68406836 range.insertNode( document.createTextNode( insertLines[i] ) );
@@ -6845,8 +6841,7 @@
68466842 context.fn.scrollToTop( lastNode );
68476843 }
68486844 } else if ( context.$iframe[0].contentWindow.document.selection ) {
6849 - // IE
6850 - // TODO
 6845+ // TODO: IE
68516846 }
68526847 // Trigger the encapsulateSelection event (this might need to get named something else/done differently)
68536848 context.$content.trigger(
@@ -6859,9 +6854,7 @@
68606855 * DO NOT CALL THESE DIRECTLY, use .textSelection( 'functionname', options ) instead
68616856 */
68626857 'getCaretPosition': function( options ) {
6863 - // FIXME: Character-based functions aren't useful for the magic iframe
6864 - // ...
6865 - //reurn character position
 6858+ // FIXME: Character-based functions aren't useful for the magic iframe - return character position?
68666859 },
68676860 /**
68686861 * Sets the selection of the content
@@ -6885,7 +6878,6 @@
68866879 while ( ec.firstChild && ec.nodeName != '#text' ) {
68876880 ec = ec.firstChild;
68886881 }
6889 -
68906882 var range = document.createRange();
68916883 range.setStart( sc, options.start );
68926884 range.setEnd( ec, options.end );
@@ -6893,8 +6885,7 @@
68946886 sel.addRange( range );
68956887 context.$iframe[0].contentWindow.focus();
68966888 } else if ( context.$iframe[0].contentWindow.document.selection ) {
6897 - // IE
6898 - // FIXME still broken for when sc or ec is the <body>, needs more tweaking
 6889+ // FIXME: IE is still broken for when sc or ec is the <body>, needs more tweaking
68996890 var range = document.selection.createRange();
69006891 range.moveToElementText( sc );
69016892 range.moveStart( 'character', options.start );
@@ -6910,8 +6901,7 @@
69116902 * DO NOT CALL THESE DIRECTLY, use .textSelection( 'functionname', options ) instead
69126903 */
69136904 'scrollToCaretPosition': function( options ) {
6914 - // ...
6915 - //context.$textarea.trigger( 'scrollToPosition' );
 6905+ // FIXME: context.$textarea.trigger( 'scrollToPosition' ) ?
69166906 },
69176907 /**
69186908 * Scroll an element to the top of the iframe
@@ -6938,8 +6928,9 @@
69396929 * @return jQuery object
69406930 */
69416931 'beforeSelection': function( selector, strict ) {
6942 - if ( typeof selector == 'undefined' )
 6932+ if ( typeof selector == 'undefined' ) {
69436933 selector = '*';
 6934+ }
69446935 var e;
69456936 if ( context.$iframe[0].contentWindow.getSelection ) {
69466937 // Firefox and Opera
@@ -6979,10 +6970,9 @@
69806971 return $( [] );
69816972 }
69826973
6983 - /**
6984 - * End of "wonky" textSelection "compatible" section that needs attention.
 6974+ /*
 6975+ * End of wonky textSelection "compatible" section that needs attention.
69856976 */
6986 -
69876977 };
69886978
69896979 /*
@@ -7028,7 +7018,8 @@
70297019 // Create an iframe in place of the text area
70307020 context.$iframe = $( '<iframe></iframe>' )
70317021 .attr( {
7032 - 'frameborder': 0,
 7022+ 'frameBorder': 0,
 7023+ 'border': 0,
70337024 'src': wgScriptPath + '/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.html?' +
70347025 'instance=' + context.instance + '&ts=' + ( new Date() ).getTime(),
70357026 'id': 'wikiEditor-iframe-' + context.instance
@@ -7043,18 +7034,26 @@
70447035 } )
70457036 .insertAfter( context.$textarea )
70467037 .load( function() {
7047 - if ( !context.$iframe[0].contentWindow.document.body ) {
7048 - return;
 7038+ // Internet Explorer will reload the iframe once we turn on design mode, so we need to only turn it on
 7039+ // during the first run, and then bail
 7040+ if ( !this.isSecondRun ) {
 7041+ // Turn the document's design mode on
 7042+ context.$iframe[0].contentWindow.document.designMode = 'on';
 7043+ // Let the rest of this function happen next time around
 7044+ if ( $.browser.msie ) {
 7045+ this.isSecondRun = true;
 7046+ return;
 7047+ }
70497048 }
7050 - // Turn the document's design mode on
7051 - context.$iframe[0].contentWindow.document.designMode = 'on';
70527049 // Get a reference to the content area of the iframe
70537050 context.$content = $( context.$iframe[0].contentWindow.document.body );
7054 - // We need to properly escape any HTML entities like &amp;, &lt; and &gt; so they end up as visible
7055 - // characters rather than actual HTML tags in the code editor container.
 7051+ // If we just do "context.$content.text( context.$textarea.val() )", Internet Explorer will strip out the
 7052+ // whitespace charcters, specifically "\n" - so we must manually encode the text and append it
70567053 context.$content.append(
7057 - context.$textarea.val().replace( /</g, '&lt;' ).replace( />/g, '&gt;' )
 7054+ context.$textarea.val().replace( /\</g, '&lt;' ).replace( /\>/g, '&gt;' ).replace( /\n/g, '<br />' )
70587055 );
 7056+ //context.$content[0].innerText = context.$textarea.val().replace( /\n/g, '\n\n' );
 7057+ //context.$content.text( context.$textarea.val() );
70597058 // Reflect direction of parent frame into child
70607059 if ( $( 'body' ).is( '.rtl' ) ) {
70617060 context.$content.addClass( 'rtl' ).attr( 'dir', 'rtl' );
@@ -7295,15 +7294,8 @@
72967295 } ) );
72977296 */
72987297 // Highlight stuff for the first time
 7298+
72997299
7300 - //IE8 runs this twice, the second time is valid
7301 - if( $.browser.msie && $.browser.version >= 8 ) {
7302 - if(!this.isSecondRun){
7303 - this.isSecondRun = true;
7304 - return;
7305 - }
7306 - }
7307 -
73087300 $.wikiEditor.modules.highlight.fn.scan( context, "" );
73097301 $.wikiEditor.modules.highlight.fn.mark( context, "", "" );
73107302 }
@@ -7934,6 +7926,7 @@
79357927 return;
79367928 }
79377929 // Build a model for this
 7930+
79387931 var model = new $.wikiEditor.modules.templateEditor.fn.model( $( this ).text() );
79397932 var $template = $( this )
79407933 .wrap( '<div class="wikiEditor-template"></div>' )
@@ -7941,8 +7934,8 @@
79427935 .html(
79437936 // Wrap the start and end of the wikitext in spans so we can bind events to them
79447937 $( this ).html()
7945 - .replace( /\{\{/, '<span class="wikiEditor-template-start">{{</span>' )
7946 - .replace( /\}\}/, '<span class="wikiEditor-template-end">}}</span>' ) )
 7938+ .replace( /\{\{/, '<span class="wikiEditor-template-start">{{</span><span class="wikiEditor-template-inner-text">' )
 7939+ .replace( /\}\}$/, '</span><span class="wikiEditor-template-end">}}</span>' ) ) //grab the *last* {{
79477940 .parent()
79487941 .addClass( 'wikiEditor-template-collapsed' )
79497942 .data( 'model', model );
@@ -7952,7 +7945,7 @@
79537946 .mousedown( noEdit )
79547947 .prependTo( $template );
79557948 $template.find( '.wikiEditor-template-end, .wikiEditor-template-start' ).mousedown( toggleWikiText );
7956 - $( '<ul />' )
 7949+ var $options = $( '<ul />' )
79577950 .addClass( 'wikiEditor-template-modes wikiEditor-noinclude' )
79587951 .append( $( '<li />' )
79597952 .addClass( 'wikiEditor-template-action-wikiText' )
@@ -7960,6 +7953,14 @@
79617954 $.wikiEditor.imgPath + 'templateEditor/' + 'wiki-text.png' ) )
79627955 .mousedown( toggleWikiText ) )
79637956 .insertAfter( $template.find( '.wikiEditor-template-name' ) );
 7957+ $options.append(
 7958+ $( '<li />' )
 7959+ .addClass( 'wikiEditor-template-action-form' )
 7960+ .append( $( '<span>F</span>' ) )
 7961+ .mousedown( function(){createDialog($template); return false;} ));
 7962+
 7963+
 7964+
79647965 // Expand
79657966 function expandTemplate( $displayDiv ) {
79667967 // Housekeeping
@@ -7995,6 +7996,45 @@
79967997 $displayDiv.removeClass( 'wikiEditor-template-expanded' );
79977998 $displayDiv.text( model.getName() );
79987999 };
 8000+
 8001+
 8002+ function createDialog( $templateDiv ){
 8003+ var templateModel = $templateDiv.data('model');
 8004+ var $dialog = $("<div></div>");
 8005+ var $title = $("<div>" + templateModel.getName() + "</div>").addClass('wikiEditor-template-dialog-title');
 8006+ var $table = $("<table></table>")
 8007+ .addClass('wikiEditor-template-dialog-table')
 8008+ .appendTo($dialog);
 8009+ var allInitialParams = templateModel.getAllInitialParams();
 8010+ for( var paramIndex in allInitialParams ){
 8011+ var param = allInitialParams[paramIndex];
 8012+ if(typeof param.name == 'undefined'){continue;} //param 0 is the name
 8013+ var $paramRow = $("<tr></tr>")
 8014+ .addClass('wikiEditor-template-dialog-row');
 8015+ var $paramName = $("<td></td>")
 8016+ .addClass('wikiEditor-template-dialog-name')
 8017+ .text( param.name );
 8018+ var $paramVal = $("<td></td>")
 8019+ .addClass('wikiEditor-template-dialog-value');
 8020+ var $paramInput =$("<input></input>")
 8021+ .data('name', param.name)
 8022+ .val( templateModel.getValue(param.name) );
 8023+ $paramVal.append($paramInput);
 8024+ $paramRow.append($paramName).append($paramVal);
 8025+ $table.append($paramRow);
 8026+ }
 8027+ //click handler for values
 8028+ $("<button></button>").click(function(){
 8029+ $('.wikiEditor-template-dialog-value input').each( function(){
 8030+ templateModel.setValue( $(this).data('name'), $(this).val() );
 8031+ });
 8032+ $dialog.dialog('close');
 8033+
 8034+ }).text("OK").appendTo($dialog);
 8035+ $dialog.dialog(); //opens dialog
 8036+ };
 8037+
 8038+
79998039 function toggleWikiText( ) {
80008040 var $template = $( this ).closest( '.wikiEditor-template' );
80018041 $template
@@ -8002,6 +8042,22 @@
80038043 .toggleClass( 'wikiEditor-template-expanded' )
80048044 .children( '.wikiEditor-template-text, .wikiEditor-template-name, .wikiEditor-template-modes' )
80058045 .toggleClass( 'wikiEditor-nodisplay' );
 8046+
 8047+ //if we just collapsed this
 8048+ if( $template.hasClass('wikiEditor-template-collapsed') ) {
 8049+ var model = new $.wikiEditor.modules.templateEditor.fn.model( $template.children( '.wikiEditor-template-text' ).text() );
 8050+ $template.data( 'model' , model );
 8051+ $template.children( '.wikiEditor-template-name' ).text( model.getName() );
 8052+ }
 8053+ else{ //else we just expanded this
 8054+ $template.children( '.wikiEditor-template-text' ).children('.wikiEditor-template-inner-text').text(
 8055+ $template.data('model')
 8056+ .getText()
 8057+ .replace(/\{\{/, '')
 8058+ .replace(/\}\}$/, '')
 8059+ );
 8060+
 8061+ }
80068062 return false;
80078063 }
80088064 function noEdit() {
@@ -8009,9 +8065,6 @@
80108066 }
80118067 });
80128068
8013 - function toggleWikiText ( context, template ) {
8014 -
8015 - }
80168069 },
80178070
80188071
@@ -8180,6 +8233,23 @@
81818234 return newText;
81828235 };
81838236
 8237+ /**
 8238+ * Update ranges if there's been a change
 8239+ */
 8240+ this.updateRanges = function() {
 8241+ var adjustment = 0;
 8242+ for ( i = 0 ; i < ranges.length; i++ ) {
 8243+ ranges[i].begin += adjustment;
 8244+ if( typeof ranges[i].adjust != 'undefined' ) {
 8245+ adjustment += ranges[i].adjust();
 8246+ //note, adjust should be a function that has the information necessary to calculate the length of this 'segment'
 8247+ delete ranges[i].adjust;
 8248+ }
 8249+ ranges[i].end += adjustment;
 8250+ }
 8251+ };
 8252+
 8253+
81848254 // Whitespace* {{ whitespace* nonwhitespace:
81858255 if ( wikitext.match( /\s*{{\s*\S*:/ ) ) {
81868256 // We have a parser function!
@@ -8201,7 +8271,7 @@
82028272 startIndex = sanatizedStr.indexOf( '{{' ) + 1;
82038273 openBraces = 2;
82048274 endIndex = startIndex;
8205 - while ( openBraces > 0 ) {
 8275+ while ( (openBraces > 0) && (endIndex < sanatizedStr.length) ) {
82068276 var brace = sanatizedStr[++endIndex];
82078277 openBraces += brace == '}' ? -1 : brace == '{' ? 1 : 0;
82088278 }
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -389,7 +389,7 @@
390390 context.data.$textbox.trigger('change');preventDefault=wasVisible;break;case 27:context.data.$container.hide();$.suggestions.restore(context);$.suggestions.cancel(context);context.data.$textbox.trigger('change');preventDefault=wasVisible;break;case 13:context.data.$container.hide();preventDefault=wasVisible;if(typeof context.config.result.select=='function'){context.config.result.select.call(context.data.$container.find('.suggestions-result-current'),context.data.$textbox);}
391391 break;default:$.suggestions.update(context,true);break;}
392392 if(preventDefault){e.preventDefault();e.stopImmediatePropagation();}}};$.fn.suggestions=function(){var returnValue=null;var args=arguments;$(this).each(function(){var context=$(this).data('suggestions-context');if(typeof context=='undefined'){context={config:{'fetch':function(){},'cancel':function(){},'special':{},'result':{},'$region':$(this),'suggestions':[],'maxRows':7,'delay':120,'submitOnClick':false}};}
393 -if(args.length>0){if(typeof args[0]=='object'){for(key in args[0]){$.suggestions.configure(context,key,args[0][key]);}}else if(typeof args[0]=='string'){if(args.length>1){$.suggestions.configure(context,args[0],args[1]);}else if(returnValue==null){returnValue=(args[0]in context.config?undefined:context.config[args[0]]);}}}
 393+if(args.length>0){if(typeof args[0]=='object'){for(var key in args[0]){$.suggestions.configure(context,key,args[0][key]);}}else if(typeof args[0]=='string'){if(args.length>1){$.suggestions.configure(context,args[0],args[1]);}else if(returnValue==null){returnValue=(args[0]in context.config?undefined:context.config[args[0]]);}}}
394394 if(typeof context.data=='undefined'){context.data={'timerID':null,'prevText':null,'visibleResults':0,'mouseDownOn':$([]),'$textbox':$(this)};context.data.$container=$('<div />').css({'top':Math.round(context.data.$textbox.offset().top+context.data.$textbox.outerHeight()),'left':Math.round(context.data.$textbox.offset().left),'width':context.data.$textbox.outerWidth(),'display':'none'}).mouseover(function(e){$.suggestions.highlight(context,$(e.target).closest('.suggestions-results div'),false);}).addClass('suggestions').append($('<div />').addClass('suggestions-results').mousedown(function(e){context.data.mouseDownOn=$(e.target).closest('.suggestions-results div');}).mouseup(function(e){var $result=$(e.target).closest('.suggestions-results div');var $other=context.data.mouseDownOn;context.data.mouseDownOn=$([]);if($result.get(0)!=$other.get(0)){return;}
395395 $.suggestions.highlight(context,$result,true);context.data.$container.hide();if(typeof context.config.result.select=='function'){context.config.result.select.call($result,context.data.$textbox);}
396396 context.data.$textbox.focus();})).append($('<div />').addClass('suggestions-special').mousedown(function(e){context.data.mouseDownOn=$(e.target).closest('.suggestions-special');}).mouseup(function(e){var $special=$(e.target).closest('.suggestions-special');var $other=context.data.mouseDownOn;context.data.mouseDownOn=$([]);if($special.get(0)!=$other.get(0)){return;}
@@ -444,7 +444,7 @@
445445 event.preventDefault();return false;}).text($.wikiEditor.autoMsg(options,'title'))).appendTo(context.$tabs);}
446446 if(!context.$tabs.children().size()){addTab({'name':'wikitext','titleMsg':'wikieditor-wikitext-tab'});}
447447 addTab(options);return $('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-'+options.name).hide().appendTo(context.$ui);},'getContents':function(){if($.browser.name=='msie'){return context.$content.text();}
448 -var $dummyDiv=$('<div />').html(context.$content.html().replace(/\<br\>/g,"\n"));$dummyDiv.find(".wikiEditor-noinclude").each(function(){$(this).remove();});return $dummyDiv.text();},'setContents':function(options){context.$content.text(options.contents);return context.$textarea;},'getSelection':function(){var retval;if(context.$iframe[0].contentWindow.getSelection){retval=context.$iframe[0].contentWindow.getSelection();}else if(context.$iframe[0].contentWindow.document.selection){retval=context.$iframe[0].contentWindow.document.selection.createRange();}
 448+var $dummyDiv=$('<div />').html(context.$content.html().replace(/\<br[^\>]*\>/g,"\n"));$dummyDiv.find(".wikiEditor-noinclude").each(function(){$(this).remove();});return $dummyDiv.text();},'setContents':function(options){context.$content.text(options.contents);return context.$textarea;},'getSelection':function(){var retval;if(context.$iframe[0].contentWindow.getSelection){retval=context.$iframe[0].contentWindow.getSelection();}else if(context.$iframe[0].contentWindow.document.selection){retval=context.$iframe[0].contentWindow.document.selection.createRange();}
449449 if(retval.text){retval=retval.text;}else if(retval.toString){retval=retval.toString();}
450450 return retval;},'encapsulateSelection':function(options){var selText=$(this).textSelection('getSelection');var selectAfter=false;var pre=options.pre,post=options.post;if(!selText){selText=options.peri;selectAfter=true;}else if(options.replace){selText=options.peri;}else if(selText.charAt(selText.length-1)==' '){selText=selText.substring(0,selText.length-1);post+=' ';}
451451 if(context.$iframe[0].contentWindow.getSelection){var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);if(options.ownline){if(range.startOffset!=0){pre="\n"+options.pre;}
@@ -454,16 +454,16 @@
455455 context.$content.trigger('encapsulateSelection',[pre,options.peri,post,options.ownline,options.replace]);return context.$textarea;},'getCaretPosition':function(options){},'setSelection':function(options){var sc=options.startContainer,ec=options.endContainer;sc=sc.jquery?sc[0]:sc;ec=ec.jquery?ec[0]:ec;if(context.$iframe[0].contentWindow.getSelection){var sel=context.$iframe[0].contentWindow.getSelection();while(sc.firstChild&&sc.nodeName!='#text'){sc=sc.firstChild;}
456456 while(ec.firstChild&&ec.nodeName!='#text'){ec=ec.firstChild;}
457457 var range=document.createRange();range.setStart(sc,options.start);range.setEnd(ec,options.end);sel.removeAllRanges();sel.addRange(range);context.$iframe[0].contentWindow.focus();}else if(context.$iframe[0].contentWindow.document.selection){var range=document.selection.createRange();range.moveToElementText(sc);range.moveStart('character',options.start);var range2=document.selection.createRange();range2.moveToElementText(ec);range2.moveEnd('character',options.end);range.setEndPoint(EndToEnd,range2);range.select();}},'scrollToCaretPosition':function(options){},'scrollToTop':function($element,force){var html=context.$content.closest('html'),body=context.$content.closest('body'),parent=$('html');var y=$element.offset().top-context.$content.offset().top;y=parent.scrollTop()>0?y+html.scrollTop()-parent.scrollTop():y;if(force||y<html.scrollTop()||y>html.scrollTop()+context.$iframe.height()){html.scrollTop(y);}
458 -$element.trigger('scrollToTop');},'beforeSelection':function(selector,strict){if(typeof selector=='undefined')
459 -selector='*';var e;if(context.$iframe[0].contentWindow.getSelection){var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);e=range.startContainer;}else if(context.$iframe[0].contentWindow.document.selection){return $([]);}
 458+$element.trigger('scrollToTop');},'beforeSelection':function(selector,strict){if(typeof selector=='undefined'){selector='*';}
 459+var e;if(context.$iframe[0].contentWindow.getSelection){var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);e=range.startContainer;}else if(context.$iframe[0].contentWindow.document.selection){return $([]);}
460460 if(e.nodeName!='#text'){var newE=e.firstChild;for(var i=0;i<range.startOffset-1&&newE;i++){newE=newE.nextSibling;}
461461 while(newE&&newE.lastChild){newE=newE.lastChild;}
462462 e=newE;}
463463 while(e){if($(e).is(selector)&&!strict)
464464 return $(e);var next=e.previousSibling;while(next&&next.lastChild){next=next.lastChild;}
465465 e=next||e.parentNode;strict=false;}
466 -return $([]);}};context.$textarea.wrap($('<div></div>').addClass('wikiEditor-ui')).wrap($('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-wikitext')).wrap($('<div></div>').addClass('wikiEditor-ui-left')).wrap($('<div></div>').addClass('wikiEditor-ui-bottom')).wrap($('<div></div>').addClass('wikiEditor-ui-text'));context.$ui=context.$textarea.parent().parent().parent().parent().parent();context.$wikitext=context.$textarea.parent().parent().parent().parent();context.$wikitext.before($('<div></div>').addClass('wikiEditor-ui-controls').append($('<div></div>').addClass('wikiEditor-ui-tabs').hide()).append($('<div></div>').addClass('wikiEditor-ui-buttons'))).before($('<div style="clear:both;"></div>'));context.$controls=context.$ui.find('.wikiEditor-ui-buttons').hide();context.$buttons=context.$ui.find('.wikiEditor-ui-buttons');context.$tabs=context.$ui.find('.wikiEditor-ui-tabs');context.$ui.after($('<div style="clear:both;"></div>'));context.$wikitext.append($('<div></div>').addClass('wikiEditor-ui-right'));context.$wikitext.find('.wikiEditor-ui-left').prepend($('<div></div>').addClass('wikiEditor-ui-top'));context.view='wikitext';$(window).resize(function(event){context.fn.trigger('resize',event)});context.$iframe=$('<iframe></iframe>').attr({'frameborder':0,'src':wgScriptPath+'/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.html?'+'instance='+context.instance+'&ts='+(new Date()).getTime(),'id':'wikiEditor-iframe-'+context.instance}).css({'backgroundColor':'white','width':'100%','height':context.$textarea.height(),'display':'none','overflow-y':'scroll','overflow-x':'hidden'}).insertAfter(context.$textarea).load(function(){if(!context.$iframe[0].contentWindow.document.body){return;}
467 -context.$iframe[0].contentWindow.document.designMode='on';context.$content=$(context.$iframe[0].contentWindow.document.body);context.$content.append(context.$textarea.val().replace(/</g,'&lt;').replace(/>/g,'&gt;'));if($('body').is('.rtl')){context.$content.addClass('rtl').attr('dir','rtl');}
 466+return $([]);}};context.$textarea.wrap($('<div></div>').addClass('wikiEditor-ui')).wrap($('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-wikitext')).wrap($('<div></div>').addClass('wikiEditor-ui-left')).wrap($('<div></div>').addClass('wikiEditor-ui-bottom')).wrap($('<div></div>').addClass('wikiEditor-ui-text'));context.$ui=context.$textarea.parent().parent().parent().parent().parent();context.$wikitext=context.$textarea.parent().parent().parent().parent();context.$wikitext.before($('<div></div>').addClass('wikiEditor-ui-controls').append($('<div></div>').addClass('wikiEditor-ui-tabs').hide()).append($('<div></div>').addClass('wikiEditor-ui-buttons'))).before($('<div style="clear:both;"></div>'));context.$controls=context.$ui.find('.wikiEditor-ui-buttons').hide();context.$buttons=context.$ui.find('.wikiEditor-ui-buttons');context.$tabs=context.$ui.find('.wikiEditor-ui-tabs');context.$ui.after($('<div style="clear:both;"></div>'));context.$wikitext.append($('<div></div>').addClass('wikiEditor-ui-right'));context.$wikitext.find('.wikiEditor-ui-left').prepend($('<div></div>').addClass('wikiEditor-ui-top'));context.view='wikitext';$(window).resize(function(event){context.fn.trigger('resize',event)});context.$iframe=$('<iframe></iframe>').attr({'frameBorder':0,'border':0,'src':wgScriptPath+'/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.html?'+'instance='+context.instance+'&ts='+(new Date()).getTime(),'id':'wikiEditor-iframe-'+context.instance}).css({'backgroundColor':'white','width':'100%','height':context.$textarea.height(),'display':'none','overflow-y':'scroll','overflow-x':'hidden'}).insertAfter(context.$textarea).load(function(){if(!this.isSecondRun){context.$iframe[0].contentWindow.document.designMode='on';if($.browser.msie){this.isSecondRun=true;return;}}
 467+context.$content=$(context.$iframe[0].contentWindow.document.body);context.$content.append(context.$textarea.val().replace(/\</g,'&lt;').replace(/\>/g,'&gt;').replace(/\n/g,'<br />'));if($('body').is('.rtl')){context.$content.addClass('rtl').attr('dir','rtl');}
468468 context.$textarea.attr('disabled',true);context.$textarea.hide();context.$iframe.show();context.fn.trigger('ready');});context.$textarea.closest('form').submit(function(){context.$textarea.attr('disabled',false);context.$textarea.val(context.$textarea.textSelection('getContents'));});}
469469 arguments=$.makeArray(arguments);if(arguments.length>0){var call=arguments.shift();if(call in context.api){context.api[call](context,typeof arguments[0]=='undefined'?{}:arguments[0]);}}
470470 return $(this).data('wikiEditor-context',context);};})(jQuery);RegExp.escape=function(s){return s.replace(/([.*+?^${}()|\/\\[\]])/g,'\\$1');};(function($){$.wikiEditor.modules.dialogs={api:{addDialog:function(context,data){$.wikiEditor.modules.dialogs.fn.create(context,data)},openDialog:function(context,module){if(module in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[module].id).dialog('open');}},closeDialog:function(context,data){if(module in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[module].id).dialog('close');}}},fn:{create:function(context,config){for(module in config){$.wikiEditor.modules.dialogs.modules[module]=config[module];}
@@ -471,8 +471,7 @@
472472 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);});}
473473 var maxTI=0;$j('[tabindex]').each(function(){var ti=parseInt($j(this).attr('tabindex'));if(ti>maxTI)
474474 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);}
475 -$(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;}}
476 -$.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;}
 475+$(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){$.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;}
477476 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;}
478477 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;}
479478 tokenArray.push(new Token(match.index+oldOffset+markOffset,label,tokenStart,match));oldOffset+=match.index+match[0].length;newSubstring=text.substring(oldOffset);match=newSubstring.match(regex);}}}}
@@ -529,8 +528,12 @@
530529 $('#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++;}
531530 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;}}}
532531 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;}
533 -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;}
534 -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;}
 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><span class="wikiEditor-template-inner-text">').replace(/\}\}$/,'</span><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);var $options=$('<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'));$options.append($('<li />').addClass('wikiEditor-template-action-form').append($('<span>F</span>')).mousedown(function(){createDialog($template);return false;}));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 createDialog($templateDiv){var templateModel=$templateDiv.data('model');var $dialog=$("<div></div>");var $title=$("<div>"+templateModel.getName()+"</div>").addClass('wikiEditor-template-dialog-title');var $table=$("<table></table>").addClass('wikiEditor-template-dialog-table').appendTo($dialog);var allInitialParams=templateModel.getAllInitialParams();for(var paramIndex in allInitialParams){var param=allInitialParams[paramIndex];if(typeof param.name=='undefined'){continue;}
 533+var $paramRow=$("<tr></tr>").addClass('wikiEditor-template-dialog-row');var $paramName=$("<td></td>").addClass('wikiEditor-template-dialog-name').text(param.name);var $paramVal=$("<td></td>").addClass('wikiEditor-template-dialog-value');var $paramInput=$("<input></input>").data('name',param.name).val(templateModel.getValue(param.name));$paramVal.append($paramInput);$paramRow.append($paramName).append($paramVal);$table.append($paramRow);}
 534+$("<button></button>").click(function(){$('.wikiEditor-template-dialog-value input').each(function(){templateModel.setValue($(this).data('name'),$(this).val());});$dialog.dialog('close');}).text("OK").appendTo($dialog);$dialog.dialog();};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');if($template.hasClass('wikiEditor-template-collapsed')){var model=new $.wikiEditor.modules.templateEditor.fn.model($template.children('.wikiEditor-template-text').text());$template.data('model',model);$template.children('.wikiEditor-template-name').text(model.getName());}
 535+else{$template.children('.wikiEditor-template-text').children('.wikiEditor-template-inner-text').text($template.data('model').getText().replace(/\{\{/,'').replace(/\}\}$/,''));}
 536+return false;}
 537+function noEdit(){return false;}});},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;}
535538 function Range(begin,end){this.begin=begin;this.end=end;}
536539 function getSetValue(name,value,original){var valueRange;var rangeIndex;var retVal;if(isNaN(name)){if(typeof paramsByName[name]=='undefined'){return"";}
537540 rangeIndex=paramsByName[name];}else{rangeIndex=parseInt(name);}
@@ -539,10 +542,11 @@
540543 if(value!=null){ranges[params[rangeIndex].valueIndex].newVal=value;}
541544 return retVal;};this.getName=function(){if(typeof ranges[templateNameIndex].newVal=='undefined'){return wikitext.substring(ranges[templateNameIndex].begin,ranges[templateNameIndex].end);}else{return ranges[templateNameIndex].newVal;}};this.setName=function(name){ranges[templateNameIndex].newVal=name;};this.setValue=function(name,value){return getSetValue(name,value,false);};this.getValue=function(name){return getSetValue(name,null,false);};this.getOriginalValue=function(name){return getSetValue(name,null,true);};this.getAllParamNames=function(){return paramsByName;};this.getAllInitialParams=function(){return params;}
542545 this.getOriginalText=function(){return wikitext;};this.getText=function(){newText="";for(i=0;i<ranges.length;i++){if(typeof ranges[i].newVal=='undefined'){newText+=wikitext.substring(ranges[i].begin,ranges[i].end);}else{newText+=ranges[i].newVal;}}
543 -return newText;};if(wikitext.match(/\s*{{\s*\S*:/)){}
 546+return newText;};this.updateRanges=function(){var adjustment=0;for(i=0;i<ranges.length;i++){ranges[i].begin+=adjustment;if(typeof ranges[i].adjust!='undefined'){adjustment+=ranges[i].adjust();delete ranges[i].adjust;}
 547+ranges[i].end+=adjustment;}};if(wikitext.match(/\s*{{\s*\S*:/)){}
544548 var sanatizedStr=wikitext.replace(/{{/," ");endBraces=sanatizedStr.match(/}}\s*$/);if(endBraces){sanatizedStr=sanatizedStr.substring(0,endBraces.index)+" "+
545549 sanatizedStr.substring(endBraces.index+2);}
546 -while(sanatizedStr.indexOf('{{')!=-1){startIndex=sanatizedStr.indexOf('{{')+1;openBraces=2;endIndex=startIndex;while(openBraces>0){var brace=sanatizedStr[++endIndex];openBraces+=brace=='}'?-1:brace=='{'?1:0;}
 550+while(sanatizedStr.indexOf('{{')!=-1){startIndex=sanatizedStr.indexOf('{{')+1;openBraces=2;endIndex=startIndex;while((openBraces>0)&&(endIndex<sanatizedStr.length)){var brace=sanatizedStr[++endIndex];openBraces+=brace=='}'?-1:brace=='{'?1:0;}
547551 sanatizedSegment=sanatizedStr.substring(startIndex,endIndex).replace(/[{}|=]/g,'X');sanatizedStr=sanatizedStr.substring(0,startIndex)+sanatizedSegment+sanatizedStr.substring(endIndex);}
548552 var ranges=[];var params=[];var templateNameIndex=0;var doneParsing=false;oldDivider=0;divider=sanatizedStr.indexOf('|',oldDivider);if(divider==-1){divider=sanatizedStr.length;doneParsing=true;}
549553 nameMatch=wikitext.substring(0,divider).match(/[^{\s]+/);if(nameMatch!=undefined){ranges.push(new Range(0,nameMatch.index));nameEndMatch=sanatizedStr.substring(0,divider).match(/[^\s]\s*$/);templateNameIndex=ranges.push(new Range(nameMatch.index,nameEndMatch.index+1));templateNameIndex--;ranges[templateNameIndex].old=wikitext.substring(ranges[templateNameIndex].begin,ranges[templateNameIndex].end);}

Status & tagging log