home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 September / PCO_0998.ISO / browser / ns405lyc / netcast.z / ncjs10.jar / dialog.js < prev    next >
Encoding:
JavaScript  |  1998-03-06  |  3.1 KB  |  153 lines

  1. /*
  2.  * dialog.js
  3.  * 
  4.  * Copyright (c) 1997 Netscape Communications Corporation, All Rights Reserved
  5.  * 
  6.  * Utility functions for dealing with dialog boxes in Netcaster
  7.  */
  8.  
  9. /* Globals */
  10.  
  11. var gTabShowing = "";
  12.  
  13. /* Display utilities */
  14.  
  15. /* ShowTab  
  16.  * 
  17.  * In : the name of the pane (layer) to display
  18.  *
  19.  * Out: None
  20.  *
  21.  * ShowTab uses layers to implement a tabbed dialog box
  22.  * 
  23.  * Each tabbed area should have two layers, one which is the set to the
  24.  * size of the display area (beneath the tab) and one which is the tab
  25.  * itself, positioned at the correct location it would occur in the
  26.  * unopened state.  The tab layer should named with the name of the
  27.  * content area, plus the word "Tab".  So if there were a "general" pane,
  28.  * its tab layer would be named "generalTab".
  29.  
  30.  * The tab's onclick behavior should call showTab with the name of the pane to
  31.  * display (in the above example, "General").
  32.  */
  33.  
  34. function showTab(tabName)
  35. {
  36.     var tabLayerName;
  37.  
  38.     if (gTabShowing == tabName) {
  39.         return;
  40.     }
  41.  
  42.     if (gTabShowing != "") {
  43.         var tabLayerName = gTabShowing + "Tab";
  44.         
  45.         if (document.layers[gTabShowing].document.hiding) {
  46.             if (!document.layers[gTabShowing].document.hiding())
  47.                 return;
  48.         }
  49.  
  50.         document.layers[gTabShowing].visibility="hide";
  51.  
  52.         if ( document.layers[gTabShowing].hideChildren )
  53.           document.layers[gTabShowing].hideChildren();
  54.  
  55.         document.layers[tabLayerName].clip.height -= 3;
  56.         document.layers[tabLayerName].y += 2;
  57.         document.layers[tabLayerName].clip.width -= 2;
  58.     }
  59.  
  60.     document.layers[tabName].visibility="show";
  61.     if ( document.layers[tabName].showChildren )
  62.       document.layers[tabName].showChildren();
  63.  
  64.     tabLayerName = tabName + "Tab";
  65.     document.layers[tabLayerName].y -= 2;
  66.     document.layers[tabLayerName].clip.height += 3;
  67.  
  68.     if (gTabShowing != "") {
  69.         document.layers[tabLayerName].clip.width += 2;
  70.     }
  71.  
  72.     gTabShowing = tabName;
  73.  
  74.     if (document.layers[gTabShowing].document.showing) {
  75.         document.layers[gTabShowing].document.showing();
  76.     }
  77.  
  78.     return;
  79. }
  80.  
  81.  
  82.  
  83. /* Interaction utilities */
  84.  
  85. function handleHelp(topic)
  86. {
  87.     if ((topic == null) || (topic == ""))
  88.         topic = "net_main_about";
  89.  
  90.     self.location.href = "nethelp:netscape/netcastr:" + topic;
  91. }
  92.  
  93.  
  94. // handleCancel simply dismisses the dialog, optionally calling
  95. // a callback function.
  96.  
  97.  
  98. function handleCancel()
  99. {
  100.     if (self.closing && self.closing != null) {
  101.         self.closing();
  102.     }
  103.  
  104.     self.close();
  105. }
  106.  
  107.  
  108. /* Data validation utilities */
  109.  
  110. function trimString(jsString)
  111. {
  112.     var    tempStr = new java.lang.String(jsString);
  113.     tempStr.trim();
  114.  
  115.     return tempStr.toString();
  116. }
  117.  
  118. function fieldEmpty(field)
  119. {
  120.     if ((field == null) || (field.value == null) || (field.value == ""))
  121.         return true;
  122.  
  123.     var tempStr = trimString(field.value);
  124.  
  125.     if (tempStr == "")
  126.         return true;
  127.     
  128.     return false;
  129. }
  130.  
  131.  
  132. /* Test functions */
  133.  
  134. function getKey(e)
  135. {
  136.     alert("The key: " + e.which);
  137.  
  138. }
  139.  
  140. function getDrag(e)
  141. {
  142.     var    fileNames = e.data;
  143.  
  144.     alert("File: " + e.data[0]);
  145.     for (var i=0; i< fileNames.length; i++) {
  146.         alert("Dragged: fileNames[0]");
  147.     }
  148.  
  149.     return false;
  150.  
  151. }
  152.  
  153. void(0);