xpfe/global/resources/content/unix/printjoboptions.js - Revision 1.2

There were 17 changes made.
Legend
   Added lines
   Changed lines
   Removed lines

xpfe/global/resources/content/unix/printjoboptions.js,1.2
.
Disk File
Skipping to line 37. 
 * the terms of any one of the NPL, the GPL or the LGPL.
.
 * the terms of any one of the NPL, the GPL or the LGPL.
 *
.
 *
 * ***** END LICENSE BLOCK ***** */
.
 * ***** END LICENSE BLOCK ***** */
 
.
 
var dialog;
.
var dialog;
var printService       = null;
.
var gPrintSettings      = null;
 
.
 
var default_command    = "lpr";
.
var default_command    = "lpr";
var gPrintOptInterface = Components.interfaces.nsIPrintOptions;
.
var gPrintSetInterface = Components.interfaces.nsIPrintSettings;
var doDebug            = false;
.
var doDebug            = true;
 
.
 
//---------------------------------------------------
.
//---------------------------------------------------
function initDialog()
.
function initDialog()
{
.
{
  dialog = new Object;
.
  dialog = new Object;
Skipping to line 53. 
  dialog.cmdLabel        = document.getElementById("cmdLabel");
.
  dialog.cmdLabel        = document.getElementById("cmdLabel");
 
.
 
  dialog.colorGroup      = document.getElementById("colorGroup");
.
  dialog.colorGroup      = document.getElementById("colorGroup");
  dialog.colorRadio      = document.getElementById("colorRadio");
.
  dialog.colorRadio      = document.getElementById("colorRadio");
  dialog.grayRadio       = document.getElementById("grayRadio");
.
  dialog.grayRadio       = document.getElementById("grayRadio");
 
.
 
  dialog.paperGroup      = document.getElementById("paperGroup");
.
 
  dialog.a4Radio         = document.getElementById("a4Radio");
.
 
  dialog.a3Radio         = document.getElementById("a3Radio");
.
 
  dialog.letterRadio     = document.getElementById("letterRadio");
.
 
  dialog.legalRadio      = document.getElementById("legalRadio");
.
 
  dialog.exectiveRadio   = document.getElementById("exectiveRadio");
.
 
  
.
 
  dialog.orientationGroup = document.getElementById("orientationGroup");
.
 
  dialog.portraitRadio    = document.getElementById("portraitRadio");
.
 
  dialog.landscapeRadio   = document.getElementById("landscapeRadio");
.
 
 
.
 
  dialog.topInput        = document.getElementById("topInput");
.
 
  dialog.bottomInput     = document.getElementById("bottomInput");
.
 
  dialog.leftInput       = document.getElementById("leftInput");
.
 
  dialog.rightInput      = document.getElementById("rightInput");
.
 
 
.
 
  dialog.cmdInput        = document.getElementById("cmdInput");
.
  dialog.cmdInput        = document.getElementById("cmdInput");
 
.
 
  dialog.enabled         = false;
.
  dialog.enabled         = false;
}
.
}
 
.
 
Skipping to line 74. 
    if (!stringIn) stringIn = "";
.
    if (!stringIn) stringIn = "";
    editField.value = stringIn;
.
    editField.value = stringIn;
  }
.
  }
}
.
}
 
.
 
//---------------------------------------------------
.
//---------------------------------------------------
function stripTrailingWhitespace(element)
.
 
{
.
 
  var stringIn = element.value;
.
 
  stringIn = stringIn.replace(/\s+$/,"");
.
 
  element.value = stringIn;
.
 
}
.
 
 
.
 
//---------------------------------------------------
.
 
function getDoubleStr( val, dec )
.
 
{
.
 
  var str = val.toString();
.
 
  var inx = str.indexOf(".");
.
 
  return str.substring(0, inx+dec+1);
.
 
}
.
 
 
.
 
//---------------------------------------------------
.
 
