HTML_Progress
[ class tree: HTML_Progress ] [ index: HTML_Progress ] [ all elements ]
Prev Next
HTML_Progress_UI::setScript
sets an external JavaScript file to manage the progress meter

Synopsis

require_once 'HTML/Progress/UI.php';

void HTML_Progress_UI::setScript( string $url)

Description

This method is used to identify an external JavaScript file, that will used to replace the default internal code, to manage the progress meter.

$url is an URL that identify a JavaScript file target.

Parameter

    string $url
  • URL to the linked JavaScript file.

Throws

Possible PEAR_Error values

Error level Error code Error message Solution
exception HTML_PROGRESS_ERROR_INVALID_INPUT invalid input, parameter #1 "$url" was expecting "string|NULL" Fixed the cast of parameter
error HTML_PROGRESS_ERROR_INVALID_INPUT invalid input, parameter #1 "$url" was expecting "file exists" Give URL of a valid javascript target

Note

( HTML_Progress >= 1.0 )

This function can not be called statically.

If you have provided a custom javascript and want to revert to the built-in-behavior, set the URL back to NULL.

See

HTML_Progress_UI::getScript

Example

Example below (that requires HTML_Progress >= 1.2.0RC3) will produced a horizontal progress bar with custom cell contents (see line 23). It's a dynamic example, the progress bar will run.

  1. <?php
  2. require_once 'HTML/Progress.php';
  3.  
  4. $bar = new HTML_Progress();
  5. $bar->setAnimSpeed(100);
  6. $bar->setIncrement(10);
  7. $bar->setBorderPainted(true);
  8.  
  9. $ui =& $bar->getUI();
  10. $ui->setCellAttributes(array(
  11. 'active-color' => '#3874B4',
  12. 'inactive-color' => '#EEEECC',
  13. 'width' => 10,
  14. 'font-size' => 10
  15. ));
  16. $ui->setBorderAttributes('width=1 color=navy');
  17. $ui->setStringAttributes(array(
  18. 'width' => 60,
  19. 'font-size' => 14,
  20. 'background-color' => '#EEEEEE',
  21. 'align' => 'center'
  22. ));
  23. $ui->setScript('progress.js');
  24.  
  25. foreach (range(0,2) as $index) {
  26. $ui->setCellAttributes('color=silver', $index);
  27. }
  28. foreach (range(3,6) as $index) {
  29. $ui->setCellAttributes('color=yellow', $index);
  30. }
  31. foreach (range(7,9) as $index) {
  32. $ui->setCellAttributes('color=orange', $index);
  33. }
  34. ?>
  35. <!DOCTYPE html
  36. PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  37. "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  38.  
  39. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  40. <head>
  41. <title>setScript example</title>
  42. <style type="text/css">
  43. <!--
  44. <?php echo $bar->getStyle(); ?>
  45.  
  46. body {
  47. background-color: #EEEEEE;
  48. color: #000000;
  49. font-family: Verdana, Arial;
  50. }
  51. // -->
  52. </style>
  53. <script type="text/javascript" src="<?php echo $bar->getScript(); ?>"></script>
  54. </head>
  55. <body>
  56.  
  57. <?php
  58. echo $bar->toHtml();
  59. $bar->run();
  60. ?>
  61.  
  62. </body>
  63. </html>

Prev Up Next
HTML_Progress_UI::getScript Reference Guide HTML_Progress_UI::getStyle

Documentation generated on Sun, 12 Sep 2004 20:23:30 +0200 by phpDocumentor 1.3.0RC3