// -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ var dialog; var gPrintBundle; var gPrintSettings = null; var gPrintSettingsInterface = Components.interfaces.nsIPrintSettings; var gPaperArray; var gPlexArray; var gResolutionArray; var gColorSpaceArray; var gPrefs; var default_command = "lpr"; var gPrintSetInterface = Components.interfaces.nsIPrintSettings; var doDebug = true; //--------------------------------------------------- function checkDouble(element, maxVal) { var value = element.value; if (value && value.length > 0) { value = value.replace(/[^\.|^0-9]/g,""); if (!value) { element.value = ""; } else { if (value > maxVal) { element.value = maxVal; } else { element.value = value; } } } } //--------------------------------------------------- function isListOfPrinterFeaturesAvailable() { var has_printerfeatures = false; try { has_printerfeatures = gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".has_special_printerfeatures"); } catch(ex) { } return has_printerfeatures; } //--------------------------------------------------- function getDoubleStr(val, dec) { var str = val.toString(); var inx = str.indexOf("."); return str.substring(0, inx+dec+1); } //--------------------------------------------------- function initDialog() { gPrintBundle = document.getElementById("printBundle"); dialog = new Object; dialog.paperList = document.getElementById("paperList"); dialog.paperGroup = document.getElementById("paperGroup"); dialog.plexList = document.getElementById("plexList"); dialog.plexGroup = document.getElementById("plexGroup"); dialog.resolutionList = document.getElementById("resolutionList"); dialog.resolutionGroup = document.getElementById("resolutionGroup"); dialog.jobTitleLabel = document.getElementById("jobTitleLabel"); dialog.jobTitleGroup = document.getElementById("jobTitleGroup"); dialog.jobTitleInput = document.getElementById("jobTitleInput"); dialog.cmdLabel = document.getElementById("cmdLabel"); dialog.cmdGroup = document.getElementById("cmdGroup"); dialog.cmdInput = document.getElementById("cmdInput"); dialog.colorspaceList = document.getElementById("colorspaceList"); dialog.colorspaceGroup = document.getElementById("colorspaceGroup"); dialog.colorGroup = document.getElementById("colorGroup"); dialog.colorRadioGroup = document.getElementById("colorRadioGroup"); dialog.colorRadio = document.getElementById("colorRadio"); dialog.grayRadio = document.getElementById("grayRadio"); dialog.fontsGroup = document.getElementById("fontsGroup"); dialog.downloadFonts = document.getElementById("downloadFonts"); dialog.topInput = document.getElementById("topInput"); dialog.bottomInput = document.getElementById("bottomInput"); dialog.leftInput = document.getElementById("leftInput"); dialog.rightInput = document.getElementById("rightInput"); } //--------------------------------------------------- function round10(val) { return Math.round(val * 10) / 10; } //--------------------------------------------------- function paperListElement(aPaperListElement) { this.paperListElement = aPaperListElement; } paperListElement.prototype = { clearPaperList: function () { // remove the menupopup node child of the menulist. this.paperListElement.removeChild(this.paperListElement.firstChild); }, appendPaperNames: function (aDataObject) { var popupNode = document.createElement("menupopup"); for (var i=0;i -1) { selectElement.paperListElement.selectedIndex = selectedInx; } //dialog.paperList = selectElement; } //--------------------------------------------------- function plexListElement(aPlexListElement) { this.plexListElement = aPlexListElement; } plexListElement.prototype = { clearPlexList: function () { // remove the menupopup node child of the menulist. this.plexListElement.removeChild(this.plexListElement.firstChild); }, appendPlexNames: function (aDataObject) { var popupNode = document.createElement("menupopup"); for (var i=0;i -1) { selectElement.plexListElement.selectedIndex = selectedInx; } //dialog.plexList = selectElement; } //--------------------------------------------------- function resolutionListElement(aResolutionListElement) { this.resolutionListElement = aResolutionListElement; } resolutionListElement.prototype = { clearResolutionList: function () { // remove the menupopup node child of the menulist. this.resolutionListElement.removeChild(this.resolutionListElement.firstChild); }, appendResolutionNames: function (aDataObject) { var popupNode = document.createElement("menupopup"); for (var i=0;i -1) { selectElement.resolutionListElement.selectedIndex = selectedInx; } //dialog.resolutionList = selectElement; } //--------------------------------------------------- function colorspaceListElement(aColorspaceListElement) { this.colorspaceListElement = aColorspaceListElement; } colorspaceListElement.prototype = { clearColorspaceList: function () { // remove the menupopup node child of the menulist. this.colorspaceListElement.removeChild(this.colorspaceListElement.firstChild); }, appendColorspaceNames: function (aDataObject) { var popupNode = document.createElement("menupopup"); for (var i=0;i -1) { selectElement.colorspaceListElement.selectedIndex = selectedInx; } //dialog.colorspaceList = selectElement; } //--------------------------------------------------- function loadDialog() { var print_paper_type = 0; var print_paper_unit = 0; var print_paper_width = 0.0; var print_paper_height = 0.0; var print_paper_name = ""; var print_plex_name = ""; var print_resolution_name = ""; var print_colorspace = ""; var print_color = true; var print_downloadfonts = true; var print_command = default_command; var print_jobtitle = ""; gPrefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); if (gPrintSettings) { print_paper_type = gPrintSettings.paperSizeType; print_paper_unit = gPrintSettings.paperSizeUnit; print_paper_width = gPrintSettings.paperWidth; print_paper_height = gPrintSettings.paperHeight; print_paper_name = gPrintSettings.paperName; print_plex_name = gPrintSettings.plexName; print_resolution_name = gPrintSettings.resolutionName; print_colorspace = gPrintSettings.colorspace; print_color = gPrintSettings.printInColor; print_downloadfonts = gPrintSettings.downloadFonts; print_command = gPrintSettings.printCommand; print_jobtitle = gPrintSettings.title; } if (doDebug) { dump("loadDialog******************************\n"); dump("paperSizeType "+print_paper_unit+"\n"); dump("paperWidth "+print_paper_width+"\n"); dump("paperHeight "+print_paper_height+"\n"); dump("paperName "+print_paper_name+"\n"); dump("plexName "+print_plex_name+"\n"); dump("resolutionName "+print_resolution_name+"\n"); dump("colorspace "+print_colorspace+"\n"); dump("print_color "+print_color+"\n"); dump("print_downloadfonts "+print_downloadfonts+"\n"); dump("print_command "+print_command+"\n"); dump("print_jobtitle "+print_jobtitle+"\n"); } createPaperArray(); var paperSelectedInx = 0; for (var i=0;i