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 / InsertRepeatingContent.js < prev    next >
Encoding:
JavaScript  |  2003-09-05  |  3.0 KB  |  124 lines

  1. // Copyright 2001, 2002, 2003 Macromedia, Inc. All rights reserved.
  2.  
  3. //---------------   GLOBAL VARIABLES   ---------------
  4.  
  5. var helpDoc = MM.HELP_insertRepeatingContent;
  6. var targetDom = null; 
  7. var abortCommand = false; //Set to true if the user cancels out of the 'save as template' dialog
  8.  
  9. var selectedRepeatingNode = null; 
  10.  
  11. //---------------     API FUNCTIONS    ---------------
  12.  
  13. function commandButtons()
  14.     {
  15.       return new Array(
  16.                       MM.BTN_OK,"okClicked()",
  17.                       MM.BTN_Cancel,"window.close()",
  18.                       MM.BTN_Help,"displayHelp()");
  19.     }
  20.  
  21.  
  22. function isDomRequired() {
  23.     return true;
  24. }
  25.  
  26. function receiveArguments()
  27.     {
  28.     targetDom = arguments[0]; 
  29.     if (!targetDom)
  30.         targetDom = dw.getDocumentDOM(); 
  31.     
  32.     if (targetDom == null)
  33.         return false; 
  34.         
  35.     abortCommand = false; 
  36.     
  37.     if (!CheckWarnNoTemplate(targetDom))
  38.         abortCommand = true; 
  39.     
  40.     var result = new Object();
  41.         
  42.     if (!canMakeTemplateContent("repeating", targetDom, result))
  43.         {
  44.         abortCommand = true; 
  45.         
  46.         if (result.status == "contained in DW4 edit")
  47.             alert(MM.MSG_SaveDW4First); 
  48.         else if (result.status == "locked")
  49.             alert(MSG_cantInsertRepeatHere); 
  50.         else
  51.             alert(MM.MSG_AlreadyEdit);
  52.         }
  53.         
  54.    var curSelNode = getUnlockedSelNode(targetDom, false); 
  55.            
  56.    if (curSelNode.tagName == "MMTEMPLATE:REPEATING" && arguments.length > 1 && arguments[1] == "useSelectedNode")
  57.         selectedRepeatingNode = curSelNode; 
  58.     } //receiveArguments
  59.  
  60.  
  61. function okClicked()
  62.     {
  63.     var curDOM = (targetDom == null) ? dw.getDocumentDOM('document') : targetDom; 
  64.  
  65.     if (stringIsAllDigits(document.theForm.name.value))
  66.         {
  67.         //parsed as a number - this is not allowed. 
  68.         alert(MSG_numberNotAllowed);
  69.         return; 
  70.         }
  71.  
  72.     if (selectedRepeatingNode != null)
  73.         {        
  74.         if (selectedRepeatingNode.name == document.theForm.name.value)
  75.             {
  76.             window.close();
  77.             return;             
  78.             }
  79.         
  80.         if (findNamedRepeatingRegion(document.theForm.name.value, curDOM) != null)    
  81.             {
  82.             alert(MSG_alreadyExists_Repeat);
  83.             return; 
  84.             }        
  85.             
  86.         curDOM.syncronizeDocument();     
  87.         curDOM.disableLocking(); 
  88.         selectedRepeatingNode.name = document.theForm.name.value;            
  89.         curDOM.enableLocking(); 
  90.         
  91.         window.close();
  92.         }
  93.     else if (doInsertRepeat(document.theForm.name.value, targetDom))
  94.         window.close();
  95.     }
  96.     
  97. function canAcceptCommand()
  98.     {
  99.     return (dw.getDocumentDOM('document') != null && dw.getFocus() != 'browser' && dw.getDocumentDOM().getParseMode() == 'html');
  100.     } //canAcceptCommand
  101.  
  102.     
  103. //---------------    LOCAL FUNCTIONS   ---------------
  104.  
  105.  
  106. function initializeUI()
  107.     {
  108.     if (abortCommand)
  109.         {
  110.         window.close();
  111.         return; 
  112.         }
  113.         
  114.    if (selectedRepeatingNode != null)
  115.         document.theForm.name.value = selectedRepeatingNode.name; 
  116.     else
  117.         document.theForm.name.value = getUniqueRegionName(MM.RepeatAutonamePreamble, "MMTemplate:Repeat",  dw.getDocumentDOM('document'));
  118.         
  119.       document.theForm.name.focus(); //set focus on textbox
  120.       document.theForm.name.select(); //set insertion point into textbox
  121.     } //initializeUI
  122.  
  123.  
  124.