function loadDialog()
.
function loadDialog()
{
.
{
  var print_color         = true;
.
  var print_color         = true;
  var print_paper_size    = 0;
.
 
  var print_orientation   = 0;
.
 
  var print_margin_top    = 0.5;
.
 
  var print_margin_left   = 0.5;
.
 
  var print_margin_bottom = 0.5;
.
 
  var print_margin_right  = 0.5;
.
 
  var print_command       = default_command;
.
  var print_command       = default_command;
 
.
 
  try {
.
  if (gPrintSettings) {
    printService = Components.classes["@mozilla.org/gfx/printoptions;1"];
.
    print_color     = gPrintSettings.printInColor;
    if (printService) {
.
    print_command   = gPrintSettings.printCommand;
      printService = printService.getService();
.
 
      if (printService) {
.
 
        printService = printService.QueryInterface(Components.interfaces.nsIPr
intOptions);
.
 
 
      }
.
 
    }
.
 
  } catch(e) {}
.
 
 
.
 
  if (printService) {
.
 
    print_color      = printService.printInColor;
.
 
    print_paper_size = printService.paperSize;
.
 
    print_orientation = printService.orientation;
.
 
 
.
 
    print_margin_top    = printService.marginTop;
.
 
    print_margin_left   = printService.marginLeft;
.
 
    print_margin_right  = printService.marginRight;
.
 
    print_margin_bottom = printService.marginBottom;
.
 
 
.
 
    print_command   = printService.printCommand;
.
 
  }
.
  }
 
.
 
  if (doDebug) {
.
  if (doDebug) {
 
.
    dump("loadDialog******************************\n");
    dump("printInColor  "+print_color+"\n");
.
    dump("printInColor  "+print_color+"\n");
    dump("paperSize     "+print_paper_size+"\n");
.
 
    dump("orientation   "+print_orientation+"\n");
.
 
    dump("printCommand  "+print_command+"\n");
.
    dump("printCommand  "+print_command+"\n");
 
.
 
    dump("print_margin_top    "+print_margin_top+"\n");
.
 
    dump("print_margin_left   "+print_margin_left+"\n");
.
 
    dump("print_margin_right  "+print_margin_right+"\n");
.
 
    dump("print_margin_bottom "+print_margin_bottom+"\n");
.
 
  }
.
  }
 
.
 
  if (print_command == "") {
.
  if (print_command == "") {
    print_command = default_command;
.
    print_command = default_command;
  }
.
  }
Skipping to line 100. 
  if ( print_color) {
.
  if ( print_color) {
    dialog.colorGroup.selectedItem = dialog.colorRadio;
.
    dialog.colorGroup.selectedItem = dialog.colorRadio;
  } else {
.
  } else {
    dialog.colorGroup.selectedItem = dialog.grayRadio;
.
    dialog.colorGroup.selectedItem = dialog.grayRadio;
  }
.
  }
 
.
 
  if ( print_paper_size == gPrintOptInterface.kLetterPaperSize ) {
.
 
    dialog.paperGroup.selectedItem = dialog.letterRadio;
.
 
  } else if ( print_paper_size == gPrintOptInterface.kLegalPaperSize ) {
.
 
    dialog.paperGroup.selectedItem = dialog.legalRadio;
.
 
  } else if ( print_paper_size == gPrintOptInterface.kExecutivePaperSize ) {
.
 
    dialog.paperGroup.selectedItem = dialog.exectiveRadio;
.
 
  } else if ( print_paper_size == gPrintOptInterface.kA4PaperSize ) {
.
 
    dialog.paperGroup.selectedItem = dialog.a4Radio;
.
 
  } else if ( print_paper_size == gPrintOptInterface.kA3PaperSize ) {
.
 
    dialog.paperGroup.selectedItem = dialog.a3Radio;
.
 
  }
.
 
 
.
 
  if ( print_orientation == gPrintOptInterface.kPortraitOrientation ) {
.
 
    dialog.orientationGroup.selectedItem = dialog.portraitRadio;
.
 
  } else  if ( print_orientation == gPrintOptInterface.kLandscapeOrientation )
 {
.
 
 
    dialog.orientationGroup.selectedItem = dialog.landscapeRadio;
.
 
  }
.
 
 
.
 
  dialog.topInput.value    = getDoubleStr(print_margin_top, 1);
.
 
  dialog.bottomInput.value = getDoubleStr(print_margin_bottom, 1);
.
 
  dialog.leftInput.value   = getDoubleStr(print_margin_left, 1);
.
 
  dialog.rightInput.value  = getDoubleStr(print_margin_right, 1);
.
 
 
.
 
  dialog.cmdInput.value    = print_command;
.
  dialog.cmdInput.value    = print_command;
}
.
}
 
