home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2001 December / VPR0112B.ISO / NETSCAPE6 / N6Setup.exe / bin / chrome / comm.jar / content / communicator / askViewZoom.js next >
Text File  |  2001-01-12  |  2KB  |  76 lines

  1. /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  
  3.  * The contents of this file are subject to the Mozilla Public
  4.  * License Version 1.1 (the "License"); you may not use this file
  5.  * except in compliance with the License. You may obtain a copy of
  6.  * the License at http://www.mozilla.org/MPL/
  7.  * 
  8.  * Software distributed under the License is distributed on an "AS
  9.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  10.  * implied. See the License for the specific language governing
  11.  * rights and limitations under the License.
  12.  * 
  13.  * The Original Code is this file as it was released upon
  14.  * September 7, 2000.
  15.  * 
  16.  * The Initial Developer of the Original Code is Peter Annema.
  17.  * Portions created by Peter Annema are Copyright (C) 2000
  18.  * Peter Annema. All Rights Reserved.
  19.  * 
  20.  * Contributor(s):
  21.  *   Peter Annema <disttsc@bart.nl> (Original Author)
  22.  * 
  23.  * Alternatively, the contents of this file may be used under the
  24.  * terms of the GNU General Public License Version 2 or later (the
  25.  * "GPL"), in which case the provisions of the GPL are applicable 
  26.  * instead of those above.  If you wish to allow use of your 
  27.  * version of this file only under the terms of the GPL and not to
  28.  * allow others to use your version of this file under the MPL,
  29.  * indicate your decision by deleting the provisions above and
  30.  * replace them with the notice and other provisions required by
  31.  * the GPL.  If you do not delete the provisions above, a recipient
  32.  * may use your version of this file under either the MPL or the
  33.  * GPL.
  34.  */
  35.  
  36. var dialog;
  37. var args;
  38.  
  39. function onLoad() {
  40.   args = window.arguments[0];
  41.   args.zoomOK = false;
  42.  
  43.   dialog = {};
  44.   dialog.OKButton = document.getElementById("ok");
  45.  
  46.   dialog.input = document.getElementById("zoomValue");
  47.   dialog.input.value = args.value;
  48.   dialog.input.select();
  49.   dialog.input.focus();
  50.  
  51.   sizeToContent();
  52.   moveToAlertPosition();
  53.   doEnabling();
  54.   doSetOKCancel(onOK);
  55. }
  56.  
  57. function onOK() {
  58.   var zoom = parseInt(dialog.input.value);
  59.   if (!isNaN(zoom) && zoom >= args.zoomMin && zoom <= args.zoomMax) {
  60.     args.value = zoom;
  61.     args.zoomOK = true;
  62.   }
  63.   return args.zoomOK;
  64. }
  65.  
  66. function doEnabling() {
  67.   var enable = false;
  68.   if (dialog.input.value) {
  69.     var zoom = parseInt(dialog.input.value);
  70.     if (!isNaN(zoom) && zoom >= args.zoomMin && zoom <= args.zoomMax)
  71.       enable = true;
  72.   }
  73.  
  74.   dialog.OKButton.disabled = !enable;
  75. }
  76.