Index: trunk/extensions/SmoothGallery/SmoothGallery.php |
— | — | @@ -34,6 +34,8 @@ |
35 | 35 | |
36 | 36 | $wgHooks['BeforePageDisplay'][] = 'addSmoothGalleryJavascriptAndCSS'; |
37 | 37 | |
| 38 | +$wgSmoothGalleryExtensionPath = $wgScriptPath . '/extensions/SmoothGallery'; //sane default |
| 39 | + |
38 | 40 | function wfSmoothGallery() { |
39 | 41 | global $wgParser; |
40 | 42 | |
— | — | @@ -206,7 +208,7 @@ |
207 | 209 | } |
208 | 210 | |
209 | 211 | //Open the outer div of the gallery |
210 | | - $output = '<div id="' . $name . '" class="myGallery" style="width: ' . $width . ';height: ' . $height . '">'; |
| 212 | + $output = '<div id="' . $name . '" class="myGallery" style="width: ' . $width . ';height: ' . $height . '; display:none;">'; |
211 | 213 | |
212 | 214 | //Expand templates in the input |
213 | 215 | $input = $parser->replaceVariables( $input ); |
— | — | @@ -219,6 +221,8 @@ |
220 | 222 | //can report them later |
221 | 223 | $missing_img = ""; |
222 | 224 | |
| 225 | + $plain_gallery = new ImageGallery(); |
| 226 | + |
223 | 227 | foreach ( $img_arr as $img ) { |
224 | 228 | //Get the image object from the database |
225 | 229 | #$img_obj = Image::newFromName( $wgContLang->ucfirst($img) ); |
— | — | @@ -288,6 +292,8 @@ |
289 | 293 | } |
290 | 294 | |
291 | 295 | $output .= '</div>'; |
| 296 | + |
| 297 | + $plain_gallery->add( $img_obj ); //TODO: use text |
292 | 298 | } |
293 | 299 | |
294 | 300 | //Make sure we have something to output |
— | — | @@ -311,10 +317,22 @@ |
312 | 318 | //Close the outer div of the gallery |
313 | 319 | $output .= '</div>'; |
314 | 320 | |
| 321 | + //Wrapper div for plain old gallery, to be shown per default, if JS is off. |
| 322 | + $output .= '<div id="' . $name . '-plain">'; |
| 323 | + |
| 324 | + $output .= $plain_gallery->toHTML(); |
| 325 | + |
| 326 | + //Close the wrappe div for the plain old gallery |
| 327 | + $output .= '</div>'; |
| 328 | + |
315 | 329 | //Output the javascript needed for the gallery with any |
316 | 330 | //options the user requested |
317 | 331 | $output .= '<script type="text/javascript">'; |
318 | | - $output .= 'function startGallery() {'; |
| 332 | + |
| 333 | + $output .= 'document.getElementById("' . $name . '-plain").style.display = "none";'; //hide plain gallery |
| 334 | + $output .= 'document.getElementById("' . $name . '").style.display = "block";'; //show smooth gallery |
| 335 | + |
| 336 | + $output .= 'function startGallery_' . $name . '() {'; |
319 | 337 | $output .= "var myGallery = new gallery($('" . $name . "'), {"; |
320 | 338 | |
321 | 339 | //A boolean to tell whether or not we need a comma before |
— | — | @@ -356,7 +374,7 @@ |
357 | 375 | |
358 | 376 | $output .= '});'; |
359 | 377 | $output .= '}'; |
360 | | - $output .= 'window.onDomReady(startGallery);'; |
| 378 | + $output .= 'addOnloadHook(startGallery_' . $name . ');'; |
361 | 379 | $output .= '</script>'; |
362 | 380 | |
363 | 381 | //Finished, let's send it out |