.
 
var param;
.
var param;
 
.
 
Skipping to line 112. 
function onLoad()
.
function onLoad()
{
.
{
  // Init dialog.
.
  // Init dialog.
  initDialog();
.
  initDialog();
 
.
 
  param = window.arguments[0].QueryInterface(Components.interfaces.nsIDialogPa
ramBlock);
.
  var ps = window.arguments[0].QueryInterface(gPrintSetInterface);
 
  if( !param ) {
.
  if (ps != null) {
    return;
.
    gPrintSettings = ps;
 
 
.
    paramBlock = window.arguments[1].QueryInterface(Components.interfaces.nsID
ialogParamBlock);
 
.
  }
 
.
 
 
.
  if (doDebug) {
 
.
    if (ps == null) alert("PrintSettings is null!");
 
.
    if (paramBlock == null) alert("nsIDialogParam is null!");
  }
.
  }
 
.
 
  param.SetInt(0, 1 );
.
  paramBlock.SetInt(0, 0 );
 
.
 
  loadDialog();
.
  loadDialog();
}
.
}
 
.
 
//---------------------------------------------------
.
//---------------------------------------------------
Skipping to line 135. 
{
.
{
  var print_paper_size = 0;
.
  if (gPrintSettings != null) {
 
.
    gPrintSettings.printInColor = dialog.colorRadio.selected;
  if (printService) {
.
    gPrintSettings.printCommand = dialog.cmdInput.value;
    printService.printInColor  = dialog.colorRadio.selected;
.
    if (doDebug) {
 
.
      dump("onAccept******************************\n");
    if (dialog.letterRadio.selected) {
.
      dump("printInColor  "+gPrintSettings.printInColor+"\n");
      print_paper_size = gPrintOptInterface.kLetterPaperSize;
.
      dump("printCommand  "+gPrintSettings.printCommand+"\n");
    } else if (dialog.legalRadio.selected) {
.
 
      print_paper_size = gPrintOptInterface.kLegalPaperSize;
.
 
    } else if (dialog.exectiveRadio.selected) {
.
 
      print_paper_size = gPrintOptInterface.kExecutivePaperSize;
.
 
    } else if (dialog.a4Radio.selected) {
.
 
      print_paper_size = gPrintOptInterface.kA4PaperSize;
.
 
    } else if (dialog.a3Radio.selected) {
.
 
      print_paper_size = gPrintOptInterface.kA3PaperSize;
.
 
    }
.
 
    printService.paperSize = print_paper_size;
.
 
    
.
 
    var print_orientation;
.
 
    if (dialog.portraitRadio.selected) {
.
 
      print_orientation = gPrintOptInterface.kPortraitOrientation;
.
 
    } else if (dialog.landscapeRadio.selected) {
.
 
      print_orientation = gPrintOptInterface.kLandscapeOrientation;
.
 
    }
.
    }
    printService.orientation = print_orientation;
.
 
 
.
 
    // save these out so they can be picked up by the device spec
.
 
    printService.marginTop    = dialog.topInput.value;
.
 
    printService.marginLeft   = dialog.leftInput.value;
.
 
    printService.marginBottom = dialog.bottomInput.value;
.
 
    printService.marginRight  = dialog.rightInput.value;
.
 
 
.
 
    printService.printCommand = dialog.cmdInput.value;
.
 
 
.
 
  } else {
.
  } else {
    dump("************ printService: "+printService+"\n");
.
    dump("************ onAccept gPrintSettings: "+gPrintSettings+"\n");
  }
.
  }
 
.
 
  if (param) {
.
  if (param) {
    param.SetInt(0, 0 );
.
    param.SetInt(0, 1 );
  }
.
  }
 
.
 
  return true;
.
  return true;
}
.
}
 
.
 
Skipping to line 156. 
function onCancel()
.
function onCancel()
{
.
{
  if (param) {
.
  if (param) {
    param.SetInt(0, 1 );
.
    param.SetInt(0, 0 );
  }
.
  }
  return true;
.
  return true;
}
.
}
 
.