home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 October / Chip Ekim 2003.iso / prog / code / contr / setup.exe / Disk1 / data1.cab / Configuration_En / Commands / PageProperties.js < prev    next >
Encoding:
JavaScript  |  2003-07-18  |  1.6 KB  |  77 lines

  1. // Copyright 2002, 2003 Macromedia, Inc. All rights reserved.
  2.  
  3. //*************** GLOBALS  *****************
  4.  
  5.  
  6. //******************* API **********************
  7.  
  8. function commandButtons()
  9. {
  10.   var btns = new Array(BTN_OK,     "okClicked()", BTN_Cancel, "cancelClicked()");
  11.   return btns;
  12. }
  13.  
  14. //***************** LOCAL FUNCTIONS  ******************
  15.  
  16. function initializeUI()
  17. {
  18.   var pgTitleObj = findObject("pgTitle");  //find our title textbox in UI
  19.   var titleObj = getTitleObj();  //find the title tag for the current doc
  20.   if (titleObj)
  21.   {
  22.     var theTitle = titleObj.innerHTML;  //extract the title
  23.     pgTitleObj.value = theTitle;  //store title in UI
  24.   }
  25.   else
  26.   {
  27.     alert("The current document has no title tags, so we can't do this right now.");
  28.     cancelClicked();
  29.   }
  30. }
  31.  
  32.  
  33.  
  34. function okClicked()
  35. {
  36.   var pgTitleObj = findObject("pgTitle");
  37.   var titleObj = getTitleObj();  //get the title tag
  38.   var changedTitle = false;
  39.  
  40.   if (titleObj)
  41.   {
  42.     var newTitle = pgTitleObj.value;
  43.     if (titleObj.innerHTML != newTitle) //if title changed
  44.     {
  45.       titleObj.innerHTML = newTitle;  //store in doc
  46.       changedTitle = true;
  47.     }
  48.   }
  49.   window.close();
  50.   if (changedTitle) CCWorkspaceManager.getManager(dw.getDocumentDOM()).refreshPanes();
  51. }
  52.  
  53.  
  54. function cancelClicked()
  55. {
  56.   window.close();
  57. }
  58.  
  59.  
  60. //find the title tag for the current document
  61. function getTitleObj()
  62. {
  63.   var retObj = null;
  64.  
  65.   var DOM = dw.getDocumentDOM();
  66.   if (DOM)
  67.   {
  68.     var titleObjs = DOM.getElementsByTagName("TITLE");
  69.     if (titleObjs && titleObjs.length)
  70.     {
  71.       retObj = titleObjs[0];
  72.     }
  73.   }
  74.  
  75.   return retObj;
  76. }
  77.