Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 21 ), |
74 | 74 | array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 31 ), |
75 | 75 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 1 ), |
76 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 35 ), |
| 76 | + array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 36 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 9 ), |
78 | 78 | array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 48 ), |
79 | 79 | array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 7 ), |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.preview.js |
— | — | @@ -17,14 +17,15 @@ |
18 | 18 | * @param config Configuration object to create module from |
19 | 19 | */ |
20 | 20 | create: function( context, config ) { |
21 | | - if ( 'preview' in context.modules ) { |
| 21 | + if ( 'initialized' in context.modules.preview ) { |
22 | 22 | return; |
23 | 23 | } |
24 | 24 | context.modules.preview = { |
| 25 | + 'initialized': true, |
25 | 26 | 'previewText': null, |
26 | 27 | 'changesText': null |
27 | 28 | }; |
28 | | - context.$preview = context.fn.addView( { |
| 29 | + context.modules.preview.$preview = context.fn.addView( { |
29 | 30 | 'name': 'preview', |
30 | 31 | 'titleMsg': 'wikieditor-preview-tab', |
31 | 32 | 'init': function( context ) { |
— | — | @@ -34,8 +35,8 @@ |
35 | 36 | if ( context.modules.preview.previewText == wikitext ) { |
36 | 37 | return; |
37 | 38 | } |
38 | | - context.$preview.find( '.wikiEditor-preview-contents' ).empty(); |
39 | | - context.$preview.find( '.wikiEditor-preview-loading' ).show(); |
| 39 | + context.modules.preview.$preview.find( '.wikiEditor-preview-contents' ).empty(); |
| 40 | + context.modules.preview.$preview.find( '.wikiEditor-preview-loading' ).show(); |
40 | 41 | $.post( |
41 | 42 | wgScriptPath + '/api.php', |
42 | 43 | { |
— | — | @@ -55,8 +56,8 @@ |
56 | 57 | return; |
57 | 58 | } |
58 | 59 | context.modules.preview.previewText = wikitext; |
59 | | - context.$preview.find( '.wikiEditor-preview-loading' ).hide(); |
60 | | - context.$preview.find( '.wikiEditor-preview-contents' ) |
| 60 | + context.modules.preview.$preview.find( '.wikiEditor-preview-loading' ).hide(); |
| 61 | + context.modules.preview.$preview.find( '.wikiEditor-preview-contents' ) |
61 | 62 | .html( data.parse.text['*'] ) |
62 | 63 | .find( 'a:not([href^=#])' ).click( function() { return false; } ); |
63 | 64 | }, |
— | — | @@ -113,9 +114,9 @@ |
114 | 115 | ); |
115 | 116 | } |
116 | 117 | } ); |
117 | | - |
| 118 | + |
118 | 119 | var loadingMsg = gM( 'wikieditor-preview-loading' ); |
119 | | - context.$preview |
| 120 | + context.modules.preview.$preview |
120 | 121 | .add( context.$changesTab ) |
121 | 122 | .append( $( '<div />' ) |
122 | 123 | .addClass( 'wikiEditor-preview-loading' ) |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js |
— | — | @@ -21,11 +21,6 @@ |
22 | 22 | */ |
23 | 23 | evt: { |
24 | 24 | ready: function( context, event ) { |
25 | | - // Only run this code if this module is turned on |
26 | | - if ( !( '$toc' in context.modules ) ) { |
27 | | - return; |
28 | | - } |
29 | | - |
30 | 25 | // Add the TOC to the document |
31 | 26 | $.wikiEditor.modules.toc.fn.build( context ); |
32 | 27 | context.$content.parent() |
— | — | @@ -58,18 +53,18 @@ |
59 | 54 | * @param {Object} config Configuration object to create module from |
60 | 55 | */ |
61 | 56 | create: function( context, config ) { |
62 | | - if ( '$toc' in context.modules ) { |
| 57 | + if ( '$toc' in context.modules.toc ) { |
63 | 58 | return; |
64 | 59 | } |
65 | 60 | |
66 | 61 | var height = context.$ui.find( '.wikiEditor-ui-left' ).height(); |
67 | | - context.modules.$toc = $( '<div />' ) |
| 62 | + context.modules.toc.$toc = $( '<div />' ) |
68 | 63 | .addClass( 'wikiEditor-ui-toc' ) |
69 | 64 | .data( 'context', context ); |
70 | 65 | context.$ui.find( '.wikiEditor-ui-right' ) |
71 | 66 | .css( 'width', $.wikiEditor.modules.toc.defaultWidth ) |
72 | | - .append( context.modules.$toc ); |
73 | | - context.modules.$toc.height( |
| 67 | + .append( context.modules.toc.$toc ); |
| 68 | + context.modules.toc.$toc.height( |
74 | 69 | context.$ui.find( '.wikiEditor-ui-left' ).height() |
75 | 70 | ); |
76 | 71 | context.$ui.find( '.wikiEditor-ui-left' ) |
— | — | @@ -79,7 +74,7 @@ |
80 | 75 | }, |
81 | 76 | |
82 | 77 | unhighlight: function( context ) { |
83 | | - context.modules.$toc.find( 'div' ).removeClass( 'current' ); |
| 78 | + context.modules.toc.$toc.find( 'div' ).removeClass( 'current' ); |
84 | 79 | }, |
85 | 80 | /** |
86 | 81 | * Highlight the section the cursor is currently within |
— | — | @@ -103,20 +98,20 @@ |
104 | 99 | } |
105 | 100 | section = Math.max( 0, section ); |
106 | 101 | } |
107 | | - var sectionLink = context.modules.$toc.find( 'div.section-' + section ); |
| 102 | + var sectionLink = context.modules.toc.$toc.find( 'div.section-' + section ); |
108 | 103 | sectionLink.addClass( 'current' ); |
109 | 104 | |
110 | 105 | // Scroll the highlighted link into view if necessary |
111 | | - var relTop = sectionLink.offset().top - context.modules.$toc.offset().top; |
112 | | - var scrollTop = context.modules.$toc.scrollTop(); |
113 | | - var divHeight = context.modules.$toc.height(); |
| 106 | + var relTop = sectionLink.offset().top - context.modules.toc.$toc.offset().top; |
| 107 | + var scrollTop = context.modules.toc.$toc.scrollTop(); |
| 108 | + var divHeight = context.modules.toc.$toc.height(); |
114 | 109 | var sectionHeight = sectionLink.height(); |
115 | 110 | if ( relTop < 0 ) |
116 | 111 | // Scroll up |
117 | | - context.modules.$toc.scrollTop( scrollTop + relTop ); |
| 112 | + context.modules.toc.$toc.scrollTop( scrollTop + relTop ); |
118 | 113 | else if ( relTop + sectionHeight > divHeight ) |
119 | 114 | // Scroll down |
120 | | - context.modules.$toc.scrollTop( scrollTop + relTop + sectionHeight - divHeight ); |
| 115 | + context.modules.toc.$toc.scrollTop( scrollTop + relTop + sectionHeight - divHeight ); |
121 | 116 | } |
122 | 117 | }, |
123 | 118 | |
— | — | @@ -155,7 +150,7 @@ |
156 | 151 | expand: function( event ) { |
157 | 152 | var $this = $( this ), |
158 | 153 | context = $this.data( 'context' ), |
159 | | - openWidth = context.modules.$toc.data( 'openWidth' ); |
| 154 | + openWidth = context.modules.toc.$toc.data( 'openWidth' ); |
160 | 155 | context.$ui.find( '.wikiEditor-ui-toc-expandControl' ).hide(); |
161 | 156 | $this.parent() |
162 | 157 | .show() |
— | — | @@ -171,7 +166,7 @@ |
172 | 167 | .children() |
173 | 168 | .animate( { 'marginRight': openWidth }, 'fast' ); |
174 | 169 | $.cookie( 'wikiEditor-' + context.instance + '-toc-width', |
175 | | - context.modules.$toc.data( 'openWidth' ) ); |
| 170 | + context.modules.toc.$toc.data( 'openWidth' ) ); |
176 | 171 | return false; |
177 | 172 | }, |
178 | 173 | /** |
— | — | @@ -245,7 +240,7 @@ |
246 | 241 | .addClass( 'tab-toc' ) |
247 | 242 | .append( '<a href="#" />' ) |
248 | 243 | .bind( 'click.wikiEditor-toc', function() { |
249 | | - context.modules.$toc.trigger( 'collapse.wikiEditor-toc' ); return false; |
| 244 | + context.modules.toc.$toc.trigger( 'collapse.wikiEditor-toc' ); return false; |
250 | 245 | } ) |
251 | 246 | .find( 'a' ) |
252 | 247 | .text( gM( 'wikieditor-toc-hide' ) ); |
— | — | @@ -253,12 +248,12 @@ |
254 | 249 | .addClass( 'wikiEditor-ui-toc-expandControl' ) |
255 | 250 | .append( '<a href="#" />' ) |
256 | 251 | .bind( 'click.wikiEditor-toc', function() { |
257 | | - context.modules.$toc.trigger( 'expand.wikiEditor-toc' ); return false; |
| 252 | + context.modules.toc.$toc.trigger( 'expand.wikiEditor-toc' ); return false; |
258 | 253 | } ) |
259 | 254 | .hide() |
260 | 255 | .find( 'a' ) |
261 | 256 | .text( gM( 'wikieditor-toc-show' ) ); |
262 | | - $collapseControl.insertBefore( context.modules.$toc ); |
| 257 | + $collapseControl.insertBefore( context.modules.toc.$toc ); |
263 | 258 | context.$ui.find( '.wikiEditor-ui-left .wikiEditor-ui-top' ).append( $expandControl ); |
264 | 259 | } |
265 | 260 | /** |
— | — | @@ -294,9 +289,9 @@ |
295 | 290 | context.$ui.find( '.wikiEditor-ui-resize-mask' ).remove(); |
296 | 291 | context.$content.trigger( 'mouseup' ); |
297 | 292 | if( ui.size.width < parseFloat( $.wikiEditor.modules.toc.minimumWidth ) ) { |
298 | | - context.modules.$toc.trigger( 'collapse' ); |
| 293 | + context.modules.toc.$toc.trigger( 'collapse' ); |
299 | 294 | } else { |
300 | | - context.modules.$toc.data( 'openWidth', ui.size.width ); |
| 295 | + context.modules.toc.$toc.data( 'openWidth', ui.size.width ); |
301 | 296 | $.cookie( 'wikiEditor-' + context.instance + '-toc-width', ui.size.width ); |
302 | 297 | } |
303 | 298 | // Let the UI know things have moved around |
— | — | @@ -309,18 +304,18 @@ |
310 | 305 | .addClass( 'ui-resizable-w' ) |
311 | 306 | .addClass( 'wikiEditor-ui-toc-resize-grip' ); |
312 | 307 | // Bind collapse and expand event handlers to the TOC |
313 | | - context.modules.$toc |
| 308 | + context.modules.toc.$toc |
314 | 309 | .bind( 'collapse.wikiEditor-toc', $.wikiEditor.modules.toc.fn.collapse ) |
315 | 310 | .bind( 'expand.wikiEditor-toc', $.wikiEditor.modules.toc.fn.expand ); |
316 | | - context.modules.$toc.data( 'openWidth', $.wikiEditor.modules.toc.defaultWidth ); |
| 311 | + context.modules.toc.$toc.data( 'openWidth', $.wikiEditor.modules.toc.defaultWidth ); |
317 | 312 | // If the toc-width cookie is set, reset the widths based upon that |
318 | 313 | if ( $.cookie( 'wikiEditor-' + context.instance + '-toc-width' ) == 0 ) { |
319 | | - context.modules.$toc.trigger( 'collapse.wikiEditor-toc', { data: context } ); |
| 314 | + context.modules.toc.$toc.trigger( 'collapse.wikiEditor-toc', { data: context } ); |
320 | 315 | } else if ( $.cookie( 'wikiEditor-' + context.instance + '-toc-width' ) > 0 ) { |
321 | 316 | var initialWidth = $.cookie( 'wikiEditor-' + context.instance + '-toc-width' ); |
322 | 317 | if( initialWidth < parseFloat( $.wikiEditor.modules.toc.minimumWidth ) ) |
323 | 318 | initialWidth = parseFloat( $.wikiEditor.modules.toc.minimumWidth ) + 1; |
324 | | - context.modules.$toc.data( 'openWidth', initialWidth + 'px' ); |
| 319 | + context.modules.toc.$toc.data( 'openWidth', initialWidth + 'px' ); |
325 | 320 | context.$ui.find( '.wikiEditor-ui-right' ) |
326 | 321 | .css( 'width', initialWidth + 'px' ); |
327 | 322 | context.$ui.find( '.wikiEditor-ui-left' ) |
— | — | @@ -431,13 +426,13 @@ |
432 | 427 | structure.unshift( { 'text': wgPageName.replace(/_/g, ' '), 'level': 1, 'index': 0, |
433 | 428 | 'wrapper': context.$content } ); |
434 | 429 | } |
435 | | - context.modules.$toc.html( buildList( structure ) ); |
| 430 | + context.modules.toc.$toc.html( buildList( structure ) ); |
436 | 431 | |
437 | 432 | if ( wgNavigableTOCResizable && !context.$ui.data( 'resizableDone' ) ) { |
438 | 433 | buildResizeControls(); |
439 | 434 | buildCollapseControls(); |
440 | 435 | } |
441 | | - context.modules.$toc.find( 'div' ).autoEllipse( { 'position': 'right', 'tooltip': true } ); |
| 436 | + context.modules.toc.$toc.find( 'div' ).autoEllipse( { 'position': 'right', 'tooltip': true } ); |
442 | 437 | // Cache the outline for later use |
443 | 438 | context.data.outline = outline; |
444 | 439 | } |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -187,6 +187,9 @@ |
188 | 188 | 'fn' in $.wikiEditor.modules[module] && |
189 | 189 | call in $.wikiEditor.modules[module].fn |
190 | 190 | ) { |
| 191 | + // Add a place for the module to put it's own stuff |
| 192 | + context.modules[module] = {}; |
| 193 | + // Tell the module to create itself |
191 | 194 | $.wikiEditor.modules[module].fn[call]( context, data ); |
192 | 195 | } |
193 | 196 | } |
— | — | @@ -265,8 +268,13 @@ |
266 | 269 | return false; |
267 | 270 | } |
268 | 271 | } |
269 | | - for ( module in $.wikiEditor.modules ) { |
270 | | - if ( 'evt' in $.wikiEditor.modules[module] && name in $.wikiEditor.modules[module].evt ) { |
| 272 | + for ( module in context.modules ) { |
| 273 | + // Pass the event around to all modules activated on this context |
| 274 | + if ( |
| 275 | + module in $.wikiEditor.modules && |
| 276 | + 'evt' in $.wikiEditor.modules[module] && |
| 277 | + name in $.wikiEditor.modules[module].evt |
| 278 | + ) { |
271 | 279 | $.wikiEditor.modules[module].evt[name]( context, event ); |
272 | 280 | } |
273 | 281 | } |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js |
— | — | @@ -11,14 +11,14 @@ |
12 | 12 | for ( type in data ) { |
13 | 13 | switch ( type ) { |
14 | 14 | case 'sections': |
15 | | - var $sections = context.modules.$toolbar |
| 15 | + var $sections = context.modules.toolbar.$toolbar |
16 | 16 | .find( 'div.sections' ); |
17 | | - var $tabs = context.modules.$toolbar |
| 17 | + var $tabs = context.modules.toolbar.$toolbar |
18 | 18 | .find( 'div.tabs' ); |
19 | 19 | for ( section in data[type] ) { |
20 | 20 | if ( section == 'main' ) { |
21 | 21 | // Section |
22 | | - context.modules.$toolbar |
| 22 | + context.modules.toolbar.$toolbar |
23 | 23 | .prepend( |
24 | 24 | $.wikiEditor.modules.toolbar.fn.buildSection( |
25 | 25 | context, section, data[type][section] |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | if ( ! ( 'section' in data ) ) { |
47 | 47 | continue; |
48 | 48 | } |
49 | | - var $section = context.modules.$toolbar |
| 49 | + var $section = context.modules.toolbar.$toolbar |
50 | 50 | .find( 'div[rel=' + data.section + '].section' ); |
51 | 51 | for ( group in data[type] ) { |
52 | 52 | // Group |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | if ( ! ( 'section' in data && 'group' in data ) ) { |
59 | 59 | continue; |
60 | 60 | } |
61 | | - var $group = context.modules.$toolbar |
| 61 | + var $group = context.modules.toolbar.$toolbar |
62 | 62 | .find( 'div[rel=' + data.section + '].section ' + 'div[rel=' + data.group + '].group' ); |
63 | 63 | for ( tool in data[type] ) { |
64 | 64 | // Tool |
— | — | @@ -68,9 +68,9 @@ |
69 | 69 | if ( ! ( 'section' in data ) ) { |
70 | 70 | continue; |
71 | 71 | } |
72 | | - var $pages = context.modules.$toolbar |
| 72 | + var $pages = context.modules.toolbar.$toolbar |
73 | 73 | .find( 'div[rel=' + data.section + '].section .pages' ); |
74 | | - var $index = context.modules.$toolbar |
| 74 | + var $index = context.modules.toolbar.$toolbar |
75 | 75 | .find( 'div[rel=' + data.section + '].section .index' ); |
76 | 76 | for ( page in data[type] ) { |
77 | 77 | // Page |
— | — | @@ -86,7 +86,7 @@ |
87 | 87 | if ( ! ( 'section' in data && 'page' in data ) ) { |
88 | 88 | continue; |
89 | 89 | } |
90 | | - var $table = context.modules.$toolbar.find( |
| 90 | + var $table = context.modules.toolbar.$toolbar.find( |
91 | 91 | 'div[rel=' + data.section + '].section ' + 'div[rel=' + data.page + '].page table' |
92 | 92 | ); |
93 | 93 | for ( row in data[type] ) { |
— | — | @@ -98,7 +98,7 @@ |
99 | 99 | if ( ! ( 'section' in data && 'page' in data ) ) { |
100 | 100 | continue; |
101 | 101 | } |
102 | | - $characters = context.modules.$toolbar.find( |
| 102 | + $characters = context.modules.toolbar.$toolbar.find( |
103 | 103 | 'div[rel=' + data.section + '].section ' + 'div[rel=' + data.page + '].page div' |
104 | 104 | ); |
105 | 105 | var actions = $characters.data( 'actions' ); |
— | — | @@ -144,20 +144,20 @@ |
145 | 145 | target += ' table tr:not(:has(th)):eq(' + data.row + ')'; |
146 | 146 | } else { |
147 | 147 | // Just a page, remove the index too! |
148 | | - context.modules.$toolbar.find( index ).remove(); |
| 148 | + context.modules.toolbar.$toolbar.find( index ).remove(); |
149 | 149 | $.wikiEditor.modules.toolbar.fn.updateBookletSelection( |
150 | 150 | context, |
151 | 151 | null, |
152 | | - context.modules.$toolbar.find( target ), |
153 | | - context.modules.$toolbar.find( index ) |
| 152 | + context.modules.toolbar.$toolbar.find( target ), |
| 153 | + context.modules.toolbar.$toolbar.find( index ) |
154 | 154 | ); |
155 | 155 | } |
156 | 156 | } else { |
157 | 157 | // Just a section, remove the tab too! |
158 | | - context.modules.$toolbar.find( tab ).remove(); |
| 158 | + context.modules.toolbar.$toolbar.find( tab ).remove(); |
159 | 159 | } |
160 | 160 | js_log('target is: ' + target); |
161 | | - context.modules.$toolbar.find( target ).remove(); |
| 161 | + context.modules.toolbar.$toolbar.find( target ).remove(); |
162 | 162 | } |
163 | 163 | } |
164 | 164 | }, |
— | — | @@ -180,14 +180,14 @@ |
181 | 181 | * @param {Object} config Configuration object to create module from |
182 | 182 | */ |
183 | 183 | create : function( context, config ) { |
184 | | - if ( '$toolbar' in context.modules ) { |
| 184 | + if ( '$toolbar' in context.modules.toolbar ) { |
185 | 185 | return; |
186 | 186 | } |
187 | | - context.modules.$toolbar = $( '<div />' ) |
| 187 | + context.modules.toolbar.$toolbar = $( '<div />' ) |
188 | 188 | .addClass( 'wikiEditor-ui-toolbar' ) |
189 | 189 | .attr( 'id', 'wikiEditor-ui-toolbar' ); |
190 | 190 | $.wikiEditor.modules.toolbar.fn.build( context, config ); |
191 | | - context.$ui.find( '.wikiEditor-ui-top' ).append( context.modules.$toolbar ); |
| 191 | + context.$ui.find( '.wikiEditor-ui-top' ).append( context.modules.toolbar.$toolbar ); |
192 | 192 | }, |
193 | 193 | /** |
194 | 194 | * Performs an operation based on parameters |
— | — | @@ -484,8 +484,8 @@ |
485 | 485 | if ( show ) { |
486 | 486 | $section.fadeIn( 'fast' ); |
487 | 487 | dH = $section.outerHeight() - dH; |
488 | | - if ( context.modules.$toc ) { |
489 | | - context.modules.$toc.animate({'height': "+="+dH}, $section.outerHeight() * 2); |
| 488 | + if ( 'toc' in context.modules ) { |
| 489 | + context.modules.toc.$toc.animate({'height': "+="+dH}, $section.outerHeight() * 2); |
490 | 490 | } |
491 | 491 | $sections.animate( { 'height': $section.outerHeight() }, $section.outerHeight() * 2, function() { |
492 | 492 | $(this).css('overflow', 'visible').css('height', 'auto'); |
— | — | @@ -496,8 +496,8 @@ |
497 | 497 | .animate( { 'height': 0 }, $section.outerHeight() * 2, function() { |
498 | 498 | $(this).css('overflow', 'visible'); |
499 | 499 | } ); |
500 | | - if ( context.modules.$toc ) { |
501 | | - context.modules.$toc.animate({'height': "-="+$section.outerHeight()}, $section.outerHeight() * 2); |
| 500 | + if ( 'toc' in context.modules ) { |
| 501 | + context.modules.toc.$toc.animate({'height': "-="+$section.outerHeight()}, $section.outerHeight() * 2); |
502 | 502 | } |
503 | 503 | } |
504 | 504 | // Click tracking |
— | — | @@ -567,13 +567,13 @@ |
568 | 568 | $selectedIndex.addClass( 'current' ); |
569 | 569 | }, |
570 | 570 | build : function( context, config ) { |
571 | | - var $tabs = $( '<div />' ).addClass( 'tabs' ).appendTo( context.modules.$toolbar ); |
572 | | - var $sections = $( '<div />' ).addClass( 'sections' ).appendTo( context.modules.$toolbar ); |
573 | | - context.modules.$toolbar.append( $( '<div />' ).css( 'clear', 'both' ) ); |
| 571 | + var $tabs = $( '<div />' ).addClass( 'tabs' ).appendTo( context.modules.toolbar.$toolbar ); |
| 572 | + var $sections = $( '<div />' ).addClass( 'sections' ).appendTo( context.modules.toolbar.$toolbar ); |
| 573 | + context.modules.toolbar.$toolbar.append( $( '<div />' ).css( 'clear', 'both' ) ); |
574 | 574 | var sectionQueue = []; |
575 | 575 | for ( section in config ) { |
576 | 576 | if ( section == 'main' ) { |
577 | | - context.modules.$toolbar.prepend( |
| 577 | + context.modules.toolbar.$toolbar.prepend( |
578 | 578 | $.wikiEditor.modules.toolbar.fn.buildSection( context, section, config[section] ) |
579 | 579 | ); |
580 | 580 | } else { |
— | — | @@ -599,8 +599,8 @@ |
600 | 600 | var $section = s.$sections.find( '.section:visible' ); |
601 | 601 | if ( $section.size() ) { |
602 | 602 | $sections.animate( { 'height': $section.outerHeight() }, $section.outerHeight() * 2, function( ) { |
603 | | - if ( context.modules.$toc ) { |
604 | | - context.modules.$toc.height( |
| 603 | + if ( 'toc' in context.modules ) { |
| 604 | + context.modules.toc.$toc.height( |
605 | 605 | context.$ui.find( '.wikiEditor-ui-left' ) |
606 | 606 | .outerHeight() - context.$ui.find( '.tab-toc' ).outerHeight() |
607 | 607 | ) |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -1497,6 +1497,9 @@ |
1498 | 1498 | 'fn' in $.wikiEditor.modules[module] && |
1499 | 1499 | call in $.wikiEditor.modules[module].fn |
1500 | 1500 | ) { |
| 1501 | + // Add a place for the module to put it's own stuff |
| 1502 | + context.modules[module] = {}; |
| 1503 | + // Tell the module to create itself |
1501 | 1504 | $.wikiEditor.modules[module].fn[call]( context, data ); |
1502 | 1505 | } |
1503 | 1506 | } |
— | — | @@ -1575,8 +1578,13 @@ |
1576 | 1579 | return false; |
1577 | 1580 | } |
1578 | 1581 | } |
1579 | | - for ( module in $.wikiEditor.modules ) { |
1580 | | - if ( 'evt' in $.wikiEditor.modules[module] && name in $.wikiEditor.modules[module].evt ) { |
| 1582 | + for ( module in context.modules ) { |
| 1583 | + // Pass the event around to all modules activated on this context |
| 1584 | + if ( |
| 1585 | + module in $.wikiEditor.modules && |
| 1586 | + 'evt' in $.wikiEditor.modules[module] && |
| 1587 | + name in $.wikiEditor.modules[module].evt |
| 1588 | + ) { |
1581 | 1589 | $.wikiEditor.modules[module].evt[name]( context, event ); |
1582 | 1590 | } |
1583 | 1591 | } |
— | — | @@ -2181,14 +2189,15 @@ |
2182 | 2190 | * @param config Configuration object to create module from |
2183 | 2191 | */ |
2184 | 2192 | create: function( context, config ) { |
2185 | | - if ( 'preview' in context.modules ) { |
| 2193 | + if ( 'initialized' in context.modules.preview ) { |
2186 | 2194 | return; |
2187 | 2195 | } |
2188 | 2196 | context.modules.preview = { |
| 2197 | + 'initialized': true, |
2189 | 2198 | 'previewText': null, |
2190 | 2199 | 'changesText': null |
2191 | 2200 | }; |
2192 | | - context.$preview = context.fn.addView( { |
| 2201 | + context.modules.preview.$preview = context.fn.addView( { |
2193 | 2202 | 'name': 'preview', |
2194 | 2203 | 'titleMsg': 'wikieditor-preview-tab', |
2195 | 2204 | 'init': function( context ) { |
— | — | @@ -2198,8 +2207,8 @@ |
2199 | 2208 | if ( context.modules.preview.previewText == wikitext ) { |
2200 | 2209 | return; |
2201 | 2210 | } |
2202 | | - context.$preview.find( '.wikiEditor-preview-contents' ).empty(); |
2203 | | - context.$preview.find( '.wikiEditor-preview-loading' ).show(); |
| 2211 | + context.modules.preview.$preview.find( '.wikiEditor-preview-contents' ).empty(); |
| 2212 | + context.modules.preview.$preview.find( '.wikiEditor-preview-loading' ).show(); |
2204 | 2213 | $.post( |
2205 | 2214 | wgScriptPath + '/api.php', |
2206 | 2215 | { |
— | — | @@ -2219,8 +2228,8 @@ |
2220 | 2229 | return; |
2221 | 2230 | } |
2222 | 2231 | context.modules.preview.previewText = wikitext; |
2223 | | - context.$preview.find( '.wikiEditor-preview-loading' ).hide(); |
2224 | | - context.$preview.find( '.wikiEditor-preview-contents' ) |
| 2232 | + context.modules.preview.$preview.find( '.wikiEditor-preview-loading' ).hide(); |
| 2233 | + context.modules.preview.$preview.find( '.wikiEditor-preview-contents' ) |
2225 | 2234 | .html( data.parse.text['*'] ) |
2226 | 2235 | .find( 'a:not([href^=#])' ).click( function() { return false; } ); |
2227 | 2236 | }, |
— | — | @@ -2277,9 +2286,9 @@ |
2278 | 2287 | ); |
2279 | 2288 | } |
2280 | 2289 | } ); |
2281 | | - |
| 2290 | + |
2282 | 2291 | var loadingMsg = gM( 'wikieditor-preview-loading' ); |
2283 | | - context.$preview |
| 2292 | + context.modules.preview.$preview |
2284 | 2293 | .add( context.$changesTab ) |
2285 | 2294 | .append( $( '<div />' ) |
2286 | 2295 | .addClass( 'wikiEditor-preview-loading' ) |
— | — | @@ -2441,11 +2450,6 @@ |
2442 | 2451 | */ |
2443 | 2452 | evt: { |
2444 | 2453 | ready: function( context, event ) { |
2445 | | - // Only run this code if this module is turned on |
2446 | | - if ( !( '$toc' in context.modules ) ) { |
2447 | | - return; |
2448 | | - } |
2449 | | - |
2450 | 2454 | // Add the TOC to the document |
2451 | 2455 | $.wikiEditor.modules.toc.fn.build( context ); |
2452 | 2456 | context.$content.parent() |
— | — | @@ -2478,18 +2482,18 @@ |
2479 | 2483 | * @param {Object} config Configuration object to create module from |
2480 | 2484 | */ |
2481 | 2485 | create: function( context, config ) { |
2482 | | - if ( '$toc' in context.modules ) { |
| 2486 | + if ( '$toc' in context.modules.toc ) { |
2483 | 2487 | return; |
2484 | 2488 | } |
2485 | 2489 | |
2486 | 2490 | var height = context.$ui.find( '.wikiEditor-ui-left' ).height(); |
2487 | | - context.modules.$toc = $( '<div />' ) |
| 2491 | + context.modules.toc.$toc = $( '<div />' ) |
2488 | 2492 | .addClass( 'wikiEditor-ui-toc' ) |
2489 | 2493 | .data( 'context', context ); |
2490 | 2494 | context.$ui.find( '.wikiEditor-ui-right' ) |
2491 | 2495 | .css( 'width', $.wikiEditor.modules.toc.defaultWidth ) |
2492 | | - .append( context.modules.$toc ); |
2493 | | - context.modules.$toc.height( |
| 2496 | + .append( context.modules.toc.$toc ); |
| 2497 | + context.modules.toc.$toc.height( |
2494 | 2498 | context.$ui.find( '.wikiEditor-ui-left' ).height() |
2495 | 2499 | ); |
2496 | 2500 | context.$ui.find( '.wikiEditor-ui-left' ) |
— | — | @@ -2499,7 +2503,7 @@ |
2500 | 2504 | }, |
2501 | 2505 | |
2502 | 2506 | unhighlight: function( context ) { |
2503 | | - context.modules.$toc.find( 'div' ).removeClass( 'current' ); |
| 2507 | + context.modules.toc.$toc.find( 'div' ).removeClass( 'current' ); |
2504 | 2508 | }, |
2505 | 2509 | /** |
2506 | 2510 | * Highlight the section the cursor is currently within |
— | — | @@ -2523,20 +2527,20 @@ |
2524 | 2528 | } |
2525 | 2529 | section = Math.max( 0, section ); |
2526 | 2530 | } |
2527 | | - var sectionLink = context.modules.$toc.find( 'div.section-' + section ); |
| 2531 | + var sectionLink = context.modules.toc.$toc.find( 'div.section-' + section ); |
2528 | 2532 | sectionLink.addClass( 'current' ); |
2529 | 2533 | |
2530 | 2534 | // Scroll the highlighted link into view if necessary |
2531 | | - var relTop = sectionLink.offset().top - context.modules.$toc.offset().top; |
2532 | | - var scrollTop = context.modules.$toc.scrollTop(); |
2533 | | - var divHeight = context.modules.$toc.height(); |
| 2535 | + var relTop = sectionLink.offset().top - context.modules.toc.$toc.offset().top; |
| 2536 | + var scrollTop = context.modules.toc.$toc.scrollTop(); |
| 2537 | + var divHeight = context.modules.toc.$toc.height(); |
2534 | 2538 | var sectionHeight = sectionLink.height(); |
2535 | 2539 | if ( relTop < 0 ) |
2536 | 2540 | // Scroll up |
2537 | | - context.modules.$toc.scrollTop( scrollTop + relTop ); |
| 2541 | + context.modules.toc.$toc.scrollTop( scrollTop + relTop ); |
2538 | 2542 | else if ( relTop + sectionHeight > divHeight ) |
2539 | 2543 | // Scroll down |
2540 | | - context.modules.$toc.scrollTop( scrollTop + relTop + sectionHeight - divHeight ); |
| 2544 | + context.modules.toc.$toc.scrollTop( scrollTop + relTop + sectionHeight - divHeight ); |
2541 | 2545 | } |
2542 | 2546 | }, |
2543 | 2547 | |
— | — | @@ -2575,7 +2579,7 @@ |
2576 | 2580 | expand: function( event ) { |
2577 | 2581 | var $this = $( this ), |
2578 | 2582 | context = $this.data( 'context' ), |
2579 | | - openWidth = context.modules.$toc.data( 'openWidth' ); |
| 2583 | + openWidth = context.modules.toc.$toc.data( 'openWidth' ); |
2580 | 2584 | context.$ui.find( '.wikiEditor-ui-toc-expandControl' ).hide(); |
2581 | 2585 | $this.parent() |
2582 | 2586 | .show() |
— | — | @@ -2591,7 +2595,7 @@ |
2592 | 2596 | .children() |
2593 | 2597 | .animate( { 'marginRight': openWidth }, 'fast' ); |
2594 | 2598 | $.cookie( 'wikiEditor-' + context.instance + '-toc-width', |
2595 | | - context.modules.$toc.data( 'openWidth' ) ); |
| 2599 | + context.modules.toc.$toc.data( 'openWidth' ) ); |
2596 | 2600 | return false; |
2597 | 2601 | }, |
2598 | 2602 | /** |
— | — | @@ -2665,7 +2669,7 @@ |
2666 | 2670 | .addClass( 'tab-toc' ) |
2667 | 2671 | .append( '<a href="#" />' ) |
2668 | 2672 | .bind( 'click.wikiEditor-toc', function() { |
2669 | | - context.modules.$toc.trigger( 'collapse.wikiEditor-toc' ); return false; |
| 2673 | + context.modules.toc.$toc.trigger( 'collapse.wikiEditor-toc' ); return false; |
2670 | 2674 | } ) |
2671 | 2675 | .find( 'a' ) |
2672 | 2676 | .text( gM( 'wikieditor-toc-hide' ) ); |
— | — | @@ -2673,12 +2677,12 @@ |
2674 | 2678 | .addClass( 'wikiEditor-ui-toc-expandControl' ) |
2675 | 2679 | .append( '<a href="#" />' ) |
2676 | 2680 | .bind( 'click.wikiEditor-toc', function() { |
2677 | | - context.modules.$toc.trigger( 'expand.wikiEditor-toc' ); return false; |
| 2681 | + context.modules.toc.$toc.trigger( 'expand.wikiEditor-toc' ); return false; |
2678 | 2682 | } ) |
2679 | 2683 | .hide() |
2680 | 2684 | .find( 'a' ) |
2681 | 2685 | .text( gM( 'wikieditor-toc-show' ) ); |
2682 | | - $collapseControl.insertBefore( context.modules.$toc ); |
| 2686 | + $collapseControl.insertBefore( context.modules.toc.$toc ); |
2683 | 2687 | context.$ui.find( '.wikiEditor-ui-left .wikiEditor-ui-top' ).append( $expandControl ); |
2684 | 2688 | } |
2685 | 2689 | /** |
— | — | @@ -2714,9 +2718,9 @@ |
2715 | 2719 | context.$ui.find( '.wikiEditor-ui-resize-mask' ).remove(); |
2716 | 2720 | context.$content.trigger( 'mouseup' ); |
2717 | 2721 | if( ui.size.width < parseFloat( $.wikiEditor.modules.toc.minimumWidth ) ) { |
2718 | | - context.modules.$toc.trigger( 'collapse' ); |
| 2722 | + context.modules.toc.$toc.trigger( 'collapse' ); |
2719 | 2723 | } else { |
2720 | | - context.modules.$toc.data( 'openWidth', ui.size.width ); |
| 2724 | + context.modules.toc.$toc.data( 'openWidth', ui.size.width ); |
2721 | 2725 | $.cookie( 'wikiEditor-' + context.instance + '-toc-width', ui.size.width ); |
2722 | 2726 | } |
2723 | 2727 | // Let the UI know things have moved around |
— | — | @@ -2729,18 +2733,18 @@ |
2730 | 2734 | .addClass( 'ui-resizable-w' ) |
2731 | 2735 | .addClass( 'wikiEditor-ui-toc-resize-grip' ); |
2732 | 2736 | // Bind collapse and expand event handlers to the TOC |
2733 | | - context.modules.$toc |
| 2737 | + context.modules.toc.$toc |
2734 | 2738 | .bind( 'collapse.wikiEditor-toc', $.wikiEditor.modules.toc.fn.collapse ) |
2735 | 2739 | .bind( 'expand.wikiEditor-toc', $.wikiEditor.modules.toc.fn.expand ); |
2736 | | - context.modules.$toc.data( 'openWidth', $.wikiEditor.modules.toc.defaultWidth ); |
| 2740 | + context.modules.toc.$toc.data( 'openWidth', $.wikiEditor.modules.toc.defaultWidth ); |
2737 | 2741 | // If the toc-width cookie is set, reset the widths based upon that |
2738 | 2742 | if ( $.cookie( 'wikiEditor-' + context.instance + '-toc-width' ) == 0 ) { |
2739 | | - context.modules.$toc.trigger( 'collapse.wikiEditor-toc', { data: context } ); |
| 2743 | + context.modules.toc.$toc.trigger( 'collapse.wikiEditor-toc', { data: context } ); |
2740 | 2744 | } else if ( $.cookie( 'wikiEditor-' + context.instance + '-toc-width' ) > 0 ) { |
2741 | 2745 | var initialWidth = $.cookie( 'wikiEditor-' + context.instance + '-toc-width' ); |
2742 | 2746 | if( initialWidth < parseFloat( $.wikiEditor.modules.toc.minimumWidth ) ) |
2743 | 2747 | initialWidth = parseFloat( $.wikiEditor.modules.toc.minimumWidth ) + 1; |
2744 | | - context.modules.$toc.data( 'openWidth', initialWidth + 'px' ); |
| 2748 | + context.modules.toc.$toc.data( 'openWidth', initialWidth + 'px' ); |
2745 | 2749 | context.$ui.find( '.wikiEditor-ui-right' ) |
2746 | 2750 | .css( 'width', initialWidth + 'px' ); |
2747 | 2751 | context.$ui.find( '.wikiEditor-ui-left' ) |
— | — | @@ -2851,13 +2855,13 @@ |
2852 | 2856 | structure.unshift( { 'text': wgPageName.replace(/_/g, ' '), 'level': 1, 'index': 0, |
2853 | 2857 | 'wrapper': context.$content } ); |
2854 | 2858 | } |
2855 | | - context.modules.$toc.html( buildList( structure ) ); |
| 2859 | + context.modules.toc.$toc.html( buildList( structure ) ); |
2856 | 2860 | |
2857 | 2861 | if ( wgNavigableTOCResizable && !context.$ui.data( 'resizableDone' ) ) { |
2858 | 2862 | buildResizeControls(); |
2859 | 2863 | buildCollapseControls(); |
2860 | 2864 | } |
2861 | | - context.modules.$toc.find( 'div' ).autoEllipse( { 'position': 'right', 'tooltip': true } ); |
| 2865 | + context.modules.toc.$toc.find( 'div' ).autoEllipse( { 'position': 'right', 'tooltip': true } ); |
2862 | 2866 | // Cache the outline for later use |
2863 | 2867 | context.data.outline = outline; |
2864 | 2868 | } |
— | — | @@ -2888,14 +2892,14 @@ |
2889 | 2893 | for ( type in data ) { |
2890 | 2894 | switch ( type ) { |
2891 | 2895 | case 'sections': |
2892 | | - var $sections = context.modules.$toolbar |
| 2896 | + var $sections = context.modules.toolbar.$toolbar |
2893 | 2897 | .find( 'div.sections' ); |
2894 | | - var $tabs = context.modules.$toolbar |
| 2898 | + var $tabs = context.modules.toolbar.$toolbar |
2895 | 2899 | .find( 'div.tabs' ); |
2896 | 2900 | for ( section in data[type] ) { |
2897 | 2901 | if ( section == 'main' ) { |
2898 | 2902 | // Section |
2899 | | - context.modules.$toolbar |
| 2903 | + context.modules.toolbar.$toolbar |
2900 | 2904 | .prepend( |
2901 | 2905 | $.wikiEditor.modules.toolbar.fn.buildSection( |
2902 | 2906 | context, section, data[type][section] |
— | — | @@ -2922,7 +2926,7 @@ |
2923 | 2927 | if ( ! ( 'section' in data ) ) { |
2924 | 2928 | continue; |
2925 | 2929 | } |
2926 | | - var $section = context.modules.$toolbar |
| 2930 | + var $section = context.modules.toolbar.$toolbar |
2927 | 2931 | .find( 'div[rel=' + data.section + '].section' ); |
2928 | 2932 | for ( group in data[type] ) { |
2929 | 2933 | // Group |
— | — | @@ -2934,7 +2938,7 @@ |
2935 | 2939 | if ( ! ( 'section' in data && 'group' in data ) ) { |
2936 | 2940 | continue; |
2937 | 2941 | } |
2938 | | - var $group = context.modules.$toolbar |
| 2942 | + var $group = context.modules.toolbar.$toolbar |
2939 | 2943 | .find( 'div[rel=' + data.section + '].section ' + 'div[rel=' + data.group + '].group' ); |
2940 | 2944 | for ( tool in data[type] ) { |
2941 | 2945 | // Tool |
— | — | @@ -2945,9 +2949,9 @@ |
2946 | 2950 | if ( ! ( 'section' in data ) ) { |
2947 | 2951 | continue; |
2948 | 2952 | } |
2949 | | - var $pages = context.modules.$toolbar |
| 2953 | + var $pages = context.modules.toolbar.$toolbar |
2950 | 2954 | .find( 'div[rel=' + data.section + '].section .pages' ); |
2951 | | - var $index = context.modules.$toolbar |
| 2955 | + var $index = context.modules.toolbar.$toolbar |
2952 | 2956 | .find( 'div[rel=' + data.section + '].section .index' ); |
2953 | 2957 | for ( page in data[type] ) { |
2954 | 2958 | // Page |
— | — | @@ -2963,7 +2967,7 @@ |
2964 | 2968 | if ( ! ( 'section' in data && 'page' in data ) ) { |
2965 | 2969 | continue; |
2966 | 2970 | } |
2967 | | - var $table = context.modules.$toolbar.find( |
| 2971 | + var $table = context.modules.toolbar.$toolbar.find( |
2968 | 2972 | 'div[rel=' + data.section + '].section ' + 'div[rel=' + data.page + '].page table' |
2969 | 2973 | ); |
2970 | 2974 | for ( row in data[type] ) { |
— | — | @@ -2975,7 +2979,7 @@ |
2976 | 2980 | if ( ! ( 'section' in data && 'page' in data ) ) { |
2977 | 2981 | continue; |
2978 | 2982 | } |
2979 | | - $characters = context.modules.$toolbar.find( |
| 2983 | + $characters = context.modules.toolbar.$toolbar.find( |
2980 | 2984 | 'div[rel=' + data.section + '].section ' + 'div[rel=' + data.page + '].page div' |
2981 | 2985 | ); |
2982 | 2986 | var actions = $characters.data( 'actions' ); |
— | — | @@ -3021,20 +3025,20 @@ |
3022 | 3026 | target += ' table tr:not(:has(th)):eq(' + data.row + ')'; |
3023 | 3027 | } else { |
3024 | 3028 | // Just a page, remove the index too! |
3025 | | - context.modules.$toolbar.find( index ).remove(); |
| 3029 | + context.modules.toolbar.$toolbar.find( index ).remove(); |
3026 | 3030 | $.wikiEditor.modules.toolbar.fn.updateBookletSelection( |
3027 | 3031 | context, |
3028 | 3032 | null, |
3029 | | - context.modules.$toolbar.find( target ), |
3030 | | - context.modules.$toolbar.find( index ) |
| 3033 | + context.modules.toolbar.$toolbar.find( target ), |
| 3034 | + context.modules.toolbar.$toolbar.find( index ) |
3031 | 3035 | ); |
3032 | 3036 | } |
3033 | 3037 | } else { |
3034 | 3038 | // Just a section, remove the tab too! |
3035 | | - context.modules.$toolbar.find( tab ).remove(); |
| 3039 | + context.modules.toolbar.$toolbar.find( tab ).remove(); |
3036 | 3040 | } |
3037 | 3041 | js_log('target is: ' + target); |
3038 | | - context.modules.$toolbar.find( target ).remove(); |
| 3042 | + context.modules.toolbar.$toolbar.find( target ).remove(); |
3039 | 3043 | } |
3040 | 3044 | } |
3041 | 3045 | }, |
— | — | @@ -3057,14 +3061,14 @@ |
3058 | 3062 | * @param {Object} config Configuration object to create module from |
3059 | 3063 | */ |
3060 | 3064 | create : function( context, config ) { |
3061 | | - if ( '$toolbar' in context.modules ) { |
| 3065 | + if ( '$toolbar' in context.modules.toolbar ) { |
3062 | 3066 | return; |
3063 | 3067 | } |
3064 | | - context.modules.$toolbar = $( '<div />' ) |
| 3068 | + context.modules.toolbar.$toolbar = $( '<div />' ) |
3065 | 3069 | .addClass( 'wikiEditor-ui-toolbar' ) |
3066 | 3070 | .attr( 'id', 'wikiEditor-ui-toolbar' ); |
3067 | 3071 | $.wikiEditor.modules.toolbar.fn.build( context, config ); |
3068 | | - context.$ui.find( '.wikiEditor-ui-top' ).append( context.modules.$toolbar ); |
| 3072 | + context.$ui.find( '.wikiEditor-ui-top' ).append( context.modules.toolbar.$toolbar ); |
3069 | 3073 | }, |
3070 | 3074 | /** |
3071 | 3075 | * Performs an operation based on parameters |
— | — | @@ -3361,8 +3365,8 @@ |
3362 | 3366 | if ( show ) { |
3363 | 3367 | $section.fadeIn( 'fast' ); |
3364 | 3368 | dH = $section.outerHeight() - dH; |
3365 | | - if ( context.modules.$toc ) { |
3366 | | - context.modules.$toc.animate({'height': "+="+dH}, $section.outerHeight() * 2); |
| 3369 | + if ( 'toc' in context.modules ) { |
| 3370 | + context.modules.toc.$toc.animate({'height': "+="+dH}, $section.outerHeight() * 2); |
3367 | 3371 | } |
3368 | 3372 | $sections.animate( { 'height': $section.outerHeight() }, $section.outerHeight() * 2, function() { |
3369 | 3373 | $(this).css('overflow', 'visible').css('height', 'auto'); |
— | — | @@ -3373,8 +3377,8 @@ |
3374 | 3378 | .animate( { 'height': 0 }, $section.outerHeight() * 2, function() { |
3375 | 3379 | $(this).css('overflow', 'visible'); |
3376 | 3380 | } ); |
3377 | | - if ( context.modules.$toc ) { |
3378 | | - context.modules.$toc.animate({'height': "-="+$section.outerHeight()}, $section.outerHeight() * 2); |
| 3381 | + if ( 'toc' in context.modules ) { |
| 3382 | + context.modules.toc.$toc.animate({'height': "-="+$section.outerHeight()}, $section.outerHeight() * 2); |
3379 | 3383 | } |
3380 | 3384 | } |
3381 | 3385 | // Click tracking |
— | — | @@ -3444,13 +3448,13 @@ |
3445 | 3449 | $selectedIndex.addClass( 'current' ); |
3446 | 3450 | }, |
3447 | 3451 | build : function( context, config ) { |
3448 | | - var $tabs = $( '<div />' ).addClass( 'tabs' ).appendTo( context.modules.$toolbar ); |
3449 | | - var $sections = $( '<div />' ).addClass( 'sections' ).appendTo( context.modules.$toolbar ); |
3450 | | - context.modules.$toolbar.append( $( '<div />' ).css( 'clear', 'both' ) ); |
| 3452 | + var $tabs = $( '<div />' ).addClass( 'tabs' ).appendTo( context.modules.toolbar.$toolbar ); |
| 3453 | + var $sections = $( '<div />' ).addClass( 'sections' ).appendTo( context.modules.toolbar.$toolbar ); |
| 3454 | + context.modules.toolbar.$toolbar.append( $( '<div />' ).css( 'clear', 'both' ) ); |
3451 | 3455 | var sectionQueue = []; |
3452 | 3456 | for ( section in config ) { |
3453 | 3457 | if ( section == 'main' ) { |
3454 | | - context.modules.$toolbar.prepend( |
| 3458 | + context.modules.toolbar.$toolbar.prepend( |
3455 | 3459 | $.wikiEditor.modules.toolbar.fn.buildSection( context, section, config[section] ) |
3456 | 3460 | ); |
3457 | 3461 | } else { |
— | — | @@ -3476,8 +3480,8 @@ |
3477 | 3481 | var $section = s.$sections.find( '.section:visible' ); |
3478 | 3482 | if ( $section.size() ) { |
3479 | 3483 | $sections.animate( { 'height': $section.outerHeight() }, $section.outerHeight() * 2, function( ) { |
3480 | | - if ( context.modules.$toc ) { |
3481 | | - context.modules.$toc.height( |
| 3484 | + if ( 'toc' in context.modules ) { |
| 3485 | + context.modules.toc.$toc.height( |
3482 | 3486 | context.$ui.find( '.wikiEditor-ui-left' ) |
3483 | 3487 | .outerHeight() - context.$ui.find( '.tab-toc' ).outerHeight() |
3484 | 3488 | ) |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -88,7 +88,7 @@ |
89 | 89 | return $.wikiEditor.supported=true;},'autoMsg':function(object,property){if(typeof property=='object'){for(i in property){if(property[i]in object||property[i]+'Msg'in object){property=property[i];break;}}} |
90 | 90 | if(property in object){return object[property];}else if(property+'Msg'in object){return gM(object[property+'Msg']);}else{return'';}},'getIcon':function(icon,path,lang){lang=lang||wgUserLanguage;path=path||$.wikiEditor.imgPath;var src=icon[lang]||icon['default']||icon;if(src.substr(0,7)!='http://'&&src.substr(0,8)!='https://'&&src[0]!='/') |
91 | 91 | src=path+src;return src+'?'+wgWikiEditorIconVersion;},'fixOperaBrokenness':function(s){return s;}};$.fn.wikiEditor=function(){if($j.wikiEditor.isSupportKnown()&&!$j.wikiEditor.isSupported()){return $(this);} |
92 | | -var context=$(this).data('wikiEditor-context');if(typeof context=='undefined'){var instance=$.wikiEditor.instances.length;context={'$textarea':$(this),'views':{},'modules':{},'data':{},'instance':instance};$.wikiEditor.instances[instance]=$(this);context.api={'addModule':function(context,data){function callModuleApi(module,call,data){if(module in $.wikiEditor.modules&&'fn'in $.wikiEditor.modules[module]&&call in $.wikiEditor.modules[module].fn){$.wikiEditor.modules[module].fn[call](context,data);}} |
| 92 | +var context=$(this).data('wikiEditor-context');if(typeof context=='undefined'){var instance=$.wikiEditor.instances.length;context={'$textarea':$(this),'views':{},'modules':{},'data':{},'instance':instance};$.wikiEditor.instances[instance]=$(this);context.api={'addModule':function(context,data){function callModuleApi(module,call,data){if(module in $.wikiEditor.modules&&'fn'in $.wikiEditor.modules[module]&&call in $.wikiEditor.modules[module].fn){context.modules[module]={};$.wikiEditor.modules[module].fn[call](context,data);}} |
93 | 93 | if(typeof data=='string'){callModuleApi(data,'create',{});}else if(typeof data=='object'){for(module in data){if(typeof module=='string'){callModuleApi(module,'create',data[module]);}}}}};for(module in $.wikiEditor.modules){if('api'in $.wikiEditor.modules[module]){for(call in $.wikiEditor.modules[module].api){if(!(call in context.api)){context.api[call]=$.wikiEditor.modules[module].api[call];}}}} |
94 | 94 | context.evt={'change':function(event){switch(event.type){case'keypress':if(true){event.data.scope='division';}else{event.data.scope='character';} |
95 | 95 | break;case'mousedown':if(true){event.data.scope='division';}else{return false;} |
— | — | @@ -96,7 +96,7 @@ |
97 | 97 | return true;}};context.fn={'trigger':function(name,event){if(typeof event=='undefined'){event={'type':'custom'};} |
98 | 98 | if(typeof event.data=='undefined'){event.data={};} |
99 | 99 | if(name in context.evt){if(!context.evt[name](event)){return false;}} |
100 | | -for(module in $.wikiEditor.modules){if('evt'in $.wikiEditor.modules[module]&&name in $.wikiEditor.modules[module].evt){$.wikiEditor.modules[module].evt[name](context,event);}}},'addButton':function(options){context.$controls.show();context.$buttons.show();return $('<button />').text($.wikiEditor.autoMsg(options,'caption')).click(options.action).appendTo(context.$buttons);},'addView':function(options){function addTab(options){context.$controls.show();context.$tabs.show();return $('<div></div>').attr('rel','wikiEditor-ui-view-'+options.name).addClass(context.view==options.name?'current':null).append($('<a></a>').attr('href','#').click(function(event){context.$ui.find('.wikiEditor-ui-view').hide();context.$ui.find('.'+$(this).parent().attr('rel')).show();context.$tabs.find('div').removeClass('current');$(this).parent().addClass('current');$(this).blur();if('init'in options&&typeof options.init=='function'){options.init(context);} |
| 100 | +for(module in context.modules){if(module in $.wikiEditor.modules&&'evt'in $.wikiEditor.modules[module]&&name in $.wikiEditor.modules[module].evt){$.wikiEditor.modules[module].evt[name](context,event);}}},'addButton':function(options){context.$controls.show();context.$buttons.show();return $('<button />').text($.wikiEditor.autoMsg(options,'caption')).click(options.action).appendTo(context.$buttons);},'addView':function(options){function addTab(options){context.$controls.show();context.$tabs.show();return $('<div></div>').attr('rel','wikiEditor-ui-view-'+options.name).addClass(context.view==options.name?'current':null).append($('<a></a>').attr('href','#').click(function(event){context.$ui.find('.wikiEditor-ui-view').hide();context.$ui.find('.'+$(this).parent().attr('rel')).show();context.$tabs.find('div').removeClass('current');$(this).parent().addClass('current');$(this).blur();if('init'in options&&typeof options.init=='function'){options.init(context);} |
101 | 101 | event.preventDefault();return false;}).text($.wikiEditor.autoMsg(options,'title'))).appendTo(context.$tabs);} |
102 | 102 | if(!context.$tabs.children().size()){addTab({'name':'wikitext','titleMsg':'wikieditor-wikitext-tab'});} |
103 | 103 | addTab(options);return $('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-'+options.name).hide().appendTo(context.$ui);},'setup':function(){context.$iframe[0].contentWindow.document.designMode='on';context.$content=$(context.$iframe[0].contentWindow.document.body);context.$content.append($('<div />').text(context.$textarea.val()).html());if($('body').is('.rtl')){context.$content.addClass('rtl').attr('dir','rtl');} |
— | — | @@ -123,13 +123,13 @@ |
124 | 124 | dialogDiv.bind('dialogopen',$.wikiEditor.modules.dialogs.fn.resize).find('.ui-tabs').bind('tabsshow',function(){$(this).closest('.ui-dialog-content').each($.wikiEditor.modules.dialogs.fn.resize);});var maxTI=0;$j('[tabindex]').each(function(){var ti=parseInt($j(this).attr('tabindex'));if(ti>maxTI) |
125 | 125 | maxTI=ti;});var tabIndex=maxTI+1;$j('.ui-dialog input, .ui-dialog button').not('[tabindex]').each(function(){$j(this).attr('tabindex',tabIndex++);});}}});},resize:function(){var wrapper=$(this).closest('.ui-dialog');var oldWidth=wrapper.width();var oldHidden=$(this).find('*').not(':visible');oldHidden.each(function(){$(this).data('oldstyle',$(this).attr('style'));});oldHidden.show();var oldWS=$(this).css('white-space');$(this).css('white-space','nowrap');if(wrapper.width()<=$(this).get(0).scrollWidth){var thisWidth=$(this).data('thisWidth')?$(this).data('thisWidth'):0;thisWidth=Math.max($(this).get(0).scrollWidth,thisWidth);$(this).width(thisWidth);$(this).data('thisWidth',thisWidth);var wrapperWidth=$(this).data('wrapperWidth')?$(this).data('wrapperWidth'):0;wrapperWidth=Math.max(wrapper.get(0).scrollWidth,wrapperWidth);wrapper.width(wrapperWidth);$(this).data('wrapperWidth',wrapperWidth);$(this).dialog({'width':wrapper.width()});wrapper.css('left',parseInt(wrapper.css('left'))- |
126 | 126 | (wrapper.width()-oldWidth)/2);} |
127 | | -$(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={api:{},evt:{change:function(event){}},fn:{create:function(context,config){},divide:function(context){},isolate:function(context){return[];},strip:function(context,division){return $('<div />').html(division.html().replace(/\<br[^\>]*\>/g,"\n")).text();},scan:function(context,division){return[];},mark:function(context,division,tokens){}}};})(jQuery);(function($){$.wikiEditor.modules.preview={api:{},fn:{create:function(context,config){if('preview'in context.modules){return;} |
128 | | -context.modules.preview={'previewText':null,'changesText':null};context.$preview=context.fn.addView({'name':'preview','titleMsg':'wikieditor-preview-tab','init':function(context){var wikitext=context.fn.getContents();if(context.modules.preview.previewText==wikitext){return;} |
129 | | -context.$preview.find('.wikiEditor-preview-contents').empty();context.$preview.find('.wikiEditor-preview-loading').show();$.post(wgScriptPath+'/api.php',{'action':'parse','title':wgPageName,'text':wikitext,'prop':'text','pst':'','format':'json'},function(data){if(typeof data.parse=='undefined'||typeof data.parse.text=='undefined'||typeof data.parse.text['*']=='undefined'){return;} |
130 | | -context.modules.preview.previewText=wikitext;context.$preview.find('.wikiEditor-preview-loading').hide();context.$preview.find('.wikiEditor-preview-contents').html(data.parse.text['*']).find('a:not([href^=#])').click(function(){return false;});},'json');}});context.$changesTab=context.fn.addView({'name':'changes','titleMsg':'wikieditor-preview-changes-tab','init':function(context){var wikitext=context.fn.getContents();if(context.modules.preview.changesText==wikitext){return;} |
| 127 | +$(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={api:{},evt:{change:function(event){}},fn:{create:function(context,config){},divide:function(context){},isolate:function(context){return[];},strip:function(context,division){return $('<div />').html(division.html().replace(/\<br[^\>]*\>/g,"\n")).text();},scan:function(context,division){return[];},mark:function(context,division,tokens){}}};})(jQuery);(function($){$.wikiEditor.modules.preview={api:{},fn:{create:function(context,config){if('initialized'in context.modules.preview){return;} |
| 128 | +context.modules.preview={'initialized':true,'previewText':null,'changesText':null};context.modules.preview.$preview=context.fn.addView({'name':'preview','titleMsg':'wikieditor-preview-tab','init':function(context){var wikitext=context.fn.getContents();if(context.modules.preview.previewText==wikitext){return;} |
| 129 | +context.modules.preview.$preview.find('.wikiEditor-preview-contents').empty();context.modules.preview.$preview.find('.wikiEditor-preview-loading').show();$.post(wgScriptPath+'/api.php',{'action':'parse','title':wgPageName,'text':wikitext,'prop':'text','pst':'','format':'json'},function(data){if(typeof data.parse=='undefined'||typeof data.parse.text=='undefined'||typeof data.parse.text['*']=='undefined'){return;} |
| 130 | +context.modules.preview.previewText=wikitext;context.modules.preview.$preview.find('.wikiEditor-preview-loading').hide();context.modules.preview.$preview.find('.wikiEditor-preview-contents').html(data.parse.text['*']).find('a:not([href^=#])').click(function(){return false;});},'json');}});context.$changesTab=context.fn.addView({'name':'changes','titleMsg':'wikieditor-preview-changes-tab','init':function(context){var wikitext=context.fn.getContents();if(context.modules.preview.changesText==wikitext){return;} |
131 | 131 | context.$changesTab.find('table.diff tbody').empty();context.$changesTab.find('.wikiEditor-preview-loading').show();var postdata={'action':'query','indexpageids':'','prop':'revisions','titles':wgPageName,'rvdifftotext':wikitext,'rvprop':'','format':'json'};var section=$('[name=wpSection]').val();if(section!='') |
132 | 132 | postdata['rvsection']=section;$.post(wgScriptPath+'/api.php',postdata,function(data){if($('link[href='+stylepath+'/common/diff.css]').size()==0){$('head').append($('<link />').attr({'rel':'stylesheet','type':'text/css','href':stylepath+'/common/diff.css'}));} |
133 | | -try{var diff=data.query.pages[data.query.pageids[0]].revisions[0].diff['*'];context.$changesTab.find('table.diff tbody').html(diff);context.$changesTab.find('.wikiEditor-preview-loading').hide();context.modules.preview.changesText=wikitext;}catch(e){}},'json');}});var loadingMsg=gM('wikieditor-preview-loading');context.$preview.add(context.$changesTab).append($('<div />').addClass('wikiEditor-preview-loading').append($('<img />').addClass('wikiEditor-preview-spinner').attr({'src':$.wikiEditor.imgPath+'dialogs/loading.gif','valign':'absmiddle','alt':loadingMsg,'title':loadingMsg})).append($('<span></span>').text(loadingMsg))).append($('<div />').addClass('wikiEditor-preview-contents'));context.$changesTab.find('.wikiEditor-preview-contents').html('<table class="diff"><col class="diff-marker" /><col class="diff-content" />'+'<col class="diff-marker" /><col class="diff-content" /><tbody /></table>');}}};})(jQuery);(function($){$.wikiEditor.modules.publish={api:{},fn:{create:function(context,config){var dialogID='wikiEditor-'+context.instance+'-dialog';$.wikiEditor.modules.dialogs.fn.create(context,{previewsave:{id:dialogID,titleMsg:'wikieditor-publish-dialog-title',html:'\ |
| 133 | +try{var diff=data.query.pages[data.query.pageids[0]].revisions[0].diff['*'];context.$changesTab.find('table.diff tbody').html(diff);context.$changesTab.find('.wikiEditor-preview-loading').hide();context.modules.preview.changesText=wikitext;}catch(e){}},'json');}});var loadingMsg=gM('wikieditor-preview-loading');context.modules.preview.$preview.add(context.$changesTab).append($('<div />').addClass('wikiEditor-preview-loading').append($('<img />').addClass('wikiEditor-preview-spinner').attr({'src':$.wikiEditor.imgPath+'dialogs/loading.gif','valign':'absmiddle','alt':loadingMsg,'title':loadingMsg})).append($('<span></span>').text(loadingMsg))).append($('<div />').addClass('wikiEditor-preview-contents'));context.$changesTab.find('.wikiEditor-preview-contents').html('<table class="diff"><col class="diff-marker" /><col class="diff-content" />'+'<col class="diff-marker" /><col class="diff-content" /><tbody /></table>');}}};})(jQuery);(function($){$.wikiEditor.modules.publish={api:{},fn:{create:function(context,config){var dialogID='wikiEditor-'+context.instance+'-dialog';$.wikiEditor.modules.dialogs.fn.create(context,{previewsave:{id:dialogID,titleMsg:'wikieditor-publish-dialog-title',html:'\ |
134 | 134 | <div class="wikiEditor-dialog-copywarn"></div>\ |
135 | 135 | <div class="wikiEditor-dialog-editoptions">\ |
136 | 136 | <form>\ |
— | — | @@ -153,13 +153,12 @@ |
154 | 154 | $('#wikiEditor-'+context.instance+'-dialog-minor').hide();else if($('#wpMinoredit').is(':checked')) |
155 | 155 | $('#wikiEditor-'+context.instance+'-dialog-minor').attr('checked','checked');if($('#wpWatchthis').size()==0) |
156 | 156 | $('#wikiEditor-'+context.instance+'-dialog-watch').hide();else if($('#wpWatchthis').is(':checked')) |
157 | | -$('#wikiEditor-'+context.instance+'-dialog-watch').attr('checked','checked');$(this).find('form').submit(function(e){$(this).closest('.ui-dialog').find('button:first').click();e.preventDefault();});},dialog:{buttons:{'wikieditor-publish-dialog-publish':function(){var minorChecked=$('#wikiEditor-'+context.instance+'-dialog-minor').is(':checked')?'checked':'';var watchChecked=$('#wikiEditor-'+context.instance+'-dialog-watch').is(':checked')?'checked':'';$('#wpMinoredit').attr('checked',minorChecked);$('#wpWatchthis').attr('checked',watchChecked);$('#wpSummary').val($j('#wikiEditor-'+context.instance+'-dialog-summary').val());$('#editform').submit();},'wikieditor-publish-dialog-goback':function(){$(this).dialog('close');}},open:function(){$('#wikiEditor-'+context.instance+'-dialog-summary').focus();},width:500},resizeme:false}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-publish','action':function(){$('#'+dialogID).dialog('open');return false;}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-cancel','action':function(){}});}}};})(jQuery);(function($){$.wikiEditor.modules.toc={defaultWidth:'166px',minimumWidth:'70px',api:{},evt:{ready:function(context,event){if(!('$toc'in context.modules)){return;} |
158 | | -$.wikiEditor.modules.toc.fn.build(context);context.$content.parent().delayedBind(250,'mouseup scrollToTop keyup change',function(){$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(event){var context=event.data.context;context.$textarea.delayedBindCancel(250,'mouseup scrollToTop keyup change');$.wikiEditor.modules.toc.fn.unhighlight(context);});}},fn:{create:function(context,config){if('$toc'in context.modules){return;} |
159 | | -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);},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++;} |
| 157 | +$('#wikiEditor-'+context.instance+'-dialog-watch').attr('checked','checked');$(this).find('form').submit(function(e){$(this).closest('.ui-dialog').find('button:first').click();e.preventDefault();});},dialog:{buttons:{'wikieditor-publish-dialog-publish':function(){var minorChecked=$('#wikiEditor-'+context.instance+'-dialog-minor').is(':checked')?'checked':'';var watchChecked=$('#wikiEditor-'+context.instance+'-dialog-watch').is(':checked')?'checked':'';$('#wpMinoredit').attr('checked',minorChecked);$('#wpWatchthis').attr('checked',watchChecked);$('#wpSummary').val($j('#wikiEditor-'+context.instance+'-dialog-summary').val());$('#editform').submit();},'wikieditor-publish-dialog-goback':function(){$(this).dialog('close');}},open:function(){$('#wikiEditor-'+context.instance+'-dialog-summary').focus();},width:500},resizeme:false}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-publish','action':function(){$('#'+dialogID).dialog('open');return false;}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-cancel','action':function(){}});}}};})(jQuery);(function($){$.wikiEditor.modules.toc={defaultWidth:'166px',minimumWidth:'70px',api:{},evt:{ready:function(context,event){$.wikiEditor.modules.toc.fn.build(context);context.$content.parent().delayedBind(250,'mouseup scrollToTop keyup change',function(){$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(event){var context=event.data.context;context.$textarea.delayedBindCancel(250,'mouseup scrollToTop keyup change');$.wikiEditor.modules.toc.fn.unhighlight(context);});}},fn:{create:function(context,config){if('$toc'in context.modules.toc){return;} |
| 158 | +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.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.defaultWidth).children().css('marginRight',$.wikiEditor.modules.toc.defaultWidth);},unhighlight:function(context){context.modules.toc.$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++;} |
160 | 159 | section=Math.max(0,section);} |
161 | | -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) |
162 | | -context.modules.$toc.scrollTop(scrollTop+relTop);else if(relTop+sectionHeight>divHeight) |
163 | | -context.modules.$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':'auto','right':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.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','top':'auto'});context.fn.trigger('resize');}).prev().animate({'marginRight':(parseFloat(openWidth)*-1)},'fast').children().animate({'marginRight':openWidth},'fast');$.cookie('wikiEditor-'+context.instance+'-toc-width',context.modules.$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;} |
| 160 | +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) |
| 161 | +context.modules.toc.$toc.scrollTop(scrollTop+relTop);else if(relTop+sectionHeight>divHeight) |
| 162 | +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':'auto','right':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','top':'auto'});context.fn.trigger('resize');}).prev().animate({'marginRight':(parseFloat(openWidth)*-1)},'fast').children().animate({'marginRight':openWidth},'fast');$.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;} |
164 | 163 | sections[sections.length]=outline[i];}else if(outline[i].nLevel<level){break;}} |
165 | 164 | return sections;} |
166 | 165 | function buildList(structure){var list=$('<ul />');for(i in structure){var div=$('<div />').addClass('section-'+structure[i].index).data('wrapper',structure[i].wrapper).click(function(event){context.fn.scrollToTop($(this).data('wrapper'));context.$textarea.textSelection('setSelection',{'start':0,'startContainer':$(this).data('wrapper')});if(typeof $.trackAction!='undefined') |
— | — | @@ -167,10 +166,10 @@ |
168 | 167 | div.html(' ');var item=$('<li />').append(div);if(structure[i].sections!==undefined){item.append(buildList(structure[i].sections));} |
169 | 168 | list.append(item);} |
170 | 169 | return list;} |
171 | | -function buildCollapseControls(){var $collapseControl=$('<div />'),$expandControl=$('<div />');$collapseControl.addClass('tab').addClass('tab-toc').append('<a href="#" />').bind('click.wikiEditor-toc',function(){context.modules.$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.trigger('expand.wikiEditor-toc');return false;}).hide().find('a').text(gM('wikieditor-toc-show'));$collapseControl.insertBefore(context.modules.$toc);context.$ui.find('.wikiEditor-ui-left .wikiEditor-ui-top').append($expandControl);} |
172 | | -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.minimumWidth)){context.modules.$toc.trigger('collapse');}else{context.modules.$toc.data('openWidth',ui.size.width);$.cookie('wikiEditor-'+context.instance+'-toc-width',ui.size.width);} |
173 | | -context.fn.trigger('resize');}});context.$ui.find('.ui-resizable-e').removeClass('ui-resizable-e').addClass('ui-resizable-w').addClass('wikiEditor-ui-toc-resize-grip');context.modules.$toc.bind('collapse.wikiEditor-toc',$.wikiEditor.modules.toc.fn.collapse).bind('expand.wikiEditor-toc',$.wikiEditor.modules.toc.fn.expand);context.modules.$toc.data('openWidth',$.wikiEditor.modules.toc.defaultWidth);if($.cookie('wikiEditor-'+context.instance+'-toc-width')==0){context.modules.$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.minimumWidth)) |
174 | | -initialWidth=parseFloat($.wikiEditor.modules.toc.minimumWidth)+1;context.modules.$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');}} |
| 170 | +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);} |
| 171 | +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.minimumWidth)){context.modules.toc.$toc.trigger('collapse');}else{context.modules.toc.$toc.data('openWidth',ui.size.width);$.cookie('wikiEditor-'+context.instance+'-toc-width',ui.size.width);} |
| 172 | +context.fn.trigger('resize');}});context.$ui.find('.ui-resizable-e').removeClass('ui-resizable-e').addClass('ui-resizable-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.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.minimumWidth)) |
| 173 | +initialWidth=parseFloat($.wikiEditor.modules.toc.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');}} |
175 | 174 | var outline=[],h=0;function traverseTextNodes(){if(this.nodeName!='#text'){$(this.childNodes).each(traverseTextNodes);return;} |
176 | 175 | var text=this.nodeValue;var p=this;while(!p.previousSibling) |
177 | 176 | p=p.parentNode;var prev=p?p.previousSibling:null;p=this;while(p&&!p.nextSibling) |
— | — | @@ -190,22 +189,22 @@ |
191 | 190 | if(nLevel<=0){nLevel=1;} |
192 | 191 | outline[i].nLevel=nLevel;lastLevel=outline[i].level;} |
193 | 192 | var structure=buildStructure(outline);if($('input[name=wpSection]').val()==''){structure.unshift({'text':wgPageName.replace(/_/g,' '),'level':1,'index':0,'wrapper':context.$content});} |
194 | | -context.modules.$toc.html(buildList(structure));if(wgNavigableTOCResizable&&!context.$ui.data('resizableDone')){buildResizeControls();buildCollapseControls();} |
195 | | -context.modules.$toc.find('div').autoEllipse({'position':'right','tooltip':true});context.data.outline=outline;}}};$.ui.plugin.add("resizable","preventPositionLeftChange",{resize:function(event,ui){$(this).data("resizable").position.left=0;}});})(jQuery);(function($){$.wikiEditor.modules.toolbar={api:{addToToolbar:function(context,data){for(type in data){switch(type){case'sections':var $sections=context.modules.$toolbar.find('div.sections');var $tabs=context.modules.$toolbar.find('div.tabs');for(section in data[type]){if(section=='main'){context.modules.$toolbar.prepend($.wikiEditor.modules.toolbar.fn.buildSection(context,section,data[type][section]));continue;} |
| 193 | +context.modules.toc.$toc.html(buildList(structure));if(wgNavigableTOCResizable&&!context.$ui.data('resizableDone')){buildResizeControls();buildCollapseControls();} |
| 194 | +context.modules.toc.$toc.find('div').autoEllipse({'position':'right','tooltip':true});context.data.outline=outline;}}};$.ui.plugin.add("resizable","preventPositionLeftChange",{resize:function(event,ui){$(this).data("resizable").position.left=0;}});})(jQuery);(function($){$.wikiEditor.modules.toolbar={api:{addToToolbar:function(context,data){for(type in data){switch(type){case'sections':var $sections=context.modules.toolbar.$toolbar.find('div.sections');var $tabs=context.modules.toolbar.$toolbar.find('div.tabs');for(section in data[type]){if(section=='main'){context.modules.toolbar.$toolbar.prepend($.wikiEditor.modules.toolbar.fn.buildSection(context,section,data[type][section]));continue;} |
196 | 195 | $sections.append($.wikiEditor.modules.toolbar.fn.buildSection(context,section,data[type][section]));$tabs.append($.wikiEditor.modules.toolbar.fn.buildTab(context,section,data[type][section]));$section=$sections.find('.section:visible');if($section.size()){$sections.animate({'height':$section.outerHeight()},'fast');}} |
197 | 196 | break;case'groups':if(!('section'in data)){continue;} |
198 | | -var $section=context.modules.$toolbar.find('div[rel='+data.section+'].section');for(group in data[type]){$section.append($.wikiEditor.modules.toolbar.fn.buildGroup(context,group,data[type][group]));} |
| 197 | +var $section=context.modules.toolbar.$toolbar.find('div[rel='+data.section+'].section');for(group in data[type]){$section.append($.wikiEditor.modules.toolbar.fn.buildGroup(context,group,data[type][group]));} |
199 | 198 | break;case'tools':if(!('section'in data&&'group'in data)){continue;} |
200 | | -var $group=context.modules.$toolbar.find('div[rel='+data.section+'].section '+'div[rel='+data.group+'].group');for(tool in data[type]){$group.append($.wikiEditor.modules.toolbar.fn.buildTool(context,tool,data[type][tool]));} |
| 199 | +var $group=context.modules.toolbar.$toolbar.find('div[rel='+data.section+'].section '+'div[rel='+data.group+'].group');for(tool in data[type]){$group.append($.wikiEditor.modules.toolbar.fn.buildTool(context,tool,data[type][tool]));} |
201 | 200 | break;case'pages':if(!('section'in data)){continue;} |
202 | | -var $pages=context.modules.$toolbar.find('div[rel='+data.section+'].section .pages');var $index=context.modules.$toolbar.find('div[rel='+data.section+'].section .index');for(page in data[type]){$pages.append($.wikiEditor.modules.toolbar.fn.buildPage(context,page,data[type][page]));$index.append($.wikiEditor.modules.toolbar.fn.buildBookmark(context,page,data[type][page]));} |
| 201 | +var $pages=context.modules.toolbar.$toolbar.find('div[rel='+data.section+'].section .pages');var $index=context.modules.toolbar.$toolbar.find('div[rel='+data.section+'].section .index');for(page in data[type]){$pages.append($.wikiEditor.modules.toolbar.fn.buildPage(context,page,data[type][page]));$index.append($.wikiEditor.modules.toolbar.fn.buildBookmark(context,page,data[type][page]));} |
203 | 202 | $.wikiEditor.modules.toolbar.fn.updateBookletSelection(context,page,$pages,$index);break;case'rows':if(!('section'in data&&'page'in data)){continue;} |
204 | | -var $table=context.modules.$toolbar.find('div[rel='+data.section+'].section '+'div[rel='+data.page+'].page table');for(row in data[type]){$table.append($.wikiEditor.modules.toolbar.fn.buildRow(context,data[type][row]));} |
| 203 | +var $table=context.modules.toolbar.$toolbar.find('div[rel='+data.section+'].section '+'div[rel='+data.page+'].page table');for(row in data[type]){$table.append($.wikiEditor.modules.toolbar.fn.buildRow(context,data[type][row]));} |
205 | 204 | break;case'characters':if(!('section'in data&&'page'in data)){continue;} |
206 | | -$characters=context.modules.$toolbar.find('div[rel='+data.section+'].section '+'div[rel='+data.page+'].page div');var actions=$characters.data('actions');for(character in data[type]){$characters.append($($.wikiEditor.modules.toolbar.fn.buildCharacter(data[type][character],actions)).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).parent().data('context'),$(this).parent().data('actions')[$(this).attr('rel')]);return false;}));} |
207 | | -break;default:break;}}},removeFromToolbar:function(context,data){js_log("f:removeFromToolbar");if(typeof data.section=='string'){var tab='div.tabs span[rel='+data.section+'].tab';var target='div[rel='+data.section+'].section';if(typeof data.group=='string'){target+=' div[rel='+data.group+'].group';if(typeof data.tool=='string'){target+=' div[rel='+data.tool+'].tool';}}else if(typeof data.page=='string'){var index=target+' div.index div[rel='+data.page+']';target+=' div.pages div[rel='+data.page+'].page';if(typeof data.character=='string'){target+=' a[rel='+data.character+']';}else if(typeof data.row=='number'){target+=' table tr:not(:has(th)):eq('+data.row+')';}else{context.modules.$toolbar.find(index).remove();$.wikiEditor.modules.toolbar.fn.updateBookletSelection(context,null,context.modules.$toolbar.find(target),context.modules.$toolbar.find(index));}}else{context.modules.$toolbar.find(tab).remove();} |
208 | | -js_log('target is: '+target);context.modules.$toolbar.find(target).remove();}}},evt:{resize:function(context,event){context.$ui.find('.sections').height(context.$ui.find('.sections .section:visible').outerHeight());}},fn:{create:function(context,config){if('$toolbar'in context.modules){return;} |
209 | | -context.modules.$toolbar=$('<div />').addClass('wikiEditor-ui-toolbar').attr('id','wikiEditor-ui-toolbar');$.wikiEditor.modules.toolbar.fn.build(context,config);context.$ui.find('.wikiEditor-ui-top').append(context.modules.$toolbar);},doAction:function(context,action,source){if($.trackAction!=undefined&&source.closest('.wikiEditor-ui-toolbar').size()){var rels=[];var step=source;var i=0;while(!step.hasClass('wikiEditor-ui-toolbar')){if(i>25){break;} |
| 205 | +$characters=context.modules.toolbar.$toolbar.find('div[rel='+data.section+'].section '+'div[rel='+data.page+'].page div');var actions=$characters.data('actions');for(character in data[type]){$characters.append($($.wikiEditor.modules.toolbar.fn.buildCharacter(data[type][character],actions)).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).parent().data('context'),$(this).parent().data('actions')[$(this).attr('rel')]);return false;}));} |
| 206 | +break;default:break;}}},removeFromToolbar:function(context,data){js_log("f:removeFromToolbar");if(typeof data.section=='string'){var tab='div.tabs span[rel='+data.section+'].tab';var target='div[rel='+data.section+'].section';if(typeof data.group=='string'){target+=' div[rel='+data.group+'].group';if(typeof data.tool=='string'){target+=' div[rel='+data.tool+'].tool';}}else if(typeof data.page=='string'){var index=target+' div.index div[rel='+data.page+']';target+=' div.pages div[rel='+data.page+'].page';if(typeof data.character=='string'){target+=' a[rel='+data.character+']';}else if(typeof data.row=='number'){target+=' table tr:not(:has(th)):eq('+data.row+')';}else{context.modules.toolbar.$toolbar.find(index).remove();$.wikiEditor.modules.toolbar.fn.updateBookletSelection(context,null,context.modules.toolbar.$toolbar.find(target),context.modules.toolbar.$toolbar.find(index));}}else{context.modules.toolbar.$toolbar.find(tab).remove();} |
| 207 | +js_log('target is: '+target);context.modules.toolbar.$toolbar.find(target).remove();}}},evt:{resize:function(context,event){context.$ui.find('.sections').height(context.$ui.find('.sections .section:visible').outerHeight());}},fn:{create:function(context,config){if('$toolbar'in context.modules.toolbar){return;} |
| 208 | +context.modules.toolbar.$toolbar=$('<div />').addClass('wikiEditor-ui-toolbar').attr('id','wikiEditor-ui-toolbar');$.wikiEditor.modules.toolbar.fn.build(context,config);context.$ui.find('.wikiEditor-ui-top').append(context.modules.toolbar.$toolbar);},doAction:function(context,action,source){if($.trackAction!=undefined&&source.closest('.wikiEditor-ui-toolbar').size()){var rels=[];var step=source;var i=0;while(!step.hasClass('wikiEditor-ui-toolbar')){if(i>25){break;} |
210 | 209 | i++;var rel=step.attr('rel');if(rel){rels.push(step.attr('rel'));} |
211 | 210 | step=step.parent();} |
212 | 211 | rels.reverse();var id=rels.join('.');$.trackAction(id);} |
— | — | @@ -229,13 +228,13 @@ |
230 | 229 | return html;},buildRow:function(context,row){var html='<tr>';for(cell in row){html+='<td class="cell cell-'+cell+'" valign="top"><span>'+ |
231 | 230 | $.wikiEditor.autoMsg(row[cell],['html','text'])+'</span></td>';} |
232 | 231 | html+='</tr>';return html;},buildCharacter:function(character,actions){if(typeof character=='string'){character={'label':character,'action':{'type':'encapsulate','options':{'pre':character}}};}else if(0 in character&&1 in character){character={'label':character[0],'action':{'type':'encapsulate','options':{'pre':character[1]}}};} |
233 | | -if('action'in character&&'label'in character){actions[character.label]=character.action;return'<a rel="'+character.label+'" href="#">'+character.label+'</a>';}},buildTab:function(context,id,section){var selected=$.cookie('wikiEditor-'+context.instance+'-toolbar-section');return $('<span />').attr({'class':'tab tab-'+id,'rel':id}).append($('<a />').addClass(selected==id?'current':null).attr('href','#').text($.wikiEditor.autoMsg(section,'label')).data('context',context).bind('mouseup',function(e){$(this).blur();}).bind('click',function(e){var $sections=$(this).data('context').$ui.find('.sections');var $section=$(this).data('context').$ui.find('.section-'+$(this).parent().attr('rel'));var show=$section.css('display')=='none';$previousSections=$section.parent().find('.section:visible');var dH=$previousSections.outerHeight();$previousSections.css('position','absolute');$previousSections.fadeOut('fast',function(){$(this).css('position','relative');});$(this).parent().parent().find('a').removeClass('current');$sections.css('overflow','hidden');if(show){$section.fadeIn('fast');dH=$section.outerHeight()-dH;if(context.modules.$toc){context.modules.$toc.animate({'height':"+="+dH},$section.outerHeight()*2);} |
234 | | -$sections.animate({'height':$section.outerHeight()},$section.outerHeight()*2,function(){$(this).css('overflow','visible').css('height','auto');});$(this).addClass('current');}else{$sections.css('height',$section.outerHeight()).animate({'height':0},$section.outerHeight()*2,function(){$(this).css('overflow','visible');});if(context.modules.$toc){context.modules.$toc.animate({'height':"-="+$section.outerHeight()},$section.outerHeight()*2);}} |
| 232 | +if('action'in character&&'label'in character){actions[character.label]=character.action;return'<a rel="'+character.label+'" href="#">'+character.label+'</a>';}},buildTab:function(context,id,section){var selected=$.cookie('wikiEditor-'+context.instance+'-toolbar-section');return $('<span />').attr({'class':'tab tab-'+id,'rel':id}).append($('<a />').addClass(selected==id?'current':null).attr('href','#').text($.wikiEditor.autoMsg(section,'label')).data('context',context).bind('mouseup',function(e){$(this).blur();}).bind('click',function(e){var $sections=$(this).data('context').$ui.find('.sections');var $section=$(this).data('context').$ui.find('.section-'+$(this).parent().attr('rel'));var show=$section.css('display')=='none';$previousSections=$section.parent().find('.section:visible');var dH=$previousSections.outerHeight();$previousSections.css('position','absolute');$previousSections.fadeOut('fast',function(){$(this).css('position','relative');});$(this).parent().parent().find('a').removeClass('current');$sections.css('overflow','hidden');if(show){$section.fadeIn('fast');dH=$section.outerHeight()-dH;if('toc'in context.modules){context.modules.toc.$toc.animate({'height':"+="+dH},$section.outerHeight()*2);} |
| 233 | +$sections.animate({'height':$section.outerHeight()},$section.outerHeight()*2,function(){$(this).css('overflow','visible').css('height','auto');});$(this).addClass('current');}else{$sections.css('height',$section.outerHeight()).animate({'height':0},$section.outerHeight()*2,function(){$(this).css('overflow','visible');});if('toc'in context.modules){context.modules.toc.$toc.animate({'height':"-="+$section.outerHeight()},$section.outerHeight()*2);}} |
235 | 234 | if($.trackAction!=undefined){$.trackAction($section.attr('rel')+'.'+(show?'show':'hide'));} |
236 | 235 | $.cookie('wikiEditor-'+$(this).data('context').instance+'-toolbar-section',show?$section.attr('rel'):null);return false;}));},buildSection:function(context,id,section){context.$textarea.trigger('wikiEditor-toolbar-buildSection-'+id,[section]);var selected=$.cookie('wikiEditor-'+context.instance+'-toolbar-section');var $section;switch(section.type){case'toolbar':var $section=$('<div />').attr({'class':'toolbar section section-'+id,'rel':id});if('groups'in section){for(group in section.groups){$section.append($.wikiEditor.modules.toolbar.fn.buildGroup(context,group,section.groups[group]));}} |
237 | 236 | break;case'booklet':var $pages=$('<div />').addClass('pages');var $index=$('<div />').addClass('index');if('pages'in section){for(page in section.pages){$pages.append($.wikiEditor.modules.toolbar.fn.buildPage(context,page,section.pages[page]));$index.append($.wikiEditor.modules.toolbar.fn.buildBookmark(context,page,section.pages[page]));}} |
238 | 237 | $section=$('<div />').attr({'class':'booklet section section-'+id,'rel':id}).append($index).append($pages);$.wikiEditor.modules.toolbar.fn.updateBookletSelection(context,page,$pages,$index);break;} |
239 | 238 | if($section!==null&&id!=='main'){var show=selected==id;$section.css('display',show?'block':'none');} |
240 | 239 | 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);} |
241 | | -$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);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]));}} |
242 | | -$.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,function(){if(context.modules.$toc){context.modules.$toc.height(context.$ui.find('.wikiEditor-ui-left').outerHeight()-context.$ui.find('.tab-toc').outerHeight())}});}}});}}};})(jQuery); |
\ No newline at end of file |
| 240 | +$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.$toolbar);var $sections=$('<div />').addClass('sections').appendTo(context.modules.toolbar.$toolbar);context.modules.toolbar.$toolbar.append($('<div />').css('clear','both'));var sectionQueue=[];for(section in config){if(section=='main'){context.modules.toolbar.$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]));}} |
| 241 | +$.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,function(){if('toc'in context.modules){context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').outerHeight()-context.$ui.find('.tab-toc').outerHeight())}});}}});}}};})(jQuery); |
\ No newline at end of file |