Hidden

Overview

This example will hide a progress meter at end of initialize process.

Screenshot

sample screenshot

And at end :

sample screenshot

Demonstration

Give it a try

Dependencies

This example requires mandatory resources :

And also but optional :

Explains step by step

The progress meter wait 200ms (line 30) between each step of 10% (line 31).
We used the absolute positionning pattern and control the progress bar's size for a better render of 'ancestor' skin (lines 32-36).

Source Code

  1. <?php
  2. /**
  3. * Simple example that hide a progress meter at end of process.
  4. *
  5. * @version    $Id: hidden.php,v 1.5 2006/05/24 08:40:35 farell Exp $
  6. * @author     Laurent Laville <pear@laurent-laville.org>
  7. * @package    HTML_Progress2
  8. * @subpackage Examples
  9. * @access     public
  10. * @example    examples/preload/hidden.php
  11. *             hidden source code
  12. * @link       http://www.laurent-laville.org/img/progress/screenshot/hidden1.png
  13. *             screenshot (Image PNG, 389x101 pixels) 694 bytes
  14. */
  15. require_once 'HTML/Progress2.php';
  16.  
  17. /**
  18. *  User process while the progress bar is visible.
  19. *
  20. *  @param int     $pValue   current value of the progress bar
  21. *  @param object  $pBar     the progress bar itself
  22. */
  23. function myFunctionHandler($pValue, &$pBar)
  24. {
  25.     // nothing to do here, except sleep a bit ... it's only a demo!
  26.     $pBar->sleep();
  27. }
  28.  
  29. $pb = new HTML_Progress2();
  30. $pb->setAnimSpeed(200);
  31. $pb->setIncrement(10);
  32. $pb->setProgressAttributes(array(
  33.     'position' => 'absolute',
  34.     'width' => 220,
  35.     'height' => 24
  36. ));
  37. $pb->setLabelAttributes('pct1', array(
  38.     'width' => 0,
  39.     'left' => 190
  40. ));
  41. $pb->setProgressHandler('myFunctionHandler');
  42. ?>
  43. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  44.     "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  45. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  46. <head>
  47. <title>Hidden preload Progress2 example</title>
  48. <style type="text/css">
  49. <!--
  50. body {
  51.     background-color: #CCCC99;
  52.     color: #996;
  53.     font-family: Verdana, Arial;
  54. }
  55.  
  56. <?php echo $pb->getStyle(); ?>
  57.  -->
  58. </style>
  59. <?php echo $pb->getScript(false); ?>
  60. </head>
  61. <body>
  62.  
  63. <?php
  64. $pb->display();
  65. $pb->run();
  66. $pb->hide();
  67. ?>
  68.  
  69. <h1>Your job is finished ! </h1>
  70. <p>The progress meter is now hidden.</p>
  71.  
  72. </body>
  73. </html>