Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | 'base_sets' => array( |
21 | 21 | 'raw' => array( |
22 | 22 | array( 'src' => 'css/suggestions.css', 'version' => 6 ), |
23 | | - array( 'src' => 'css/wikiEditor.css', 'version' => 5 ), |
| 23 | + array( 'src' => 'css/wikiEditor.css', 'version' => 6 ), |
24 | 24 | array( 'src' => 'css/wikiEditor.toolbar.css', 'version' => 7 ), |
25 | 25 | array( 'src' => 'css/wikiEditor.dialogs.css', 'version' => 2 ), |
26 | 26 | array( 'src' => 'css/wikiEditor.toc.css', 'version' => 16 ), |
— | — | @@ -27,11 +27,11 @@ |
28 | 28 | array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2y' ), |
29 | 29 | ), |
30 | 30 | 'combined' => array( |
31 | | - array( 'src' => 'css/combined.css', 'version' => 23 ), |
| 31 | + array( 'src' => 'css/combined.css', 'version' => 24 ), |
32 | 32 | array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2y' ), |
33 | 33 | ), |
34 | 34 | 'minified' => array( |
35 | | - array( 'src' => 'css/combined.min.css', 'version' => 23 ), |
| 35 | + array( 'src' => 'css/combined.min.css', 'version' => 24 ), |
36 | 36 | array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2y' ), |
37 | 37 | ), |
38 | 38 | ) |
— | — | @@ -70,17 +70,17 @@ |
71 | 71 | array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ), |
72 | 72 | array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 6 ), |
73 | 73 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 20 ), |
74 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 15 ), |
75 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 27 ), |
| 74 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 16 ), |
| 75 | + array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 28 ), |
76 | 76 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 9 ), |
77 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 35 ), |
| 77 | + array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 36 ), |
78 | 78 | array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 3 ), |
79 | 79 | ), |
80 | 80 | 'combined' => array( |
81 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 75 ), |
| 81 | + array( 'src' => 'js/plugins.combined.js', 'version' => 76 ), |
82 | 82 | ), |
83 | 83 | 'minified' => array( |
84 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 75 ), |
| 84 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 76 ), |
85 | 85 | ), |
86 | 86 | ), |
87 | 87 | ); |
Index: trunk/extensions/UsabilityInitiative/css/wikiEditor.css |
— | — | @@ -52,10 +52,12 @@ |
53 | 53 | float: left; |
54 | 54 | width: 100%; |
55 | 55 | } |
| 56 | +/* |
56 | 57 | .wikiEditor-tabs { |
57 | 58 | float: left; |
58 | 59 | width: 50%; |
59 | 60 | } |
| 61 | +*/ |
60 | 62 | .wikiEditor-buttons { |
61 | 63 | float: right; |
62 | 64 | width: 50%; |
Index: trunk/extensions/UsabilityInitiative/css/combined.css |
— | — | @@ -102,10 +102,12 @@ |
103 | 103 | float: left; |
104 | 104 | width: 100%; |
105 | 105 | } |
| 106 | +/* |
106 | 107 | .wikiEditor-tabs { |
107 | 108 | float: left; |
108 | 109 | width: 50%; |
109 | 110 | } |
| 111 | +*/ |
110 | 112 | .wikiEditor-buttons { |
111 | 113 | float: right; |
112 | 114 | width: 50%; |
Index: trunk/extensions/UsabilityInitiative/css/combined.min.css |
— | — | @@ -95,10 +95,12 @@ |
96 | 96 | float:left; |
97 | 97 | width:100%; |
98 | 98 | } |
| 99 | +/* |
99 | 100 | .wikiEditor-tabs{ |
100 | 101 | float:left; |
101 | 102 | width:50%; |
102 | 103 | } |
| 104 | +*/ |
103 | 105 | .wikiEditor-buttons{ |
104 | 106 | float:right; |
105 | 107 | width:50%; |
Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.hooks.php |
— | — | @@ -82,6 +82,10 @@ |
83 | 83 | 'wgNavigableTOCCollapseEnable', |
84 | 84 | 'wgNavigableTOCResizable' |
85 | 85 | ), |
| 86 | + 'messages' => array( |
| 87 | + 'wikieditor-toc-show', |
| 88 | + 'wikieditor-toc-hide', |
| 89 | + ), |
86 | 90 | ), |
87 | 91 | 'toolbar' => array( |
88 | 92 | 'i18n' => 'WikiEditorToolbar', |
Index: trunk/extensions/UsabilityInitiative/WikiEditor/Modules/Toc/Toc.i18n.php |
— | — | @@ -13,6 +13,8 @@ |
14 | 14 | */ |
15 | 15 | $messages['en'] = array( |
16 | 16 | 'wikieditor-toc-preference' => 'Enable navigable table of contents', |
| 17 | + 'wikieditor-toc-show' => 'Show contents', |
| 18 | + 'wikieditor-toc-hide' => 'Hide contents', |
17 | 19 | ); |
18 | 20 | |
19 | 21 | /** Message documentation (Message documentation) |
— | — | @@ -21,6 +23,8 @@ |
22 | 24 | */ |
23 | 25 | $messages['qqq'] = array( |
24 | 26 | 'wikieditor-toc-preference' => "Option at [[Special:Preferences]], tab ''{{int:prefs-editing}}''", |
| 27 | + 'wikieditor-toc-show' => 'Label of the show/hide link when the navigable table of contents is hidden', |
| 28 | + 'wikieditor-toc-hide' => 'Label of the show/hide link when the navigable table of contents is visible', |
25 | 29 | ); |
26 | 30 | |
27 | 31 | /** Arabic (العربية) |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -357,11 +357,14 @@ |
358 | 358 | // Insert the contents one line at a time |
359 | 359 | // insertNode() inserts at the beginning, so this has |
360 | 360 | // to happen in reverse order |
| 361 | + var lastNode; |
361 | 362 | for ( var i = insertLines.length - 1; i >= 0; i-- ) { |
362 | 363 | range.insertNode( document.createTextNode( insertLines[i] ) ); |
363 | 364 | if ( i > 0 ) |
364 | | - range.insertNode( document.createElement( 'br' ) ); |
| 365 | + lastNode = range.insertNode( document.createElement( 'br' ) ); |
365 | 366 | } |
| 367 | + if ( lastNode ) |
| 368 | + context.fn.scrollToTop( lastNode ); |
366 | 369 | |
367 | 370 | // ... |
368 | 371 | // Scroll the textarea to the inserted text |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js |
— | — | @@ -563,27 +563,31 @@ |
564 | 564 | build : function( context, config ) { |
565 | 565 | var $tabs = $( '<div />' ).addClass( 'tabs' ).appendTo( context.modules.$toolbar ); |
566 | 566 | if( wgNavigableTOCCollapseEnable ) { |
| 567 | + // FIXME: This code is duplicated from the TOC plugin and doesn't belong here; |
| 568 | + // the TOC drag thingy should be in the TOC plugin instead |
567 | 569 | // placeholder for drag control creation code |
| 570 | + /* |
568 | 571 | $dragControl = $( '<div />' ).addClass( 'tab' ).attr( 'id', 'wikiEditor-ui-toc-resize-grip' ) |
569 | 572 | .append( '<a href="#" title="Drag to resize"></a>' ) |
570 | 573 | .bind( 'mousedown', function() { |
571 | 574 | $( '#wikiEditor-ui-toc' ) |
572 | 575 | .data( 'openWidth', $( '#wikiEditor-ui-toc' ).width() ); |
573 | 576 | $() |
574 | | - .bind( 'mousemove', {'context': context}, $.wikiEditor.modules.toc.fn.drag ) |
575 | | - .bind( 'mouseup', {'context': context}, $.wikiEditor.modules.toc.fn.stopDrag ); |
| 577 | + .bind( 'mousemove', context, $.wikiEditor.modules.toc.fn.drag ) |
| 578 | + .bind( 'mouseup', context, $.wikiEditor.modules.toc.fn.stopDrag ); |
576 | 579 | $(context.$iframe[0].contentWindow.document) |
577 | | - .bind( 'mousemove', {'context': context}, function( e ){ |
| 580 | + .bind( 'mousemove', function() { |
578 | 581 | parent.top.$j().trigger("mousemove", e.pageX); |
579 | | - return false; |
| 582 | + return false; |
580 | 583 | } ) |
581 | | - .bind( 'mouseup', {'context': context}, function( e ){ |
| 584 | + .bind( 'mouseup', function() { |
582 | 585 | parent.top.$j().trigger("mouseup"); |
583 | | - return false; |
| 586 | + return false; |
584 | 587 | }); |
585 | 588 | return false; |
586 | 589 | }) |
587 | 590 | context.modules.$toolbar.append( $dragControl ); |
| 591 | + */ |
588 | 592 | } |
589 | 593 | var $sections = $( '<div />' ).addClass( 'sections' ).appendTo( context.modules.$toolbar ); |
590 | 594 | context.modules.$toolbar.append( $( '<div />' ).css( 'clear', 'both' ) ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | if ( '$toc' in context.modules ) { |
27 | 27 | return; |
28 | 28 | } |
29 | | - /* |
| 29 | + |
30 | 30 | context.initialWidth = $.wikiEditor.modules.toc.defaultWidth; |
31 | 31 | if( wgNavigableTOCResizable ) { |
32 | 32 | if( !$.cookie( 'wikiEditor-' + context.instance + '-toc-width' ) ) { |
— | — | @@ -37,7 +37,7 @@ |
38 | 38 | context.initialWidth = $.cookie( 'wikiEditor-' + context.instance + '-toc-width' ); |
39 | 39 | } |
40 | 40 | } |
41 | | - */ |
| 41 | + |
42 | 42 | var height = context.$ui.find( '.wikiEditor-ui-left' ).height(); |
43 | 43 | context.modules.$toc = $( '<div />' ) |
44 | 44 | .addClass( 'wikiEditor-ui-toc' ) |
— | — | @@ -49,9 +49,9 @@ |
50 | 50 | context.$ui.find( '.wikiEditor-ui-left' ).height() |
51 | 51 | ); |
52 | 52 | context.$ui.find( '.wikiEditor-ui-left' ) |
53 | | - .css( 'marginRight', "-" + $.wikiEditor.modules.toc.defaultWidth) |
| 53 | + .css( 'marginRight', "-" + $.wikiEditor.modules.toc.defaultWidth ) |
54 | 54 | .children() |
55 | | - .css('marginRight', $.wikiEditor.modules.toc.defaultWidth ); |
| 55 | + .css( 'marginRight', $.wikiEditor.modules.toc.defaultWidth ); |
56 | 56 | |
57 | 57 | // Add the TOC to the document |
58 | 58 | $.wikiEditor.modules.toc.fn.build( context, config ); |
— | — | @@ -121,46 +121,50 @@ |
122 | 122 | /** |
123 | 123 | * Collapse the contents module |
124 | 124 | * |
125 | | - * @param {Object} context |
| 125 | + * @param {Object} event Event object with context as data |
126 | 126 | */ |
127 | | - collapse: function( context ) { |
128 | | - var $toc = $( '#wikiEditor-ui-toc' ); |
129 | | - if( !$toc.data( 'openWidth' ) ) { |
| 127 | + collapse: function( event ) { |
| 128 | + var context = event.data; |
| 129 | + var $toc = context.modules.$toc; |
| 130 | + if( !$toc.data( 'openWidth' ) ) { |
130 | 131 | $toc.data( 'openWidth', $toc.width() ); |
131 | 132 | } |
132 | | - var $toolbar = $( '#wikiEditor-ui-toolbar .tab-toc' ) |
| 133 | + context.$ui.find( '.tab-toc' ) |
133 | 134 | .unbind( 'click', $.wikiEditor.modules.toc.fn.collapse ) |
134 | | - .bind( 'click', $.wikiEditor.modules.toc.fn.expand ) |
| 135 | + .bind( 'click', context, $.wikiEditor.modules.toc.fn.expand ) |
135 | 136 | .children( 'a' ) |
136 | | - .text( 'Show Contents' ); |
| 137 | + .text( gM( 'wikieditor-toc-show' ) ); |
137 | 138 | |
138 | 139 | $toc |
139 | | - .animate( { 'width': '1px' }, 'fast', function() { $(this).hide(); } ) |
140 | | - .prev() |
141 | | - .animate( {'marginRight': '1px'}, 'fast', function() { $(this).css('marginRight', '-1px'); } ); |
142 | | - $.cookie( 'wikiEditor-' + context.instance + '-toc-width', '1px' ); |
| 140 | + //.animate( { 'width': '1px' }, 'fast', function() { $(this).hide(); } ) |
| 141 | + .animate( { 'width': 1 }, 'fast' ); |
| 142 | + //.prev() |
| 143 | + //.animate( {'marginRight': '1px'}, 'fast', function() { $(this).css('marginRight', '-1px'); } ); |
| 144 | + $.cookie( 'wikiEditor-' + context.instance + '-toc-width', 1 ); |
143 | 145 | return false; |
144 | 146 | }, |
145 | 147 | |
146 | 148 | /** |
147 | 149 | * Expand the contents module |
148 | 150 | * |
149 | | - * @param {Object} context |
| 151 | + * @param {Object} event Event object with context as data |
150 | 152 | */ |
151 | | - expand: function( context ) { |
152 | | - $( '#wikiEditor-ui-toolbar .tab-toc' ) |
| 153 | + expand: function( event) { |
| 154 | + var context = event.data; |
| 155 | + context.$ui.find( '.tab-toc' ) |
153 | 156 | .unbind( 'click', $.wikiEditor.modules.toc.fn.expand ) |
154 | | - .bind( 'click', $.wikiEditor.modules.toc.fn.collapse ) |
| 157 | + .bind( 'click', context, $.wikiEditor.modules.toc.fn.collapse ) |
155 | 158 | .children( 'a' ) |
156 | | - .text( 'Hide Contents' ); |
157 | | - $( '#wikiEditor-ui-toc' ) |
| 159 | + .text( gM( 'wikieditor-toc-hide' ) ); |
| 160 | + context.modules.$toc |
158 | 161 | .show() |
159 | | - .animate( { 'width': $( '#wikiEditor-ui-toc' ).data( 'openWidth' )}, 'fast', function() { |
160 | | - $( '#wikiEditor-ui-text textarea' ).trigger( 'mouseup' ); |
161 | | - } ) |
162 | | - .prev() |
163 | | - .animate( { 'marginRight': $( '#wikiEditor-ui-toc' ).data( 'openWidth' ) }, 'fast' ); |
164 | | - $.cookie( 'wikiEditor-' + context.instance + '-toc-width', $( '#wikiEditor-ui-toc' ).data( 'openWidth' ) ); |
| 162 | + .animate( { 'width': context.modules.$toc.data( 'openWidth' ) }, 'fast' ); |
| 163 | + //.animate( { 'width': context.modules.$toc.data( 'openWidth' )}, 'fast', function() { |
| 164 | + // $( '#wikiEditor-ui-text textarea' ).trigger( 'mouseup' ); |
| 165 | + //} ) |
| 166 | + //.prev() |
| 167 | + //.animate( { 'marginRight': context.modules.$toc.data( 'openWidth' ) }, 'fast' ); |
| 168 | + $.cookie( 'wikiEditor-' + context.instance + '-toc-width', context.modules.$toc.data( 'openWidth' ) ); |
165 | 169 | return false; |
166 | 170 | }, |
167 | 171 | /** |
— | — | @@ -169,13 +173,22 @@ |
170 | 174 | * @param {object} e |
171 | 175 | */ |
172 | 176 | drag: function( e, pageX ) { |
173 | | - var mR = pageX ? pageX : |
174 | | - (e.pageX - e.data.context.$ui.find( '.wikiEditor-ui-left' ).offset().left); |
175 | | - mR = e.data.context.$ui.find( '.wikiEditor-ui-left' ).width() - mR; |
176 | | - if( mR < 26 || mR > e.data.context.$ui.find( '.wikiEditor-ui-left' ).width() - 250) return false; |
177 | | - e.data.context.$ui.find( '.wikiEditor-ui-left' ).css( 'marginRight', "-"+mR+'px' ) |
178 | | - .children().css('marginRight', mR+'px'); |
179 | | - e.data.context.$ui.find( '.wikiEditor-ui-right' ).css( 'width', mR+'px' ); |
| 177 | + var context = e.data; |
| 178 | + var mR; |
| 179 | + // This used to be done with a ternary expression, but for some reason that |
| 180 | + // returned NaN in some cases. Even this seems to be buggy in that .offset().left |
| 181 | + // is sometimes 0. |
| 182 | + // FIXME: We should ditch the whole thing and use jQuery UI Resizable if possible |
| 183 | + if ( pageX ) |
| 184 | + mR = pageX; |
| 185 | + else |
| 186 | + mR = e.pageX - context.$ui.find( '.wikiEditor.ui-left' ).offset().left; |
| 187 | + mR = context.$ui.find( '.wikiEditor-ui-left' ).width() - mR; |
| 188 | + if( mR < 26 || mR > context.$ui.find( '.wikiEditor-ui-left' ).width() - 250) |
| 189 | + return false; |
| 190 | + context.$ui.find( '.wikiEditor-ui-left' ).css( 'marginRight', -mR ) |
| 191 | + .children().css('marginRight', mR); |
| 192 | + context.$ui.find( '.wikiEditor-ui-right' ).css( 'width', mR ); |
180 | 193 | return false; |
181 | 194 | }, |
182 | 195 | /** |
— | — | @@ -184,19 +197,21 @@ |
185 | 198 | * @param {object} e |
186 | 199 | */ |
187 | 200 | stopDrag: function( e ) { |
| 201 | + var context = e.data; |
188 | 202 | $() |
189 | 203 | .unbind( 'mousemove', $.wikiEditor.modules.toc.fn.drag ) |
190 | 204 | .unbind( 'mouseup', $.wikiEditor.modules.toc.fn.stopDrag ); |
191 | | - $(e.data.context.$iframe[0].contentWindow.document) |
| 205 | + $(context.$iframe[0].contentWindow.document) |
192 | 206 | .unbind( 'mousemove' ) |
193 | 207 | .unbind( 'mouseup' ); |
194 | | - if( $( '#wikiEditor-ui-right' ).width() < 50 && wgNavigableTOCCollapseEnable ) { |
195 | | - $.wikiEditor.modules.toc.fn.collapse( e.data.context ); |
| 208 | + if( context.$ui.find( '.wikiEditor-ui-right' ).width() < 50 && wgNavigableTOCCollapseEnable ) { |
| 209 | + $.wikiEditor.modules.toc.fn.collapse( { data: context } ); |
196 | 210 | } else { |
197 | | - $( '#wikiEditor-ui-left' ).trigger( 'mouseup' ); |
198 | | - $( '#wikiEditor-ui-right' ) |
199 | | - .data( 'openWidth', $( '#wikiEditor-ui-right' ).width() + 'px' ); |
200 | | - $.cookie( 'wikiEditor-' + e.data.context.instance + '-toc-width', $( '#wikiEditor-ui-right' ).width() + 'px' ); |
| 211 | + context.$ui.find( '.wikiEditor-ui-left' ).trigger( 'mouseup' ); |
| 212 | + context.$ui.find( '.wikiEditor-ui-right' ) |
| 213 | + .data( 'openWidth', context.$ui.find( '.wikiEditor-ui-right' ).width() ); |
| 214 | + $.cookie( 'wikiEditor-' + context.instance + '-toc-width', |
| 215 | + context.$ui.find( '.wikiEditor-ui-right' ).width() ); |
201 | 216 | } |
202 | 217 | return false; |
203 | 218 | }, |
— | — | @@ -258,17 +273,18 @@ |
259 | 274 | return list; |
260 | 275 | } |
261 | 276 | function buildCollapseBar() { |
262 | | - $( '.wikiEditor-ui-toc ul:first' ).css( 'width', '147px' ) |
| 277 | + // FIXME: Move this to a .css file |
| 278 | + context.modules.$toc.find( 'ul:first' ).css( 'width', '147px' ) |
263 | 279 | .css( 'margin-left', '19px' ).css( 'border-left', '1px solid #DDDDDD' ); |
264 | 280 | var $collapseBar = $( '<div />' ) |
265 | 281 | .addClass( 'wikiEditor-ui-toc-collapse-open' ) |
266 | 282 | .attr( 'id', 'wikiEditor-ui-toc-collapse' ) |
267 | | - .data( 'openWidth', $.wikiEditor.modules.toc.defaultWidth) |
| 283 | + .data( 'openWidth', $.wikiEditor.modules.toc.defaultWidth ) |
268 | 284 | .bind( 'mouseup', function() { |
269 | 285 | var $e = $(this); |
270 | 286 | var close = $e.hasClass( 'wikiEditor-ui-toc-collapse-open' ); |
271 | 287 | if( close ) { |
272 | | - $( '#wikiEditor-ui-toc-collapse' ) |
| 288 | + $e |
273 | 289 | .removeClass( 'wikiEditor-ui-toc-collapse-open' ); |
274 | 290 | $e.parent() |
275 | 291 | .animate( { 'width': $e.outerWidth() }, 'fast', function() { |
— | — | @@ -276,65 +292,63 @@ |
277 | 293 | } ) |
278 | 294 | .prev() |
279 | 295 | .animate( { 'marginRight': $e.outerWidth() + 1 }, 'fast', function() { |
280 | | - $( '#wikiEditor-ui-toc-collapse' ) |
| 296 | + $e |
281 | 297 | .addClass( 'wikiEditor-ui-toc-collapse-closed' ); |
282 | 298 | }); |
283 | 299 | } else { |
284 | | - $( '#wikiEditor-ui-toc-collapse' ) |
| 300 | + $e |
285 | 301 | .removeClass( 'wikiEditor-ui-toc-collapse-closed' ); |
286 | 302 | $e.siblings().show() |
287 | 303 | .parent() |
288 | 304 | .animate( { 'width': $e.data( 'openWidth' ) }, 'fast' ) |
289 | 305 | .prev() |
290 | 306 | .animate( { 'marginRight': $e.data( 'openWidth' ) }, 'fast', function() { |
291 | | - $( '#wikiEditor-ui-toc-collapse' ) |
| 307 | + $e |
292 | 308 | .addClass( 'wikiEditor-ui-toc-collapse-open' ); |
293 | 309 | }); |
294 | 310 | } |
295 | 311 | |
296 | 312 | }); |
297 | | - return $collapseBar; |
| 313 | + return $collapseBar; |
298 | 314 | } |
299 | 315 | function buildResizeControls() { |
300 | 316 | var $resizeControlVertical = $( '<div />' ) |
301 | 317 | .attr( 'id', 'wikiEditor-ui-toc-resize-vertical') |
302 | 318 | .bind( 'mousedown', function() { |
303 | | - $( '#wikiEditor-ui-toc' ) |
304 | | - .data( 'openWidth', $( '#wikiEditor-ui-toc' ).width() ); |
| 319 | + context.modules.$toc |
| 320 | + .data( 'openWidth', context.modules.$toc.width() ); |
305 | 321 | $() |
306 | | - .bind( 'mousemove', { 'context': context }, $.wikiEditor.modules.toc.fn.drag ) |
307 | | - .bind( 'mouseup', {'context': context}, $.wikiEditor.modules.toc.fn.stopDrag ); |
| 322 | + .bind( 'mousemove', context, $.wikiEditor.modules.toc.fn.drag ) |
| 323 | + .bind( 'mouseup', context, $.wikiEditor.modules.toc.fn.stopDrag ); |
308 | 324 | $(context.$iframe[0].contentWindow.document) |
309 | | - .bind( 'mousemove', {'context': context}, function( e ){ |
310 | | - parent.top.$j().trigger("mousemove", e.pageX); |
| 325 | + .bind( 'mousemove', function( e ) { |
| 326 | + parent.top.$j().trigger("mousemove", e.pageX); |
311 | 327 | return false; |
312 | 328 | } ) |
313 | | - .bind( 'mouseup', {'context': context}, function( e ){ |
314 | | - parent.top.$j().trigger("mouseup"); |
315 | | - return false; |
| 329 | + .bind( 'mouseup', function() { |
| 330 | + parent.top.$j().trigger("mouseup"); |
| 331 | + return false; |
316 | 332 | }); |
317 | 333 | return false; |
318 | 334 | }); |
319 | 335 | |
320 | 336 | var $collapseControl = $( '<div />' ).addClass( 'tab' ).addClass( 'tab-toc' ) |
321 | | - .append( '<a href="#"></a>' ); |
322 | | - if( $.cookie( 'wikiEditor-' + context.instance + '-toc-width' ) != '1px' ) { |
323 | | - $collapseControl.bind( 'click', function() { |
324 | | - $.wikiEditor.modules.toc.fn.collapse( context ); |
325 | | - } ) |
326 | | - .find( 'a' ).text( 'Hide Contents' ); |
327 | | - } else { |
328 | | - $collapseControl.bind( 'click', function() { |
329 | | - $.wikiEditor.modules.toc.fn.expand( context ); |
330 | | - } ) |
331 | | - .find( 'a' ).text( 'Show Contents' ); |
| 337 | + .append( '<a href="#" />' ); |
| 338 | + if( $.cookie( 'wikiEditor-' + context.instance + '-toc-width' ) != 1 ) { |
| 339 | + $collapseControl.bind( 'click', context, $.wikiEditor.modules.toc.fn.collapse ) |
| 340 | + .find( 'a' ).text( gM( 'wikieditor-toc-hide' ) ); |
| 341 | + } else { |
| 342 | + $collapseControl.bind( 'click', context, $.wikiEditor.modules.toc.fn.expand ) |
| 343 | + .find( 'a' ).text( gM( 'wikieditor-toc-show' ) ); |
332 | 344 | } |
333 | 345 | $collapseControl.insertBefore( context.modules.$toc ); |
334 | 346 | |
335 | | - if( !$( '#wikiEditor-ui-toc' ).data( 'openWidth' ) ) { |
336 | | - $( '#wikiEditor-ui-toc' ).data( 'openWidth', context.initialWidth == '1px' ? |
| 347 | + if( !context.modules.$toc.data( 'openWidth' ) ) { |
| 348 | + context.modules.$toc.data( 'openWidth', context.initialWidth == 1 ? |
337 | 349 | $.wikiEditor.modules.toc.defaultWidth : context.initialWidth ); |
338 | 350 | } |
| 351 | + if ( context.initialWidth == 1 ) |
| 352 | + $.wikiEditor.modules.toc.fn.collapse( { data: context } ); |
339 | 353 | return $resizeControlVertical; |
340 | 354 | } |
341 | 355 | |
— | — | @@ -400,7 +414,7 @@ |
401 | 415 | |
402 | 416 | if(wgNavigableTOCResizable) { |
403 | 417 | context.modules.$toc.append( buildResizeControls() ); |
404 | | - }else if(wgNavigableTOCCollapseEnable){ |
| 418 | + } else if(wgNavigableTOCCollapseEnable) { |
405 | 419 | context.modules.$toc.append( buildCollapseBar() ); |
406 | 420 | } |
407 | 421 | context.modules.$toc.find( 'div' ).autoEllipse( { 'position': 'right', 'tooltip': true } ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -1655,11 +1655,14 @@ |
1656 | 1656 | // Insert the contents one line at a time |
1657 | 1657 | // insertNode() inserts at the beginning, so this has |
1658 | 1658 | // to happen in reverse order |
| 1659 | + var lastNode; |
1659 | 1660 | for ( var i = insertLines.length - 1; i >= 0; i-- ) { |
1660 | 1661 | range.insertNode( document.createTextNode( insertLines[i] ) ); |
1661 | 1662 | if ( i > 0 ) |
1662 | | - range.insertNode( document.createElement( 'br' ) ); |
| 1663 | + lastNode = range.insertNode( document.createElement( 'br' ) ); |
1663 | 1664 | } |
| 1665 | + if ( lastNode ) |
| 1666 | + context.fn.scrollToTop( lastNode ); |
1664 | 1667 | |
1665 | 1668 | // ... |
1666 | 1669 | // Scroll the textarea to the inserted text |
— | — | @@ -2472,27 +2475,31 @@ |
2473 | 2476 | build : function( context, config ) { |
2474 | 2477 | var $tabs = $( '<div />' ).addClass( 'tabs' ).appendTo( context.modules.$toolbar ); |
2475 | 2478 | if( wgNavigableTOCCollapseEnable ) { |
| 2479 | + // FIXME: This code is duplicated from the TOC plugin and doesn't belong here; |
| 2480 | + // the TOC drag thingy should be in the TOC plugin instead |
2476 | 2481 | // placeholder for drag control creation code |
| 2482 | + /* |
2477 | 2483 | $dragControl = $( '<div />' ).addClass( 'tab' ).attr( 'id', 'wikiEditor-ui-toc-resize-grip' ) |
2478 | 2484 | .append( '<a href="#" title="Drag to resize"></a>' ) |
2479 | 2485 | .bind( 'mousedown', function() { |
2480 | 2486 | $( '#wikiEditor-ui-toc' ) |
2481 | 2487 | .data( 'openWidth', $( '#wikiEditor-ui-toc' ).width() ); |
2482 | 2488 | $() |
2483 | | - .bind( 'mousemove', {'context': context}, $.wikiEditor.modules.toc.fn.drag ) |
2484 | | - .bind( 'mouseup', {'context': context}, $.wikiEditor.modules.toc.fn.stopDrag ); |
| 2489 | + .bind( 'mousemove', context, $.wikiEditor.modules.toc.fn.drag ) |
| 2490 | + .bind( 'mouseup', context, $.wikiEditor.modules.toc.fn.stopDrag ); |
2485 | 2491 | $(context.$iframe[0].contentWindow.document) |
2486 | | - .bind( 'mousemove', {'context': context}, function( e ){ |
| 2492 | + .bind( 'mousemove', function() { |
2487 | 2493 | parent.top.$j().trigger("mousemove", e.pageX); |
2488 | | - return false; |
| 2494 | + return false; |
2489 | 2495 | } ) |
2490 | | - .bind( 'mouseup', {'context': context}, function( e ){ |
| 2496 | + .bind( 'mouseup', function() { |
2491 | 2497 | parent.top.$j().trigger("mouseup"); |
2492 | | - return false; |
| 2498 | + return false; |
2493 | 2499 | }); |
2494 | 2500 | return false; |
2495 | 2501 | }) |
2496 | 2502 | context.modules.$toolbar.append( $dragControl ); |
| 2503 | + */ |
2497 | 2504 | } |
2498 | 2505 | var $sections = $( '<div />' ).addClass( 'sections' ).appendTo( context.modules.$toolbar ); |
2499 | 2506 | context.modules.$toolbar.append( $( '<div />' ).css( 'clear', 'both' ) ); |
— | — | @@ -2560,7 +2567,7 @@ |
2561 | 2568 | if ( '$toc' in context.modules ) { |
2562 | 2569 | return; |
2563 | 2570 | } |
2564 | | - /* |
| 2571 | + |
2565 | 2572 | context.initialWidth = $.wikiEditor.modules.toc.defaultWidth; |
2566 | 2573 | if( wgNavigableTOCResizable ) { |
2567 | 2574 | if( !$.cookie( 'wikiEditor-' + context.instance + '-toc-width' ) ) { |
— | — | @@ -2572,7 +2579,7 @@ |
2573 | 2580 | context.initialWidth = $.cookie( 'wikiEditor-' + context.instance + '-toc-width' ); |
2574 | 2581 | } |
2575 | 2582 | } |
2576 | | - */ |
| 2583 | + |
2577 | 2584 | var height = context.$ui.find( '.wikiEditor-ui-left' ).height(); |
2578 | 2585 | context.modules.$toc = $( '<div />' ) |
2579 | 2586 | .addClass( 'wikiEditor-ui-toc' ) |
— | — | @@ -2584,9 +2591,9 @@ |
2585 | 2592 | context.$ui.find( '.wikiEditor-ui-left' ).height() |
2586 | 2593 | ); |
2587 | 2594 | context.$ui.find( '.wikiEditor-ui-left' ) |
2588 | | - .css( 'marginRight', "-" + $.wikiEditor.modules.toc.defaultWidth) |
| 2595 | + .css( 'marginRight', "-" + $.wikiEditor.modules.toc.defaultWidth ) |
2589 | 2596 | .children() |
2590 | | - .css('marginRight', $.wikiEditor.modules.toc.defaultWidth ); |
| 2597 | + .css( 'marginRight', $.wikiEditor.modules.toc.defaultWidth ); |
2591 | 2598 | |
2592 | 2599 | // Add the TOC to the document |
2593 | 2600 | $.wikiEditor.modules.toc.fn.build( context, config ); |
— | — | @@ -2656,46 +2663,50 @@ |
2657 | 2664 | /** |
2658 | 2665 | * Collapse the contents module |
2659 | 2666 | * |
2660 | | - * @param {Object} context |
| 2667 | + * @param {Object} event Event object with context as data |
2661 | 2668 | */ |
2662 | | - collapse: function( context ) { |
2663 | | - var $toc = $( '#wikiEditor-ui-toc' ); |
2664 | | - if( !$toc.data( 'openWidth' ) ) { |
| 2669 | + collapse: function( event ) { |
| 2670 | + var context = event.data; |
| 2671 | + var $toc = context.modules.$toc; |
| 2672 | + if( !$toc.data( 'openWidth' ) ) { |
2665 | 2673 | $toc.data( 'openWidth', $toc.width() ); |
2666 | 2674 | } |
2667 | | - var $toolbar = $( '#wikiEditor-ui-toolbar .tab-toc' ) |
| 2675 | + context.$ui.find( '.tab-toc' ) |
2668 | 2676 | .unbind( 'click', $.wikiEditor.modules.toc.fn.collapse ) |
2669 | | - .bind( 'click', $.wikiEditor.modules.toc.fn.expand ) |
| 2677 | + .bind( 'click', context, $.wikiEditor.modules.toc.fn.expand ) |
2670 | 2678 | .children( 'a' ) |
2671 | | - .text( 'Show Contents' ); |
| 2679 | + .text( gM( 'wikieditor-toc-show' ) ); |
2672 | 2680 | |
2673 | 2681 | $toc |
2674 | | - .animate( { 'width': '1px' }, 'fast', function() { $(this).hide(); } ) |
2675 | | - .prev() |
2676 | | - .animate( {'marginRight': '1px'}, 'fast', function() { $(this).css('marginRight', '-1px'); } ); |
2677 | | - $.cookie( 'wikiEditor-' + context.instance + '-toc-width', '1px' ); |
| 2682 | + //.animate( { 'width': '1px' }, 'fast', function() { $(this).hide(); } ) |
| 2683 | + .animate( { 'width': 1 }, 'fast' ); |
| 2684 | + //.prev() |
| 2685 | + //.animate( {'marginRight': '1px'}, 'fast', function() { $(this).css('marginRight', '-1px'); } ); |
| 2686 | + $.cookie( 'wikiEditor-' + context.instance + '-toc-width', 1 ); |
2678 | 2687 | return false; |
2679 | 2688 | }, |
2680 | 2689 | |
2681 | 2690 | /** |
2682 | 2691 | * Expand the contents module |
2683 | 2692 | * |
2684 | | - * @param {Object} context |
| 2693 | + * @param {Object} event Event object with context as data |
2685 | 2694 | */ |
2686 | | - expand: function( context ) { |
2687 | | - $( '#wikiEditor-ui-toolbar .tab-toc' ) |
| 2695 | + expand: function( event) { |
| 2696 | + var context = event.data; |
| 2697 | + context.$ui.find( '.tab-toc' ) |
2688 | 2698 | .unbind( 'click', $.wikiEditor.modules.toc.fn.expand ) |
2689 | | - .bind( 'click', $.wikiEditor.modules.toc.fn.collapse ) |
| 2699 | + .bind( 'click', context, $.wikiEditor.modules.toc.fn.collapse ) |
2690 | 2700 | .children( 'a' ) |
2691 | | - .text( 'Hide Contents' ); |
2692 | | - $( '#wikiEditor-ui-toc' ) |
| 2701 | + .text( gM( 'wikieditor-toc-hide' ) ); |
| 2702 | + context.modules.$toc |
2693 | 2703 | .show() |
2694 | | - .animate( { 'width': $( '#wikiEditor-ui-toc' ).data( 'openWidth' )}, 'fast', function() { |
2695 | | - $( '#wikiEditor-ui-text textarea' ).trigger( 'mouseup' ); |
2696 | | - } ) |
2697 | | - .prev() |
2698 | | - .animate( { 'marginRight': $( '#wikiEditor-ui-toc' ).data( 'openWidth' ) }, 'fast' ); |
2699 | | - $.cookie( 'wikiEditor-' + context.instance + '-toc-width', $( '#wikiEditor-ui-toc' ).data( 'openWidth' ) ); |
| 2704 | + .animate( { 'width': context.modules.$toc.data( 'openWidth' ) }, 'fast' ); |
| 2705 | + //.animate( { 'width': context.modules.$toc.data( 'openWidth' )}, 'fast', function() { |
| 2706 | + // $( '#wikiEditor-ui-text textarea' ).trigger( 'mouseup' ); |
| 2707 | + //} ) |
| 2708 | + //.prev() |
| 2709 | + //.animate( { 'marginRight': context.modules.$toc.data( 'openWidth' ) }, 'fast' ); |
| 2710 | + $.cookie( 'wikiEditor-' + context.instance + '-toc-width', context.modules.$toc.data( 'openWidth' ) ); |
2700 | 2711 | return false; |
2701 | 2712 | }, |
2702 | 2713 | /** |
— | — | @@ -2704,13 +2715,22 @@ |
2705 | 2716 | * @param {object} e |
2706 | 2717 | */ |
2707 | 2718 | drag: function( e, pageX ) { |
2708 | | - var mR = pageX ? pageX : |
2709 | | - (e.pageX - e.data.context.$ui.find( '.wikiEditor-ui-left' ).offset().left); |
2710 | | - mR = e.data.context.$ui.find( '.wikiEditor-ui-left' ).width() - mR; |
2711 | | - if( mR < 26 || mR > e.data.context.$ui.find( '.wikiEditor-ui-left' ).width() - 250) return false; |
2712 | | - e.data.context.$ui.find( '.wikiEditor-ui-left' ).css( 'marginRight', "-"+mR+'px' ) |
2713 | | - .children().css('marginRight', mR+'px'); |
2714 | | - e.data.context.$ui.find( '.wikiEditor-ui-right' ).css( 'width', mR+'px' ); |
| 2719 | + var context = e.data; |
| 2720 | + var mR; |
| 2721 | + // This used to be done with a ternary expression, but for some reason that |
| 2722 | + // returned NaN in some cases. Even this seems to be buggy in that .offset().left |
| 2723 | + // is sometimes 0. |
| 2724 | + // FIXME: We should ditch the whole thing and use jQuery UI Resizable if possible |
| 2725 | + if ( pageX ) |
| 2726 | + mR = pageX; |
| 2727 | + else |
| 2728 | + mR = e.pageX - context.$ui.find( '.wikiEditor.ui-left' ).offset().left; |
| 2729 | + mR = context.$ui.find( '.wikiEditor-ui-left' ).width() - mR; |
| 2730 | + if( mR < 26 || mR > context.$ui.find( '.wikiEditor-ui-left' ).width() - 250) |
| 2731 | + return false; |
| 2732 | + context.$ui.find( '.wikiEditor-ui-left' ).css( 'marginRight', -mR ) |
| 2733 | + .children().css('marginRight', mR); |
| 2734 | + context.$ui.find( '.wikiEditor-ui-right' ).css( 'width', mR ); |
2715 | 2735 | return false; |
2716 | 2736 | }, |
2717 | 2737 | /** |
— | — | @@ -2719,19 +2739,21 @@ |
2720 | 2740 | * @param {object} e |
2721 | 2741 | */ |
2722 | 2742 | stopDrag: function( e ) { |
| 2743 | + var context = e.data; |
2723 | 2744 | $() |
2724 | 2745 | .unbind( 'mousemove', $.wikiEditor.modules.toc.fn.drag ) |
2725 | 2746 | .unbind( 'mouseup', $.wikiEditor.modules.toc.fn.stopDrag ); |
2726 | | - $(e.data.context.$iframe[0].contentWindow.document) |
| 2747 | + $(context.$iframe[0].contentWindow.document) |
2727 | 2748 | .unbind( 'mousemove' ) |
2728 | 2749 | .unbind( 'mouseup' ); |
2729 | | - if( $( '#wikiEditor-ui-right' ).width() < 50 && wgNavigableTOCCollapseEnable ) { |
2730 | | - $.wikiEditor.modules.toc.fn.collapse( e.data.context ); |
| 2750 | + if( context.$ui.find( '.wikiEditor-ui-right' ).width() < 50 && wgNavigableTOCCollapseEnable ) { |
| 2751 | + $.wikiEditor.modules.toc.fn.collapse( { data: context } ); |
2731 | 2752 | } else { |
2732 | | - $( '#wikiEditor-ui-left' ).trigger( 'mouseup' ); |
2733 | | - $( '#wikiEditor-ui-right' ) |
2734 | | - .data( 'openWidth', $( '#wikiEditor-ui-right' ).width() + 'px' ); |
2735 | | - $.cookie( 'wikiEditor-' + e.data.context.instance + '-toc-width', $( '#wikiEditor-ui-right' ).width() + 'px' ); |
| 2753 | + context.$ui.find( '.wikiEditor-ui-left' ).trigger( 'mouseup' ); |
| 2754 | + context.$ui.find( '.wikiEditor-ui-right' ) |
| 2755 | + .data( 'openWidth', context.$ui.find( '.wikiEditor-ui-right' ).width() ); |
| 2756 | + $.cookie( 'wikiEditor-' + context.instance + '-toc-width', |
| 2757 | + context.$ui.find( '.wikiEditor-ui-right' ).width() ); |
2736 | 2758 | } |
2737 | 2759 | return false; |
2738 | 2760 | }, |
— | — | @@ -2793,17 +2815,18 @@ |
2794 | 2816 | return list; |
2795 | 2817 | } |
2796 | 2818 | function buildCollapseBar() { |
2797 | | - $( '.wikiEditor-ui-toc ul:first' ).css( 'width', '147px' ) |
| 2819 | + // FIXME: Move this to a .css file |
| 2820 | + context.modules.$toc.find( 'ul:first' ).css( 'width', '147px' ) |
2798 | 2821 | .css( 'margin-left', '19px' ).css( 'border-left', '1px solid #DDDDDD' ); |
2799 | 2822 | var $collapseBar = $( '<div />' ) |
2800 | 2823 | .addClass( 'wikiEditor-ui-toc-collapse-open' ) |
2801 | 2824 | .attr( 'id', 'wikiEditor-ui-toc-collapse' ) |
2802 | | - .data( 'openWidth', $.wikiEditor.modules.toc.defaultWidth) |
| 2825 | + .data( 'openWidth', $.wikiEditor.modules.toc.defaultWidth ) |
2803 | 2826 | .bind( 'mouseup', function() { |
2804 | 2827 | var $e = $(this); |
2805 | 2828 | var close = $e.hasClass( 'wikiEditor-ui-toc-collapse-open' ); |
2806 | 2829 | if( close ) { |
2807 | | - $( '#wikiEditor-ui-toc-collapse' ) |
| 2830 | + $e |
2808 | 2831 | .removeClass( 'wikiEditor-ui-toc-collapse-open' ); |
2809 | 2832 | $e.parent() |
2810 | 2833 | .animate( { 'width': $e.outerWidth() }, 'fast', function() { |
— | — | @@ -2811,65 +2834,63 @@ |
2812 | 2835 | } ) |
2813 | 2836 | .prev() |
2814 | 2837 | .animate( { 'marginRight': $e.outerWidth() + 1 }, 'fast', function() { |
2815 | | - $( '#wikiEditor-ui-toc-collapse' ) |
| 2838 | + $e |
2816 | 2839 | .addClass( 'wikiEditor-ui-toc-collapse-closed' ); |
2817 | 2840 | }); |
2818 | 2841 | } else { |
2819 | | - $( '#wikiEditor-ui-toc-collapse' ) |
| 2842 | + $e |
2820 | 2843 | .removeClass( 'wikiEditor-ui-toc-collapse-closed' ); |
2821 | 2844 | $e.siblings().show() |
2822 | 2845 | .parent() |
2823 | 2846 | .animate( { 'width': $e.data( 'openWidth' ) }, 'fast' ) |
2824 | 2847 | .prev() |
2825 | 2848 | .animate( { 'marginRight': $e.data( 'openWidth' ) }, 'fast', function() { |
2826 | | - $( '#wikiEditor-ui-toc-collapse' ) |
| 2849 | + $e |
2827 | 2850 | .addClass( 'wikiEditor-ui-toc-collapse-open' ); |
2828 | 2851 | }); |
2829 | 2852 | } |
2830 | 2853 | |
2831 | 2854 | }); |
2832 | | - return $collapseBar; |
| 2855 | + return $collapseBar; |
2833 | 2856 | } |
2834 | 2857 | function buildResizeControls() { |
2835 | 2858 | var $resizeControlVertical = $( '<div />' ) |
2836 | 2859 | .attr( 'id', 'wikiEditor-ui-toc-resize-vertical') |
2837 | 2860 | .bind( 'mousedown', function() { |
2838 | | - $( '#wikiEditor-ui-toc' ) |
2839 | | - .data( 'openWidth', $( '#wikiEditor-ui-toc' ).width() ); |
| 2861 | + context.modules.$toc |
| 2862 | + .data( 'openWidth', context.modules.$toc.width() ); |
2840 | 2863 | $() |
2841 | | - .bind( 'mousemove', { 'context': context }, $.wikiEditor.modules.toc.fn.drag ) |
2842 | | - .bind( 'mouseup', {'context': context}, $.wikiEditor.modules.toc.fn.stopDrag ); |
| 2864 | + .bind( 'mousemove', context, $.wikiEditor.modules.toc.fn.drag ) |
| 2865 | + .bind( 'mouseup', context, $.wikiEditor.modules.toc.fn.stopDrag ); |
2843 | 2866 | $(context.$iframe[0].contentWindow.document) |
2844 | | - .bind( 'mousemove', {'context': context}, function( e ){ |
2845 | | - parent.top.$j().trigger("mousemove", e.pageX); |
| 2867 | + .bind( 'mousemove', function( e ) { |
| 2868 | + parent.top.$j().trigger("mousemove", e.pageX); |
2846 | 2869 | return false; |
2847 | 2870 | } ) |
2848 | | - .bind( 'mouseup', {'context': context}, function( e ){ |
2849 | | - parent.top.$j().trigger("mouseup"); |
2850 | | - return false; |
| 2871 | + .bind( 'mouseup', function() { |
| 2872 | + parent.top.$j().trigger("mouseup"); |
| 2873 | + return false; |
2851 | 2874 | }); |
2852 | 2875 | return false; |
2853 | 2876 | }); |
2854 | 2877 | |
2855 | 2878 | var $collapseControl = $( '<div />' ).addClass( 'tab' ).addClass( 'tab-toc' ) |
2856 | | - .append( '<a href="#"></a>' ); |
2857 | | - if( $.cookie( 'wikiEditor-' + context.instance + '-toc-width' ) != '1px' ) { |
2858 | | - $collapseControl.bind( 'click', function() { |
2859 | | - $.wikiEditor.modules.toc.fn.collapse( context ); |
2860 | | - } ) |
2861 | | - .find( 'a' ).text( 'Hide Contents' ); |
2862 | | - } else { |
2863 | | - $collapseControl.bind( 'click', function() { |
2864 | | - $.wikiEditor.modules.toc.fn.expand( context ); |
2865 | | - } ) |
2866 | | - .find( 'a' ).text( 'Show Contents' ); |
| 2879 | + .append( '<a href="#" />' ); |
| 2880 | + if( $.cookie( 'wikiEditor-' + context.instance + '-toc-width' ) != 1 ) { |
| 2881 | + $collapseControl.bind( 'click', context, $.wikiEditor.modules.toc.fn.collapse ) |
| 2882 | + .find( 'a' ).text( gM( 'wikieditor-toc-hide' ) ); |
| 2883 | + } else { |
| 2884 | + $collapseControl.bind( 'click', context, $.wikiEditor.modules.toc.fn.expand ) |
| 2885 | + .find( 'a' ).text( gM( 'wikieditor-toc-show' ) ); |
2867 | 2886 | } |
2868 | 2887 | $collapseControl.insertBefore( context.modules.$toc ); |
2869 | 2888 | |
2870 | | - if( !$( '#wikiEditor-ui-toc' ).data( 'openWidth' ) ) { |
2871 | | - $( '#wikiEditor-ui-toc' ).data( 'openWidth', context.initialWidth == '1px' ? |
| 2889 | + if( !context.modules.$toc.data( 'openWidth' ) ) { |
| 2890 | + context.modules.$toc.data( 'openWidth', context.initialWidth == 1 ? |
2872 | 2891 | $.wikiEditor.modules.toc.defaultWidth : context.initialWidth ); |
2873 | 2892 | } |
| 2893 | + if ( context.initialWidth == 1 ) |
| 2894 | + $.wikiEditor.modules.toc.fn.collapse( { data: context } ); |
2874 | 2895 | return $resizeControlVertical; |
2875 | 2896 | } |
2876 | 2897 | |
— | — | @@ -2935,7 +2956,7 @@ |
2936 | 2957 | |
2937 | 2958 | if(wgNavigableTOCResizable) { |
2938 | 2959 | context.modules.$toc.append( buildResizeControls() ); |
2939 | | - }else if(wgNavigableTOCCollapseEnable){ |
| 2960 | + } else if(wgNavigableTOCCollapseEnable) { |
2940 | 2961 | context.modules.$toc.append( buildCollapseBar() ); |
2941 | 2962 | } |
2942 | 2963 | context.modules.$toc.find( 'div' ).autoEllipse( { 'position': 'right', 'tooltip': true } ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -92,9 +92,10 @@ |
93 | 93 | var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);if(options.ownline){if(range.startOffset!=0) |
94 | 94 | pre="\n"+options.pre;if(range.endContainer==range.commonAncestorContainer) |
95 | 95 | post+="\n";} |
96 | | -var insertText=pre+selText+post;var insertLines=insertText.split("\n");range.extractContents();for(var i=insertLines.length-1;i>=0;i--){range.insertNode(document.createTextNode(insertLines[i]));if(i>0) |
97 | | -range.insertNode(document.createElement('br'));} |
98 | | -return context.$textarea;},'getCaretPosition':function(options){},'setSelection':function(options){},'scrollToCaretPosition':function(options){},'scrollToTop':function($element,force){var body=context.$content.closest('body');var y=$element.offset().top-context.$content.offset().top;if(force||y<body.scrollTop()||y>body.scrollTop()+body.height()) |
| 96 | +var insertText=pre+selText+post;var insertLines=insertText.split("\n");range.extractContents();var lastNode;for(var i=insertLines.length-1;i>=0;i--){range.insertNode(document.createTextNode(insertLines[i]));if(i>0) |
| 97 | +lastNode=range.insertNode(document.createElement('br'));} |
| 98 | +if(lastNode) |
| 99 | +context.fn.scrollToTop(lastNode);return context.$textarea;},'getCaretPosition':function(options){},'setSelection':function(options){},'scrollToCaretPosition':function(options){},'scrollToTop':function($element,force){var body=context.$content.closest('body');var y=$element.offset().top-context.$content.offset().top;if(force||y<body.scrollTop()||y>body.scrollTop()+body.height()) |
99 | 100 | body.scrollTop(y);}};} |
100 | 101 | if(arguments.length>0&&typeof arguments[0]=='object'){if(context.$content) |
101 | 102 | context.api.addModule(context,arguments[0]);else{var args=arguments;setTimeout(function(){context.api.addModule(context,args[0]);},2);}}else{arguments=$.makeArray(arguments);if(arguments.length>0){var call=arguments.shift();if(call in context.api){if(context.$content) |
— | — | @@ -152,16 +153,19 @@ |
153 | 154 | $section=$('<div />').attr({'class':'booklet section section-'+id,'rel':id}).append($index).append($pages);$.wikiEditor.modules.toolbar.fn.updateBookletSelection(context,page,$pages,$index);break;} |
154 | 155 | if($section!==null&&id!=='main'){var show=selected==id;$section.css('display',show?'block':'none');} |
155 | 156 | return $section;},updateBookletSelection:function(context,id,$pages,$index){var cookie='wikiEditor-'+context.instance+'-booklet-'+id+'-page';var selected=$.cookie(cookie);var $selectedIndex=$index.find('*[rel='+selected+']');if($selectedIndex.size()==0){selected=$index.children().eq(0).attr('rel');$.cookie(cookie,selected);} |
156 | | -$pages.children().hide();$pages.find('*[rel='+selected+']').show();$index.children().removeClass('current');$selectedIndex.addClass('current');},build:function(context,config){var $tabs=$('<div />').addClass('tabs').appendTo(context.modules.$toolbar);if(wgNavigableTOCCollapseEnable){$dragControl=$('<div />').addClass('tab').attr('id','wikiEditor-ui-toc-resize-grip').append('<a href="#" title="Drag to resize"></a>').bind('mousedown',function(){$('#wikiEditor-ui-toc').data('openWidth',$('#wikiEditor-ui-toc').width());$().bind('mousemove',{'context':context},$.wikiEditor.modules.toc.fn.drag).bind('mouseup',{'context':context},$.wikiEditor.modules.toc.fn.stopDrag);$(context.$iframe[0].contentWindow.document).bind('mousemove',{'context':context},function(e){parent.top.$j().trigger("mousemove",e.pageX);return false;}).bind('mouseup',{'context':context},function(e){parent.top.$j().trigger("mouseup");return false;});return false;}) |
157 | | -context.modules.$toolbar.append($dragControl);} |
| 157 | +$pages.children().hide();$pages.find('*[rel='+selected+']').show();$index.children().removeClass('current');$selectedIndex.addClass('current');},build:function(context,config){var $tabs=$('<div />').addClass('tabs').appendTo(context.modules.$toolbar);if(wgNavigableTOCCollapseEnable){} |
158 | 158 | var $sections=$('<div />').addClass('sections').appendTo(context.modules.$toolbar);context.modules.$toolbar.append($('<div />').css('clear','both'));var sectionQueue=[];for(section in config){if(section=='main'){context.modules.$toolbar.prepend($.wikiEditor.modules.toolbar.fn.buildSection(context,section,config[section]));}else{sectionQueue.push({'$sections':$sections,'context':context,'id':section,'config':config[section]});$tabs.append($.wikiEditor.modules.toolbar.fn.buildTab(context,section,config[section]));}} |
159 | 159 | $.eachAsync(sectionQueue,{'bulk':0,'end':function(){$('body').css('position','static');$('body').css('position','relative');},'loop':function(i,s){s.$sections.append($.wikiEditor.modules.toolbar.fn.buildSection(s.context,s.id,s.config));var $section=s.$sections.find('.section:visible');if($section.size()){$sections.animate({'height':$section.outerHeight()},$section.outerHeight()*2);}}});}}};})(jQuery);(function($){$.wikiEditor.modules.toc={api:{},defaultWidth:'13em',fn:{create:function(context,config){if('$toc'in context.modules){return;} |
| 160 | +context.initialWidth=$.wikiEditor.modules.toc.defaultWidth;if(wgNavigableTOCResizable){if(!$.cookie('wikiEditor-'+context.instance+'-toc-width')){$.cookie('wikiEditor-'+context.instance+'-toc-width',$.wikiEditor.modules.toc.defaultWidth);}else{context.initialWidth=$.cookie('wikiEditor-'+context.instance+'-toc-width');}} |
160 | 161 | var height=context.$ui.find('.wikiEditor-ui-left').height();context.modules.$toc=$('<div />').addClass('wikiEditor-ui-toc').data('context',context);context.$ui.find('.wikiEditor-ui-right').css('width',$.wikiEditor.modules.toc.defaultWidth).append(context.modules.$toc);context.modules.$toc.height(context.$ui.find('.wikiEditor-ui-left').height());context.$ui.find('.wikiEditor-ui-left').css('marginRight',"-"+$.wikiEditor.modules.toc.defaultWidth).children().css('marginRight',$.wikiEditor.modules.toc.defaultWidth);$.wikiEditor.modules.toc.fn.build(context,config);context.$textarea.delayedBind(250,'mouseup scrollToPosition focus keyup encapsulateSelection change',function(event){var context=$(this).data('wikiEditor-context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(){var context=$(this).data('wikiEditor-context');context.$textarea.delayedBindCancel(250,'mouseup scrollToPosition focus keyup encapsulateSelection change');$.wikiEditor.modules.toc.fn.unhighlight(context);});},unhighlight:function(context){context.modules.$toc.find('div').removeClass('current');},update:function(context){$.wikiEditor.modules.toc.fn.unhighlight(context);var position=context.$textarea.textSelection('getCaretPosition');var section=0;if(context.data.outline.length>0){if(!(position<context.data.outline[0].position-1)){while(section<context.data.outline.length&&context.data.outline[section].position-1<position){section++;} |
161 | 162 | section=Math.max(0,section);} |
162 | 163 | var sectionLink=context.modules.$toc.find('div.section-'+section);sectionLink.addClass('current');var relTop=sectionLink.offset().top-context.modules.$toc.offset().top;var scrollTop=context.modules.$toc.scrollTop();var divHeight=context.modules.$toc.height();var sectionHeight=sectionLink.height();if(relTop<0) |
163 | 164 | context.modules.$toc.scrollTop(scrollTop+relTop);else if(relTop+sectionHeight>divHeight) |
164 | | -context.modules.$toc.scrollTop(scrollTop+relTop+sectionHeight-divHeight);}},collapse:function(context){var $toc=$('#wikiEditor-ui-toc');if(!$toc.data('openWidth')){$toc.data('openWidth',$toc.width());} |
165 | | -var $toolbar=$('#wikiEditor-ui-toolbar .tab-toc').unbind('click',$.wikiEditor.modules.toc.fn.collapse).bind('click',$.wikiEditor.modules.toc.fn.expand).children('a').text('Show Contents');$toc.animate({'width':'1px'},'fast',function(){$(this).hide();}).prev().animate({'marginRight':'1px'},'fast',function(){$(this).css('marginRight','-1px');});$.cookie('wikiEditor-'+context.instance+'-toc-width','1px');return false;},expand:function(context){$('#wikiEditor-ui-toolbar .tab-toc').unbind('click',$.wikiEditor.modules.toc.fn.expand).bind('click',$.wikiEditor.modules.toc.fn.collapse).children('a').text('Hide Contents');$('#wikiEditor-ui-toc').show().animate({'width':$('#wikiEditor-ui-toc').data('openWidth')},'fast',function(){$('#wikiEditor-ui-text textarea').trigger('mouseup');}).prev().animate({'marginRight':$('#wikiEditor-ui-toc').data('openWidth')},'fast');$.cookie('wikiEditor-'+context.instance+'-toc-width',$('#wikiEditor-ui-toc').data('openWidth'));return false;},drag:function(e,pageX){var mR=pageX?pageX:(e.pageX-e.data.context.$ui.find('.wikiEditor-ui-left').offset().left);mR=e.data.context.$ui.find('.wikiEditor-ui-left').width()-mR;if(mR<26||mR>e.data.context.$ui.find('.wikiEditor-ui-left').width()-250)return false;e.data.context.$ui.find('.wikiEditor-ui-left').css('marginRight',"-"+mR+'px').children().css('marginRight',mR+'px');e.data.context.$ui.find('.wikiEditor-ui-right').css('width',mR+'px');return false;},stopDrag:function(e){$().unbind('mousemove',$.wikiEditor.modules.toc.fn.drag).unbind('mouseup',$.wikiEditor.modules.toc.fn.stopDrag);$(e.data.context.$iframe[0].contentWindow.document).unbind('mousemove').unbind('mouseup');if($('#wikiEditor-ui-right').width()<50&&wgNavigableTOCCollapseEnable){$.wikiEditor.modules.toc.fn.collapse(e.data.context);}else{$('#wikiEditor-ui-left').trigger('mouseup');$('#wikiEditor-ui-right').data('openWidth',$('#wikiEditor-ui-right').width()+'px');$.cookie('wikiEditor-'+e.data.context.instance+'-toc-width',$('#wikiEditor-ui-right').width()+'px');} |
| 165 | +context.modules.$toc.scrollTop(scrollTop+relTop+sectionHeight-divHeight);}},collapse:function(event){var context=event.data;var $toc=context.modules.$toc;if(!$toc.data('openWidth')){$toc.data('openWidth',$toc.width());} |
| 166 | +context.$ui.find('.tab-toc').unbind('click',$.wikiEditor.modules.toc.fn.collapse).bind('click',context,$.wikiEditor.modules.toc.fn.expand).children('a').text(gM('wikieditor-toc-show'));$toc.animate({'width':1},'fast');$.cookie('wikiEditor-'+context.instance+'-toc-width',1);return false;},expand:function(event){var context=event.data;context.$ui.find('.tab-toc').unbind('click',$.wikiEditor.modules.toc.fn.expand).bind('click',context,$.wikiEditor.modules.toc.fn.collapse).children('a').text(gM('wikieditor-toc-hide'));context.modules.$toc.show().animate({'width':context.modules.$toc.data('openWidth')},'fast');$.cookie('wikiEditor-'+context.instance+'-toc-width',context.modules.$toc.data('openWidth'));return false;},drag:function(e,pageX){var context=e.data;var mR;if(pageX) |
| 167 | +mR=pageX;else |
| 168 | +mR=e.pageX-context.$ui.find('.wikiEditor.ui-left').offset().left;mR=context.$ui.find('.wikiEditor-ui-left').width()-mR;if(mR<26||mR>context.$ui.find('.wikiEditor-ui-left').width()-250) |
| 169 | +return false;context.$ui.find('.wikiEditor-ui-left').css('marginRight',-mR).children().css('marginRight',mR);context.$ui.find('.wikiEditor-ui-right').css('width',mR);return false;},stopDrag:function(e){var context=e.data;$().unbind('mousemove',$.wikiEditor.modules.toc.fn.drag).unbind('mouseup',$.wikiEditor.modules.toc.fn.stopDrag);$(context.$iframe[0].contentWindow.document).unbind('mousemove').unbind('mouseup');if(context.$ui.find('.wikiEditor-ui-right').width()<50&&wgNavigableTOCCollapseEnable){$.wikiEditor.modules.toc.fn.collapse({data:context});}else{context.$ui.find('.wikiEditor-ui-left').trigger('mouseup');context.$ui.find('.wikiEditor-ui-right').data('openWidth',context.$ui.find('.wikiEditor-ui-right').width());$.cookie('wikiEditor-'+context.instance+'-toc-width',context.$ui.find('.wikiEditor-ui-right').width());} |
166 | 170 | 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;} |
167 | 171 | sections[sections.length]=outline[i];}else if(outline[i].nLevel<level){break;}} |
168 | 172 | return sections;} |
— | — | @@ -170,10 +174,11 @@ |
171 | 175 | div.html(' ');var item=$('<li />').append(div);if(structure[i].sections!==undefined){item.append(buildList(structure[i].sections));} |
172 | 176 | list.append(item);} |
173 | 177 | return list;} |
174 | | -function buildCollapseBar(){$('.wikiEditor-ui-toc ul:first').css('width','147px').css('margin-left','19px').css('border-left','1px solid #DDDDDD');var $collapseBar=$('<div />').addClass('wikiEditor-ui-toc-collapse-open').attr('id','wikiEditor-ui-toc-collapse').data('openWidth',$.wikiEditor.modules.toc.defaultWidth).bind('mouseup',function(){var $e=$(this);var close=$e.hasClass('wikiEditor-ui-toc-collapse-open');if(close){$('#wikiEditor-ui-toc-collapse').removeClass('wikiEditor-ui-toc-collapse-open');$e.parent().animate({'width':$e.outerWidth()},'fast',function(){$(this).find('ul:first').hide();}).prev().animate({'marginRight':$e.outerWidth()+1},'fast',function(){$('#wikiEditor-ui-toc-collapse').addClass('wikiEditor-ui-toc-collapse-closed');});}else{$('#wikiEditor-ui-toc-collapse').removeClass('wikiEditor-ui-toc-collapse-closed');$e.siblings().show().parent().animate({'width':$e.data('openWidth')},'fast').prev().animate({'marginRight':$e.data('openWidth')},'fast',function(){$('#wikiEditor-ui-toc-collapse').addClass('wikiEditor-ui-toc-collapse-open');});}});return $collapseBar;} |
175 | | -function buildResizeControls(){var $resizeControlVertical=$('<div />').attr('id','wikiEditor-ui-toc-resize-vertical').bind('mousedown',function(){$('#wikiEditor-ui-toc').data('openWidth',$('#wikiEditor-ui-toc').width());$().bind('mousemove',{'context':context},$.wikiEditor.modules.toc.fn.drag).bind('mouseup',{'context':context},$.wikiEditor.modules.toc.fn.stopDrag);$(context.$iframe[0].contentWindow.document).bind('mousemove',{'context':context},function(e){parent.top.$j().trigger("mousemove",e.pageX);return false;}).bind('mouseup',{'context':context},function(e){parent.top.$j().trigger("mouseup");return false;});return false;});var $collapseControl=$('<div />').addClass('tab').addClass('tab-toc').append('<a href="#"></a>');if($.cookie('wikiEditor-'+context.instance+'-toc-width')!='1px'){$collapseControl.bind('click',function(){$.wikiEditor.modules.toc.fn.collapse(context);}).find('a').text('Hide Contents');}else{$collapseControl.bind('click',function(){$.wikiEditor.modules.toc.fn.expand(context);}).find('a').text('Show Contents');} |
176 | | -$collapseControl.insertBefore(context.modules.$toc);if(!$('#wikiEditor-ui-toc').data('openWidth')){$('#wikiEditor-ui-toc').data('openWidth',context.initialWidth=='1px'?$.wikiEditor.modules.toc.defaultWidth:context.initialWidth);} |
177 | | -return $resizeControlVertical;} |
| 178 | +function buildCollapseBar(){context.modules.$toc.find('ul:first').css('width','147px').css('margin-left','19px').css('border-left','1px solid #DDDDDD');var $collapseBar=$('<div />').addClass('wikiEditor-ui-toc-collapse-open').attr('id','wikiEditor-ui-toc-collapse').data('openWidth',$.wikiEditor.modules.toc.defaultWidth).bind('mouseup',function(){var $e=$(this);var close=$e.hasClass('wikiEditor-ui-toc-collapse-open');if(close){$e.removeClass('wikiEditor-ui-toc-collapse-open');$e.parent().animate({'width':$e.outerWidth()},'fast',function(){$(this).find('ul:first').hide();}).prev().animate({'marginRight':$e.outerWidth()+1},'fast',function(){$e.addClass('wikiEditor-ui-toc-collapse-closed');});}else{$e.removeClass('wikiEditor-ui-toc-collapse-closed');$e.siblings().show().parent().animate({'width':$e.data('openWidth')},'fast').prev().animate({'marginRight':$e.data('openWidth')},'fast',function(){$e.addClass('wikiEditor-ui-toc-collapse-open');});}});return $collapseBar;} |
| 179 | +function buildResizeControls(){var $resizeControlVertical=$('<div />').attr('id','wikiEditor-ui-toc-resize-vertical').bind('mousedown',function(){context.modules.$toc.data('openWidth',context.modules.$toc.width());$().bind('mousemove',context,$.wikiEditor.modules.toc.fn.drag).bind('mouseup',context,$.wikiEditor.modules.toc.fn.stopDrag);$(context.$iframe[0].contentWindow.document).bind('mousemove',function(e){parent.top.$j().trigger("mousemove",e.pageX);return false;}).bind('mouseup',function(){parent.top.$j().trigger("mouseup");return false;});return false;});var $collapseControl=$('<div />').addClass('tab').addClass('tab-toc').append('<a href="#" />');if($.cookie('wikiEditor-'+context.instance+'-toc-width')!=1){$collapseControl.bind('click',context,$.wikiEditor.modules.toc.fn.collapse).find('a').text(gM('wikieditor-toc-hide'));}else{$collapseControl.bind('click',context,$.wikiEditor.modules.toc.fn.expand).find('a').text(gM('wikieditor-toc-show'));} |
| 180 | +$collapseControl.insertBefore(context.modules.$toc);if(!context.modules.$toc.data('openWidth')){context.modules.$toc.data('openWidth',context.initialWidth==1?$.wikiEditor.modules.toc.defaultWidth:context.initialWidth);} |
| 181 | +if(context.initialWidth==1) |
| 182 | +$.wikiEditor.modules.toc.fn.collapse({data:context});return $resizeControlVertical;} |
178 | 183 | var outline=[];var h=0;context.$content.contents().each(function(){if(this.nodeName!='#text') |
179 | 184 | return;var text=this.textContent;var match=text.match(/^(={1,6})(.*?)\1\s*$/);if(!match) |
180 | 185 | return;var div;if($(this).parent().is('div')&&$(this).parent().children().size()==1) |