home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet Web Designer 86 / PIWD86.iso / pc / contents / dreamweaver / software / dwmx2004.exe / Disk1 / data1.cab / Configuration_En / Commands / ServerObject-RSNavStats.js < prev    next >
Encoding:
JavaScript  |  2003-09-05  |  6.7 KB  |  261 lines

  1. // Copyright 2001, 2002, 2003 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 (dreamweaver.appVersion && ( (dreamweaver.appVersion.indexOf('ja') != -1) ||
  118.                                   (dreamweaver.appVersion.indexOf('ko') != -1) ||
  119.                                   (dreamweaver.appVersion.indexOf('zh') != -1) ) ) {
  120.     var charSet = dw.getDocumentDOM().getCharSet();
  121.     charSet = charSet.toLowerCase();
  122.     if (   ( (dreamweaver.appVersion.indexOf('ja') != -1) && 
  123.              (charSet == "shift_jis" || charSet == "x-sjis" || charSet == "euc-jp" || charSet == "iso-2022-jp") )
  124.         || ( (dreamweaver.appVersion.indexOf('ko') != -1) && 
  125.              (charSet == "euc-kr") )
  126.         || ( (dreamweaver.appVersion.indexOf('zh') != -1) && 
  127.              (charSet == "big5" || charSet == "gb2312") ) ) {
  128.       // Japanese, Korean and Chinese exceptions
  129.       paramObj.beforeFirst = MM.LABEL_RSNavBeforeFirst;
  130.       paramObj.beforeLast  = MM.LABEL_RSNavBeforeLast;
  131.       paramObj.beforeTotal = MM.LABEL_RSNavBeforeTotal;
  132.       paramObj.afterTotal  = MM.LABEL_RSNavAfterTotal;
  133.     } else {
  134.       // not a JA, KO, or Chinese document so we will use English to prevent corruption
  135.         paramObj.beforeFirst = MM.LABEL_EngRSNavBeforeFirst;
  136.         paramObj.beforeLast  = MM.LABEL_EngRSNavBeforeLast;
  137.         paramObj.beforeTotal = MM.LABEL_EngRSNavBeforeTotal;
  138.         paramObj.afterTotal  = MM.LABEL_EngRSNavAfterTotal;
  139.       }
  140.     } 
  141.     else 
  142.     {
  143.       paramObj.beforeFirst = dwscripts.entityNameEncode(MM.LABEL_RSNavBeforeFirst);
  144.       paramObj.beforeLast  = dwscripts.entityNameEncode(MM.LABEL_RSNavBeforeLast);
  145.       paramObj.beforeTotal = dwscripts.entityNameEncode(MM.LABEL_RSNavBeforeTotal);
  146.       paramObj.afterTotal  = dwscripts.entityNameEncode(MM.LABEL_RSNavAfterTotal);
  147.     }
  148.     
  149.     dwscripts.fixUpSelection(dw.getDocumentDOM(), false, true);
  150.     dwscripts.applyGroup("RSNavStats", paramObj);
  151.     
  152.     window.close();
  153.   }
  154.   else
  155.   {
  156.     alert(dwscripts.sprintf(MM.MSG_invalidRS, dwscripts.getRecordsetDisplayName()));
  157.   }
  158. }
  159.  
  160.  
  161. //--------------------------------------------------------------------
  162. // FUNCTION:
  163. //   clickedCancel
  164. //
  165. // DESCRIPTION:
  166. //   This function is called when CANCEL is clicked
  167. //
  168. // ARGUMENTS:
  169. //   none
  170. //
  171. // RETURNS:
  172. //   nothing
  173. //--------------------------------------------------------------------
  174.  
  175. function clickedCancel()
  176. {
  177.   window.close();
  178. }
  179.  
  180.  
  181. //--------------------------------------------------------------------
  182. // FUNCTION:
  183. //   displayHelp
  184. //
  185. // DESCRIPTION:
  186. //   This function is called when the user clicks the HELP button
  187. //
  188. // ARGUMENTS:
  189. //   none
  190. //
  191. // RETURNS:
  192. //   nothing
  193. //--------------------------------------------------------------------
  194.  
  195. function displayHelp()
  196. {
  197.   dwscripts.displayDWHelp(helpDoc);
  198. }
  199.  
  200.  
  201. //***************** LOCAL FUNCTIONS  ******************
  202.  
  203. //--------------------------------------------------------------------
  204. // FUNCTION:
  205. //   initializeUI
  206. //
  207. // DESCRIPTION:
  208. //   This function is called in the onLoad event.  It is responsible
  209. //   for initializing the UI.
  210. //
  211. // ARGUMENTS:
  212. //   none
  213. //
  214. // RETURNS:
  215. //   nothing
  216. //--------------------------------------------------------------------
  217.  
  218. function initializeUI()
  219. {
  220.   var args = dwscripts.getCommandArguments();
  221.   var obj = dwscripts.findDOMObject("RecordsetName");
  222.   if (args && obj)
  223.   {
  224.     if (args.editableRecordset)
  225.     {
  226.       obj.setAttribute("editable","true");
  227.     }
  228.     else
  229.     {
  230.       obj.removeAttribute("editable");
  231.     }
  232.   }
  233.   
  234.   if (args)
  235.   {
  236.     LIMIT_RECORDSET = args.limitRecordset;
  237.   }
  238.   
  239.   // Display the example text
  240.   var spanObj = dwscripts.findDOMObject("exampleSpan");
  241.   
  242.   if (spanObj)
  243.   {
  244.     spanObj.innerHTML = MM.LABEL_RSNavExampleText;
  245.   }
  246.  
  247.   // Build Recordset menu
  248.   _RecordsetName.initializeUI();
  249.   
  250.   var rsToPick = dwscripts.getRecordsetNameWithPageNav();
  251.   if (rsToPick)
  252.   {
  253.     _RecordsetName.pickValue(rsToPick);
  254.   }
  255.   
  256.   if (obj)
  257.   {
  258.     obj.focus();
  259.   }
  260. }
  261.