home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / ui.setscript.cls < prev    next >
Encoding:
Text File  |  2004-03-24  |  5.6 KB  |  196 lines

  1. <refentry id="{@id}">
  2.  <refnamediv>
  3.   <refname>setScript Manual</refname>
  4.   <refpurpose>defines the external JavaScript file to manage the progress bar</refpurpose>
  5.  </refnamediv>
  6.  <refsynopsisdiv>
  7.   <refsynopsisdivinfo>
  8.    <author>
  9.     by Laurent Laville
  10.     <authorblurb>{@link mailto:pear@laurent-laville.org}</authorblurb>
  11.    </author>
  12.    <copyright>November 2003, Laurent Laville</copyright>
  13.    <releaseinfo>HTML_Progress 1.0+</releaseinfo>
  14.   </refsynopsisdivinfo>
  15.  </refsynopsisdiv>
  16.  <refsect1 id="{@id synopsis}">
  17.   <title>Synopsis</title>
  18.   <para><emphasis>void</emphasis> <important>setScript</important>( $url )</para>
  19.  </refsect1>
  20.  <refsect1 id="{@id attributes}">
  21.   <title>Attributes</title>
  22.   <para>
  23.    <table frame="all">
  24.     <tgroup cols="3">
  25.     <thead align="center">
  26.       <row>
  27.        <entry><important>Name</important></entry>
  28.        <entry><important>Type</important></entry>
  29.        <entry><important>Default</important></entry>
  30.       </row>
  31.     </thead>
  32.     <tbody>
  33.      <row>
  34.       <entry><emphasis>url</emphasis> </entry>
  35.       <entry>file ressource           </entry>
  36.       <entry>Null                     </entry>
  37.      </row>
  38.     </tbody>
  39.     </tgroup>
  40.    </table>
  41.   </para>
  42.   <para>
  43.    <emphasis>$url</emphasis> is an URL that identify a JavaScript file target.
  44.   </para>
  45.  </refsect1>
  46.  <refsect1 id="{@id description}">
  47.   <title>Description</title>
  48.   <para>The <emphasis>setScript()</emphasis> method is used to identify an external JavaScript
  49.    file, that will used to replace the default internal code, to manage the progress bar.
  50.    If you have provided a custom javascript and want to revert to the built-in-behavior, 
  51.    set the URL back to null.
  52.   </para>
  53.  </refsect1>
  54.  <refsect1 id="{@id example}">
  55.   <title>Example</title>
  56.   <para>
  57.    Example below will produced a horizontal progress bar custom cell contents.
  58.    It's a dynamic example, the progress bar will run.
  59.    <para><graphic fileref="../media/screenshots/bluesandplus.png"></graphic></para>
  60.    <programlisting role="php">
  61.    <![CDATA[
  62. <?php
  63. require_once ('HTML/Progress.php');
  64.  
  65. $bar = new HTML_Progress();
  66. $bar->setIncrement(10);
  67. $bar->setBorderPainted(true);
  68.  
  69. $ui =& $bar->getUI();
  70. $ui->setCellAttributes(array(
  71.     'active-color' => '#3874B4',
  72.     'inactive-color' => '#EEEECC',
  73.     'width' => 10
  74. ));
  75. $ui->setBorderAttributes('width=1 color=navy');
  76. $ui->setStringAttributes(array(
  77.     'width' => 60,
  78.     'font-size' => 14,
  79.     'background-color' => '#EEEEEE',
  80.     'align' => 'center'
  81. ));
  82. $ui->setScript('progress.js');
  83.  
  84. foreach (range(0,2) as $index) {
  85.     $ui->setCellAttributes('color=silver', $index);
  86. }
  87. foreach (range(3,6) as $index) {
  88.     $ui->setCellAttributes('color=yellow', $index);
  89. }
  90. foreach (range(7,9) as $index) {
  91.     $ui->setCellAttributes('color=orange', $index);
  92. }
  93.  
  94. ?>
  95. <!DOCTYPE html
  96.     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  97.     "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  98.  
  99. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  100. <head>
  101. <title>Progress example</title>
  102. <style type="text/css">
  103. <!--
  104. <?php echo $bar->getStyle(); ?>
  105.  
  106. body {
  107.     background-color: #EEEEEE;
  108.     color: #000000;
  109.     font-family: Verdana, Arial;
  110. }
  111. // -->
  112. </style>
  113. <script type="text/javascript" src="<?php echo $ui->getScript(); ?>"></script>
  114. </head>
  115. <body>
  116.  
  117. <?php 
  118. echo $bar->toHtml(); 
  119.  
  120. do {
  121.     $bar->display();
  122.     if ($bar->getPercentComplete() == 1) {
  123.         break;   // the progress bar has reached 100%
  124.     }
  125.     $bar->incValue();
  126. } while(1);
  127. ?>
  128.  
  129. </body>
  130. </html>
  131.    ]]>
  132.    </programlisting>
  133.   </para>
  134.   <para><title>JavaScript external code from file progress.js</title>
  135.    <example>
  136.    <![CDATA[
  137. var isDom = document.getElementById?true:false;
  138. var isIE  = document.all?true:false;
  139. var isNS4 = document.layers?true:false;
  140. var cellCount = 10;
  141.  
  142. function setprogress(pIdent, pValue, pString, pDeterminate)
  143. {
  144.         if (isDom)
  145.             prog = document.getElementById(pIdent+'installationProgress');
  146.         if (isIE)
  147.             prog = document.all[pIdent+'installationProgress'];
  148.         if (isNS4)
  149.             prog = document.layers[pIdent+'installationProgress'];
  150.     if (prog != null) 
  151.         prog.innerHTML = pString;
  152.  
  153.         if (pValue == pDeterminate) {
  154.         for (i=0; i < cellCount; i++) {
  155.                 showCell(i, pIdent, "hidden");    
  156.             }
  157.         }
  158.         if ((pDeterminate > 0) && (pValue > 0)) {
  159.             i = (pValue-1) % cellCount;
  160.             showCell(i, pIdent, "visible");    
  161.         } else {
  162.             for (i=pValue-1; i >=0; i--) {
  163.                 showCell(i, pIdent, "visible");    
  164.                 if (isDom)
  165.                     document.getElementById(pIdent+'progressCell'+i+'A').innerHTML = i;
  166.                 if (isIE)
  167.                     document.all[pIdent+'progressCell'+i+'A'].innerHTML = i;
  168.                 if (isNS4)
  169.                     document.layers[pIdent+'progressCell'+i+'A'].innerHTML = i;
  170.             }
  171.     }
  172. }
  173.  
  174. function showCell(pCell, pIdent, pVisibility)
  175. {
  176.     if (isDom)
  177.         document.getElementById(pIdent+'progressCell'+pCell+'A').style.visibility = pVisibility;
  178.     if (isIE)
  179.         document.all[pIdent+'progressCell'+pCell+'A'].style.visibility = pVisibility;
  180.     if (isNS4)
  181.         document.layers[pIdent+'progressCell'+pCell+'A'].style.visibility = pVisibility;
  182.  
  183. }
  184.    ]]>
  185.    </example>
  186.   </para>
  187.  </refsect1>
  188.  <refsect1 id="{@id seealso}">
  189.   <title>See Also</title>
  190.   <para>
  191.    The {@link HTML_Progress_UI::getScript()} method is an easy way to build the default
  192.    internal JavaScript code, that will manage the progress bar.
  193.   </para>
  194.  </refsect1>
  195. </refentry>
  196.