Index: trunk/extensions/Storyboard/api/ApiQueryStories.php |
— | — | @@ -6,6 +6,7 @@ |
7 | 7 | * @ingroup Storyboard |
8 | 8 | * |
9 | 9 | * @author Jeroen De Dauw |
| 10 | + * @author Roan Kattouw |
10 | 11 | * |
11 | 12 | * This program is free software; you can redistribute it and/or modify |
12 | 13 | * it under the terms of the GNU General Public License as published by |
Index: trunk/extensions/Storyboard/tags/Storyboard/storyboard.js |
— | — | @@ -2,14 +2,6 @@ |
3 | 3 | * JavaScript added for <storyboard> tags |
4 | 4 | */ |
5 | 5 | |
6 | | -$j( document ).ready( function(){ |
7 | | - $j( '#storyboard' ).ajaxScroll( { |
8 | | - updateBatch: updateStoryboard, |
9 | | - batchSize: 5, |
10 | | - batchNum: 1 |
11 | | - } ); |
12 | | -}); |
13 | | - |
14 | 6 | function updateStoryboard( $storyboard ){ |
15 | 7 | $j.getJSON( wgScriptPath + '/api.php', |
16 | 8 | { |
Index: trunk/extensions/Storyboard/tags/Storyboard/Storyboard_body.php |
— | — | @@ -7,6 +7,7 @@ |
8 | 8 | * @ingroup Storyboard |
9 | 9 | * |
10 | 10 | * @author Jeroen De Dauw |
| 11 | + * @author Roan Kattouw |
11 | 12 | */ |
12 | 13 | |
13 | 14 | if ( !defined( 'MEDIAWIKI' ) ) { |
— | — | @@ -16,23 +17,33 @@ |
17 | 18 | class TagStoryboard { |
18 | 19 | |
19 | 20 | public static function render( $input, $args, $parser, $frame ) { |
20 | | - global $wgOut, $wgJsMimeType, $wgScriptPath, $egStoryboardScriptPath, $egStoryboardWidth, $egStoryboardHeight; |
| 21 | + global $wgOut, $wgJsMimeType, $wgScriptPath, $egStoryboardScriptPath, $egStoryboardWidth, $egStoryboardHeight, $egStoryboardsOnPage; |
21 | 22 | |
22 | | - $wgOut->addStyle( $egStoryboardScriptPath . '/tags/Storyboard/storyboard.css' ); |
23 | | - $wgOut->includeJQuery(); |
24 | | - // TODO: Combine+minfiy JS files, add switch to use combined+minified version |
25 | | - $wgOut->addScriptFile( $egStoryboardScriptPath . '/tags/Storyboard/jquery.ajaxscroll.js' ); |
26 | | - $wgOut->addScriptFile( $egStoryboardScriptPath . '/tags/Storyboard/storyboard.js' ); |
| 23 | + if (empty($egStoryboardsOnPage)) { |
| 24 | + $egStoryboardsOnPage = 0; |
| 25 | + $wgOut->addStyle( $egStoryboardScriptPath . '/tags/Storyboard/storyboard.css' ); |
| 26 | + $wgOut->includeJQuery(); |
| 27 | + // TODO: Combine+minfiy JS files, add switch to use combined+minified version |
| 28 | + $wgOut->addScriptFile( $egStoryboardScriptPath . '/tags/Storyboard/jquery.ajaxscroll.js' ); |
| 29 | + $wgOut->addScriptFile( $egStoryboardScriptPath . '/tags/Storyboard/storyboard.js' ); |
| 30 | + } |
27 | 31 | |
28 | 32 | $width = self::getDimension( $args, 'width', $egStoryboardWidth ); |
29 | 33 | $height = self::getDimension( $args, 'height', $egStoryboardHeight ); |
30 | 34 | |
| 35 | + $egStoryboardsOnPage++; |
| 36 | + |
31 | 37 | $output = Html::element( 'div', array( |
32 | 38 | 'class' => 'ajaxscroll', |
33 | | - 'id' => 'storyboard', // FIXME: Causes id conflicts for multiple <storyboard> tags |
| 39 | + 'id' => "storyboard-$egStoryboardsOnPage", |
34 | 40 | 'style' => "height: $height; width: $width;" |
35 | 41 | ) |
36 | 42 | ); |
| 43 | + |
| 44 | + $output .= <<<EOT |
| 45 | +<script type="$wgJsMimeType"> /*<![CDATA[*/ jQuery( document ).ready( function(){ jQuery( '#storyboard-$egStoryboardsOnPage' ).ajaxScroll( {updateBatch: updateStoryboard,batchSize: 5,batchNum: 1} ); });/*]]>*/ </script> |
| 46 | +EOT; |
| 47 | + |
37 | 48 | return array( $output, 'noparse' => 'true', 'isHTML' => 'true' ); |
38 | 49 | } |
39 | 50 | |