r61032 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61031‎ | r61032 | r61033 >
Date:22:55, 13 January 2010
Author:nimishg
Status:ok (Comments)
Tags:
Comment:
wiki editor stylization fixes
Modified paths:
  • /trunk/extensions/UsabilityInitiative/js/plugins/codepress (added) (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/js/plugins/jquery.wikiEditor.templateEditor.js
@@ -97,7 +97,7 @@
9898 // Wrap the start and end of the wikitext in spans so we can bind events to them
9999 $( this ).html()
100100 .replace( /\{\{/, '<span class="wikiEditor-template-start">{{</span>' )
101 - .replace( /\}\}/, '<span class="wikiEditor-template-end">}}</span>' ) )
 101+ .replace( /\}\}$/, '<span class="wikiEditor-template-end">}}</span>' ) ) //grab the *last* {{
102102 .parent()
103103 .addClass( 'wikiEditor-template-collapsed' )
104104 .data( 'model', model );
@@ -157,6 +157,13 @@
158158 .toggleClass( 'wikiEditor-template-expanded' )
159159 .children( '.wikiEditor-template-text, .wikiEditor-template-name, .wikiEditor-template-modes' )
160160 .toggleClass( 'wikiEditor-nodisplay' );
 161+
 162+ //if we just collapsed this
 163+ if( $template.hasClass('wikiEditor-template-collapsed') ){
 164+ var model = new $.wikiEditor.modules.templateEditor.fn.model( $template.children( '.wikiEditor-template-text' ).text() );
 165+ $template.data( 'model' , model );
 166+ $template.children( '.wikiEditor-template-name' ).text( model.getName() );
 167+ }
161168 return false;
162169 }
163170 function noEdit() {
@@ -164,9 +171,6 @@
165172 }
166173 });
167174
168 - function toggleWikiText ( context, template ) {
169 -
170 - }
171175 },
172176
173177
@@ -335,6 +339,23 @@
336340 return newText;
337341 };
338342
 343+ /**
 344+ * Update ranges if there's been a change
 345+ */
 346+ this.updateRanges = function() {
 347+ var adjustment = 0;
 348+ for ( i = 0 ; i < ranges.length; i++ ) {
 349+ ranges[i].begin += adjustment;
 350+ if( typeof ranges[i].adjust != 'undefined' ) {
 351+ adjustment += ranges[i].adjust();
 352+ //note, adjust should be a function that has the information necessary to calculate the length of this 'segment'
 353+ delete ranges[i].adjust;
 354+ }
 355+ ranges[i].end += adjustment;
 356+ }
 357+ };
 358+
 359+
339360 // Whitespace* {{ whitespace* nonwhitespace:
340361 if ( wikitext.match( /\s*{{\s*\S*:/ ) ) {
341362 // We have a parser function!
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.html
@@ -47,13 +47,24 @@
4848 cursor: pointer !important;
4949 }
5050 /* An expanded template */
 51+
5152 .wikiEditor-template-expanded {
 53+ display: inline;
 54+ }
 55+ .wikiEditor-template-text{
 56+ display: inline;
 57+ }
 58+ .wikiEditor-template-end, .wikiEditor-template-start{
 59+ color: blue;
 60+ cursor: pointer;
 61+ }
 62+ /*.wikiEditor-template-expanded {
5263 background:#DDEEFF none repeat scroll 0 0;
5364 border:1px inset #DDEEFF;
5465 color:black;
5566 margin:3px;
5667 padding:0 0.25em;
57 - }
 68+ }*/
5869 /* == Header == */
5970 .wikiEditor-toc-header { /* TODO: move parsing to highlight module and rename this */
6071 display: inline;

Comments

#Comment by Catrope (talk | contribs)   21:40, 17 January 2010
+			for ( i = 0 ; i < ranges.length; i++ ) {

Use var i = 0; to prevent scope problems.

+					delete ranges[i].adjust;

Please add a comment explaining why you're deleting it. I understood after reading the code twice. The entire function should probably be explained better.

#Comment by Nimish Gautam (talk | contribs)   01:20, 26 January 2010

changed in r61508

Status & tagging log