home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Complet / thunderbird / chrome / mail.jar / content / editor / EdSnapToGrid.js < prev    next >
Encoding:
JavaScript  |  2003-06-25  |  2.3 KB  |  80 lines

  1. /* 
  2.  * The contents of this file are subject to the Netscape Public
  3.  * License Version 1.1 (the "License"); you may not use this file
  4.  * except in compliance with the License. You may obtain a copy of
  5.  * the License at http://www.mozilla.org/NPL/
  6.  *  
  7.  * Software distributed under the License is distributed on an "AS
  8.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  9.  * implied. See the License for the specific language governing
  10.  * rights and limitations under the License.
  11.  *  
  12.  * The Original Code is Mozilla Communicator client code, released
  13.  * March 31, 1998.
  14.  * 
  15.  * The Initial Developer of the Original Code is Netscape
  16.  * Communications Corporation. Portions created by Netscape are
  17.  * Copyright (C) 1998-1999 Netscape Communications Corporation. All
  18.  * Rights Reserved.
  19.  * 
  20.  * Contributor(s): 
  21.  */
  22.  
  23. var gPrefs = GetPrefs();
  24. var gEditor;
  25.  
  26. // dialog initialization code
  27. function Startup()
  28. {
  29.   gEditor = GetCurrentEditor();
  30.   if (!gEditor)
  31.   {
  32.     window.close();
  33.     return;
  34.   }
  35.  
  36.   gEditor instanceof Components.interfaces.nsIHTMLAbsPosEditor;
  37.  
  38.   gDialog.enableSnapToGrid = document.getElementById("enableSnapToGrid");
  39.   gDialog.sizeInput        = document.getElementById("size");
  40.   gDialog.sizeLabel        = document.getElementById("sizeLabel");
  41.   gDialog.unitLabel        = document.getElementById("unitLabel");
  42.  
  43.   // Initialize control values based on existing attributes
  44.   InitDialog()
  45.  
  46.   // SET FOCUS TO FIRST CONTROL
  47.   SetTextboxFocus(gDialog.sizeInput);
  48.  
  49.   // Resize window
  50.   window.sizeToContent();
  51.  
  52.   SetWindowLocation();
  53. }
  54.  
  55. // Set dialog widgets with attribute data
  56. // We get them from globalElement copy so this can be used
  57. //   by AdvancedEdit(), which is shared by all property dialogs
  58. function InitDialog()
  59. {
  60.   gDialog.enableSnapToGrid.checked = gEditor.snapToGridEnabled;
  61.   toggleSnapToGrid();
  62.  
  63.   gDialog.sizeInput.value = gEditor.gridSize;
  64. }
  65.  
  66. function onAccept()
  67. {
  68.   gEditor.snapToGridEnabled = gDialog.enableSnapToGrid.checked;
  69.   gEditor.gridSize = gDialog.sizeInput.value;
  70.  
  71.   return true;
  72. }
  73.  
  74. function toggleSnapToGrid()
  75. {
  76.   SetElementEnabledById("size", gDialog.enableSnapToGrid.checked)
  77.   SetElementEnabledById("sizeLabel", gDialog.enableSnapToGrid.checked)
  78.   SetElementEnabledById("unitLabel", gDialog.enableSnapToGrid.checked)
  79. }
  80.