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
-
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chrome/chromeFiles/content/scholar/fileInterface.js b/chrome/chromeFiles/content/scholar/fileInterface.js
index d704da4b8..f8846e809 100644
--- a/chrome/chromeFiles/content/scholar/fileInterface.js
+++ b/chrome/chromeFiles/content/scholar/fileInterface.js
@@ -15,27 +15,24 @@ var Scholar_File_Interface = new function() {
var translation = new Scholar.Translate("export");
var translators = translation.getTranslators();
+ // present options dialog
+ var io = {translators:translators}
+ window.openDialog("chrome://scholar/content/exportOptions.xul",
+ "_blank", "chrome,modal,centerscreen", io);
+ if(!io.selectedTranslator) {
+ return false;
+ }
+
const nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(nsIFilePicker);
fp.init(window, Scholar.getString("fileInterface.export"), nsIFilePicker.modeSave);
- // set file name and extension.
+ // set file name and extension
name = (name ? name : Scholar.getString("pane.collections.library"));
- fp.defaultString = name+"."+translators[0].target;
-
- // add save filters
- for(var i in translators) {
- var label = translators[i].label;
-
- // put extensions in parentheses if Mac (Windows users already
- // get extension)
- label += " (."+translators[i].target+")";
-
- fp.appendFilter(label, "*."+translators[i].target);
- }
-
+ fp.defaultString = name+"."+io.selectedTranslator.target;
+ fp.appendFilter(io.selectedTranslator.label, "*."+io.selectedTranslator.target);
var rv = fp.show();
if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) {
@@ -43,8 +40,7 @@ var Scholar_File_Interface = new function() {
translation.setItems(items);
}
translation.setLocation(fp.file);
- translation.setTranslator(translators[fp.filterIndex]);
- translation.setHandler("options", _exportOptions);
+ translation.setTranslator(io.selectedTranslator);
translation.setHandler("done", _exportDone);
_disableUnresponsive();
Scholar_File_Interface.Progress.show(
@@ -89,22 +85,6 @@ var Scholar_File_Interface = new function() {
exportFile(Scholar.getString("fileInterface.exportedItems"), items);
}
- /*
- * closes items exported indicator
- */
- function _exportOptions(obj, options) {
- var io = {options:options}
- window.openDialog("chrome://scholar/content/exportOptions.xul",
- "_blank","chrome,modal,centerscreen", io);
- if(io.options) {
- // refocus dialog
- Scholar_File_Interface.Progress.show();
- return options;
- } else {
- return false;
- }
- }
-
/*
* closes items exported indicator
*/
diff --git a/chrome/chromeFiles/content/scholar/ingester/browser.js b/chrome/chromeFiles/content/scholar/ingester/browser.js
index b0f12fcc8..92e5df757 100644
--- a/chrome/chromeFiles/content/scholar/ingester/browser.js
+++ b/chrome/chromeFiles/content/scholar/ingester/browser.js
@@ -180,10 +180,7 @@ Scholar_Ingester_Interface.showPopup = function(collectionID, parentElement) {
return false; // Don't dynamically reload popups that are already showing
}
Scholar_Ingester_Interface._scrapePopupShowing = true;
-
- while(parentElement.hasChildNodes()) {
- parentElement.removeChild(parentElement.firstChild);
- }
+ parentElement.removeAllItems();
if(collectionID == null) { // show library
var newItem = document.createElement("menuitem");
diff --git a/chrome/chromeFiles/content/scholar/xpcom/translate.js b/chrome/chromeFiles/content/scholar/xpcom/translate.js
index f1ce1a754..d485a2f9b 100644
--- a/chrome/chromeFiles/content/scholar/xpcom/translate.js
+++ b/chrome/chromeFiles/content/scholar/xpcom/translate.js
@@ -246,6 +246,14 @@ Scholar.Translate.prototype.setString = function(string) {
this._storagePointer = 0;
}
+/*
+ * sets translator display options. you can also pass a translator (not ID) to
+ * setTranslator that includes a displayOptions argument
+ */
+Scholar.Translate.prototype.setDisplayOptions = function(displayOptions) {
+ this._setDisplayOptions = displayOptions;
+}
+
/*
* sets the translator to be used for import/export
*
@@ -256,8 +264,14 @@ Scholar.Translate.prototype.setTranslator = function(translator) {
throw("cannot set translator: invalid value");
}
+ this._setDisplayOptions = null;
+
if(typeof(translator) == "object") { // passed an object and not an ID
if(translator.translatorID) {
+ if(translator.displayOptions) {
+ this._setDisplayOptions = translator.displayOptions;
+ }
+
translator = [translator.translatorID];
} else {
// we have an associative array of translators
@@ -303,12 +317,6 @@ Scholar.Translate.prototype.setTranslator = function(translator) {
*
* as the first argument, all handlers will be passed the current function. the
* second argument is dependent on the handler.
- *
- * options
- * valid: export
- * called: when options requiring user interaction are available
- * passed: an associative array of options and default values
- * returns: an associative array of options
*
* select
* valid: web
@@ -372,22 +380,16 @@ Scholar.Translate.prototype.getTranslators = function() {
var translators = Scholar.DB.query(sql);
}
- if(!this.location && !this.search) {
- return translators; // no need to see which can translate, because
- // we don't have a location yet (for export or
- // import dialog)
- } else {
- // create a new sandbox
- this._generateSandbox();
-
- var possibleTranslators = new Array();
- Scholar.debug("searching for translators for "+this.path);
-
- // see which translators can translate
- var possibleTranslators = this._findTranslators(translators);
-
- return possibleTranslators;
- }
+ // create a new sandbox
+ this._generateSandbox();
+
+ var possibleTranslators = new Array();
+ Scholar.debug("searching for translators for "+(this.path ? this.path : "an undisclosed location"));
+
+ // see which translators can translate
+ var possibleTranslators = this._findTranslators(translators);
+
+ return possibleTranslators;
}
/*
@@ -408,6 +410,9 @@ Scholar.Translate.prototype._findTranslators = function(translators, ignoreExten
label:translators[i].label,
target:translators[i].target,
itemType:translators[i].itemType}
+ if(this.type == "export") {
+ translator.displayOptions = this._displayOptions;
+ }
possibleTranslators.push(translator);
}
@@ -471,24 +476,16 @@ Scholar.Translate.prototype.translate = function() {
return;
}
+ if(this._setDisplayOptions) {
+ this._displayOptions = this._setDisplayOptions;
+ }
+
if(this._storage) {
// enable reading from storage, which we can't do until the translator
// is loaded
this._storageFunctions(true);
}
- // hack to see if there are any options, bc length does not work on objects
- if(this.type == "export") {
- for(var i in this._displayOptions) {
- // run handler for options if there are any
- if(!(this._displayOptions = this._runHandler("options", this._displayOptions))) {
- this._translationComplete(true);
- return false;
- }
- break;
- }
- }
-
var returnValue;
if(this.type == "web") {
returnValue = this._web();
diff --git a/chrome/chromeFiles/locale/en-US/scholar/scholar.dtd b/chrome/chromeFiles/locale/en-US/scholar/scholar.dtd
index 966a80c0c..37184fc64 100644
--- a/chrome/chromeFiles/locale/en-US/scholar/scholar.dtd
+++ b/chrome/chromeFiles/locale/en-US/scholar/scholar.dtd
@@ -64,6 +64,8 @@
+
+