home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 July / 07_02.iso / software / mdmx / files / DreamweaverMXInstaller.exe / Disk1 / data1.cab / Configuration_En / Commands / ServerObject-RSNavStats.js < prev    next >
Encoding:
JavaScript  |  2002-05-01  |  6.3 KB  |  258 lines

  1. // Copyright 2001-2002 Macromedia, Inc. All rights reserved.
  2.  
  3. // *************** GLOBALS VARS *****************
  4.  
  5. var helpDoc = MM.HELP_objRecordsetStatistics;
  6.  
  7. var _RecordsetName = new EditableRecordsetMenu("RSStatsFirst.htm", "RecordsetName", "");
  8.  
  9. var LIMIT_RECORDSET = false;
  10.  
  11. //******************* API **********************
  12.  
  13. //--------------------------------------------------------------------
  14. // FUNCTION:
  15. //   canInsertObject
  16. //
  17. // DESCRIPTION:
  18. //   This function is called to determine if this object can be inserted
  19. //   into the current document.  It displays the relevant error messages,
  20. //   and then returns a boolean to indicate if insertion is possible.
  21. //
  22. //   NOTE: this function is called before initializeUI, so it should
  23. //         not rely on internal state.
  24. //
  25. // ARGUMENTS:
  26. //   none
  27. //
  28. // RETURNS:
  29. //   boolean
  30. //--------------------------------------------------------------------
  31.  
  32. function canInsertObject()
  33. {
  34.   var retVal = true;
  35.   
  36.   var errMsgStr = "";
  37.   var isServerObject = true;
  38.   
  39.   if (errMsgStr)
  40.   {
  41.     alert (errMsgStr);
  42.     retVal = false;
  43.   }
  44.   
  45.   return retVal;
  46. }
  47.  
  48.  
  49. //--------------------------------------------------------------------
  50. // FUNCTION:
  51. //   commandButtons
  52. //
  53. // DESCRIPTION:
  54. //   Returns the list of buttons which should appear on the right hand
  55. //   side of the dialog
  56. //
  57. // ARGUMENTS:
  58. //   none
  59. //
  60. // RETURNS:
  61. //   Array - pairs of button name and function call
  62. //--------------------------------------------------------------------
  63.  
  64. function commandButtons()
  65. {
  66.    return new Array(MM.BTN_OK,     "clickedOK()",
  67.                     MM.BTN_Cancel, "clickedCancel()",
  68.                     MM.BTN_Help,   "displayHelp()");
  69. }
  70.  
  71.  
  72. //--------------------------------------------------------------------
  73. // FUNCTION:
  74. //   clickedOK
  75. //
  76. // DESCRIPTION:
  77. //   This function is called when the user clicks OK
  78. //
  79. // ARGUMENTS:
  80. //   none
  81. //
  82. // RETURNS:
  83. //   nothing
  84. //--------------------------------------------------------------------
  85.  
  86. function clickedOK()
  87. {
  88.   var rsName = _RecordsetName.getValue();
  89.   
  90.   if (rsName)
  91.   {
  92.     // check if a page navigation repeat region exists for this recordset
  93.     dwscripts.warnIfNoPageNavDisplay(rsName,true);
  94.         
  95.     // Build up the insertion string, and then apply a doc edit    
  96.     var paramObj = new Object();
  97.     
  98.     paramObj["RecordsetName"] = rsName;
  99.        
  100.     if (!LIMIT_RECORDSET)
  101.     {
  102.       paramObj.MM_familyDefaults = new Object();
  103.       paramObj.MM_familyDefaults.PageSize = 10;
  104.     }
  105.     else
  106.     {
  107.       var sbRecordset = dwscripts.getServerBehaviorByParam("Recordset.htm","RecordsetName",paramObj["RecordsetName"]);
  108.       if (sbRecordset)
  109.       {
  110.         var newRS = sbRecordset.makeEditableCopy();
  111.         newRS.setDefaultPageSize();
  112.         newRS.queueDocEdits();
  113.       }
  114.     }
  115.     
  116.     // Get the language specific display strings
  117.     if (dw.appVersion && dw.appVersion.indexOf('ja') != -1)  // Japanese version?
  118.     {
  119.       var charSet = dw.getDocumentDOM().getCharSet().toLowerCase();
  120.       if (charSet == "shift_jis" || 
  121.           charSet == "x-sjis" || 
  122.           charSet == "euc-jp" || 
  123.           charSet == "iso-2022-jp") 
  124.       {
  125.         paramObj.beforeFirst = MM.LABEL_RSNavBeforeFirst;
  126.         paramObj.beforeLast  = MM.LABEL_RSNavBeforeLast;
  127.         paramObj.beforeTotal = MM.LABEL_RSNavBeforeTotal;
  128.         paramObj.afterTotal  = MM.LABEL_RSNavAfterTotal;
  129.       } 
  130.       else // not a japanese document so we will use English to prevent corruption
  131.       {
  132.         paramObj.beforeFirst = MM.LABEL_EngRSNavBeforeFirst;
  133.         paramObj.beforeLast  = MM.LABEL_EngRSNavBeforeLast;
  134.         paramObj.beforeTotal = MM.LABEL_EngRSNavBeforeTotal;
  135.         paramObj.afterTotal  = MM.LABEL_EngRSNavAfterTotal;
  136.       }
  137.     } 
  138.     else 
  139.     {
  140.       paramObj.beforeFirst = dwscripts.entityNameEncode(MM.LABEL_RSNavBeforeFirst);
  141.       paramObj.beforeLast  = dwscripts.entityNameEncode(MM.LABEL_RSNavBeforeLast);
  142.       paramObj.beforeTotal = dwscripts.entityNameEncode(MM.LABEL_RSNavBeforeTotal);
  143.       paramObj.afterTotal  = dwscripts.entityNameEncode(MM.LABEL_RSNavAfterTotal);
  144.     }
  145.     
  146.     dwscripts.fixUpSelection(dw.getDocumentDOM(), false, true);
  147.     dwscripts.applyGroup("RSNavStats", paramObj);
  148.     
  149.     window.close();
  150.   }
  151.   else
  152.   {
  153.     alert(dwscripts.sprintf(MM.MSG_invalidRS, dwscripts.getRecordsetDisplayName()));
  154.   }
  155. }
  156.  
  157.  
  158. //--------------------------------------------------------------------
  159. // FUNCTION:
  160. //   clickedCancel
  161. //
  162. // DESCRIPTION:
  163. //   This function is called when CANCEL is clicked
  164. //
  165. // ARGUMENTS:
  166. //   none
  167. //
  168. // RETURNS:
  169. //   nothing
  170. //--------------------------------------------------------------------
  171.  
  172. function clickedCancel()
  173. {
  174.   window.close();
  175. }
  176.  
  177.  
  178. //--------------------------------------------------------------------
  179. // FUNCTION:
  180. //   displayHelp
  181. //
  182. // DESCRIPTION:
  183. //   This function is called when the user clicks the HELP button
  184. //
  185. // ARGUMENTS:
  186. //   none
  187. //
  188. // RETURNS:
  189. //   nothing
  190. //--------------------------------------------------------------------
  191.  
  192. function displayHelp()
  193. {
  194.   dwscripts.displayDWHelp(helpDoc);
  195. }
  196.  
  197.  
  198. //***************** LOCAL FUNCTIONS  ******************
  199.  
  200. //--------------------------------------------------------------------
  201. // FUNCTION:
  202. //   initializeUI
  203. //
  204. // DESCRIPTION:
  205. //   This function is called in the onLoad event.  It is responsible
  206. //   for initializing the UI.
  207. //
  208. // ARGUMENTS:
  209. //   none
  210. //
  211. // RETURNS:
  212. //   nothing
  213. //--------------------------------------------------------------------
  214.  
  215. function initializeUI()
  216. {
  217.   var args = dwscripts.getCommandArguments();
  218.   var obj = dwscripts.findDOMObject("RecordsetName");
  219.   if (args && obj)
  220.   {
  221.     if (args.editableRecordset)
  222.     {
  223.       obj.setAttribute("editable","true");
  224.     }
  225.     else
  226.     {
  227.       obj.removeAttribute("editable");
  228.     }
  229.   }
  230.   
  231.   if (args)
  232.   {
  233.     LIMIT_RECORDSET = args.limitRecordset;
  234.   }
  235.   
  236.   // Display the example text
  237.   var spanObj = dwscripts.findDOMObject("exampleSpan");
  238.   
  239.   if (spanObj)
  240.   {
  241.     spanObj.innerHTML = MM.LABEL_RSNavExampleText;
  242.   }
  243.  
  244.   // Build Recordset menu
  245.   _RecordsetName.initializeUI();
  246.   
  247.   var rsToPick = dwscripts.getRecordsetNameWithPageNav();
  248.   if (rsToPick)
  249.   {
  250.     _RecordsetName.pickValue(rsToPick);
  251.   }
  252.   
  253.   if (obj)
  254.   {
  255.     obj.focus();
  256.   }
  257. }
  258.