Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -25,16 +25,16 @@ |
26 | 26 | array( 'src' => 'css/wikiEditor.dialogs.css', 'version' => 10 ), |
27 | 27 | array( 'src' => 'css/wikiEditor.preview.css', 'version' => 1 ), |
28 | 28 | array( 'src' => 'css/wikiEditor.templateEditor.css', 'version' => 1 ), |
29 | | - array( 'src' => 'css/wikiEditor.toc.css', 'version' => 26 ), |
| 29 | + array( 'src' => 'css/wikiEditor.toc.css', 'version' => 27 ), |
30 | 30 | array( 'src' => 'css/wikiEditor.toolbar.css', 'version' => 9 ), |
31 | 31 | array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2y' ), |
32 | 32 | ), |
33 | 33 | 'combined' => array( |
34 | | - array( 'src' => 'css/combined.css', 'version' => 49 ), |
| 34 | + array( 'src' => 'css/combined.css', 'version' => 50 ), |
35 | 35 | array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2y' ), |
36 | 36 | ), |
37 | 37 | 'minified' => array( |
38 | | - array( 'src' => 'css/combined.min.css', 'version' => 49 ), |
| 38 | + array( 'src' => 'css/combined.min.css', 'version' => 50 ), |
39 | 39 | array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2y' ), |
40 | 40 | ), |
41 | 41 | ) |
— | — | @@ -173,7 +173,7 @@ |
174 | 174 | array( |
175 | 175 | 'src' => 'js/plugins/jquery.wikiEditor.toc.js', |
176 | 176 | 'class' => 'j.wikiEditor.modules.toc', |
177 | | - 'version' => 62 |
| 177 | + 'version' => 63 |
178 | 178 | ), |
179 | 179 | array( |
180 | 180 | 'src' => 'js/plugins/jquery.wikiEditor.preview.js', |
— | — | @@ -191,10 +191,10 @@ |
192 | 192 | 'version' => 1 ), |
193 | 193 | ), |
194 | 194 | 'combined' => array( |
195 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 155 ), |
| 195 | + array( 'src' => 'js/plugins.combined.js', 'version' => 156 ), |
196 | 196 | ), |
197 | 197 | 'minified' => array( |
198 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 155 ), |
| 198 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 156 ), |
199 | 199 | ), |
200 | 200 | ), |
201 | 201 | ); |
Index: trunk/extensions/UsabilityInitiative/css/wikiEditor.toc.css |
— | — | @@ -202,3 +202,21 @@ |
203 | 203 | .wikiEditor-ui-text textarea:focus { |
204 | 204 | outline: none; |
205 | 205 | } |
| 206 | + |
| 207 | +/* Self Clearing for the wikiText view */ |
| 208 | +.wikiEditor-ui-view-wikiText:after { |
| 209 | + content: "."; |
| 210 | + display: block; |
| 211 | + height: 0; |
| 212 | + clear: both; |
| 213 | + visibility: hidden; |
| 214 | +} |
| 215 | +.wikiEditor-ui-view-wikiText { |
| 216 | + display: inline-block; |
| 217 | +} |
| 218 | +* html .wikiEditor-ui-view-wikiText { |
| 219 | + height: 1%; |
| 220 | +} |
| 221 | +.wikiEditor-ui-view-wikiText { |
| 222 | + display:block; |
| 223 | +} |
\ No newline at end of file |
Index: trunk/extensions/UsabilityInitiative/css/combined.css |
— | — | @@ -468,8 +468,25 @@ |
469 | 469 | .wikiEditor-ui-text textarea:focus { |
470 | 470 | outline: none; |
471 | 471 | } |
472 | | -/* wikiEditor toolbar module */ |
473 | 472 | |
| 473 | +/* Self Clearing for the wikiText view */ |
| 474 | +.wikiEditor-ui-view-wikiText:after { |
| 475 | + content: "."; |
| 476 | + display: block; |
| 477 | + height: 0; |
| 478 | + clear: both; |
| 479 | + visibility: hidden; |
| 480 | +} |
| 481 | +.wikiEditor-ui-view-wikiText { |
| 482 | + display: inline-block; |
| 483 | +} |
| 484 | +* html .wikiEditor-ui-view-wikiText { |
| 485 | + height: 1%; |
| 486 | +} |
| 487 | +.wikiEditor-ui-view-wikiText { |
| 488 | + display:block; |
| 489 | +}/* wikiEditor toolbar module */ |
| 490 | + |
474 | 491 | .wikiEditor-ui-toolbar { |
475 | 492 | position: relative; |
476 | 493 | width: 100%; |
Index: trunk/extensions/UsabilityInitiative/css/combined.min.css |
— | — | @@ -439,6 +439,22 @@ |
440 | 440 | .wikiEditor-ui-text textarea:focus{ |
441 | 441 | outline:none; |
442 | 442 | } |
| 443 | +.wikiEditor-ui-view-wikiText:after{ |
| 444 | +content:"."; |
| 445 | +display:block; |
| 446 | +height:0; |
| 447 | +clear:both; |
| 448 | +visibility:hidden; |
| 449 | +} |
| 450 | +.wikiEditor-ui-view-wikiText{ |
| 451 | +display:inline-block; |
| 452 | +} |
| 453 | +* html .wikiEditor-ui-view-wikiText{ |
| 454 | +height:1%; |
| 455 | +} |
| 456 | +.wikiEditor-ui-view-wikiText{ |
| 457 | +display:block; |
| 458 | +} |
443 | 459 | .wikiEditor-ui-toolbar{ |
444 | 460 | position:relative; |
445 | 461 | width:100%; |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js |
— | — | @@ -9,6 +9,8 @@ |
10 | 10 | defaultWidth: '166px', |
11 | 11 | // Minimum width to allow resizing to before collapsing the table of contents - used when resizing and collapsing |
12 | 12 | minimumWidth: '70px', |
| 13 | + // Minimum width of the wikiText area |
| 14 | + textMinimumWidth: '450px', |
13 | 15 | // Boolean var indicating text direction |
14 | 16 | rtl: false |
15 | 17 | }, |
— | — | @@ -33,12 +35,39 @@ |
34 | 36 | var context = event.data.context; |
35 | 37 | $.wikiEditor.modules.toc.fn.unhighlight( context ); |
36 | 38 | }); |
| 39 | + $.wikiEditor.modules.toc.evt.resize( context ); |
37 | 40 | }, |
38 | 41 | resize: function( context, event ) { |
| 42 | + var availableWidth = context.$wikitext.width() - parseFloat( $.wikiEditor.modules.toc.cfg.textMinimumWidth ), |
| 43 | + totalMinWidth = parseFloat( $.wikiEditor.modules.toc.cfg.minimumWidth ) + |
| 44 | + parseFloat( $.wikiEditor.modules.toc.cfg.textMinimumWidth ); |
| 45 | + context.$ui.find( '.wikiEditor-ui-right' ) |
| 46 | + .resizable( 'option', 'maxWidth', availableWidth ); |
| 47 | + if ( context.modules.toc.$toc.data( 'positionMode' ) != 'disabled' && |
| 48 | + context.$wikitext.width() < totalMinWidth ) { |
| 49 | + $.wikiEditor.modules.toc.fn.disable( context ); |
| 50 | + } else if ( context.modules.toc.$toc.data( 'positionMode' ) == 'disabled' && |
| 51 | + context.$wikitext.width() > totalMinWidth ) { |
| 52 | + $.wikiEditor.modules.toc.fn.enable( context ); |
| 53 | + } else if ( context.modules.toc.$toc.data( 'positionMode' ) == 'regular' && |
| 54 | + context.$ui.find( '.wikiEditor-ui-right' ).width() > availableWidth ) { |
| 55 | + //switch mode |
| 56 | + $.wikiEditor.modules.toc.fn.switchLayout( context ); |
| 57 | + } else if ( context.modules.toc.$toc.data( 'positionMode' ) == 'goofy' && |
| 58 | + context.modules.toc.$toc.data( 'previousWidth' ) < context.$wikitext.width() ) { |
| 59 | + //switch mode |
| 60 | + $.wikiEditor.modules.toc.fn.switchLayout( context ); |
| 61 | + } |
| 62 | + if ( context.modules.toc.$toc.data( 'positionMode' ) == 'goofy' ) { |
| 63 | + context.modules.toc.$toc.find( 'div' ).autoEllipsis( { 'position': 'right', 'tooltip': true, 'restoreText': true } ); |
| 64 | + } |
| 65 | + // reset the height of the TOC |
39 | 66 | context.modules.toc.$toc.height( |
40 | 67 | context.$ui.find( '.wikiEditor-ui-left' ).height() - |
41 | 68 | context.$ui.find( '.tab-toc' ).outerHeight() |
42 | 69 | ); |
| 70 | + // store the width of the view for comparison on next resize |
| 71 | + context.modules.toc.$toc.data( 'previousWidth', context.$wikitext.width() ); |
43 | 72 | }, |
44 | 73 | mark: function( context, event ) { |
45 | 74 | var markers = context.modules.highlight.markers; |
— | — | @@ -98,19 +127,109 @@ |
99 | 128 | var height = context.$ui.find( '.wikiEditor-ui-left' ).height(); |
100 | 129 | context.modules.toc.$toc = $( '<div />' ) |
101 | 130 | .addClass( 'wikiEditor-ui-toc' ) |
102 | | - .data( 'context', context ); |
103 | | - context.$ui.find( '.wikiEditor-ui-right' ) |
104 | | - .css( 'width', $.wikiEditor.modules.toc.cfg.defaultWidth ) |
105 | | - .append( context.modules.toc.$toc ); |
106 | | - context.modules.toc.$toc.height( |
107 | | - context.$ui.find( '.wikiEditor-ui-left' ).height() |
108 | | - ); |
109 | | - context.$ui.find( '.wikiEditor-ui-left' ) |
110 | | - .css( 'marginRight', "-" + $.wikiEditor.modules.toc.cfg.defaultWidth ) |
111 | | - .children() |
112 | | - .css( 'marginRight', $.wikiEditor.modules.toc.cfg.defaultWidth ); |
| 131 | + .data( 'context', context ) |
| 132 | + .data( 'positionMode', 'regular' ) |
| 133 | + .data( 'collapsed', false ); |
| 134 | + /* context.$ui.find( '.wikiEditor-ui-right' ) |
| 135 | + .css( 'width', $.wikiEditor.modules.toc.cfg.defaultWidth ) |
| 136 | + .append( context.modules.toc.$toc ); |
| 137 | + context.modules.toc.$toc.height( |
| 138 | + context.$ui.find( '.wikiEditor-ui-left' ).height() |
| 139 | + ); |
| 140 | + context.$ui.find( '.wikiEditor-ui-left' ) |
| 141 | + .css( 'marginRight', "-" + $.wikiEditor.modules.toc.cfg.defaultWidth ) |
| 142 | + .children() |
| 143 | + .css( 'marginRight', $.wikiEditor.modules.toc.cfg.defaultWidth ); |
| 144 | + */ |
| 145 | + context.$ui.find( '.wikiEditor-ui-right' ) |
| 146 | + .append( context.modules.toc.$toc ); |
| 147 | + context.modules.toc.$toc.height( |
| 148 | + context.$ui.find( '.wikiEditor-ui-left' ).height() |
| 149 | + ); |
| 150 | + $.wikiEditor.modules.toc.fn.redraw( context, $.wikiEditor.modules.toc.cfg.defaultWidth ); |
| 151 | + }, |
| 152 | + |
| 153 | + |
| 154 | + redraw: function( context, fixedWidth ) { |
| 155 | + var fixedWidth = parseFloat( fixedWidth ); |
| 156 | + if( context.modules.toc.$toc.data( 'positionMode' ) == 'regular' ) { |
| 157 | + context.$ui.find( '.wikiEditor-ui-right' ) |
| 158 | + .css( 'width', fixedWidth + 'px' ); |
| 159 | + context.$ui.find( '.wikiEditor-ui-left' ) |
| 160 | + .css( 'marginRight', ( -1 * fixedWidth ) + 'px' ) |
| 161 | + .children() |
| 162 | + .css( 'marginRight', fixedWidth + 'px' ); |
| 163 | + } else if( context.modules.toc.$toc.data( 'positionMode' ) == 'goofy' ) { |
| 164 | + context.$ui.find( '.wikiEditor-ui-left' ) |
| 165 | + .css( 'width', fixedWidth ); |
| 166 | + context.$ui.find( '.wikiEditor-ui-right' ) |
| 167 | + .css( 'left', fixedWidth ); |
| 168 | + context.$wikitext.css( 'height', context.$ui.find( '.wikiEditor-ui-right' ).height() ); |
| 169 | + } |
113 | 170 | }, |
114 | | - |
| 171 | + switchLayout: function( context ) { |
| 172 | + var width, |
| 173 | + height = context.$ui.find( '.wikiEditor-ui-right' ).height(); |
| 174 | + if( context.modules.toc.$toc.data( 'positionMode' ) == 'regular' |
| 175 | + && !context.modules.toc.$toc.data( 'collapsed' ) ) { |
| 176 | + // store position mode |
| 177 | + context.modules.toc.$toc.data( 'positionMode', 'goofy' ); |
| 178 | + // store the width of the TOC, to ensure we dont allow it to be larger than this when switching back |
| 179 | + context.modules.toc.$toc.data( 'positionModeChangeAt', |
| 180 | + context.$ui.find( '.wikiEditor-ui-right' ).width() ); |
| 181 | + width = $.wikiEditor.modules.toc.cfg.textMinimumWidth; |
| 182 | + // set our styles for goofy mode |
| 183 | + context.$ui.find( '.wikiEditor-ui-left' ) |
| 184 | + .css( { 'marginRight': '', 'position': 'absolute', 'left': '0px', 'right': 'auto', 'float': 'none' } ) |
| 185 | + .children() |
| 186 | + .css( 'marginRight', '' ); |
| 187 | + context.$ui.find( '.wikiEditor-ui-right' ) |
| 188 | + .css( { 'width': '100%', 'position': 'absolute', 'right': '0px', 'width': 'auto', 'float': 'none' } ); |
| 189 | + context.$wikitext |
| 190 | + .css( 'position', 'relative' ); |
| 191 | + } else if ( context.modules.toc.$toc.data( 'positionMode' ) == 'goofy' ) { |
| 192 | + // store position mode |
| 193 | + context.modules.toc.$toc.data( 'positionMode', 'regular' ); |
| 194 | + // set width |
| 195 | + width = context.$wikitext.width() - context.$ui.find( '.wikiEditor-ui-left' ).width(); |
| 196 | + if ( width > context.modules.toc.$toc.data( 'positionModeChangeAt' ) ) { |
| 197 | + width = context.modules.toc.$toc.data( 'positionModeChangeAt' ); |
| 198 | + } |
| 199 | + // set our styles for regular mode |
| 200 | + context.$wikitext |
| 201 | + .css( { 'position': '', 'height': '' } ); |
| 202 | + context.$ui.find( '.wikiEditor-ui-right' ) |
| 203 | + .css( { 'marginRight': '', 'position': '', 'left': '', 'right': '', 'float': '', 'top': '', 'height': '' } ); |
| 204 | + context.$ui.find( '.wikiEditor-ui-left' ) |
| 205 | + .css( { 'width': '', 'position': '', 'left': '', 'float': '', 'right': '' } ); |
| 206 | + } |
| 207 | + $.wikiEditor.modules.toc.fn.redraw( context, width ); |
| 208 | + }, |
| 209 | + disable: function( context ) { |
| 210 | + if ( context.modules.toc.$toc.data( 'collapsed' ) ) { |
| 211 | + context.$ui.find( '.wikiEditor-ui-toc-expandControl' ).hide(); |
| 212 | + } else { |
| 213 | + if( context.modules.toc.$toc.data( 'positionMode' ) == 'goofy' ) { |
| 214 | + $.wikiEditor.modules.toc.fn.switchLayout( context ); |
| 215 | + } |
| 216 | + context.$ui.find( '.wikiEditor-ui-right' ).hide(); |
| 217 | + context.$ui.find( '.wikiEditor-ui-left' ) |
| 218 | + .css( 'marginRight', '' ) |
| 219 | + .children() |
| 220 | + .css( 'marginRight', '' ); |
| 221 | + } |
| 222 | + context.modules.toc.$toc.data( 'positionMode', 'disabled' ); |
| 223 | + }, |
| 224 | + enable: function( context ) { |
| 225 | + context.modules.toc.$toc.data( 'positionMode', 'regular' ); |
| 226 | + if ( context.modules.toc.$toc.data( 'collapsed' ) ) { |
| 227 | + context.$ui.find( '.wikiEditor-ui-toc-expandControl' ).show(); |
| 228 | + } else { |
| 229 | + context.$ui.find( '.wikiEditor-ui-right' ).show(); |
| 230 | + $.wikiEditor.modules.toc.fn.redraw( context, $.wikiEditor.modules.toc.cfg.minimumWidth ); |
| 231 | + context.modules.toc.$toc.find( 'div' ).autoEllipsis( { 'position': 'right', 'tooltip': true, 'restoreText': true } ); |
| 232 | + } |
| 233 | + }, |
115 | 234 | unhighlight: function( context ) { |
116 | 235 | context.modules.toc.$toc.find( 'div' ).removeClass( 'current' ); |
117 | 236 | }, |
— | — | @@ -149,9 +268,21 @@ |
150 | 269 | */ |
151 | 270 | collapse: function( event ) { |
152 | 271 | var $this = $( this ), |
153 | | - context = $this.data( 'context' ), |
154 | | - pT = $this.parent().position().top - 1; |
155 | | - $this.parent() |
| 272 | + context = $this.data( 'context' ); |
| 273 | + if( context.modules.toc.$toc.data( 'positionMode' ) == 'goofy' ) { |
| 274 | + $.wikiEditor.modules.toc.fn.switchLayout( context ); |
| 275 | + } |
| 276 | + var pT = $this.parent().position().top - 1; |
| 277 | + context.modules.toc.$toc.data( 'collapsed', true ); |
| 278 | + context.$ui.find( '.wikiEditor-ui-left' ) |
| 279 | + .animate( { 'marginRight': '-1px' }, 'fast', function() { |
| 280 | + $( this ).css( 'marginRight', 0 ); |
| 281 | + } ) |
| 282 | + .children() |
| 283 | + .animate( { 'marginRight': '1px' }, 'fast', function() { |
| 284 | + $( this ).css( 'marginRight', 0 ); |
| 285 | + } ); |
| 286 | + context.$ui.find( '.wikiEditor-ui-right' ) |
156 | 287 | .css( { |
157 | 288 | 'marginTop' : '1px', |
158 | 289 | 'position' : 'absolute', |
— | — | @@ -162,15 +293,10 @@ |
163 | 294 | $( this ).hide() |
164 | 295 | .css( { 'marginTop': '0', 'width': '1px' } ); |
165 | 296 | context.$ui.find( '.wikiEditor-ui-toc-expandControl' ).fadeIn( 'fast' ); |
166 | | - } ) |
167 | | - .prev() |
168 | | - .animate( { 'marginRight': '-1px' }, 'fast', function() { |
169 | | - $( this ).css( 'marginRight', 0 ); |
170 | 297 | // Let the UI know things have moved around |
171 | 298 | context.fn.trigger( 'resize' ); |
172 | | - } ) |
173 | | - .children() |
174 | | - .animate( { 'marginRight': '1px' }, 'fast', function() { $( this ).css( 'marginRight', 0 ); } ); |
| 299 | + } ); |
| 300 | + |
175 | 301 | $.cookie( 'wikiEditor-' + context.instance + '-toc-width', 0 ); |
176 | 302 | return false; |
177 | 303 | }, |
— | — | @@ -183,9 +309,18 @@ |
184 | 310 | expand: function( event ) { |
185 | 311 | var $this = $( this ), |
186 | 312 | context = $this.data( 'context' ), |
187 | | - openWidth = context.modules.toc.$toc.data( 'openWidth' ); |
| 313 | + openWidth = parseFloat( context.modules.toc.$toc.data( 'openWidth' ) ), |
| 314 | + availableSpace = context.$wikitext.width() - parseFloat( $.wikiEditor.modules.toc.cfg.textMinimumWidth ); |
| 315 | + if ( availableSpace < $.wikiEditor.modules.toc.cfg.textMinmumWidth ) return false; |
| 316 | + context.modules.toc.$toc.data( 'collapsed', false ); |
| 317 | + // check if we've got enough room to open to our stored width |
| 318 | + if ( availableSpace < openWidth ) openWidth = availableSpace; |
188 | 319 | context.$ui.find( '.wikiEditor-ui-toc-expandControl' ).hide(); |
189 | | - $this.parent() |
| 320 | + context.$ui.find( '.wikiEditor-ui-left' ) |
| 321 | + .animate( { 'marginRight': ( parseFloat( openWidth ) * -1 ) }, 'fast' ) |
| 322 | + .children() |
| 323 | + .animate( { 'marginRight': openWidth }, 'fast' ); |
| 324 | + context.$ui.find( '.wikiEditor-ui-right' ) |
190 | 325 | .show() |
191 | 326 | .css( 'marginTop', '1px' ) |
192 | 327 | .animate( { 'width' : openWidth }, 'fast', function() { |
— | — | @@ -196,14 +331,8 @@ |
197 | 332 | 'right' : 'auto', |
198 | 333 | 'left' : 'auto', |
199 | 334 | 'top': 'auto' } ); |
200 | | - } ) |
201 | | - .prev() |
202 | | - .animate( { 'marginRight': ( parseFloat( openWidth ) * -1 ) }, 'fast' ) |
203 | | - .children() |
204 | | - .animate( { 'marginRight': openWidth }, 'fast', function() { |
205 | | - // Let the UI know things have moved around |
206 | | - context.fn.trigger( 'resize' ); |
207 | | - } ); |
| 335 | + context.fn.trigger( 'resize' ); |
| 336 | + } ); |
208 | 337 | $.cookie( 'wikiEditor-' + context.instance + '-toc-width', |
209 | 338 | context.modules.toc.$toc.data( 'openWidth' ) ); |
210 | 339 | return false; |
— | — | @@ -302,7 +431,6 @@ |
303 | 432 | .text( gM( 'wikieditor-toc-show' ) ); |
304 | 433 | $collapseControl.insertBefore( context.modules.toc.$toc ); |
305 | 434 | context.$ui.find( '.wikiEditor-ui-left .wikiEditor-ui-top' ).append( $expandControl ); |
306 | | - context.fn.trigger( 'resize' ); |
307 | 435 | } |
308 | 436 | /** |
309 | 437 | * Initializes resizing controls on the TOC and sets the width of |
— | — | @@ -314,7 +442,8 @@ |
315 | 443 | .data( 'resizableDone', true ) |
316 | 444 | .find( '.wikiEditor-ui-right' ) |
317 | 445 | .data( 'wikiEditor-ui-left', context.$ui.find( '.wikiEditor-ui-left' ) ) |
318 | | - .resizable( { handles: 'w,e', preventPositionLeftChange: true, minWidth: 50, |
| 446 | + .resizable( { handles: 'w,e', preventPositionLeftChange: true, |
| 447 | + minWidth: parseFloat( $.wikiEditor.modules.toc.cfg.minimumWidth ), |
319 | 448 | start: function( e, ui ) { |
320 | 449 | var $this = $( this ); |
321 | 450 | // Toss a transparent cover over our iframe |
— | — | @@ -329,7 +458,11 @@ |
330 | 459 | 'right': 0 |
331 | 460 | } ) |
332 | 461 | .appendTo( context.$ui.find( '.wikiEditor-ui-left' ) ); |
333 | | - $this.resizable( 'option', 'maxWidth', $this.parent().width() - 450 ); |
| 462 | + $this.resizable( 'option', 'maxWidth', $this.parent().width() - |
| 463 | + parseFloat( $.wikiEditor.modules.toc.cfg.textMinimumWidth ) ); |
| 464 | + if(context.modules.toc.$toc.data( 'positionMode' ) == 'goofy' ) { |
| 465 | + $.wikiEditor.modules.toc.fn.switchLayout( context ); |
| 466 | + } |
334 | 467 | }, |
335 | 468 | resize: function( e, ui ) { |
336 | 469 | // for some odd reason, ui.size.width seems a step ahead of what the *actual* width of |
— | — | @@ -344,7 +477,7 @@ |
345 | 478 | context.$ui.find( '.wikiEditor-ui-resize-mask' ).remove(); |
346 | 479 | context.$content.trigger( 'mouseup' ); |
347 | 480 | if( ui.size.width < parseFloat( $.wikiEditor.modules.toc.cfg.minimumWidth ) ) { |
348 | | - context.modules.toc.$toc.trigger( 'collapse' ); |
| 481 | + context.modules.toc.$toc.trigger( 'collapse.wikiEditor-toc' ); |
349 | 482 | } else { |
350 | 483 | context.modules.toc.$toc.find( 'div' ).autoEllipsis( { 'position': 'right', 'tooltip': true, 'restoreText': true } ); |
351 | 484 | context.modules.toc.$toc.data( 'openWidth', ui.size.width ); |
— | — | @@ -373,12 +506,7 @@ |
374 | 507 | if( initialWidth < parseFloat( $.wikiEditor.modules.toc.cfg.minimumWidth ) ) |
375 | 508 | initialWidth = parseFloat( $.wikiEditor.modules.toc.cfg.minimumWidth ) + 1; |
376 | 509 | context.modules.toc.$toc.data( 'openWidth', initialWidth + 'px' ); |
377 | | - context.$ui.find( '.wikiEditor-ui-right' ) |
378 | | - .css( 'width', initialWidth + 'px' ); |
379 | | - context.$ui.find( '.wikiEditor-ui-left' ) |
380 | | - .css( 'marginRight', ( parseFloat( initialWidth ) * -1 ) + 'px' ) |
381 | | - .children() |
382 | | - .css( 'marginRight', initialWidth + 'px' ); |
| 510 | + $.wikiEditor.modules.toc.fn.redraw( context, initialWidth ); |
383 | 511 | } |
384 | 512 | } |
385 | 513 | |
— | — | @@ -407,7 +535,7 @@ |
408 | 536 | // section 0, if needed |
409 | 537 | var structure = buildStructure( outline ); |
410 | 538 | if ( $( 'input[name=wpSection]' ).val() == '' ) { |
411 | | - structure.unshift( { 'text': wgPageName.replace(/_/g, ' '), 'level': 1, 'index': 0 } ); |
| 539 | + structure.unshift( { 'text': wgPageName.replace( /_/g, ' ' ), 'level': 1, 'index': 0 } ); |
412 | 540 | } |
413 | 541 | context.modules.toc.$toc.html( buildList( structure ) ); |
414 | 542 | |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -8577,6 +8577,8 @@ |
8578 | 8578 | defaultWidth: '166px', |
8579 | 8579 | // Minimum width to allow resizing to before collapsing the table of contents - used when resizing and collapsing |
8580 | 8580 | minimumWidth: '70px', |
| 8581 | + // Minimum width of the wikiText area |
| 8582 | + textMinimumWidth: '450px', |
8581 | 8583 | // Boolean var indicating text direction |
8582 | 8584 | rtl: false |
8583 | 8585 | }, |
— | — | @@ -8601,12 +8603,39 @@ |
8602 | 8604 | var context = event.data.context; |
8603 | 8605 | $.wikiEditor.modules.toc.fn.unhighlight( context ); |
8604 | 8606 | }); |
| 8607 | + $.wikiEditor.modules.toc.evt.resize( context ); |
8605 | 8608 | }, |
8606 | 8609 | resize: function( context, event ) { |
| 8610 | + var availableWidth = context.$wikitext.width() - parseFloat( $.wikiEditor.modules.toc.cfg.textMinimumWidth ), |
| 8611 | + totalMinWidth = parseFloat( $.wikiEditor.modules.toc.cfg.minimumWidth ) + |
| 8612 | + parseFloat( $.wikiEditor.modules.toc.cfg.textMinimumWidth ); |
| 8613 | + context.$ui.find( '.wikiEditor-ui-right' ) |
| 8614 | + .resizable( 'option', 'maxWidth', availableWidth ); |
| 8615 | + if ( context.modules.toc.$toc.data( 'positionMode' ) != 'disabled' && |
| 8616 | + context.$wikitext.width() < totalMinWidth ) { |
| 8617 | + $.wikiEditor.modules.toc.fn.disable( context ); |
| 8618 | + } else if ( context.modules.toc.$toc.data( 'positionMode' ) == 'disabled' && |
| 8619 | + context.$wikitext.width() > totalMinWidth ) { |
| 8620 | + $.wikiEditor.modules.toc.fn.enable( context ); |
| 8621 | + } else if ( context.modules.toc.$toc.data( 'positionMode' ) == 'regular' && |
| 8622 | + context.$ui.find( '.wikiEditor-ui-right' ).width() > availableWidth ) { |
| 8623 | + //switch mode |
| 8624 | + $.wikiEditor.modules.toc.fn.switchLayout( context ); |
| 8625 | + } else if ( context.modules.toc.$toc.data( 'positionMode' ) == 'goofy' && |
| 8626 | + context.modules.toc.$toc.data( 'previousWidth' ) < context.$wikitext.width() ) { |
| 8627 | + //switch mode |
| 8628 | + $.wikiEditor.modules.toc.fn.switchLayout( context ); |
| 8629 | + } |
| 8630 | + if ( context.modules.toc.$toc.data( 'positionMode' ) == 'goofy' ) { |
| 8631 | + context.modules.toc.$toc.find( 'div' ).autoEllipsis( { 'position': 'right', 'tooltip': true, 'restoreText': true } ); |
| 8632 | + } |
| 8633 | + // reset the height of the TOC |
8607 | 8634 | context.modules.toc.$toc.height( |
8608 | 8635 | context.$ui.find( '.wikiEditor-ui-left' ).height() - |
8609 | 8636 | context.$ui.find( '.tab-toc' ).outerHeight() |
8610 | 8637 | ); |
| 8638 | + // store the width of the view for comparison on next resize |
| 8639 | + context.modules.toc.$toc.data( 'previousWidth', context.$wikitext.width() ); |
8611 | 8640 | }, |
8612 | 8641 | mark: function( context, event ) { |
8613 | 8642 | var markers = context.modules.highlight.markers; |
— | — | @@ -8666,19 +8695,109 @@ |
8667 | 8696 | var height = context.$ui.find( '.wikiEditor-ui-left' ).height(); |
8668 | 8697 | context.modules.toc.$toc = $( '<div />' ) |
8669 | 8698 | .addClass( 'wikiEditor-ui-toc' ) |
8670 | | - .data( 'context', context ); |
8671 | | - context.$ui.find( '.wikiEditor-ui-right' ) |
8672 | | - .css( 'width', $.wikiEditor.modules.toc.cfg.defaultWidth ) |
8673 | | - .append( context.modules.toc.$toc ); |
8674 | | - context.modules.toc.$toc.height( |
8675 | | - context.$ui.find( '.wikiEditor-ui-left' ).height() |
8676 | | - ); |
8677 | | - context.$ui.find( '.wikiEditor-ui-left' ) |
8678 | | - .css( 'marginRight', "-" + $.wikiEditor.modules.toc.cfg.defaultWidth ) |
8679 | | - .children() |
8680 | | - .css( 'marginRight', $.wikiEditor.modules.toc.cfg.defaultWidth ); |
| 8699 | + .data( 'context', context ) |
| 8700 | + .data( 'positionMode', 'regular' ) |
| 8701 | + .data( 'collapsed', false ); |
| 8702 | + /* context.$ui.find( '.wikiEditor-ui-right' ) |
| 8703 | + .css( 'width', $.wikiEditor.modules.toc.cfg.defaultWidth ) |
| 8704 | + .append( context.modules.toc.$toc ); |
| 8705 | + context.modules.toc.$toc.height( |
| 8706 | + context.$ui.find( '.wikiEditor-ui-left' ).height() |
| 8707 | + ); |
| 8708 | + context.$ui.find( '.wikiEditor-ui-left' ) |
| 8709 | + .css( 'marginRight', "-" + $.wikiEditor.modules.toc.cfg.defaultWidth ) |
| 8710 | + .children() |
| 8711 | + .css( 'marginRight', $.wikiEditor.modules.toc.cfg.defaultWidth ); |
| 8712 | + */ |
| 8713 | + context.$ui.find( '.wikiEditor-ui-right' ) |
| 8714 | + .append( context.modules.toc.$toc ); |
| 8715 | + context.modules.toc.$toc.height( |
| 8716 | + context.$ui.find( '.wikiEditor-ui-left' ).height() |
| 8717 | + ); |
| 8718 | + $.wikiEditor.modules.toc.fn.redraw( context, $.wikiEditor.modules.toc.cfg.defaultWidth ); |
| 8719 | + }, |
| 8720 | + |
| 8721 | + |
| 8722 | + redraw: function( context, fixedWidth ) { |
| 8723 | + var fixedWidth = parseFloat( fixedWidth ); |
| 8724 | + if( context.modules.toc.$toc.data( 'positionMode' ) == 'regular' ) { |
| 8725 | + context.$ui.find( '.wikiEditor-ui-right' ) |
| 8726 | + .css( 'width', fixedWidth + 'px' ); |
| 8727 | + context.$ui.find( '.wikiEditor-ui-left' ) |
| 8728 | + .css( 'marginRight', ( -1 * fixedWidth ) + 'px' ) |
| 8729 | + .children() |
| 8730 | + .css( 'marginRight', fixedWidth + 'px' ); |
| 8731 | + } else if( context.modules.toc.$toc.data( 'positionMode' ) == 'goofy' ) { |
| 8732 | + context.$ui.find( '.wikiEditor-ui-left' ) |
| 8733 | + .css( 'width', fixedWidth ); |
| 8734 | + context.$ui.find( '.wikiEditor-ui-right' ) |
| 8735 | + .css( 'left', fixedWidth ); |
| 8736 | + context.$wikitext.css( 'height', context.$ui.find( '.wikiEditor-ui-right' ).height() ); |
| 8737 | + } |
8681 | 8738 | }, |
8682 | | - |
| 8739 | + switchLayout: function( context ) { |
| 8740 | + var width, |
| 8741 | + height = context.$ui.find( '.wikiEditor-ui-right' ).height(); |
| 8742 | + if( context.modules.toc.$toc.data( 'positionMode' ) == 'regular' |
| 8743 | + && !context.modules.toc.$toc.data( 'collapsed' ) ) { |
| 8744 | + // store position mode |
| 8745 | + context.modules.toc.$toc.data( 'positionMode', 'goofy' ); |
| 8746 | + // store the width of the TOC, to ensure we dont allow it to be larger than this when switching back |
| 8747 | + context.modules.toc.$toc.data( 'positionModeChangeAt', |
| 8748 | + context.$ui.find( '.wikiEditor-ui-right' ).width() ); |
| 8749 | + width = $.wikiEditor.modules.toc.cfg.textMinimumWidth; |
| 8750 | + // set our styles for goofy mode |
| 8751 | + context.$ui.find( '.wikiEditor-ui-left' ) |
| 8752 | + .css( { 'marginRight': '', 'position': 'absolute', 'left': '0px', 'right': 'auto', 'float': 'none' } ) |
| 8753 | + .children() |
| 8754 | + .css( 'marginRight', '' ); |
| 8755 | + context.$ui.find( '.wikiEditor-ui-right' ) |
| 8756 | + .css( { 'width': '100%', 'position': 'absolute', 'right': '0px', 'width': 'auto', 'float': 'none' } ); |
| 8757 | + context.$wikitext |
| 8758 | + .css( 'position', 'relative' ); |
| 8759 | + } else if ( context.modules.toc.$toc.data( 'positionMode' ) == 'goofy' ) { |
| 8760 | + // store position mode |
| 8761 | + context.modules.toc.$toc.data( 'positionMode', 'regular' ); |
| 8762 | + // set width |
| 8763 | + width = context.$wikitext.width() - context.$ui.find( '.wikiEditor-ui-left' ).width(); |
| 8764 | + if ( width > context.modules.toc.$toc.data( 'positionModeChangeAt' ) ) { |
| 8765 | + width = context.modules.toc.$toc.data( 'positionModeChangeAt' ); |
| 8766 | + } |
| 8767 | + // set our styles for regular mode |
| 8768 | + context.$wikitext |
| 8769 | + .css( { 'position': '', 'height': '' } ); |
| 8770 | + context.$ui.find( '.wikiEditor-ui-right' ) |
| 8771 | + .css( { 'marginRight': '', 'position': '', 'left': '', 'right': '', 'float': '', 'top': '', 'height': '' } ); |
| 8772 | + context.$ui.find( '.wikiEditor-ui-left' ) |
| 8773 | + .css( { 'width': '', 'position': '', 'left': '', 'float': '', 'right': '' } ); |
| 8774 | + } |
| 8775 | + $.wikiEditor.modules.toc.fn.redraw( context, width ); |
| 8776 | + }, |
| 8777 | + disable: function( context ) { |
| 8778 | + if ( context.modules.toc.$toc.data( 'collapsed' ) ) { |
| 8779 | + context.$ui.find( '.wikiEditor-ui-toc-expandControl' ).hide(); |
| 8780 | + } else { |
| 8781 | + if( context.modules.toc.$toc.data( 'positionMode' ) == 'goofy' ) { |
| 8782 | + $.wikiEditor.modules.toc.fn.switchLayout( context ); |
| 8783 | + } |
| 8784 | + context.$ui.find( '.wikiEditor-ui-right' ).hide(); |
| 8785 | + context.$ui.find( '.wikiEditor-ui-left' ) |
| 8786 | + .css( 'marginRight', '' ) |
| 8787 | + .children() |
| 8788 | + .css( 'marginRight', '' ); |
| 8789 | + } |
| 8790 | + context.modules.toc.$toc.data( 'positionMode', 'disabled' ); |
| 8791 | + }, |
| 8792 | + enable: function( context ) { |
| 8793 | + context.modules.toc.$toc.data( 'positionMode', 'regular' ); |
| 8794 | + if ( context.modules.toc.$toc.data( 'collapsed' ) ) { |
| 8795 | + context.$ui.find( '.wikiEditor-ui-toc-expandControl' ).show(); |
| 8796 | + } else { |
| 8797 | + context.$ui.find( '.wikiEditor-ui-right' ).show(); |
| 8798 | + $.wikiEditor.modules.toc.fn.redraw( context, $.wikiEditor.modules.toc.cfg.minimumWidth ); |
| 8799 | + context.modules.toc.$toc.find( 'div' ).autoEllipsis( { 'position': 'right', 'tooltip': true, 'restoreText': true } ); |
| 8800 | + } |
| 8801 | + }, |
8683 | 8802 | unhighlight: function( context ) { |
8684 | 8803 | context.modules.toc.$toc.find( 'div' ).removeClass( 'current' ); |
8685 | 8804 | }, |
— | — | @@ -8717,9 +8836,21 @@ |
8718 | 8837 | */ |
8719 | 8838 | collapse: function( event ) { |
8720 | 8839 | var $this = $( this ), |
8721 | | - context = $this.data( 'context' ), |
8722 | | - pT = $this.parent().position().top - 1; |
8723 | | - $this.parent() |
| 8840 | + context = $this.data( 'context' ); |
| 8841 | + if( context.modules.toc.$toc.data( 'positionMode' ) == 'goofy' ) { |
| 8842 | + $.wikiEditor.modules.toc.fn.switchLayout( context ); |
| 8843 | + } |
| 8844 | + var pT = $this.parent().position().top - 1; |
| 8845 | + context.modules.toc.$toc.data( 'collapsed', true ); |
| 8846 | + context.$ui.find( '.wikiEditor-ui-left' ) |
| 8847 | + .animate( { 'marginRight': '-1px' }, 'fast', function() { |
| 8848 | + $( this ).css( 'marginRight', 0 ); |
| 8849 | + } ) |
| 8850 | + .children() |
| 8851 | + .animate( { 'marginRight': '1px' }, 'fast', function() { |
| 8852 | + $( this ).css( 'marginRight', 0 ); |
| 8853 | + } ); |
| 8854 | + context.$ui.find( '.wikiEditor-ui-right' ) |
8724 | 8855 | .css( { |
8725 | 8856 | 'marginTop' : '1px', |
8726 | 8857 | 'position' : 'absolute', |
— | — | @@ -8730,15 +8861,10 @@ |
8731 | 8862 | $( this ).hide() |
8732 | 8863 | .css( { 'marginTop': '0', 'width': '1px' } ); |
8733 | 8864 | context.$ui.find( '.wikiEditor-ui-toc-expandControl' ).fadeIn( 'fast' ); |
8734 | | - } ) |
8735 | | - .prev() |
8736 | | - .animate( { 'marginRight': '-1px' }, 'fast', function() { |
8737 | | - $( this ).css( 'marginRight', 0 ); |
8738 | 8865 | // Let the UI know things have moved around |
8739 | 8866 | context.fn.trigger( 'resize' ); |
8740 | | - } ) |
8741 | | - .children() |
8742 | | - .animate( { 'marginRight': '1px' }, 'fast', function() { $( this ).css( 'marginRight', 0 ); } ); |
| 8867 | + } ); |
| 8868 | + |
8743 | 8869 | $.cookie( 'wikiEditor-' + context.instance + '-toc-width', 0 ); |
8744 | 8870 | return false; |
8745 | 8871 | }, |
— | — | @@ -8751,9 +8877,18 @@ |
8752 | 8878 | expand: function( event ) { |
8753 | 8879 | var $this = $( this ), |
8754 | 8880 | context = $this.data( 'context' ), |
8755 | | - openWidth = context.modules.toc.$toc.data( 'openWidth' ); |
| 8881 | + openWidth = parseFloat( context.modules.toc.$toc.data( 'openWidth' ) ), |
| 8882 | + availableSpace = context.$wikitext.width() - parseFloat( $.wikiEditor.modules.toc.cfg.textMinimumWidth ); |
| 8883 | + if ( availableSpace < $.wikiEditor.modules.toc.cfg.textMinmumWidth ) return false; |
| 8884 | + context.modules.toc.$toc.data( 'collapsed', false ); |
| 8885 | + // check if we've got enough room to open to our stored width |
| 8886 | + if ( availableSpace < openWidth ) openWidth = availableSpace; |
8756 | 8887 | context.$ui.find( '.wikiEditor-ui-toc-expandControl' ).hide(); |
8757 | | - $this.parent() |
| 8888 | + context.$ui.find( '.wikiEditor-ui-left' ) |
| 8889 | + .animate( { 'marginRight': ( parseFloat( openWidth ) * -1 ) }, 'fast' ) |
| 8890 | + .children() |
| 8891 | + .animate( { 'marginRight': openWidth }, 'fast' ); |
| 8892 | + context.$ui.find( '.wikiEditor-ui-right' ) |
8758 | 8893 | .show() |
8759 | 8894 | .css( 'marginTop', '1px' ) |
8760 | 8895 | .animate( { 'width' : openWidth }, 'fast', function() { |
— | — | @@ -8764,14 +8899,8 @@ |
8765 | 8900 | 'right' : 'auto', |
8766 | 8901 | 'left' : 'auto', |
8767 | 8902 | 'top': 'auto' } ); |
8768 | | - } ) |
8769 | | - .prev() |
8770 | | - .animate( { 'marginRight': ( parseFloat( openWidth ) * -1 ) }, 'fast' ) |
8771 | | - .children() |
8772 | | - .animate( { 'marginRight': openWidth }, 'fast', function() { |
8773 | | - // Let the UI know things have moved around |
8774 | | - context.fn.trigger( 'resize' ); |
8775 | | - } ); |
| 8903 | + context.fn.trigger( 'resize' ); |
| 8904 | + } ); |
8776 | 8905 | $.cookie( 'wikiEditor-' + context.instance + '-toc-width', |
8777 | 8906 | context.modules.toc.$toc.data( 'openWidth' ) ); |
8778 | 8907 | return false; |
— | — | @@ -8870,7 +8999,6 @@ |
8871 | 9000 | .text( gM( 'wikieditor-toc-show' ) ); |
8872 | 9001 | $collapseControl.insertBefore( context.modules.toc.$toc ); |
8873 | 9002 | context.$ui.find( '.wikiEditor-ui-left .wikiEditor-ui-top' ).append( $expandControl ); |
8874 | | - context.fn.trigger( 'resize' ); |
8875 | 9003 | } |
8876 | 9004 | /** |
8877 | 9005 | * Initializes resizing controls on the TOC and sets the width of |
— | — | @@ -8882,7 +9010,8 @@ |
8883 | 9011 | .data( 'resizableDone', true ) |
8884 | 9012 | .find( '.wikiEditor-ui-right' ) |
8885 | 9013 | .data( 'wikiEditor-ui-left', context.$ui.find( '.wikiEditor-ui-left' ) ) |
8886 | | - .resizable( { handles: 'w,e', preventPositionLeftChange: true, minWidth: 50, |
| 9014 | + .resizable( { handles: 'w,e', preventPositionLeftChange: true, |
| 9015 | + minWidth: parseFloat( $.wikiEditor.modules.toc.cfg.minimumWidth ), |
8887 | 9016 | start: function( e, ui ) { |
8888 | 9017 | var $this = $( this ); |
8889 | 9018 | // Toss a transparent cover over our iframe |
— | — | @@ -8897,7 +9026,11 @@ |
8898 | 9027 | 'right': 0 |
8899 | 9028 | } ) |
8900 | 9029 | .appendTo( context.$ui.find( '.wikiEditor-ui-left' ) ); |
8901 | | - $this.resizable( 'option', 'maxWidth', $this.parent().width() - 450 ); |
| 9030 | + $this.resizable( 'option', 'maxWidth', $this.parent().width() - |
| 9031 | + parseFloat( $.wikiEditor.modules.toc.cfg.textMinimumWidth ) ); |
| 9032 | + if(context.modules.toc.$toc.data( 'positionMode' ) == 'goofy' ) { |
| 9033 | + $.wikiEditor.modules.toc.fn.switchLayout( context ); |
| 9034 | + } |
8902 | 9035 | }, |
8903 | 9036 | resize: function( e, ui ) { |
8904 | 9037 | // for some odd reason, ui.size.width seems a step ahead of what the *actual* width of |
— | — | @@ -8912,7 +9045,7 @@ |
8913 | 9046 | context.$ui.find( '.wikiEditor-ui-resize-mask' ).remove(); |
8914 | 9047 | context.$content.trigger( 'mouseup' ); |
8915 | 9048 | if( ui.size.width < parseFloat( $.wikiEditor.modules.toc.cfg.minimumWidth ) ) { |
8916 | | - context.modules.toc.$toc.trigger( 'collapse' ); |
| 9049 | + context.modules.toc.$toc.trigger( 'collapse.wikiEditor-toc' ); |
8917 | 9050 | } else { |
8918 | 9051 | context.modules.toc.$toc.find( 'div' ).autoEllipsis( { 'position': 'right', 'tooltip': true, 'restoreText': true } ); |
8919 | 9052 | context.modules.toc.$toc.data( 'openWidth', ui.size.width ); |
— | — | @@ -8941,12 +9074,7 @@ |
8942 | 9075 | if( initialWidth < parseFloat( $.wikiEditor.modules.toc.cfg.minimumWidth ) ) |
8943 | 9076 | initialWidth = parseFloat( $.wikiEditor.modules.toc.cfg.minimumWidth ) + 1; |
8944 | 9077 | context.modules.toc.$toc.data( 'openWidth', initialWidth + 'px' ); |
8945 | | - context.$ui.find( '.wikiEditor-ui-right' ) |
8946 | | - .css( 'width', initialWidth + 'px' ); |
8947 | | - context.$ui.find( '.wikiEditor-ui-left' ) |
8948 | | - .css( 'marginRight', ( parseFloat( initialWidth ) * -1 ) + 'px' ) |
8949 | | - .children() |
8950 | | - .css( 'marginRight', initialWidth + 'px' ); |
| 9078 | + $.wikiEditor.modules.toc.fn.redraw( context, initialWidth ); |
8951 | 9079 | } |
8952 | 9080 | } |
8953 | 9081 | |
— | — | @@ -8975,7 +9103,7 @@ |
8976 | 9104 | // section 0, if needed |
8977 | 9105 | var structure = buildStructure( outline ); |
8978 | 9106 | if ( $( 'input[name=wpSection]' ).val() == '' ) { |
8979 | | - structure.unshift( { 'text': wgPageName.replace(/_/g, ' '), 'level': 1, 'index': 0 } ); |
| 9107 | + structure.unshift( { 'text': wgPageName.replace( /_/g, ' ' ), 'level': 1, 'index': 0 } ); |
8980 | 9108 | } |
8981 | 9109 | context.modules.toc.$toc.html( buildList( structure ) ); |
8982 | 9110 | |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -571,13 +571,21 @@ |
572 | 572 | nameEndIndex=nameEnd.index+oldDivider+2;ranges.push(new Range(ranges[ranges.length-1].end,nameBeginIndex));nameIndex=ranges.push(new Range(nameBeginIndex,nameEndIndex))-1;currentValue=currentField.substring(currentField.indexOf('=')+1);oldDivider+=currentField.indexOf('=')+1;valueBegin=currentValue.match(/\S+/);if(valueBegin==null){continue;} |
573 | 573 | valueBeginIndex=valueBegin.index+oldDivider+1;valueEnd=currentValue.match(/[^\s]\s*$/);if(valueEnd==null){continue;} |
574 | 574 | valueEndIndex=valueEnd.index+oldDivider+2;equalsIndex=ranges.push(new Range(ranges[ranges.length-1].end,valueBeginIndex))-1;valueIndex=ranges.push(new Range(valueBeginIndex,valueEndIndex))-1;params.push(new Param(wikitext.substring(nameBeginIndex,nameEndIndex),wikitext.substring(valueBeginIndex,valueEndIndex),currentParamNumber,nameIndex,equalsIndex,valueIndex));paramsByName[wikitext.substring(nameBeginIndex,nameEndIndex)]=currentParamNumber;}} |
575 | | -ranges.push(new Range(valueEndIndex,wikitext.length));this.ranges=ranges;this.wikitext=wikitext;this.params=params;this.paramsByName=paramsByName;this.templateNameIndex=templateNameIndex;}}};})(jQuery);(function($){$.wikiEditor.modules.toc={cfg:{defaultWidth:'166px',minimumWidth:'70px',rtl:false},api:{},evt:{change:function(context,event){$.wikiEditor.modules.toc.fn.update(context);},ready:function(context,event){$.wikiEditor.modules.toc.fn.build(context);context.$content.parent().blur(function(){var context=event.data.context;$.wikiEditor.modules.toc.fn.unhighlight(context);});},resize:function(context,event){context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height()- |
576 | | -context.$ui.find('.tab-toc').outerHeight());},mark:function(context,event){var markers=context.modules.highlight.markers;var tokenArray=context.modules.highlight.tokenArray;var outline=context.data.outline=[];var h=0;for(var i=0;i<tokenArray.length;i++){if(tokenArray[i].label!='TOC_HEADER'){continue;} |
| 575 | +ranges.push(new Range(valueEndIndex,wikitext.length));this.ranges=ranges;this.wikitext=wikitext;this.params=params;this.paramsByName=paramsByName;this.templateNameIndex=templateNameIndex;}}};})(jQuery);(function($){$.wikiEditor.modules.toc={cfg:{defaultWidth:'166px',minimumWidth:'70px',textMinimumWidth:'450px',rtl:false},api:{},evt:{change:function(context,event){$.wikiEditor.modules.toc.fn.update(context);},ready:function(context,event){$.wikiEditor.modules.toc.fn.build(context);context.$content.parent().blur(function(){var context=event.data.context;$.wikiEditor.modules.toc.fn.unhighlight(context);});$.wikiEditor.modules.toc.evt.resize(context);},resize:function(context,event){var availableWidth=context.$wikitext.width()-parseFloat($.wikiEditor.modules.toc.cfg.textMinimumWidth),totalMinWidth=parseFloat($.wikiEditor.modules.toc.cfg.minimumWidth)+ |
| 576 | +parseFloat($.wikiEditor.modules.toc.cfg.textMinimumWidth);context.$ui.find('.wikiEditor-ui-right').resizable('option','maxWidth',availableWidth);if(context.modules.toc.$toc.data('positionMode')!='disabled'&&context.$wikitext.width()<totalMinWidth){$.wikiEditor.modules.toc.fn.disable(context);}else if(context.modules.toc.$toc.data('positionMode')=='disabled'&&context.$wikitext.width()>totalMinWidth){$.wikiEditor.modules.toc.fn.enable(context);}else if(context.modules.toc.$toc.data('positionMode')=='regular'&&context.$ui.find('.wikiEditor-ui-right').width()>availableWidth){$.wikiEditor.modules.toc.fn.switchLayout(context);}else if(context.modules.toc.$toc.data('positionMode')=='goofy'&&context.modules.toc.$toc.data('previousWidth')<context.$wikitext.width()){$.wikiEditor.modules.toc.fn.switchLayout(context);} |
| 577 | +if(context.modules.toc.$toc.data('positionMode')=='goofy'){context.modules.toc.$toc.find('div').autoEllipsis({'position':'right','tooltip':true,'restoreText':true});} |
| 578 | +context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height()- |
| 579 | +context.$ui.find('.tab-toc').outerHeight());context.modules.toc.$toc.data('previousWidth',context.$wikitext.width());},mark:function(context,event){var markers=context.modules.highlight.markers;var tokenArray=context.modules.highlight.tokenArray;var outline=context.data.outline=[];var h=0;for(var i=0;i<tokenArray.length;i++){if(tokenArray[i].label!='TOC_HEADER'){continue;} |
577 | 580 | h++;markers.push({index:h,start:tokenArray[i].tokenStart,end:tokenArray[i].offset,afterWrap:function(node){var marker=$(node).data('marker');$(node).addClass('wikiEditor-toc-header').addClass('wikiEditor-toc-section-'+marker.index).data('section',marker.index);},getWrapper:function(ca1,ca2){return $(ca1.parentNode).is('div.wikiEditor-toc-header')&&ca1.previousSibling==null&&ca1.nextSibling==null?ca1.parentNode:null;}});outline.push({'text':tokenArray[i].match[2],'level':tokenArray[i].match[1].length,'index':h});} |
578 | 581 | $.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}},exp:[{'regex':/^(={1,6})(.+?)\1\s*$/m,'label':'TOC_HEADER','markAfter':true}],fn:{create:function(context,config){if('$toc'in context.modules.toc){return;} |
579 | | -$.wikiEditor.modules.toc.cfg.rtl=config.rtl;var height=context.$ui.find('.wikiEditor-ui-left').height();context.modules.toc.$toc=$('<div />').addClass('wikiEditor-ui-toc').data('context',context);context.$ui.find('.wikiEditor-ui-right').css('width',$.wikiEditor.modules.toc.cfg.defaultWidth).append(context.modules.toc.$toc);context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height());context.$ui.find('.wikiEditor-ui-left').css('marginRight',"-"+$.wikiEditor.modules.toc.cfg.defaultWidth).children().css('marginRight',$.wikiEditor.modules.toc.cfg.defaultWidth);},unhighlight:function(context){context.modules.toc.$toc.find('div').removeClass('current');},update:function(context){$.wikiEditor.modules.toc.fn.unhighlight(context);var div=context.fn.beforeSelection('div.wikiEditor-toc-header');var section=div.data('section')||0;if(context.data.outline.length>0){var sectionLink=context.modules.toc.$toc.find('div.section-'+section);sectionLink.addClass('current');var relTop=sectionLink.offset().top-context.modules.toc.$toc.offset().top;var scrollTop=context.modules.toc.$toc.scrollTop();var divHeight=context.modules.toc.$toc.height();var sectionHeight=sectionLink.height();if(relTop<0) |
| 582 | +$.wikiEditor.modules.toc.cfg.rtl=config.rtl;var height=context.$ui.find('.wikiEditor-ui-left').height();context.modules.toc.$toc=$('<div />').addClass('wikiEditor-ui-toc').data('context',context).data('positionMode','regular').data('collapsed',false);context.$ui.find('.wikiEditor-ui-right').append(context.modules.toc.$toc);context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height());$.wikiEditor.modules.toc.fn.redraw(context,$.wikiEditor.modules.toc.cfg.defaultWidth);},redraw:function(context,fixedWidth){var fixedWidth=parseFloat(fixedWidth);if(context.modules.toc.$toc.data('positionMode')=='regular'){context.$ui.find('.wikiEditor-ui-right').css('width',fixedWidth+'px');context.$ui.find('.wikiEditor-ui-left').css('marginRight',(-1*fixedWidth)+'px').children().css('marginRight',fixedWidth+'px');}else if(context.modules.toc.$toc.data('positionMode')=='goofy'){context.$ui.find('.wikiEditor-ui-left').css('width',fixedWidth);context.$ui.find('.wikiEditor-ui-right').css('left',fixedWidth);context.$wikitext.css('height',context.$ui.find('.wikiEditor-ui-right').height());}},switchLayout:function(context){var width,height=context.$ui.find('.wikiEditor-ui-right').height();if(context.modules.toc.$toc.data('positionMode')=='regular'&&!context.modules.toc.$toc.data('collapsed')){context.modules.toc.$toc.data('positionMode','goofy');context.modules.toc.$toc.data('positionModeChangeAt',context.$ui.find('.wikiEditor-ui-right').width());width=$.wikiEditor.modules.toc.cfg.textMinimumWidth;context.$ui.find('.wikiEditor-ui-left').css({'marginRight':'','position':'absolute','left':'0px','right':'auto','float':'none'}).children().css('marginRight','');context.$ui.find('.wikiEditor-ui-right').css({'width':'100%','position':'absolute','right':'0px','width':'auto','float':'none'});context.$wikitext.css('position','relative');}else if(context.modules.toc.$toc.data('positionMode')=='goofy'){context.modules.toc.$toc.data('positionMode','regular');width=context.$wikitext.width()-context.$ui.find('.wikiEditor-ui-left').width();if(width>context.modules.toc.$toc.data('positionModeChangeAt')){width=context.modules.toc.$toc.data('positionModeChangeAt');} |
| 583 | +context.$wikitext.css({'position':'','height':''});context.$ui.find('.wikiEditor-ui-right').css({'marginRight':'','position':'','left':'','right':'','float':'','top':'','height':''});context.$ui.find('.wikiEditor-ui-left').css({'width':'','position':'','left':'','float':'','right':''});} |
| 584 | +$.wikiEditor.modules.toc.fn.redraw(context,width);},disable:function(context){if(context.modules.toc.$toc.data('collapsed')){context.$ui.find('.wikiEditor-ui-toc-expandControl').hide();}else{if(context.modules.toc.$toc.data('positionMode')=='goofy'){$.wikiEditor.modules.toc.fn.switchLayout(context);} |
| 585 | +context.$ui.find('.wikiEditor-ui-right').hide();context.$ui.find('.wikiEditor-ui-left').css('marginRight','').children().css('marginRight','');} |
| 586 | +context.modules.toc.$toc.data('positionMode','disabled');},enable:function(context){context.modules.toc.$toc.data('positionMode','regular');if(context.modules.toc.$toc.data('collapsed')){context.$ui.find('.wikiEditor-ui-toc-expandControl').show();}else{context.$ui.find('.wikiEditor-ui-right').show();$.wikiEditor.modules.toc.fn.redraw(context,$.wikiEditor.modules.toc.cfg.minimumWidth);context.modules.toc.$toc.find('div').autoEllipsis({'position':'right','tooltip':true,'restoreText':true});}},unhighlight:function(context){context.modules.toc.$toc.find('div').removeClass('current');},update:function(context){$.wikiEditor.modules.toc.fn.unhighlight(context);var div=context.fn.beforeSelection('div.wikiEditor-toc-header');var section=div.data('section')||0;if(context.data.outline.length>0){var sectionLink=context.modules.toc.$toc.find('div.section-'+section);sectionLink.addClass('current');var relTop=sectionLink.offset().top-context.modules.toc.$toc.offset().top;var scrollTop=context.modules.toc.$toc.scrollTop();var divHeight=context.modules.toc.$toc.height();var sectionHeight=sectionLink.height();if(relTop<0) |
580 | 587 | context.modules.toc.$toc.scrollTop(scrollTop+relTop);else if(relTop+sectionHeight>divHeight) |
581 | | -context.modules.toc.$toc.scrollTop(scrollTop+relTop+sectionHeight-divHeight);}},collapse:function(event){var $this=$(this),context=$this.data('context'),pT=$this.parent().position().top-1;$this.parent().css({'marginTop':'1px','position':'absolute','left':$.wikiEditor.modules.toc.cfg.rtl?0:'auto','right':$.wikiEditor.modules.toc.cfg.rtl?'auto':0,'top':pT}).fadeOut('fast',function(){$(this).hide().css({'marginTop':'0','width':'1px'});context.$ui.find('.wikiEditor-ui-toc-expandControl').fadeIn('fast');}).prev().animate({'marginRight':'-1px'},'fast',function(){$(this).css('marginRight',0);context.fn.trigger('resize');}).children().animate({'marginRight':'1px'},'fast',function(){$(this).css('marginRight',0);});$.cookie('wikiEditor-'+context.instance+'-toc-width',0);return false;},expand:function(event){var $this=$(this),context=$this.data('context'),openWidth=context.modules.toc.$toc.data('openWidth');context.$ui.find('.wikiEditor-ui-toc-expandControl').hide();$this.parent().show().css('marginTop','1px').animate({'width':openWidth},'fast',function(){context.$content.trigger('mouseup');$(this).css({'marginTop':'0','position':'relative','right':'auto','left':'auto','top':'auto'});}).prev().animate({'marginRight':(parseFloat(openWidth)*-1)},'fast').children().animate({'marginRight':openWidth},'fast',function(){context.fn.trigger('resize');});$.cookie('wikiEditor-'+context.instance+'-toc-width',context.modules.toc.$toc.data('openWidth'));return false;},build:function(context){function buildStructure(outline,offset,level){if(offset==undefined)offset=0;if(level==undefined)level=1;var sections=[];for(var i=offset;i<outline.length;i++){if(outline[i].nLevel==level){var sub=buildStructure(outline,i+1,level+1);if(sub.length){outline[i].sections=sub;} |
| 588 | +context.modules.toc.$toc.scrollTop(scrollTop+relTop+sectionHeight-divHeight);}},collapse:function(event){var $this=$(this),context=$this.data('context');if(context.modules.toc.$toc.data('positionMode')=='goofy'){$.wikiEditor.modules.toc.fn.switchLayout(context);} |
| 589 | +var pT=$this.parent().position().top-1;context.modules.toc.$toc.data('collapsed',true);context.$ui.find('.wikiEditor-ui-left').animate({'marginRight':'-1px'},'fast',function(){$(this).css('marginRight',0);}).children().animate({'marginRight':'1px'},'fast',function(){$(this).css('marginRight',0);});context.$ui.find('.wikiEditor-ui-right').css({'marginTop':'1px','position':'absolute','left':$.wikiEditor.modules.toc.cfg.rtl?0:'auto','right':$.wikiEditor.modules.toc.cfg.rtl?'auto':0,'top':pT}).fadeOut('fast',function(){$(this).hide().css({'marginTop':'0','width':'1px'});context.$ui.find('.wikiEditor-ui-toc-expandControl').fadeIn('fast');context.fn.trigger('resize');});$.cookie('wikiEditor-'+context.instance+'-toc-width',0);return false;},expand:function(event){var $this=$(this),context=$this.data('context'),openWidth=parseFloat(context.modules.toc.$toc.data('openWidth')),availableSpace=context.$wikitext.width()-parseFloat($.wikiEditor.modules.toc.cfg.textMinimumWidth);if(availableSpace<$.wikiEditor.modules.toc.cfg.textMinmumWidth)return false;context.modules.toc.$toc.data('collapsed',false);if(availableSpace<openWidth)openWidth=availableSpace;context.$ui.find('.wikiEditor-ui-toc-expandControl').hide();context.$ui.find('.wikiEditor-ui-left').animate({'marginRight':(parseFloat(openWidth)*-1)},'fast').children().animate({'marginRight':openWidth},'fast');context.$ui.find('.wikiEditor-ui-right').show().css('marginTop','1px').animate({'width':openWidth},'fast',function(){context.$content.trigger('mouseup');$(this).css({'marginTop':'0','position':'relative','right':'auto','left':'auto','top':'auto'});context.fn.trigger('resize');});$.cookie('wikiEditor-'+context.instance+'-toc-width',context.modules.toc.$toc.data('openWidth'));return false;},build:function(context){function buildStructure(outline,offset,level){if(offset==undefined)offset=0;if(level==undefined)level=1;var sections=[];for(var i=offset;i<outline.length;i++){if(outline[i].nLevel==level){var sub=buildStructure(outline,i+1,level+1);if(sub.length){outline[i].sections=sub;} |
582 | 590 | sections[sections.length]=outline[i];}else if(outline[i].nLevel<level){break;}} |
583 | 591 | return sections;} |
584 | 592 | function buildList(structure){var list=$('<ul />');for(i in structure){var wrapper=context.$content.find('.wikiEditor-toc-section-'+structure[i].index);if(wrapper.size()==0) |
— | — | @@ -586,10 +594,11 @@ |
587 | 595 | div.html(' ');var item=$('<li />').append(div);if(structure[i].sections!==undefined){item.append(buildList(structure[i].sections));} |
588 | 596 | list.append(item);} |
589 | 597 | return list;} |
590 | | -function buildCollapseControls(){var $collapseControl=$('<div />'),$expandControl=$('<div />');$collapseControl.addClass('tab').addClass('tab-toc').append('<a href="#" />').bind('click.wikiEditor-toc',function(){context.modules.toc.$toc.trigger('collapse.wikiEditor-toc');return false;}).find('a').text(gM('wikieditor-toc-hide'));$expandControl.addClass('wikiEditor-ui-toc-expandControl').append('<a href="#" />').bind('click.wikiEditor-toc',function(){context.modules.toc.$toc.trigger('expand.wikiEditor-toc');return false;}).hide().find('a').text(gM('wikieditor-toc-show'));$collapseControl.insertBefore(context.modules.toc.$toc);context.$ui.find('.wikiEditor-ui-left .wikiEditor-ui-top').append($expandControl);context.fn.trigger('resize');} |
591 | | -function buildResizeControls(){context.$ui.data('resizableDone',true).find('.wikiEditor-ui-right').data('wikiEditor-ui-left',context.$ui.find('.wikiEditor-ui-left')).resizable({handles:'w,e',preventPositionLeftChange:true,minWidth:50,start:function(e,ui){var $this=$(this);$('<div />').addClass('wikiEditor-ui-resize-mask').css({'position':'absolute','z-index':2,'left':0,'top':0,'bottom':0,'right':0}).appendTo(context.$ui.find('.wikiEditor-ui-left'));$this.resizable('option','maxWidth',$this.parent().width()-450);},resize:function(e,ui){$(this).css({'width':ui.size.width,'top':'auto','height':'auto'}).data('wikiEditor-ui-left').css('marginRight',(-1*ui.size.width)).children().css('marginRight',ui.size.width);context.fn.trigger('resize');},stop:function(e,ui){context.$ui.find('.wikiEditor-ui-resize-mask').remove();context.$content.trigger('mouseup');if(ui.size.width<parseFloat($.wikiEditor.modules.toc.cfg.minimumWidth)){context.modules.toc.$toc.trigger('collapse');}else{context.modules.toc.$toc.find('div').autoEllipsis({'position':'right','tooltip':true,'restoreText':true});context.modules.toc.$toc.data('openWidth',ui.size.width);$.cookie('wikiEditor-'+context.instance+'-toc-width',ui.size.width);} |
| 598 | +function buildCollapseControls(){var $collapseControl=$('<div />'),$expandControl=$('<div />');$collapseControl.addClass('tab').addClass('tab-toc').append('<a href="#" />').bind('click.wikiEditor-toc',function(){context.modules.toc.$toc.trigger('collapse.wikiEditor-toc');return false;}).find('a').text(gM('wikieditor-toc-hide'));$expandControl.addClass('wikiEditor-ui-toc-expandControl').append('<a href="#" />').bind('click.wikiEditor-toc',function(){context.modules.toc.$toc.trigger('expand.wikiEditor-toc');return false;}).hide().find('a').text(gM('wikieditor-toc-show'));$collapseControl.insertBefore(context.modules.toc.$toc);context.$ui.find('.wikiEditor-ui-left .wikiEditor-ui-top').append($expandControl);} |
| 599 | +function buildResizeControls(){context.$ui.data('resizableDone',true).find('.wikiEditor-ui-right').data('wikiEditor-ui-left',context.$ui.find('.wikiEditor-ui-left')).resizable({handles:'w,e',preventPositionLeftChange:true,minWidth:parseFloat($.wikiEditor.modules.toc.cfg.minimumWidth),start:function(e,ui){var $this=$(this);$('<div />').addClass('wikiEditor-ui-resize-mask').css({'position':'absolute','z-index':2,'left':0,'top':0,'bottom':0,'right':0}).appendTo(context.$ui.find('.wikiEditor-ui-left'));$this.resizable('option','maxWidth',$this.parent().width()- |
| 600 | +parseFloat($.wikiEditor.modules.toc.cfg.textMinimumWidth));if(context.modules.toc.$toc.data('positionMode')=='goofy'){$.wikiEditor.modules.toc.fn.switchLayout(context);}},resize:function(e,ui){$(this).css({'width':ui.size.width,'top':'auto','height':'auto'}).data('wikiEditor-ui-left').css('marginRight',(-1*ui.size.width)).children().css('marginRight',ui.size.width);context.fn.trigger('resize');},stop:function(e,ui){context.$ui.find('.wikiEditor-ui-resize-mask').remove();context.$content.trigger('mouseup');if(ui.size.width<parseFloat($.wikiEditor.modules.toc.cfg.minimumWidth)){context.modules.toc.$toc.trigger('collapse.wikiEditor-toc');}else{context.modules.toc.$toc.find('div').autoEllipsis({'position':'right','tooltip':true,'restoreText':true});context.modules.toc.$toc.data('openWidth',ui.size.width);$.cookie('wikiEditor-'+context.instance+'-toc-width',ui.size.width);} |
592 | 601 | context.fn.trigger('resize');}});var handle=$.wikiEditor.modules.toc.cfg.rtl?'w':'e';context.$ui.find('.ui-resizable-'+handle).removeClass('ui-resizable-'+handle).addClass('ui-resizable-'+(handle=='w'?'e':'w')).addClass('wikiEditor-ui-toc-resize-grip');context.modules.toc.$toc.bind('collapse.wikiEditor-toc',$.wikiEditor.modules.toc.fn.collapse).bind('expand.wikiEditor-toc',$.wikiEditor.modules.toc.fn.expand);context.modules.toc.$toc.data('openWidth',$.wikiEditor.modules.toc.cfg.defaultWidth);if($.cookie('wikiEditor-'+context.instance+'-toc-width')==0){context.modules.toc.$toc.trigger('collapse.wikiEditor-toc',{data:context});}else if($.cookie('wikiEditor-'+context.instance+'-toc-width')>0){var initialWidth=$.cookie('wikiEditor-'+context.instance+'-toc-width');if(initialWidth<parseFloat($.wikiEditor.modules.toc.cfg.minimumWidth)) |
593 | | -initialWidth=parseFloat($.wikiEditor.modules.toc.cfg.minimumWidth)+1;context.modules.toc.$toc.data('openWidth',initialWidth+'px');context.$ui.find('.wikiEditor-ui-right').css('width',initialWidth+'px');context.$ui.find('.wikiEditor-ui-left').css('marginRight',(parseFloat(initialWidth)*-1)+'px').children().css('marginRight',initialWidth+'px');}} |
| 602 | +initialWidth=parseFloat($.wikiEditor.modules.toc.cfg.minimumWidth)+1;context.modules.toc.$toc.data('openWidth',initialWidth+'px');$.wikiEditor.modules.toc.fn.redraw(context,initialWidth);}} |
594 | 603 | if(context.data.outline){var outline=context.data.outline;var lastLevel=0;var nLevel=0;for(var i=0;i<outline.length;i++){if(outline[i].level>lastLevel){nLevel++;} |
595 | 604 | else if(outline[i].level<lastLevel){nLevel-=Math.max(1,lastLevel-outline[i].level);} |
596 | 605 | if(nLevel<=0){nLevel=1;} |