Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js |
— | — | @@ -97,7 +97,7 @@ |
98 | 98 | // Wrap the start and end of the wikitext in spans so we can bind events to them |
99 | 99 | $( this ).html() |
100 | 100 | .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* {{ |
102 | 102 | .parent() |
103 | 103 | .addClass( 'wikiEditor-template-collapsed' ) |
104 | 104 | .data( 'model', model ); |
— | — | @@ -157,6 +157,13 @@ |
158 | 158 | .toggleClass( 'wikiEditor-template-expanded' ) |
159 | 159 | .children( '.wikiEditor-template-text, .wikiEditor-template-name, .wikiEditor-template-modes' ) |
160 | 160 | .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 | + } |
161 | 168 | return false; |
162 | 169 | } |
163 | 170 | function noEdit() { |
— | — | @@ -164,9 +171,6 @@ |
165 | 172 | } |
166 | 173 | }); |
167 | 174 | |
168 | | - function toggleWikiText ( context, template ) { |
169 | | - |
170 | | - } |
171 | 175 | }, |
172 | 176 | |
173 | 177 | |
— | — | @@ -335,6 +339,23 @@ |
336 | 340 | return newText; |
337 | 341 | }; |
338 | 342 | |
| 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 | + |
339 | 360 | // Whitespace* {{ whitespace* nonwhitespace: |
340 | 361 | if ( wikitext.match( /\s*{{\s*\S*:/ ) ) { |
341 | 362 | // We have a parser function! |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.html |
— | — | @@ -47,13 +47,24 @@ |
48 | 48 | cursor: pointer !important; |
49 | 49 | } |
50 | 50 | /* An expanded template */ |
| 51 | + |
51 | 52 | .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 { |
52 | 63 | background:#DDEEFF none repeat scroll 0 0; |
53 | 64 | border:1px inset #DDEEFF; |
54 | 65 | color:black; |
55 | 66 | margin:3px; |
56 | 67 | padding:0 0.25em; |
57 | | - } |
| 68 | + }*/ |
58 | 69 | /* == Header == */ |
59 | 70 | .wikiEditor-toc-header { /* TODO: move parsing to highlight module and rename this */ |
60 | 71 | display: inline; |