From dd0c537ce15b94c9b24cfa9ee3b8ab623303b826 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Mon, 4 Sep 2006 22:57:23 +0000 Subject: [PATCH] closes #267, MODS export option uses an rdf extension (should be xml) thanks to Dan for the idea --- .../content/scholar/exportOptions.js | 110 +++++++++++++----- .../content/scholar/exportOptions.xul | 11 +- .../content/scholar/fileInterface.js | 44 ++----- .../content/scholar/ingester/browser.js | 5 +- .../content/scholar/xpcom/translate.js | 65 +++++------ .../locale/en-US/scholar/scholar.dtd | 2 + 6 files changed, 139 insertions(+), 98 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/exportOptions.js b/chrome/chromeFiles/content/scholar/exportOptions.js index bcb3dc0d4..c4e55c77a 100644 --- a/chrome/chromeFiles/content/scholar/exportOptions.js +++ b/chrome/chromeFiles/content/scholar/exportOptions.js @@ -7,9 +7,8 @@ // Class to provide options for export var Scholar_File_Interface_Export = new function() { - var _options; - this.init = init; + this.updateOptions = updateOptions; this.accept = accept; this.cancel = cancel; @@ -17,29 +16,80 @@ var Scholar_File_Interface_Export = new function() { * add options to export */ function init() { - _options = window.arguments[0].options; + var addedOptions = new Object(); - // add options to dialog - var dialog = document.getElementById("scholar-export-options"); - for(var option in _options) { - var defValue = _options[option]; + var translators = window.arguments[0].translators; + + var listbox = document.getElementById("format-popup"); + var formatMenu = document.getElementById("format-menu"); + var optionsBox = document.getElementById("translator-options"); + + // add styles to list + for(i in translators) { + var itemNode = document.createElement("menuitem"); + itemNode.setAttribute("label", translators[i].label); + listbox.appendChild(itemNode); - // get readable name for option - try { - var optionLabel = Scholar.getString("exportOptions."+option); - } catch(e) { - var optionLabel = option; + // add options + for(var option in translators[i].displayOptions) { + if(!addedOptions[option]) { // if this option is not already + // presented to the user + // get readable name for option + try { + var optionLabel = Scholar.getString("exportOptions."+option); + } catch(e) { + var optionLabel = option; + } + + // right now, option interface supports only boolean values, which + // it interprets as checkboxes + if(typeof(translators[i].displayOptions[option]) == "boolean") { + var checkbox = document.createElement("checkbox"); + checkbox.setAttribute("id", "export-option-"+option); + checkbox.setAttribute("label", optionLabel); + optionsBox.appendChild(checkbox); + } + + addedOptions[option] = true; + } } + } + + // select first item by default + if(formatMenu.selectedIndex == -1) { + formatMenu.selectedIndex = 0; + } + + updateOptions(); + } + + /* + * update translator-specific options + */ + function updateOptions() { + // get selected translator + var index = document.getElementById("format-menu").selectedIndex; + var translatorOptions = window.arguments[0].translators[index].displayOptions; + + var optionsBox = document.getElementById("translator-options"); + for(var i=0; i