home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Java / ScriptBuilder / NOSB30_TRIAL.exe / data1.cab / Program_Files / CompLib / scrollbar.js < prev    next >
Encoding:
Text File  |  1998-10-05  |  4.7 KB  |  118 lines

  1. function com_netobjects_scrollBarComponent( params ) {
  2.     this.statusScroll = seStatusScroll;
  3.     this.display = display;
  4.     this.clearStatusBar = ssClearStatusBar;
  5.  
  6.     this.name = (params.name+"" != "undefined" && params.name+"" != "" && params.name != null ? params.name : "scrollBarComponent1");
  7.    this.tooltip = (params.tooltip+"" != "undefined" && params.tooltip != null ? params.tooltip : "");
  8.     this.updateDuration = (params.updateDuration+"" != "undefined" && params.updateDuration != null ? params.updateDuration : 10);
  9.     this.scrollRate = (params.scrollRate+"" != "undefined" && params.scrollRate != null ? params.scrollRate : 1);
  10.     this.scrollMsg = (params.scrollMsg+"" != "undefined" && params.scrollMsg != null ? params.scrollMsg : "");
  11.     this.scrollWidth = (params.scrollWidth+"" != "undefined" && params.scrollWidth != null ? params.scrollWidth : 200);
  12.     this.scrollNewWidth = (params.scrollWidth+"" != "undefined" && params.scrollWidth != null ? params.scrollWidth : 200);
  13.  
  14.     function display() {
  15.  
  16.         window.status = this.tooltip;
  17.         setTimeout(this.name + '.display();',this.updateDuration*1000);
  18.     }
  19.  
  20.        function ssClearStatusBar() {  
  21.         window.status="";
  22.        }
  23.  
  24.     /* ======================================================================
  25.     FUNCTION:    statusScroll
  26.     
  27.     INPUT:        msg (string): the string to be displayed in the status bar
  28.                     width (integer): the number of spaces to appear between
  29.                                             the left margin of the status bar and the
  30.                                             message string, msg, when first displayed
  31.                     rate (integer): the number of milliseconds between scrolling
  32.                                     intervals
  33.     
  34.     RETURNS:        a handle to the timer;
  35.                     null if invalid parameters were entered.
  36.     
  37.     DESC:            This function scrolls a user-defined message, msg, from right to 
  38.                     left in the browser's status bar.  The message is scrolled and
  39.                     refreshed at every interval specified by the rate parameter.
  40.                     Set the width parameter to determine how far from the left side
  41.                     of the status bar to start the scrolling message.  The message
  42.                     will then scroll that many spaces from right to left until being
  43.                     "swallowed up" by the left margin, and repeat.
  44.                     
  45.                     The following example shows how to generate a scrolling message
  46.                     that will scroll 100 spaces from right to left, moving one 
  47.                     space every 50 milliseconds:
  48.                     
  49.                     statusScroll("Welcome to my site!", 100, 50);
  50.                     
  51.     PLATFORMS:    Netscape Navigator 3.01 or higher, 
  52.                     Microsoft Internet Explorer 3.02 or higher
  53.     ====================================================================== */
  54.     function seStatusScroll()
  55.     {
  56.         // Use the hidden 4th parameter to "save" the initial width during the multiple
  57.         // iterations of the function.  If it's not specified, as is the case when called
  58.         // for the first time by the user, initialize  it to the width param.  
  59.         var CWIDTH = this.scrollWidth;
  60.          var width = this.scrollNewWidth;
  61.     
  62.         var ch = " ";
  63.         var outputStr = "";
  64.         var command = "";
  65.     
  66.         // Check validity of parameters    
  67.         if (this.scrollMsg+"" == "undefined" || this.scrollMsg == null) 
  68.             return null;
  69.         if (width+"" == "undefined" || width == null) 
  70.             return null;
  71.         if (this.scrollRate+"" == "undefined" || this.scrollRate == null) 
  72.             return null;
  73.         
  74.         // If the current width is greater than the initial width,
  75.         // whittle it down.
  76.         if (width > CWIDTH) 
  77.             width--;
  78.         else if (width <= CWIDTH && width > 0) {
  79.             // If the current width is less than the initial width, 
  80.             // but still greater than zero, the message is being
  81.             // displayed between the status-bar boundaries.
  82.             
  83.             // Pad the msg string with spaces
  84.             for (var i=0 ; i < width ; i++) 
  85.                 outputStr+=" ";
  86.             outputStr += this.scrollMsg;
  87.             
  88.             // Decrement the width to keep the string moving from right to left
  89.             width--;
  90.         }
  91.         else if (width <= 0) {
  92.             // If the width is less than zero, then the string is
  93.             // being "swallowed up" but the left border of the 
  94.             // margin.  Execute the code to swallow up one character
  95.             // at a time.
  96.             if (-width < this.scrollMsg.length) {
  97.                 outputStr += this.scrollMsg.substring(-width, this.scrollMsg.length);
  98.                 width--;
  99.             }
  100.             else {
  101.                 outputStr = " ";
  102.                 width = CWIDTH;
  103.             }
  104.         } // end else if (width <= 0) 
  105.             
  106.        window.status = outputStr;
  107.     
  108.         // Set the timer to call this function with the newly decremented width
  109.         // parameter.  Continue to pass the msg and rate parameters.  Also pass
  110.         // the CWIDTH parameter so the original width is always known.  This is 
  111.         // needed to continually loop through the sequence.
  112.         this.scrollNewWidth = width;
  113.         command = this.name + ".statusScroll()";
  114.         scrollTimer = window.setTimeout(command, this.scrollRate*1000);
  115.         return outputStr;
  116.     
  117.     }     // end statusScroll
  118. }